Example #1
0
void WintergraspScript::OnUpdate(uint32 p_time)
{
    if(!m_Initialized)
    {
        m_Initialized = true;
        sLog.Notice("Wintergrasp", "Server is loading wintergrasp tiles, it might take some time..");
        mgr->UpdateAllCells(true, ZONE_WINTERGRASP);
        sLog.Notice("Wintergrasp", "Finished loading tiles...");
    }

    UpdateClockDigit(m_NextTime-UNIXTIME, m_started ? 0 : 1, 10);
    if(UNIXTIME >= m_NextTime)
    {
        if(m_started)
        {
            if(m_FinishTime > p_time)
            {
                m_FinishTime -= p_time;
                UpdateWarZones();
            }
            else
            {
                EndBattle();
                Herald((char*)format("The battle for Wintergrasp has ended! The Winner is, the %s!", ControllingTeam ? "Horde" : "Alliance").c_str());
            }
        }
        else StartBattle();
    }
    else
    {
        float timeInHours = float((m_NextTime-UNIXTIME)/60);
        if(timeInHours < 0.7)
        {
            float timeInMinutes = floor((timeInHours*60));
            if(timeInMinutes == 30 && !ThirtyMinuteHerald)
            {
                ThirtyMinuteHerald = true;
                Herald("The battle for Wintergrasp begins in 30 minutes!");
            }
            else if(timeInMinutes == 15 && !FifteenMinuteHerald)
            {
                FifteenMinuteHerald = true;
                Herald("The battle for Wintergrasp begins in 15 minutes!");
            }
        }
        else
        {
            if(timeInHours == 1 && !FirstHourHerald)
            {
                FirstHourHerald = true;
                Herald("The battle for Wintergrasp begins in 1 hour!");
            }
        }
    }
}
Example #2
0
void IsleOfConquest::HookOnUnitKill(Player* plr, Unit* pVictim)
{
	if(pVictim->IsPlayer())
		return;

	if(pVictim->GetEntry() == 34924)	// High Commander Halford Wyrmbane
	{
		Herald("The 7th Legion General is dead!");
		RemoveReinforcements( 0, m_reinforcements[0] );	// Horde Win
		Finish(0);
	}
	else if(pVictim->GetEntry() == 34922)	// Overlord Agmar
	{
		Herald("The Scarshield Legion General is dead!");
		RemoveReinforcements( 1, m_reinforcements[1] );	// Alliance Win
		Finish(1);
	}
}
Example #3
0
void WintergraspScript::SpawnWarZones(bool apply)
{
    return; // Needs work and more base implementation before it's safe to enable it.

    // This one is simple.
    if(apply)
    {
        Herald("Multiple Battle groups have engaged!");

        uint32 Entry = 0, percent = 100;
        CreatureProto* ctrp = NULL;
        for(uint32 i = 0; i < MAX_BATTLE_ZONES; i++)
        {
            for(uint32 t = 0; t < MAX_UNITS_PER_ZONE/2; t++)
            {
                float x = Wintergrasp_WarZones[i][t].mX, y = Wintergrasp_WarZones[i][t].mY, z = Wintergrasp_WarZones[i][t].mZ, o = Wintergrasp_WarZones[i][t].mO;
                if(x == 0.0f || y == 0.0f || z == 0.0f)
                    continue;

                if(RandomUInt(percent) > (percent/2))
                    Entry = 00000;
                else
                    Entry = 00000;
                percent += 1;

                ctrp = CreatureProtoStorage.LookupEntry(Entry);
                if(ctrp == NULL)
                    continue;

                Creature* ctr = mgr->CreateCreature(Entry);
                if(ctr == NULL)
                    continue;

                ctr->SetMapId(mgr->GetMapId());
                ctr->SetInstanceID(mgr->GetInstanceID());

                if(ctr->Load(ctrp, mgr->iInstanceMode, x, y, z, o))
                {
                    if(!ctr->CanAddToWorld())
                    {
                        ctr->Destruct();
                        continue;
                    }

                    ctr->PushToWorld(mgr);

                    SpawnInfo* spI = new SpawnInfo();
                    spI->CreatureEntry = Entry;
                    spI->RespawnTime = 0;
                    spI->locationId = i;
                    spI->SpawnId = t;
                    spI->m_Spawn = ctr;
                    m_WarriorPool.insert(spI);
                }
                else ctr->Destruct();
            }

            for(uint32 t = MAX_UNITS_PER_ZONE/2; t < MAX_UNITS_PER_ZONE; t++)
            {
                float x = Wintergrasp_WarZones[i][t].mX, y = Wintergrasp_WarZones[i][t].mY, z = Wintergrasp_WarZones[i][t].mZ, o = Wintergrasp_WarZones[i][t].mO;
                if(x == 0.0f || y == 0.0f || z == 0.0f)
                    continue;

                if(RandomUInt(percent) > (percent/2))
                    Entry = 00000;
                else
                    Entry = 00000;
                percent += 1;

                ctrp = CreatureProtoStorage.LookupEntry(Entry);
                if(ctrp == NULL)
                    continue;

                Creature* ctr = mgr->CreateCreature(Entry);
                if(ctr == NULL)
                    continue;

                ctr->SetMapId(mgr->GetMapId());
                ctr->SetInstanceID(mgr->GetInstanceID());

                if(ctr->Load(ctrp, mgr->iInstanceMode, x, y, z, o))
                {
                    if(!ctr->CanAddToWorld())
                    {
                        ctr->Destruct();
                        continue;
                    }

                    ctr->PushToWorld(mgr);

                    SpawnInfo* spI = new SpawnInfo();
                    spI->CreatureEntry = Entry;
                    spI->RespawnTime = 0;
                    spI->locationId = i;
                    spI->SpawnId = t;
                    spI->m_Spawn = ctr;
                    m_WarriorPool.insert(spI);
                }
                else ctr->Destruct();
            }
        }
    }
    else
    {
        m_WarriorSoulPool.clear();
        float x = 0.0f, y = 0.0f;
        for(std::set<SpawnInfo*>::iterator itr = m_WarriorPool.begin(), it2; itr != m_WarriorPool.end();)
        {
            it2 = itr++;
            Creature* ctr = (*it2)->m_Spawn;
            if(ctr != NULL)
            {
                x = ctr->GetPositionX();
                y = ctr->GetPositionY();

                (*it2)->m_Spawn = NULL;
                ctr->RemoveFromWorld(false, true);
                ctr->Destruct();
            }

            delete (*it2);
        }
        m_WarriorPool.clear();
    }
}