TrinityCore
Loading...
Searching...
No Matches
BattlegroundScript.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITY_BATTLEGROUND_SCRIPT_H
19#define TRINITY_BATTLEGROUND_SCRIPT_H
20
21#include "SharedDefines.h"
22#include "ZoneScript.h"
23
24#ifdef TRINITY_API_USE_DYNAMIC_LINKING
25#include <memory>
26#endif
27
28class Battleground;
29class BattlegroundMap;
30class ModuleReference;
31
33{
34public:
35 explicit BattlegroundScript(BattlegroundMap* map) noexcept;
36 ~BattlegroundScript() override = default;
37
38 virtual void OnInit() { }
39 virtual void OnUpdate([[maybe_unused]] uint32 diff) { }
40 virtual void OnPrepareStage1() { }
41 virtual void OnPrepareStage2() { }
42 virtual void OnPrepareStage3() { }
43 virtual void OnStart() { }
44 virtual void OnEnd([[maybe_unused]] Team winner) { }
45 virtual void OnPlayerJoined([[maybe_unused]] Player* player, [[maybe_unused]] bool inBattleground) { }
46 virtual void OnPlayerLeft([[maybe_unused]] Player* player) { }
47 virtual void OnPlayerKilled([[maybe_unused]] Player* victim, [[maybe_unused]] Player* killer) { }
48 virtual void OnUnitKilled([[maybe_unused]] Creature* victim, [[maybe_unused]] Unit* killer) { }
49 virtual Team GetPrematureWinner();
50
51 void TriggerGameEvent(uint32 gameEventId, WorldObject* source = nullptr, WorldObject* target = nullptr) override;
52
53protected:
54 void UpdateWorldState(int32 worldStateId, int32 value, bool hidden = false) const;
55
58
59private:
60#ifdef TRINITY_API_USE_DYNAMIC_LINKING
61 // Strong reference to the associated script module
62 std::shared_ptr<ModuleReference> module_reference;
63#endif // #ifndef TRINITY_API_USE_DYNAMIC_LINKING
64};
65
67{
68public:
69 explicit ArenaScript(BattlegroundMap* map);
70 ~ArenaScript() override = default;
71
72protected:
73 GameObject* CreateObject(uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, GOState goState = GO_STATE_READY) const;
74 Creature* CreateCreature(uint32 entry, float x, float y, float z, float o) const;
75};
76
77#endif // TRINITY_BATTLEGROUND_SCRIPT_H
#define TC_GAME_API
Definition Define.h:129
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
GOState
@ GO_STATE_READY
~ArenaScript() override=default
Battleground * battleground
virtual void OnPrepareStage1()
BattlegroundMap * battlegroundMap
~BattlegroundScript() override=default
virtual void OnEnd(Team winner)
virtual void OnPrepareStage2()
virtual void OnPlayerKilled(Player *victim, Player *killer)
virtual void OnPlayerLeft(Player *player)
virtual void OnUpdate(uint32 diff)
virtual void OnPrepareStage3()
virtual void OnPlayerJoined(Player *player, bool inBattleground)
virtual void OnUnitKilled(Creature *victim, Unit *killer)
Definition Unit.h:635
virtual void TriggerGameEvent(uint32 gameEventId, WorldObject *source=nullptr, WorldObject *target=nullptr)