Exemplo n.º 1
0
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)

}