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)
if (GameObject* crystal = instance->GetGameObject(ActivationCrystalGUIDs[i]))
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)
{
@@ -852,9 +858,29 @@ class instance_violet_hold : public InstanceMapScript
void Update(uint32 diff) override
{
// if we don't have any player in the instance
if (!instance->HavePlayers())
{
if (EventState == IN_PROGRESS) // if event is in progress, mark as fail
{
EventState = FAIL;
CheckEventState();
}
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 ((EventState == IN_PROGRESS && CheckWipe()) || EventState == FAIL)
{
@@ -872,15 +898,6 @@ class instance_violet_hold : public InstanceMapScript
if (Creature* sinclari = GetCreature(DATA_SINCLARI))
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()

View File

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