Added ai command setEquipment
[ryzomcore.git] / ryzom / server / src / ai_service / ai_profile_npc.h
blobbd4993662730cd901ae6dfd4aa2b0f2ab411060a
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/>.
19 #ifndef AI_PROFILE_NPC_H
20 #define AI_PROFILE_NPC_H
22 #include "profile.h"
23 #include "ai_bot_npc.h"
24 #include "ai_grp_npc.h"
25 #include "ai_generic_fight.h"
27 extern bool simulateBug(int bugId);
29 // Forard declarations
30 class CSpawnGroupNpc;
32 //////////////////////////////////////////////////////////////////////////////
33 // Free variables and functions //
34 //////////////////////////////////////////////////////////////////////////////
36 extern bool ai_profile_npc_VerboseLog;
38 //////////////////////////////////////////////////////////////////////////////
39 // CBotProfileMoveTo //
40 //////////////////////////////////////////////////////////////////////////////
42 class CBotProfileMoveTo
43 : public CAIBaseProfile
44 , public NLMISC::IDbgPtrData
46 public:
47 CBotProfileMoveTo(AITYPES::TVerticalPos verticalPos, RYAI_MAP_CRUNCH::CWorldPosition const& dest, CProfileOwner* owner);
49 /// @name IAIProfile implementation
50 //@{
51 virtual void beginProfile();
52 virtual void endProfile();
53 virtual void updateProfile(uint ticksSinceLastUpdate);
54 virtual AITYPES::TProfiles getAIProfileType () const { return AITYPES::BOT_MOVE_TO; }
55 virtual std::string getOneLineInfoString() const;
56 //@}
58 bool destinationReach() const;
60 CFollowPath::TFollowStatus _Status;
61 AITYPES::TVerticalPos _VerticalPos;
62 RYAI_MAP_CRUNCH::CWorldPosition _Dest;
63 CPathCont _PathCont;
64 CPathPosition _PathPos;
65 CAIVector _LastPos;
67 protected:
68 NLMISC::CDbgPtr<CSpawnBotNpc> _Bot;
71 //////////////////////////////////////////////////////////////////////////////
72 // CBotProfileFollowPos //
73 //////////////////////////////////////////////////////////////////////////////
75 class CBotProfileFollowPos
76 : public CAIBaseProfile
77 , public NLMISC::IDbgPtrData
79 public:
80 CBotProfileFollowPos(CPathCont* pathCont, CProfileOwner* owner);
81 CBotProfileFollowPos(CBotProfileFollowPos const& other);
83 /// @name IAIProfile implementation
84 //@{
85 virtual void beginProfile();
86 virtual void endProfile();
87 virtual void updateProfile(uint ticksSinceLastUpdate);
88 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::BOT_FOLLOW_POS; }
89 virtual std::string getOneLineInfoString() const;
90 //@}
92 void setMaxSpeeds(float walkSpeed, float runSpeed);
93 void setStop(bool stop);
95 CFollowPath::TFollowStatus _Status;
96 CPathPosition _PathPos;
98 protected:
99 NLMISC::CDbgPtr<CSpawnBotNpc> _Bot;
101 private:
102 NLMISC::CDbgPtr<CPathCont> _PathCont;
104 // maximum speed to use (for group with different creatures)
105 float _MaxWalkSpeed;
106 float _MaxRunSpeed;
108 // flag to stop temporary stop the movement
109 bool _Stop;
112 //////////////////////////////////////////////////////////////////////////////
113 // CBotProfileWanderBase //
114 //////////////////////////////////////////////////////////////////////////////
116 class CBotProfileWanderBase
117 : public CAIBaseProfile
119 public:
120 CBotProfileWanderBase();
122 void setTimer(uint32 ticks);
123 bool testTimer() const;
125 protected:
126 CAITimer _Timer;
129 //////////////////////////////////////////////////////////////////////////////
130 // CBotProfileStandAtPos //
131 //////////////////////////////////////////////////////////////////////////////
133 class CBotProfileStandAtPos
134 : public CBotProfileWanderBase
135 , public NLMISC::IDbgPtrData
137 public:
138 CBotProfileStandAtPos(CProfileOwner* owner);
140 /// @name IAIProfile implementation
141 //@{
142 virtual void beginProfile();
143 virtual void endProfile();
144 virtual void updateProfile(uint ticksSinceLastUpdate);
145 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::BOT_STAND_AT_POS; }
146 virtual std::string getOneLineInfoString() const;
147 //@}
149 protected:
150 NLMISC::CDbgPtr<CSpawnBotNpc> _Bot;
153 //////////////////////////////////////////////////////////////////////////////
154 // CBotProfileForage //
155 //////////////////////////////////////////////////////////////////////////////
157 class CBotProfileForage
158 : public CBotProfileWanderBase
159 , public NLMISC::IDbgPtrData
161 public:
162 CBotProfileForage(CProfileOwner* owner);
163 virtual ~CBotProfileForage();
165 /// @name IAIProfile implementation
166 //@{
167 virtual void beginProfile();
168 virtual void endProfile();
169 virtual void updateProfile(uint ticksSinceLastUpdate);
170 virtual AITYPES::TProfiles getAIProfileType () const { return AITYPES::BOT_FORAGE; }
171 virtual std::string getOneLineInfoString() const;
172 //@}
174 void setOldSheet();
176 protected:
177 NLMISC::CDbgPtr<CSpawnBotNpc> _Bot;
179 CAITimer _ForageTimer;
180 AISHEETS::ICreatureCPtr _OldSheet;
181 bool _TemporarySheetUsed;
184 //////////////////////////////////////////////////////////////////////////////
185 // CActivityProfile //
186 //////////////////////////////////////////////////////////////////////////////
188 class CActivityProfile
189 : public CAIBaseProfile
193 //////////////////////////////////////////////////////////////////////////////
194 // CGrpProfileNormal //
195 //////////////////////////////////////////////////////////////////////////////
197 class CGrpProfileNormal
198 : public CActivityProfile
200 public:
201 CGrpProfileNormal(CProfileOwner* owner);
203 /// @name IAIProfile implementation
204 //@{
205 virtual void beginProfile();
206 virtual void endProfile();
207 virtual void updateProfile(uint ticksSinceLastUpdate);
208 virtual AITYPES::TProfiles getAIProfileType () const { return AITYPES::ACTIVITY_NORMAL; }
209 virtual std::string getOneLineInfoString() const;
210 //@}
212 bool isGroupFighting() const;
213 void setGroupFighting(bool groupFighting);
215 protected:
216 NLMISC::CDbgPtr<CSpawnGroupNpc> _Grp;
217 bool _GroupFighting;
220 //////////////////////////////////////////////////////////////////////////////
221 // CSlaveProfile //
222 //////////////////////////////////////////////////////////////////////////////
223 // :TODO: Understand following comment, and act accordingly
224 // every bot add or remove must be done from a spawn/despawn/die event (and not this way!)
226 class CSlaveProfile
227 : public CAIBaseProfile
229 public:
230 CSlaveProfile(CProfileOwner* owner);
232 /// @name IAIProfile partial implementation
233 //@{
234 virtual void beginProfile();
235 virtual void updateProfile(uint ticksSinceLastUpdate);
236 //@}
238 virtual void addBot(CBot* bot) = 0;
239 virtual void removeBot(CBot* bot) = 0;
241 protected:
242 NLMISC::CDbgPtr<CSpawnGroup> _Grp;
245 //////////////////////////////////////////////////////////////////////////////
246 // CMoveProfile //
247 //////////////////////////////////////////////////////////////////////////////
249 class CMoveProfile
250 : public CSlaveProfile
252 public:
253 CMoveProfile(CProfileOwner* owner) ;
255 virtual CPathCont* getPathCont(CBot const* bot) = 0;
257 virtual void resumeBot(CBot const* bot);
259 protected:
260 float _MaxRunSpeed;
261 float _MaxWalkSpeed;
264 //////////////////////////////////////////////////////////////////////////////
265 // CFightProfile //
266 //////////////////////////////////////////////////////////////////////////////
268 class CFightProfile
269 : public CSlaveProfile
271 public:
272 CFightProfile(CProfileOwner* owner);
274 virtual std::vector<CBot*>& npcList() = 0;
275 virtual bool stillHaveEnnemy() const = 0;
278 //////////////////////////////////////////////////////////////////////////////
279 // CGrpProfileGoToPoint //
280 //////////////////////////////////////////////////////////////////////////////
282 class CGrpProfileGoToPoint
283 : public CMoveProfile
285 public:
286 /// @name Constructors, destructor
287 //@{
288 CGrpProfileGoToPoint(CProfileOwner* owner, RYAI_MAP_CRUNCH::CWorldPosition const& startPos, RYAI_MAP_CRUNCH::CWorldPosition const& endPos, bool dontSendEvent = false);
289 virtual ~CGrpProfileGoToPoint();
290 //@}
292 enum TShapeType
294 SHAPE_NOTHING,
295 SHAPE_RECTANGLE,
297 class CBotFollower
299 public:
300 CBotFollower();
301 virtual ~CBotFollower();
302 void setBotAtDest(bool atDest = true);
303 const bool& isBotAtDest() const;
305 private:
306 bool _BotAtDest;
309 /// @name CMoveProfile implementation
310 //@{
311 virtual CPathCont* getPathCont(CBot const* bot);
312 //@}
314 /// @name CSlaveProfile implementation
315 //@{
316 virtual void addBot(CBot* bot);
317 virtual void removeBot(CBot* bot);
318 //@}
320 /// @name IAIProfile implementation
321 //@{
322 virtual void beginProfile();
323 virtual void updateProfile(uint ticksSinceLastUpdate);
324 virtual void endProfile();
325 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::MOVE_GOTO_POINT; }
326 virtual std::string getOneLineInfoString() const;
327 virtual void stateChangeProfile();
328 virtual void resumeProfile();
329 //@}
331 bool profileTerminated() const;
333 protected:
334 void setDirection(bool forward);
335 bool getDirection();
338 void setCurrentDestination(RYAI_MAP_CRUNCH::CWorldPosition const& dest);
340 void calcRatios();
342 void stopNpc(bool stop);
344 private:
345 void assignGeometryFromState();
347 typedef std::map<CBot*, CBotFollower> TBotFollowerMap;
348 TBotFollowerMap _NpcList;
350 bool _ValidPosInit;
351 bool _FollowForward;
352 bool _ProfileTerminated;
353 bool _MustCalcRatios;
354 TShapeType _Shape;
355 RYAI_MAP_CRUNCH::CWorldPosition _StartPos;
356 RYAI_MAP_CRUNCH::CWorldPosition _EndPos;
358 /// flag to temporary stop the bots
359 bool _StopNpc;
361 // rectangle shape related vars.
362 float _XSize;
363 float _YSize;
364 float _Ratio;
365 double _Cx, _Cy;
366 uint32 _NbRange;
367 uint32 _NbLines;
368 uint32 _NbBotInNormalShape;
369 uint32 _Rest;
371 uint32 _GeomIndex;
372 CPathCont _PathCont;
373 CAIVector _GlobalOrient;
375 AITYPES::TVerticalPos _VerticalPos;
376 bool _DontSendEvent;
379 //////////////////////////////////////////////////////////////////////////////
380 // CGrpProfileFollowRoute //
381 //////////////////////////////////////////////////////////////////////////////
383 class CGrpProfileFollowRoute
384 : public CMoveProfile
386 public:
387 CGrpProfileFollowRoute(CProfileOwner* owner, std::vector<CShape::TPosition> const& geometry, AITYPES::TVerticalPos const& verticalPos, bool dontSendEvent = false);
388 CGrpProfileFollowRoute(CProfileOwner* owner);
390 virtual ~CGrpProfileFollowRoute();
392 enum TShapeType
394 SHAPE_NOTHING,
395 SHAPE_RECTANGLE,
398 class CBotFollower
400 public:
401 CBotFollower();
402 virtual ~CBotFollower();
403 void setBotAtDest(bool atDest = true);
404 const bool& isBotAtDest() const;
406 private:
407 bool _BotAtDest;
410 void setDirection(bool forward);
411 bool getDirection();
413 void resumeProfile();
415 CPathCont* getPathCont(CBot const* bot);
417 void addBot(CBot* bot);
418 void removeBot(CBot* bot);
420 /// @name IAIProfile implementation
421 //@{
422 virtual void beginProfile();
423 virtual void updateProfile(uint ticksSinceLastUpdate);
424 virtual void endProfile();
425 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::MOVE_FOLLOW_ROUTE; }
426 virtual std::string getOneLineInfoString() const;
427 //@}
429 bool profileTerminated() const;
431 void setCurrentValidPos(AITYPES::TVerticalPos verticalPos);
433 void calcRatios();
435 virtual void stateChangeProfile();
437 void stopNpc(bool stop);
439 private:
440 void assignGeometryFromState();
442 typedef std::map<CBot*, CBotFollower> TBotFollowerMap;
443 TBotFollowerMap _NpcList;
445 bool _ValidPosInit;
446 bool _FollowForward;
447 bool _ProfileTerminated;
448 bool _MustCalcRatios;
449 TShapeType _Shape;
451 /// flag to temporary stop the bots
452 bool _StopNpc;
454 // rectangle shape related vars.
455 float _XSize;
456 float _YSize;
457 float _Ratio;
458 double _Cx, _Cy;
459 uint32 _NbRange;
460 uint32 _NbLines;
461 uint32 _NbBotInNormalShape;
462 uint32 _Rest;
464 uint32 _GeomIndex;
465 CPathCont _PathCont;
466 CAIVector _GlobalOrient;
468 bool _GeometryComeFromState;
469 std::vector<CShape::TPosition> const* _Geometry;
470 AITYPES::TVerticalPos _VerticalPos;
471 bool _DontSendEvent;
474 //////////////////////////////////////////////////////////////////////////////
475 // CGrpProfileStandOnVertices //
476 //////////////////////////////////////////////////////////////////////////////
478 class CGrpProfileStandOnVertices
479 : public CMoveProfile
481 public:
482 // utility class
483 class CBotPositionner : public NLMISC::CRefCount
485 public:
486 CBotPositionner(RYAI_MAP_CRUNCH::TAStarFlag flags);
487 CBotPositionner(uint32 geomIndex, RYAI_MAP_CRUNCH::TAStarFlag flags);
488 void setBotAtDest(bool atDest = true);
489 bool isBotAtDest() const;
491 CPathCont _PathCont;
492 uint32 _GeomIndex;
493 private:
494 bool _BotAtDest;
497 CGrpProfileStandOnVertices(CProfileOwner* owner);
498 ~CGrpProfileStandOnVertices();
500 CPathCont *getPathCont (const CBot *bot);
502 /// @name IAIProfile implementation
503 //@{
504 virtual void beginProfile();
505 virtual void updateProfile(uint ticksSinceLastUpdate);
506 virtual void endProfile();
507 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::MOVE_STAND_ON_VERTICES; }
508 virtual std::string getOneLineInfoString() const;
509 //@}
510 void resumeProfile();
512 void setCurrentValidPos (CAIStatePositional *grpState);
514 void addBot(CBot* bot);
515 void removeBot(CBot* bot);
517 private:
518 typedef std::map<const CBot*,NLMISC::CSmartPtr<CBotPositionner> > TNpcBotPositionnerMap;
519 TNpcBotPositionnerMap _NpcList;
520 bool _Finished;
521 RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
524 //////////////////////////////////////////////////////////////////////////////
525 // CGrpProfileWander //
526 //////////////////////////////////////////////////////////////////////////////
528 class CGrpProfileWander
529 : public CMoveProfile
531 public:
532 CGrpProfileWander(CProfileOwner* owner);
533 CGrpProfileWander(CProfileOwner* owner, CNpcZone const* const npcZone);
534 virtual ~CGrpProfileWander();
536 void setBotStandProfile(AITYPES::TProfiles botStandProfileType, IAIProfileFactory* botStandProfileFactory);
538 /// @name IAIProfile implementation
539 //@{
540 virtual void beginProfile();
541 virtual void updateProfile(uint ticksSinceLastUpdate);
542 virtual void endProfile();
543 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::MOVE_WANDER; }
544 virtual std::string getOneLineInfoString() const;
545 //@}
547 void addBot (CBot* bot);
548 void removeBot (CBot* bot);
549 CPathCont* getPathCont (CBot const* bot);
551 void stateChangeProfile();
553 void affectZoneFromStateMachine();
554 void resetDestinationReachedData();
556 void setTimer(uint32 ticks) { _Timer.set(ticks); }
557 bool testTimer() const { return _Timer.test(); }
559 CNpcZone const* currentZone() const { return _NpcZone; }
561 private:
563 /// the profile type to apply to bot standing between two deplacement
564 AITYPES::TProfiles _BotStandProfileType;
565 /// the profile factory to apply to bot standing between two deplacement
566 IAIProfileFactory*_BotStandProfileFactory;
567 /// a flag to force social interaction for the bots
568 bool _Social;
570 NLMISC::CstCDbgPtr<CPlaceRandomPos> _RandomPos;
571 NLMISC::CSmartPtr<const CNpcZone> _NpcZone;
572 std::vector<bool> _NpcDestinationReached;
573 bool _DestinationReachedAll;
574 bool _DestinationReachedFirst;
576 CAITimer _Timer;
579 //////////////////////////////////////////////////////////////////////////////
580 // CGrpProfileWanderNoPrim //
581 //////////////////////////////////////////////////////////////////////////////
583 /// This profile shouldn't require data primitive for wander zone
584 class CGrpProfileWanderNoPrim
585 : public CMoveProfile
587 public:
588 // CGrpProfileWanderNoPrim(CProfileOwner* owner);
589 CGrpProfileWanderNoPrim(CProfileOwner* owner, NLMISC::CSmartPtr<CNpcZonePlaceNoPrim> const& npcZone);
590 virtual ~CGrpProfileWanderNoPrim();
592 void setBotStandProfile(AITYPES::TProfiles botStandProfileType, IAIProfileFactory* botStandProfileFactory);
594 /// @name IAIProfile implementation
595 //@{
596 virtual void beginProfile();
597 virtual void updateProfile(uint ticksSinceLastUpdate);
598 virtual void endProfile();
599 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::MOVE_WANDER; }
600 virtual std::string getOneLineInfoString() const;
601 //@}
603 void addBot (CBot* bot);
604 void removeBot (CBot* bot);
605 CPathCont* getPathCont (CBot const* bot);
607 void stateChangeProfile();
609 // void affectZoneFromStateMachine();
611 void setTimer(uint32 ticks) { _Timer.set(ticks); }
612 bool testTimer() const { return _Timer.test(); }
614 // CNpcZone const* currentZone() const { return _NpcZone; }
616 private:
618 /// the profile type to apply to bot standing between two deplacement
619 AITYPES::TProfiles _BotStandProfileType;
620 /// the profile factory to apply to bot standing between two deplacement
621 IAIProfileFactory*_BotStandProfileFactory;
622 /// a flag to force social interaction for the bots
623 bool _Social;
625 // NLMISC::CstCDbgPtr<CPlaceRandomPos> _RandomPos;
626 NLMISC::CSmartPtr<CNpcZonePlaceNoPrim> _NpcZone;
628 CAITimer _Timer;
631 class CGrpProfileFollowPlayer :
632 public CMoveProfile
634 public:
635 CGrpProfileFollowPlayer(CProfileOwner* owner, TDataSetRow const& playerRow, uint32 dispersionRadius);
636 virtual ~CGrpProfileFollowPlayer() {}
638 void setBotStandProfile(AITYPES::TProfiles botStandProfileType, IAIProfileFactory* botStandProfileFactory);
640 /// @name IAIProfile implementation
641 //@{
642 virtual void beginProfile();
643 virtual void updateProfile(uint ticksSinceLastUpdate);
644 virtual void endProfile() {}
645 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::BOT_FOLLOW_POS; }
646 virtual std::string getOneLineInfoString() const { return std::string("follow_player group profile"); }
647 //@}
649 void stateChangeProfile() {}
650 bool destinationReach() const;
652 void addBot (CBot* bot) {}
653 void removeBot (CBot* bot) {}
654 CPathCont* getPathCont (CBot const* bot) { return NULL; };
657 protected:
658 private:
659 /// the profile type to apply to bot standing between two deplacement
660 AITYPES::TProfiles _BotStandProfileType;
661 /// the profile factory to apply to bot standing between two deplacement
662 IAIProfileFactory*_BotStandProfileFactory;
664 CFollowPath::TFollowStatus _Status;
665 CPathPosition _PathPos;
666 CPathCont _PathCont;
667 CAIVector _LastPos;
669 TDataSetRow _PlayerRow;
670 uint32 _DispersionRadius;
674 //////////////////////////////////////////////////////////////////////////////
675 // CGrpProfileIdle //
676 //////////////////////////////////////////////////////////////////////////////
678 class CGrpProfileIdle
679 : public CMoveProfile
681 public:
682 CGrpProfileIdle(CProfileOwner* owner);
683 virtual ~CGrpProfileIdle();
685 class CBotPositionner
687 public:
688 CBotPositionner();
689 virtual ~CBotPositionner();
692 CPathCont* getPathCont(CBot const* bot);
693 virtual void beginProfile();
694 void resumeProfile();
695 virtual void endProfile();
696 virtual void updateProfile(uint ticksSinceLastUpdate);
698 void addBot(CBot* bot);
699 void removeBot(CBot* bot);
701 virtual std::string getOneLineInfoString() const;
702 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::MOVE_IDLE; }
704 private:
705 typedef std::map<CBot*,CBotPositionner> TNpcBotPositionnerMap;
706 TNpcBotPositionnerMap _NpcList;
709 //////////////////////////////////////////////////////////////////////////////
710 // CGrpProfileBandit //
711 //////////////////////////////////////////////////////////////////////////////
713 class CGrpProfileBandit
714 : public CGrpProfileNormal
716 public:
717 CGrpProfileBandit(CProfileOwner* owner);
718 virtual ~CGrpProfileBandit();
720 /// @name IAIProfile implementation
721 //@{
722 virtual void beginProfile();
723 virtual void updateProfile(uint ticksSinceLastUpdate);
724 virtual void endProfile();
725 virtual AITYPES::TProfiles getAIProfileType () const { return AITYPES::ACTIVITY_BANDIT; }
726 virtual std::string getOneLineInfoString() const;
727 //@}
729 private:
730 uint32 _AggroRange;
733 //////////////////////////////////////////////////////////////////////////////
734 // CGrpProfileEscorted //
735 //////////////////////////////////////////////////////////////////////////////
737 class CGrpProfileEscorted
738 : public CGrpProfileNormal
740 public:
741 CGrpProfileEscorted(CProfileOwner* owner);
742 virtual ~CGrpProfileEscorted();
744 /// @name IAIProfile implementation
745 //@{
746 virtual void beginProfile();
747 virtual void updateProfile(uint ticksSinceLastUpdate);
748 virtual void endProfile();
749 virtual AITYPES::TProfiles getAIProfileType () const { return AITYPES::ACTIVITY_ESCORTED; }
750 virtual std::string getOneLineInfoString() const;
751 //@}
753 void stateChangeProfile();
755 protected:
756 bool _EscortTeamInRange;
759 //////////////////////////////////////////////////////////////////////////////
760 // CGrpProfileGuard //
761 //////////////////////////////////////////////////////////////////////////////
763 class CGrpProfileGuard
764 : public CGrpProfileNormal
766 public:
767 CGrpProfileGuard(CProfileOwner* owner);
768 virtual ~CGrpProfileGuard();
770 /// @name IAIProfile implementation
771 //@{
772 virtual void beginProfile();
773 virtual void updateProfile(uint ticksSinceLastUpdate);
774 virtual void endProfile();
775 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::ACTIVITY_GUARD; }
776 virtual std::string getOneLineInfoString() const;
777 //@}
779 private:
780 CAIVector _CenterPos;
781 uint32 _AggroRange;
784 //////////////////////////////////////////////////////////////////////////////
785 // CGrpProfileGuardEscorted //
786 //////////////////////////////////////////////////////////////////////////////
788 class CGrpProfileGuardEscorted
789 : public CGrpProfileNormal
791 public:
792 CGrpProfileGuardEscorted(CProfileOwner* owner);
793 virtual ~CGrpProfileGuardEscorted();
795 /// @name IAIProfile implementation
796 //@{
797 virtual void beginProfile();
798 virtual void updateProfile(uint ticksSinceLastUpdate);
799 virtual void endProfile();
800 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::ACTIVITY_GUARD_ESCORTED; }
801 virtual std::string getOneLineInfoString() const;
802 //@}
804 void stateChangeProfile();
806 protected:
807 NLMISC::CSmartPtr<CGrpProfileGuard> _GuardProfile;
808 NLMISC::CSmartPtr<CGrpProfileEscorted> _EscortedProfile;
811 //////////////////////////////////////////////////////////////////////////////
812 // CGrpProfileFaction //
813 //////////////////////////////////////////////////////////////////////////////
815 class CGrpProfileFaction
816 : public CGrpProfileNormal
818 public:
819 CGrpProfileFaction(CProfileOwner* owner);
820 virtual ~CGrpProfileFaction();
822 /// @name IAIProfile implementation
823 //@{
824 virtual void beginProfile();
825 virtual void updateProfile(uint ticksSinceLastUpdate);
826 virtual void endProfile();
827 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::ACTIVITY_FACTION; }
828 virtual std::string getOneLineInfoString() const;
829 //@}
831 virtual void aggroEntity(CAIEntityPhysical const* entity);
832 void checkTargetsAround();
833 void noAssist() { bNoAssist = true; }
835 static std::string scriptFactionToFameFaction(std::string name);
836 static std::string fameFactionToScriptFaction(std::string name);
838 static bool scriptFactionToFameFactionGreaterThan(std::string name);
839 static sint32 scriptFactionToFameFactionValue(std::string name);
842 private:
843 CAITimer _checkTargetTimer;
844 bool bNoAssist;
846 private:
847 static AITYPES::CPropertySet _FameFactions;
848 static void initFameFactions();
849 static bool entityHavePartOfFactions(CAIEntityPhysical const* entity, AITYPES::CPropertySetWithExtraList<TAllianceId> const& factions);
852 //////////////////////////////////////////////////////////////////////////////
853 // CGrpProfileSquad //
854 // The Manager Parent of the Manager of this Grp class is COutpost //
855 //////////////////////////////////////////////////////////////////////////////
857 class CGrpProfileSquad
858 : public CGrpProfileFaction
860 public:
861 CGrpProfileSquad(CProfileOwner* owner);
862 virtual ~CGrpProfileSquad();
864 /// @name IAIProfile implementation
865 //@{
866 virtual void beginProfile();
867 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::ACTIVITY_SQUAD; }
868 virtual std::string getOneLineInfoString() const;
869 //@}
871 virtual void aggroEntity(CAIEntityPhysical const* entity);
873 NLMISC::CSmartPtr<CAIPlace const> buildFirstHitPlace(TDataSetRow const& aggroBot);
875 protected:
877 /// Return the outpost to which the squad belongs, or NULL if not found
878 COutpost* getDefendedOutpost() { return dynamic_cast<COutpost*>(_Grp->getPersistent().getOwner()->getOwner()); }
881 //////////////////////////////////////////////////////////////////////////////
882 // CGrpProfileFight //
883 //////////////////////////////////////////////////////////////////////////////
885 class CGrpProfileFight
886 : public CFightProfile
887 , public CFightOrganizer
889 // TODO : set this parameters thrue the group, no hardcode them
890 enum
893 CHECK_AROUND_PERIOD = 50, ///< Check every 5s
894 CHECK_AROUND_RADIUS = 60, ///< Check 60 meters around
896 public:
897 CGrpProfileFight(CProfileOwner *owner);
898 virtual ~CGrpProfileFight();
900 virtual void beginProfile();
901 void endProfile();
903 void addBot (CBot *bot);
904 void removeBot (CBot *bot);
906 //////////////////////////////////////////////////////////////////////////
907 /// @name CFightOrganizer
908 //@{
909 virtual void setFight(CSpawnBot* bot, CAIEntityPhysical* ennemy);
910 virtual void setHeal(CSpawnBot* bot, CAIEntityPhysical* target);
911 virtual void setNoFight(CSpawnBot* bot);
912 virtual void setFlee(CSpawnBot* bot, CAIVector& fleeVect);
913 virtual void setReturnAfterFight(CSpawnBot* bot);
914 //@}
916 bool stillHaveEnnemy () const;
918 virtual void updateProfile(uint ticksSinceLastUpdate);
920 virtual std::string getOneLineInfoString() const;
922 virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::FIGHT_NORMAL; }
924 std::vector<CBot*> &npcList();
926 private:
927 std::vector<CBot*> _NpcList;
928 /// A timer to check the friend groups around and set their aggro list if they are not fighting
929 CAITimer _CheckAround;
930 bool _WasRunning;
933 /****************************************************************************/
934 /* Profile factories */
935 /****************************************************************************/
937 //- Simple profile factories (based on generic factory) ----------------------
939 // CBotProfileStandAtPos
940 typedef CAIGenericProfileFactory<CBotProfileStandAtPos> CBotProfileStandAtPosFactory;
942 // CBotProfileForage
943 typedef CAIGenericProfileFactory<CBotProfileForage> CBotProfileForageFactory;
945 // CGrpProfileNormal
946 typedef CAIGenericProfileFactory<CGrpProfileNormal> CGrpProfileNormalFactory;
948 // CGrpProfileFollowRoute
949 typedef CAIGenericProfileFactory<CGrpProfileFollowRoute> CGrpProfileFollowRouteFactory;
951 // CGrpProfileWander
952 typedef CAIGenericProfileFactory<CGrpProfileWander> CGrpProfileWanderFactory;
954 // CGrpProfileGuardFactory
955 typedef CAIGenericProfileFactory<CGrpProfileGuard> CGrpProfileGuardFactory;
957 // CGrpProfileEscortedFactory
958 typedef CAIGenericProfileFactory<CGrpProfileEscorted> CGrpProfileEscortedFactory;
960 // CGrpProfileGuardEscortedFactory
961 typedef CAIGenericProfileFactory<CGrpProfileGuardEscorted> CGrpProfileGuardEscortedFactory;
963 // CGrpProfileFactionFactory
964 typedef CAIGenericProfileFactory<CGrpProfileFaction> CGrpProfileFactionFactory;
966 // CGrpProfileSquadFactory
967 typedef CAIGenericProfileFactory<CGrpProfileSquad> CGrpProfileSquadFactory;
969 // CGrpProfileStandOnVerticesFactory
970 typedef CAIGenericProfileFactory<CGrpProfileStandOnVertices> CGrpProfileStandOnVerticesFactory;
972 //////////////////////////////////////////////////////////////////////////////
973 // CGrpProfileNoChange //
974 //////////////////////////////////////////////////////////////////////////////
976 /// No change special profile
977 class CGrpProfileNoChangeFactory
978 : public IAIProfileFactory
980 public:
981 NLMISC::CSmartPtr<IAIProfile> createAIProfile(CProfileOwner* owner)
983 return NULL;
986 RYAI_DECLARE_PROFILE_FACTORY(CGrpProfileNoChangeFactory);
988 //////////////////////////////////////////////////////////////////////////////
989 // CGrpProfileBanditFactory //
990 //////////////////////////////////////////////////////////////////////////////
992 class CGrpProfileBanditFactory
993 : public IAIProfileFactory
995 public:
996 NLMISC::CSmartPtr<IAIProfile> createAIProfile(CProfileOwner* owner);
997 static float getDefaultBanditAggroRange();
998 private:
999 static float _DefaultAggroRange;
1002 //- Singleton profiles (stateless ones) --------------------------------------
1004 extern CBotProfileStandAtPosFactory BotProfileStandAtPosFactory;
1005 extern CBotProfileForageFactory BotProfileForageFactory;
1007 #endif