Merge branch 'fixes'

feature/prepare-cross-merge
Ulukyn 5 years ago committed by kaetemi
parent 8df98ce44a
commit ea095ca4f3
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -45,7 +45,7 @@ extern bool GrpHistoryRecordLog;
/// This is a common parent for all grp classes (bot group classes)
/// Group contains a container of Bots.
class CSpawnGroup
class CSpawnGroup
: public NLMISC::CDbgRefCount<CSpawnGroup>
, public CSpawnable<CPersistent<CSpawnGroup> >
, public CProfileOwner
@ -53,45 +53,45 @@ class CSpawnGroup
{
public:
CSpawnGroup(CPersistent<CSpawnGroup>& owner);
virtual ~CSpawnGroup();
virtual void spawnBotOfGroup();
void aggroLost(TDataSetRow const& aggroBot) const { }
void aggroGain(TDataSetRow const& aggroBot) const { }
virtual void spawnBots() = 0;
virtual void despawnBots(bool immediately) = 0;
virtual void update() = 0;
// Update Rate feature.
virtual int getUpdatePriority() const { return 0; }
virtual void recalcUpdatePriorityDelta() { }
CGroup& getPersistent() const;
CAliasCont<CBot> const& bots() const;
CAliasCont<CBot>& bots();
CBot* findLeader();
CProfilePtr& movingProfile() { return _MovingProfile; }
CProfilePtr& activityProfile() { return _ActivityProfile; }
CProfilePtr const& activityProfile() const { return _ActivityProfile; }
CProfilePtr& fightProfile() { return _FightProfile; }
/// only for use by State Machine (or problems will occurs -> callStateChanged if same )
void setMoveProfileFromStateMachine(IAIProfileFactory* staticProfile);
/// only for use by State Machine (or problems will occurs -> callStateChanged if same )
void setActivityProfileFromStateMachine(IAIProfileFactory* staticProfile);
bool calcCenterPos(CAIVector& grp_pos, bool allowDeadBot = false);
// Respawn bot list
class CBotToSpawn
{
@ -123,32 +123,32 @@ public:
CAITimer _despawnTimer;
CAITimer _respawnTimer;
};
void incSpawnedBot(CBot& spawnBot);
void decSpawnedBot();
void addBotToDespawnAndRespawnTime(CBot* faunaBot, uint32 despawnTime, uint32 respawnTime);
void checkDespawn();
void addBotToDespawnAndRespawnTime(CBot* faunaBot, uint32 despawnTime, uint32 respawnTime);
void checkDespawn();
void checkRespawn();
uint32 nbSpawnedBot() const { return _NbSpawnedBot; }
uint32 nbBotToRespawn() const { return (uint32)_BotsToRespawn.size(); }
uint32 nbBotToDespawn() const { return (uint32)_BotsToDespawn.size(); }
bool isGroupAlive(uint32 const nbMoreKilledBot = 0) const;
CAIVector const& getCenterPos() const { return _CenterPos; }
void setCenterPos(CAIVector const& pos) { _CenterPos = pos; }
std::vector<std::string> getMultiLineInfoString() const;
virtual NLMISC::CSmartPtr<CAIPlace const> buildFirstHitPlace(TDataSetRow const& aggroBot) const;
void addAggroFor(TDataSetRow const& bot, float aggro, bool forceReturnAggro, NLMISC::CSmartPtr<CAIPlace const> place = NLMISC::CSmartPtr<CAIPlace const>(NULL));
void setAggroMinimumFor(TDataSetRow const& bot, float aggro, bool forceReturnAggro, NLMISC::CSmartPtr<CAIPlace const> place = NLMISC::CSmartPtr<CAIPlace const>(NULL));
bool haveAggro() const;
@ -160,7 +160,7 @@ public:
const std::string getUrl() const { return _Url; }
void setUrl(const std::string &url) { _Url = url; }
protected:
CProfilePtr _PunctualHoldMovingProfile;
CProfilePtr _PunctualHoldActivityProfile;
@ -173,7 +173,7 @@ private:
std::vector<CBotToSpawn> _BotsToRespawn;
std::vector<CBotToSpawn> _BotsToDespawn;
CProfilePtr _MovingProfile;
CProfilePtr _ActivityProfile;
CProfilePtr _FightProfile;
@ -198,25 +198,25 @@ class CGroup
{
public:
friend class CSpawnGroup;
CGroup(CManager* owner, RYAI_MAP_CRUNCH::TAStarFlag denyFlag, CAIAliasDescriptionNode* aliasTree = NULL);
CGroup(CManager* owner, RYAI_MAP_CRUNCH::TAStarFlag denyFlag, uint32 alias, std::string const& name);
virtual ~CGroup();
void serviceEvent(CServiceEvent const& info);
CBot* getLeader();
CBot* getSquadLeader(bool checkAliveStatus = true);
void despawnBots();
virtual CDynGrpBase* getGrpDynBase() = 0;
CAliasTreeOwner* aliasTreeOwner() { return this; }
bool _AutoDestroy;
void autoDestroy(bool ad) { _AutoDestroy = ad; }
/// @name CChild implementation
//@{
virtual std::string getIndexString() const;
@ -224,67 +224,67 @@ public:
virtual std::vector<std::string> getMultiLineInfoString() const;
virtual std::string getFullName() const;
//@}
virtual void lastBotDespawned();
virtual void firstBotSpawned();
virtual CPersistentStateInstance* getPersistentStateInstance() = 0;
RYAI_MAP_CRUNCH::TAStarFlag getAStarFlag() const { return _DenyFlags; }
virtual CAIS::CCounter& getSpawnCounter() = 0;
virtual RYZOMID::TTypeId getRyzomType() = 0;
virtual void setEvent(uint eventId) = 0;
virtual bool spawn();
virtual NLMISC::CSmartPtr<CSpawnGroup> createSpawnGroup() = 0;
virtual void despawnGrp();
void despawnBots(bool immediately);
CAliasCont<CBot> const& bots() const { return _Bots; }
CAliasCont<CBot>& bots() { return _Bots; }
void display(CStringWriter& stringWriter);
CBot* getBot(uint32 index);
// debugging stuff
CDebugHistory* getDebugHistory() { return this; }
CBot* getNextValidBotChild(CBot* child = NULL) { return _Bots.getNextValidChild(child); }
CManager& getManager() { return *getOwner(); }
void setEscortTeamId(uint16 teamId) { _EscortTeamId = teamId; }
uint16 getEscortTeamId() const { return _EscortTeamId; }
void setEscortRange(float range) { _EscortRange = range; }
float getEscortRange() const { return _EscortRange; }
virtual void setAutoSpawn(bool autoSpawn) { _AutoSpawn = autoSpawn; }
bool isAutoSpawn() const { return _AutoSpawn; }
CAIInstance* getAIInstance() const { return getOwner()->getAIInstance(); }
void setEventParams(const std::vector<std::string> &a) { _EventParams = a; }
std::string getEventParamString(uint32 i) { if (i >= _EventParams.size()) return ""; return _EventParams[i]; }
float getEventParamFloat(uint32 i) { if (i >= _EventParams.size()) return 0.0f; return (float)atof(_EventParams[i].c_str()); }
float _AggroRange;
uint32 _AggroRange;
uint32 _UpdateNbTicks;
protected:
CAliasCont<CBot> _Bots;
/// Team Id of the escort (if any).
uint16 _EscortTeamId;
/// The range of the escort, ie the maximal distance of any escorter player that alow the group to be escorted
float _EscortRange;
uint8 _EscortRange;
/// The bots automaticaly spawn when the group is spawned.
bool _AutoSpawn;
RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
std::vector<std::string> _EventParams;
@ -299,7 +299,7 @@ protected:
//////////////////////////////////////////////////////////////////////////////
inline
CSpawnGroup::CSpawnGroup(CPersistent<CSpawnGroup>& owner)
CSpawnGroup::CSpawnGroup(CPersistent<CSpawnGroup>& owner)
: CSpawnable<CPersistent<CSpawnGroup> >(owner)
, CProfileOwner()
, _NbSpawnedBot(0)
@ -351,10 +351,10 @@ bool CGroup::spawn()
{
if (isSpawned())
return true;
if (!getSpawnCounter().remainToMax())
return false;
setSpawn(createSpawnGroup());
return true;
}
@ -373,7 +373,7 @@ inline
void CGroup::despawnBots(bool immediately)
{
if (!isSpawned())
return;
return;
getSpawnObj()->despawnBots(immediately);
}

File diff suppressed because it is too large Load Diff

@ -55,7 +55,7 @@ IAiFactory<IFamilyProfile> *_ProfileTribe=&_singleProfileTribe;
//CPropertyId act_nz_outpost_def("activity_npc_outpost_def");
//CPropertyId act_nz_outpost_atk("activity_npc_outpost_atk");
//CPropertyId act_nz_kami_wander("activity_npc_kami_wander");
//CPropertyId act_nz_escort("activity_npc_escort");
//CPropertyId act_nz_escort("activity_npc_escort");
//CPropertyId act_nz_convoy("activity_npc_convoy");
//CPropertyId act_nz_contact("activity_npc_contact");
//CPropertyId act_nz_fight("activity_npc_fight");
@ -71,7 +71,7 @@ IAiFactory<IFamilyProfile> *_ProfileTribe=&_singleProfileTribe;
//CPropertyId act_fz_rest_kitin_invasion("act_fz_rest_kitin_invasion");
//CPropertyId act_fz_food_degen("act_fz_food_degen");
//CPropertyId act_fz_plant("act_fz_plant");
//CPropertyId act_fz_rest_kitin("act_fz_rest_kitin");
//CPropertyId act_fz_rest_kitin("act_fz_rest_kitin");
//CPropertyId act_fz_rest_degen("act_fz_rest_degen");
// Todo:
@ -96,15 +96,15 @@ void COutpostInfo::checkDespawnGroupList ()
while (_DespawnList.size()>0)
{
CGroupNpc *grpNpc=_DespawnList.back();
CGroupNpc *grpNpc=_DespawnList.back();
_DespawnList.pop_back();
{
TGroupList::iterator it=_FightGroup.begin();
const TGroupList::iterator itEnd=_FightGroup.end();
for (;(it!=itEnd) && ((*it).ptr()!=grpNpc);++it);
if (it!=itEnd)
{
(*it)->despawnGrp();
@ -119,14 +119,14 @@ void COutpostInfo::checkDespawnGroupList ()
const TGroupList::iterator itEnd=_ContactGroups.end();
for (;(it!=itEnd) && ((*it).ptr()!=grpNpc);++it);
if (it!=itEnd)
{
(*it)->despawnGrp();
_ContactGroups.erase(it);
continue;
}
}
#ifdef NL_DEBUG
nlassert(true==false); // unknown group.
@ -206,7 +206,7 @@ void COutpostInfo::fightGroups(bool exist)
// CGroupNpc *const grp = _FamilyProfileTribe->createNpcGroup(spawnZone,gd);
// if (!grp)
// continue;
//
//
// grp->setDiscardable (false);
// // this group will run !
// grp->mergeProfileParameter (CProfileParameters::TProfileParameter("running", "", 0));
@ -224,7 +224,7 @@ void COutpostInfo::fightGroups(bool exist)
// return;
//
// for (TGroupList::iterator it=_FightGroup.begin(), itEnd=_FightGroup.end();it!=itEnd;++it)
// {
// {
// NLMISC::CDbgPtr<CGroupNpc> &dbgPtr=*it;
//#ifdef NL_DEBUG
// nlassert(!dbgPtr.isNULL());
@ -273,11 +273,11 @@ void COutpostInfo::contactGroups(bool exist) // contact groups ..
// const CGroupDesc *gd = _FamilyBehavior->getOwner()->getOwner()->getProportionalGroupDesc(_FamilyBehavior, act_nz_contact+act_nz_contact_outpost, act_nz_escort+act_nz_convoy);
// if (!gd)
// continue;
//
//
// CGroupNpc *const grp=_FamilyProfileTribe->createNpcGroup(_FamilyProfileTribe->getCampZone(),gd);
// if (!grp)
// continue;
//
//
// grp->getSpawnObj()->activityProfile().setAIProfile(new CGrpProfileDynContact(grp->getSpawnObj(), _FamilyProfileTribe, this));
// _ContactGroups.push_back(grp);
//
@ -290,7 +290,7 @@ void COutpostInfo::contactGroups(bool exist) // contact groups ..
// return;
//
// for (TGroupList::iterator it=_ContactGroups.begin(), itEnd=_ContactGroups.end();it!=itEnd;++it)
// {
// {
// NLMISC::CDbgPtr<CGroupNpc> &dbgPtr=*it;
// CGrpProfileDynFight *dynFight=safe_cast<CGrpProfileDynFight*>(dbgPtr->getSpawnObj()->activityProfile().getAIProfile());
// dynFight->gotoZone(_FamilyProfileTribe->getCampZone(),CPropertySet());
@ -356,7 +356,7 @@ void CFamilyProfileTribe::outpostAdd(NLMISC::TStringId outpostName)
_FamilyBehavior->getName().c_str(),
_FamilyBehavior->getOwner()->getAliasFullName().c_str());
CSmartPtr<COutpostInfo> outPost=COutpostInfo::createOutpost(_FamilyBehavior,this,outpostName);
if (!outPost)
{
@ -402,7 +402,7 @@ void CFamilyProfileTribe::spawnGroup()
{
H_AUTO(FamilySpawnTribe)
static CPropertyId act_nz_spawn("activity_spawn");
if (getCampZone().isNull())
return;
@ -411,11 +411,11 @@ void CFamilyProfileTribe::spawnGroup()
if (!spawn)
return;
static CPropertyId act_nz_escort("activity_escort");
static CPropertyId act_nz_escort("activity_escort");
static CPropertyId act_nz_contact("activity_contact");
static CPropertyId act_nz_fight_boss("act_nz_fight_boss");
// CCellZone &cellZone=_FamilyBehavior->getOwner();
const CGroupDesc<CGroupFamily> *const gd = _FamilyBehavior->grpFamily()->getProportionalGroupDesc(_FamilyBehavior, CPropertySet(), act_nz_contact+act_nz_fight_boss+act_nz_escort);
@ -473,7 +473,7 @@ void CGrpProfileDynContact::endProfile()
// there's a coherence problem about the activity.
void CGrpProfileDynContact::updateProfile(uint ticksSinceLastUpdate)
{
// this is a contact group, special treatment
switch (_Grp->movingProfile().getAIProfileType())
{
@ -495,7 +495,7 @@ void CGrpProfileDynContact::updateProfile(uint ticksSinceLastUpdate)
{
static CPropertyId act_nz_outpost("activity_outpost");
// time to go work childrens!
// time to go work childrens!
const CNpcZone *dest = _FamilyProfile->getFamilyBehavior()->getOwner()->lookupNpcZone(/*_FamilyProfile->getFamilyBehavior()->getFamily(),*/ act_nz_outpost, _FamilyProfile->getFamilyBehavior()->grpFamily()->getSubstitutionId());
if (dest)
{
@ -512,7 +512,7 @@ void CGrpProfileDynContact::updateProfile(uint ticksSinceLastUpdate)
// if arrived.
if (!profile->destinationReach())
break;
if (!_OutPostInfo->_ContactGroupExist)
{
_OutPostInfo->addToDespawnGroupList(_Grp);
@ -583,26 +583,26 @@ void CGrpProfileDynHarvest::checkTargetsAround ()
if (std::find(aggroList.begin(), aggroList.end(), AISHEETS::CSheets::getInstance()->playerGroupIndex())==aggroList.end())
return;
}
CAIVision<CPersistentOfPhysical> Vision;
breakable
{
CAIVector centerPos;
if (!_Grp->calcCenterPos(centerPos)) // true if there's some bots in the group.
break;
const uint32 playerRadius= uint(30); // _AggroRange);
const uint32 botRadius=uint(0); // _AggroRange);
const uint32 playerRadius=30; // _AggroRange);
const uint32 botRadius=0; // _AggroRange);
const uint32 minRadius=playerRadius>botRadius?botRadius:playerRadius;
Vision.updateBotsAndPlayers(_Grp->getPersistent().getAIInstance(), centerPos, playerRadius, botRadius);
}
{
const std::vector<NLMISC::CDbgPtr<CPersistentOfPhysical> > &players = Vision.players();
std::vector<NLMISC::CDbgPtr<CPersistentOfPhysical> >::const_iterator first(players.begin()), last(players.end());
for (; first != last; ++first)
{
@ -617,7 +617,7 @@ void CGrpProfileDynHarvest::checkTargetsAround ()
if ( rootCell
&& rootCell->getFlag()!=0 ) // Safe Zone ?
continue;
_Grp->setAggroMinimumFor(ep->dataSetRow(), 0.5f, false);
}
}
@ -659,9 +659,9 @@ void CGrpProfileDynHarvest::updateProfile(uint ticksSinceLastUpdate)
// Moving -> Wandering(Harvesting)|Camping
case MOVE_DYN_FOLLOW_PATH:
{
{
CGrpProfileDynFollowPath const* const fp = safe_cast<CGrpProfileDynFollowPath*>(movingProfile.getAIProfile());
if (!fp->destinationReach())
break;
@ -694,7 +694,7 @@ void CGrpProfileDynHarvest::updateProfile(uint ticksSinceLastUpdate)
// send the group to a harvest point
const CNpcZone *dest=NULL;
while ( !dest
|| dest==profile->currentZone())
{
@ -715,7 +715,7 @@ void CGrpProfileDynHarvest::updateProfile(uint ticksSinceLastUpdate)
#endif
break;
}
checkTargetsAround ();
checkTargetsAround ();
CGrpProfileNormal::updateProfile(ticksSinceLastUpdate);
}
@ -735,7 +735,7 @@ void CGrpProfileDynFight::beginProfile()
static CPropertyId act_nz_rest("activity_rest");
static CPropertyId act_nz_harvest("activity_harvest");
static CPropertyId act_nz_outpost("activity_outpost");
const CNpcZone *const dest = _FamilyProfile->getFamilyBehavior()->getOwner()->lookupNpcZone(/*_FamilyProfile->getFamilyBehavior()->getFamily(),*/ act_nz_harvest, _FamilyProfile->getFamilyBehavior()->grpFamily()->getSubstitutionId());
_Grp->movingProfile().setAIProfile(new CGrpProfileDynFollowPath(_Grp, _CurrentZone, dest, act_nz_outpost + act_nz_rest + act_nz_harvest));
}
@ -752,7 +752,7 @@ void CGrpProfileDynFight::updateProfile(uint ticksSinceLastUpdate)
{
static CPropertyId act_nz_outpost("activity_outpost");
CProfilePtr &movingProfile=_Grp->movingProfile();
// this is a contact group, special treatment
switch (movingProfile.getAIProfileType())
{
@ -772,14 +772,14 @@ void CGrpProfileDynFight::updateProfile(uint ticksSinceLastUpdate)
// send the group to an harvest site.
movingProfile.setAIProfile(new CGrpProfileDynFollowPath(_Grp, profile->currentZone(), dest, CPropertySet()));
break;
}
}
break;
// Moving -> Wandering(Fighting)|Camping
case MOVE_DYN_FOLLOW_PATH:
{
{
CGrpProfileDynFollowPath const* const fp = safe_cast<CGrpProfileDynFollowPath*>(movingProfile.getAIProfile());
_CurrentZone=fp->currentZone();
if (!fp->destinationReach())

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save