aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/CoreAI/GameObjectAI.h
blob: 54306e2cf720543fbd9a6cd450a35551b76ae471 (plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
 * This file is part of the TrinityCore 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, see <http://www.gnu.org/licenses/>.
 */

#ifndef TRINITY_GAMEOBJECTAI_H
#define TRINITY_GAMEOBJECTAI_H

#include "Define.h"
#include "LootItemType.h"
#include "ObjectGuid.h"
#include "Optional.h"

class Creature;
class GameObject;
class Player;
class Quest;
class SpellInfo;
class Unit;
class WorldObject;
enum class QuestGiverStatus : uint64;

namespace WorldPackets
{
    namespace Battleground
    {
        enum class BattlegroundCapturePointState : uint8;
    }
}

class TC_GAME_API GameObjectAI
{
    private:
        // Script Id
        uint32 const _scriptId;

    protected:
        GameObject* const me;

    public:
        explicit GameObjectAI(GameObject* go, uint32 scriptId = {}) noexcept;
        GameObjectAI(GameObjectAI const&) = delete;
        GameObjectAI(GameObjectAI&&) = delete;
        GameObjectAI& operator=(GameObjectAI const&) = delete;
        GameObjectAI& operator=(GameObjectAI&&) = delete;
        virtual ~GameObjectAI();

        // Gets the id of the AI (script id)
        uint32 GetId() const { return _scriptId; }

        virtual void UpdateAI(uint32 /*diff*/) { }

        virtual void InitializeAI() { Reset(); }

        virtual void Reset() { }

        // Pass parameters between AI
        virtual void DoAction([[maybe_unused]] int32 param) { }
        virtual void SetGUID([[maybe_unused]] ObjectGuid const& guid, [[maybe_unused]] int32 id) { }
        virtual ObjectGuid GetGUID([[maybe_unused]] int32 id) const { return ObjectGuid::Empty; }

        static int32 Permissible(GameObject const* go);

        // Called when the dialog status between a player and the gameobject is requested.
        virtual Optional<QuestGiverStatus> GetDialogStatus(Player const* player);

        // Called when a player opens a gossip dialog with the gameobject.
        virtual bool OnGossipHello(Player* /*player*/) { return false; }

        // Called when a player selects a gossip item in the gameobject's gossip menu.
        virtual bool OnGossipSelect(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/) { return false; }

        // Called when a player selects a gossip with a code in the gameobject's gossip menu.
        virtual bool OnGossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, char const* /*code*/) { return false; }

        // Called when a player accepts a quest from the gameobject.
        virtual void OnQuestAccept(Player* /*player*/, Quest const* /*quest*/) { }

        // Called when a player completes a quest and is rewarded, opt is the selected item's index or 0
        virtual void OnQuestReward(Player* /*player*/, Quest const* /*quest*/, LootItemType /*type*/, uint32 /*opt*/) { }

        // Called when a Player clicks a GameObject, before GossipHello
        // prevents achievement tracking if returning true
        virtual bool OnReportUse(Player* /*player*/) { return false; }

        virtual void Destroyed(WorldObject* /*attacker*/, uint32 /*eventId*/) { }
        virtual void Damaged(WorldObject* /*attacker*/, uint32 /*eventId*/) { }

        virtual uint32 GetData(uint32 /*id*/) const { return 0; }
        virtual void SetData64(uint32 /*id*/, uint64 /*value*/) { }
        virtual uint64 GetData64(uint32 /*id*/) const { return 0; }
        virtual void SetData(uint32 /*id*/, uint32 /*value*/) { }

        virtual void OnGameEvent(bool /*start*/, uint16 /*eventId*/) { }
        virtual void OnLootStateChanged(uint32 /*state*/, Unit* /*unit*/) { }
        virtual void OnStateChanged(uint32 /*state*/) { }
        virtual void EventInform(uint32 /*eventId*/) { }

        // Called when hit by a spell
        virtual void SpellHit(WorldObject* /*caster*/, SpellInfo const* /*spellInfo*/) { }

        // Called when spell hits a target
        virtual void SpellHitTarget(WorldObject* /*target*/, SpellInfo const* /*spellInfo*/) { }

        // Called when the gameobject summon successfully other creature
        virtual void JustSummoned(Creature* /*summon*/) { }

        virtual void SummonedCreatureDespawn(Creature* /*summon*/) { }
        virtual void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) { }

        // Called when the capture point gets assaulted by a player. Return true to disable default behaviour.
        virtual bool OnCapturePointAssaulted(Player* /*player*/) { return false; }
        // Called when the capture point state gets updated. Return true to disable default behaviour.
        virtual bool OnCapturePointUpdated(WorldPackets::Battleground::BattlegroundCapturePointState /*state*/) { return false; }
};

class TC_GAME_API NullGameObjectAI : public GameObjectAI
{
    public:
        using GameObjectAI::GameObjectAI;

        void UpdateAI(uint32 /*diff*/) override { }

        static int32 Permissible(GameObject const* go);
};
#endif