mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[8233] Implement new EventAI action ACTION_T_SET_INVINCEABILITY_HP_LEVEL.
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.
This commit is contained in:
parent
6c395cf79c
commit
dce0941511
5 changed files with 54 additions and 6 deletions
|
|
@ -137,6 +137,7 @@ Each event type has its own specific interpretation of it's params, like every e
|
||||||
39 ACTION_T_CALL_FOR_HELP Radius Call any friendly out-of-combat creatures in a radius (Param1) to attack current creature's target.
|
39 ACTION_T_CALL_FOR_HELP Radius Call any friendly out-of-combat creatures in a radius (Param1) to attack current creature's target.
|
||||||
40 ACTION_T_SET_SHEATH Sheath Sets sheath state for a creature (0 = no weapon, 1 = melee weapon, 2 = ranged weapon).
|
40 ACTION_T_SET_SHEATH Sheath Sets sheath state for a creature (0 = no weapon, 1 = melee weapon, 2 = ranged weapon).
|
||||||
41 ACTION_T_FORCE_DESPAWN No Params Despawns the creature
|
41 ACTION_T_FORCE_DESPAWN No Params Despawns the creature
|
||||||
|
42 ACTION_T_SET_INVINCEABILITY_HP_LEVEL hp_level, is_percent Set min. health level for creature that can be set at damage as flat value or percent from max health
|
||||||
|
|
||||||
* = Use -1 where the param is expected to do nothing. Random constant is generated for each event, so if you have a random yell and a random sound, they will be linked up with each other (ie. param2 with param2).
|
* = Use -1 where the param is expected to do nothing. Random constant is generated for each event, so if you have a random yell and a random sound, they will be linked up with each other (ie. param2 with param2).
|
||||||
|
|
||||||
|
|
@ -737,6 +738,14 @@ This possible setup by set ar event AI start (single used EVENT_T_TIMER_OOC set
|
||||||
Despawns the creature (in or out of combat)
|
Despawns the creature (in or out of combat)
|
||||||
No parameters
|
No parameters
|
||||||
|
|
||||||
|
-------------------------
|
||||||
|
42 ACTION_T_SET_INVINCEABILITY_HP_LEVEL
|
||||||
|
-------------------------
|
||||||
|
Parameter 1: min. health level for creature that can be set at damage, 0 used as absent min. health value for apply damage.
|
||||||
|
Parameter 2: format of paramater 1 value
|
||||||
|
0 paramater 1 used as flat value
|
||||||
|
1 paramater 1 used as percent (0..100) from creature max health
|
||||||
|
|
||||||
=========================================
|
=========================================
|
||||||
Target Types
|
Target Types
|
||||||
=========================================
|
=========================================
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,8 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
|
||||||
AttackDistance = 0.0f;
|
AttackDistance = 0.0f;
|
||||||
AttackAngle = 0.0f;
|
AttackAngle = 0.0f;
|
||||||
|
|
||||||
|
InvinceabilityHpLevel = 0;
|
||||||
|
|
||||||
//Handle Spawned Events
|
//Handle Spawned Events
|
||||||
if (!bEmptyList)
|
if (!bEmptyList)
|
||||||
{
|
{
|
||||||
|
|
@ -780,6 +782,14 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
||||||
m_creature->ForcedDespawn();
|
m_creature->ForcedDespawn();
|
||||||
break;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1380,6 +1390,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)
|
bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& event)
|
||||||
{
|
{
|
||||||
if(event.event_type != EVENT_T_SPAWNED)
|
if(event.event_type != EVENT_T_SPAWNED)
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ enum EventAI_ActionType
|
||||||
ACTION_T_CALL_FOR_HELP = 39, // Radius
|
ACTION_T_CALL_FOR_HELP = 39, // Radius
|
||||||
ACTION_T_SET_SHEATH = 40, // Sheath (0-passive,1-melee,2-ranged)
|
ACTION_T_SET_SHEATH = 40, // Sheath (0-passive,1-melee,2-ranged)
|
||||||
ACTION_T_FORCE_DESPAWN = 41, // No Params
|
ACTION_T_FORCE_DESPAWN = 41, // No Params
|
||||||
|
ACTION_T_SET_INVINCEABILITY_HP_LEVEL= 42, // MinHpValue, format(0-flat,1-percent from max health)
|
||||||
ACTION_T_END,
|
ACTION_T_END,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -373,6 +374,11 @@ struct CreatureEventAI_Action
|
||||||
{
|
{
|
||||||
uint32 sheath;
|
uint32 sheath;
|
||||||
} set_sheath;
|
} set_sheath;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32 hp_level;
|
||||||
|
uint32 is_percent;
|
||||||
|
} invinceability_hp_level;
|
||||||
// RAW
|
// RAW
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
|
@ -575,6 +581,7 @@ class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI
|
||||||
void AttackStart(Unit *who);
|
void AttackStart(Unit *who);
|
||||||
void MoveInLineOfSight(Unit *who);
|
void MoveInLineOfSight(Unit *who);
|
||||||
void SpellHit(Unit* pUnit, const SpellEntry* pSpell);
|
void SpellHit(Unit* pUnit, const SpellEntry* pSpell);
|
||||||
|
void DamageTaken(Unit* done_by, uint32& damage);
|
||||||
void UpdateAI(const uint32 diff);
|
void UpdateAI(const uint32 diff);
|
||||||
bool IsVisible(Unit *) const;
|
bool IsVisible(Unit *) const;
|
||||||
void ReceiveEmote(Player* pPlayer, uint32 text_emote);
|
void ReceiveEmote(Player* pPlayer, uint32 text_emote);
|
||||||
|
|
@ -604,10 +611,11 @@ class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI
|
||||||
bool bEmptyList;
|
bool bEmptyList;
|
||||||
|
|
||||||
//Variables used by Events themselves
|
//Variables used by Events themselves
|
||||||
uint8 Phase; //Current phase, max 32 phases
|
uint8 Phase; // Current phase, max 32 phases
|
||||||
bool CombatMovementEnabled; //If we allow targeted movment gen (movement twoards top threat)
|
bool CombatMovementEnabled; // If we allow targeted movment gen (movement twoards top threat)
|
||||||
bool MeleeEnabled; //If we allow melee auto attack
|
bool MeleeEnabled; // If we allow melee auto attack
|
||||||
float AttackDistance; //Distance to attack from
|
float AttackDistance; // Distance to attack from
|
||||||
float AttackAngle; //Angle of attack
|
float AttackAngle; // Angle of attack
|
||||||
|
uint32 InvinceabilityHpLevel; // Minimal health level allowed at damage apply
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -661,6 +661,16 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
|
||||||
action.set_sheath.sheath = SHEATH_STATE_UNARMED;
|
action.set_sheath.sheath = SHEATH_STATE_UNARMED;
|
||||||
}
|
}
|
||||||
break;
|
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_EVADE: //No Params
|
||||||
case ACTION_T_FLEE_FOR_ASSIST: //No Params
|
case ACTION_T_FLEE_FOR_ASSIST: //No Params
|
||||||
case ACTION_T_DIE: //No Params
|
case ACTION_T_DIE: //No Params
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8232"
|
#define REVISION_NR "8233"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue