[7847] Replace paramter unions by uniton of event ai action type structures. Add/fix some loading checks. Author: VladimirMangos
* Also send to process function reference to strucutre instead large amount fields.
* Specially note that fixed check for first arg of action type 27 that before wrongly test as quest id,
when by using code expected creature id. Possible some used data wrongly can be quest ids....
--HG--
branch : trunk
This commit is contained in:
+202
-22
@@ -30,6 +30,7 @@ class WorldObject;
|
||||
#define EVENT_UPDATE_TIME 500
|
||||
#define SPELL_RUN_AWAY 8225
|
||||
#define MAX_ACTIONS 3
|
||||
#define MAX_PHASE 32
|
||||
|
||||
enum EventAI_Type
|
||||
{
|
||||
@@ -78,7 +79,7 @@ enum EventAI_ActionType
|
||||
ACTION_T_THREAT_SINGLE_PCT = 13, //*Threat%, Target
|
||||
ACTION_T_THREAT_ALL_PCT = 14, //Threat%
|
||||
ACTION_T_QUEST_EVENT = 15, //*QuestID, Target
|
||||
ACTION_T_CASTCREATUREGO = 16, //*QuestID, SpellId, Target
|
||||
ACTION_T_CAST_EVENT = 16, //*QuestID, SpellId, Target - must be removed as hack?
|
||||
ACTION_T_SET_UNIT_FIELD = 17, //*Field_Number, Value, Target
|
||||
ACTION_T_SET_UNIT_FLAG = 18, //*Flags (may be more than one field OR'd together), Target
|
||||
ACTION_T_REMOVE_UNIT_FLAG = 19, //*Flags (may be more than one field OR'd together), Target
|
||||
@@ -89,7 +90,7 @@ enum EventAI_ActionType
|
||||
ACTION_T_EVADE = 24, //No Params
|
||||
ACTION_T_FLEE = 25, //No Params
|
||||
ACTION_T_QUEST_EVENT_ALL = 26, //*QuestID
|
||||
ACTION_T_CASTCREATUREGO_ALL = 27, //*QuestId, SpellId
|
||||
ACTION_T_CAST_EVENT_ALL = 27, //*QuestId, SpellId
|
||||
ACTION_T_REMOVEAURASFROMSPELL = 28, //*Target, Spellid
|
||||
ACTION_T_RANGED_MOVEMENT = 29, //Distance, Angle
|
||||
ACTION_T_RANDOM_PHASE = 30, //PhaseId1, PhaseId2, PhaseId3
|
||||
@@ -171,6 +172,202 @@ struct StringTextData
|
||||
// Text Maps
|
||||
typedef UNORDERED_MAP<int32, StringTextData> CreatureEventAI_TextMap;
|
||||
|
||||
struct CreatureEventAI_Action
|
||||
{
|
||||
EventAI_ActionType type: 16;
|
||||
union
|
||||
{
|
||||
// ACTION_T_TEXT = 1
|
||||
struct
|
||||
{
|
||||
int32 TextId1;
|
||||
int32 TextId2;
|
||||
int32 TextId3;
|
||||
} text;
|
||||
// ACTION_T_SET_FACTION = 2
|
||||
struct
|
||||
{
|
||||
uint32 factionId; // faction or 0 for default)
|
||||
} set_faction;
|
||||
// ACTION_T_MORPH_TO_ENTRY_OR_MODEL = 3
|
||||
struct
|
||||
{
|
||||
uint32 creatireId; // set one from fields (or 0 for both to demorph)
|
||||
uint32 modelId;
|
||||
} morph;
|
||||
// ACTION_T_SOUND = 4
|
||||
struct
|
||||
{
|
||||
uint32 soundId;
|
||||
} sound;
|
||||
// ACTION_T_EMOTE = 5
|
||||
struct
|
||||
{
|
||||
uint32 emoteId;
|
||||
} emote;
|
||||
// ACTION_T_RANDOM_SOUND = 9
|
||||
struct
|
||||
{
|
||||
int32 soundId1; // (-1 in any field means no output if randomed that field)
|
||||
int32 soundId2;
|
||||
int32 soundId3;
|
||||
} random_sound;
|
||||
// ACTION_T_RANDOM_EMOTE = 10
|
||||
struct
|
||||
{
|
||||
int32 emoteId1; // (-1 in any field means no output if randomed that field)
|
||||
int32 emoteId2;
|
||||
int32 emoteId3;
|
||||
} random_emote;
|
||||
// ACTION_T_CAST = 11
|
||||
struct
|
||||
{
|
||||
uint32 spellId;
|
||||
uint32 target;
|
||||
uint32 castFlags;
|
||||
} cast;
|
||||
// ACTION_T_SUMMON = 12
|
||||
struct
|
||||
{
|
||||
uint32 creatured;
|
||||
uint32 target;
|
||||
uint32 duration;
|
||||
} summon;
|
||||
// ACTION_T_THREAT_SINGLE_PCT = 13
|
||||
struct
|
||||
{
|
||||
int32 percent;
|
||||
uint32 target;
|
||||
} threat_single_pct;
|
||||
// ACTION_T_THREAT_ALL_PCT = 14
|
||||
struct
|
||||
{
|
||||
int32 percent;
|
||||
} threat_all_pct;
|
||||
// ACTION_T_QUEST_EVENT = 15
|
||||
struct
|
||||
{
|
||||
uint32 questId;
|
||||
uint32 target;
|
||||
} quest_event;
|
||||
// ACTION_T_CAST_EVENT = 16
|
||||
struct
|
||||
{
|
||||
uint32 creatureId;
|
||||
uint32 spellId;
|
||||
uint32 target;
|
||||
} cast_event;
|
||||
// ACTION_T_SET_UNIT_FIELD = 17
|
||||
struct
|
||||
{
|
||||
uint32 field;
|
||||
uint32 value;
|
||||
uint32 target;
|
||||
} set_unit_field;
|
||||
// ACTION_T_SET_UNIT_FLAG = 18, // value provided mask bits that will be set
|
||||
// ACTION_T_REMOVE_UNIT_FLAG = 19, // value provided mask bits that will be clear
|
||||
struct
|
||||
{
|
||||
uint32 value;
|
||||
uint32 target;
|
||||
} unit_flag;
|
||||
// ACTION_T_AUTO_ATTACK = 20
|
||||
struct
|
||||
{
|
||||
uint32 state; // 0 = stop attack, anything else means continue attacking
|
||||
} auto_attack;
|
||||
// ACTION_T_COMBAT_MOVEMENT = 21
|
||||
struct
|
||||
{
|
||||
uint32 state; // 0 = stop combat based movement, anything else continue attacking
|
||||
} combat_movement;
|
||||
// ACTION_T_SET_PHASE = 22
|
||||
struct
|
||||
{
|
||||
uint32 phase;
|
||||
} set_phase;
|
||||
// ACTION_T_INC_PHASE = 23
|
||||
struct
|
||||
{
|
||||
int32 step;
|
||||
} set_inc_phase;
|
||||
// ACTION_T_QUEST_EVENT_ALL = 26
|
||||
struct
|
||||
{
|
||||
uint32 questId;
|
||||
} quest_event_all;
|
||||
// ACTION_T_CAST_EVENT_ALL = 27
|
||||
struct
|
||||
{
|
||||
uint32 creatureId;
|
||||
uint32 spellId;
|
||||
} cast_event_all;
|
||||
// ACTION_T_REMOVEAURASFROMSPELL = 28
|
||||
struct
|
||||
{
|
||||
uint32 target;
|
||||
uint32 spellId;
|
||||
} remove_aura;
|
||||
// ACTION_T_RANGED_MOVEMENT = 29
|
||||
struct
|
||||
{
|
||||
uint32 distance;
|
||||
int32 angle;
|
||||
} ranged_movement;
|
||||
// ACTION_T_RANDOM_PHASE = 30
|
||||
struct
|
||||
{
|
||||
uint32 phase1;
|
||||
uint32 phase2;
|
||||
uint32 phase3;
|
||||
} random_phase;
|
||||
// ACTION_T_RANDOM_PHASE_RANGE = 31
|
||||
struct
|
||||
{
|
||||
uint32 phaseMin;
|
||||
uint32 phaseMax;
|
||||
} random_phase_range;
|
||||
// ACTION_T_SUMMON_ID = 32
|
||||
struct
|
||||
{
|
||||
uint32 creatureId;
|
||||
uint32 target;
|
||||
uint32 spawnId;
|
||||
} summon_id;
|
||||
// ACTION_T_KILLED_MONSTER = 33
|
||||
struct
|
||||
{
|
||||
uint32 creatureId;
|
||||
uint32 target;
|
||||
} killed_monster;
|
||||
// ACTION_T_SET_INST_DATA = 34
|
||||
struct
|
||||
{
|
||||
uint32 field;
|
||||
uint32 value;
|
||||
} set_inst_data;
|
||||
// ACTION_T_SET_INST_DATA64 = 35
|
||||
struct
|
||||
{
|
||||
uint32 field;
|
||||
uint32 target;
|
||||
} set_inst_data64;
|
||||
// ACTION_T_UPDATE_TEMPLATE = 36, //*Entry, Team
|
||||
struct
|
||||
{
|
||||
uint32 creatureId;
|
||||
uint32 team;
|
||||
} update_template;
|
||||
// RAW
|
||||
struct
|
||||
{
|
||||
uint32 param1;
|
||||
uint32 param2;
|
||||
uint32 param3;
|
||||
} raw;
|
||||
};
|
||||
};
|
||||
|
||||
struct CreatureEventAI_Event
|
||||
{
|
||||
uint32 event_id;
|
||||
@@ -204,25 +401,7 @@ struct CreatureEventAI_Event
|
||||
int32 event_param4_s;
|
||||
};
|
||||
|
||||
struct _action
|
||||
{
|
||||
EventAI_ActionType type: 16;
|
||||
union
|
||||
{
|
||||
uint32 param1;
|
||||
int32 param1_s;
|
||||
};
|
||||
union
|
||||
{
|
||||
uint32 param2;
|
||||
int32 param2_s;
|
||||
};
|
||||
union
|
||||
{
|
||||
uint32 param3;
|
||||
int32 param3_s;
|
||||
};
|
||||
}action[MAX_ACTIONS];
|
||||
CreatureEventAI_Action action[MAX_ACTIONS];
|
||||
};
|
||||
//Event_Map
|
||||
typedef UNORDERED_MAP<uint32, std::vector<CreatureEventAI_Event> > CreatureEventAI_Event_Map;
|
||||
@@ -275,8 +454,9 @@ class TRINITY_DLL_SPEC CreatureEventAI : public CreatureAI
|
||||
static int Permissible(const Creature *);
|
||||
|
||||
bool ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker = NULL);
|
||||
void ProcessAction(uint16 type, uint32 param1, uint32 param2, uint32 param3, uint32 rnd, uint32 EventId, Unit* pActionInvoker);
|
||||
void ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker);
|
||||
inline uint32 GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3);
|
||||
inline int32 GetRandActionParam(uint32 rnd, int32 param1, int32 param2, int32 param3);
|
||||
inline Unit* GetTargetByType(uint32 Target, Unit* pActionInvoker);
|
||||
inline Unit* SelectUnit(AttackingTarget target, uint32 position);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user