Ejemplo n.º 1
0
HappinessState Pet::GetHappinessState()
{
    if (GetPower(POWER_HAPPINESS) < HAPPINESS_LEVEL_SIZE)
        return UNHAPPY;
    else if (GetPower(POWER_HAPPINESS) >= HAPPINESS_LEVEL_SIZE * 2)
        return HAPPY;
    else
        return CONTENT;
}
Ejemplo n.º 2
0
void Creature::RegenerateHealth()
{
    uint32 curValue = GetHealth();
    uint32 maxValue = GetMaxHealth();

    if (curValue >= maxValue) return;

    float HealthIncreaseRate = sWorld.getRate(RATE_HEALTH);

    float Spirit = GetStat(STAT_SPIRIT);

    if( HealthIncreaseRate <= 0 ) HealthIncreaseRate = 1;

    uint32 addvalue = 0;

    if(isPet())
    {
        if( GetPower(POWER_MANA) > 0 )
            addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate);
        else
            addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate);
    }
    else
        addvalue = maxValue/3;

    ModifyHealth(addvalue);
}
Ejemplo n.º 3
0
void Vehicle::RegeneratePower(Powers power)
{
    uint32 curValue = GetPower(power);
    uint32 maxValue = GetMaxPower(power);

    if (curValue >= maxValue)
        return;

    float addvalue = 0.0f;

    // hack: needs more research of power type from the dbc. 
    // It must contains some info about vehicles like Salvaged Chopper.
    if(m_vehicleInfo->m_powerType == POWER_TYPE_PYRITE)
        return;

    addvalue = 10.0f;

    ModifyPower(power, (int32)addvalue);

    for(int i =0; i != MAX_SEAT; i++)
    {
        if(Unit *pPassanger = GetPassenger(i))
        {
            if(pPassanger->GetTypeId() == TYPEID_PLAYER)
                SendCreateUpdateToPlayer((Player*)pPassanger);
        }
    }

}
Ejemplo n.º 4
0
//______________________________________________________________________________
double ConvertVoltageFrom_Vp_to_dBm(double v_p){
   double R      = 50.;                 // 50-Ohm impedance  
   double P      = GetPower(R,v_p); 
   double P_1mW  = 1E-3; 
   double G_dBm  = 10.*log(P/P_1mW); 
   return G_dBm;  
}
Ejemplo n.º 5
0
inline bool MtgCard::operator==(const MtgCard& rhs) {
    return GetLayout() == rhs.GetLayout() &&
            GetManacost() == rhs.GetManacost() &&
            GetCmc() == rhs.GetCmc() &&
            CompareStringList(GetColors(), rhs.GetColors()) &&
            type == rhs.type &&
            CompareStringList(GetSupertypes(), rhs.GetSupertypes()) &&
            CompareStringList(GetTypes(), rhs.GetTypes()) &&
            CompareStringList(GetSubtypes(), rhs.GetSubtypes()) &&
            GetRarity() == rhs.GetRarity() &&
            text == rhs.GetText() &&
            GetFlavor() == rhs.GetFlavor() &&
            GetArtist() == rhs.GetArtist() &&
            GetNumber() == rhs.GetNumber() &&
            GetPower() == rhs.GetPower() &&
            GetToughness() == rhs.GetToughness() &&
            GetLoyalty() == rhs.GetLoyalty() &&
            GetMultiverseid() == rhs.GetMultiverseid() &&
            CompareIntList(GetVariations(), rhs.GetVariations()) &&
            GetImageName() == rhs.GetImageName() &&
            GetWatermark() == rhs.GetWatermark() &&
            GetBorder() == rhs.GetBorder() &&
            IsTimeshifted() == rhs.IsTimeshifted() &&
            GetHand() == rhs.GetHand() &&
            GetLife() == rhs.GetLife() &&
            IsReserved() == rhs.IsReserved() &&
            GetReleasedate() == rhs.GetReleasedate() &&
            IsStarter() == rhs.IsStarter() &&
            CompareStringPairList(GetRulings(), rhs.GetRulings()) &&
            CompareStringPairList(GetForeignNames(), rhs.GetForeignNames()) &&
            GetOriginalText() == rhs.GetOriginalText() &&
            GetOriginalType() == rhs.GetOriginalType() &&
            CompareStringPairList(GetLegalities(), rhs.GetLegalities()) &&
            GetEdition() == rhs.GetEdition();
}
Ejemplo n.º 6
0
float Sniper::Shot(Game_Manager* gm_, Unit* User_, int team_, const coord_def& start_, const coord_def& pos_, float focus_)
{
	float angle_ = GetAngleToTarget(start_, pos_);
	if(UseBullet(1))
	{
		for(int i = 0;i<bunch;i++)
		{
			float focus2_ = rand_float(-focus_, focus_,"Sniper::Shot focus");
			if(User_->GetSniper())
				focus2_ = 0;
			float speed2_ = shot_speed*GetShotSpeedApply()*rand_float(0.8f, 1.2f, "Sniper::Shot speed");
			float damage_ =  damage*GetDamegeApply()*(User_?User_->GetAtkApply():1.0f);
			gm_->shot_list.push_back(new Shot_sniper(&tex_gun, User_, damage_, sniper, GetPower(), GetMaxPower(), team_, start_, angle_+focus2_, GetDistance(), 50));
		}
		if (gm_->isPlayerCanHear(GetPos()))
		{
			if(GetType() == WT_SILENCE || User_->GetSilencer() != 1.0f)
				PlaySE(se_silencesnipergun);
			else
				PlaySE(se_snipergun);
		}
		gm_->Noise(team_,start_,GetNoise() * User_->GetSilencer());
		return burst_speed*(1.0f/(GetBurstSpeedApply()*(User_?User_->GetAtkSpdApply():1.0f)));
	}
	return -1;
}
Ejemplo n.º 7
0
void Vehicle::RegeneratePower(Powers power)
{
    uint32 curValue = GetPower(power);
    uint32 maxValue = GetMaxPower(power);

    if (curValue >= maxValue)
        return;

    float addvalue = 0.0f;

    // hack: needs more research of power type from the dbc. 
    // It must contains some info about vehicles like Salvaged Chopper.
    if(m_vehicleInfo->m_powerType == POWER_TYPE_PYRITE)
        return;

    addvalue = 10.0;

    ModifyPower(power, (int32)addvalue);

    WorldPacket data(SMSG_POWER_UPDATE);
    data << GetPackGUID();
    data << uint8(power);
    data << uint32(addvalue+curValue);
    SendMessageToSet(&data, true);
}
Ejemplo n.º 8
0
//______________________________________________________________________________
double ConvertVoltageFrom_Vpp_to_dBm(double v_pp){
   double v_p    = ConvertVoltageFrom_Vpp_to_Vp(v_pp); 
   double R      = 50.; 
   double P      = GetPower(R,v_p); 
   double P_1mW  = 1E-3; 
   double G_dBm  = 10.*log(P/P_1mW); 
   return G_dBm;  
}
Ejemplo n.º 9
0
double MapAnalysis::GetPowerRank(const CityData * city) const
{
    Assert(city);
    PLAYER_INDEX owner = city->GetOwner();
    double power = GetPower(owner, city->GetHomeCity().RetPos());
    double max_power = GetMaxPower(owner);

    return (max_power > 0.0) ? (power / max_power) : 0.0;
}
Ejemplo n.º 10
0
int main()
{
	char powerfile[]="Power.txt";
	GetPower(powerfile);

	/*
	 * 声明基底中的变量
	 */
	double Vbase(0);//初始化 @Vbase
	double Ibase(0);
	double Rbase(r_conduct+r_fan);//初始化基底的热阻
	double ebase(0);//初始化基底的热容中的电流源部分
	double rbase(h/(2*c_conduct));//初始化基底的热容中的热阻部分=h/2c

	double rtmp=Pararlle(Rbase,rbase);//计算Vbase时用到的热阻并联和
	double Itmp(0);


	double Vref;
	double eps(1);
	double compareVbase;

	std::ofstream out("Trace.txt");
	if(not out)
		std::perror("Trace.txt failed!");

	do//begin loop!
	{
		Vref=Vbase;
		/*
		* 刷新@Vbase以及@ebase
		*/

		Itmp=SumPower+ebase;//计算@Itmp,需要每次刷新

		Vbase=rtmp*Itmp;//刷新@Vcore,@Vbase的值
		compareVbase=ChargeLine(SumPower,Rbase,c_conduct,IterNumber++);

		Ibase=SumPower-Vbase/Rbase;//刷新@Ibase,@ebase的值

		ebase=Vbase/rbase+Ibase;//计算@ebase,需要每次刷新


		out<<std::setw(SetWidth)<<std::setprecision(SetPrecision)<<Vbase<<"\t";
		//out<<std::setw(SetWidth)<<std::setprecision(SetPrecision)<<Ibase<<"\t";
		//out<<std::setw(SetWidth)<<std::setprecision(SetPrecision)<<ebase<<"\t";
		out<<std::setw(SetWidth)<<std::setprecision(SetPrecision)<<compareVbase<<"\n";

		eps=std::fabs(Vref-Vbase);//根据@eps(@Vbase的前后迭代差)判断迭代的收敛情况
		--ForceStop;

	}while(eps>0.0000005);

	out.close();
	return 0;
}
Ejemplo n.º 11
0
void Pet::LoseHappiness()
{
    uint32 curValue = GetPower(POWER_HAPPINESS);
    if (curValue <= 0)
        return;
    int32 addvalue = 670;                                   //value is 70/35/17/8/4 (per min) * 1000 / 8 (timer 7.5 secs)
    if (isInCombat())                                        //we know in combat happiness fades faster, multiplier guess
        addvalue = int32(addvalue * 1.5f);
    ModifyPower(POWER_HAPPINESS, -addvalue);
}
Ejemplo n.º 12
0
void CASW_Weapon_Blink::UpdatePower()
{
	if ( GetPower() < asw_blink_charge_time.GetFloat() )
	{
		float flNewPower = GetPower() + gpGlobals->frametime * 1.4f;
		flNewPower = MIN( asw_blink_charge_time.GetFloat(), flNewPower );
		m_flPower = flNewPower;

		if ( flNewPower >= asw_blink_charge_time.GetFloat() )
		{
#ifdef CLIENT_DLL
			EmitSound( "ASW_Weapon.BatteryCharged" );
#else
			if ( gpGlobals->maxClients <= 1 )
			{
				EmitSound( "ASW_Weapon.BatteryCharged" );
			}
#endif
		}
	}
}
Ejemplo n.º 13
0
	void StaticObject::Collide(IColidable* obj) {
		obj->SetHealth(obj->GetHealth() - GetPower());
		this->SetHealth(this->GetHealth() - obj->GetPower());
		if(obj->GetHealth() <= 0)
		{
			obj->OnDestroy();
		}

		if(this->GetHealth() <= 0)
		{
			this->OnDestroy();
		}
	}
