mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
Over 100 camangos Cata commits applied (to c12950)
Over 100 camangos Cata commits applied. up to and inclusing c12950.
This commit is contained in:
parent
b4ec0440aa
commit
eef77eadb9
117 changed files with 4314 additions and 3547 deletions
|
|
@ -168,8 +168,7 @@ Creature::Creature(CreatureSubtype subtype) : Unit(),
|
|||
m_corpseDecayTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_aggroDelay(0), m_respawnradius(5.0f),
|
||||
m_subtype(subtype), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0),
|
||||
m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false),
|
||||
m_regenHealth(true), m_AI_locked(false), m_IsDeadByDefault(false),
|
||||
m_temporaryFactionFlags(TEMPFACTION_NONE),
|
||||
m_AI_locked(false), m_IsDeadByDefault(false), m_temporaryFactionFlags(TEMPFACTION_NONE),
|
||||
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0),
|
||||
m_creatureInfo(NULL)
|
||||
{
|
||||
|
|
@ -252,6 +251,12 @@ void Creature::RemoveCorpse()
|
|||
if (AI())
|
||||
{ AI()->CorpseRemoved(respawnDelay); }
|
||||
|
||||
if (m_isCreatureLinkingTrigger)
|
||||
GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_DESPAWN, this);
|
||||
|
||||
if (InstanceData* mapInstance = GetInstanceData())
|
||||
mapInstance->OnCreatureDespawn(this);
|
||||
|
||||
// script can set time (in seconds) explicit, override the original
|
||||
if (respawnDelay)
|
||||
{ m_respawnTime = time(NULL) + respawnDelay; }
|
||||
|
|
@ -335,6 +340,24 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameE
|
|||
|
||||
SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender);
|
||||
|
||||
// set PowerType based on unit class
|
||||
switch (cinfo->UnitClass)
|
||||
{
|
||||
case CLASS_WARRIOR:
|
||||
SetPowerType(POWER_RAGE);
|
||||
break;
|
||||
case CLASS_PALADIN:
|
||||
case CLASS_MAGE:
|
||||
SetPowerType(POWER_MANA);
|
||||
break;
|
||||
case CLASS_ROGUE:
|
||||
SetPowerType(POWER_ENERGY);
|
||||
break;
|
||||
default:
|
||||
sLog.outErrorDb("Creature (Entry: %u) has unhandled unit class. Power type will not be set!", Entry);
|
||||
break;
|
||||
}
|
||||
|
||||
// Load creature equipment
|
||||
if (eventData && eventData->equipment_id)
|
||||
{
|
||||
|
|
@ -663,33 +686,68 @@ void Creature::RegenerateAll(uint32 update_diff)
|
|||
if (!IsInCombat() || IsPolymorphed())
|
||||
RegenerateHealth();
|
||||
|
||||
RegenerateMana();
|
||||
RegeneratePower();
|
||||
|
||||
m_regenTimer = REGEN_TIME_FULL;
|
||||
}
|
||||
|
||||
void Creature::RegenerateMana()
|
||||
void Creature::RegeneratePower()
|
||||
{
|
||||
uint32 curValue = GetPower(POWER_MANA);
|
||||
uint32 maxValue = GetMaxPower(POWER_MANA);
|
||||
if (!IsRegeneratingPower())
|
||||
return;
|
||||
|
||||
Powers powerType = GetPowerType();
|
||||
uint32 curValue = GetPower(powerType);
|
||||
uint32 maxValue = GetMaxPower(powerType);
|
||||
|
||||
if (curValue >= maxValue)
|
||||
return;
|
||||
|
||||
uint32 addvalue = 0;
|
||||
float addValue = 0.0f;
|
||||
|
||||
// Combat and any controlled creature
|
||||
if (IsInCombat() || GetCharmerOrOwnerGuid())
|
||||
switch (powerType)
|
||||
{
|
||||
float ManaIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_MANA);
|
||||
float Spirit = GetStat(STAT_SPIRIT);
|
||||
case POWER_MANA:
|
||||
// Combat and any controlled creature
|
||||
if (IsInCombat() || GetCharmerOrOwnerGuid())
|
||||
{
|
||||
float ManaIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_MANA);
|
||||
float Spirit = GetStat(STAT_SPIRIT);
|
||||
|
||||
addvalue = uint32((Spirit / 5.0f + 17.0f) * ManaIncreaseRate);
|
||||
addValue = uint32(Spirit / 5.0f + 17.0f) * ManaIncreaseRate;
|
||||
}
|
||||
else
|
||||
addValue = maxValue / 3.0f;
|
||||
break;
|
||||
case POWER_ENERGY:
|
||||
// ToDo: for vehicle this is different - NEEDS TO BE FIXED!
|
||||
addValue = 20 * sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_ENERGY);
|
||||
break;
|
||||
case POWER_FOCUS:
|
||||
addValue = 24 * sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_FOCUS);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
else
|
||||
addvalue = maxValue / 3;
|
||||
|
||||
ModifyPower(POWER_MANA, addvalue);
|
||||
// Apply modifiers (if any)
|
||||
AuraList const& ModPowerRegenAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN);
|
||||
for (AuraList::const_iterator i = ModPowerRegenAuras.begin(); i != ModPowerRegenAuras.end(); ++i)
|
||||
{
|
||||
Modifier const* modifier = (*i)->GetModifier();
|
||||
if (modifier->m_miscvalue == int32(powerType))
|
||||
addValue += modifier->m_amount;
|
||||
}
|
||||
|
||||
AuraList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT);
|
||||
for (AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
|
||||
{
|
||||
Modifier const* modifier = (*i)->GetModifier();
|
||||
if (modifier->m_miscvalue == int32(powerType))
|
||||
addValue *= (modifier->m_amount + 100) / 100.0f;
|
||||
}
|
||||
|
||||
ModifyPower(powerType, int32(addValue));
|
||||
}
|
||||
|
||||
void Creature::RegenerateHealth()
|
||||
|
|
@ -1237,12 +1295,12 @@ void Creature::SelectLevel(const CreatureInfo* cinfo, float percentHealth /*= 10
|
|||
|
||||
switch (i)
|
||||
{
|
||||
case POWER_MANA: maxValue = mana; break;
|
||||
case POWER_RAGE: maxValue = 0; break;
|
||||
case POWER_FOCUS: maxValue = POWER_FOCUS_DEFAULT; break;
|
||||
case POWER_ENERGY: maxValue = POWER_ENERGY_DEFAULT * cinfo->PowerMultiplier; break;
|
||||
case POWER_RUNE: maxValue = 0; break;
|
||||
case POWER_RUNIC_POWER: maxValue = 0; break;
|
||||
case POWER_MANA: maxValue = mana; break;
|
||||
case POWER_RAGE: maxValue = 0; break;
|
||||
case POWER_FOCUS: maxValue = POWER_FOCUS_DEFAULT; break;
|
||||
case POWER_ENERGY: maxValue = POWER_ENERGY_DEFAULT * cinfo->PowerMultiplier; break;
|
||||
case POWER_RUNE: maxValue = 0; break;
|
||||
case POWER_RUNIC_POWER: maxValue = 0; break;
|
||||
}
|
||||
|
||||
uint32 value = maxValue;
|
||||
|
|
@ -1313,22 +1371,22 @@ float Creature::_GetDamageMod(int32 Rank)
|
|||
}
|
||||
}
|
||||
|
||||
float Creature::GetSpellDamageMod(int32 Rank)
|
||||
float Creature::_GetSpellDamageMod(int32 Rank)
|
||||
{
|
||||
switch (Rank) // define rates for each elite rank
|
||||
{
|
||||
case CREATURE_ELITE_NORMAL:
|
||||
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_NORMAL_SPELLDAMAGE);
|
||||
case CREATURE_ELITE_ELITE:
|
||||
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE);
|
||||
case CREATURE_ELITE_RAREELITE:
|
||||
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE);
|
||||
case CREATURE_ELITE_WORLDBOSS:
|
||||
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE);
|
||||
case CREATURE_ELITE_RARE:
|
||||
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_RARE_SPELLDAMAGE);
|
||||
default:
|
||||
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE);
|
||||
case CREATURE_ELITE_NORMAL:
|
||||
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_NORMAL_SPELLDAMAGE);
|
||||
case CREATURE_ELITE_ELITE:
|
||||
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE);
|
||||
case CREATURE_ELITE_RAREELITE:
|
||||
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE);
|
||||
case CREATURE_ELITE_WORLDBOSS:
|
||||
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE);
|
||||
case CREATURE_ELITE_RARE:
|
||||
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_RARE_SPELLDAMAGE);
|
||||
default:
|
||||
return sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1581,7 +1639,7 @@ void Creature::SetDeathState(DeathState s)
|
|||
if ((s == JUST_DIED && !m_IsDeadByDefault) || (s == JUST_ALIVED && m_IsDeadByDefault))
|
||||
{
|
||||
m_corpseDecayTimer = m_corpseDelay * IN_MILLISECONDS; // the max/default time for corpse decay (before creature is looted/AllLootRemovedFromCorpse() is called)
|
||||
m_respawnTime = time(NULL) + m_respawnDelay; // respawn delay (spawntimesecs)
|
||||
m_respawnTime = time(nullptr) + m_respawnDelay; // respawn delay (spawntimesecs)
|
||||
|
||||
// always save boss respawn time at death to prevent crash cheating
|
||||
if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY) || IsWorldBoss())
|
||||
|
|
@ -1614,7 +1672,7 @@ void Creature::SetDeathState(DeathState s)
|
|||
Unit::SetDeathState(ALIVE);
|
||||
|
||||
SetHealth(GetMaxHealth());
|
||||
SetLootRecipient(NULL);
|
||||
SetLootRecipient(nullptr);
|
||||
if (GetTemporaryFactionFlags() & TEMPFACTION_RESTORE_RESPAWN)
|
||||
ClearTemporaryFaction();
|
||||
|
||||
|
|
@ -2523,6 +2581,10 @@ void Creature::SetFactionTemporary(uint32 factionId, uint32 tempFactionFlags)
|
|||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
|
||||
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_PASSIVE)
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);
|
||||
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_PACIFIED)
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
|
||||
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_NOT_SELECTABLE)
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
|
||||
}
|
||||
|
||||
void Creature::ClearTemporaryFaction()
|
||||
|
|
@ -2535,13 +2597,17 @@ void Creature::ClearTemporaryFaction()
|
|||
|
||||
// Reset to original faction
|
||||
setFaction(GetCreatureInfo()->FactionAlliance);
|
||||
// Reset UNIT_FLAG_NON_ATTACKABLE, UNIT_FLAG_OOC_NOT_ATTACKABLE or UNIT_FLAG_PASSIVE flags
|
||||
// Reset UNIT_FLAG_NON_ATTACKABLE, UNIT_FLAG_OOC_NOT_ATTACKABLE, UNIT_FLAG_PASSIVE, UNIT_FLAG_PACIFIED or UNIT_FLAG_NOT_SELECTABLE flags
|
||||
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_NON_ATTACKABLE && GetCreatureInfo()->UnitFlags & UNIT_FLAG_NON_ATTACKABLE)
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
|
||||
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_OOC_NOT_ATTACK && GetCreatureInfo()->UnitFlags & UNIT_FLAG_OOC_NOT_ATTACKABLE && !IsInCombat())
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
|
||||
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_PASSIVE && GetCreatureInfo()->UnitFlags & UNIT_FLAG_PASSIVE)
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);
|
||||
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_PACIFIED && GetCreatureInfo()->UnitFlags & UNIT_FLAG_PACIFIED)
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
|
||||
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_NOT_SELECTABLE && GetCreatureInfo()->UnitFlags & UNIT_FLAG_NOT_SELECTABLE)
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
|
||||
|
||||
m_temporaryFactionFlags = TEMPFACTION_NONE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue