root/trunk/src/game/OutdoorPvPZM.cpp @ 102

Revision 102, 21.0 kB (checked in by yumileroy, 17 years ago)

[svn] Fixed copyright notices to comply with GPL.

Original author: w12x
Date: 2008-10-23 03:29:52-05:00

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