diff options
| author | megamage <none@none> | 2009-07-30 10:53:16 +0800 |
|---|---|---|
| committer | megamage <none@none> | 2009-07-30 10:53:16 +0800 |
| commit | 3926cb174b7a5ff98a69705092831a7111333377 (patch) | |
| tree | f34f9ac23333d2bb5e91cdda898b02264328a65b /src | |
| parent | dd94fb12d68677c01b906ab05ef8c8eb676554b3 (diff) | |
[8233] Implement new EventAI action ACTION_T_SET_INVINCEABILITY_HP_LEVEL. Author: VladimirMangos
Action set min. health value that can be set for creature in result damage apply.
It can be used in duel like events with creatures to prevent killing creature and other
cases when creature must avoid damage at some health level while it used.
--HG--
branch : trunk
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/CreatureEventAI.cpp | 21 | ||||
| -rw-r--r-- | src/game/CreatureEventAI.h | 18 | ||||
| -rw-r--r-- | src/game/CreatureEventAIMgr.cpp | 10 |
3 files changed, 44 insertions, 5 deletions
diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 6e8ac6a4909..6f7a8a89958 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -96,6 +96,8 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c) AttackDistance = 0.0f; AttackAngle = 0.0f; + InvinceabilityHpLevel = 0; + //Handle Spawned Events if (!bEmptyList) { @@ -792,6 +794,14 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 m_creature->ForcedDespawn(); break; } + case ACTION_T_SET_INVINCEABILITY_HP_LEVEL: + { + if(action.invinceability_hp_level.is_percent) + InvinceabilityHpLevel = m_creature->GetMaxHealth()*100/action.invinceability_hp_level.hp_level; + else + InvinceabilityHpLevel = action.invinceability_hp_level.hp_level; + break; + } } } @@ -1338,6 +1348,17 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote) } } +void CreatureEventAI::DamageTaken( Unit* done_by, uint32& damage ) +{ + if(InvinceabilityHpLevel > 0 && m_creature->GetHealth() < InvinceabilityHpLevel+damage) + { + if(m_creature->GetHealth() <= InvinceabilityHpLevel) + damage = 0; + else + damage = m_creature->GetHealth() - InvinceabilityHpLevel; + } +} + bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& event) { if(event.event_type != EVENT_T_SPAWNED) diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index ad3827ef75d..de46fee3eae 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -113,6 +113,7 @@ enum EventAI_ActionType ACTION_T_FORCE_DESPAWN = 41, // No Params ACTION_T_END = 105, + ACTION_T_SET_INVINCEABILITY_HP_LEVEL= 42, // MinHpValue, format(0-flat,1-percent from max health) }; enum Target @@ -379,6 +380,11 @@ struct CreatureEventAI_Action { uint32 sheath; } set_sheath; + struct + { + uint32 hp_level; + uint32 is_percent; + } invinceability_hp_level; // RAW struct { @@ -581,6 +587,7 @@ class TRINITY_DLL_SPEC CreatureEventAI : public CreatureAI void AttackStart(Unit *who); void MoveInLineOfSight(Unit *who); void SpellHit(Unit* pUnit, const SpellEntry* pSpell); + void DamageTaken(Unit* done_by, uint32& damage); void UpdateAI(const uint32 diff); void ReceiveEmote(Player* pPlayer, uint32 text_emote); static int Permissible(const Creature *); @@ -608,10 +615,11 @@ class TRINITY_DLL_SPEC CreatureEventAI : public CreatureAI bool bEmptyList; //Variables used by Events themselves - uint8 Phase; //Current phase, max 32 phases - bool CombatMovementEnabled; //If we allow targeted movment gen (movement twoards top threat) - bool MeleeEnabled; //If we allow melee auto attack - float AttackDistance; //Distance to attack from - float AttackAngle; //Angle of attack + uint8 Phase; // Current phase, max 32 phases + bool CombatMovementEnabled; // If we allow targeted movment gen (movement twoards top threat) + bool MeleeEnabled; // If we allow melee auto attack + float AttackDistance; // Distance to attack from + float AttackAngle; // Angle of attack + uint32 InvinceabilityHpLevel; // Minimal health level allowed at damage apply }; #endif diff --git a/src/game/CreatureEventAIMgr.cpp b/src/game/CreatureEventAIMgr.cpp index 18db935536b..94f83296536 100644 --- a/src/game/CreatureEventAIMgr.cpp +++ b/src/game/CreatureEventAIMgr.cpp @@ -661,6 +661,16 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() action.set_sheath.sheath = SHEATH_STATE_UNARMED; } break; + case ACTION_T_SET_INVINCEABILITY_HP_LEVEL: + if(action.invinceability_hp_level.is_percent) + { + if(action.invinceability_hp_level.hp_level > 100) + { + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses wrong percent value %u.", i, j+1, action.invinceability_hp_level.hp_level); + action.invinceability_hp_level.hp_level = 100; + } + } + break; case ACTION_T_EVADE: //No Params case ACTION_T_FLEE_FOR_ASSIST: //No Params case ACTION_T_DIE: //No Params |
