| 1 | #include "OutdoorPvPZM.h" |
|---|
| 2 | #include "ObjectMgr.h" |
|---|
| 3 | #include "OutdoorPvPMgr.h" |
|---|
| 4 | #include "Player.h" |
|---|
| 5 | #include "Creature.h" |
|---|
| 6 | #include "ObjectAccessor.h" |
|---|
| 7 | #include "WorldPacket.h" |
|---|
| 8 | #include "GossipDef.h" |
|---|
| 9 | #include "World.h" |
|---|
| 10 | |
|---|
| 11 | OutdoorPvPObjectiveZM_Beacon::OutdoorPvPObjectiveZM_Beacon(OutdoorPvP *pvp, ZM_BeaconType type) |
|---|
| 12 | : OutdoorPvPObjective(pvp), m_TowerType(type), m_TowerState(ZM_TOWERSTATE_N) |
|---|
| 13 | { |
|---|
| 14 | AddCapturePoint(ZMCapturePoints[type].entry,ZMCapturePoints[type].map,ZMCapturePoints[type].x,ZMCapturePoints[type].y,ZMCapturePoints[type].z,ZMCapturePoints[type].o,ZMCapturePoints[type].rot0,ZMCapturePoints[type].rot1,ZMCapturePoints[type].rot2,ZMCapturePoints[type].rot3); |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | void OutdoorPvPObjectiveZM_Beacon::FillInitialWorldStates(WorldPacket &data) |
|---|
| 18 | { |
|---|
| 19 | data << uint32(ZMBeaconInfo[m_TowerType].ui_tower_n) << uint32(bool(m_TowerState & ZM_TOWERSTATE_N)); |
|---|
| 20 | data << uint32(ZMBeaconInfo[m_TowerType].map_tower_n) << uint32(bool(m_TowerState & ZM_TOWERSTATE_N)); |
|---|
| 21 | data << uint32(ZMBeaconInfo[m_TowerType].ui_tower_a) << uint32(bool(m_TowerState & ZM_TOWERSTATE_A)); |
|---|
| 22 | data << uint32(ZMBeaconInfo[m_TowerType].map_tower_a) << uint32(bool(m_TowerState & ZM_TOWERSTATE_A)); |
|---|
| 23 | data << uint32(ZMBeaconInfo[m_TowerType].ui_tower_h) << uint32(bool(m_TowerState & ZM_TOWERSTATE_H)); |
|---|
| 24 | data << uint32(ZMBeaconInfo[m_TowerType].map_tower_h) << uint32(bool(m_TowerState & ZM_TOWERSTATE_H)); |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | void OutdoorPvPObjectiveZM_Beacon::UpdateTowerState() |
|---|
| 28 | { |
|---|
| 29 | m_PvP->SendUpdateWorldState(uint32(ZMBeaconInfo[m_TowerType].ui_tower_n),uint32(bool(m_TowerState & ZM_TOWERSTATE_N))); |
|---|
| 30 | m_PvP->SendUpdateWorldState(uint32(ZMBeaconInfo[m_TowerType].map_tower_n),uint32(bool(m_TowerState & ZM_TOWERSTATE_N))); |
|---|
| 31 | m_PvP->SendUpdateWorldState(uint32(ZMBeaconInfo[m_TowerType].ui_tower_a),uint32(bool(m_TowerState & ZM_TOWERSTATE_A))); |
|---|
| 32 | m_PvP->SendUpdateWorldState(uint32(ZMBeaconInfo[m_TowerType].map_tower_a),uint32(bool(m_TowerState & ZM_TOWERSTATE_A))); |
|---|
| 33 | m_PvP->SendUpdateWorldState(uint32(ZMBeaconInfo[m_TowerType].ui_tower_h),uint32(bool(m_TowerState & ZM_TOWERSTATE_H))); |
|---|
| 34 | m_PvP->SendUpdateWorldState(uint32(ZMBeaconInfo[m_TowerType].map_tower_h),uint32(bool(m_TowerState & ZM_TOWERSTATE_H))); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | bool OutdoorPvPObjectiveZM_Beacon::HandlePlayerEnter(Player *plr) |
|---|
| 38 | { |
|---|
| 39 | if(OutdoorPvPObjective::HandlePlayerEnter(plr)) |
|---|
| 40 | { |
|---|
| 41 | plr->SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_disp, 1); |
|---|
| 42 | uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f); |
|---|
| 43 | plr->SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_pos, phase); |
|---|
| 44 | plr->SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_n, m_NeutralValue); |
|---|
| 45 | return true; |
|---|
| 46 | } |
|---|
| 47 | return false; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | void OutdoorPvPObjectiveZM_Beacon::HandlePlayerLeave(Player *plr) |
|---|
| 51 | { |
|---|
| 52 | plr->SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_disp, 0); |
|---|
| 53 | OutdoorPvPObjective::HandlePlayerLeave(plr); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | bool OutdoorPvPObjectiveZM_Beacon::HandleCapturePointEvent(Player *plr, uint32 eventId) |
|---|
| 57 | { |
|---|
| 58 | if(eventId == ZMBeaconInfo[m_TowerType].event_enter) |
|---|
| 59 | { |
|---|
| 60 | this->HandlePlayerEnter(plr); |
|---|
| 61 | return true; |
|---|
| 62 | } |
|---|
| 63 | else if (eventId == ZMBeaconInfo[m_TowerType].event_leave) |
|---|
| 64 | { |
|---|
| 65 | this->HandlePlayerLeave(plr); |
|---|
| 66 | return true; |
|---|
| 67 | } |
|---|
| 68 | return false; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | bool OutdoorPvPObjectiveZM_Beacon::Update(uint32 diff) |
|---|
| 72 | { |
|---|
| 73 | if(OutdoorPvPObjective::Update(diff)) |
|---|
| 74 | { |
|---|
| 75 | if(m_OldState != m_State) |
|---|
| 76 | { |
|---|
| 77 | // if changing from controlling alliance to horde |
|---|
| 78 | if( m_OldState == OBJECTIVESTATE_ALLIANCE ) |
|---|
| 79 | { |
|---|
| 80 | if(((OutdoorPvPZM*)m_PvP)->m_AllianceTowersControlled) |
|---|
| 81 | ((OutdoorPvPZM*)m_PvP)->m_AllianceTowersControlled--; |
|---|
| 82 | sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,objmgr.GetTrinityStringForDBCLocale(ZMBeaconLooseA[m_TowerType])); |
|---|
| 83 | } |
|---|
| 84 | // if changing from controlling horde to alliance |
|---|
| 85 | else if ( m_OldState == OBJECTIVESTATE_HORDE ) |
|---|
| 86 | { |
|---|
| 87 | if(((OutdoorPvPZM*)m_PvP)->m_HordeTowersControlled) |
|---|
| 88 | ((OutdoorPvPZM*)m_PvP)->m_HordeTowersControlled--; |
|---|
| 89 | sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,objmgr.GetTrinityStringForDBCLocale(ZMBeaconLooseH[m_TowerType])); |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | switch(m_State) |
|---|
| 93 | { |
|---|
| 94 | case OBJECTIVESTATE_ALLIANCE: |
|---|
| 95 | m_TowerState = ZM_TOWERSTATE_A; |
|---|
| 96 | if(((OutdoorPvPZM*)m_PvP)->m_AllianceTowersControlled<ZM_NUM_BEACONS) |
|---|
| 97 | ((OutdoorPvPZM*)m_PvP)->m_AllianceTowersControlled++; |
|---|
| 98 | sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,objmgr.GetTrinityStringForDBCLocale(ZMBeaconCaptureA[m_TowerType])); |
|---|
| 99 | break; |
|---|
| 100 | case OBJECTIVESTATE_HORDE: |
|---|
| 101 | m_TowerState = ZM_TOWERSTATE_H; |
|---|
| 102 | if(((OutdoorPvPZM*)m_PvP)->m_HordeTowersControlled<ZM_NUM_BEACONS) |
|---|
| 103 | ((OutdoorPvPZM*)m_PvP)->m_HordeTowersControlled++; |
|---|
| 104 | sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,objmgr.GetTrinityStringForDBCLocale(ZMBeaconCaptureH[m_TowerType])); |
|---|
| 105 | break; |
|---|
| 106 | case OBJECTIVESTATE_NEUTRAL: |
|---|
| 107 | case OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE: |
|---|
| 108 | case OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE: |
|---|
| 109 | case OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE: |
|---|
| 110 | case OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE: |
|---|
| 111 | m_TowerState = ZM_TOWERSTATE_N; |
|---|
| 112 | break; |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | UpdateTowerState(); |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | if(m_ShiftPhase != m_OldPhase) |
|---|
| 119 | { |
|---|
| 120 | // send this too, sometimes the slider disappears, dunno why :( |
|---|
| 121 | SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_disp, 1); |
|---|
| 122 | // send these updates to only the ones in this objective |
|---|
| 123 | uint32 phase = (uint32)ceil(( m_ShiftPhase + m_ShiftMaxPhase) / ( 2 * m_ShiftMaxPhase ) * 100.0f); |
|---|
| 124 | SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_pos, phase); |
|---|
| 125 | SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_n, m_NeutralValue); |
|---|
| 126 | } |
|---|
| 127 | return true; |
|---|
| 128 | } |
|---|
| 129 | return false; |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | bool OutdoorPvPZM::Update(uint32 diff) |
|---|
| 133 | { |
|---|
| 134 | bool changed = false; |
|---|
| 135 | if(changed = OutdoorPvP::Update(diff)) |
|---|
| 136 | { |
|---|
| 137 | if(m_AllianceTowersControlled == ZM_NUM_BEACONS) |
|---|
| 138 | m_GraveYard->SetBeaconState(ALLIANCE); |
|---|
| 139 | else if(m_HordeTowersControlled == ZM_NUM_BEACONS) |
|---|
| 140 | m_GraveYard->SetBeaconState(HORDE); |
|---|
| 141 | else |
|---|
| 142 | m_GraveYard->SetBeaconState(0); |
|---|
| 143 | } |
|---|
| 144 | return changed; |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | void OutdoorPvPZM::HandlePlayerEnterZone(Player * plr, uint32 zone) |
|---|
| 148 | { |
|---|
| 149 | if(plr->GetTeam() == ALLIANCE) |
|---|
| 150 | { |
|---|
| 151 | if(m_GraveYard->m_GraveYardState & ZM_GRAVEYARD_A) |
|---|
| 152 | plr->CastSpell(plr,ZM_CAPTURE_BUFF,true); |
|---|
| 153 | } |
|---|
| 154 | else |
|---|
| 155 | { |
|---|
| 156 | if(m_GraveYard->m_GraveYardState & ZM_GRAVEYARD_H) |
|---|
| 157 | plr->CastSpell(plr,ZM_CAPTURE_BUFF,true); |
|---|
| 158 | } |
|---|
| 159 | OutdoorPvP::HandlePlayerEnterZone(plr,zone); |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | void OutdoorPvPZM::HandlePlayerLeaveZone(Player * plr, uint32 zone) |
|---|
| 163 | { |
|---|
| 164 | // remove buffs |
|---|
| 165 | plr->RemoveAurasDueToSpell(ZM_CAPTURE_BUFF); |
|---|
| 166 | // remove flag |
|---|
| 167 | plr->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_A); |
|---|
| 168 | plr->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_H); |
|---|
| 169 | OutdoorPvP::HandlePlayerLeaveZone(plr, zone); |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | OutdoorPvPZM::OutdoorPvPZM() |
|---|
| 173 | { |
|---|
| 174 | m_TypeId = OUTDOOR_PVP_ZM; |
|---|
| 175 | m_GraveYard = NULL; |
|---|
| 176 | m_AllianceTowersControlled = 0; |
|---|
| 177 | m_HordeTowersControlled = 0; |
|---|
| 178 | |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | bool OutdoorPvPZM::SetupOutdoorPvP() |
|---|
| 182 | { |
|---|
| 183 | m_AllianceTowersControlled = 0; |
|---|
| 184 | m_HordeTowersControlled = 0; |
|---|
| 185 | |
|---|
| 186 | // add the zones affected by the pvp buff |
|---|
| 187 | for(int i = 0; i < OutdoorPvPZMBuffZonesNum; ++i) |
|---|
| 188 | sOutdoorPvPMgr.AddZone(OutdoorPvPZMBuffZones[i],this); |
|---|
| 189 | |
|---|
| 190 | m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveZM_Beacon(this,ZM_BEACON_WEST)); |
|---|
| 191 | m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveZM_Beacon(this,ZM_BEACON_EAST)); |
|---|
| 192 | m_GraveYard = new OutdoorPvPObjectiveZM_GraveYard(this); |
|---|
| 193 | m_OutdoorPvPObjectives.insert(m_GraveYard); // though the update function isn't used, the handleusego is! |
|---|
| 194 | |
|---|
| 195 | return true; |
|---|
| 196 | } |
|---|
| 197 | |
|---|
| 198 | void OutdoorPvPZM::HandleKillImpl(Player *plr, Unit * killed) |
|---|
| 199 | { |
|---|
| 200 | if(killed->GetTypeId() != TYPEID_PLAYER) |
|---|
| 201 | return; |
|---|
| 202 | |
|---|
| 203 | if(plr->GetTeam() == ALLIANCE && ((Player*)killed)->GetTeam() != ALLIANCE) |
|---|
| 204 | plr->CastSpell(plr,ZM_AlliancePlayerKillReward,true); |
|---|
| 205 | else if(plr->GetTeam() == HORDE && ((Player*)killed)->GetTeam() != HORDE) |
|---|
| 206 | plr->CastSpell(plr,ZM_HordePlayerKillReward,true); |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | void OutdoorPvPZM::BuffTeam(uint32 team) |
|---|
| 210 | { |
|---|
| 211 | if(team == ALLIANCE) |
|---|
| 212 | { |
|---|
| 213 | for(std::set<uint64>::iterator itr = m_PlayerGuids[0].begin(); itr != m_PlayerGuids[0].end(); ++itr) |
|---|
| 214 | { |
|---|
| 215 | if(Player * plr = objmgr.GetPlayer(*itr)) |
|---|
| 216 | if(plr->IsInWorld()) plr->CastSpell(plr,ZM_CAPTURE_BUFF,true); |
|---|
| 217 | } |
|---|
| 218 | for(std::set<uint64>::iterator itr = m_PlayerGuids[1].begin(); itr != m_PlayerGuids[1].end(); ++itr) |
|---|
| 219 | { |
|---|
| 220 | if(Player * plr = objmgr.GetPlayer(*itr)) |
|---|
| 221 | if(plr->IsInWorld()) plr->RemoveAurasDueToSpell(ZM_CAPTURE_BUFF); |
|---|
| 222 | } |
|---|
| 223 | } |
|---|
| 224 | else if(team == HORDE) |
|---|
| 225 | { |
|---|
| 226 | for(std::set<uint64>::iterator itr = m_PlayerGuids[1].begin(); itr != m_PlayerGuids[1].end(); ++itr) |
|---|
| 227 | { |
|---|
| 228 | if(Player * plr = objmgr.GetPlayer(*itr)) |
|---|
| 229 | if(plr->IsInWorld()) plr->CastSpell(plr,ZM_CAPTURE_BUFF,true); |
|---|
| 230 | } |
|---|
| 231 | for(std::set<uint64>::iterator itr = m_PlayerGuids[0].begin(); itr != m_PlayerGuids[0].end(); ++itr) |
|---|
| 232 | { |
|---|
| 233 | if(Player * plr = objmgr.GetPlayer(*itr)) |
|---|
| 234 | if(plr->IsInWorld()) plr->RemoveAurasDueToSpell(ZM_CAPTURE_BUFF); |
|---|
| 235 | } |
|---|
| 236 | } |
|---|
| 237 | else |
|---|
| 238 | { |
|---|
| 239 | for(std::set<uint64>::iterator itr = m_PlayerGuids[0].begin(); itr != m_PlayerGuids[0].end(); ++itr) |
|---|
| 240 | { |
|---|
| 241 | if(Player * plr = objmgr.GetPlayer(*itr)) |
|---|
| 242 | if(plr->IsInWorld()) plr->RemoveAurasDueToSpell(ZM_CAPTURE_BUFF); |
|---|
| 243 | } |
|---|
| 244 | for(std::set<uint64>::iterator itr = m_PlayerGuids[1].begin(); itr != m_PlayerGuids[1].end(); ++itr) |
|---|
| 245 | { |
|---|
| 246 | if(Player * plr = objmgr.GetPlayer(*itr)) |
|---|
| 247 | if(plr->IsInWorld()) plr->RemoveAurasDueToSpell(ZM_CAPTURE_BUFF); |
|---|
| 248 | } |
|---|
| 249 | } |
|---|
| 250 | } |
|---|
| 251 | |
|---|
| 252 | bool OutdoorPvPObjectiveZM_GraveYard::Update(uint32 diff) |
|---|
| 253 | { |
|---|
| 254 | bool retval = m_State != m_OldState; |
|---|
| 255 | m_State = m_OldState; |
|---|
| 256 | return retval; |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | int32 OutdoorPvPObjectiveZM_GraveYard::HandleOpenGo(Player *plr, uint64 guid) |
|---|
| 260 | { |
|---|
| 261 | uint32 retval = OutdoorPvPObjective::HandleOpenGo(plr, guid); |
|---|
| 262 | if(retval>=0) |
|---|
| 263 | { |
|---|
| 264 | if(plr->HasAura(ZM_BATTLE_STANDARD_A,0) && m_GraveYardState != ZM_GRAVEYARD_A) |
|---|
| 265 | { |
|---|
| 266 | if(m_GraveYardState == ZM_GRAVEYARD_H) |
|---|
| 267 | sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,objmgr.GetTrinityStringForDBCLocale(LANG_OPVP_ZM_LOOSE_GY_H)); |
|---|
| 268 | m_GraveYardState = ZM_GRAVEYARD_A; |
|---|
| 269 | DelObject(0); // only one gotype is used in the whole outdoor pvp, no need to call it a constant |
|---|
| 270 | AddObject(0,ZM_Banner_A.entry,ZM_Banner_A.map,ZM_Banner_A.x,ZM_Banner_A.y,ZM_Banner_A.z,ZM_Banner_A.o,ZM_Banner_A.rot0,ZM_Banner_A.rot1,ZM_Banner_A.rot2,ZM_Banner_A.rot3); |
|---|
| 271 | objmgr.RemoveGraveYardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, HORDE); // rem gy |
|---|
| 272 | objmgr.AddGraveYardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, ALLIANCE, false); // add gy |
|---|
| 273 | ((OutdoorPvPZM*)m_PvP)->BuffTeam(ALLIANCE); |
|---|
| 274 | plr->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_A); |
|---|
| 275 | sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,objmgr.GetTrinityStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_A)); |
|---|
| 276 | } |
|---|
| 277 | else if(plr->HasAura(ZM_BATTLE_STANDARD_H,0) && m_GraveYardState != ZM_GRAVEYARD_H) |
|---|
| 278 | { |
|---|
| 279 | if(m_GraveYardState == ZM_GRAVEYARD_A) |
|---|
| 280 | sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,objmgr.GetTrinityStringForDBCLocale(LANG_OPVP_ZM_LOOSE_GY_A)); |
|---|
| 281 | m_GraveYardState = ZM_GRAVEYARD_H; |
|---|
| 282 | DelObject(0); // only one gotype is used in the whole outdoor pvp, no need to call it a constant |
|---|
| 283 | AddObject(0,ZM_Banner_H.entry,ZM_Banner_H.map,ZM_Banner_H.x,ZM_Banner_H.y,ZM_Banner_H.z,ZM_Banner_H.o,ZM_Banner_H.rot0,ZM_Banner_H.rot1,ZM_Banner_H.rot2,ZM_Banner_H.rot3); |
|---|
| 284 | objmgr.RemoveGraveYardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, ALLIANCE); // rem gy |
|---|
| 285 | objmgr.AddGraveYardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, HORDE, false); // add gy |
|---|
| 286 | ((OutdoorPvPZM*)m_PvP)->BuffTeam(HORDE); |
|---|
| 287 | plr->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_H); |
|---|
| 288 | sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,objmgr.GetTrinityStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_H)); |
|---|
| 289 | } |
|---|
| 290 | UpdateTowerState(); |
|---|
| 291 | } |
|---|
| 292 | return retval; |
|---|
| 293 | } |
|---|
| 294 | |
|---|
| 295 | OutdoorPvPObjectiveZM_GraveYard::OutdoorPvPObjectiveZM_GraveYard(OutdoorPvP *pvp) |
|---|
| 296 | : OutdoorPvPObjective(pvp) |
|---|
| 297 | { |
|---|
| 298 | m_BothControllingFaction = 0; |
|---|
| 299 | m_GraveYardState = ZM_GRAVEYARD_N; |
|---|
| 300 | m_FlagCarrierGUID = 0; |
|---|
| 301 | // add field scouts here |
|---|
| 302 | AddCreature(ZM_ALLIANCE_FIELD_SCOUT,ZM_AllianceFieldScout.entry,ZM_AllianceFieldScout.teamval,ZM_AllianceFieldScout.map,ZM_AllianceFieldScout.x,ZM_AllianceFieldScout.y,ZM_AllianceFieldScout.z,ZM_AllianceFieldScout.o); |
|---|
| 303 | AddCreature(ZM_HORDE_FIELD_SCOUT,ZM_HordeFieldScout.entry,ZM_HordeFieldScout.teamval,ZM_HordeFieldScout.map,ZM_HordeFieldScout.x,ZM_HordeFieldScout.y,ZM_HordeFieldScout.z,ZM_HordeFieldScout.o); |
|---|
| 304 | // add neutral banner |
|---|
| 305 | AddObject(0,ZM_Banner_N.entry,ZM_Banner_N.map,ZM_Banner_N.x,ZM_Banner_N.y,ZM_Banner_N.z,ZM_Banner_N.o,ZM_Banner_N.rot0,ZM_Banner_N.rot1,ZM_Banner_N.rot2,ZM_Banner_N.rot3); |
|---|
| 306 | } |
|---|
| 307 | |
|---|
| 308 | void OutdoorPvPObjectiveZM_GraveYard::UpdateTowerState() |
|---|
| 309 | { |
|---|
| 310 | m_PvP->SendUpdateWorldState(ZM_MAP_GRAVEYARD_N,uint32(bool(m_GraveYardState & ZM_GRAVEYARD_N))); |
|---|
| 311 | m_PvP->SendUpdateWorldState(ZM_MAP_GRAVEYARD_H,uint32(bool(m_GraveYardState & ZM_GRAVEYARD_H))); |
|---|
| 312 | m_PvP->SendUpdateWorldState(ZM_MAP_GRAVEYARD_A,uint32(bool(m_GraveYardState & ZM_GRAVEYARD_A))); |
|---|
| 313 | |
|---|
| 314 | m_PvP->SendUpdateWorldState(ZM_MAP_ALLIANCE_FLAG_READY,uint32(m_BothControllingFaction == ALLIANCE)); |
|---|
| 315 | m_PvP->SendUpdateWorldState(ZM_MAP_ALLIANCE_FLAG_NOT_READY,uint32(m_BothControllingFaction != ALLIANCE)); |
|---|
| 316 | m_PvP->SendUpdateWorldState(ZM_MAP_HORDE_FLAG_READY,uint32(m_BothControllingFaction == HORDE)); |
|---|
| 317 | m_PvP->SendUpdateWorldState(ZM_MAP_HORDE_FLAG_NOT_READY,uint32(m_BothControllingFaction != HORDE)); |
|---|
| 318 | } |
|---|
| 319 | |
|---|
| 320 | void OutdoorPvPObjectiveZM_GraveYard::FillInitialWorldStates(WorldPacket &data) |
|---|
| 321 | { |
|---|
| 322 | data << ZM_MAP_GRAVEYARD_N << uint32(bool(m_GraveYardState & ZM_GRAVEYARD_N)); |
|---|
| 323 | data << ZM_MAP_GRAVEYARD_H << uint32(bool(m_GraveYardState & ZM_GRAVEYARD_H)); |
|---|
| 324 | data << ZM_MAP_GRAVEYARD_A << uint32(bool(m_GraveYardState & ZM_GRAVEYARD_A)); |
|---|
| 325 | |
|---|
| 326 | data << ZM_MAP_ALLIANCE_FLAG_READY << uint32(m_BothControllingFaction == ALLIANCE); |
|---|
| 327 | data << ZM_MAP_ALLIANCE_FLAG_NOT_READY << uint32(m_BothControllingFaction != ALLIANCE); |
|---|
| 328 | data << ZM_MAP_HORDE_FLAG_READY << uint32(m_BothControllingFaction == HORDE); |
|---|
| 329 | data << ZM_MAP_HORDE_FLAG_NOT_READY << uint32(m_BothControllingFaction != HORDE); |
|---|
| 330 | } |
|---|
| 331 | |
|---|
| 332 | void OutdoorPvPObjectiveZM_GraveYard::SetBeaconState(uint32 controlling_faction) |
|---|
| 333 | { |
|---|
| 334 | // nothing to do here |
|---|
| 335 | if(m_BothControllingFaction == controlling_faction) |
|---|
| 336 | return; |
|---|
| 337 | m_BothControllingFaction = controlling_faction; |
|---|
| 338 | |
|---|
| 339 | switch(controlling_faction) |
|---|
| 340 | { |
|---|
| 341 | case ALLIANCE: |
|---|
| 342 | // if ally already controls the gy and taken back both beacons, return, nothing to do for us |
|---|
| 343 | if(m_GraveYardState & ZM_GRAVEYARD_A) |
|---|
| 344 | return; |
|---|
| 345 | // ally doesn't control the gy, but controls the side beacons -> add gossip option, add neutral banner |
|---|
| 346 | break; |
|---|
| 347 | case HORDE: |
|---|
| 348 | // if horde already controls the gy and taken back both beacons, return, nothing to do for us |
|---|
| 349 | if(m_GraveYardState & ZM_GRAVEYARD_H) |
|---|
| 350 | return; |
|---|
| 351 | // horde doesn't control the gy, but controls the side beacons -> add gossip option, add neutral banner |
|---|
| 352 | break; |
|---|
| 353 | default: |
|---|
| 354 | // if the graveyard is not neutral, then leave it that way |
|---|
| 355 | // if the graveyard is neutral, then we have to dispel the buff from the flag carrier |
|---|
| 356 | if(m_GraveYardState & ZM_GRAVEYARD_N) |
|---|
| 357 | { |
|---|
| 358 | // gy was neutral, thus neutral banner was spawned, it is possible that someone was taking the flag to the gy |
|---|
| 359 | if(m_FlagCarrierGUID) |
|---|
| 360 | { |
|---|
| 361 | // remove flag from carrier, reset flag carrier guid |
|---|
| 362 | Player * p = objmgr.GetPlayer(m_FlagCarrierGUID); |
|---|
| 363 | if(p) |
|---|
| 364 | { |
|---|
| 365 | p->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_A); |
|---|
| 366 | p->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_H); |
|---|
| 367 | } |
|---|
| 368 | m_FlagCarrierGUID = 0; |
|---|
| 369 | } |
|---|
| 370 | } |
|---|
| 371 | break; |
|---|
| 372 | } |
|---|
| 373 | // send worldstateupdate |
|---|
| 374 | UpdateTowerState(); |
|---|
| 375 | } |
|---|
| 376 | |
|---|
| 377 | bool OutdoorPvPObjectiveZM_GraveYard::CanTalkTo(Player * plr, Creature * c, GossipOption & gso) |
|---|
| 378 | { |
|---|
| 379 | uint64 guid = c->GetGUID(); |
|---|
| 380 | std::map<uint64,uint32>::iterator itr = m_CreatureTypes.find(guid); |
|---|
| 381 | if(itr != m_CreatureTypes.end()) |
|---|
| 382 | { |
|---|
| 383 | if(itr->second == ZM_ALLIANCE_FIELD_SCOUT && plr->GetTeam() == ALLIANCE && m_BothControllingFaction == ALLIANCE && !m_FlagCarrierGUID && m_GraveYardState != ZM_GRAVEYARD_A) |
|---|
| 384 | { |
|---|
| 385 | gso.Option.assign(objmgr.GetTrinityStringForDBCLocale(LANG_OPVP_ZM_GOSSIP_ALLIANCE)); |
|---|
| 386 | return true; |
|---|
| 387 | } |
|---|
| 388 | else if(itr->second == ZM_HORDE_FIELD_SCOUT && plr->GetTeam() == HORDE && m_BothControllingFaction == HORDE && !m_FlagCarrierGUID && m_GraveYardState != ZM_GRAVEYARD_H) |
|---|
| 389 | { |
|---|
| 390 | gso.Option.assign(objmgr.GetTrinityStringForDBCLocale(LANG_OPVP_ZM_GOSSIP_HORDE)); |
|---|
| 391 | return true; |
|---|
| 392 | } |
|---|
| 393 | } |
|---|
| 394 | return false; |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | bool OutdoorPvPObjectiveZM_GraveYard::HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid) |
|---|
| 398 | { |
|---|
| 399 | std::map<uint64,uint32>::iterator itr = m_CreatureTypes.find(guid); |
|---|
| 400 | if(itr != m_CreatureTypes.end()) |
|---|
| 401 | { |
|---|
| 402 | Creature * cr = HashMapHolder<Creature>::Find(guid); |
|---|
| 403 | if(!cr) |
|---|
| 404 | return true; |
|---|
| 405 | // if the flag is already taken, then return |
|---|
| 406 | if(m_FlagCarrierGUID) |
|---|
| 407 | return true; |
|---|
| 408 | if(itr->second == ZM_ALLIANCE_FIELD_SCOUT) |
|---|
| 409 | { |
|---|
| 410 | cr->CastSpell(plr,ZM_BATTLE_STANDARD_A,true); |
|---|
| 411 | m_FlagCarrierGUID = plr->GetGUID(); |
|---|
| 412 | } |
|---|
| 413 | else if(itr->second == ZM_HORDE_FIELD_SCOUT) |
|---|
| 414 | { |
|---|
| 415 | cr->CastSpell(plr,ZM_BATTLE_STANDARD_H,true); |
|---|
| 416 | m_FlagCarrierGUID = plr->GetGUID(); |
|---|
| 417 | } |
|---|
| 418 | UpdateTowerState(); |
|---|
| 419 | plr->PlayerTalkClass->CloseGossip(); |
|---|
| 420 | return true; |
|---|
| 421 | } |
|---|
| 422 | return false; |
|---|
| 423 | } |
|---|
| 424 | |
|---|
| 425 | bool OutdoorPvPObjectiveZM_GraveYard::HandleDropFlag(Player * plr, uint32 spellId) |
|---|
| 426 | { |
|---|
| 427 | switch(spellId) |
|---|
| 428 | { |
|---|
| 429 | case ZM_BATTLE_STANDARD_A: |
|---|
| 430 | m_FlagCarrierGUID = 0; |
|---|
| 431 | return true; |
|---|
| 432 | case ZM_BATTLE_STANDARD_H: |
|---|
| 433 | m_FlagCarrierGUID = 0; |
|---|
| 434 | return true; |
|---|
| 435 | } |
|---|
| 436 | return false; |
|---|
| 437 | } |
|---|
| 438 | |
|---|
| 439 | void OutdoorPvPZM::FillInitialWorldStates(WorldPacket &data) |
|---|
| 440 | { |
|---|
| 441 | data << ZM_WORLDSTATE_UNK_1 << uint32(1); |
|---|
| 442 | for(OutdoorPvPObjectiveSet::iterator itr = m_OutdoorPvPObjectives.begin(); itr != m_OutdoorPvPObjectives.end(); ++itr) |
|---|
| 443 | { |
|---|
| 444 | (*itr)->FillInitialWorldStates(data); |
|---|
| 445 | } |
|---|
| 446 | } |
|---|
| 447 | |
|---|
| 448 | void OutdoorPvPZM::SendRemoveWorldStates(Player *plr) |
|---|
| 449 | { |
|---|
| 450 | plr->SendUpdateWorldState(ZM_UI_TOWER_SLIDER_N_W,0); |
|---|
| 451 | plr->SendUpdateWorldState(ZM_UI_TOWER_SLIDER_POS_W,0); |
|---|
| 452 | plr->SendUpdateWorldState(ZM_UI_TOWER_SLIDER_DISPLAY_W,0); |
|---|
| 453 | plr->SendUpdateWorldState(ZM_UI_TOWER_SLIDER_N_E,0); |
|---|
| 454 | plr->SendUpdateWorldState(ZM_UI_TOWER_SLIDER_POS_E,0); |
|---|
| 455 | plr->SendUpdateWorldState(ZM_UI_TOWER_SLIDER_DISPLAY_E,0); |
|---|
| 456 | plr->SendUpdateWorldState(ZM_WORLDSTATE_UNK_1,1); |
|---|
| 457 | plr->SendUpdateWorldState(ZM_UI_TOWER_EAST_N,0); |
|---|
| 458 | plr->SendUpdateWorldState(ZM_UI_TOWER_EAST_H,0); |
|---|
| 459 | plr->SendUpdateWorldState(ZM_UI_TOWER_EAST_A,0); |
|---|
| 460 | plr->SendUpdateWorldState(ZM_UI_TOWER_WEST_N,0); |
|---|
| 461 | plr->SendUpdateWorldState(ZM_UI_TOWER_WEST_H,0); |
|---|
| 462 | plr->SendUpdateWorldState(ZM_UI_TOWER_WEST_A,0); |
|---|
| 463 | plr->SendUpdateWorldState(ZM_MAP_TOWER_EAST_N,0); |
|---|
| 464 | plr->SendUpdateWorldState(ZM_MAP_TOWER_EAST_H,0); |
|---|
| 465 | plr->SendUpdateWorldState(ZM_MAP_TOWER_EAST_A,0); |
|---|
| 466 | plr->SendUpdateWorldState(ZM_MAP_GRAVEYARD_H,0); |
|---|
| 467 | plr->SendUpdateWorldState(ZM_MAP_GRAVEYARD_A,0); |
|---|
| 468 | plr->SendUpdateWorldState(ZM_MAP_GRAVEYARD_N,0); |
|---|
| 469 | plr->SendUpdateWorldState(ZM_MAP_TOWER_WEST_N,0); |
|---|
| 470 | plr->SendUpdateWorldState(ZM_MAP_TOWER_WEST_H,0); |
|---|
| 471 | plr->SendUpdateWorldState(ZM_MAP_TOWER_WEST_A,0); |
|---|
| 472 | plr->SendUpdateWorldState(ZM_MAP_HORDE_FLAG_READY,0); |
|---|
| 473 | plr->SendUpdateWorldState(ZM_MAP_HORDE_FLAG_NOT_READY,0); |
|---|
| 474 | plr->SendUpdateWorldState(ZM_MAP_ALLIANCE_FLAG_NOT_READY,0); |
|---|
| 475 | plr->SendUpdateWorldState(ZM_MAP_ALLIANCE_FLAG_READY,0); |
|---|
| 476 | } |
|---|