Core/AI: Remove default arguments for inter-script communication

This commit is contained in:
ModoX
2024-12-29 00:17:07 +01:00
parent 309ba22a15
commit 6b96facee3
19 changed files with 111 additions and 58 deletions

View File

@@ -61,10 +61,10 @@ class TC_GAME_API AreaTriggerAI
// Pass parameters between AI
virtual void DoAction([[maybe_unused]] int32 param) { }
virtual uint32 GetData([[maybe_unused]] uint32 id = 0) const { return 0; }
virtual uint32 GetData([[maybe_unused]] uint32 id) const { return 0; }
virtual void SetData([[maybe_unused]] uint32 id, [[maybe_unused]] uint32 value) { }
virtual void SetGUID([[maybe_unused]] ObjectGuid const& guid, [[maybe_unused]] int32 id = 0) { }
virtual ObjectGuid GetGUID([[maybe_unused]] int32 id = 0) const { return ObjectGuid::Empty; }
virtual void SetGUID([[maybe_unused]] ObjectGuid const& guid, [[maybe_unused]] int32 id) { }
virtual ObjectGuid GetGUID([[maybe_unused]] int32 id) const { return ObjectGuid::Empty; }
// Gets the id of the AI (script id)
uint32 GetId() const { return _scriptId; }

View File

@@ -55,10 +55,10 @@ class TC_GAME_API ConversationAI
// Pass parameters between AI
virtual void DoAction([[maybe_unused]] int32 param) { }
virtual uint32 GetData([[maybe_unused]] uint32 id = 0) const { return 0; }
virtual uint32 GetData([[maybe_unused]] uint32 id) const { return 0; }
virtual void SetData([[maybe_unused]] uint32 id, [[maybe_unused]] uint32 value) { }
virtual void SetGUID([[maybe_unused]] ObjectGuid const& guid, [[maybe_unused]] int32 id = 0) { }
virtual ObjectGuid GetGUID([[maybe_unused]] int32 id = 0) const { return ObjectGuid::Empty; }
virtual void SetGUID([[maybe_unused]] ObjectGuid const& guid, [[maybe_unused]] int32 id) { }
virtual ObjectGuid GetGUID([[maybe_unused]] int32 id) const { return ObjectGuid::Empty; }
// Gets the id of the AI (script id)
uint32 GetId() const { return _scriptId; }

View File

@@ -63,9 +63,9 @@ class TC_GAME_API GameObjectAI
virtual void Reset() { }
// Pass parameters between AI
virtual void DoAction(int32 /*param = 0 */) { }
virtual void SetGUID(ObjectGuid const& /*guid*/, int32 /*id = 0 */) { }
virtual ObjectGuid GetGUID(int32 /*id = 0 */) const { return ObjectGuid::Empty; }
virtual void DoAction([[maybe_unused]] int32 param) { }
virtual void SetGUID([[maybe_unused]] ObjectGuid const& guid, [[maybe_unused]] int32 id) { }
virtual ObjectGuid GetGUID([[maybe_unused]] int32 id) const { return ObjectGuid::Empty; }
static int32 Permissible(GameObject const* go);

View File

@@ -69,11 +69,11 @@ class TC_GAME_API UnitAI
virtual void OnCharmed(bool isNew);
// Pass parameters between AI
virtual void DoAction(int32 /*param*/) { }
virtual uint32 GetData(uint32 /*id = 0*/) const { return 0; }
virtual void SetData(uint32 /*id*/, uint32 /*value*/) { }
virtual void SetGUID(ObjectGuid const& /*guid*/, int32 /*id*/ = 0) { }
virtual ObjectGuid GetGUID(int32 /*id*/ = 0) const { return ObjectGuid::Empty; }
virtual void DoAction([[maybe_unused]] int32 param) { }
virtual uint32 GetData([[maybe_unused]] uint32 id) const { return 0; }
virtual void SetData([[maybe_unused]] uint32 id, [[maybe_unused]] uint32 value) { }
virtual void SetGUID([[maybe_unused]] ObjectGuid const& guid, [[maybe_unused]] int32 id) { }
virtual ObjectGuid GetGUID([[maybe_unused]] int32 id) const { return ObjectGuid::Empty; }
// Select the best target (in <targetType> order) from the threat list that fulfill the following:
// - Not among the first <offset> entries in <targetType> order (or SelectTargetMethod::MaxThreat order,

