예제 #1
0
void BattlefieldWG::OnUnitDeath(Unit* unit)
{
    if (IsWarTime())
        if (unit->IsVehicle())
            if (FindAndRemoveVehicleFromList(unit))
                UpdateVehicleCountWG();
}
void BattlefieldWG::UpdateCounterVehicle(bool init)
{
    if (!IsWarTime())
    return;

    if (init)
    {
        SetData(BATTLEFIELD_WG_DATA_VEHICLE_H, 0);
        SetData(BATTLEFIELD_WG_DATA_VEHICLE_A, 0);
    }
    SetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H, 0);
    SetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_A, 0);

    for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
    {
        if (WGWorkshop* workshop = (*itr))
        {
            if (workshop->teamControl == TEAM_ALLIANCE)
                UpdateData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_A, 4);
            else if (workshop->teamControl == TEAM_HORDE)
                UpdateData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H, 4);
        }
    }

    UpdateVehicleCountWG();
}
예제 #3
0
void BattlefieldWG::UpdateCounterVehicle(bool init)
{
    if (init)
    {
        m_Data32[BATTLEFIELD_WG_DATA_VEHICLE_H] = 0;
        m_Data32[BATTLEFIELD_WG_DATA_VEHICLE_A] = 0;
    }
    m_Data32[BATTLEFIELD_WG_DATA_MAX_VEHICLE_H] = 0;
    m_Data32[BATTLEFIELD_WG_DATA_MAX_VEHICLE_A] = 0;

    for (WorkShop::const_iterator itr = WorkShopList.begin(); itr != WorkShopList.end(); ++itr)
    {
        if (BfWGWorkShopData* workshop = *itr)
        {
            if (workshop->m_TeamControl == TEAM_ALLIANCE)
                m_Data32[BATTLEFIELD_WG_DATA_MAX_VEHICLE_A] = m_Data32[BATTLEFIELD_WG_DATA_MAX_VEHICLE_A] + 4;
            else if (workshop->m_TeamControl == TEAM_HORDE)
                m_Data32[BATTLEFIELD_WG_DATA_MAX_VEHICLE_H] = m_Data32[BATTLEFIELD_WG_DATA_MAX_VEHICLE_H] + 4;
        }
    }

    UpdateVehicleCountWG();
}
예제 #4
0
void BattlefieldWG::OnCreatureCreate(Creature* creature)
{
    // Accessing to db spawned creatures
    switch (creature->GetEntry())
    {
        case NPC_DWARVEN_SPIRIT_GUIDE:
        case NPC_TAUNKA_SPIRIT_GUIDE:
        {
            TeamId teamId = (creature->GetEntry() == NPC_DWARVEN_SPIRIT_GUIDE ? TEAM_ALLIANCE : TEAM_HORDE);
            uint8 graveyardId = GetSpiritGraveyardId(creature->GetAreaId());
            if (m_GraveyardList[graveyardId])
                m_GraveyardList[graveyardId]->SetSpirit(creature, teamId);
            break;
        }
    }

    // untested code - not sure if it is valid.
    if (IsWarTime())
    {
        switch (creature->GetEntry())
        {
            case NPC_WINTERGRASP_SIEGE_ENGINE_ALLIANCE:
            case NPC_WINTERGRASP_SIEGE_ENGINE_HORDE:
            case NPC_WINTERGRASP_CATAPULT:
            case NPC_WINTERGRASP_DEMOLISHER:
            {
                if (!creature->ToTempSummon() || !creature->ToTempSummon()->GetSummonerGUID() || !sObjectAccessor->FindPlayer(creature->ToTempSummon()->GetSummonerGUID()))
                {
                    creature->DespawnOrUnsummon();
                    return;
                }

                Player* creator = sObjectAccessor->FindPlayer(creature->ToTempSummon()->GetSummonerGUID());
                TeamId team = creator->GetTeamId();

                if (team == TEAM_HORDE)
                {
                    if (GetData(BATTLEFIELD_WG_DATA_VEHICLE_H) < GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H))
                    {
                        UpdateData(BATTLEFIELD_WG_DATA_VEHICLE_H, 1);
                        creature->AddAura(SPELL_HORDE_FLAG, creature);
                        m_vehicles[team].insert(creature->GetGUID());
                        UpdateVehicleCountWG();
                    }
                    else
                    {
                        creature->DespawnOrUnsummon();
                        return;
                    }
                }
                else
                {
                    if (GetData(BATTLEFIELD_WG_DATA_VEHICLE_A) < GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_A))
                    {
                        UpdateData(BATTLEFIELD_WG_DATA_VEHICLE_A, 1);
                        creature->AddAura(SPELL_ALLIANCE_FLAG, creature);
                        m_vehicles[team].insert(creature->GetGUID());
                        UpdateVehicleCountWG();
                    }
                    else
                    {
                        creature->DespawnOrUnsummon();
                        return;
                    }
                }

                creature->CastSpell(creator, SPELL_GRAB_PASSENGER, true);
                break;
            }
        }
    }
}
예제 #5
0
void BattlefieldWG::OnCreatureCreate(Creature *creature, bool add)
{
    if (IsWarTime())
    {
        switch (creature->GetEntry())
        {
            case 28312:
            case 32627:
            case 27881:
            case 28094:
                {
                    uint8 team;
                    if (creature->getFaction() == WintergraspFaction[TEAM_ALLIANCE])
                        team = TEAM_ALLIANCE;
                    else if (creature->getFaction() == WintergraspFaction[TEAM_HORDE])
                        team = TEAM_HORDE;
                    else
                        return;

                    if (add)
                    {
                        if (team == TEAM_HORDE)
                        {
                            m_Data32[BATTLEFIELD_WG_DATA_VEHICLE_H]++;
                            if (GetData(BATTLEFIELD_WG_DATA_VEHICLE_H) <= GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H))
                            {
                                creature->AddAura(SPELL_HORDE_FLAG, creature);
                                m_vehicles[team].insert(creature->GetGUID());
                                UpdateVehicleCountWG();
                            }
                            else
                            {
                                creature->setDeathState(DEAD);
                                creature->SetRespawnTime(RESPAWN_ONE_DAY);
                                return;
                            }
                        }
                        else
                        {
                            m_Data32[BATTLEFIELD_WG_DATA_VEHICLE_A]++;
                            if (GetData(BATTLEFIELD_WG_DATA_VEHICLE_A) <= GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_A))
                            {
                                creature->AddAura(SPELL_ALLIANCE_FLAG, creature);
                                m_vehicles[team].insert(creature->GetGUID());
                                UpdateVehicleCountWG();
                            }
                            else
                            {
                                creature->setDeathState(DEAD);
                                creature->SetRespawnTime(RESPAWN_ONE_DAY);
                                return;
                            }
                        }
                    }
                    else
                    {
                        m_vehicles[team].erase(creature->GetGUID());
                        if (team == TEAM_HORDE)
                            m_Data32[BATTLEFIELD_WG_DATA_VEHICLE_H]--;
                        else
                            m_Data32[BATTLEFIELD_WG_DATA_VEHICLE_A]--;
                        UpdateVehicleCountWG();
                    }
                    break;
                }
        }
    }
}