int CInstanceHandler::registerDynamis(uint16 id, CCharEntity* PChar) { if(!hasFreeInstance()) { return -1; } CInstance* PInstance = instanceutils::loadInstance(this,id); if(PInstance==NULL) { return -1; } for(int i=0; i<m_MaxInstances; i++) { if(m_Instances[i]==NULL) { PInstance->setInstanceNumber(i+1); break; } } if(PInstance->addPlayerToDynamis(PChar)) { ShowDebug("InstanceHandler ::1 Added %s to the valid players list for Dynamis %i Instance %i \n", PChar->GetName(),id,PInstance->getInstanceNumber()); } m_Instances[PInstance->getInstanceNumber()-1] = PInstance; PInstance->init(); PInstance->setDynaUniqueID(); luautils::OnBcnmRegister(PChar,PInstance); return PInstance->getInstanceNumber(); }
void CInstanceHandler::handleInstances(uint32 tick) { for(int i=0; i<m_MaxInstances; i++) { if(m_Instances[i]!=NULL) { //handle it! CInstance* PInstance = m_Instances[i]; int instzone = PInstance->getZoneId(); //Dynamis zone (need to add COP Dyna) if(instzone > 184 && instzone < 189 || instzone > 133 && instzone < 136) { //handle death time if(PInstance->allPlayersDead()) { //set dead time if(PInstance->getDeadTime()==0) { PInstance->setDeadTime(tick); ShowDebug("Dynamis %i instance %i : All players have fallen.\n",PInstance->getID(),PInstance->getInstanceNumber()); } } else { if(PInstance->getDeadTime()!=0) { PInstance->setDeadTime(0); //reset dead time when people are alive ShowDebug("Dynamis %i instance %i : Death counter reset as a player is now alive.\n",PInstance->getID(),PInstance->getInstanceNumber()); } } //handle time remaining prompts (since its useful!) Prompts every minute int Tremaining = (tick - PInstance->getStartTime())/1000; //New message (in yellow) at the end of dynamis (5min before the end) if((Tremaining % 60) == 0 && (PInstance->getTimeLimit() - Tremaining) <= 300) { PInstance->pushMessageToAllInBcnm(449,((PInstance->getTimeLimit()-Tremaining)/60)); } else { if(((tick - PInstance->getStartTime())/1000) % 60 == 0) { PInstance->pushMessageToAllInBcnm(202,(PInstance->getTimeLimit()-Tremaining)); } } //if the time is finished, exiting dynamis if(instanceutils::meetsLosingConditions(PInstance,tick)) { ShowDebug("Dynamis %i instance %i : Dynamis is finished. Exiting battlefield.\n",PInstance->getID(),PInstance->getInstanceNumber()); PInstance->finishDynamis(); } } else { //handle locking of bcnm when engaged if(!PInstance->locked && PInstance->isPlayersFighting()) { PInstance->lockBcnm(); PInstance->locked = true; ShowDebug("BCNM %i instance %i : Battlefield has been locked. No more players can enter.\n",PInstance->getID(),PInstance->getInstanceNumber()); } //handle death time if(PInstance->allPlayersDead()) { //set dead time if(PInstance->getDeadTime()==0) { PInstance->setDeadTime(tick); ShowDebug("BCNM %i instance %i : All players have fallen.\n",PInstance->getID(),PInstance->getInstanceNumber()); } } else { if(PInstance->getDeadTime()!=0) { PInstance->setDeadTime(0); //reset dead time when people are alive ShowDebug("BCNM %i instance %i : Death counter reset as a player is now alive.\n",PInstance->getID(),PInstance->getInstanceNumber()); } } //handle time remaining prompts (since its useful!) Prompts every minute if(((tick - PInstance->getStartTime())/1000) % 60 == 0) { PInstance->pushMessageToAllInBcnm(202,(PInstance->getTimeLimit()-((tick - PInstance->getStartTime())/1000))); } //handle win conditions if(instanceutils::meetsWinningConditions(PInstance,tick)) { //check rule mask to see if warp immediately or pop a chest if(PInstance->m_RuleMask & RULES_SPAWN_TREASURE_ON_WIN) { //spawn chest if(PInstance->treasureChestSpawned == false) { ShowDebug("BCNM %i instance %i : Winning conditions met. Spawning chest.\n",PInstance->getID(),PInstance->getInstanceNumber()); PInstance->spawnTreasureChest(); //PInstance->getHighestTHforBcnm(); apparently not used in bcnm PInstance->treasureChestSpawned = true; } } else { ShowDebug("BCNM %i instance %i : Winning conditions met. Exiting battlefield.\n",PInstance->getID(),PInstance->getInstanceNumber()); PInstance->winBcnm(); } } //handle lose conditions else if(instanceutils::meetsLosingConditions(PInstance,tick)) { ShowDebug("BCNM %i instance %i : Losing conditions met. Exiting battlefield.\n",PInstance->getID(),PInstance->getInstanceNumber()); PInstance->loseBcnm(); } } } } //send 246 with bunrning circle as target (bcnm is full. followed by time remaining) }
int CInstanceHandler::registerBcnm(uint16 id, CCharEntity* PChar) { if(!hasFreeInstance()) { return -1; } CInstance* PInstance = instanceutils::loadInstance(this,id); if(PInstance==NULL) { return -1; } for(int i=0; i<m_MaxInstances; i++) { if(m_Instances[i]==NULL) { PInstance->setInstanceNumber(i+1); break; } } switch(PInstance->getMaxParticipants()) { case 1: if(PInstance->addPlayerToBcnm(PChar)) { ShowDebug("InstanceHandler ::1 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->GetName(),id,PInstance->getInstanceNumber()); } break; case 3: if(PChar->PParty == NULL) { //just add the initiator if(PInstance->addPlayerToBcnm(PChar)) { ShowDebug("InstanceHandler ::3 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->GetName(),id,PInstance->getInstanceNumber()); } } else { int numRegistered = 0; for(int j=0; j<PChar->PParty->members.size(); j++) { if(PInstance->addPlayerToBcnm((CCharEntity*)PChar->PParty->members.at(j))) { ShowDebug("InstanceHandler ::3 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->PParty->members.at(j)->GetName(),id,PInstance->getInstanceNumber()); numRegistered++; } if(numRegistered>=3) { break; } } } break; case 6: if(PChar->PParty == NULL) { //just add the initiator if(PInstance->addPlayerToBcnm(PChar)) { ShowDebug("InstanceHandler ::6 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->GetName(),id,PInstance->getInstanceNumber()); } } else { for(int j=0; j<PChar->PParty->members.size(); j++) { if(PInstance->addPlayerToBcnm((CCharEntity*)PChar->PParty->members.at(j))) { ShowDebug("InstanceHandler ::6 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->PParty->members.at(j)->GetName(),id,PInstance->getInstanceNumber()); } } } break; case 12: ShowDebug("BCNMs for 12 people are not implemented yet.\n"); break; case 18: if(PChar->PParty == NULL) { //1 player entering 18 man bcnm if(PInstance->addPlayerToBcnm(PChar)) { ShowDebug("InstanceHandler ::18 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->GetName(),id,PInstance->getInstanceNumber()); } } else { //alliance entering 18 man bcnm if(PChar->PParty->m_PAlliance != NULL) { for(uint8 a = 0; a < PChar->PParty->m_PAlliance->partyList.size(); ++a) { for(uint8 j=0; j<PChar->PParty->m_PAlliance->partyList.at(a)->members.size(); j++) { if(PInstance->addPlayerToBcnm((CCharEntity*)PChar->PParty->m_PAlliance->partyList.at(a)->members.at(j))) { ShowDebug("InstanceHandler ::18 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->PParty->m_PAlliance->partyList.at(a)->members.at(j)->GetName(),id,PInstance->getInstanceNumber()); } } } } else { //single party entering 18 man bcnm for(uint8 j=0; j<PChar->PParty->members.size(); j++) { if(PInstance->addPlayerToBcnm((CCharEntity*)PChar->PParty->members.at(j))) { ShowDebug("InstanceHandler ::18 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->PParty->members.at(j)->GetName(),id,PInstance->getInstanceNumber()); } } } } break; default: ShowDebug("Unknown max participants value %i \n",PInstance->getMaxParticipants()); } if(!PInstance->isReserved()) { //no player met the criteria for entering, so revoke the previous permission. ShowDebug("No player has met the requirements for entering the BCNM.\n"); delete PInstance; return -1; } m_Instances[PInstance->getInstanceNumber()-1] = PInstance; PInstance->init(); luautils::OnBcnmRegister(PChar,PInstance); return PInstance->getInstanceNumber(); }