diff options
| author | QAston <none@none> | 2010-01-10 01:23:15 +0100 |
|---|---|---|
| committer | QAston <none@none> | 2010-01-10 01:23:15 +0100 |
| commit | 8e9d2cdf01929f513e37eccbfdea952aa04e78f6 (patch) | |
| tree | 54d298a9e7f5b84bd230bf340d76180116008496 /src/game/Creature.cpp | |
| parent | a0f7762cab9b759b7d3e7dc25a447b5e43f2048b (diff) | |
Update aura system:
* Change system logic - unify Auras, AreaAuras and PersistentAreaAuras:
* Aura has now its owner - which is the WorldObject, which applies aura (creates AuraApplication object) dependant on aura radius, and effect type
* Owner can be Dynobj (DynObjAura class) for PersistentAreaAuras, or Unit (UnitAura class) for Area and nonArea auras
* Aura data is shared for all units which have AuraApplication of the Aura
* Because of that AuraEffect handlers , and periodic tick functions can't modify AuraEffect object (they are const now)
* Remove spell source and AreaAuraEffect classes
* Add AuraEffect::UpdatePeriodic function, to allow periodic aura object modification (target independant)
* Add AuraEffect::CalculateAmount and AuraEffect::CalculateSpellMod function, to allow non-default amount calculation
* AreaAura updates are done in owner _UpdateSpells cycle
* Since now you don't need to wait an aura update cycle to get area aura applied on it's correct target list
* And you can access area aura target list
* Add basic support for aura amount recalculation
* Save recalculation state and base amount of auras to db
* Add AuraEffect::CalculatePeriodic function to determine if aura is periodic, and to set correct tick number after aura is loaded from db
* Add ChangeAmount function in addition to SetAmount function, to allow easy reapplication of AuraEffect handlers on all targets
* Sort aura effect handlers in SpellAuras.cpp and .h by their use
* Add check for already existing aura of that type to some AuraEffect handlers, to prevent incorrect effect removal
* SPELL_AURA_CONVERT_RUNE and MOD_POWER_REGEN and MOD_REGEN hacky handlers are now implemented correctly
* Send aura application client update only once per unit update - prevent unnecesary packet spam
* Fix ByteBuffer::appendPackGUID function - it added additionall 0s at the end of the packet
* Fix memory leak at player creation (not deleted auras)
* Updated some naming conventions (too many to mention)
* Added Unit::GetAuraOfRankedSpell() function
* Remove procflags on aura remove, use Aura::HandleAuraSpecificMods instead
* Added functions to maintain owned auras (GetOwnedAuras, GetOwnedAura, RemoveOwnedAura, etc)
* Implement AURA_INTERRUPT_FLAG_LANDING
* Implement EffectPlayerNotification (thanks to Spp)
* Remove wrong aura 304 handler
* Add better handler for death runes
* Remove unnecesary variables from DynamicObject class, and cleanup related code, link dynobj duration with aura
* Add GetAuraEffectTriggerTarget function in CreatureAi for special target selection for periodic trigger auras used in a script
* Add many assert() procection from idiots using some functions in wrong way
* I am to lazy to write here anything more
Thanks to Visagalis for testing this patch
PS: Do not make patches like this, please
--HG--
branch : trunk
Diffstat (limited to 'src/game/Creature.cpp')
| -rw-r--r-- | src/game/Creature.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 4bcf866632c..9795671ef22 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -47,6 +47,7 @@ #include "GameEventMgr.h" #include "CreatureGroups.h" #include "Vehicle.h" +#include "SpellAuraEffects.h" // apply implementation of the singletons #include "Policies/SingletonImp.h" @@ -142,7 +143,7 @@ m_creatureInfo(NULL), m_reactState(REACT_AGGRESSIVE), m_formation(NULL) , m_AlreadySearchedAssistance(false) , m_creatureData(NULL), m_PlayerDamageReq(0) { - m_regenTimer = 2000; + m_regenTimer = CREATURE_REGEN_INTERVAL; m_valuesCount = UNIT_END; for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i) @@ -571,12 +572,12 @@ void Creature::Update(uint32 diff) RegenerateMana(); /*if(!bIsPolymorphed) // only increase the timer if not polymorphed - m_regenTimer += 2000 - diff; + m_regenTimer += CREATURE_REGEN_INTERVAL - diff; } else if(!bIsPolymorphed) // if polymorphed, skip the timer m_regenTimer -= diff;*/ - m_regenTimer = 2000; + m_regenTimer = CREATURE_REGEN_INTERVAL; break; } case DEAD_FALLING: @@ -611,6 +612,14 @@ void Creature::RegenerateMana() else addvalue = maxValue/3; + // 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 ((*i)->GetMiscValue() == POWER_MANA) + addvalue *= ((*i)->GetAmount() + 100) / 100.0f; + + addvalue += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, POWER_MANA) * CREATURE_REGEN_INTERVAL / (5 * IN_MILISECONDS); + ModifyPower(POWER_MANA, addvalue); } @@ -641,6 +650,13 @@ void Creature::RegenerateHealth() else addvalue = maxValue/3; + // Apply modifiers (if any). + AuraEffectList const& ModPowerRegenPCTAuras = GetAuraEffectsByType(SPELL_AURA_MOD_HEALTH_REGEN_PERCENT); + for (AuraEffectList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i) + addvalue *= ((*i)->GetAmount() + 100) / 100.0f; + + addvalue += GetTotalAuraModifier(SPELL_AURA_MOD_REGEN) * CREATURE_REGEN_INTERVAL / (5 * IN_MILISECONDS); + ModifyHealth(addvalue); } @@ -1988,16 +2004,16 @@ bool Creature::LoadCreaturesAddon(bool reload) } // skip already applied aura - if(HasAuraEffect(cAura->spell_id,cAura->effect_idx)) + if(HasAura(cAura->spell_id)) { if(!reload) - sLog.outErrorDb("Creature (GUID: %u Entry: %u) has duplicate aura (spell %u effect %u) in `auras` field.",GetGUIDLow(),GetEntry(),cAura->spell_id,cAura->effect_idx); + sLog.outErrorDb("Creature (GUID: %u Entry: %u) has duplicate aura (spell %u) in `auras` field.",GetGUIDLow(),GetEntry(),cAura->spell_id); continue; } - AddAuraEffect(AdditionalSpellInfo, cAura->effect_idx, this, this); - sLog.outDebug("Spell: %u with Aura %u added to creature (GUID: %u Entry: %u)", cAura->spell_id, AdditionalSpellInfo->EffectApplyAuraName[cAura->effect_idx],GetGUIDLow(),GetEntry()); + AddAura(AdditionalSpellInfo, cAura->effectMask, this); + sLog.outDebug("Spell: %u with AuraEffectMask %u added to creature (GUID: %u Entry: %u)", cAura->spell_id, cAura->effectMask,GetGUIDLow(),GetEntry()); } } return true; |
