Skip to content

Commit

Permalink
ZA: Safeguard starting npc event again through saving in DB
Browse files Browse the repository at this point in the history
Perhaps in future, make NPCs not respawn?
  • Loading branch information
killerwife committed Aug 17, 2021
1 parent 642a6b2 commit 65afafe
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
Expand Up @@ -478,6 +478,12 @@ void instance_zulaman::SetData(uint32 type, uint32 data)
}
}

break;
case TYPE_TANZAR:
case TYPE_KRAZ:
case TYPE_ASHLI:
case TYPE_HARKOR:
m_auiEncounter[type] = data;
break;
case TYPE_RUN_EVENT_TIME:
m_auiEncounter[type] = data;
Expand Down Expand Up @@ -512,7 +518,8 @@ void instance_zulaman::SetData(uint32 type, uint32 data)
std::ostringstream saveStream;
saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " "
<< m_auiEncounter[3] << " " << m_auiEncounter[4] << " " << m_auiEncounter[5] << " "
<< m_auiEncounter[6] << " " << m_auiEncounter[7];
<< m_auiEncounter[6] << " " << m_auiEncounter[7] << " " << m_auiEncounter[8] << " "
<< m_auiEncounter[9] << " " << m_auiEncounter[10] << " " << m_auiEncounter[11];

m_strInstData = saveStream.str();

Expand All @@ -533,7 +540,8 @@ void instance_zulaman::Load(const char* chrIn)

std::istringstream loadStream(chrIn);
loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3]
>> m_auiEncounter[4] >> m_auiEncounter[5] >> m_auiEncounter[6] >> m_auiEncounter[7];
>> m_auiEncounter[4] >> m_auiEncounter[5] >> m_auiEncounter[6] >> m_auiEncounter[7]
>> m_auiEncounter[8] >> m_auiEncounter[9] >> m_auiEncounter[10] >> m_auiEncounter[11];

// Skip m_auiEncounter[7], to start the time event properly if needed
for (uint8 i = 0; i < MAX_ENCOUNTER - 1; ++i)
Expand Down
14 changes: 10 additions & 4 deletions src/game/AI/ScriptDevAI/scripts/eastern_kingdoms/zulaman/zulaman.h
Expand Up @@ -44,11 +44,17 @@ enum InstanceZA
TYPE_HALAZZI = 4,
TYPE_MALACRASS = 5,
TYPE_ZULJIN = 6,
TYPE_RUN_EVENT_TIME = 7, // Must be MAX_ENCOUNTER -1
TYPE_AKILZON_GAUNTLET = 8,
TYPE_RUN_EVENT_TIME = 7,

TYPE_RAND_VENDOR_1 = 9,
TYPE_RAND_VENDOR_2 = 10,
TYPE_TANZAR = 8,
TYPE_KRAZ = 9,
TYPE_ASHLI = 10,
TYPE_HARKOR = 11, // Must be MAX_ENCOUNTER -1

TYPE_AKILZON_GAUNTLET = 12,

TYPE_RAND_VENDOR_1 = 13,
TYPE_RAND_VENDOR_2 = 14,

NPC_AKILZON = 23574,
NPC_NALORAKK = 23576,
Expand Down
Expand Up @@ -902,6 +902,9 @@ struct npc_harkorAI : public ScriptedAI
itr->SetRespawnTime(7 * DAY);
}

if (m_instance)
m_instance->SetData(TYPE_HARKOR, DONE);

m_uiEventTimer = 0;
m_uiEvent = 0;
break;
Expand Down Expand Up @@ -971,6 +974,9 @@ struct npc_harkorAI : public ScriptedAI

void StartEvent()
{
if (m_instance && m_instance->GetData(TYPE_HARKOR) == DONE)
return;

m_bChestEventInProgress = true;

m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
Expand Down Expand Up @@ -1213,6 +1219,9 @@ struct npc_tanzarAI : public ScriptedAI
pTrunk->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
}

if (m_instance)
m_instance->SetData(TYPE_TANZAR, DONE);

m_uiEventTimer = 0;
m_uiEvent = 0;
break;
Expand Down Expand Up @@ -1302,6 +1311,9 @@ struct npc_tanzarAI : public ScriptedAI

void StartEvent()
{
if (m_instance && m_instance->GetData(TYPE_TANZAR) == DONE)
return;

m_bChestEventInProgress = true;

m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
Expand Down Expand Up @@ -1560,6 +1572,9 @@ struct npc_krazAI : public ScriptedAI
itr->SetRespawnTime(7 * DAY);
}

if (m_instance)
m_instance->SetData(TYPE_KRAZ, DONE);

lCoinList.clear();

m_uiEventTimer = 1000;
Expand Down Expand Up @@ -1591,6 +1606,9 @@ struct npc_krazAI : public ScriptedAI

void StartEvent()
{
if (m_instance && m_instance->GetData(TYPE_KRAZ) == DONE)
return;

m_bChestEventInProgress = true;

m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
Expand Down Expand Up @@ -1909,10 +1927,16 @@ struct npc_ashliAI : public ScriptedAI

if (GameObject* pVase = GetClosestGameObjectWithEntry(pTarget, GO_ASHLIS_VASE, 10.0f))
pVase->Delete();

if (m_instance)
m_instance->SetData(TYPE_ASHLI, DONE);
}

void StartEvent()
{
if (m_instance && m_instance->GetData(TYPE_ASHLI) == DONE)
return;

m_bChestEventInProgress = true;

m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
Expand Down

0 comments on commit 65afafe

Please sign in to comment.