Ejemplo n.º 14
0
void CollisionSystem::CombatEntities(std::shared_ptr<Entity> entity1,
        std::shared_ptr<Entity> entity2)
{
    auto combatComponent1 = std::static_pointer_cast<CombatComponent>(Engine::GetInstance().GetSingleComponentOfClass(entity1, "CombatComponent"));
    auto combatComponent2 = std::static_pointer_cast<CombatComponent>(Engine::GetInstance().GetSingleComponentOfClass(entity2, "CombatComponent"));

    int power1 = combatComponent1->GetPower();
    int power2 = combatComponent2->GetPower();

    LOG_D("[CollisionSystem] Combat between entity " << entity1->GetId()
        << " and " << entity2->GetId());

    if (power1 > power2)
    {
        LOG_D("[CollisionSystem] Entity " << entity1->GetId()
            << " wins the combat");

        if (Engine::GetInstance().HasComponent(entity1, "GrowthComponent"))
            EatEntity(entity1, entity2);
        else
            DestroyEntity(entity2);
    }
    else if (power2 > power1)
    {
        LOG_D("[CollisionSystem] Entity " << entity2->GetId()
            << " wins the combat");

        if (Engine::GetInstance().HasComponent(entity2, "GrowthComponent"))
            EatEntity(entity2, entity1);
        else
            DestroyEntity(entity1);
    }
    else
    {
        LOG_D("[CollisionSystem] Tied combat");
        CollideBodies(entity1, entity2);
    }
}
Ejemplo n.º 15
0
SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim)
{
    if(!pVictim)
        return NULL;

    for(uint32 i=0; i < CREATURE_MAX_SPELLS; i++)
    {
        if(!m_spells[i])
            continue;
        SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_spells[i] );
        if(!spellInfo)
        {
            sLog.outError("WORLD: unknown spell id %i\n", m_spells[i]);
            continue;
        }

        bool bcontinue = true;
        for(uint32 j=0;j<3;j++)
        {
            if( (spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE )       ||
                (spellInfo->Effect[j] == SPELL_EFFECT_INSTAKILL)            ||
                (spellInfo->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) ||
                (spellInfo->Effect[j] == SPELL_EFFECT_HEALTH_LEECH )
                )
            {
                bcontinue = false;
                break;
            }
        }
        if(bcontinue) continue;

        if(spellInfo->manaCost > GetPower(POWER_MANA))
            continue;
        SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
        float range = GetMaxRange(srange);
        float minrange = GetMinRange(srange);
        float dist = GetDistanceSq(pVictim);
        //if(!isInFront( pVictim, range ) && spellInfo->AttributesEx )
        //    continue;
        if( dist > range * range || dist < minrange * minrange )
            continue;
        if(m_silenced)
            continue;
        return spellInfo;
    }
    return NULL;
}
Ejemplo n.º 16
0
void GuardianSummon::Load(CreatureProto* proto, Unit* owner, LocationVector & position, uint32 spellid, int32 summonslot)
{
	Summon::Load(proto, owner, position, spellid, summonslot);

	SetPowerType(POWER_TYPE_MANA);
	SetMaxPower(POWER_TYPE_MANA, GetMaxPower(POWER_TYPE_MANA) + 28 + 10 * getLevel());
	SetPower(POWER_TYPE_MANA, GetPower(POWER_TYPE_MANA) + 28 + 10 * getLevel());
	setLevel(owner->getLevel());
	SetMaxHealth(GetMaxHealth() + 28 + 30 * getLevel());
	SetHealth(GetMaxHealth());
	SetType(CREATURE_TYPE_GUARDIAN);

	m_aiInterface->Init(this, AITYPE_PET , MOVEMENTTYPE_NONE, owner);
	m_aiInterface->SetUnitToFollow(owner);
	m_aiInterface->SetFollowDistance(3.0f);

	m_noRespawn = true;
}
Ejemplo n.º 17
0
/**
 @brief 영웅캠페인은 스테이지가 많으므로 이걸 전부 DB에 저장할필요는 없다.
*/
int XStageObjHero2::Serialize( XArchive& ar )
{
	XLOCK_OBJ;
	ar << (char)GetnumClear();
	ar << (char)GetnumStar();
	ar << (short)0;
	if( ar.IsForDB() ) {
		// DB저장시엔 모든정보를 저장할필요는 없다.
		ar << (int)0;
	} else {
		ar << m_idHero;
		ar << GetPower();
		ar << (char)GetLevelLegion();
		ar << (char)0;
		ar << (short)0;
	}
	return 1;
}
Ejemplo n.º 18
0
void CASW_Weapon_Blink::PrimaryAttack( void )
{
	CASW_Player *pPlayer = GetCommander();
	if (!pPlayer)
		return;

	CASW_Marine *pMarine = GetMarine();
	if ( !pMarine || pMarine->GetCurrentMeleeAttack() || pMarine->GetForcedActionRequest() != 0 )
		return;

	if ( GetPower() < asw_blink_charge_time.GetFloat() )
	{
#ifdef CLIENT_DLL
		EmitSound( "ASW_Weapon.InsufficientBattery" );
#else
		if ( gpGlobals->maxClients <= 1 )
		{
			EmitSound( "ASW_Weapon.InsufficientBattery" );
		}
#endif
		return;
	}

	if ( pMarine->IsInhabited() )
	{
		// Get the server to verify destination and do a forced action to actually blink
#ifdef GAME_DLL
		if ( !SetBlinkDestination() )
		{
			CSingleUserRecipientFilter user( pPlayer );
			UserMessageBegin( user, "ASWInvalidDesination" );
			WRITE_SHORT( pMarine->entindex() );
			WRITE_FLOAT( m_vecInvalidDestination.x );
			WRITE_FLOAT( m_vecInvalidDestination.y );
			WRITE_FLOAT( m_vecInvalidDestination.z );
			MessageEnd();
			return;
		}

		pMarine->RequestForcedAction( FORCED_ACTION_BLINK );
		pMarine->OnWeaponFired( this, 1 );
#endif	
	}
}
Ejemplo n.º 19
0
void Vehicle::RegeneratePower(Powers power)
{
    uint32 curValue = GetPower(power);
    uint32 maxValue = GetMaxPower(power);

    if (curValue >= maxValue)
        return;

    float addvalue = 0.0f;

    // hack: needs more research of power type from the dbc. 
    // It must contains some info about vehicles like Salvaged Chopper.
    if(m_vehicleInfo->m_powerType == POWER_TYPE_PYRITE)
        return;

    addvalue = 20.0f;

    ModifyPower(power, (int32)addvalue);
}
Ejemplo n.º 20
0
void PSGame::SetCurrentStep(PSStep* pStep)
{
	m_pCurrentStep = pStep;
	PSData* pData = pStep->GetData();
	int nPowers = GetNumberOfPowers();
	for (int i = 1; i <= nPowers; i++)
	{
		PSPower* pPow = GetPower(i);
		pPow->Clear();
	}
	m_Data.Clear();
	m_Data = *pData;
	m_Data.m_arStrMovingUnits.RemoveAll();
	const SCs vSCs = pData->GetSCs();
	for (i = 0; i < vSCs.size(); i++)
	{
		SC* pSC = vSCs[i];
		pSC->m_pPower->Gains(pSC->m_pProvince, FALSE);
	}
}
Ejemplo n.º 21
0
float Bazooka::Shot(Game_Manager* gm_, Unit* User_, int team_, const coord_def& start_, const coord_def& pos_, float focus_)
{
	float angle_ = GetAngleToTarget(start_, pos_);
	if(UseBullet(1))
	{
		for(int i = 0;i<bunch;i++)
		{
			float focus2_ = rand_float(-focus_, focus_, "Bazooka::Shot focus");
			float speed2_ = shot_speed*GetShotSpeedApply();
			float damage_ =  damage*GetDamegeApply()*(User_?User_->GetAtkApply():1.0f);
			gm_->shot_list.push_back(new Shot_missile(&tex_missile, User_, damage_, GetPower(), GetMaxPower(), range, team_, start_, angle_+focus2_, speed2_, guided_range, guided_power, GetDistance()));
		}
		if (gm_->isPlayerCanHear(GetPos()))
		{
			PlaySE(se_rocket, false);
		}
		gm_->Noise(team_,start_,GetNoise() * User_->GetSilencer());
		return burst_speed*(1.0f/(GetBurstSpeedApply()*(User_?User_->GetAtkSpdApply():1.0f)));
	}
	return -1;
}
Ejemplo n.º 22
0
void Creature::RegenerateMana()
{
    uint32 curValue = GetPower(POWER_MANA);
    uint32 maxValue = GetMaxPower(POWER_MANA);

    if (curValue >= maxValue)   return;

    float ManaIncreaseRate = sWorld.getRate(RATE_POWER_MANA);

    float Spirit = GetStat(STAT_SPIRIT);

    if( ManaIncreaseRate <= 0 ) ManaIncreaseRate = 1;

    uint32 addvalue = 0;

    if (isInCombat() || isPet())
        addvalue = uint32((Spirit/5 + 17) * ManaIncreaseRate);
    else
        addvalue = maxValue/3;

    ModifyPower(POWER_MANA, addvalue);
}
Ejemplo n.º 23
0
void CDBCountry::AddEntityDataToMsg(vector<BYTE>& pBA)
{
	_AddToByteArray(&pBA, m_GUID); // 实体ID
	_AddToByteArray(&pBA, (WORD)4/*CDBCountry的所有属性种类个数*/); // 发送的CDBCountry的所有属性种类个数

	// add one card data
	_AddToByteArray(&pBA, (WORD)1);
	_AddToByteArray(&pBA, (long)DB_COUNTRY_ATTR_LONG_ID);
	_AddToByteArray(&pBA, GetID());

	_AddToByteArray(&pBA, (WORD)1);
	_AddToByteArray(&pBA, (long)DB_COUNTRY_ATTR_LONG_POWER);
	_AddToByteArray(&pBA, GetPower());

	_AddToByteArray(&pBA, (WORD)1);
	_AddToByteArray(&pBA, (long)DB_COUNTRY_ATTR_LONG_TECH_LEVEL);
	_AddToByteArray(&pBA, GetTechLevel());

	_AddToByteArray(&pBA, (WORD)1);
	_AddToByteArray(&pBA, (long)DB_COUNTRY_ATTR_LONG_KING);
	_AddToByteArray(&pBA, GetKing());	
}
Ejemplo n.º 24
0
void Creature::Regenerate(Powers power)
{
    uint32 curValue = GetPower(power);
    uint32 maxValue = GetMaxPower(power);

    if (curValue >= maxValue)
        return;

    float addvalue = 0.0f;

    switch (power)
    {
        case POWER_FOCUS:
        {
            // For hunter pets.
            addvalue = 24 * sWorld->getRate(RATE_POWER_FOCUS);
            break;
        }
        case POWER_ENERGY:
        {
            // For deathknight's ghoul.
            addvalue = 20;
            break;
        }
        default:
            return;
    }

    // Apply modifiers (if any).
    AuraEffectList const& ModPowerRegenPCTAuras = GetAuraEffectsByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT);
    for (AuraEffectList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
        if (Powers((*i)->GetMiscValue()) == power)
            AddPctN(addvalue, (*i)->GetAmount());

    addvalue += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, power) * (isHunterPet()? PET_FOCUS_REGEN_INTERVAL : CREATURE_REGEN_INTERVAL) / (5 * IN_MILLISECONDS);

    ModifyPower(power, int32(addvalue));
}
Ejemplo n.º 25
0
        void HandleDummy(SpellEffIndex /*effIndex*/)
        {
            auto target = GetHitUnit();
            if (!target || target->GetTypeId() != TYPEID_PLAYER)
                return;

            auto player = GetCaster()->ToPlayer();
            if (player->GetQuestStatus(29951) == QUEST_STATUS_INCOMPLETE)
            {
                if (!player->HasAura(106284))
                {
                    player->MonsterTextEmote("Mudmug's vial will slowly spill water while you are moving. Plan your path carefully!", player->GetGUID() , true);
                    player->CastSpell(player, 106284, true);
                }
                else
                    player->CastSpell(player, 106294, true);

                if (player->GetPower(POWER_ALTERNATE_POWER) == 100)
                {
                    player->AddItem(76356, 1);
                    player->RemoveAurasDueToSpell(106284);
                }
            }
        }
