-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathbattleground.cpp
More file actions
106 lines (87 loc) · 3.46 KB
/
battleground.cpp
File metadata and controls
106 lines (87 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* This file is part of the ScriptDev2 Project. See AUTHORS file for Copyright information
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* ScriptData
SDName: Battleground
SD%Complete: 100
SDComment: Spirit guides in battlegrounds will revive all players every 30 sec
SDCategory: Battlegrounds
EndScriptData */
#include "precompiled.h"
// **** Script Info ****
// Spiritguides in battlegrounds resurrecting many players at once
// every 30 seconds - through a channeled spell, which gets autocasted
// the whole time
// if spiritguide despawns all players around him will get teleported
// to the next spiritguide
// here i'm not sure, if a dummyspell exist for it
// **** Quick Info ****
// battleground spiritguides - this script handles gossipHello
// and JustDied also it let autocast the channel-spell
enum
{
SPELL_SPIRIT_HEAL_CHANNEL = 22011, // Spirit Heal Channel
SPELL_SPIRIT_HEAL = 22012, // Spirit Heal
SPELL_WAITING_TO_RESURRECT = 2584 // players who cancel this aura don't want a resurrection
};
struct npc_spirit_guideAI : public ScriptedAI
{
npc_spirit_guideAI(Creature* pCreature) : ScriptedAI(pCreature)
{
pCreature->SetActiveObjectState(true);
Reset();
}
void Reset() override {}
void UpdateAI(const uint32 /*uiDiff*/) override
{
// auto cast the whole time this spell
if (!m_creature->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
m_creature->CastSpell(m_creature, SPELL_SPIRIT_HEAL_CHANNEL, false);
}
void CorpseRemoved(uint32&) override
{
// TODO: would be better to cast a dummy spell
Map* pMap = m_creature->GetMap();
if (!pMap || !pMap->IsBattleGround())
return;
Map::PlayerList const& PlayerList = pMap->GetPlayers();
for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
{
Player* pPlayer = itr->getSource();
if (!pPlayer || !pPlayer->IsWithinDistInMap(m_creature, 20.0f) || !pPlayer->HasAura(SPELL_WAITING_TO_RESURRECT))
continue;
// repop player again - now this node won't be counted and another node is searched
pPlayer->RepopAtGraveyard();
}
}
};
bool GossipHello_npc_spirit_guide(Player* pPlayer, Creature* /*pCreature*/)
{
pPlayer->CastSpell(pPlayer, SPELL_WAITING_TO_RESURRECT, true);
return true;
}
CreatureAI* GetAI_npc_spirit_guide(Creature* pCreature)
{
return new npc_spirit_guideAI(pCreature);
}
void AddSC_battleground()
{
Script* pNewScript;
pNewScript = new Script;
pNewScript->Name = "npc_spirit_guide";
pNewScript->GetAI = &GetAI_npc_spirit_guide;
pNewScript->pGossipHello = &GossipHello_npc_spirit_guide;
pNewScript->RegisterSelf();
}