View File

@@ -174,20 +174,20 @@ class TC_GAME_API SmartAI : public CreatureAI
void OnCharmed(bool isNew) override;
// Used in scripts to share variables
void DoAction(int32 param = 0) override;
void DoAction(int32 param) override;
// Used in scripts to share variables
uint32 GetData(uint32 id = 0) const override;
uint32 GetData(uint32 id) const override;
// Used in scripts to share variables
void SetData(uint32 id, uint32 value) override { SetData(id, value, nullptr); }
void SetData(uint32 id, uint32 value, Unit* invoker);
// Used in scripts to share variables
void SetGUID(ObjectGuid const& guid, int32 id = 0) override;
void SetGUID(ObjectGuid const& guid, int32 id) override;
// Used in scripts to share variables
ObjectGuid GetGUID(int32 id = 0) const override;
ObjectGuid GetGUID(int32 id) const override;
// Makes the creature run/walk
void SetRun(bool run = true);

View File

@@ -73,6 +73,11 @@ enum UnworthyInitiatePhase
PHASE_ATTACKING,
};
enum UnworthyInitiateData
{
DATA_PRISONER_GUID = 0
};
uint32 acherus_soul_prison[12] =
{
191577,
@@ -191,7 +196,7 @@ public:
{
if (Creature* anchor = me->FindNearestCreature(29521, 30))
{
anchor->AI()->SetGUID(me->GetGUID());
anchor->AI()->SetGUID(me->GetGUID(), DATA_PRISONER_GUID);
anchor->CastSpell(me, SPELL_SOUL_PRISON_CHAIN, true);
anchorGUID = anchor->GetGUID();
}
@@ -312,8 +317,11 @@ public:
ObjectGuid prisonerGUID;
void SetGUID(ObjectGuid const& guid, int32 /*id*/) override
void SetGUID(ObjectGuid const& guid, int32 id) override
{
if (id != DATA_PRISONER_GUID)
return;
prisonerGUID = guid;
}
@@ -337,7 +345,7 @@ class go_acherus_soul_prison : public GameObjectScript
{
if (Creature* anchor = me->FindNearestCreature(29521, 15))
{
ObjectGuid prisonerGUID = anchor->AI()->GetGUID();
ObjectGuid prisonerGUID = anchor->AI()->GetGUID(DATA_PRISONER_GUID);
if (!prisonerGUID.IsEmpty())
if (Creature* prisoner = ObjectAccessor::GetCreature(*player, prisonerGUID))
ENSURE_AI(npc_unworthy_initiate::npc_unworthy_initiateAI, prisoner->AI())->EventStart(anchor, player);

View File

@@ -88,12 +88,13 @@ enum Action
ACTION_REVIVE = 1
};
enum Misc
enum MandokirMisc
{
POINT_START_REVIVE = 1,
DATA_OHGANOT_SO_FAST = 5762,
DATA_REVIVE_GUID = 0,
};
enum SummonGroups
@@ -198,7 +199,7 @@ struct boss_mandokir : public BossAI
{
if (Creature* chainedSpirit = ObjectAccessor::GetCreature(*me, (*itr)->GetGUID()))
{
chainedSpirit->AI()->SetGUID(_reviveGUID);
chainedSpirit->AI()->SetGUID(_reviveGUID, DATA_REVIVE_GUID);
chainedSpirit->AI()->DoAction(ACTION_REVIVE);
_reviveGUID.Clear();
}
@@ -219,7 +220,7 @@ struct boss_mandokir : public BossAI
return 0;
}
void SetGUID(ObjectGuid const& guid, int32 /*type = 0 */) override
void SetGUID(ObjectGuid const& guid, int32 /*type*/) override
{
_reviveGUID = guid;
}
@@ -343,7 +344,7 @@ struct npc_chained_spirit : public ScriptedAI
_revivePlayerGUID.Clear();
}
void SetGUID(ObjectGuid const& guid, int32 /*type = 0 */) override
void SetGUID(ObjectGuid const& guid, int32 /*type*/) override
{
_revivePlayerGUID = guid;
}
@@ -383,7 +384,7 @@ struct npc_chained_spirit : public ScriptedAI
if (Creature* mandokir = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_MANDOKIR)))
{
mandokir->GetAI()->SetGUID(target->GetGUID());
mandokir->GetAI()->SetGUID(target->GetGUID(), DATA_REVIVE_GUID);
mandokir->GetAI()->DoAction(ACTION_START_REVIVE);
}

