BF/Wintergrasp: Now graveyards use db spawned spirits.
This commit is contained in:
@@ -717,32 +717,24 @@ BfGraveYard::BfGraveYard(Battlefield *Bf)
|
||||
m_ResurrectQueue.clear();
|
||||
}
|
||||
|
||||
void BfGraveYard::Init(uint32 horde_entry, uint32 alliance_entry, float x, float y, float z, float o, TeamId startcontrol, uint32 gy)
|
||||
void BfGraveYard::Initialize(TeamId startcontrol, uint32 gy)
|
||||
{
|
||||
m_ControlTeam = startcontrol;
|
||||
if (Creature* cre = m_Bf->SpawnCreature(horde_entry, x, y, z, o, TEAM_HORDE))
|
||||
{
|
||||
m_SpiritGuide[TEAM_HORDE] = cre;
|
||||
m_SpiritGuide[TEAM_HORDE]->SetReactState(REACT_PASSIVE);
|
||||
if (m_ControlTeam == TEAM_ALLIANCE)
|
||||
m_SpiritGuide[TEAM_HORDE]->SetVisible(false);
|
||||
}
|
||||
else
|
||||
sLog->outError("BfGraveYard::Init can't spawn horde spiritguide %u", horde_entry);
|
||||
|
||||
if (Creature* cre = m_Bf->SpawnCreature(alliance_entry, x, y, z, o, TEAM_ALLIANCE))
|
||||
{
|
||||
m_SpiritGuide[TEAM_ALLIANCE] = cre;
|
||||
m_SpiritGuide[TEAM_ALLIANCE]->SetReactState(REACT_PASSIVE);
|
||||
if (m_ControlTeam == TEAM_HORDE)
|
||||
m_SpiritGuide[TEAM_ALLIANCE]->SetVisible(false);
|
||||
}
|
||||
else
|
||||
sLog->outError("BfGraveYard::Init can't spawn alliance spiritguide %u", alliance_entry);
|
||||
|
||||
m_GraveyardId = gy;
|
||||
}
|
||||
|
||||
void BfGraveYard::SetSpirit(Creature* spirit, TeamId team)
|
||||
{
|
||||
if (!spirit)
|
||||
{
|
||||
sLog->outError("<Error - Wintergrasp>: Invalid Spirit.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_SpiritGuide[team] = spirit->GetGUID();
|
||||
spirit->SetReactState(REACT_PASSIVE);
|
||||
}
|
||||
|
||||
float BfGraveYard::GetDistance(Player *plr)
|
||||
{
|
||||
const WorldSafeLocsEntry* ws = sWorldSafeLocsStore.LookupEntry(m_GraveyardId);
|
||||
@@ -782,8 +774,8 @@ void BfGraveYard::Resurrect()
|
||||
|
||||
// Check player isinworld and player is on good graveyard
|
||||
if (plr->IsInWorld())
|
||||
if (m_SpiritGuide[m_ControlTeam])
|
||||
m_SpiritGuide[m_ControlTeam]->CastSpell(m_SpiritGuide[m_ControlTeam], SPELL_SPIRIT_HEAL, true);
|
||||
if (Unit* spirit = sObjectAccessor->FindUnit(m_SpiritGuide[m_ControlTeam]))
|
||||
spirit->CastSpell(spirit, SPELL_SPIRIT_HEAL, true);
|
||||
|
||||
// Resurect player
|
||||
plr->CastSpell(plr, SPELL_RESURRECTION_VISUAL, true);
|
||||
@@ -801,10 +793,11 @@ void BfGraveYard::Resurrect()
|
||||
void BfGraveYard::ChangeControl(TeamId team)
|
||||
{
|
||||
// Guide switching
|
||||
if (m_SpiritGuide[1 - team])
|
||||
// Note: Visiblity changes are made by phasing
|
||||
/*if (m_SpiritGuide[1 - team])
|
||||
m_SpiritGuide[1 - team]->SetVisible(false);
|
||||
if (m_SpiritGuide[team])
|
||||
m_SpiritGuide[team]->SetVisible(true);
|
||||
m_SpiritGuide[team]->SetVisible(true);*/
|
||||
|
||||
m_ControlTeam = team;
|
||||
// Teleport to other graveyard, player witch were on this graveyard
|
||||
|
||||
@@ -145,14 +145,26 @@ public:
|
||||
|
||||
// use for found the nearest graveyard
|
||||
float GetDistance(Player * plr);
|
||||
void Init(uint32 horde_entry, uint32 alliance_entry, float x, float y, float z, float o, TeamId startcontrol, uint32 gy);
|
||||
void Initialize(TeamId startcontrol, uint32 gy);
|
||||
void SetSpirit(Creature* spirit, TeamId team);
|
||||
void AddPlayer(uint64 player_guid);
|
||||
void RemovePlayer(uint64 player_guid);
|
||||
|
||||
void Resurrect();
|
||||
void RelocateDeadPlayers();
|
||||
|
||||
bool HasNpc(uint64 guid) { return (m_SpiritGuide[0]->GetGUID() == guid || m_SpiritGuide[1]->GetGUID() == guid); }
|
||||
bool HasNpc(uint64 guid)
|
||||
{
|
||||
// npcs could not be loaded in the map yet.
|
||||
if (!m_SpiritGuide[0] || !m_SpiritGuide[1])
|
||||
return false;
|
||||
|
||||
if (!sObjectAccessor->FindUnit(m_SpiritGuide[0]) ||
|
||||
!sObjectAccessor->FindUnit(m_SpiritGuide[1]))
|
||||
return false;
|
||||
|
||||
return (m_SpiritGuide[0] == guid || m_SpiritGuide[1] == guid);
|
||||
}
|
||||
bool HasPlayer(uint64 guid) { return m_ResurrectQueue.find(guid) != m_ResurrectQueue.end(); }
|
||||
uint32 GetGraveYardId() { return m_GraveyardId; }
|
||||
|
||||
@@ -160,7 +172,7 @@ protected:
|
||||
|
||||
TeamId m_ControlTeam;
|
||||
uint32 m_GraveyardId;
|
||||
Creature *m_SpiritGuide[2];
|
||||
uint64 m_SpiritGuide[2];
|
||||
GuidSet m_ResurrectQueue;
|
||||
Battlefield *m_Bf;
|
||||
};
|
||||
|
||||
@@ -88,10 +88,13 @@ bool BattlefieldWG::SetupBattlefield()
|
||||
for (uint8 i = 0; i < BATTLEFIELD_WG_GY_MAX; i++)
|
||||
{
|
||||
BfGraveYardWG *gy = new BfGraveYardWG(this);
|
||||
if (WGGraveYard[i].startcontrol == TEAM_NEUTRAL) // When between games, the graveyard is controlled by the defending team
|
||||
gy->Init(NPC_TAUNKA_SPIRIT_GUIDE, NPC_DWARVEN_SPIRIT_GUIDE, WGGraveYard[i].x, WGGraveYard[i].y, WGGraveYard[i].z, WGGraveYard[i].o, m_DefenderTeam, WGGraveYard[i].gyid);
|
||||
|
||||
// When between games, the graveyard is controlled by the defending team
|
||||
if (WGGraveYard[i].startcontrol == TEAM_NEUTRAL)
|
||||
gy->Initialize(m_DefenderTeam, WGGraveYard[i].gyid);
|
||||
else
|
||||
gy->Init(NPC_TAUNKA_SPIRIT_GUIDE, NPC_DWARVEN_SPIRIT_GUIDE, WGGraveYard[i].x, WGGraveYard[i].y, WGGraveYard[i].z, WGGraveYard[i].o, WGGraveYard[i].startcontrol, WGGraveYard[i].gyid);
|
||||
gy->Initialize(WGGraveYard[i].startcontrol, WGGraveYard[i].gyid);
|
||||
|
||||
gy->SetTextId(WGGraveYard[i].textid);
|
||||
m_GraveYardList[i] = gy;
|
||||
}
|
||||
@@ -578,8 +581,53 @@ void BattlefieldWG::OnStartGrouping()
|
||||
SendWarningToAllInZone(BATTLEFIELD_WG_TEXT_WILL_START);
|
||||
}
|
||||
|
||||
uint8 BattlefieldWG::GetSpiritGraveyardId(uint32 areaId)
|
||||
{
|
||||
uint8 graveyardId = 0;
|
||||
|
||||
switch (areaId)
|
||||
{
|
||||
case AREA_WINTERGRASP_FORTRESS:
|
||||
return BATTLEFIELD_WG_GY_KEEP;
|
||||
case AREA_THE_SUNKEN_RING:
|
||||
return BATTLEFIELD_WG_GY_WORKSHOP_NE;
|
||||
case AREA_THE_BROKEN_TEMPLATE:
|
||||
return BATTLEFIELD_WG_GY_WORKSHOP_NW;
|
||||
case AREA_WESTPARK_WORKSHOP:
|
||||
return BATTLEFIELD_WG_GY_WORKSHOP_SW;
|
||||
case AREA_EASTPARK_WORKSHOP:
|
||||
return BATTLEFIELD_WG_GY_WORKSHOP_SE;
|
||||
case AREA_WINTERGRASP:
|
||||
return BATTLEFIELD_WG_GY_ALLIANCE;
|
||||
case AREA_THE_CHILLED_QUAGMIRE:
|
||||
return BATTLEFIELD_WG_GY_HORDE;
|
||||
default:
|
||||
sLog->outError("<Error - Wintergrasp>: Unexpected Area Id %u", areaId);
|
||||
break;
|
||||
}
|
||||
|
||||
return graveyardId;
|
||||
}
|
||||
|
||||
void BattlefieldWG::OnCreatureCreate(Creature *creature)
|
||||
{
|
||||
// Accessing to db spawned creatures
|
||||
switch (creature->GetEntry())
|
||||
{
|
||||
// Alliance Spirit
|
||||
case NPC_DWARVEN_SPIRIT_GUIDE:
|
||||
// Horde Spirit
|
||||
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())
|
||||
|
||||
@@ -142,6 +142,18 @@ enum eWGWorldStates
|
||||
BATTLEFIELD_WG_WORLD_STATE_DEFENDER = 3802,
|
||||
BATTLEFIELD_WG_WORLD_STATE_ATTACKER = 3803,
|
||||
};
|
||||
|
||||
enum WGAreaIds
|
||||
{
|
||||
AREA_WINTERGRASP_FORTRESS = 4575,
|
||||
AREA_THE_SUNKEN_RING = 4538,
|
||||
AREA_THE_BROKEN_TEMPLATE = 4539,
|
||||
AREA_WESTPARK_WORKSHOP = 4611,
|
||||
AREA_EASTPARK_WORKSHOP = 4612,
|
||||
AREA_WINTERGRASP = 4197,
|
||||
AREA_THE_CHILLED_QUAGMIRE = 4589,
|
||||
};
|
||||
|
||||
/*#########################
|
||||
*####### Graveyards ######*
|
||||
#########################*/
|
||||
@@ -157,7 +169,7 @@ class BfGraveYardWG : public BfGraveYard
|
||||
uint32 m_GossipTextId;
|
||||
};
|
||||
|
||||
enum eWGGraveyardId
|
||||
enum WGGraveyardId
|
||||
{
|
||||
BATTLEFIELD_WG_GY_WORKSHOP_NE,
|
||||
BATTLEFIELD_WG_GY_WORKSHOP_NW,
|
||||
@@ -414,6 +426,8 @@ class BattlefieldWG : public Battlefield
|
||||
void UpdateTenacity();
|
||||
void ProcessEvent(WorldObject *obj, uint32 eventId);
|
||||
|
||||
// returns the graveyardId in the specified area.
|
||||
uint8 GetSpiritGraveyardId(uint32 areaId);
|
||||
protected:
|
||||
bool m_CanClickOnOrb;
|
||||
GameObject* m_relic;
|
||||
|
||||
Reference in New Issue
Block a user