Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / server / src / ai_service / ai_bot_pet.h
blob67252b10c90d27270d9f74252b7e27a7e183e9df
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifdef NL_OS_WINDOWS
18 #pragma warning (disable : 4355) // warning C4355: 'this' : used in base member initializer list
19 #endif // NL_OS_WINDOWS
21 #ifndef RYAI_BOT_PET_H
22 #define RYAI_BOT_PET_H
24 #include "ai_bot.h"
25 #include "path_behaviors.h"
27 class CBotPet;
28 class CGrpPet;
29 class CPetOwner;
31 class IAIBotCAIProfile;
32 class CSpawnGroupPet;
34 //////////////////////////////////////////////////////////////////////////////
35 // CSpawnBotPet //
36 //////////////////////////////////////////////////////////////////////////////
38 class CSpawnBotPet
39 : public NLMISC::CDbgRefCount<CSpawnBotPet>
40 , public CSpawnBot
42 public:
43 CSpawnBotPet(TDataSetRow const& row, CBot& owner, NLMISC::CEntityId const& id, float radius, uint32 level, RYAI_MAP_CRUNCH::TAStarFlag denyFlags);
45 void processEvent(CCombatInterface::CEvent const& event) { }
47 RYZOMID::TTypeId getRyzomType() const { return RYZOMID::pack_animal; }
49 CBotPet& getPersistent ();
50 CBotPet const& getPersistent() const;
52 CSpawnGroupPet& spawnGrp();
54 void sendInfoToEGS() const { }
56 // pets are always attackable by bots
57 virtual bool isBotAttackable() const { return true; }
59 // Take position from mirror
60 void updatePos();
62 // Return true if the animal is mounted (thus controlled by the GPMS)
63 bool isMounted() const;
65 CPathPosition& pathPos() { return _PathPos; }
67 uint32 _DeathTime;
69 void setVisualPropertiesName();
71 private:
73 CPathPosition _PathPos;
76 //////////////////////////////////////////////////////////////////////////////
77 // CBotPet //
78 //////////////////////////////////////////////////////////////////////////////
80 class CBotPet
81 : public CBot
83 public:
84 CBotPet(CGroup* owner, CAIAliasDescriptionNode* alias = NULL);
85 ~CBotPet();
87 void getSpawnPos(CAIVector& triedPos, RYAI_MAP_CRUNCH::CWorldPosition& spawnPos, RYAI_MAP_CRUNCH::CWorldMap const& worldMap, CAngle& spawnTheta);
88 void setSpawnPos(CAIPos const& spawnPos) { _SpawnPos = spawnPos; }
89 CGrpPet& getPetGroup();
91 void update(uint32 ticks, CAIEntityPhysical const* petOwner);
93 CSpawnBotPet* getSpawn() { return static_cast<CSpawnBotPet*>(getSpawnObj()); }
95 CAIS::CCounter& getSpawnCounter();
97 void setDespawn() { _MustDespawn = true; }
98 bool haveToDespawn() const { return _MustDespawn; }
100 void changeOwner(NLMISC::CEntityId const& newOwner);
102 virtual std::string getOneLineInfoString() const { return std::string("Pet bot '") + getName() + "'"; }
104 virtual void triggerSetSheet(AISHEETS::ICreatureCPtr const& sheet);
106 protected:
107 RYZOMID::TTypeId getRyzomType() const { return RYZOMID::pack_animal; }
109 CSpawnBot* getSpawnBot(TDataSetRow const& row, NLMISC::CEntityId const& id, float radius)
111 return new CSpawnBotPet(row, *this, id, radius, getSheet()->Level(), getGroup().getAStarFlag());
114 private:
115 CAIPos _SpawnPos;
116 bool _MustDespawn;
119 /****************************************************************************/
120 /* Inlined methods */
121 /****************************************************************************/
123 //////////////////////////////////////////////////////////////////////////////
124 // CSpawnBotPet //
125 //////////////////////////////////////////////////////////////////////////////
127 inline
128 CSpawnBotPet::CSpawnBotPet(TDataSetRow const& row, CBot& owner, NLMISC::CEntityId const& id, float radius, uint32 level, RYAI_MAP_CRUNCH::TAStarFlag denyFlags)
129 : CSpawnBot(row, owner, id, radius, level, denyFlags)
130 , _DeathTime(0)
131 , _PathPos(CAngle())
135 inline
136 CBotPet& CSpawnBotPet::getPersistent()
138 return static_cast<CBotPet&>(CSpawnBot::getPersistent());
141 inline
142 CBotPet const& CSpawnBotPet::getPersistent() const
144 return static_cast<const CBotPet&>(CSpawnBot::getPersistent());
147 //////////////////////////////////////////////////////////////////////////////
148 // CBotPet //
149 //////////////////////////////////////////////////////////////////////////////
151 inline
152 CBotPet::CBotPet(CGroup* owner, CAIAliasDescriptionNode* alias)
153 : CBot(owner, alias)
154 , _MustDespawn(false)
158 inline
159 CBotPet::~CBotPet()
161 if (!isSpawned())
162 return;
163 despawnBot();
166 inline
167 CAIS::CCounter& CBotPet::getSpawnCounter()
169 return CAIS::instance()._PetBotCounter;
172 #endif