View File

@@ -85,7 +85,8 @@ enum InnEventLines
enum InnEventMisc
{
DATA_REQUEST_FACING = 0,
DATA_REACHED_WP = 1
DATA_REACHED_WP = 1,
DATA_INVOKING_PLAYER_GUID,
};
class npc_hearthsinger_forresten_cot : public CreatureScript
@@ -158,8 +159,11 @@ class npc_hearthsinger_forresten_cot : public CreatureScript
}
// Player has hit the Belfast stairs areatrigger, we are taking him over for a moment
void SetGUID(ObjectGuid const& guid, int32 /*id*/) override
void SetGUID(ObjectGuid const& guid, int32 id) override
{
if (id != DATA_INVOKING_PLAYER_GUID)
return;
if (_hadBelfast)
return;
_hadBelfast = true;
@@ -226,7 +230,7 @@ class at_stratholme_inn_stairs_cot : public AreaTriggerScript
if (instance->GetData(DATA_INSTANCE_PROGRESS) <= CRATES_IN_PROGRESS)
// Forrest's script will handle Belfast for this, since SmartAI lacks the features to do it (we can't pass a custom target)
if (Creature* forrest = player->FindNearestCreature(NPC_FORREST, 200.0f, true))
forrest->AI()->SetGUID(player->GetGUID());
forrest->AI()->SetGUID(player->GetGUID(), DATA_INVOKING_PLAYER_GUID);
return true;
}
};

View File

