TrinityCore
ZoneScript.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 ZONE_SCRIPT_H_
19#define ZONE_SCRIPT_H_
20
21#include "Define.h"
22#include "ObjectGuid.h"
23
24class AreaTrigger;
25class Creature;
26class CreatureGroup;
27class GameObject;
28class Player;
29class Unit;
30class WorldObject;
31struct CreatureData;
32
33enum class FlagState : uint8;
34
35enum class EncounterType : uint8
36{
40};
41
43{
44public:
51
52 virtual void HandleCaptureEventHorde([[maybe_unused]] GameObject* controlZone) { }
53 virtual void HandleCaptureEventAlliance([[maybe_unused]] GameObject* controlZone) { }
54 virtual void HandleContestedEventHorde([[maybe_unused]] GameObject* controlZone) { }
55 virtual void HandleContestedEventAlliance([[maybe_unused]] GameObject* controlZone) { }
56 virtual void HandleProgressEventHorde([[maybe_unused]] GameObject* controlZone) { }
57 virtual void HandleProgressEventAlliance([[maybe_unused]] GameObject* controlZone) { }
58 virtual void HandleNeutralEventHorde([[maybe_unused]] GameObject* controlZone) { HandleNeutralEvent(controlZone); }
59 virtual void HandleNeutralEventAlliance([[maybe_unused]] GameObject* controlZone) { HandleNeutralEvent(controlZone); }
60 virtual void HandleNeutralEvent([[maybe_unused]] GameObject* controlZone) { }
61};
62
64{
65 public:
67 ZoneScript(ZoneScript const& right);
68 ZoneScript(ZoneScript&& right) noexcept;
70 ZoneScript& operator=(ZoneScript&& right) noexcept;
71 virtual ~ZoneScript();
72
73 virtual uint32 GetCreatureEntry(ObjectGuid::LowType /*spawnId*/, CreatureData const* data);
74 virtual uint32 GetGameObjectEntry(ObjectGuid::LowType /*spawnId*/, uint32 entry) { return entry; }
75
76 virtual void OnCreatureCreate(Creature* ) { }
77 virtual void OnCreatureRemove(Creature* ) { }
78
79 virtual void OnGameObjectCreate(GameObject* ) { }
80 virtual void OnGameObjectRemove(GameObject* ) { }
81
82 virtual void OnAreaTriggerCreate([[maybe_unused]] AreaTrigger* areaTrigger) { }
83 virtual void OnAreaTriggerRemove([[maybe_unused]] AreaTrigger* areaTrigger) { }
84
85 virtual void OnUnitDeath([[maybe_unused]] Unit* unit) { }
86
87 // Triggers when the CreatureGroup no longer has any alive members (either last alive member dies or is removed from the group)
88 virtual void OnCreatureGroupDepleted([[maybe_unused]] CreatureGroup const* creatureGroup) { }
89
90 //All-purpose data storage ObjectGuid
91 virtual ObjectGuid GetGuidData(uint32 /*DataId*/) const { return ObjectGuid::Empty; }
92 virtual void SetGuidData(uint32 /*DataId*/, ObjectGuid /*Value*/) { }
93
94 //All-purpose data storage 64 bit
95 virtual uint64 GetData64(uint32 /*DataId*/) const { return 0; }
96 virtual void SetData64(uint32 /*DataId*/, uint64 /*Value*/) { }
97
98 //All-purpose data storage 32 bit
99 virtual uint32 GetData(uint32 /*DataId*/) const { return 0; }
100 virtual void SetData(uint32 /*DataId*/, uint32 /*Value*/) { }
101
102 virtual void TriggerGameEvent(uint32 gameEventId, WorldObject* source = nullptr, WorldObject* target = nullptr);
103 virtual void ProcessEvent([[maybe_unused]] WorldObject* obj, [[maybe_unused]] uint32 eventId, [[maybe_unused]] WorldObject* invoker) { }
104 virtual void DoAction([[maybe_unused]] uint32 actionId, [[maybe_unused]] WorldObject* source = nullptr, [[maybe_unused]] WorldObject* target = nullptr) { }
105
106 virtual void OnFlagStateChange([[maybe_unused]] GameObject* flagInBase, [[maybe_unused]] FlagState oldValue, [[maybe_unused]] FlagState newValue, [[maybe_unused]] Player* player) { }
107
108 virtual bool CanCaptureFlag([[maybe_unused]] AreaTrigger* areaTrigger, [[maybe_unused]] Player* player) { return false; }
109 virtual void OnCaptureFlag([[maybe_unused]] AreaTrigger* areaTrigger, [[maybe_unused]] Player* player) { }
110
111 // This hook is used with GAMEOBJECT_TYPE_FLAGSTAND. Newer gameobjects use GAMEOBJECT_TYPE_NEW_FLAG and should use `OnFlagStateChange`
112 virtual void OnFlagTaken([[maybe_unused]] GameObject* flag, [[maybe_unused]] Player* player) { }
113 // This hook is used with GAMEOBJECT_TYPE_FLAGSTAND. Newer gameobjects use GAMEOBJECT_TYPE_NEW_FLAG and should use `OnFlagStateChange`. The GameObject doesn't exist anymore, but the ObjectGuid does
114 virtual void OnFlagDropped([[maybe_unused]] ObjectGuid const& flagGuid, [[maybe_unused]] Player* player) { }
115};
116
117#endif
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
uint64_t uint64
Definition: Define.h:141
uint32_t uint32
Definition: Define.h:142
FlagState
Definition: GameObject.h:46
EncounterType
Definition: ZoneScript.h:36
virtual void HandleNeutralEventHorde(GameObject *controlZone)
Definition: ZoneScript.h:58
virtual void HandleProgressEventAlliance(GameObject *controlZone)
Definition: ZoneScript.h:57
ControlZoneHandler & operator=(ControlZoneHandler &&right) noexcept
ControlZoneHandler & operator=(ControlZoneHandler const &right)
virtual ~ControlZoneHandler()
virtual void HandleContestedEventAlliance(GameObject *controlZone)
Definition: ZoneScript.h:55
virtual void HandleNeutralEventAlliance(GameObject *controlZone)
Definition: ZoneScript.h:59
virtual void HandleCaptureEventHorde(GameObject *controlZone)
Definition: ZoneScript.h:52
virtual void HandleProgressEventHorde(GameObject *controlZone)
Definition: ZoneScript.h:56
virtual void HandleNeutralEvent(GameObject *controlZone)
Definition: ZoneScript.h:60
ControlZoneHandler(ControlZoneHandler const &right)
ControlZoneHandler(ControlZoneHandler &&right) noexcept
virtual void HandleContestedEventHorde(GameObject *controlZone)
Definition: ZoneScript.h:54
virtual void HandleCaptureEventAlliance(GameObject *controlZone)
Definition: ZoneScript.h:53
static ObjectGuid const Empty
Definition: ObjectGuid.h:275
uint64 LowType
Definition: ObjectGuid.h:280
Definition: Unit.h:628
ZoneScript & operator=(ZoneScript &&right) noexcept
virtual void OnFlagTaken(GameObject *flag, Player *player)
Definition: ZoneScript.h:112
virtual void DoAction(uint32 actionId, WorldObject *source=nullptr, WorldObject *target=nullptr)
Definition: ZoneScript.h:104
virtual uint32 GetGameObjectEntry(ObjectGuid::LowType, uint32 entry)
Definition: ZoneScript.h:74
virtual void SetData64(uint32, uint64)
Definition: ZoneScript.h:96
virtual void OnCreatureGroupDepleted(CreatureGroup const *creatureGroup)
Definition: ZoneScript.h:88
virtual bool CanCaptureFlag(AreaTrigger *areaTrigger, Player *player)
Definition: ZoneScript.h:108
virtual void OnGameObjectRemove(GameObject *)
Definition: ZoneScript.h:80
ZoneScript & operator=(ZoneScript const &right)
virtual void OnCaptureFlag(AreaTrigger *areaTrigger, Player *player)
Definition: ZoneScript.h:109
virtual void OnUnitDeath(Unit *unit)
Definition: ZoneScript.h:85
virtual uint32 GetData(uint32) const
Definition: ZoneScript.h:99
ZoneScript(ZoneScript &&right) noexcept
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:100
virtual ObjectGuid GetGuidData(uint32) const
Definition: ZoneScript.h:91
virtual void OnFlagDropped(ObjectGuid const &flagGuid, Player *player)
Definition: ZoneScript.h:114
ZoneScript(ZoneScript const &right)
virtual void OnAreaTriggerRemove(AreaTrigger *areaTrigger)
Definition: ZoneScript.h:83
virtual uint64 GetData64(uint32) const
Definition: ZoneScript.h:95
virtual void SetGuidData(uint32, ObjectGuid)
Definition: ZoneScript.h:92
virtual void OnFlagStateChange(GameObject *flagInBase, FlagState oldValue, FlagState newValue, Player *player)
Definition: ZoneScript.h:106
virtual void OnAreaTriggerCreate(AreaTrigger *areaTrigger)
Definition: ZoneScript.h:82
virtual void OnCreatureRemove(Creature *)
Definition: ZoneScript.h:77
virtual void OnCreatureCreate(Creature *)
Definition: ZoneScript.h:76
virtual ~ZoneScript()
virtual void ProcessEvent(WorldObject *obj, uint32 eventId, WorldObject *invoker)
Definition: ZoneScript.h:103
virtual void OnGameObjectCreate(GameObject *)
Definition: ZoneScript.h:79