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) 2014 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/>.
27 #include "nel/misc/types_nl.h"
28 #include "nel/misc/smart_ptr.h"
29 #include "nel/misc/sheet_id.h"
32 #include "nel/georges/u_form.h"
33 #include "nel/georges/u_form_elm.h"
35 #include "ai_share/ai_types.h"
36 #include "game_share/fame.h"
38 #include "game_share/visual_slot_manager.h"
40 #include "ai_script_comp.h"
42 #include "game_share/people_pd.h"
45 * Singleton containing database on information for actors
47 * \author Nevrax France
64 //////////////////////////////////////////////////////////////////////////////
66 //////////////////////////////////////////////////////////////////////////////
69 : public NLMISC::CRefCount
70 //, public NLMISC::CDbgRefCount<IAIAction>
73 virtual ~IAIAction() { }
75 virtual NLMISC::CSheetId
SheetId() const = 0;
76 virtual bool SelfAction() const = 0;
78 typedef NLMISC::CSmartPtr
<IAIAction
> IAIActionPtr
;
79 typedef NLMISC::CSmartPtr
<IAIAction
const> IAIActionCPtr
;
86 virtual NLMISC::CSheetId
SheetId() const { return _SheetId
; }
87 virtual bool SelfAction() const { return _SelfAction
; }
90 void readGeorges(NLMISC::CSmartPtr
<NLGEORGES::UForm
> const& form
, NLMISC::CSheetId
const& sheetId
);
91 void serial(NLMISC::IStream
& s
);
93 static uint
getVersion();
95 virtual std::vector
<std::string
> getMultiLineInfoString() const;
98 NLMISC::CSheetId _SheetId
;
101 typedef NLMISC::CSmartPtr
<CAIAction
> CAIActionPtr
;
102 typedef NLMISC::CSmartPtr
<CAIAction
const> CAIActionCPtr
;
104 //////////////////////////////////////////////////////////////////////////////
106 //////////////////////////////////////////////////////////////////////////////
109 : public NLMISC::CDbgRefCount
<CActionList
>
112 virtual ~CActionList() { }
114 NLMISC::CSheetId _SheetId
;
115 std::vector
<IAIActionCPtr
> _Actions
;
117 bool _HasNormalAction
;
120 void computeAbilities();
122 void readGeorges(NLMISC::CSmartPtr
<NLGEORGES::UForm
> const& form
, NLMISC::CSheetId
const& sheetId
);
123 void serial(NLMISC::IStream
& s
);
125 static uint
getVersion();
127 void addAction(NLMISC::CSheetId
const& sheetId
, std::string
const& actionName
);
129 virtual std::vector
<std::string
> getMultiLineInfoString() const;
132 //////////////////////////////////////////////////////////////////////////////
133 // CGroupProperties //
134 //////////////////////////////////////////////////////////////////////////////
136 class CGroupProperties
140 virtual ~CGroupProperties() { }
141 virtual void setAssist(bool assist
) { _Assist
= assist
; }
142 bool assist() const { return _Assist
; }
143 virtual void setAttack(bool attack
) { _Attack
= attack
; }
144 bool attack() const { return _Attack
; }
150 typedef std::vector
<CGroupProperties
> TGroupPropertiesLine
;
152 //////////////////////////////////////////////////////////////////////////////
153 // CDefaultGroupProperties //
154 //////////////////////////////////////////////////////////////////////////////
156 class CDefaultGroupProperties
157 : public CGroupProperties
160 virtual ~CDefaultGroupProperties() { }
161 // avoid modification.
162 virtual void setAssist(bool assist
) { }
163 virtual void setAttack(bool attack
) { }
166 //////////////////////////////////////////////////////////////////////////////
168 //////////////////////////////////////////////////////////////////////////////
171 : public NLMISC::CRefCount
174 typedef std::vector
<NLMISC::CSmartPtr
<CFightScriptComp
> > TScriptCompList
;
177 virtual ~ICreature() { }
180 virtual NLMISC::CSheetId
const& SheetId() const = 0;
181 virtual uint32
Level() const = 0; // Level of the creature
184 virtual uint8
ColorHead() const = 0;
185 virtual uint8
ColorArms() const = 0;
186 virtual uint8
ColorHands() const = 0;
187 virtual uint8
ColorBody() const = 0;
188 virtual uint8
ColorLegs() const = 0;
189 virtual uint8
ColorFeets() const = 0;
191 virtual float Radius() const = 0; // pacs primitive 's radius
192 virtual float Height() const = 0; // pacs primitive 's height
193 virtual float Width() const = 0; // pacs primitive 's width
194 virtual float Length() const = 0; // pacs primitive 's length
195 virtual float BoundingRadius() const = 0; // fighting radius
197 // the entity is a bot object and cannot be traversed.
198 virtual bool NotTraversable() const = 0;
200 // the entity is a fauna, even is used as npc, it keep it's fauna name
201 virtual bool ForceDisplayCreatureName() const = 0;
203 virtual float BonusAggroHungry() const = 0;
204 virtual float BonusAggroVeryHungry() const = 0;
206 virtual float AssistDist() const = 0;
208 virtual float AggroRadiusNotHungry() const = 0;
209 virtual float AggroRadiusHungry() const = 0;
210 virtual float AggroRadiusHunting() const = 0;
212 virtual float AggroReturnDistCheck() const = 0;
213 virtual float AggroRadiusD1() const = 0; // large radius, for first hit place
214 virtual float AggroRadiusD2() const = 0; // small radius, for last hit place
215 virtual float AggroPrimaryGroupDist() const = 0;
216 virtual float AggroPrimaryGroupCoef() const = 0;
217 virtual float AggroSecondaryGroupDist() const = 0;
218 virtual float AggroSecondaryGroupCoef() const = 0;
219 virtual float AggroPropagationRadius() const = 0;
221 virtual AITYPES::TFaunaType
FaunaType() const = 0;
223 virtual float Scale() const = 0; // 3d scale.
225 virtual float DistToFront() const = 0;
226 virtual float DistToBack() const = 0;
227 virtual float DistToSide() const = 0;
229 virtual float DistModulator() const = 0; // = 0.5f; // (0) - (1) - (n).
230 virtual float TargetModulator() const = 0; // = 1.f; // (0) - (1).
231 virtual float ScoreModulator() const = 0; // = 0.01f; // (0) - (-1).
232 virtual float FearModulator() const = 0; // = 0.01f; // (0) - (1).
233 virtual float LifeLevelModulator() const = 0; // = 0.5f; // (0) - (1).
234 virtual float CourageModulator() const = 0; // = 2.f; // (-n) - (0) - (+n)
235 virtual float GroupCohesionModulator() const = 0;
237 virtual float GroupDispersion() const = 0; // 0.f 1.f
239 virtual uint32
XPLevel() const = 0;
240 virtual uint32
NbPlayers() const = 0;
242 virtual uint32
EnergyValue() const = 0;
244 virtual bool CanTurn() const = 0;
246 virtual NLMISC::CDbgPtr
<CActionList
> const& FightConfig(TFightCfg fightCfg
) const = 0;
248 virtual NLMISC::CSheetId
const& LeftItem() const = 0;
249 virtual NLMISC::CSheetId
const& RightItem() const = 0;
251 virtual uint32
MinFightDist() const = 0;
253 virtual uint32
FactionIndex() const = 0;
254 virtual sint32
FameForGuardAttack() const = 0;
256 virtual std::string
const& AssistGroupIndexStr() const = 0;
257 virtual std::string
const& AttackGroupIndexStr() const = 0;
258 virtual std::string
const& GroupIndexStr() const = 0;
260 virtual uint32
GroupPropertiesIndex() const = 0;
262 /// the creature sheet can specify a multiplier that modulate the dynmaic groupe size
263 virtual uint32
DynamicGroupCountMultiplier() const = 0;
265 virtual std::string
const& BotName() const = 0;
267 virtual TScriptCompList
const& ScriptCompList() const = 0;
269 virtual TScriptCompList
const& UpdateScriptList() const = 0;
270 virtual TScriptCompList
const& DeathScriptList() const = 0;
271 virtual TScriptCompList
const& BirthScriptList() const = 0;
274 virtual EGSPD::CPeople::TPeople
Race() const = 0;
276 virtual CGroupProperties
const& getPropertiesCst(uint32 groupIndex
) const = 0;
278 virtual std::vector
<std::string
> getMultiLineInfoString() const = 0;
280 static sint32 InvalidFameForGuardAttack
;
282 typedef NLMISC::CSmartPtr
<ICreature
> ICreaturePtr
;
283 typedef NLMISC::CSmartPtr
<ICreature
const> ICreatureCPtr
;
285 //////////////////////////////////////////////////////////////////////////////
287 //////////////////////////////////////////////////////////////////////////////
293 AISHEETS::ICreatureCPtr _Sheet
;
295 CCreatureProxy(AISHEETS::ICreatureCPtr
const& sheet
)
299 virtual void setSheet(AISHEETS::ICreatureCPtr
const& sheet
) { _Sheet
= sheet
; }
300 virtual bool isValid() const { return _Sheet
!=NULL
; }
303 virtual NLMISC::CSheetId
const& SheetId() const { if (_Sheet
) return _Sheet
->SheetId(); else return NLMISC::CSheetId::Unknown
; }
304 virtual uint32
Level() const { return _Sheet
->Level(); }
306 virtual uint8
ColorHead() const { return _Sheet
->ColorHead(); }
307 virtual uint8
ColorArms() const { return _Sheet
->ColorArms(); }
308 virtual uint8
ColorHands() const { return _Sheet
->ColorHands(); }
309 virtual uint8
ColorBody() const { return _Sheet
->ColorBody(); }
310 virtual uint8
ColorLegs() const { return _Sheet
->ColorLegs(); }
311 virtual uint8
ColorFeets() const { return _Sheet
->ColorFeets(); }
313 virtual float Radius() const { return _Sheet
->Radius(); }
314 virtual float Height() const { return _Sheet
->Height(); }
315 virtual float Width() const { return _Sheet
->Width(); }
316 virtual float Length() const { return _Sheet
->Length(); }
317 virtual float BoundingRadius() const { return _Sheet
->BoundingRadius(); }
319 virtual bool NotTraversable() const { return _Sheet
->NotTraversable(); }
321 virtual bool ForceDisplayCreatureName() const { return _Sheet
->ForceDisplayCreatureName(); }
323 virtual float BonusAggroHungry() const { return _Sheet
->BonusAggroHungry(); }
324 virtual float BonusAggroVeryHungry() const { return _Sheet
->BonusAggroVeryHungry(); }
326 virtual float AssistDist() const { return _Sheet
->AssistDist(); }
328 virtual float AggroRadiusNotHungry() const { return _Sheet
->AggroRadiusNotHungry(); }
329 virtual float AggroRadiusHungry() const { return _Sheet
->AggroRadiusHungry(); }
330 virtual float AggroRadiusHunting() const { return _Sheet
->AggroRadiusHunting(); }
332 virtual float AggroReturnDistCheck() const { return _Sheet
->AggroReturnDistCheck(); }
333 virtual float AggroRadiusD1() const { return _Sheet
->AggroRadiusD1(); }
334 virtual float AggroRadiusD2() const { return _Sheet
->AggroRadiusD2(); }
335 virtual float AggroPrimaryGroupDist() const { return _Sheet
->AggroPrimaryGroupDist(); }
336 virtual float AggroPrimaryGroupCoef() const { return _Sheet
->AggroPrimaryGroupCoef(); }
337 virtual float AggroSecondaryGroupDist() const { return _Sheet
->AggroSecondaryGroupDist(); }
338 virtual float AggroSecondaryGroupCoef() const { return _Sheet
->AggroSecondaryGroupCoef(); }
339 virtual float AggroPropagationRadius() const { return _Sheet
->AggroPropagationRadius(); }
341 virtual AITYPES::TFaunaType
FaunaType() const { return _Sheet
->FaunaType(); }
343 virtual float Scale() const { return _Sheet
->Scale(); }
345 virtual float DistToFront() const { return _Sheet
->DistToFront(); }
346 virtual float DistToBack() const { return _Sheet
->DistToBack(); }
347 virtual float DistToSide() const { return _Sheet
->DistToSide(); }
349 virtual float DistModulator() const { return _Sheet
->DistModulator(); }
350 virtual float TargetModulator() const { return _Sheet
->TargetModulator(); }
351 virtual float ScoreModulator() const { return _Sheet
->ScoreModulator(); }
352 virtual float FearModulator() const { return _Sheet
->FearModulator(); }
353 virtual float LifeLevelModulator() const { return _Sheet
->LifeLevelModulator(); }
354 virtual float CourageModulator() const { return _Sheet
->CourageModulator(); }
355 virtual float GroupCohesionModulator() const { return _Sheet
->GroupCohesionModulator(); }
357 virtual float GroupDispersion() const { return _Sheet
->GroupDispersion(); }
359 virtual uint32
XPLevel() const { return _Sheet
->XPLevel(); }
360 virtual uint32
NbPlayers() const { return _Sheet
->NbPlayers(); }
362 virtual uint32
EnergyValue() const { return _Sheet
->EnergyValue(); }
364 virtual bool CanTurn() const { return _Sheet
->CanTurn(); }
366 virtual NLMISC::CDbgPtr
<CActionList
> const& FightConfig(TFightCfg fightCfg
) const { return _Sheet
->FightConfig(fightCfg
); }
368 virtual NLMISC::CSheetId
const& LeftItem() const { return _Sheet
->LeftItem(); }
369 virtual NLMISC::CSheetId
const& RightItem() const { return _Sheet
->RightItem(); }
371 virtual uint32
MinFightDist() const { return _Sheet
->MinFightDist(); }
373 virtual uint32
FactionIndex() const { return _Sheet
->FactionIndex(); }
374 virtual sint32
FameForGuardAttack() const { return _Sheet
->FameForGuardAttack(); }
376 virtual std::string
const& AssistGroupIndexStr() const { return _Sheet
->AssistGroupIndexStr(); }
377 virtual std::string
const& AttackGroupIndexStr() const { return _Sheet
->AttackGroupIndexStr(); }
378 virtual std::string
const& GroupIndexStr() const { return _Sheet
->GroupIndexStr(); }
380 virtual uint32
GroupPropertiesIndex() const { return _Sheet
->GroupPropertiesIndex(); }
382 virtual uint32
DynamicGroupCountMultiplier() const { return _Sheet
->DynamicGroupCountMultiplier(); }
384 virtual std::string
const& BotName() const { return _Sheet
->BotName(); }
386 virtual TScriptCompList
const& ScriptCompList() const { return _Sheet
->ScriptCompList(); }
388 virtual TScriptCompList
const& UpdateScriptList() const { return _Sheet
->UpdateScriptList(); }
389 virtual TScriptCompList
const& DeathScriptList() const { return _Sheet
->DeathScriptList(); }
390 virtual TScriptCompList
const& BirthScriptList() const { return _Sheet
->BirthScriptList(); }
392 virtual EGSPD::CPeople::TPeople
Race() const { return _Sheet
->Race(); }
394 virtual CGroupProperties
const& getPropertiesCst(uint32 groupIndex
) const { return _Sheet
->getPropertiesCst(groupIndex
); }
396 virtual std::vector
<std::string
> getMultiLineInfoString() const { return _Sheet
->getMultiLineInfoString(); }
399 //////////////////////////////////////////////////////////////////////////////
401 //////////////////////////////////////////////////////////////////////////////
410 NLMISC::CSheetId _SheetId
;
425 float _BoundingRadius
;
427 // the entity is a bot object and cannot be traversed.
428 bool _NotTraversable
;
430 // the entity is a fauna, even is used as npc, it keep it's fauna name
431 bool _ForceDisplayCreatureName
;
433 float _BonusAggroHungry
;
434 float _BonusAggroVeryHungry
;
438 float _AggroRadiusNotHungry
;
439 float _AggroRadiusHungry
;
440 float _AggroRadiusHunting
;
442 float _AggroReturnDistCheck
;
443 float _AggroRadiusD1
;
444 float _AggroRadiusD2
;
445 float _AggroPrimaryGroupDist
;
446 float _AggroPrimaryGroupCoef
;
447 float _AggroSecondaryGroupDist
;
448 float _AggroSecondaryGroupCoef
;
449 float _AggroPropagationRadius
;
451 AITYPES::TFaunaType _FaunaType
;
459 float _DistModulator
;
460 float _TargetModulator
;
461 float _ScoreModulator
;
462 float _FearModulator
;
463 float _LifeLevelModulator
;
464 float _CourageModulator
;
465 float _GroupCohesionModulator
;
467 float _GroupDispersion
;
476 NLMISC::CDbgPtr
<CActionList
> _FightConfig
[FIGHTCFG_MAX
];
478 NLMISC::CSheetId _LeftItem
;
479 NLMISC::CSheetId _RightItem
;
481 uint32 _MinFightDist
;
483 uint32 _FactionIndex
;
484 sint32 _FameForGuardAttack
;
486 std::string _AssistGroupIndexStr
;
487 std::string _AttackGroupIndexStr
;
488 std::string _GroupIndexStr
;
490 uint32 _GroupPropertiesIndex
;
492 /// the creature sheet can specify a multiplier that modulate the dynmaic groupe size
493 uint32 _DynamicGroupCountMultiplier
;
495 std::string _BotName
;
497 TScriptCompList _ScriptCompList
;
499 TScriptCompList _UpdateScriptList
;
500 TScriptCompList _DeathScriptList
;
501 TScriptCompList _BirthScriptList
;
504 EGSPD::CPeople::TPeople _Race
;
507 ///@name ICreature implementation
509 virtual NLMISC::CSheetId
const& SheetId() const { return _SheetId
; }
510 virtual uint32
Level() const { return _Level
; }
513 virtual uint8
ColorHead() const { return _ColorHead
; }
514 virtual uint8
ColorArms() const { return _ColorArms
; }
515 virtual uint8
ColorHands() const { return _ColorHands
; }
516 virtual uint8
ColorBody() const { return _ColorBody
; }
517 virtual uint8
ColorLegs() const { return _ColorLegs
; }
518 virtual uint8
ColorFeets() const { return _ColorFeets
; }
520 virtual float Radius() const { return _Radius
; }
521 virtual float Height() const { return _Height
; }
522 virtual float Width() const { return _Width
; }
523 virtual float Length() const { return _Length
; }
524 virtual float BoundingRadius() const { return _BoundingRadius
; }
526 // the entity is a bot object and cannot be traversed.
527 virtual bool NotTraversable() const { return _NotTraversable
; }
529 // the entity is a fauna, even is used as npc, it keep it's fauna name
530 virtual bool ForceDisplayCreatureName() const { return _ForceDisplayCreatureName
; }
532 virtual float BonusAggroHungry() const { return _BonusAggroHungry
; }
533 virtual float BonusAggroVeryHungry() const { return _BonusAggroVeryHungry
; }
535 virtual float AssistDist() const { return _AssistDist
; }
537 virtual float AggroRadiusNotHungry() const { return _AggroRadiusNotHungry
; }
538 virtual float AggroRadiusHungry() const { return _AggroRadiusHungry
; }
539 virtual float AggroRadiusHunting() const { return _AggroRadiusHunting
; }
541 virtual float AggroReturnDistCheck() const { return _AggroReturnDistCheck
; }
542 virtual float AggroRadiusD1() const { return _AggroRadiusD1
; }
543 virtual float AggroRadiusD2() const { return _AggroRadiusD2
; }
544 virtual float AggroPrimaryGroupDist() const { return _AggroPrimaryGroupDist
; }
545 virtual float AggroPrimaryGroupCoef() const { return _AggroPrimaryGroupCoef
; }
546 virtual float AggroSecondaryGroupDist() const { return _AggroSecondaryGroupDist
; }
547 virtual float AggroSecondaryGroupCoef() const { return _AggroSecondaryGroupCoef
; }
548 virtual float AggroPropagationRadius() const { return _AggroPropagationRadius
; }
550 virtual AITYPES::TFaunaType
FaunaType() const { return _FaunaType
; }
552 virtual float Scale() const { return _Scale
; }
554 virtual float DistToFront() const { return _DistToFront
; }
555 virtual float DistToBack() const { return _DistToBack
; }
556 virtual float DistToSide() const { return _DistToSide
; }
558 virtual float DistModulator() const { return _DistModulator
; }
559 virtual float TargetModulator() const { return _TargetModulator
; }
560 virtual float ScoreModulator() const { return _ScoreModulator
; }
561 virtual float FearModulator() const { return _FearModulator
; }
562 virtual float LifeLevelModulator() const { return _LifeLevelModulator
; }
563 virtual float CourageModulator() const { return _CourageModulator
; }
564 virtual float GroupCohesionModulator() const { return _GroupCohesionModulator
; }
566 virtual float GroupDispersion() const { return _GroupDispersion
; }
568 virtual uint32
XPLevel() const { return _XPLevel
; }
569 virtual uint32
NbPlayers() const { return _NbPlayers
; }
571 virtual uint32
EnergyValue() const { return _EnergyValue
; }
573 virtual bool CanTurn() const { return _CanTurn
; }
575 virtual NLMISC::CDbgPtr
<CActionList
> const& FightConfig(TFightCfg fightCfg
) const { return _FightConfig
[fightCfg
]; }
577 virtual NLMISC::CSheetId
const& LeftItem() const { return _LeftItem
; }
578 virtual NLMISC::CSheetId
const& RightItem() const { return _RightItem
; }
580 virtual uint32
MinFightDist() const { return _MinFightDist
; }
582 virtual uint32
FactionIndex() const { return _FactionIndex
; }
583 virtual sint32
FameForGuardAttack() const { return _FameForGuardAttack
; }
585 virtual std::string
const& AssistGroupIndexStr() const { return _AssistGroupIndexStr
; }
586 virtual std::string
const& AttackGroupIndexStr() const { return _AttackGroupIndexStr
; }
587 virtual std::string
const& GroupIndexStr() const { return _GroupIndexStr
; }
589 virtual uint32
GroupPropertiesIndex() const { return _GroupPropertiesIndex
; }
591 /// the creature sheet can specify a multiplier that modulate the dynmaic groupe size
592 virtual uint32
DynamicGroupCountMultiplier() const { return _DynamicGroupCountMultiplier
; }
594 virtual std::string
const& BotName() const { return _BotName
; }
596 virtual TScriptCompList
const& ScriptCompList() const { return _ScriptCompList
; }
598 virtual TScriptCompList
const& UpdateScriptList() const { return _UpdateScriptList
; }
599 virtual TScriptCompList
const& DeathScriptList() const { return _DeathScriptList
; }
600 virtual TScriptCompList
const& BirthScriptList() const { return _BirthScriptList
; }
602 virtual EGSPD::CPeople::TPeople
Race() const { return _Race
; }
604 virtual CGroupProperties
const& getPropertiesCst(uint32 groupIndex
) const;
606 virtual std::vector
<std::string
> getMultiLineInfoString() const;
610 void readGeorges(NLMISC::CSmartPtr
<NLGEORGES::UForm
> const& form
, NLMISC::CSheetId
const& sheetId
);
611 void serial(NLMISC::IStream
& s
);
613 uint32
minFightDist() const { return MinFightDist(); }
614 void calcFightAndVisualValues(std::string
* left
= NULL
, std::string
* right
= NULL
);
615 void parseFightConfig(NLGEORGES::UForm
const* form
, std::string
const& fightConfigString
, uint32 actionListIndex
, NLMISC::CDbgPtr
<CActionList
>& fightConfig
);
616 void readFightConfig(NLMISC::IStream
& s
, NLMISC::CDbgPtr
<CActionList
>& fightConfig
);
617 void saveFightConfig(NLMISC::IStream
& s
, NLMISC::CDbgPtr
<CActionList
>& fightConfig
);
618 bool mustAssist(CCreature
const& creature
) const;
619 void setAssisGroupIndexs();
620 void setAttackGroupIndexs();
621 void addActionConfig(std::string
const& sheetIdName
, NLMISC::CDbgPtr
<CActionList
>& actionConfigList
);
622 bool addActionConfig(NLMISC::CSheetId
const& sheetId
, NLMISC::CDbgPtr
<CActionList
>& actionConfigList
);
624 void registerScriptComp(CFightScriptComp
* scriptComp
);
626 TGroupPropertiesLine _GroupPropertiesTbl
;
629 CGroupProperties
& getProperties(uint32 groupIndex
);
632 static uint
getVersion();
635 static void getVarListFromParents(NLGEORGES::UForm
const* form
, std::set
<T
>& varList
, std::string
const& varName
);
637 static void getGroupStr(std::vector
<uint32
>& groupIndexStrList
, std::string
const& groupIndexStr
);
639 typedef NLMISC::CSmartPtr
<CCreature
> CCreaturePtr
;
640 typedef NLMISC::CSmartPtr
<CCreature
const> CCreatureCPtr
;
642 //////////////////////////////////////////////////////////////////////////////
644 //////////////////////////////////////////////////////////////////////////////
647 : public NLMISC::CRefCount
650 virtual ~IRaceStats() {}
651 virtual NLMISC::CSheetId
SheetId() const = 0;
652 virtual std::string
Race() const = 0;
654 typedef NLMISC::CSmartPtr
<IRaceStats
> IRaceStatsPtr
;
655 typedef NLMISC::CSmartPtr
<IRaceStats
const> IRaceStatsCPtr
;
661 virtual NLMISC::CSheetId
SheetId() const { return _SheetId
; }
662 virtual std::string
Race() const { return _Race
; }
665 void readGeorges(NLMISC::CSmartPtr
<NLGEORGES::UForm
> const& form
, NLMISC::CSheetId
const& sheetId
);
666 void serial(NLMISC::IStream
& s
);
670 NLMISC::CSheetId _SheetId
;
674 static uint
getVersion();
676 typedef NLMISC::CSmartPtr
<CRaceStats
> CRaceStatsPtr
;
677 typedef NLMISC::CSmartPtr
<CRaceStats
const> CRaceStatsCPtr
;
679 //////////////////////////////////////////////////////////////////////////////
681 //////////////////////////////////////////////////////////////////////////////
686 static CSheets
* _Instance
;
689 static CSheets
* getInstance();
690 static void destroyInstance();
693 // load the creature data from the george files
695 void packSheets(const std::string
&writeFilesDirectoryName
);
697 // display the creature data for all known creature types
698 void display(NLMISC::CSmartPtr
<CStringWriter
> stringWriter
, uint infoSelect
= 0);
703 // get a data record from the database
704 ICreatureCPtr
lookup (NLMISC::CSheetId
const& id
);
705 CActionList
const* lookupActionList(NLMISC::CSheetId
const& id
);
706 IAIActionCPtr
lookupAction (NLMISC::CSheetId
const& id
);
707 IRaceStatsCPtr
lookupRaceStats (NLMISC::CSheetId
const& id
);
709 uint32
getGroupPropertiesIndex(const std::string
&groupIndexName
);
711 uint32
playerGroupIndex() { return _PlayerGroupIndex
; }
714 friend class CCreature
;
717 // prohibit cnstructor as this is a singleton
721 CDefaultGroupProperties _DefaultGroupProp
;
723 std::map
<NLMISC::CSheetId
, CCreaturePtr
> _Sheets
;
724 std::map
<NLMISC::CSheetId
, CActionList
> _ActionListSheets
;
725 std::map
<NLMISC::CSheetId
, CAIActionPtr
> _ActionSheets
;
726 std::map
<NLMISC::CSheetId
, CRaceStatsPtr
> _RaceStatsSheets
;
728 std::map
<std::string
, uint32
> _NameToGroupIndex
;
730 uint32 _PlayerGroupIndex
;
737 /****************************************************************************/
739 /****************************************************************************/
741 //////////////////////////////////////////////////////////////////////////////
743 //////////////////////////////////////////////////////////////////////////////
746 void AISHEETS::CCreature::getVarListFromParents(NLGEORGES::UForm
const* form
, std::set
<T
>& varList
, std::string
const& varName
)
748 uint32 nbParents
= form
->getNumParent ();
752 NLGEORGES::UForm
const* parentForm
= form
->getParentForm(nbParents
);
755 getVarListFromParents(parentForm
, varList
, varName
);
757 NLGEORGES::UFormElm
const& item
= form
->getRootNode();
759 if (item
.getValueByName(temp
, varName
.c_str()))
761 varList
.insert (temp
);