@@ -218,7 +218,7 @@ struct boss_baleroc : public firelands_bossAI
firelands_bossAI::UpdateAI(diff);
}
void SetGUID(ObjectGuid const& guid, int32 type = 0) override
void SetGUID(ObjectGuid const& guid, int32 type) override
{
switch (type)
{

View File

@@ -54,7 +54,9 @@ enum PrinceTaldaramMisc
{
DATA_EMBRACE_DMG = 20000,
H_DATA_EMBRACE_DMG = 40000,
SUMMON_GROUP_CONTROLLERS = 1
SUMMON_GROUP_CONTROLLERS = 1,
DATA_FLAME_SPHERE_TARGET_GUID = 0,
};
enum PrinceTaldaramYells
@@ -123,7 +125,7 @@ struct boss_prince_taldaram : public BossAI
case NPC_FLAME_SPHERE_1:
case NPC_FLAME_SPHERE_2:
case NPC_FLAME_SPHERE_3:
summon->AI()->SetGUID(_flameSphereTargetGUID);
summon->AI()->SetGUID(_flameSphereTargetGUID, DATA_FLAME_SPHERE_TARGET_GUID);
break;
case NPC_JEDOGA_CONTROLLER:
summon->CastSpell(me, SPELL_BEAM_VISUAL);
@@ -307,8 +309,11 @@ struct npc_prince_taldaram_flame_sphere : public ScriptedAI
_events.ScheduleEvent(EVENT_DESPAWN, 13s);
}
void SetGUID(ObjectGuid const& guid, int32 /*id*/) override
void SetGUID(ObjectGuid const& guid, int32 id) override
{
if (id != DATA_FLAME_SPHERE_TARGET_GUID)
return;
_flameSphereTargetGUID = guid;
}

View File

@@ -116,7 +116,8 @@ enum Data
{
DATA_CRUSHER_PACK_ID = 1,
DATA_HADRONOX_ENTERED_COMBAT,
DATA_HADRONOX_WEBBED_DOORS
DATA_HADRONOX_WEBBED_DOORS,
DATA_ANUBAR_GUID,
};
enum Creatures
@@ -264,8 +265,11 @@ struct boss_hadronox : public BossAI
nerubian->DespawnOrUnsummon();
}
void SetGUID(ObjectGuid const& guid, int32 /*id*/) override
void SetGUID(ObjectGuid const& guid, int32 id) override
{
if (id != DATA_ANUBAR_GUID)
return;
_anubar.push_back(guid);
}
@@ -664,7 +668,7 @@ struct npc_hadronox_foeAI : public ScriptedAI
{
ScriptedAI::InitializeAI();
if (Creature* hadronox = _instance->GetCreature(DATA_HADRONOX))
hadronox->AI()->SetGUID(me->GetGUID());
hadronox->AI()->SetGUID(me->GetGUID(), DATA_ANUBAR_GUID);
}
void MovementInform(uint32 type, uint32 id) override

View File

@@ -179,7 +179,8 @@ enum Misc
DATA_MATERIAL_DAMAGE_TAKEN = 2,
DATA_STACKS_DISPELLED = 3,
DATA_FIGHT_PHASE = 4,
DATA_SPAWNED_FLAMES = 5
DATA_SPAWNED_FLAMES = 5,
DATA_ROOT_GUID = 6,
};
enum OrbCarrierSeats
@@ -1110,7 +1111,7 @@ class npc_meteor_strike : public CreatureScript
{
Position pos = me->GetNearPosition(5.0f, frand(-static_cast<float>(M_PI / 6.0f), static_cast<float>(M_PI / 6.0f)));
if (Creature* flame = me->SummonCreature(NPC_METEOR_STRIKE_FLAME, pos, TEMPSUMMON_TIMED_DESPAWN, 25s))
flame->AI()->SetGUID(me->GetGUID());
flame->AI()->SetGUID(me->GetGUID(), DATA_ROOT_GUID);
}
}
@@ -1139,8 +1140,11 @@ class npc_meteor_strike_flame : public CreatureScript
SetCombatMovement(false);
}
void SetGUID(ObjectGuid const& guid, int32 /*id*/) override
void SetGUID(ObjectGuid const& guid, int32 id) override
{
if (id != DATA_ROOT_GUID)
return;
_rootOwnerGuid = guid;
_events.ScheduleEvent(EVENT_SPAWN_METEOR_FLAME, Milliseconds(800));
}
@@ -1170,7 +1174,7 @@ class npc_meteor_strike_flame : public CreatureScript
Position pos = me->GetNearPosition(5.0f, frand(-static_cast<float>(M_PI / 6.0f), static_cast<float>(M_PI / 6.0f)));
if (Creature* flame = me->SummonCreature(NPC_METEOR_STRIKE_FLAME, pos, TEMPSUMMON_TIMED_DESPAWN, 25s))
flame->AI()->SetGUID(_rootOwnerGuid);
flame->AI()->SetGUID(_rootOwnerGuid, DATA_ROOT_GUID);
}
void EnterEvadeMode(EvadeReason /*why*/) override { }

View File

