mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
[7863] Implement for EVENT_T_SPAWNED map/zone/subzone only event conditions. Author: Alex
--HG-- branch : trunk
This commit is contained in:
@@ -260,6 +260,8 @@ This Event is commonly used for NPC's who do something or say something to you w
|
||||
---------------------
|
||||
Expires at initial spawn and at creature respawn.
|
||||
This Event is commonly used for setting ranged movement type or Summoning a Pet on Spawn
|
||||
Parameter 1: 0: works always, 1: works on map in Parameter 2, 2: works on zone/subzone in Parameter 2
|
||||
Parameter 2: depends on Parameter 1: for 1 it is map ID, for 2 it is area ID to check
|
||||
|
||||
-----------------------
|
||||
12 = EVENT_T_TARGET_HP:
|
||||
|
||||
@@ -134,10 +134,8 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
|
||||
if (!bEmptyList)
|
||||
{
|
||||
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
|
||||
{
|
||||
if ((*i).Event.event_type == EVENT_T_SPAWNED)
|
||||
if (SpawnedEventConditionsCheck((*i).Event))
|
||||
ProcessEvent(*i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,10 +807,8 @@ void CreatureEventAI::JustRespawned()
|
||||
|
||||
//Handle Spawned Events
|
||||
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
|
||||
{
|
||||
if ((*i).Event.event_type == EVENT_T_SPAWNED)
|
||||
if (SpawnedEventConditionsCheck((*i).Event))
|
||||
ProcessEvent(*i);
|
||||
}
|
||||
}
|
||||
|
||||
void CreatureEventAI::Reset()
|
||||
@@ -1344,3 +1340,30 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& event)
|
||||
{
|
||||
if(event.event_type != EVENT_T_SPAWNED)
|
||||
return false;
|
||||
|
||||
switch (event.spawned.condition)
|
||||
{
|
||||
case SPAWNED_EVENT_ALWAY:
|
||||
// always
|
||||
return true;
|
||||
case SPAWNED_EVENT_MAP:
|
||||
// map ID check
|
||||
return m_creature->GetMapId() == event.spawned.conditionValue1;
|
||||
case SPAWNED_EVENT_ZONE:
|
||||
{
|
||||
// zone ID check
|
||||
uint32 zone, area;
|
||||
m_creature->GetZoneAndAreaId(zone,area);
|
||||
return zone == event.spawned.conditionValue1 || area == event.spawned.conditionValue1;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ enum EventAI_Type
|
||||
EVENT_T_SPELLHIT = 8, // SpellID, School, RepeatMin, RepeatMax
|
||||
EVENT_T_RANGE = 9, // MinDist, MaxDist, RepeatMin, RepeatMax
|
||||
EVENT_T_OOC_LOS = 10, // NoHostile, MaxRnage, RepeatMin, RepeatMax
|
||||
EVENT_T_SPAWNED = 11, // NONE
|
||||
EVENT_T_SPAWNED = 11, // Condition, CondValue1
|
||||
EVENT_T_TARGET_HP = 12, // HPMax%, HPMin%, RepeatMin, RepeatMax
|
||||
EVENT_T_TARGET_CASTING = 13, // RepeatMin, RepeatMax
|
||||
EVENT_T_FRIENDLY_HP = 14, // HPDeficit, Radius, RepeatMin, RepeatMax
|
||||
@@ -160,6 +160,13 @@ enum EventFlags
|
||||
EFLAG_DEBUG_ONLY = 0x80, //Event only occurs in debug build
|
||||
};
|
||||
|
||||
enum SpawnedEventMode
|
||||
{
|
||||
SPAWNED_EVENT_ALWAY = 0,
|
||||
SPAWNED_EVENT_MAP = 1,
|
||||
SPAWNED_EVENT_ZONE = 2
|
||||
};
|
||||
|
||||
// String text additional data, used in (CreatureEventAI)
|
||||
struct StringTextData
|
||||
{
|
||||
@@ -436,6 +443,12 @@ struct CreatureEventAI_Event
|
||||
uint32 repeatMin;
|
||||
uint32 repeatMax;
|
||||
} ooc_los;
|
||||
// EVENT_T_SPAWNED = 11
|
||||
struct
|
||||
{
|
||||
uint32 condition;
|
||||
uint32 conditionValue1;
|
||||
} spawned;
|
||||
// EVENT_T_TARGET_CASTING = 13
|
||||
struct
|
||||
{
|
||||
@@ -563,6 +576,8 @@ class TRINITY_DLL_SPEC CreatureEventAI : public CreatureAI
|
||||
void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target);
|
||||
bool CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered);
|
||||
|
||||
bool SpawnedEventConditionsCheck(CreatureEventAI_Event const& event);
|
||||
|
||||
Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff);
|
||||
void DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid);
|
||||
void DoFindFriendlyCC(std::list<Creature*>& _list, float range);
|
||||
|
||||
@@ -283,6 +283,23 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
|
||||
if (temp.ooc_los.repeatMax < temp.ooc_los.repeatMin)
|
||||
sLog.outErrorDb("CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
|
||||
break;
|
||||
case EVENT_T_SPAWNED:
|
||||
switch(temp.spawned.condition)
|
||||
{
|
||||
case SPAWNED_EVENT_ALWAY:
|
||||
break;
|
||||
case SPAWNED_EVENT_MAP:
|
||||
if(!sMapStore.LookupEntry(temp.spawned.conditionValue1))
|
||||
sLog.outErrorDb("CreatureEventAI: Creature %u are using spawned event(%u) with param1 = %u 'map specific' but with not existed map (%u) in param2. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1);
|
||||
break;
|
||||
case SPAWNED_EVENT_ZONE:
|
||||
if(!GetAreaEntryByAreaID(temp.spawned.conditionValue1))
|
||||
sLog.outErrorDb("CreatureEventAI: Creature %u are using spawned event(%u) with param1 = %u 'area specific' but with not existed area (%u) in param2. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1);
|
||||
default:
|
||||
sLog.outErrorDb("CreatureEventAI: Creature %u are using invalid spawned event %u mode (%u) in param1", temp.creature_id, i, temp.spawned.condition);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case EVENT_T_FRIENDLY_HP:
|
||||
if (temp.friendly_hp.repeatMax < temp.friendly_hp.repeatMin)
|
||||
sLog.outErrorDb("CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
|
||||
@@ -327,7 +344,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
|
||||
case EVENT_T_AGGRO:
|
||||
case EVENT_T_DEATH:
|
||||
case EVENT_T_EVADE:
|
||||
case EVENT_T_SPAWNED:
|
||||
case EVENT_T_REACHED_HOME:
|
||||
{
|
||||
if (temp.event_flags & EFLAG_REPEATABLE)
|
||||
|
||||
Reference in New Issue
Block a user