1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * This file defines the classes:
22 * - CPlanteIdleFaunaProfile
23 * - CStaticPlanteIdleFaunaProfile
24 * - CAIFaunaActivityBaseSpawnProfile
25 * - CWanderFaunaProfile
26 * - CStaticWanderFaunaProfile
27 * - CGrazeFaunaProfile
28 * - CStaticGrazeFaunaProfile
30 * - CStaticRestFaunaProfile
31 * - CStaticFightFaunaProfile
32 * - CCorpseFaunaProfileFactory
33 * - CEatCorpseFaunaProfile
34 * - CStaticEatCorpseFaunaProfile
35 * - CCuriosityFaunaProfile
36 * - CStaticCuriosityFaunaProfile
39 #ifndef AI_PROFILE_FAUNA_H
40 #define AI_PROFILE_FAUNA_H
42 #include "profile.h" // for CAIBaseProfile
43 #include "path_behaviors.h" // for CPathPosition
44 #include "ai_bot_fauna.h" // for CCorpseFaunaProfile
45 #include "ai_grp_fauna.h"
46 #include "ai_mgr_fauna.h"
49 class CMovementMagnet
;
51 // ---------------------------------------------------------------------------
53 // ---------------------------------------------------------------------------
54 // COMPACT_POS_WARNINGS compress flooding warnings concerning path problems.
55 // Positions where the problems occures are stored and displayed and cleared
57 // :TODO: /!\ As it cannot be tested without long-time run with several
58 // players the following define can be commented to restore previous behavior.
59 #define COMPACT_POS_WARNINGS 1
61 class CFaunaProfileFloodLogger
64 typedef std::map
<std::string
, int> TLogPositions
;
67 CFaunaProfileFloodLogger(int period
)
74 TLogPositions logPositions
;
79 //////////////////////////////////////////////////////////////////////////////
80 // CPlanteIdleFaunaProfile //
81 //////////////////////////////////////////////////////////////////////////////
83 class CPlanteIdleFaunaProfile
84 : public CAIBaseProfile
87 CPlanteIdleFaunaProfile(CProfileOwner
* owner
);
89 /// @name IAIProfile implementation
91 virtual void beginProfile();
92 virtual void updateProfile(uint ticksSinceLastUpdate
);
93 virtual void endProfile();
94 virtual AITYPES::TProfiles
getAIProfileType() const { return AITYPES::ACTIVITY_PLANTIDLE
; }
95 virtual std::string
getOneLineInfoString() const;
102 //////////////////////////////////////////////////////////////////////////////
103 // CAIFaunaActivityBaseSpawnProfile //
104 //////////////////////////////////////////////////////////////////////////////
106 class CAIFaunaActivityBaseSpawnProfile
107 : public CAIBaseProfile
108 , public IMouvementMagnetOwner
111 CAIFaunaActivityBaseSpawnProfile(CProfileOwner
* owner
);
113 virtual NLMISC::CSmartPtr
<CMovementMagnet
> const& getMovementMagnet() const;
116 NLMISC::CSmartPtr
<CMovementMagnet
> _MovementMagnet
;
117 CPathPosition _PathPos
;
121 //////////////////////////////////////////////////////////////////////////////
122 // CWanderFaunaProfile //
123 //////////////////////////////////////////////////////////////////////////////
125 class CWanderFaunaProfile
126 : public CAIFaunaActivityBaseSpawnProfile
129 CWanderFaunaProfile(CProfileOwner
* owner
);
131 /// @name IAIProfile implementation
133 virtual void beginProfile();
134 virtual void updateProfile(uint ticksSinceLastUpdate
);
135 virtual void endProfile();
136 virtual AITYPES::TProfiles
getAIProfileType() const { return AITYPES::ACTIVITY_WANDERING
; }
137 virtual std::string
getOneLineInfoString() const;
141 RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags
;
142 CSpawnBotFauna
* _Bot
;
143 double _magnetDistSq
; ///< square distance from bot to his magnet at last move
144 static CFaunaProfileFloodLogger _FloodLogger
;
147 //////////////////////////////////////////////////////////////////////////////
148 // CGrazeFaunaProfile //
149 //////////////////////////////////////////////////////////////////////////////
151 class CGrazeFaunaProfile
152 : public CAIFaunaActivityBaseSpawnProfile
155 CGrazeFaunaProfile(CProfileOwner
* owner
);
157 /// @name IAIProfile implementation
159 virtual void beginProfile();
160 virtual void updateProfile(uint ticksSinceLastUpdate
);
161 virtual void endProfile();
162 virtual AITYPES::TProfiles
getAIProfileType() const { return AITYPES::ACTIVITY_GRAZING
; }
163 virtual std::string
getOneLineInfoString() const;
167 CSpawnBotFauna
* _Bot
;
169 CAITimer _CycleTimer
;
170 uint _CycleTimerBaseTime
;
172 double _magnetDistSq
; ///< square distance from bot to his magnet at last move
173 RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags
;
174 static CFaunaProfileFloodLogger _FloodLogger
;
177 //////////////////////////////////////////////////////////////////////////////
178 // CRestFaunaProfile //
179 //////////////////////////////////////////////////////////////////////////////
181 class CRestFaunaProfile
182 : public CAIFaunaActivityBaseSpawnProfile
185 CRestFaunaProfile(CProfileOwner
* owner
);
187 /// @name IAIProfile implementation
189 virtual void beginProfile();
190 virtual void updateProfile(uint ticksSinceLastUpdate
);
191 virtual void endProfile();
192 virtual AITYPES::TProfiles
getAIProfileType() const { return AITYPES::ACTIVITY_RESTING
; }
193 virtual std::string
getOneLineInfoString() const;
197 CSpawnBotFauna
* _Bot
;
199 CAITimer _CycleTimer
;
200 uint _CycleTimerBaseTime
;
202 double _magnetDistSq
; // square distance from bot to his magnet at last move
203 RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags
;
204 static CFaunaProfileFloodLogger _FloodLogger
;
207 //////////////////////////////////////////////////////////////////////////////
208 // CEatCorpseFaunaProfile //
209 //////////////////////////////////////////////////////////////////////////////
211 class CEatCorpseFaunaProfile
212 : public CAIBaseProfile
215 CEatCorpseFaunaProfile(CProfileOwner
* owner
, TDataSetRow
const& corpse
, RYAI_MAP_CRUNCH::TAStarFlag flag
);
217 /// @name IAIProfile implementation
219 virtual void beginProfile();
220 virtual void updateProfile(uint ticksSinceLastUpdate
);
221 virtual void endProfile();
222 virtual AITYPES::TProfiles
getAIProfileType() const { return AITYPES::ACTIVITY_EAT_CORPSE
; }
223 virtual std::string
getOneLineInfoString() const;
228 CSpawnBotFauna
* _Bot
;
232 CPathPosition _PathPos
;
236 //////////////////////////////////////////////////////////////////////////////
237 // CCuriosityFaunaProfile //
238 //////////////////////////////////////////////////////////////////////////////
240 class CCuriosityFaunaProfile
241 : public CAIBaseProfile
244 CCuriosityFaunaProfile(CProfileOwner
* owner
, TDataSetRow
const& player
, RYAI_MAP_CRUNCH::TAStarFlag flag
);
246 /// @name IAIProfile implementation
248 virtual void beginProfile();
249 virtual void updateProfile(uint ticksSinceLastUpdate
);
250 virtual void endProfile();
251 virtual AITYPES::TProfiles
getAIProfileType() const { return AITYPES::ACTIVITY_CURIOSITY
; }
252 virtual std::string
getOneLineInfoString() const;
257 CSpawnBotFauna
* _Bot
;
260 CAITimer _curiosityTimer
;
261 CPathPosition _PathPos
;
263 uint32 _addCuriosityTime
;
265 RYAI_MAP_CRUNCH::TAStarFlag _Flag
;
268 //////////////////////////////////////////////////////////////////////////////
269 // CCorpseFaunaProfile //
270 //////////////////////////////////////////////////////////////////////////////
272 class CCorpseFaunaProfile
273 : public CAIBaseProfile
276 CCorpseFaunaProfile(CProfileOwner
* owner
);
278 virtual void beginProfile();
280 virtual void endProfile() { }
282 virtual void updateProfile(uint ticksSinceLastUpdate
) { }
284 virtual std::string
getOneLineInfoString() const { return NLMISC::toString("corpse fauna profile"); }
286 virtual AITYPES::TProfiles
getAIProfileType() const { return AITYPES::ACTIVITY_CORPSE
; }
288 bool eated() const { return _Eated
; }
289 void setEated(bool eated
) { _Eated
= eated
; }
291 void setEater(bool eater
) { _HaveEater
= eater
; }
292 bool haveEater() const { return _HaveEater
; }
295 CSpawnBotFauna
* _Bot
;
302 /****************************************************************************/
303 /* Profile factories */
304 /****************************************************************************/
306 //- Simple profile factories -------------------------------------------------
308 // CPlanteIdleFaunaProfileFactory
309 typedef CAIGenericProfileFactory
<CPlanteIdleFaunaProfile
> CPlanteIdleFaunaProfileFactory
;
311 // CWanderFaunaProfileFactory
312 typedef CAIGenericProfileFactory
<CWanderFaunaProfile
> CWanderFaunaProfileFactory
;
314 // CGrazeFaunaProfileFactory
315 typedef CAIGenericProfileFactory
<CGrazeFaunaProfile
> CGrazeFaunaProfileFactory
;
317 // CRestFaunaProfileFactory
318 typedef CAIGenericProfileFactory
<CRestFaunaProfile
> CRestFaunaProfileFactory
;
320 // CCorpseFaunaProfileFactory
321 typedef CAIGenericProfileFactory
<CCorpseFaunaProfile
> CCorpseFaunaProfileFactory
;
323 //- Complex profile factories ------------------------------------------------
325 // CStaticFightFaunaProfile
326 class CFightFaunaProfileFactory
327 : public IAIProfileFactory
330 NLMISC::CSmartPtr
<IAIProfile
> createAIProfile(CProfileOwner
* owner
)
336 // CStaticEatCorpseFaunaProfile
337 class CEatCorpseFaunaProfileFactory
338 : public IAIProfileFactory
341 NLMISC::CSmartPtr
<IAIProfile
> createAIProfile(CProfileOwner
* owner
)
350 // CStaticCuriosityFaunaProfile
351 class CCuriosityFaunaProfileFactory
352 : public IAIProfileFactory
355 NLMISC::CSmartPtr
<IAIProfile
> createAIProfile(CProfileOwner
* owner
)
364 //- Profile factories singletons ---------------------------------------------
366 extern CPlanteIdleFaunaProfileFactory PlanteIdleFaunaProfileFactory
;
367 extern CWanderFaunaProfileFactory WanderFaunaProfileFactory
;
368 extern CGrazeFaunaProfileFactory GrazeFaunaProfileFactory
;
369 extern CRestFaunaProfileFactory RestFaunaProfileFactory
;
370 extern CFightFaunaProfileFactory FightFaunaProfileFactory
;
371 extern CCorpseFaunaProfileFactory CorpseFaunaProfileFactory
;
372 extern CEatCorpseFaunaProfileFactory EatCorpseFaunaProfileFactory
;
373 extern CCuriosityFaunaProfileFactory CuriosityFaunaProfileFactory
;