@@ -170,7 +170,8 @@ enum Misc
SUMMON_PRINCES_GROUP = 1,
DATA_INTRO = 2,
DATA_INTRO_DONE = 3,
DATA_PRINCE_EVADE = 4
DATA_PRINCE_EVADE = 4,
DATA_CHASE_TARGET_GUID = 5,
};
class StandUpEvent : public BasicEvent
@@ -698,7 +699,7 @@ struct boss_prince_taldaram_icc : public BloodPrincesBossAI
Talk(EMOTE_TALDARAM_FLAME, target);
if (target)
summon->AI()->SetGUID(target->GetGUID());
summon->AI()->SetGUID(target->GetGUID(), DATA_CHASE_TARGET_GUID);
}
void UpdateAI(uint32 diff) override
@@ -930,8 +931,11 @@ struct npc_ball_of_flame : public ScriptedAI
}
}
void SetGUID(ObjectGuid const& guid, int32 /*id*/) override
void SetGUID(ObjectGuid const& guid, int32 id) override
{
if (id != DATA_CHASE_TARGET_GUID)
return;
_chaseGUID = guid;
}

View File

@@ -166,6 +166,11 @@ enum Actions
ACTION_START_INTRO
};
enum LadyDeathwhisperData
{
DATA_VENGEFUL_SHADE_TARGET_GUID = 0
};
#define NPC_DARNAVAN RAID_MODE<uint32>(NPC_DARNAVAN_10, NPC_DARNAVAN_25, NPC_DARNAVAN_10, NPC_DARNAVAN_25)
#define NPC_DARNAVAN_CREDIT RAID_MODE<uint32>(NPC_DARNAVAN_CREDIT_10, NPC_DARNAVAN_CREDIT_25, NPC_DARNAVAN_CREDIT_10, NPC_DARNAVAN_CREDIT_25)
#define QUEST_DEPROGRAMMING RAID_MODE<uint32>(QUEST_DEPROGRAMMING_10, QUEST_DEPROGRAMMING_25, QUEST_DEPROGRAMMING_10, QUEST_DEPROGRAMMING_25)
@@ -477,7 +482,7 @@ struct boss_lady_deathwhisper : public BossAI
case NPC_VENGEFUL_SHADE:
if (_nextVengefulShadeTargetGUID.empty())
break;
summon->AI()->SetGUID(_nextVengefulShadeTargetGUID.front());
summon->AI()->SetGUID(_nextVengefulShadeTargetGUID.front(), DATA_VENGEFUL_SHADE_TARGET_GUID);
_nextVengefulShadeTargetGUID.pop_front();
break;
case NPC_CULT_ADHERENT:
@@ -782,8 +787,11 @@ struct npc_vengeful_shade : public ScriptedAI
});
}
void SetGUID(ObjectGuid const& guid, int32 /*id*/) override
void SetGUID(ObjectGuid const& guid, int32 id) override
{
if (id != DATA_VENGEFUL_SHADE_TARGET_GUID)
return;
_targetGUID = guid;
}

View File

@@ -291,7 +291,7 @@ struct boss_lord_marrowgar : public BossAI
return &_coldflameLastPos;
}
ObjectGuid GetGUID(int32 type /*= 0 */) const override
ObjectGuid GetGUID(int32 type) const override
{
switch (type)
{

View File

@@ -358,13 +358,11 @@ enum MiscData
SOUND_PAIN = 17360, // separate sound, not attached to any text
EQUIP_ASHBRINGER_GLOWING = 50442,
EQUIP_BROKEN_FROSTMOURNE = 50840
};
EQUIP_BROKEN_FROSTMOURNE = 50840,
enum Misc
{
DATA_PLAGUE_STACK = 70337,
DATA_VILE = 45814622,
DATA_GRABBED_PLAYER_GUID = 0,
GOSSIP_MENU_START_INTRO = 10993
};
@@ -1500,8 +1498,11 @@ struct npc_valkyr_shadowguard : public ScriptedAI
}
}
void SetGUID(ObjectGuid const& guid, int32 /*id*/) override
void SetGUID(ObjectGuid const& guid, int32 id) override
{
if (id != DATA_GRABBED_PLAYER_GUID)
return;
_grabbedPlayer = guid;
}
@@ -2304,7 +2305,7 @@ class spell_the_lich_king_valkyr_target_search : public SpellScript
_target = Trinity::Containers::SelectRandomContainerElement(targets);
targets.clear();
targets.push_back(_target);
GetCaster()->GetAI()->SetGUID(_target->GetGUID());
GetCaster()->GetAI()->SetGUID(_target->GetGUID(), DATA_GRABBED_PLAYER_GUID);
}
void ReplaceTarget(std::list<WorldObject*>& targets)

