fix(Core/BWL): Suppression traps can be disarmed (#10163)

* Fix(Core/BWL): Suppression traps can be disarmed

* missing override (why not present before?)
This commit is contained in:
Nefertumm
2022-01-13 17:52:06 -03:00
committed by GitHub
parent 4330e44ad0
commit 8d78f4b8c2

View File

@@ -51,7 +51,8 @@ enum Events
enum Actions enum Actions
{ {
ACTION_DEACTIVATE = 0 ACTION_DEACTIVATE = 0,
ACTION_DISARMED = 1
}; };
class boss_broodlord : public CreatureScript class boss_broodlord : public CreatureScript
@@ -140,6 +141,19 @@ class go_suppression_device : public GameObjectScript
public: public:
go_suppression_device() : GameObjectScript("go_suppression_device") { } go_suppression_device() : GameObjectScript("go_suppression_device") { }
void OnLootStateChanged(GameObject* go, uint32 state, Unit* /*unit*/) override
{
switch (state)
{
case GO_JUST_DEACTIVATED: // This case prevents the Gameobject despawn by Disarm Trap
go->SetLootState(GO_READY);
case GO_ACTIVATED:
go->AI()->DoAction(ACTION_DISARMED);
break;
}
}
struct go_suppression_deviceAI : public GameObjectAI struct go_suppression_deviceAI : public GameObjectAI
{ {
go_suppression_deviceAI(GameObject* go) : GameObjectAI(go), _instance(go->GetInstanceScript()), _active(true) { } go_suppression_deviceAI(GameObject* go) : GameObjectAI(go), _instance(go->GetInstanceScript()), _active(true) { }
@@ -178,21 +192,6 @@ class go_suppression_device : public GameObjectScript
} }
} }
void OnLootStateChanged(uint32 state, Unit* /*unit*/)
{
switch (state)
{
case GO_ACTIVATED:
Deactivate();
_events.CancelEvent(EVENT_SUPPRESSION_CAST);
_events.ScheduleEvent(EVENT_SUPPRESSION_RESET, 30000, 120000);
break;
case GO_JUST_DEACTIVATED: // This case prevents the Gameobject despawn by Disarm Trap
me->SetLootState(GO_READY);
break;
}
}
void DoAction(int32 action) override void DoAction(int32 action) override
{ {
if (action == ACTION_DEACTIVATE) if (action == ACTION_DEACTIVATE)
@@ -200,6 +199,12 @@ class go_suppression_device : public GameObjectScript
Deactivate(); Deactivate();
_events.CancelEvent(EVENT_SUPPRESSION_RESET); _events.CancelEvent(EVENT_SUPPRESSION_RESET);
} }
else if (action == ACTION_DISARMED)
{
Deactivate();
_events.CancelEvent(EVENT_SUPPRESSION_CAST);
_events.ScheduleEvent(EVENT_SUPPRESSION_RESET, urand(30000, 120000));
}
} }
void Activate() void Activate()
@@ -212,6 +217,7 @@ class go_suppression_device : public GameObjectScript
me->SetLootState(GO_READY); me->SetLootState(GO_READY);
me->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); me->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
_events.ScheduleEvent(EVENT_SUPPRESSION_CAST, 1000); _events.ScheduleEvent(EVENT_SUPPRESSION_CAST, 1000);
me->Respawn();
} }
void Deactivate() void Deactivate()
@@ -230,7 +236,7 @@ class go_suppression_device : public GameObjectScript
bool _active; bool _active;
}; };
GameObjectAI* GetAI(GameObject* go) const GameObjectAI* GetAI(GameObject* go) const override
{ {
return new go_suppression_deviceAI(go); return new go_suppression_deviceAI(go);
} }