Scripts/VioletHold: Minor improvements (#23961)

* Scripts/VioletHold: Minor improvements
* Now we can teleport inside with gossip if event is in progress
* Improve HavePlayers() check logic

* Remove a pointless comment
suggested by shauren

* Move CheckWipe function to execute every 3 seconds instead every map update
suggested by Riztazz

* I supose Riztazz forgot add this to repeat every 3 seconds
This commit is contained in:
Gildor
2019-12-11 15:01:27 +01:00
committed by Giacomo Pozzoni
parent 297090644d
commit f661bc6c39
2 changed files with 29 additions and 12 deletions

View File

@@ -410,6 +410,12 @@ class instance_violet_hold : public InstanceMapScript
for (uint8 i = 0; i < ActivationCrystalCount; ++i) for (uint8 i = 0; i < ActivationCrystalCount; ++i)
if (GameObject* crystal = instance->GetGameObject(ActivationCrystalGUIDs[i])) if (GameObject* crystal = instance->GetGameObject(ActivationCrystalGUIDs[i]))
crystal->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); crystal->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
Scheduler.Schedule(Seconds(3), [this](TaskContext task)
{
CheckEventState();
task.Repeat(Seconds(3));
});
} }
else if (data == NOT_STARTED) else if (data == NOT_STARTED)
{ {
@@ -852,9 +858,29 @@ class instance_violet_hold : public InstanceMapScript
void Update(uint32 diff) override void Update(uint32 diff) override
{ {
// if we don't have any player in the instance
if (!instance->HavePlayers()) if (!instance->HavePlayers())
{
if (EventState == IN_PROGRESS) // if event is in progress, mark as fail
{
EventState = FAIL;
CheckEventState();
}
return; return;
}
Scheduler.Update(diff);
if (EventState == IN_PROGRESS)
{
// if door is destroyed, event is failed
if (!GetData(DATA_DOOR_INTEGRITY))
EventState = FAIL;
}
}
void CheckEventState()
{
// if main event is in progress and players have wiped then reset instance // if main event is in progress and players have wiped then reset instance
if ((EventState == IN_PROGRESS && CheckWipe()) || EventState == FAIL) if ((EventState == IN_PROGRESS && CheckWipe()) || EventState == FAIL)
{ {
@@ -872,15 +898,6 @@ class instance_violet_hold : public InstanceMapScript
if (Creature* sinclari = GetCreature(DATA_SINCLARI)) if (Creature* sinclari = GetCreature(DATA_SINCLARI))
sinclari->AI()->EnterEvadeMode(); sinclari->AI()->EnterEvadeMode();
} }
Scheduler.Update(diff);
if (EventState == IN_PROGRESS)
{
// if door is destroyed, event is failed
if (!GetData(DATA_DOOR_INTEGRITY))
EventState = FAIL;
}
} }
void ScheduleCyanigosaIntro() void ScheduleCyanigosaIntro()

View File

@@ -472,12 +472,12 @@ class npc_sinclari_vh : public CreatureScript
task.Repeat(Seconds(5)); task.Repeat(Seconds(5));
break; break;
case 8: case 8:
me->SetVisible(false); _instance->SetData(DATA_MAIN_EVENT_STATE, IN_PROGRESS);
task.Repeat(Seconds(1)); task.Repeat(Seconds(1));
break; break;
case 9: case 9:
_instance->SetData(DATA_MAIN_EVENT_STATE, IN_PROGRESS); // We should teleport inside if event is in progress with GOSSIP_MENU_SEND_ME_IN
// [1] GUID: Full: 0xF1300077C202E6DD Type: Creature Entry: 30658 Low: 190173 me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
break; break;
default: default:
break; break;