View File

@@ -69,6 +69,11 @@ enum Events
EVENT_SUMMON,
};
enum MaexxnaData
{
DATA_WEBWRAP_VICTIM_GUID = 0
};
const float WEB_WRAP_MOVE_SPEED = 20.0f;
struct WebTargetSelector
@@ -143,7 +148,7 @@ struct boss_maexxna : public BossAI
target->RemoveAura(SPELL_WEB_SPRAY);
if (Creature* wrap = DoSummon(NPC_WEB_WRAP, WrapPositions[wrapPos], 70s, TEMPSUMMON_TIMED_DESPAWN))
{
wrap->AI()->SetGUID(target->GetGUID()); // handles application of debuff
wrap->AI()->SetGUID(target->GetGUID(), DATA_WEBWRAP_VICTIM_GUID); // handles application of debuff
target->GetMotionMaster()->MoveJump(WrapPositions[wrapPos], WEB_WRAP_MOVE_SPEED, WEB_WRAP_MOVE_SPEED); // move after stun to avoid stun cancelling move
}
}
@@ -188,10 +193,14 @@ struct npc_webwrap : public NullCreatureAI
me->SetVisible(false);
}
void SetGUID(ObjectGuid const& guid, int32 /*id*/) override
void SetGUID(ObjectGuid const& guid, int32 id) override
{
if (id != DATA_WEBWRAP_VICTIM_GUID)
return;
if (!guid)
return;
victimGUID = guid;
if (Unit* victim = ObjectAccessor::GetUnit(*me, victimGUID))
{

View File

@@ -1260,7 +1260,9 @@ enum BloodsporeRuination
NPC_BLOODMAGE_LAURITH = 25381,
SAY_BLOODMAGE_LAURITH = 0,
EVENT_TALK = 1,
EVENT_RESET_ORIENTATION
EVENT_RESET_ORIENTATION,
DATA_FACING_PLAYER_GUID = 0
};
// 45997 - Bloodspore Ruination
@@ -1270,7 +1272,7 @@ class spell_q11719_bloodspore_ruination_45997 : public SpellScript
{
if (Unit* caster = GetCaster())
if (Creature* laurith = caster->FindNearestCreature(NPC_BLOODMAGE_LAURITH, 100.0f))
laurith->AI()->SetGUID(caster->GetGUID());
laurith->AI()->SetGUID(caster->GetGUID(), DATA_FACING_PLAYER_GUID);
}
void Register() override
@@ -1289,8 +1291,11 @@ struct npc_bloodmage_laurith : public ScriptedAI
_playerGUID.Clear();
}
void SetGUID(ObjectGuid const& guid, int32 /*id*/) override
void SetGUID(ObjectGuid const& guid, int32 id) override
{
if (id != DATA_FACING_PLAYER_GUID)
return;
if (!_playerGUID.IsEmpty())
return;

View File

@@ -102,7 +102,7 @@ struct npc_inner_demon : public ScriptedAI
victimGUID = guid;
}
ObjectGuid GetGUID(int32 id/* = 0 */) const override
ObjectGuid GetGUID(int32 id) const override
{
if (id == INNER_DEMON_VICTIM)
return victimGUID;