Ejemplo n.º 26
0
void Creature::SaveToDB()
{
    sDatabase.BeginTransaction();

    sDatabase.PExecuteLog("DELETE FROM `creature` WHERE `guid` = '%u'", m_DBTableGuid);

    std::ostringstream ss;
    ss << "INSERT INTO `creature` VALUES ("
        << m_DBTableGuid << ","
        << GetEntry() << ","
        << GetMapId() <<","
        << GetPositionX() << ","
        << GetPositionY() << ","
        << GetPositionZ() << ","
        << GetOrientation() << ","
        << m_respawnDelay << ","                            //respawn time
        << (float) 0  << ","                                //spawn distance (float)
        << (uint32) (0) << ","                              //currentwaypoint
        << respawn_cord[0] << ","                           //spawn_position_x
        << respawn_cord[1] << ","                           //spawn_position_y
        << respawn_cord[2] << ","                           //spawn_position_z
        << (float)(0) << ","                                //spawn_orientation
        << GetHealth() << ","                               //curhealth
        << GetPower(POWER_MANA) << ","                      //curmana

        << (uint32)(m_deathState) << ","                    // is it really death state or just state?
    //or
    //<< (uint32)(m_state) << ","                     // is it really death state or just state?

        << GetDefaultMovementType() << ","                  // default movement generator type
        << "'')";                                           // should save auras

    sDatabase.PExecuteLog( ss.str( ).c_str( ) );

    sDatabase.CommitTransaction();
}
Ejemplo n.º 27
0
void RBSwingControl::RenderPower()
{
	float power = GetPower();

	float totalAlpha = m_fadeOutTimer / m_fadeOutTime;
	
	glDisable(GL_TEXTURE_2D);
	RGL.EnableClient(kVertexArray, true);
	RGL.EnableClient(kColorArray, true);
	RGL.EnableClient(kTextureCoordArray, false);
	
	float alpha = totalAlpha * 0.8f * power;
	
	if(alpha > 1.0f)
		alpha = 1.0f;
	
	GLfloat colors[] = {
		1.0f, 1.0f, 1.0f, alpha,
		1.0f, 1.0f, 1.0f, alpha,
		1.0f, 1.0f, 1.0f, alpha,
		1.0f, 1.0f, 1.0f, alpha,
	};
	
	const float kY = 46;
	const float kY2 = 68;
	const float kX = 160;
	const float kLen = 140;
	
	float w = power * kLen;
	
	GLfloat point[] = {
		kX - w, kY,
		kX + w, kY,
		kX + w, kY2,
		kX - w, kY2,
	};
	
	glVertexPointer(2, GL_FLOAT, 0, point);
	glColorPointer(4, GL_FLOAT, 0, colors);
	
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
	
	
	if(power > 0.0f)
	{
		m_swingPowerText.SetAlpha(2.0f * totalAlpha);
		
		if(m_noSwingCommentary || m_strokeState != kStrokeComplete)
		{
			m_swingPowerText.SetValue(power * 100.0f);
		}
		else
		{
			if(power > 1.9f)
			{
				m_swingPowerText.SetText("Excellent Shot!");
			}
			else if(power > 1.5f)
			{
				m_swingPowerText.SetText("Great Shot!");
			}
			else if(power > 1.0f)
			{
				m_swingPowerText.SetText("Good Shot!");
			}
			else
			{
				m_swingPowerText.SetValue(power * 100.0f);
			}
		}
		
		m_swingPowerText.Render();
	}
}
Ejemplo n.º 28
0
void Pet::SavePetToDB(PetSaveMode mode)
{
    if (!GetEntry())
        return;

    // save only fully controlled creature
    if (!isControlled())
        return;

    // not save not player pets
    if (!IS_PLAYER_GUID(GetOwnerGUID()))
        return;

    Player* owner = (Player*)GetOwner();
    if (!owner)
        return;

    // not save pet as current if another pet temporary unsummoned
    if (mode == PET_SAVE_AS_CURRENT && owner->GetTemporaryUnsummonedPetNumber() &&
        owner->GetTemporaryUnsummonedPetNumber() != m_charmInfo->GetPetNumber())
    {
        // pet will lost anyway at restore temporary unsummoned
        if (getPetType() == HUNTER_PET)
            return;

        // for warlock case
        mode = PET_SAVE_NOT_IN_SLOT;
    }

    uint32 curhealth = GetHealth();
    uint32 curmana = GetPower(POWER_MANA);

    SQLTransaction trans = CharacterDatabase.BeginTransaction();
    // save auras before possibly removing them
    _SaveAuras(trans);

    // stable and not in slot saves
    if (mode > PET_SAVE_AS_CURRENT)
        RemoveAllAuras();

    _SaveSpells(trans);
    _SaveSpellCooldowns(trans);
    CharacterDatabase.CommitTransaction(trans);

    // current/stable/not_in_slot
    if (mode >= PET_SAVE_AS_CURRENT)
    {
        uint32 ownerLowGUID = GUID_LOPART(GetOwnerGUID());
        std::string name = m_name;
        CharacterDatabase.EscapeString(name);
        trans = CharacterDatabase.BeginTransaction();
        // remove current data
        trans->PAppend("DELETE FROM character_pet WHERE owner = '%u' AND id = '%u'", ownerLowGUID, m_charmInfo->GetPetNumber());

        // prevent duplicate using slot (except PET_SAVE_NOT_IN_SLOT)
        if (mode <= PET_SAVE_LAST_STABLE_SLOT)
            trans->PAppend("UPDATE character_pet SET slot = '%u' WHERE owner = '%u' AND slot = '%u'",
                PET_SAVE_NOT_IN_SLOT, ownerLowGUID, uint32(mode));

        // prevent existence another hunter pet in PET_SAVE_AS_CURRENT and PET_SAVE_NOT_IN_SLOT
        if (getPetType() == HUNTER_PET && (mode == PET_SAVE_AS_CURRENT || mode > PET_SAVE_LAST_STABLE_SLOT))
            trans->PAppend("DELETE FROM character_pet WHERE owner = '%u' AND (slot = '%u' OR slot > '%u')",
                ownerLowGUID, PET_SAVE_AS_CURRENT, PET_SAVE_LAST_STABLE_SLOT);
        // save pet
        std::ostringstream ss;
        ss  << "INSERT INTO character_pet (id, entry,  owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, CreatedBySpell, PetType) "
            << "VALUES ("
            << m_charmInfo->GetPetNumber() << ','
            << GetEntry() << ','
            << ownerLowGUID << ','
            << GetNativeDisplayId() << ','
            << uint32(getLevel()) << ','
            << GetUInt32Value(UNIT_FIELD_PETEXPERIENCE) << ','
            << uint32(GetReactState()) << ','
            << uint32(mode) << ", '"
            << name.c_str() << "', "
            << uint32(HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) ? 0 : 1) << ','
            << curhealth << ','
            << curmana << ','
            << GetPower(POWER_HAPPINESS) << ", '";

        for (uint32 i = ACTION_BAR_INDEX_START; i < ACTION_BAR_INDEX_END; ++i)
        {
            ss << uint32(m_charmInfo->GetActionBarEntry(i)->GetType()) << ' '
               << uint32(m_charmInfo->GetActionBarEntry(i)->GetAction()) << ' ';
        };

        ss  << "', "
            << time(NULL) << ','
            << GetUInt32Value(UNIT_CREATED_BY_SPELL) << ','
            << uint32(getPetType()) << ')';

        trans->Append(ss.str().c_str());
        CharacterDatabase.CommitTransaction(trans);
    }
    // delete
    else
    {
        RemoveAllAuras();
        DeleteFromDB(m_charmInfo->GetPetNumber());
    }
}
Ejemplo n.º 29
0
float CASW_Weapon_Blink::GetBatteryCharge()
{
	return GetPower() / asw_blink_charge_time.GetFloat();
}
Ejemplo n.º 30
0
double MOCPumpConfig::GetTr(double dSpeed)
{
	double dMass = GetMr();
	double dPower =GetPower(dMass);
	return (30*dPower/(dSpeed*PI));
}