Core/Units: Power handling improvements
This commit is contained in:
1 parent
620c39be06
commit
b5ec59a07e
6 files changed
+72
-84
No files matched your search
@@ -1443,23 +1443,24 @@ void Creature::UpdateLevelDependantStats()
|
|||||||
SetHealth(health);
|
SetHealth(health);
|
||||||
ResetPlayerDamageReq();
|
ResetPlayerDamageReq();
|
||||||
|
|
||||||
|
SetStatFlatModifier(UNIT_MOD_HEALTH, BASE_VALUE, (float)health);
|
||||||
|
|
||||||
// mana
|
// mana
|
||||||
uint32 mana = stats->GenerateMana(cInfo);
|
Powers powerType = CalculateDisplayPowerType();
|
||||||
SetCreateMana(mana);
|
SetCreateMana(stats->BaseMana);
|
||||||
|
SetStatPctModifier(UnitMods(UNIT_MOD_POWER_START + AsUnderlyingType(powerType)), BASE_PCT, cInfo->ModMana * cInfo->ModManaExtra);
|
||||||
|
SetPowerType(powerType);
|
||||||
|
|
||||||
switch (getClass())
|
switch (getClass())
|
||||||
{
|
{
|
||||||
case UNIT_CLASS_PALADIN:
|
case UNIT_CLASS_PALADIN:
|
||||||
case UNIT_CLASS_MAGE:
|
case UNIT_CLASS_MAGE:
|
||||||
SetMaxPower(POWER_MANA, mana);
|
|
||||||
SetFullPower(POWER_MANA);
|
SetFullPower(POWER_MANA);
|
||||||
break;
|
break;
|
||||||
default: // We don't set max power here, 0 makes power bar hidden
|
default: // We don't set max power here, 0 makes power bar hidden
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetStatFlatModifier(UNIT_MOD_HEALTH, BASE_VALUE, (float)health);
|
|
||||||
|
|
||||||
// damage
|
// damage
|
||||||
float basedamage = stats->GenerateBaseDamage(cInfo);
|
float basedamage = stats->GenerateBaseDamage(cInfo);
|
||||||
|
|
||||||
|
|||||||
@@ -494,15 +494,6 @@ struct TC_GAME_API CreatureBaseStats
|
|||||||
return uint32(ceil(BaseHealth[info->expansion] * info->ModHealth * info->ModHealthExtra));
|
return uint32(ceil(BaseHealth[info->expansion] * info->ModHealth * info->ModHealthExtra));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 GenerateMana(CreatureTemplate const* info) const
|
|
||||||
{
|
|
||||||
// Mana can be 0.
|
|
||||||
if (!BaseMana)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return uint32(ceil(BaseMana * info->ModMana * info->ModManaExtra));
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 GenerateArmor(CreatureTemplate const* info) const
|
uint32 GenerateArmor(CreatureTemplate const* info) const
|
||||||
{
|
{
|
||||||
return uint32(ceil(BaseArmor * info->ModArmor));
|
return uint32(ceil(BaseArmor * info->ModArmor));
|
||||||
|
|||||||
@@ -757,6 +757,8 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
|
|||||||
for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
|
for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
|
||||||
SetStatFlatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), BASE_VALUE, float(cinfo->resistance[i]));
|
SetStatFlatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), BASE_VALUE, float(cinfo->resistance[i]));
|
||||||
|
|
||||||
|
Powers powerType = CalculateDisplayPowerType();
|
||||||
|
|
||||||
// Health, mana, armor and resistance
|
// Health, mana, armor and resistance
|
||||||
PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(creature_ID, petlevel);
|
PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(creature_ID, petlevel);
|
||||||
if (pInfo) // exist in DB
|
if (pInfo) // exist in DB
|
||||||
@@ -764,6 +766,8 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
|
|||||||
SetCreateHealth(pInfo->health);
|
SetCreateHealth(pInfo->health);
|
||||||
SetCreateMana(pInfo->mana);
|
SetCreateMana(pInfo->mana);
|
||||||
|
|
||||||
|
SetStatPctModifier(UnitMods(UNIT_MOD_POWER_START + AsUnderlyingType(powerType)), BASE_PCT, 1.0f);
|
||||||
|
|
||||||
if (pInfo->armor > 0)
|
if (pInfo->armor > 0)
|
||||||
SetStatFlatModifier(UNIT_MOD_ARMOR, BASE_VALUE, float(pInfo->armor));
|
SetStatFlatModifier(UNIT_MOD_ARMOR, BASE_VALUE, float(pInfo->armor));
|
||||||
|
|
||||||
@@ -778,10 +782,9 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
|
|||||||
float healthmod = _GetHealthMod(cinfo->rank);
|
float healthmod = _GetHealthMod(cinfo->rank);
|
||||||
uint32 basehp = stats->GenerateHealth(cinfo);
|
uint32 basehp = stats->GenerateHealth(cinfo);
|
||||||
uint32 health = uint32(basehp * healthmod);
|
uint32 health = uint32(basehp * healthmod);
|
||||||
uint32 mana = stats->GenerateMana(cinfo);
|
|
||||||
|
|
||||||
SetCreateHealth(health);
|
SetCreateHealth(health);
|
||||||
SetCreateMana(mana);
|
SetCreateMana(stats->BaseMana);
|
||||||
SetCreateStat(STAT_STRENGTH, 22);
|
SetCreateStat(STAT_STRENGTH, 22);
|
||||||
SetCreateStat(STAT_AGILITY, 22);
|
SetCreateStat(STAT_AGILITY, 22);
|
||||||
SetCreateStat(STAT_STAMINA, 25);
|
SetCreateStat(STAT_STAMINA, 25);
|
||||||
@@ -793,15 +796,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Power
|
// Power
|
||||||
if (petType == HUNTER_PET) // Hunter pets have focus
|
SetPowerType(powerType);
|
||||||
SetPowerType(POWER_FOCUS);
|
|
||||||
else if (IsPetGhoul() || IsRisenAlly()) // DK pets have energy
|
|
||||||
{
|
|
||||||
SetPowerType(POWER_ENERGY);
|
|
||||||
SetFullPower(POWER_ENERGY);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SetPowerType(POWER_MANA);
|
|
||||||
|
|
||||||
// Damage
|
// Damage
|
||||||
SetBonusDamage(0);
|
SetBonusDamage(0);
|
||||||
|
|||||||
@@ -86,6 +86,39 @@ void Unit::UpdateDamagePhysical(WeaponAttackType attType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 Unit::GetCreatePowerValue(Powers power) const
|
||||||
|
{
|
||||||
|
switch (power)
|
||||||
|
{
|
||||||
|
case POWER_MANA:
|
||||||
|
return GetCreateMana();
|
||||||
|
case POWER_RAGE:
|
||||||
|
if (IsPlayer()) // only players are allowed to use rage
|
||||||
|
return 1000;
|
||||||
|
break;
|
||||||
|
case POWER_FOCUS:
|
||||||
|
return 100;
|
||||||
|
case POWER_ENERGY:
|
||||||
|
return 100;
|
||||||
|
case POWER_RUNIC_POWER:
|
||||||
|
return 1000;
|
||||||
|
case POWER_RUNE:
|
||||||
|
return 0;
|
||||||
|
case POWER_SOUL_SHARDS:
|
||||||
|
return 3;
|
||||||
|
case POWER_ECLIPSE:
|
||||||
|
return 100;
|
||||||
|
case POWER_HOLY_POWER:
|
||||||
|
return 3;
|
||||||
|
case POWER_HEALTH:
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*#######################################
|
/*#######################################
|
||||||
######## ########
|
######## ########
|
||||||
######## PLAYERS STAT SYSTEM ########
|
######## PLAYERS STAT SYSTEM ########
|
||||||
@@ -323,9 +356,9 @@ void Player::UpdateMaxPower(Powers power)
|
|||||||
|
|
||||||
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + AsUnderlyingType(power));
|
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + AsUnderlyingType(power));
|
||||||
|
|
||||||
float bonusPower = (power == POWER_MANA && GetCreatePowers(power) > 0) ? GetManaBonusFromIntellect() : 0;
|
float bonusPower = (power == POWER_MANA && GetCreatePowerValue(power) > 0) ? GetManaBonusFromIntellect() : 0;
|
||||||
|
|
||||||
float value = GetFlatModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power);
|
float value = GetFlatModifierValue(unitMod, BASE_VALUE) + GetCreatePowerValue(power);
|
||||||
value *= GetPctModifierValue(unitMod, BASE_PCT);
|
value *= GetPctModifierValue(unitMod, BASE_PCT);
|
||||||
value += GetFlatModifierValue(unitMod, TOTAL_VALUE) + bonusPower;
|
value += GetFlatModifierValue(unitMod, TOTAL_VALUE) + bonusPower;
|
||||||
value *= GetPctModifierValue(unitMod, TOTAL_PCT);
|
value *= GetPctModifierValue(unitMod, TOTAL_PCT);
|
||||||
@@ -942,7 +975,7 @@ void Creature::UpdateMaxPower(Powers power)
|
|||||||
|
|
||||||
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + AsUnderlyingType(power));
|
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + AsUnderlyingType(power));
|
||||||
|
|
||||||
float value = GetFlatModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power);
|
float value = GetFlatModifierValue(unitMod, BASE_VALUE) + GetCreatePowerValue(power);
|
||||||
value *= GetPctModifierValue(unitMod, BASE_PCT);
|
value *= GetPctModifierValue(unitMod, BASE_PCT);
|
||||||
value += GetFlatModifierValue(unitMod, TOTAL_VALUE);
|
value += GetFlatModifierValue(unitMod, TOTAL_VALUE);
|
||||||
value *= GetPctModifierValue(unitMod, TOTAL_PCT);
|
value *= GetPctModifierValue(unitMod, TOTAL_PCT);
|
||||||
@@ -1174,7 +1207,7 @@ void Guardian::UpdateMaxPower(Powers power)
|
|||||||
float addValue = (power == POWER_MANA) ? GetStat(STAT_INTELLECT) - GetCreateStat(STAT_INTELLECT) : 0.0f;
|
float addValue = (power == POWER_MANA) ? GetStat(STAT_INTELLECT) - GetCreateStat(STAT_INTELLECT) : 0.0f;
|
||||||
float multiplicator = 15.0f;
|
float multiplicator = 15.0f;
|
||||||
|
|
||||||
float value = GetFlatModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power);
|
float value = GetFlatModifierValue(unitMod, BASE_VALUE) + GetCreatePowerValue(power);
|
||||||
value *= GetPctModifierValue(unitMod, BASE_PCT);
|
value *= GetPctModifierValue(unitMod, BASE_PCT);
|
||||||
value += GetFlatModifierValue(unitMod, TOTAL_VALUE) + addValue * multiplicator;
|
value += GetFlatModifierValue(unitMod, TOTAL_VALUE) + addValue * multiplicator;
|
||||||
value *= GetPctModifierValue(unitMod, TOTAL_PCT);
|
value *= GetPctModifierValue(unitMod, TOTAL_PCT);
|
||||||
|
|||||||
@@ -5229,7 +5229,7 @@ void Unit::SetPowerType(Powers new_powertype)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::UpdateDisplayPower()
|
Powers Unit::CalculateDisplayPowerType() const
|
||||||
{
|
{
|
||||||
Powers displayPower = POWER_MANA;
|
Powers displayPower = POWER_MANA;
|
||||||
switch (GetShapeshiftForm())
|
switch (GetShapeshiftForm())
|
||||||
@@ -5247,34 +5247,34 @@ void Unit::UpdateDisplayPower()
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (GetTypeId() == TYPEID_PLAYER)
|
ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(getClass());
|
||||||
|
if (cEntry && cEntry->DisplayPower < MAX_POWERS)
|
||||||
|
displayPower = Powers(cEntry->DisplayPower);
|
||||||
|
|
||||||
|
if (Vehicle* vehicle = GetVehicleKit())
|
||||||
{
|
{
|
||||||
ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(getClass());
|
if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(vehicle->GetVehicleInfo()->PowerDisplayID[0])) // To-do: 4.x has 3 power display id fields.
|
||||||
if (cEntry && cEntry->DisplayPower < MAX_POWERS)
|
displayPower = Powers(powerDisplay->ActualType);
|
||||||
displayPower = Powers(cEntry->DisplayPower);
|
else if (getClass() == CLASS_ROGUE)
|
||||||
|
displayPower = POWER_ENERGY;
|
||||||
}
|
}
|
||||||
else if (GetTypeId() == TYPEID_UNIT)
|
else if (Pet const* pet = ToPet())
|
||||||
{
|
{
|
||||||
if (Vehicle* vehicle = GetVehicleKit())
|
if (pet->getPetType() == HUNTER_PET) // Hunter pets have focus
|
||||||
{
|
displayPower = POWER_FOCUS;
|
||||||
if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(vehicle->GetVehicleInfo()->PowerDisplayID[0])) // To-do: 4.x has 3 power display id fields.
|
else if (pet->IsPetGhoul() || pet->IsRisenAlly()) // DK pets have energy
|
||||||
displayPower = Powers(powerDisplay->ActualType);
|
displayPower = POWER_ENERGY;
|
||||||
else if (getClass() == CLASS_ROGUE)
|
|
||||||
displayPower = POWER_ENERGY;
|
|
||||||
}
|
|
||||||
else if (Pet* pet = ToPet())
|
|
||||||
{
|
|
||||||
if (pet->getPetType() == HUNTER_PET) // Hunter pets have focus
|
|
||||||
displayPower = POWER_FOCUS;
|
|
||||||
else if (pet->IsPetGhoul() || pet->IsRisenAlly()) // DK pets have energy
|
|
||||||
displayPower = POWER_ENERGY;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetPowerType(displayPower);
|
return displayPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Unit::UpdateDisplayPower()
|
||||||
|
{
|
||||||
|
SetPowerType(CalculateDisplayPowerType());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::SetSheath(SheathState sheathed)
|
void Unit::SetSheath(SheathState sheathed)
|
||||||
@@ -9369,39 +9369,6 @@ void Unit::SetMaxPower(Powers power, int32 val)
|
|||||||
SetPower(power, val);
|
SetPower(power, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 Unit::GetCreatePowers(Powers power) const
|
|
||||||
{
|
|
||||||
switch (power)
|
|
||||||
{
|
|
||||||
case POWER_MANA:
|
|
||||||
return GetCreateMana();
|
|
||||||
case POWER_RAGE:
|
|
||||||
return 1000;
|
|
||||||
case POWER_FOCUS:
|
|
||||||
if (GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_HUNTER)
|
|
||||||
return 100;
|
|
||||||
return (GetTypeId() == TYPEID_PLAYER || !((Creature const*)this)->IsPet() || ((Pet const*)this)->getPetType() != HUNTER_PET ? 0 : 100);
|
|
||||||
case POWER_ENERGY:
|
|
||||||
return 100;
|
|
||||||
case POWER_RUNIC_POWER:
|
|
||||||
return 1000;
|
|
||||||
case POWER_RUNE:
|
|
||||||
return 0;
|
|
||||||
case POWER_SOUL_SHARDS:
|
|
||||||
return 3;
|
|
||||||
case POWER_ECLIPSE:
|
|
||||||
return 100;
|
|
||||||
case POWER_HOLY_POWER:
|
|
||||||
return 3;
|
|
||||||
case POWER_HEALTH:
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Unit::Regenerate(Powers powerType, uint32 diff)
|
void Unit::Regenerate(Powers powerType, uint32 diff)
|
||||||
{
|
{
|
||||||
uint32 maxValue = GetMaxPower(powerType);
|
uint32 maxValue = GetMaxPower(powerType);
|
||||||
|
|||||||
@@ -925,6 +925,7 @@ class TC_GAME_API Unit : public WorldObject
|
|||||||
|
|
||||||
Powers GetPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE)); }
|
Powers GetPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE)); }
|
||||||
void SetPowerType(Powers power);
|
void SetPowerType(Powers power);
|
||||||
|
Powers CalculateDisplayPowerType() const;
|
||||||
void UpdateDisplayPower();
|
void UpdateDisplayPower();
|
||||||
int32 GetPower(Powers power) const;
|
int32 GetPower(Powers power) const;
|
||||||
int32 GetMinPower(Powers power) const { return power == POWER_ECLIPSE ? -100 : 0; }
|
int32 GetMinPower(Powers power) const { return power == POWER_ECLIPSE ? -100 : 0; }
|
||||||
@@ -1402,7 +1403,7 @@ class TC_GAME_API Unit : public WorldObject
|
|||||||
uint32 GetCreateHealth() const { return GetUInt32Value(UNIT_FIELD_BASE_HEALTH); }
|
uint32 GetCreateHealth() const { return GetUInt32Value(UNIT_FIELD_BASE_HEALTH); }
|
||||||
void SetCreateMana(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_MANA, val); }
|
void SetCreateMana(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_MANA, val); }
|
||||||
uint32 GetCreateMana() const { return GetUInt32Value(UNIT_FIELD_BASE_MANA); }
|
uint32 GetCreateMana() const { return GetUInt32Value(UNIT_FIELD_BASE_MANA); }
|
||||||
int32 GetCreatePowers(Powers power) const;
|
int32 GetCreatePowerValue(Powers power) const;
|
||||||
float GetPosStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0 + AsUnderlyingType(stat)); }
|
float GetPosStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0 + AsUnderlyingType(stat)); }
|
||||||
float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0 + AsUnderlyingType(stat)); }
|
float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0 + AsUnderlyingType(stat)); }
|
||||||
float GetCreateStat(Stats stat) const { return m_createStats[stat]; }
|
float GetCreateStat(Stats stat) const { return m_createStats[stat]; }
|
||||||
|
|||||||
Reference in new issue
Block a user