@ -28,7 +28,7 @@
# include "ai_generic_fight.h"
class CGrpFauna ;
class CGrpFauna ;
class CSpawnGroupFauna ;
# define GROUP_VISION_UPDATE_RADIUS (80)
@ -53,14 +53,14 @@ public:
StateWandering ,
StateResting
} ;
public :
CSpawnGroupFauna ( CPersistent < CSpawnGroup > & owner , RYAI_MAP_CRUNCH : : TAStarFlag denyFlag ) ;
bool isSpawning ( ) ;
void update ( ) ;
/// @name CFightOrganizer implementation
//@{
virtual void setFight ( CSpawnBot * bot , CAIEntityPhysical * ennemy ) ;
@ -69,84 +69,85 @@ public:
virtual void setFlee ( CSpawnBot * bot , CAIVector & fleeVect ) ;
virtual void setReturnAfterFight ( CSpawnBot * bot ) ;
//@}
virtual void spawnBots ( ) ;
virtual void spawnBots ( const std : : string & name ) ;
virtual void despawnBots ( bool immediately ) ;
// overrides the init to avoid automatic bot spawn ..
void spawnBotOfGroup ( ) { }
virtual void despawnGrp ( ) ; // critical code (despawn 'this' object).
uint32 getLastUpdate ( ) const { return _LastUpdate ; }
// Update Rate feature.
int getUpdatePriority ( ) const { return IsRingShard ? ( _UpdatePriority & 7 ) : _UpdatePriority ; }
// overloading to recalc the priority update rate.
void recalcUpdatePriorityDeltaAndGroupPos ( ) ;
CAIPos const & magnetPos ( ) const ;
float magnetRadiusNear ( ) const ;
float magnetRadiusFar ( ) const ;
void resetTimer ( ) { _Timer . set ( 0 ) ; }
CGrpFauna & getPersistent ( ) ;
// std::string buildDebugString(uint idx) const;
void setPlace ( int placeIndex ) ;
void incCurrentCycle ( ) ;
void setCurrentCycle ( uint32 cycle ) ;
uint32 getCurrentCycleTime ( ) ;
CAIPlace * targetPlace ( ) const { return _TargetPlace ; }
CPathCont & getPathCont ( ) { return _PathCont ; }
CBotFauna * leader ( ) const { return _Leader ; }
void setDespawnImmediately ( bool immediately ) { _DespawnImmediately = immediately ; }
bool despawnImmediately ( ) { return _DespawnImmediately ; }
void setMustDespawnBots ( bool toDespawnBots = true ) { _MustDespawnBots = toDespawnBots ; }
bool mustDespawnBots ( ) { return _MustDespawnBots ; }
private :
uint32 getDt ( ) const { return _DeltaTime ; }
CBotFauna * findLeader ( ) ;
CBotFauna * findLeader ( ) ;
// Behavior update method.
void generalUpdate ( TState state = StateUndefined ) ;
// Update method for different states.
void updateSpawning ( ) ;
void updateActivity ( AITYPES : : TProfiles activity ) ;
void checkTimers ( ) ; // called at each update to see if the last timer delay has expired (if true calls updateCycles)
private :
CPathCont _PathCont ;
NLMISC : : CDbgPtr < CAIPlace > _TargetPlace ; // a dynamic pointer to one of the above places
bool _ArrivedInZone ; // indicates that we have not reach the new zone
NLMISC : : CDbgPtr < CBotFauna > _Leader ; // the individual in the group who is treated as the leader
CAITimer _Timer ;
uint32 _CurrentCycle ;
int _UpdatePriority ;
uint32 _LastUpdate ; // gamecycle at which update() last called
uint32 _DeltaTime ; // Dt, simply
bool _MustDespawnBots ; // if its a day group and its night for instance.
bool _DespawnImmediately ; // when MustdespawnBots, indicate if we must done it immedialtely or at best when no player can see it
} ;
@ -189,7 +190,7 @@ public:
TPlaces _Place ;
uint32 _NextCycle ;
} ;
class Cycle
{
public :
@ -201,104 +202,104 @@ public:
}
std : : vector < uint16 > _PopList ;
} ;
public :
CGrpFauna ( CMgrFauna * mgr , CAIAliasDescriptionNode * aliasTree , RYAI_MAP_CRUNCH : : TAStarFlag denyFlags ) ;
virtual ~ CGrpFauna ( ) ;
RYZOMID : : TTypeId getRyzomType ( ) { return RYZOMID : : creature ; }
CDynGrpBase * getGrpDynBase ( ) { return this ; }
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// PersistentStateInstance
CAliasTreeOwner * aliasTreeOwner ( ) { return this ; }
CAIS : : CCounter & getSpawnCounter ( ) ;
bool timeAllowSpawn ( uint32 popVersion = 12345 ) const ;
void stateChange ( CAIState const * oldState , CAIState const * newState ) ;
CGroup * getGroup ( ) { return this ; }
//////////////////////////////////////////////////////////////////////////
virtual void lastBotDespawned ( ) ;
virtual void firstBotSpawned ( ) ;
// debugging stuff
CDebugHistory * getDebugHistory ( ) { return this ; }
CPersistentStateInstance * getPersistentStateInstance ( ) { return this ; }
virtual void setEvent ( uint eventId ) ;
virtual void serviceEvent ( const CServiceEvent & info ) ;
virtual std : : string getFullName ( ) const { return CGroup : : getFullName ( ) ; }
virtual std : : string getIndexString ( ) const { return CGroup : : getIndexString ( ) ; }
IAliasCont * getAliasCont ( AITYPES : : TAIType type ) ;
CAliasTreeOwner * createChild ( IAliasCont * cont , CAIAliasDescriptionNode * aliasTree ) ;
NLMISC : : CSmartPtr < CSpawnGroup > createSpawnGroup ( ) ;
CSpawnGroupFauna * getSpawnObj ( ) const { return NLMISC : : type_cast < CSpawnGroupFauna * > ( CGroup : : getSpawnObj ( ) ) ; }
void allocateBots ( ) ;
// This struct is used to manage dead creatures and their corresponding respawned creature.
// inheritted virtual interface ------------------------------------
virtual bool spawn ( ) ;
bool spawnPop ( uint popVersion ) ;
virtual void despawnGrp ( ) ;
// Methods for setting up static data ------------------------------
void setType ( AITYPES : : TFaunaType type ) ;
void setCyles ( std : : string const & cycles ) ;
// Methods for manageing population descriptions
void setPopulation ( CPopulation * pop ) ;
// Methods for managing places
void setPlace ( CAIPlace * & variable , CAIPlace * place ) ;
void setupWanderPlace ( ) ;
// Miscelaneous accessors ------------------------------------------
CMgrFauna & mgr ( ) const ;
// reference timer value
static uint32 refTimer ( TTime time ) ;
uint32 timer ( TTime time ) const { return _Timer [ time ] ; }
void setTimer ( TTime timer , uint32 time ) { _Timer [ timer ] = time * 10 ; } ///< we set time in seconds.
AITYPES : : TFaunaType getType ( ) const { return _Type ; }
void setSpawnType ( AITYPES : : TSpawnType sp_type ) { _SpawnType = sp_type ; }
void displayPlaces ( CStringWriter & stringWriter ) const ;
CAliasCont < CAIPlace > & places ( ) { return _Places ; }
CAliasCont < CPopulation > & populations ( ) { return _Populations ; }
AITYPES : : CPropertySet & faction ( ) { return _Faction ; }
static const CCycleDef cycles [ ] ;
static const uint32 nbCycle ;
void setAutoSpawn ( bool autoSpawn ) { CGroup : : setAutoSpawn ( autoSpawn ) ; if ( ! isAutoSpawn ( ) ) _CurrentCycle = std : : numeric_limits < uint32 > : : max ( ) ; }
/// @name CChild implementation
//@{
virtual std : : string getOneLineInfoString ( ) const ;
virtual std : : vector < std : : string > getMultiLineInfoString ( ) const ;
//@}
/** Find next valid place with the wanted flags.
* If several places are valid , then one is picked randomly
* If several places are valid , then one is picked randomly
* \ return INVALID_PLACE if no such place exist
*/
sint getNextPlace ( const CFaunaGenericPlace * startPlace , CAIPlaceXYRFauna : : TFlag wantedFlag ) const ;
@ -309,35 +310,35 @@ public:
public :
// Dynamic data modified during normal activity --------------------
uint32 _CurPopulation ; // which alternative bot population is active
protected :
// Static data initilised at init time -----------------------------
// basic data (name, id, pointer to manager, etc)
AITYPES : : TFaunaType _Type ; // FaunaTypeHerbivore, FaunaTypePredator, ... etc
// Definition of a vector of vectors of classes for populations ----
CAliasCont < CPopulation > _Populations ;
CAliasCont < CAIPlace > _Places ;
AITYPES : : TSpawnType _SpawnType ;
CAITimer _priorityRecalcTimer ; // timer used to determine time of next recalc of _updateMask
uint32 _Timer [ LAST_TIME ] ;
float _Aggro ;
/// Animat Addon
double _MotivationGroupProtection ; // A value between 0 an 1 giving the importance of the group protection.
double _MotivationHarvestSap ; // Motivation for the sap harvest.
std : : vector < Cycle > _Cycles ; // Cycles List.
uint32 _CurrentCycle ; // current Cycle.
sint32 _CurrentCycleIndex ; // the pop index in the cycle
AITYPES : : CPropertySet _Faction ;
} ;