mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 13:16:23 +00:00
Refactor(Core/Gossip): Replacing old macros with new (#1338)
* Correct support new macro
This commit is contained in:
@@ -131,41 +131,41 @@ class npc_zulaman_hostage : public CreatureScript
|
||||
bool IsLoot;
|
||||
uint64 PlayerGUID;
|
||||
|
||||
void Reset() { }
|
||||
void Reset() override { }
|
||||
|
||||
void EnterCombat(Unit* /*who*/) { }
|
||||
void EnterCombat(Unit* /*who*/) override { }
|
||||
|
||||
void JustDied(Unit* /*killer*/)
|
||||
void JustDied(Unit* /*killer*/) override
|
||||
{
|
||||
if (Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID))
|
||||
player->SendLoot(me->GetGUID(), LOOT_CORPSE);
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 /*diff*/)
|
||||
void UpdateAI(uint32 /*diff*/) override
|
||||
{
|
||||
if (IsLoot)
|
||||
DoCast(me, 7, false);
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
{
|
||||
return new npc_zulaman_hostageAI(creature);
|
||||
}
|
||||
|
||||
bool OnGossipHello(Player* player, Creature* creature)
|
||||
bool OnGossipHello(Player* player, Creature* creature) override
|
||||
{
|
||||
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HOSTAGE1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
|
||||
player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
|
||||
AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_HOSTAGE1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
|
||||
SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
|
||||
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
|
||||
{
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
|
||||
if (action == GOSSIP_ACTION_INFO_DEF + 1)
|
||||
player->CLOSE_GOSSIP_MENU();
|
||||
CloseGossipMenuFor(player);
|
||||
|
||||
if (!creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP))
|
||||
return true;
|
||||
@@ -189,6 +189,7 @@ class npc_zulaman_hostage : public CreatureScript
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -256,195 +257,195 @@ enum Weapons
|
||||
|
||||
class npc_harrison_jones : public CreatureScript
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
npc_harrison_jones() : CreatureScript("npc_harrison_jones")
|
||||
npc_harrison_jones() : CreatureScript("npc_harrison_jones")
|
||||
{
|
||||
}
|
||||
|
||||
struct npc_harrison_jonesAI : public ScriptedAI
|
||||
{
|
||||
npc_harrison_jonesAI(Creature* creature) : ScriptedAI(creature)
|
||||
{
|
||||
instance = creature->GetInstanceScript();
|
||||
}
|
||||
|
||||
struct npc_harrison_jonesAI : public ScriptedAI
|
||||
InstanceScript* instance;
|
||||
|
||||
uint8 _gongEvent;
|
||||
uint32 _gongTimer;
|
||||
uint64 uiTargetGUID;
|
||||
|
||||
void Reset()
|
||||
{
|
||||
npc_harrison_jonesAI(Creature* creature) : ScriptedAI(creature)
|
||||
_gongEvent = 0;
|
||||
_gongTimer = 0;
|
||||
uiTargetGUID = 0;
|
||||
}
|
||||
|
||||
void EnterCombat(Unit* /*who*/) { }
|
||||
|
||||
void sGossipSelect(Player* player, uint32 sender, uint32 action)
|
||||
{
|
||||
if (me->GetCreatureTemplate()->GossipMenuId == sender && !action)
|
||||
{
|
||||
instance = creature->GetInstanceScript();
|
||||
CloseGossipMenuFor(player);
|
||||
me->SetFacingToObject(player);
|
||||
me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
|
||||
Talk(SAY_HARRISON_0);
|
||||
_gongEvent = GONG_EVENT_1;
|
||||
_gongTimer = 4000;
|
||||
}
|
||||
}
|
||||
|
||||
InstanceScript* instance;
|
||||
|
||||
uint8 _gongEvent;
|
||||
uint32 _gongTimer;
|
||||
uint64 uiTargetGUID;
|
||||
|
||||
void Reset()
|
||||
void SpellHit(Unit*, const SpellInfo* spell)
|
||||
{
|
||||
if (spell->Id == SPELL_COSMETIC_SPEAR_THROW)
|
||||
{
|
||||
_gongEvent = 0;
|
||||
_gongTimer = 0;
|
||||
uiTargetGUID = 0;
|
||||
me->RemoveAllAuras();
|
||||
me->SetEntry(NPC_HARRISON_JONES_2);
|
||||
me->SetDisplayId(MODEL_HARRISON_JONES_2);
|
||||
me->SetTarget(0);
|
||||
me->SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_DEAD);
|
||||
me->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
|
||||
instance->SetData(DATA_GONGEVENT, DONE);
|
||||
}
|
||||
}
|
||||
|
||||
void EnterCombat(Unit* /*who*/) { }
|
||||
|
||||
void sGossipSelect(Player* player, uint32 sender, uint32 action)
|
||||
void UpdateAI(uint32 diff)
|
||||
{
|
||||
if (_gongEvent)
|
||||
{
|
||||
if (me->GetCreatureTemplate()->GossipMenuId == sender && !action)
|
||||
{
|
||||
player->CLOSE_GOSSIP_MENU();
|
||||
me->SetFacingToObject(player);
|
||||
me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
|
||||
Talk(SAY_HARRISON_0);
|
||||
_gongEvent = GONG_EVENT_1;
|
||||
_gongTimer = 4000;
|
||||
}
|
||||
}
|
||||
|
||||
void SpellHit(Unit*, const SpellInfo* spell)
|
||||
{
|
||||
if (spell->Id == SPELL_COSMETIC_SPEAR_THROW)
|
||||
if (_gongTimer <= diff)
|
||||
{
|
||||
me->RemoveAllAuras();
|
||||
me->SetEntry(NPC_HARRISON_JONES_2);
|
||||
me->SetDisplayId(MODEL_HARRISON_JONES_2);
|
||||
me->SetTarget(0);
|
||||
me->SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_DEAD);
|
||||
me->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
|
||||
instance->SetData(DATA_GONGEVENT, DONE);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff)
|
||||
{
|
||||
if (_gongEvent)
|
||||
{
|
||||
if (_gongTimer <= diff)
|
||||
switch (_gongEvent)
|
||||
{
|
||||
switch (_gongEvent)
|
||||
{
|
||||
case GONG_EVENT_1:
|
||||
me->GetMotionMaster()->MovePath(HARRISON_MOVE_1, false);
|
||||
_gongEvent = GONG_EVENT_2;
|
||||
_gongTimer = 12000;
|
||||
break;
|
||||
case GONG_EVENT_2:
|
||||
me->SetFacingTo(6.235659f);
|
||||
Talk(SAY_HARRISON_1);
|
||||
DoCast(me, SPELL_BANGING_THE_GONG);
|
||||
me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(WEAPON_MACE));
|
||||
me->SetSheath(SHEATH_STATE_MELEE);
|
||||
_gongEvent = GONG_EVENT_3;
|
||||
_gongTimer = 4000;
|
||||
break;
|
||||
case GONG_EVENT_3:
|
||||
if (GameObject* gong = me->GetMap()->GetGameObject(instance->GetData64(GO_STRANGE_GONG)))
|
||||
gong->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
|
||||
_gongEvent = GONG_EVENT_4;
|
||||
_gongTimer = 105000;
|
||||
break;
|
||||
case GONG_EVENT_4:
|
||||
me->RemoveAura(SPELL_BANGING_THE_GONG);
|
||||
if (GameObject* gong = me->GetMap()->GetGameObject(instance->GetData64(GO_STRANGE_GONG)))
|
||||
gong->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
|
||||
case GONG_EVENT_1:
|
||||
me->GetMotionMaster()->MovePath(HARRISON_MOVE_1, false);
|
||||
_gongEvent = GONG_EVENT_2;
|
||||
_gongTimer = 12000;
|
||||
break;
|
||||
case GONG_EVENT_2:
|
||||
me->SetFacingTo(6.235659f);
|
||||
Talk(SAY_HARRISON_1);
|
||||
DoCast(me, SPELL_BANGING_THE_GONG);
|
||||
me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(WEAPON_MACE));
|
||||
me->SetSheath(SHEATH_STATE_MELEE);
|
||||
_gongEvent = GONG_EVENT_3;
|
||||
_gongTimer = 4000;
|
||||
break;
|
||||
case GONG_EVENT_3:
|
||||
if (GameObject* gong = me->GetMap()->GetGameObject(instance->GetData64(GO_STRANGE_GONG)))
|
||||
gong->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
|
||||
_gongEvent = GONG_EVENT_4;
|
||||
_gongTimer = 105000;
|
||||
break;
|
||||
case GONG_EVENT_4:
|
||||
me->RemoveAura(SPELL_BANGING_THE_GONG);
|
||||
if (GameObject* gong = me->GetMap()->GetGameObject(instance->GetData64(GO_STRANGE_GONG)))
|
||||
gong->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
|
||||
|
||||
// trigger or gong will need to be scripted to set IN_PROGRESS after enough hits.
|
||||
// This is temp workaround.
|
||||
instance->SetData(DATA_GONGEVENT, IN_PROGRESS); // to be removed.
|
||||
// trigger or gong will need to be scripted to set IN_PROGRESS after enough hits.
|
||||
// This is temp workaround.
|
||||
instance->SetData(DATA_GONGEVENT, IN_PROGRESS); // to be removed.
|
||||
|
||||
if (instance->GetData(DATA_GONGEVENT) == IN_PROGRESS)
|
||||
if (instance->GetData(DATA_GONGEVENT) == IN_PROGRESS)
|
||||
{
|
||||
// Players are Now Saved to instance at SPECIAL (Player should be notified?)
|
||||
me->GetMotionMaster()->MovePath(HARRISON_MOVE_2, false);
|
||||
_gongEvent = GONG_EVENT_5;
|
||||
_gongTimer = 5000;
|
||||
}
|
||||
else
|
||||
{
|
||||
_gongTimer = 1000;
|
||||
_gongEvent = GONG_EVENT_9;
|
||||
}
|
||||
break;
|
||||
case GONG_EVENT_5:
|
||||
me->SetEntry(NPC_HARRISON_JONES_1);
|
||||
me->SetDisplayId(MODEL_HARRISON_JONES_1);
|
||||
Talk(SAY_HARRISON_2);
|
||||
_gongTimer = 12000;
|
||||
_gongEvent = GONG_EVENT_6;
|
||||
break;
|
||||
case GONG_EVENT_6:
|
||||
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_USE_STANDING);
|
||||
Talk(SAY_HARRISON_3);
|
||||
_gongTimer = 7000;
|
||||
_gongEvent = GONG_EVENT_7;
|
||||
break;
|
||||
case GONG_EVENT_7:
|
||||
if (!uiTargetGUID)
|
||||
{
|
||||
std::list<Creature*> targetList;
|
||||
GetCreatureListWithEntryInGrid(targetList, me, NPC_AMANISHI_GUARDIAN, 26.0f);
|
||||
if (!targetList.empty())
|
||||
{
|
||||
// Players are Now Saved to instance at SPECIAL (Player should be notified?)
|
||||
me->GetMotionMaster()->MovePath(HARRISON_MOVE_2, false);
|
||||
_gongEvent = GONG_EVENT_5;
|
||||
_gongTimer = 5000;
|
||||
}
|
||||
else
|
||||
{
|
||||
_gongTimer = 1000;
|
||||
_gongEvent = GONG_EVENT_9;
|
||||
}
|
||||
break;
|
||||
case GONG_EVENT_5:
|
||||
me->SetEntry(NPC_HARRISON_JONES_1);
|
||||
me->SetDisplayId(MODEL_HARRISON_JONES_1);
|
||||
Talk(SAY_HARRISON_2);
|
||||
_gongTimer = 12000;
|
||||
_gongEvent = GONG_EVENT_6;
|
||||
break;
|
||||
case GONG_EVENT_6:
|
||||
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_USE_STANDING);
|
||||
Talk(SAY_HARRISON_3);
|
||||
_gongTimer = 7000;
|
||||
_gongEvent = GONG_EVENT_7;
|
||||
break;
|
||||
case GONG_EVENT_7:
|
||||
if (!uiTargetGUID)
|
||||
{
|
||||
std::list<Creature*> targetList;
|
||||
GetCreatureListWithEntryInGrid(targetList, me, NPC_AMANISHI_GUARDIAN, 26.0f);
|
||||
if (!targetList.empty())
|
||||
for (std::list<Creature*>::const_iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
|
||||
{
|
||||
for (std::list<Creature*>::const_iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
|
||||
if (Creature* ptarget = *itr)
|
||||
{
|
||||
if (Creature* ptarget = *itr)
|
||||
if (ptarget->GetPositionX() > 120)
|
||||
{
|
||||
if (ptarget->GetPositionX() > 120)
|
||||
{
|
||||
ptarget->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(WEAPON_SPEAR));
|
||||
ptarget->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
|
||||
ptarget->SetReactState(REACT_PASSIVE);
|
||||
ptarget->AI()->SetData(0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptarget->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
|
||||
ptarget->SetReactState(REACT_PASSIVE);
|
||||
ptarget->AI()->SetData(0, 2);
|
||||
}
|
||||
ptarget->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(WEAPON_SPEAR));
|
||||
ptarget->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
|
||||
ptarget->SetReactState(REACT_PASSIVE);
|
||||
ptarget->AI()->SetData(0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptarget->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
|
||||
ptarget->SetReactState(REACT_PASSIVE);
|
||||
ptarget->AI()->SetData(0, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GameObject* gate = me->GetMap()->GetGameObject(instance->GetData64(GO_MASSIVE_GATE)))
|
||||
gate->SetGoState(GO_STATE_ACTIVE);
|
||||
_gongTimer = 2000;
|
||||
_gongEvent = GONG_EVENT_8;
|
||||
break;
|
||||
case GONG_EVENT_8:
|
||||
DoCast(me, SPELL_STEALTH);
|
||||
me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(0));
|
||||
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE);
|
||||
me->GetMotionMaster()->MovePath(HARRISON_MOVE_3, false);
|
||||
_gongTimer = 1000;
|
||||
_gongEvent = 0;
|
||||
break;
|
||||
case GONG_EVENT_9:
|
||||
me->GetMotionMaster()->MovePoint(0, 120.687f, 1674.0f, 42.0217f);
|
||||
_gongTimer = 12000;
|
||||
_gongEvent = GONG_EVENT_10;
|
||||
break;
|
||||
case GONG_EVENT_10:
|
||||
me->SetFacingTo(1.59044f);
|
||||
_gongEvent = 11;
|
||||
_gongTimer = 6000;
|
||||
break;
|
||||
case GONG_EVENT_11:
|
||||
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
|
||||
if (GameObject* gate = me->GetMap()->GetGameObject(instance->GetData64(GO_MASSIVE_GATE)))
|
||||
gate->SetGoState(GO_STATE_ACTIVE);
|
||||
_gongTimer = 2000;
|
||||
_gongEvent = GONG_EVENT_8;
|
||||
break;
|
||||
case GONG_EVENT_8:
|
||||
DoCast(me, SPELL_STEALTH);
|
||||
me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(0));
|
||||
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE);
|
||||
me->GetMotionMaster()->MovePath(HARRISON_MOVE_3, false);
|
||||
_gongTimer = 1000;
|
||||
_gongEvent = 0;
|
||||
break;
|
||||
case GONG_EVENT_9:
|
||||
me->GetMotionMaster()->MovePoint(0, 120.687f, 1674.0f, 42.0217f);
|
||||
_gongTimer = 12000;
|
||||
_gongEvent = GONG_EVENT_10;
|
||||
break;
|
||||
case GONG_EVENT_10:
|
||||
me->SetFacingTo(1.59044f);
|
||||
_gongEvent = 11;
|
||||
_gongTimer = 6000;
|
||||
break;
|
||||
case GONG_EVENT_11:
|
||||
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
|
||||
|
||||
instance->SetData(DATA_GONGEVENT, NOT_STARTED);
|
||||
_gongEvent = 0;
|
||||
_gongTimer = 1000;
|
||||
break;
|
||||
}
|
||||
instance->SetData(DATA_GONGEVENT, NOT_STARTED);
|
||||
_gongEvent = 0;
|
||||
_gongTimer = 1000;
|
||||
break;
|
||||
}
|
||||
else
|
||||
_gongTimer -= diff;
|
||||
}
|
||||
else
|
||||
_gongTimer -= diff;
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const
|
||||
{
|
||||
return GetInstanceAI<npc_harrison_jonesAI>(creature);
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const
|
||||
{
|
||||
return GetInstanceAI<npc_harrison_jonesAI>(creature);
|
||||
}
|
||||
};
|
||||
|
||||
class spell_banging_the_gong : public SpellScriptLoader
|
||||
|
||||
Reference in New Issue
Block a user