diff --git a/ryzom/server/src/ai_service/ai_grp.h b/ryzom/server/src/ai_service/ai_grp.h index ab92c8254..0f4e84606 100644 --- a/ryzom/server/src/ai_service/ai_grp.h +++ b/ryzom/server/src/ai_service/ai_grp.h @@ -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 , public CSpawnable > , public CProfileOwner @@ -53,45 +53,45 @@ class CSpawnGroup { public: CSpawnGroup(CPersistent& 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 const& bots() const; CAliasCont& 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 getMultiLineInfoString() const; - + virtual NLMISC::CSmartPtr buildFirstHitPlace(TDataSetRow const& aggroBot) const; - + void addAggroFor(TDataSetRow const& bot, float aggro, bool forceReturnAggro, NLMISC::CSmartPtr place = NLMISC::CSmartPtr(NULL)); void setAggroMinimumFor(TDataSetRow const& bot, float aggro, bool forceReturnAggro, NLMISC::CSmartPtr place = NLMISC::CSmartPtr(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 _BotsToRespawn; std::vector _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 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 createSpawnGroup() = 0; - + virtual void despawnGrp(); - + void despawnBots(bool immediately); - + CAliasCont const& bots() const { return _Bots; } CAliasCont& 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 &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 _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 _EventParams; @@ -299,7 +299,7 @@ protected: ////////////////////////////////////////////////////////////////////////////// inline -CSpawnGroup::CSpawnGroup(CPersistent& owner) +CSpawnGroup::CSpawnGroup(CPersistent& owner) : CSpawnable >(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); } diff --git a/ryzom/server/src/ai_service/ai_profile_npc.cpp b/ryzom/server/src/ai_service/ai_profile_npc.cpp index a54a38d57..a17bfca3c 100644 --- a/ryzom/server/src/ai_service/ai_profile_npc.cpp +++ b/ryzom/server/src/ai_service/ai_profile_npc.cpp @@ -100,11 +100,11 @@ class CBotProfileFightNpc public: CBotProfileFightNpc(CProfileOwner* owner, CAIEntityPhysical* ennemy); virtual ~CBotProfileFightNpc(); - + virtual std::string getOneLineInfoString() const { return "fight npc bot profile"; } - + void noMoreTarget(); - + void eventBeginFight(); void eventTargetKilled(); }; @@ -120,14 +120,14 @@ class CBotProfileHealNpc public: CBotProfileHealNpc(CAIEntityPhysical* target, CProfileOwner* owner); virtual ~CBotProfileHealNpc(); - + virtual std::string getOneLineInfoString() const { return "heal npc bot profile"; } - + void noMoreTarget(); - + virtual void healerAdded(CAIEntityPhysical* entity); virtual void healerRemoved(CAIEntityPhysical* entity); - + // void eventBeginFight(); // void eventTargetKilled(); private: @@ -148,9 +148,9 @@ public: virtual void endProfile(); virtual void updateProfile(uint ticksSinceLastUpdate); virtual std::string getOneLineInfoString() const; - + // virtual NLMISC::CSmartPtr const& getMovementMagnet() const { return _MovementMagnet; } - + private: CPathCont _PathCont; NLMISC::CSmartPtr _MoveProfile; @@ -165,15 +165,15 @@ class CGrpProfileTribu : public CGrpProfileNormal public: CGrpProfileTribu(CProfileOwner *owner); virtual ~CGrpProfileTribu(); - + virtual void beginProfile(); virtual void endProfile(); virtual void updateProfile(uint ticksSinceLastUpdate); - + virtual std::string getOneLineInfoString() const; - + virtual TProfiles getAIProfileType() const { return ACTIVITY_TRIBU; } - + private: CAIVector _CenterPos; }; @@ -188,7 +188,7 @@ class CGrpProfileStandAtStartPoint public: CGrpProfileStandAtStartPoint(CProfileOwner* owner); virtual ~CGrpProfileStandAtStartPoint(); - + class CBotPositionner : public CRefCount { public: @@ -197,32 +197,32 @@ public: virtual ~CBotPositionner(); void setBotAtDest(bool atDest = true); bool isBotAtDest() const; - + CPathCont _PathCont; CAIPos _Position; TVerticalPos _VerticalPos; private: bool _BotAtDest; }; - + CPathCont* getPathCont(CBot const* bot); - + virtual void beginProfile(); void resumeProfile(); virtual void endProfile(); virtual void updateProfile(uint ticksSinceLastUpdate); - + void addBot(CBot* bot); void removeBot(CBot* bot); - + void setCurrentValidPos(); - + virtual TProfiles getAIProfileType() const { return MOVE_STAND_ON_VERTICES; } virtual std::string getOneLineInfoString() const; - + private: typedef std::map > TNpcBotPositionnerMap; - + TNpcBotPositionnerMap _NpcList; bool _Finished; }; @@ -271,7 +271,7 @@ void CSpawnGroupNpc::botHaveDied(CBotNpc* bot) if (profile) profile->removeBot(bot); } - + { CSpawnBotNpc* const spawn = bot->getSpawn(); if (spawn) @@ -312,7 +312,7 @@ CBotProfileFightNpc::~CBotProfileFightNpc() } void CBotProfileFightNpc::noMoreTarget() -{ +{ _Bot->setAIProfile(BotProfileStandAtPosFactory.createAIProfile(_Bot.ptr())); } @@ -364,7 +364,7 @@ void CBotProfileHealNpc::healerRemoved(CAIEntityPhysical* entity) } void CBotProfileHealNpc::noMoreTarget() -{ +{ _Bot->setAIProfile(BotProfileStandAtPosFactory.createAIProfile(_Bot.ptr())); } @@ -428,7 +428,7 @@ CGrpProfileFight::CGrpProfileFight(CProfileOwner *owner) : CFightProfile(owner) , CFightOrganizer() , _WasRunning(false) -{ +{ PROFILE_LOG("group", "fight", "ctor", ""); } @@ -439,7 +439,7 @@ CGrpProfileFight::~CGrpProfileFight() { CBot *bot=*it; removeBot (bot); - } + } } void CGrpProfileFight::beginProfile() @@ -501,14 +501,14 @@ void CGrpProfileFight::setNoFight(CSpawnBot* bot) || bot->getAIProfileType()==BOT_FIGHT || bot->getAIProfileType()==BOT_HEAL || bot->getAIProfileType()==BOT_RETURN_AFTER_FIGHT ) - { + { bot->setAIProfile(new CBotProfileStandAtPos(bot)); } } void CGrpProfileFight::setFlee(CSpawnBot* bot, CAIVector& fleeVect) { - bot->setMoveDecalage(fleeVect); + bot->setMoveDecalage(fleeVect); if (bot->getAIProfileType()!=BOT_FLEE) { bot->setAIProfile(new CBotProfileFlee(bot)); @@ -547,12 +547,12 @@ void CGrpProfileFight::updateProfile(uint ticksSinceLastUpdate) i++; } reorganize(_NpcList.begin(), _NpcList.end()); - + // check groups around if (_CheckAround.test()) { _CheckAround.set(CHECK_AROUND_PERIOD); - + FOREACH(itBot, vector, _NpcList) { CBot* pBot = *itBot; @@ -565,7 +565,7 @@ void CGrpProfileFight::updateProfile(uint ticksSinceLastUpdate) } } } - + std::string CGrpProfileFight::getOneLineInfoString() const { return "fight profile"; @@ -585,13 +585,13 @@ void CGrpProfileNormal::beginProfile() PROFILE_LOG("group", "normal", "begin", ""); _GroupFighting=false; } - + void CGrpProfileNormal::endProfile() { PROFILE_LOG("group", "normal", "end", ""); setGroupFighting(false); } - + void CGrpProfileNormal::updateProfile(uint ticksSinceLastUpdate) { H_AUTO(GrpNormalProfileUpdate); @@ -601,18 +601,18 @@ void CGrpProfileNormal::updateProfile(uint ticksSinceLastUpdate) { if (!_Grp->fightProfile().getAIProfile()) _Grp->fightProfile().setAIProfile(new CGrpProfileFight(_Grp)); - + _Grp->fightProfile().mayUpdateProfile(ticksSinceLastUpdate); - + CFightProfile* profile = NLMISC::safe_cast(_Grp->fightProfile().getAIProfile()); if (!profile->stillHaveEnnemy ()) { // :TODO: Verify if it's needed to erase bots aggro too/instead // _Grp->clearAggroList(); // this erase all agro. - + setGroupFighting(false); _Grp->fightProfile().setAIProfile(NULL); - + CSlaveProfile* moveProfile = NLMISC::type_cast(_Grp->movingProfile().getAIProfile()); if (moveProfile) moveProfile->resumeProfile(); @@ -628,7 +628,7 @@ void CGrpProfileNormal::updateProfile(uint ticksSinceLastUpdate) if (!_Grp->fightProfile().getAIProfile()) // _Grp->fightProfile().setAIProfile(new CGrpProfileFight(_Grp)); _Grp->fightProfile().setAIProfile(_Grp.ptr(), &GrpProfileFightFactory, false); - + setGroupFighting(true); } } @@ -638,7 +638,7 @@ void CGrpProfileNormal::updateProfile(uint ticksSinceLastUpdate) } } } - + std::string CGrpProfileNormal::getOneLineInfoString() const { std::string info = "normal profile"; @@ -665,10 +665,10 @@ void CGrpProfileBandit::beginProfile() { PROFILE_LOG("group", "bandit", "begin", ""); CGrpProfileNormal::beginProfile(); - + CGroupNpc &persGrp=_Grp->getPersistent(); - + if (persGrp.isRingGrp()) { _AggroRange = persGrp.getAggroDist(); @@ -682,9 +682,9 @@ void CGrpProfileBandit::beginProfile() _AggroRange =static_cast( CGrpProfileBanditFactory::getDefaultBanditAggroRange() ); else _AggroRange = static_cast(aggroRangeFloat); - + bool resendInfo = false; - + if (!persGrp.getPlayerAttackable ()) { @@ -699,7 +699,7 @@ void CGrpProfileBandit::beginProfile() if (resendInfo) _Grp->sendInfoToEGS (); } - + } @@ -708,7 +708,7 @@ void CGrpProfileBandit::endProfile() PROFILE_LOG("group", "bandit", "end", ""); CGrpProfileNormal::endProfile(); } - + void CGrpProfileBandit::updateProfile(uint ticksSinceLastUpdate) { H_AUTO(GrpBanditProfileUpdate); @@ -722,35 +722,35 @@ void CGrpProfileBandit::updateProfile(uint ticksSinceLastUpdate) if (!_Grp->calcCenterPos(centerPos)) // true if there's some bots in the group. break; _Grp->setCenterPos(centerPos); - - uint32 playerRadius=uint(_AggroRange); - uint32 botRadius=uint(_AggroRange); + + uint32 playerRadius=_AggroRange; + uint32 botRadius=_AggroRange; uint32 groupPlayerRadius=playerRadius*2; uint32 groupBotRadius=botRadius*2; - + uint32 minRadius=playerRadius>botRadius?botRadius:playerRadius; - + CFightProfile* fightProfile=static_cast(_Grp->fightProfile().getAIProfile()); if (fightProfile) - { + { CAIVision localBanditVision; - + for (vector::iterator it=fightProfile->npcList().begin(), itEnd=fightProfile->npcList().end();it!=itEnd;++it) { CBot *bot=(*it); CSpawnBot *spawnBot=bot->getSpawnObj(); - + if (!spawnBot) continue; - + double distToCenter=centerPos.quickDistTo(spawnBot->pos()); if (distToCenter>minRadius) // (minRadius*2) - minRadius { const CAIVector spawnBotPos(spawnBot->pos()); // bot vision update. localBanditVision.updateBotsAndPlayers(spawnBot->getAIInstance(), spawnBotPos, playerRadius, botRadius); - + // bandits don't like guards nor escorted people { const std::vector > &bots = localBanditVision.bots(); @@ -763,7 +763,7 @@ void CGrpProfileBandit::updateProfile(uint ticksSinceLastUpdate) && ep->isAlive()) { CSpawnBotNpc *botNpc = NLMISC::safe_cast(ep); - + if ( botNpc->spawnGrp().activityProfile().getAIProfileType() == ACTIVITY_GUARD || botNpc->spawnGrp().activityProfile().getAIProfileType() == ACTIVITY_GUARD_ESCORTED || botNpc->spawnGrp().activityProfile().getAIProfileType() == ACTIVITY_ESCORTED ) @@ -773,9 +773,9 @@ void CGrpProfileBandit::updateProfile(uint ticksSinceLastUpdate) } } } - + // bandits don't like players. - { + { const std::vector > &players = localBanditVision.players(); std::vector >::const_iterator first(players.begin()), last(players.end()); for (; first != last; ++first) @@ -794,7 +794,7 @@ void CGrpProfileBandit::updateProfile(uint ticksSinceLastUpdate) spawnBot->setAggroMinimumFor(ep->dataSetRow(), 0.5f, false); } } - } + } } } } @@ -826,7 +826,7 @@ void CGrpProfileBandit::updateProfile(uint ticksSinceLastUpdate) } } } - + // bandits don't like guards nor escorted people { const std::vector > &bots = BanditVision.bots(); @@ -840,7 +840,7 @@ void CGrpProfileBandit::updateProfile(uint ticksSinceLastUpdate) continue; const CSpawnBot *const bot = NLMISC::safe_cast(ep); - + const TProfiles profileType=bot->spawnGrp().activityProfile().getAIProfileType(); if ( profileType != ACTIVITY_GUARD && profileType != ACTIVITY_GUARD_ESCORTED @@ -850,11 +850,11 @@ void CGrpProfileBandit::updateProfile(uint ticksSinceLastUpdate) _Grp->setAggroMinimumFor(ep->dataSetRow(), 0.8f, false); } } - + // bandits don't like players. { const std::vector > &players = BanditVision.players(); - + std::vector >::const_iterator first(players.begin()), last(players.end()); for (; first != last; ++first) { @@ -869,7 +869,7 @@ void CGrpProfileBandit::updateProfile(uint ticksSinceLastUpdate) if ( rootCell && rootCell->getFlag()!=0 ) // Safe Zone ? continue; - + _Grp->setAggroMinimumFor(ep->dataSetRow(), 0.5f, false); } } @@ -897,20 +897,20 @@ CGrpProfileGuard::~CGrpProfileGuard() { PROFILE_LOG("group", "guard", "dtor", ""); } - + void CGrpProfileGuard::beginProfile() { PROFILE_LOG("group", "guard", "begin", ""); CGrpProfileNormal::beginProfile(); CGroupNpc &persGrp=_Grp->getPersistent(); - + if (persGrp.isRingGrp()) { _AggroRange = persGrp.getAggroDist(); } else { - _AggroRange = 25; + _AggroRange = 0; } } @@ -919,14 +919,16 @@ void CGrpProfileGuard::endProfile() PROFILE_LOG("group", "guard", "end", ""); CGrpProfileNormal::endProfile(); } - + void CGrpProfileGuard::updateProfile(uint ticksSinceLastUpdate) { H_AUTO(GrpGuardProfileUpdate); CFollowPathContext fpcGrpGuardProfileUpdate("GrpGuardProfileUpdate"); - CAIVision GuardVision; - const uint32 aggroSize=uint32(_AggroRange); + CAIVision GuardVision; + uint32 aggroSize = _Grp->getPersistent()._AggroRange; + if (aggroSize == 0) + aggroSize = 25; TTicks startVisionTime = CTime::getPerformanceTime(); @@ -946,7 +948,7 @@ void CGrpProfileGuard::updateProfile(uint ticksSinceLastUpdate) static uint32 s_maxBotsVisible = 0; static double s_maxBotsVisionTime = 0.0; - + uint32 numBotsVisible = (uint32)GuardVision.bots().size(); double deltaVisionTime = CTime::ticksToSecond(endVisionTime-startVisionTime); bool bTellUs = false; @@ -967,7 +969,7 @@ void CGrpProfileGuard::updateProfile(uint ticksSinceLastUpdate) nldebug( "==> max bots visible is now %u", s_maxBotsVisible ); nldebug( "vision time: %.2f", (float)(deltaVisionTime * 1000.0) ); } - + uint32 factionIndex=CStaticFames::INVALID_FACTION_INDEX; sint32 fameForGuardAttack = FameForGuardAttack; { @@ -981,7 +983,7 @@ void CGrpProfileGuard::updateProfile(uint ticksSinceLastUpdate) factionIndex=bot->getSheet()->FactionIndex(); if (bot->getSheet()->FameForGuardAttack() != AISHEETS::ICreature::InvalidFameForGuardAttack) fameForGuardAttack = bot->getSheet()->FameForGuardAttack(); - + /* if (factionIndex == CStaticFames::INVALID_FACTION_INDEX) { nlwarning("Bot sheet '%s' have invalid faction index (guard profile)", bot->getSheet()->SheetId().toString().c_str()); @@ -990,7 +992,7 @@ void CGrpProfileGuard::updateProfile(uint ticksSinceLastUpdate) } } } - + string s; float f = 0.f; if (_Grp->getProfileParameter("faction", s) && !s.empty()) @@ -1001,7 +1003,7 @@ void CGrpProfileGuard::updateProfile(uint ticksSinceLastUpdate) { fameForGuardAttack = (sint32)f; } - + CGrpProfileNormal::updateProfile(ticksSinceLastUpdate); // check if we are in war and if some bot are waiting for a bus. @@ -1050,7 +1052,7 @@ void CGrpProfileGuard::updateProfile(uint ticksSinceLastUpdate) } } } - + // guards don't like bandits. { H_AUTO(GrpGuardProfileBandits); @@ -1095,13 +1097,13 @@ void CGrpProfileGuard::updateProfile(uint ticksSinceLastUpdate) } } } - + // guards don't like bots that attack players. { H_AUTO(GrpGuardProfileAttack); - const std::vector > &players = GuardVision.players(); + const std::vector > &players = GuardVision.players(); LOG("%u players in group vision with aggrosize %d", players.size(), aggroSize); - + const CAIVector ¢erPos=_Grp->getCenterPos(); std::vector >::const_iterator first(players.begin()), last(players.end()); @@ -1117,7 +1119,7 @@ void CGrpProfileGuard::updateProfile(uint ticksSinceLastUpdate) // check Fame before choosing what to do .. sint32 const fame = ep->getFameIndexed(factionIndex); - + // if player is kos attack him (only if bot is attackable by player) if ((_Grp->getPersistent().getPlayerAttackable() || (factionIndex!=CStaticFames::INVALID_FACTION_INDEX && _Grp->getPersistent().isFactionAttackable(CStaticFames::getInstance().getFactionName(factionIndex), fame))) && ((factionIndex!=CStaticFames::INVALID_FACTION_INDEX && fame TribuVision; + CAIVision TribuVision; const uint32 aggroSize=40; breakable @@ -1214,7 +1216,7 @@ void CGrpProfileTribu::updateProfile(uint ticksSinceLastUpdate) _CenterPos=_Grp->getCenterPos(); TribuVision.updateBotsAndPlayers(_Grp->getPersistent().getAIInstance(), _CenterPos, aggroSize, aggroSize); } - + uint32 factionIndex=CStaticFames::INVALID_FACTION_INDEX; { CBotNpc* bot = static_cast(*_Grp->getPersistent().bots().begin()); @@ -1243,7 +1245,7 @@ void CGrpProfileTribu::updateProfile(uint ticksSinceLastUpdate) { CMoveProfile *moveProf=NLMISC::safe_cast(_Grp->movingProfile().getAIProfile()); moveProf->resumeBot(bot); - } + } break; case BOT_FIGHT: { @@ -1266,14 +1268,14 @@ void CGrpProfileTribu::updateProfile(uint ticksSinceLastUpdate) break; } } - } + } // Tribus don't like players with bad fame. { const std::vector > &players = TribuVision.players(); - + LOG("%u players in group vision", players.size()); - + std::vector >::const_iterator first(players.begin()), last(players.end()); for (; first != last; ++first) { @@ -1291,7 +1293,7 @@ void CGrpProfileTribu::updateProfile(uint ticksSinceLastUpdate) // check Fame before choosing what to do .. sint32 const fame = ep->getFameIndexed(factionIndex); - + // check if player is attacked. if (fame<-10000 || OUTPOSTHELPERS::isAttackingFaction(factionIndex, ep)) { @@ -1300,7 +1302,7 @@ void CGrpProfileTribu::updateProfile(uint ticksSinceLastUpdate) } } } - + std::string CGrpProfileTribu::getOneLineInfoString() const { return "tribu profile"; @@ -1324,7 +1326,7 @@ CGrpProfileGoToPoint::CGrpProfileGoToPoint(CProfileOwner *owner, RYAI_MAP_CRUNCH _ValidPosInit=false; _StopNpc = false; } - + void CGrpProfileGoToPoint::setDirection(bool forward) { if ( _FollowForward==forward @@ -1340,14 +1342,14 @@ void CGrpProfileGoToPoint::beginProfile() PROFILE_LOG("group", "go_to_point", "begin", ""); _ProfileTerminated = false; CMoveProfile::beginProfile(); - + setCurrentDestination(_EndPos); // * } void CGrpProfileGoToPoint::stateChangeProfile() { setCurrentDestination(_EndPos); // * - + // set a stand at pos profile on every bots FOREACH(it, CAliasCont, _Grp->bots()) { @@ -1355,7 +1357,7 @@ void CGrpProfileGoToPoint::stateChangeProfile() if (sb) sb->setAIProfile(new CBotProfileStandAtPos(sb)); } - + resumeProfile(); } @@ -1382,7 +1384,7 @@ void CGrpProfileGoToPoint::resumeProfile() sbot->setAIProfile(new CBotProfileStandAtPos(sbot)); break; } - + } setCurrentDestination(_EndPos); } @@ -1408,7 +1410,7 @@ void CGrpProfileGoToPoint::removeBot(CBot* bot) CSpawnBotNpc *const spawnBot=NLMISC::safe_cast(bot)->getSpawn(); if (spawnBot) spawnBot->setAIProfile(BotProfileStandAtPosFactory.createAIProfile(spawnBot)); - + _NpcList.erase (it); _MustCalcRatios = true; } @@ -1416,7 +1418,7 @@ void CGrpProfileGoToPoint::removeBot(CBot* bot) void CGrpProfileGoToPoint::setCurrentDestination(RYAI_MAP_CRUNCH::CWorldPosition const& dest) { _PathCont.setDestination(dest); - + FOREACH(it, TBotFollowerMap, _NpcList) it->second.setBotAtDest(false); } @@ -1443,20 +1445,20 @@ void CGrpProfileGoToPoint::calcRatios() if (_Shape!=SHAPE_RECTANGLE) return; - + const uint32 nbbots=(uint32)_NpcList.size(); - + _NbRange = (uint32) sqrt(_Ratio*nbbots); if (_NbRange==0) _NbRange=1; _NbLines = nbbots/_NbRange; _NbBotInNormalShape = _NbLines*_NbRange; _Rest = nbbots-_NbBotInNormalShape; - + _Cx=(double(_NbRange)-1.0)*0.5; _Cy=(double(_NbLines)-1.0)*0.5; _Cy=(_Cy*_NbBotInNormalShape+double(_NbLines)*_Rest)/double(nbbots); -} +} void CGrpProfileGoToPoint::updateProfile(uint ticksSinceLastUpdate) { @@ -1464,14 +1466,14 @@ void CGrpProfileGoToPoint::updateProfile(uint ticksSinceLastUpdate) CFollowPathContext fpcCGrpGoToPointProfileUpdate("CGrpGoToPointProfileUpdate"); CMoveProfile::updateProfile(ticksSinceLastUpdate); - + CSpawnGroupNpc *NpcGrp=NLMISC::safe_cast(_Grp.ptr()); CGroupNpc &persGrp=NpcGrp->getPersistent(); - + CAIVector groupPosition = NpcGrp->getCenterPos(); CAIVector perpGlobalOrient; NpcGrp->calcCenterPos(groupPosition); - + uint32 nbAtDest=0; uint32 nbNewAtDest=0; @@ -1493,7 +1495,7 @@ void CGrpProfileGoToPoint::updateProfile(uint ticksSinceLastUpdate) // Calcs the correct gravity grid position (must be done only when bot are removed or add to the group. if (_MustCalcRatios) calcRatios (); - + FOREACH(it, TBotFollowerMap, _NpcList) { @@ -1523,7 +1525,7 @@ void CGrpProfileGoToPoint::updateProfile(uint ticksSinceLastUpdate) else { CBotProfileFollowPos* prof = NLMISC::safe_cast(sbot->getAIProfile()); - + // flag the sub profile to stop the npc prof->setStop(_StopNpc); if (!_StopNpc) @@ -1554,14 +1556,14 @@ void CGrpProfileGoToPoint::updateProfile(uint ticksSinceLastUpdate) } } break; - } + } if (_Shape==SHAPE_RECTANGLE) { NLMISC::CVector2d dir=sbot->theta().asVector2d(); dx+=dir.x; dy+=dir.y; - + // 4 rows CAIVector idealPos=groupPosition; if (botIndex>=_NbBotInNormalShape) @@ -1572,10 +1574,10 @@ void CGrpProfileGoToPoint::updateProfile(uint ticksSinceLastUpdate) { idealPos += perpGlobalOrient * (_XSize*(_Cx-double(xIndex))); } - + idealPos+=_GlobalOrient*(_YSize*(_Cy-(double)yIndex)); idealPos-=CAIVector(sbot->pos()); - + botIndex++; xIndex++; if (xIndex>=_NbRange) @@ -1604,7 +1606,7 @@ void CGrpProfileGoToPoint::updateProfile(uint ticksSinceLastUpdate) _ProfileTerminated = true; } } - + CGrpProfileGoToPoint::~CGrpProfileGoToPoint() { for (CCont::iterator it=_Grp->bots().begin(), itEnd=_Grp->bots().end();it!=itEnd;++it) @@ -1678,7 +1680,7 @@ CGrpProfileFollowRoute::CGrpProfileFollowRoute(CProfileOwner *owner) _GlobalOrient.setY(0); _FollowForward = true; _StopNpc = false; - + CGroupNpc &grp=*safe_cast(&_Grp->getPersistent()); if (grp.getState()) { @@ -1718,7 +1720,7 @@ CGrpProfileFollowRoute::CGrpProfileFollowRoute(CProfileOwner *owner,const std::v _GeomIndex=0; _StopNpc = false; } - + void CGrpProfileFollowRoute::setDirection(bool forward) { if ( _FollowForward==forward @@ -1753,13 +1755,13 @@ void CGrpProfileFollowRoute::assignGeometryFromState() _XSize = 1; _YSize = 1; _Ratio = 1; - + if (_Grp->getProfileParameter("shape", shape) && shape=="rectangle") { _Shape = SHAPE_RECTANGLE; } - + _Grp->getProfileParameter("ratio", _Ratio); _Grp->getProfileParameter("xsize", _XSize); _Grp->getProfileParameter("ysize", _YSize); @@ -1789,11 +1791,11 @@ void CGrpProfileFollowRoute::assignGeometryFromState() if ( !state || !state->isPositional()) return; - + const CAIStatePositional *const sp = static_cast(state); if (!sp->shape().hasPoints() && (_GeometryComeFromState)) { - nlwarning("Error, no position in state '%s'%s", + nlwarning("Error, no position in state '%s'%s", sp->getAliasFullName().c_str(), sp->getAliasString().c_str()); } @@ -1810,7 +1812,7 @@ void CGrpProfileFollowRoute::assignGeometryFromState() void CGrpProfileFollowRoute::stateChangeProfile() { assignGeometryFromState(); - + // set a stand at pos profile on every bots FOREACH(it, CAliasCont, _Grp->bots()) { @@ -1820,7 +1822,7 @@ void CGrpProfileFollowRoute::stateChangeProfile() } // Reset stop flag to false stopNpc(false); - + resumeProfile(); } @@ -1847,7 +1849,7 @@ void CGrpProfileFollowRoute::resumeProfile() sbot->setAIProfile(new CBotProfileStandAtPos(sbot)); break; } - + } // setCurrentValidPos (NLMISC::safe_cast(NLMISC::safe_cast(_Grp)->getPersistent().getCAIState())); #ifdef NL_DEBUG @@ -1877,7 +1879,7 @@ void CGrpProfileFollowRoute::removeBot (CBot *bot) CSpawnBotNpc *const spawnBot=NLMISC::safe_cast(bot)->getSpawn(); if (spawnBot) spawnBot->setAIProfile(BotProfileStandAtPosFactory.createAIProfile(spawnBot)); - + _NpcList.erase (it); _MustCalcRatios = true; } @@ -1895,7 +1897,7 @@ void CGrpProfileFollowRoute::setCurrentValidPos (TVerticalPos verticalPos) #endif _PathCont.setDestination (verticalPos, (*_Geometry)[index]); } - + FOREACH(it, TBotFollowerMap, _NpcList) it->second.setBotAtDest(false); } @@ -1931,11 +1933,11 @@ void CGrpProfileFollowRoute::calcRatios () _NbLines = nbbots/_NbRange; _NbBotInNormalShape = _NbLines*_NbRange; _Rest = nbbots-_NbBotInNormalShape; - + _Cx=(double(_NbRange)-1.0)*0.5; _Cy=(double(_NbLines)-1.0)*0.5; _Cy=(_Cy*_NbBotInNormalShape+double(_NbLines)*_Rest)/double(nbbots); -} +} void CGrpProfileFollowRoute::updateProfile(uint ticksSinceLastUpdate) { @@ -1943,14 +1945,14 @@ void CGrpProfileFollowRoute::updateProfile(uint ticksSinceLastUpdate) CFollowPathContext fpcGrpFollowRouteProfileUpdate("GrpFollowRouteProfileUpdate"); CMoveProfile::updateProfile(ticksSinceLastUpdate); - + CSpawnGroupNpc *NpcGrp=NLMISC::safe_cast(_Grp.ptr()); CGroupNpc &persGrp=NpcGrp->getPersistent(); - + CAIVector groupPosition = NpcGrp->getCenterPos(); CAIVector perpGlobalOrient; NpcGrp->calcCenterPos(groupPosition); - + uint32 nbAtDest=0; uint32 nbNewAtDest=0; @@ -1978,7 +1980,7 @@ void CGrpProfileFollowRoute::updateProfile(uint ticksSinceLastUpdate) // Calcs the correct gravity grid position (must be done only when bot are removed or add to the group. if (_MustCalcRatios) calcRatios (); - + FOREACH(it, TBotFollowerMap, _NpcList) { @@ -2008,7 +2010,7 @@ void CGrpProfileFollowRoute::updateProfile(uint ticksSinceLastUpdate) else { CBotProfileFollowPos* prof = NLMISC::safe_cast(sbot->getAIProfile()); - + // flag the sub profile to stop the npc prof->setStop(_StopNpc); if (!_StopNpc) @@ -2046,14 +2048,14 @@ void CGrpProfileFollowRoute::updateProfile(uint ticksSinceLastUpdate) } } break; - } + } if (_Shape==SHAPE_RECTANGLE) { NLMISC::CVector2d dir=sbot->theta().asVector2d(); dx+=dir.x; dy+=dir.y; - + // 4 rows CAIVector idealPos=groupPosition; if (botIndex>=_NbBotInNormalShape) @@ -2064,10 +2066,10 @@ void CGrpProfileFollowRoute::updateProfile(uint ticksSinceLastUpdate) { idealPos += perpGlobalOrient * (_XSize*(_Cx-double(xIndex))); } - + idealPos+=_GlobalOrient*(_YSize*(_Cy-(double)yIndex)); idealPos-=CAIVector(sbot->pos()); - + botIndex++; xIndex++; if (xIndex>=_NbRange) @@ -2089,7 +2091,7 @@ void CGrpProfileFollowRoute::updateProfile(uint ticksSinceLastUpdate) if (nbAtDest>0 && !_ProfileTerminated) { // oh la la (la, let 's go dancing).. - _GeomIndex++; + _GeomIndex++; #ifdef NL_DEBUG nlassert(_Geometry); #endif @@ -2111,7 +2113,7 @@ void CGrpProfileFollowRoute::updateProfile(uint ticksSinceLastUpdate) } } } - + ////////////////////////////////////////////////////////////////////////////// // CGrpProfileStandOnVertices // ////////////////////////////////////////////////////////////////////////////// @@ -2123,14 +2125,14 @@ CPathCont* CGrpProfileStandOnVertices::getPathCont(CBot const* bot) return NULL; return &it->second->_PathCont; } - + void CGrpProfileStandOnVertices::beginProfile() { PROFILE_LOG("group", "stand_on_vertices", "begin", ""); CMoveProfile::beginProfile(); CSpawnGroupNpc *NpcGrp=NLMISC::safe_cast(_Grp.ptr()); - - CAIStatePositional *grpState=NLMISC::safe_cast(NpcGrp->getPersistent().getCAIState()); + + CAIStatePositional *grpState=NLMISC::safe_cast(NpcGrp->getPersistent().getCAIState()); if ( !grpState || grpState->shape().numPoints() == 0 @@ -2170,12 +2172,12 @@ void CGrpProfileStandOnVertices::resumeProfile() case BOT_FOLLOW_POS: break; default: // push the correct behaviour - { + { sbot->setAIProfile(new CBotProfileStandAtPos(sbot)); } break; } - + } CSpawnGroupNpc *NpcGrp=NLMISC::safe_cast(_Grp.ptr()); @@ -2183,33 +2185,33 @@ void CGrpProfileStandOnVertices::resumeProfile() nlassert( grpState->shape().numPoints()>0 && grpState && grpState->isPositional()); - setCurrentValidPos (grpState); + setCurrentValidPos (grpState); _Finished=false; } - + void CGrpProfileStandOnVertices::addBot (CBot *bot) { CGroupNpc& grp=NLMISC::safe_cast(bot)->grp(); #ifdef NL_DEBUG nlassert(grp.getSpawnObj()); #endif - + CAIStatePositional *grpState=NLMISC::safe_cast(grp.getCAIState()); CSpawnBot *const sbot=bot->getSpawnObj(); - + if ( grpState->shape().numPoints() < 1 ) { nlwarning("CGrpProfileStandOnVertices : group state '%s'%s: no vertice !", grpState->getAliasFullName().c_str(), grpState->getAliasString().c_str()); return; } - + if (sbot) sbot->setAIProfile(new CBotProfileStandAtPos(sbot)); - + _NpcList[bot]=new CBotPositionner (bot->getChildIndex()%grpState->shape().numPoints(), bot->getGroup().getAStarFlag()); } - + void CGrpProfileStandOnVertices::removeBot (CBot *bot) { TNpcBotPositionnerMap::iterator it=_NpcList.find(bot); @@ -2230,13 +2232,13 @@ void CGrpProfileStandOnVertices::updateProfile(uint ticksSinceLastUpdate) CFollowPathContext fpcGrpStandProfileUpdate("GrpStandProfileUpdate"); CMoveProfile::updateProfile(ticksSinceLastUpdate); - + CGroupNpc &persGrp=NLMISC::safe_cast(_Grp.ptr())->getPersistent(); CAIStatePositional *grpState=static_cast(persGrp.getCAIState()); - + uint32 nbAtDest=0; uint32 nbNewAtDest=0; - + for (TNpcBotPositionnerMap::iterator it=_NpcList.begin(), itEnd=_NpcList.end();it!=itEnd;++it) { CBotPositionner *botPos=(*it).second; @@ -2252,7 +2254,7 @@ void CGrpProfileStandOnVertices::updateProfile(uint ticksSinceLastUpdate) case BOT_FOLLOW_POS: { CBotProfileFollowPos* prof = NLMISC::safe_cast(sbot->getAIProfile()); - + if (prof->_Status==CFollowPath::FOLLOW_ARRIVED) { sbot->setAIProfile(new CBotProfileStandAtPos(sbot)); @@ -2282,14 +2284,14 @@ void CGrpProfileStandOnVertices::updateProfile(uint ticksSinceLastUpdate) nbAtDest++; } } - + // first to arrived ? if ( nbNewAtDest==nbAtDest && nbAtDest>0 ) { persGrp.processStateEvent(persGrp.mgr().EventDestinationReachedFirst); } - + // all arrived ? if ( nbAtDest==_NpcList.size() && !_Finished ) @@ -2298,7 +2300,7 @@ void CGrpProfileStandOnVertices::updateProfile(uint ticksSinceLastUpdate) _Finished=true; } } - + ////////////////////////////////////////////////////////////////////////////// // CGrpProfileFollowPlayer // ////////////////////////////////////////////////////////////////////////////// @@ -2330,10 +2332,10 @@ void CGrpProfileFollowPlayer::updateProfile(uint ticksSinceLastUpdate) H_AUTO(CGrpProfileFollowPlayerUpdate); CFollowPathContext fpcGrpFollowPlayerUpdate("CGrpProfileFollowPlayerUpdate"); - // check all bot to see if there need to move + // check all bot to see if there need to move CSpawnGroupNpc* grp = static_cast(static_cast(_Grp)); CGroupNpc &pgrp = grp->getPersistent(); - + CBotPlayer* plrPtr = dynamic_cast(CAIS::instance().getEntityPhysical(_PlayerRow)); if ( ! plrPtr) { @@ -2359,11 +2361,11 @@ void CGrpProfileFollowPlayer::updateProfile(uint ticksSinceLastUpdate) CAIVector const& dest = _PathCont.getDestination(); if (dest.x()==0 || dest.y()==0) return; - + static const std::string runParameter("running"); float dist; if (sbot->getPersistent().getOwner()->getSpawnObj()->checkProfileParameter(runParameter)) - dist = sbot->runSpeed()*ticksSinceLastUpdate; + dist = sbot->runSpeed()*ticksSinceLastUpdate; else dist = sbot->walkSpeed()*ticksSinceLastUpdate; @@ -2381,8 +2383,8 @@ void CGrpProfileFollowPlayer::updateProfile(uint ticksSinceLastUpdate) nlwarning("Problem with following player"); } - - } + + } } @@ -2531,15 +2533,15 @@ void CGrpProfileWander::stateChangeProfile() } void CGrpProfileWander::affectZoneFromStateMachine() -{ +{ CSpawnGroupNpc* grp = static_cast(static_cast(_Grp)); CGroupNpc& pgrp = grp->getPersistent(); CAIState const* const state = pgrp.getActiveState(); - + if ( !state || !state->isPositional()) return; - + CAIStatePositional const* const sp = static_cast(state); if (!sp->shape().hasPoints()) { @@ -2584,10 +2586,10 @@ void CGrpProfileWander::beginProfile() _NpcDestinationReached.resize( grp->getPersistent().bots().size()); resetDestinationReachedData(); - + } -void CGrpProfileWander::addBot(CBot* bot) +void CGrpProfileWander::addBot(CBot* bot) { CSpawnBot *const spawnBot=bot->getSpawnObj(); if (!spawnBot) @@ -2606,7 +2608,7 @@ void CGrpProfileWander::addBot(CBot* bot) #endif spawnBot->setAIProfile(profile); } -void CGrpProfileWander::removeBot(CBot* bot) +void CGrpProfileWander::removeBot(CBot* bot) { } CPathCont* CGrpProfileWander::getPathCont(CBot const* bot) @@ -2630,7 +2632,7 @@ void CGrpProfileWander::updateProfile(uint ticksSinceLastUpdate) return; } - // check all bot to see if there need to move + // check all bot to see if there need to move CSpawnGroupNpc* grp = static_cast(static_cast(_Grp)); CGroupNpc &pgrp = grp->getPersistent(); bool aNpcHasReachDestination = false; @@ -2652,7 +2654,7 @@ void CGrpProfileWander::updateProfile(uint ticksSinceLastUpdate) // init a profile on the bot sbot->setAIProfile(new CBotProfileStandAtPos(sbot)); continue; - } + } if (profile->getAIProfileType() == BOT_MOVE_TO) { @@ -2662,24 +2664,24 @@ void CGrpProfileWander::updateProfile(uint ticksSinceLastUpdate) { if (!_DestinationReachedAll) { - + uint32 npcSize = (uint32)pgrp.bots().size(); uint32 reachedSize = (uint32)_NpcDestinationReached.size(); if (reachedSize!= npcSize) { _NpcDestinationReached.resize(npcSize); - // invalid the vector a new bot has arrived + // invalid the vector a new bot has arrived if (npcSize>reachedSize){ std::fill(_NpcDestinationReached.begin(), _NpcDestinationReached.end(), false); } } - + if ( !_NpcDestinationReached[i]) { _NpcDestinationReached[i] = true; aNpcHasReachDestination = true; } - + } - + // look arround for interesting target CAIVision vision; vision.updateBotsAndPlayers(_Grp->getPersistent().getAIInstance(), CAIVector(sbot->pos()), 10, 10); @@ -2731,7 +2733,7 @@ void CGrpProfileWander::updateProfile(uint ticksSinceLastUpdate) sbot->setVisualTarget(NULL); // now, set the idle activity with a random timer - + sbot->setAIProfile(_BotStandProfileFactory->createAIProfile(sbot)); CBotProfileWanderBase *wbs = safe_cast(sbot->getAIProfile()); if (wbs) @@ -2746,7 +2748,7 @@ void CGrpProfileWander::updateProfile(uint ticksSinceLastUpdate) waitMax = waitMin; else waitMax = waitMax > waitMin ? waitMax : waitMin; - } + } else { waitMin = float(DefaultWanderMinTimer); @@ -2757,7 +2759,7 @@ void CGrpProfileWander::updateProfile(uint ticksSinceLastUpdate) } continue; } - + if (profile->getAIProfileType()==_BotStandProfileType) { const CBotProfileWanderBase*const wbs = static_cast(sbot->getAIProfile()); @@ -2767,7 +2769,7 @@ void CGrpProfileWander::updateProfile(uint ticksSinceLastUpdate) if (!wbs->testTimer()) continue; } - + #ifdef NL_DEBUG nlassert(_RandomPos != NULL && _RandomPos->getRandomPosCount() != 0); #endif @@ -2790,7 +2792,7 @@ void CGrpProfileWander::updateProfile(uint ticksSinceLastUpdate) // time out, move to another point in the geometry RYAI_MAP_CRUNCH::CWorldPosition wp; - + if (_Social && CAIS::rand32(3) == 0) { // this time, we try to reach an npc in the neighbour @@ -2817,7 +2819,7 @@ void CGrpProfileWander::updateProfile(uint ticksSinceLastUpdate) uint32 first=0, last=(uint32)_NpcDestinationReached.size(); for ( ; first != last && _NpcDestinationReached[first]; ++first) {} - + if (first == last) { _DestinationReachedAll = true; @@ -2868,15 +2870,15 @@ void CGrpProfileWanderNoPrim::stateChangeProfile() } /* void CGrpProfileWanderNoPrim::affectZoneFromStateMachine() -{ +{ CSpawnGroupNpc* grp = static_cast(static_cast(_Grp)); CGroupNpc& pgrp = grp->getPersistent(); CAIState const* const state = pgrp.getActiveState(); - + if ( !state || !state->isPositional()) return; - + CAIStatePositional const* const sp = static_cast(state); if (!sp->shape().hasPoints()) { @@ -2919,7 +2921,7 @@ void CGrpProfileWanderNoPrim::beginProfile() } } -void CGrpProfileWanderNoPrim::addBot(CBot* bot) +void CGrpProfileWanderNoPrim::addBot(CBot* bot) { CSpawnBot *const spawnBot=bot->getSpawnObj(); if (!spawnBot) @@ -2938,7 +2940,7 @@ void CGrpProfileWanderNoPrim::addBot(CBot* bot) #endif spawnBot->setAIProfile(profile); } -void CGrpProfileWanderNoPrim::removeBot(CBot* bot) +void CGrpProfileWanderNoPrim::removeBot(CBot* bot) { } CPathCont* CGrpProfileWanderNoPrim::getPathCont(CBot const* bot) @@ -2962,10 +2964,10 @@ void CGrpProfileWanderNoPrim::updateProfile(uint ticksSinceLastUpdate) return; } - // check all bot to see if there need to move + // check all bot to see if there need to move CSpawnGroupNpc* grp = static_cast(static_cast(_Grp)); CGroupNpc &pgrp = grp->getPersistent(); - + for (uint i=0; i(pgrp.bots()[i]); @@ -2984,7 +2986,7 @@ void CGrpProfileWanderNoPrim::updateProfile(uint ticksSinceLastUpdate) // init a profile on the bot sbot->setAIProfile(new CBotProfileStandAtPos(sbot)); continue; - } + } if (profile->getAIProfileType() == BOT_MOVE_TO) { @@ -3043,7 +3045,7 @@ void CGrpProfileWanderNoPrim::updateProfile(uint ticksSinceLastUpdate) sbot->setVisualTarget(NULL); // now, set the idle activity with a random timer - + sbot->setAIProfile(_BotStandProfileFactory->createAIProfile(sbot)); CBotProfileWanderBase *wbs = safe_cast(sbot->getAIProfile()); if (wbs) @@ -3058,7 +3060,7 @@ void CGrpProfileWanderNoPrim::updateProfile(uint ticksSinceLastUpdate) waitMax = waitMin; else waitMax = waitMax > waitMin ? waitMax : waitMin; - } + } else { waitMin = float(DefaultWanderMinTimer); @@ -3071,7 +3073,7 @@ void CGrpProfileWanderNoPrim::updateProfile(uint ticksSinceLastUpdate) } continue; } - + if (profile->getAIProfileType()==_BotStandProfileType) { const CBotProfileWanderBase*const wbs = static_cast(sbot->getAIProfile()); @@ -3081,13 +3083,13 @@ void CGrpProfileWanderNoPrim::updateProfile(uint ticksSinceLastUpdate) if (!wbs->testTimer()) continue; } - + #ifdef NL_DEBUG nlassert(_NpcZone->getRandomPosCount()); #endif // time out, move to another point in the geometry RYAI_MAP_CRUNCH::CWorldPosition wp; - + if (_Social && CAIS::rand32(3) == 0) { // this time, we try to reach an npc in the neighbour @@ -3100,7 +3102,7 @@ void CGrpProfileWanderNoPrim::updateProfile(uint ticksSinceLastUpdate) } CBotProfileMoveTo* mts = new CBotProfileMoveTo(_NpcZone->getVerticalPos(), wp, sbot); sbot->setAIProfile(mts); - } + } } std::string CGrpProfileWanderNoPrim::getOneLineInfoString() const @@ -3125,7 +3127,7 @@ CGrpProfileStandAtStartPoint::~CGrpProfileStandAtStartPoint() { CBot *bot=*it; removeBot (bot); - } + } } CGrpProfileStandAtStartPoint::CBotPositionner::CBotPositionner(RYAI_MAP_CRUNCH::TAStarFlag flags) @@ -3133,7 +3135,7 @@ CGrpProfileStandAtStartPoint::CBotPositionner::CBotPositionner(RYAI_MAP_CRUNCH:: { } -CGrpProfileStandAtStartPoint::CBotPositionner::CBotPositionner(TVerticalPos verticalPos, CAIPos position, RYAI_MAP_CRUNCH::TAStarFlag flag) +CGrpProfileStandAtStartPoint::CBotPositionner::CBotPositionner(TVerticalPos verticalPos, CAIPos position, RYAI_MAP_CRUNCH::TAStarFlag flag) : _PathCont(flag) , _Position(position) , _VerticalPos(verticalPos) @@ -3141,7 +3143,7 @@ CGrpProfileStandAtStartPoint::CBotPositionner::CBotPositionner(TVerticalPos vert { _PathCont.setDestination(verticalPos, position); } - + CGrpProfileStandAtStartPoint::CBotPositionner::~CBotPositionner() { } @@ -3170,7 +3172,7 @@ void CGrpProfileStandAtStartPoint::beginProfile() { PROFILE_LOG("group", "stand_at_start_point", "begin", ""); CMoveProfile::beginProfile(); - + setCurrentValidPos(); _Finished = false; } @@ -3193,7 +3195,7 @@ void CGrpProfileStandAtStartPoint::resumeProfile() sbot->setAIProfile(new CBotProfileStandAtPos(sbot)); break; } - + } setCurrentValidPos(); @@ -3203,12 +3205,12 @@ void CGrpProfileStandAtStartPoint::resumeProfile() void CGrpProfileStandAtStartPoint::addBot(CBot* bot) { CBotNpc* botNpc = NLMISC::safe_cast(bot); - + CGroupNpc& grp = botNpc->grp(); #ifdef NL_DEBUG nlassert(grp.getSpawnObj()); -#endif - CAIStatePositional *grpState=NLMISC::safe_cast(grp.getCAIState()); +#endif + CAIStatePositional *grpState=NLMISC::safe_cast(grp.getCAIState()); _NpcList[bot]=new CBotPositionner (botNpc->getStartVerticalPos(), botNpc->getStartPos(), botNpc->getGroup().getAStarFlag()); CSpawnBot *const sbot=bot->getSpawnObj(); @@ -3222,7 +3224,7 @@ void CGrpProfileStandAtStartPoint::removeBot(CBot* bot) if (it==_NpcList.end()) return; - + CSpawnBotNpc* const spawnBot = NLMISC::safe_cast(bot)->getSpawn(); if (spawnBot) spawnBot->setAIProfile(new CBotProfileStandAtPos(spawnBot)); @@ -3254,7 +3256,7 @@ void CGrpProfileStandAtStartPoint::updateProfile(uint ticksSinceLastUpdate) CGroupNpc &persGrp=NLMISC::safe_cast(_Grp.ptr())->getPersistent(); CAIStatePositional *grpState=static_cast(persGrp.getCAIState()); - + uint32 nbAtDest=0; uint32 nbNewAtDest=0; @@ -3278,7 +3280,7 @@ void CGrpProfileStandAtStartPoint::updateProfile(uint ticksSinceLastUpdate) case BOT_FOLLOW_POS: { CBotProfileFollowPos* prof = NLMISC::safe_cast(sbot->getAIProfile()); - + if (prof->_Status==CFollowPath::FOLLOW_ARRIVED) { sbot->setTheta(botPos->_Position.theta()); @@ -3294,7 +3296,7 @@ void CGrpProfileStandAtStartPoint::updateProfile(uint ticksSinceLastUpdate) nbAtDest++; } } - + } break; default: // push the correct comportment. @@ -3303,7 +3305,7 @@ void CGrpProfileStandAtStartPoint::updateProfile(uint ticksSinceLastUpdate) } break; } - + } // first to arrived ? @@ -3362,11 +3364,11 @@ void CGrpProfileEscorted::endProfile() } } -void CGrpProfileEscorted::stateChangeProfile() +void CGrpProfileEscorted::stateChangeProfile() { CGrpProfileNormal::beginProfile(); } - + void CGrpProfileEscorted::updateProfile(uint ticksSinceLastUpdate) { H_AUTO(GrpEscortedProfileUpdate); @@ -3378,7 +3380,7 @@ void CGrpProfileEscorted::updateProfile(uint ticksSinceLastUpdate) if (teamId == CTEAM::InvalidTeamId) { - // no escort team assigned, can't move! + // no escort team assigned, can't move! _EscortTeamInRange = false; return; } @@ -3435,7 +3437,7 @@ void CGrpProfileEscorted::updateProfile(uint ticksSinceLastUpdate) } } } - + if (_EscortTeamInRange) { if (escortAway) @@ -3454,12 +3456,12 @@ void CGrpProfileEscorted::updateProfile(uint ticksSinceLastUpdate) GrpRef.processStateEvent(GrpRef.mgr().getStateMachine()->EventEscortBack); } } - + if (_GroupFighting) { if (!_Grp->fightProfile().getAIProfile()) _Grp->fightProfile().setAIProfile(_Grp.ptr(), &GrpProfileFightFactory, false); - + _Grp->fightProfile().mayUpdateProfile(ticksSinceLastUpdate); CFightProfile* profile = NLMISC::safe_cast(_Grp->fightProfile().getAIProfile()); @@ -3484,17 +3486,17 @@ void CGrpProfileEscorted::updateProfile(uint ticksSinceLastUpdate) // set the fighting comportment. if (!_Grp->fightProfile().getAIProfile()) _Grp->fightProfile().setAIProfile(_Grp.ptr(), &GrpProfileFightFactory, false); - + setGroupFighting(true); } } } } - + if (_Grp->movingProfile().getAIProfileType() == AITYPES::MOVE_FOLLOW_ROUTE && !_GroupFighting) { CGrpProfileFollowRoute* prof = NLMISC::safe_cast(_Grp->movingProfile().getAIProfile()); - + if (prof) { prof->stopNpc(!_EscortTeamInRange); @@ -3545,13 +3547,13 @@ void CGrpProfileGuardEscorted::endProfile() _GuardProfile->endProfile(); } -void CGrpProfileGuardEscorted::stateChangeProfile() +void CGrpProfileGuardEscorted::stateChangeProfile() { CGrpProfileNormal::beginProfile(); _EscortedProfile->stateChangeProfile(); _GuardProfile->stateChangeProfile(); } - + void CGrpProfileGuardEscorted::updateProfile(uint ticksSinceLastUpdate) { H_AUTO(GrpEscortedGuardProfileUpdate); @@ -3592,7 +3594,7 @@ void CGrpProfileSquad::beginProfile() { PROFILE_LOG("group", "squad", "begin", ""); CGrpProfileFaction::beginProfile(); - CGroupNpc& thisGrpNpc = _Grp->getPersistent(); + CGroupNpc& thisGrpNpc = _Grp->getPersistent(); // Set aggro parameters thisGrpNpc._AggroRange = 25; @@ -3838,10 +3840,10 @@ std::string CGrpProfileFaction::scriptFactionToFameFaction(std::string name) } bool CGrpProfileFaction::scriptFactionToFameFactionGreaterThan(string name) -{ +{ if (name.find("<") != string::npos) return false; - + return true; } @@ -3884,11 +3886,11 @@ void CGrpProfileFaction::checkTargetsAround() { if (!_checkTargetTimer.test()) return; - - CGroupNpc& thisGrpNpc = _Grp->getPersistent(); - - _checkTargetTimer.set(thisGrpNpc._UpdateNbTicks+CAIS::rand16(2)); // every _UpdateNbTicks+1 seconds. - + + CGroupNpc& thisGrpNpc = _Grp->getPersistent(); + + _checkTargetTimer.set(thisGrpNpc._UpdateNbTicks+CAIS::rand16(2)); // every _UpdateNbTicks+1 seconds. + initFameFactions(); CPropertySetWithExtraList const& thisFaction = thisGrpNpc.faction(); CPropertySetWithExtraList const& thisFriendFactions = thisGrpNpc.friendFaction(); @@ -3899,20 +3901,20 @@ void CGrpProfileFaction::checkTargetsAround() bool const assistBots = !thisFriendFactions.empty() && !bNoAssist; bool const attackPlayers = (!thisEnnemyFactions.extraSetEmpty()) || thisEnnemyFactions.containsPartOfStrictFilter("Famous*") || thisEnnemyFactions.have(AITYPES::CPropertyId("Player")) || thisEnnemyFactions.containsPartOfStrictFilter("outpost:*"); bool const attackBots = !thisEnnemyFactions.empty(); - + CAIVision Vision; breakable { CAIVector centerPos; if (!_Grp->calcCenterPos(centerPos)) // true if there's some bots in the group. break; - - const uint32 playerRadius=(uint32)(assistPlayers||attackPlayers?thisGrpNpc._AggroRange:0); - const uint32 botRadius=(uint32)(assistBots||attackBots?thisGrpNpc._AggroRange:0); - + + const uint32 playerRadius=assistPlayers||attackPlayers?thisGrpNpc._AggroRange:0; + const uint32 botRadius=assistBots||attackBots?thisGrpNpc._AggroRange:0; + Vision.updateBotsAndPlayers(thisGrpNpc.getAIInstance(), centerPos, playerRadius, botRadius); } - + // Assist players if (assistPlayers) { @@ -4030,7 +4032,7 @@ void CGrpProfileFaction::checkTargetsAround() void CGrpProfileFaction::updateProfile(uint ticksSinceLastUpdate) { - checkTargetsAround (); + checkTargetsAround (); CGrpProfileNormal::updateProfile(ticksSinceLastUpdate); } @@ -4103,7 +4105,7 @@ NLMISC::CSmartPtr CGrpProfileBanditFactory::createAIProfile(CProfile else _DefaultAggroRange = 15.0f; } - + return new CGrpProfileBandit(owner); } float CGrpProfileBanditFactory::getDefaultBanditAggroRange() @@ -4131,7 +4133,7 @@ float getDistBetWeen(CAIEntityPhysical& creat1, CAIEntityPhysical& creat2) { // coz player position is not updated really 'goodly' as it can be in a invalid ai map position. float angTo = (creat1.pos().angleTo(creat2.pos())).asRadians(); - + return creat1.getCollisionDist(angTo) + creat2.getCollisionDist(-angTo); } @@ -4139,7 +4141,7 @@ float getDistBetWeen(CAIEntityPhysical& creat1, CAIEntityPhysical& creat2) // CBotProfileMoveTo // ////////////////////////////////////////////////////////////////////////////// -CBotProfileMoveTo::CBotProfileMoveTo(AITYPES::TVerticalPos verticalPos, RYAI_MAP_CRUNCH::CWorldPosition const& dest, CProfileOwner* owner) +CBotProfileMoveTo::CBotProfileMoveTo(AITYPES::TVerticalPos verticalPos, RYAI_MAP_CRUNCH::CWorldPosition const& dest, CProfileOwner* owner) : CAIBaseProfile() , _VerticalPos(verticalPos) , _Dest(dest) @@ -4176,16 +4178,16 @@ void CBotProfileMoveTo::updateProfile(uint ticksSinceLastUpdate) if (!_Bot->canMove()) return; - + if (_Status != CFollowPath::FOLLOW_ARRIVED) { static const std::string runParameter("running"); float dist; if (_Bot->getPersistent().getOwner()->getSpawnObj()->checkProfileParameter(runParameter)) - dist =_Bot->runSpeed()*ticksSinceLastUpdate; + dist =_Bot->runSpeed()*ticksSinceLastUpdate; else dist =_Bot->walkSpeed()*ticksSinceLastUpdate; - + _Status = CFollowPath::getInstance()->followPath( _Bot, _PathPos, @@ -4196,7 +4198,7 @@ void CBotProfileMoveTo::updateProfile(uint ticksSinceLastUpdate) if (_Status==CFollowPath::FOLLOW_NO_PATH) { // get a base pointer to allow virtual call to work - + nlwarning("Follow No Path : %s", _Bot->getPersistent().getOneLineInfoString().c_str()); } } @@ -4273,9 +4275,9 @@ void CBotProfileFollowPos::updateProfile(uint ticksSinceLastUpdate) speed = std::min(_Bot->runSpeed(), _MaxRunSpeed); else speed = std::min(_Bot->walkSpeed(), _MaxWalkSpeed); - - dist = speed*ticksSinceLastUpdate; - + + dist = speed*ticksSinceLastUpdate; + CPathCont &pathContRef=*_PathCont; if (_Status!=CFollowPath::FOLLOW_NO_PATH) { @@ -4407,7 +4409,7 @@ void CBotProfileForage::beginProfile() PROFILE_LOG("bot", "forage", "begin", ""); // begin first forage in 3-10 second _ForageTimer.set(30+CAIS::rand32(70)); - + static const NLMISC::CSheetId forageTool("itforage.sitem"); /* AISHEETS::ICreature *cs = new AISHEETS::CCreature(*_Bot->getPersistent().getSheet()); @@ -4419,7 +4421,7 @@ void CBotProfileForage::beginProfile() _TemporarySheetUsed = true; */ nlerror("This profile has been broken (above block commented), it shouldn't be used"); - + // begin propecting _Bot->setBehaviour(MBEHAV::PROSPECTING); } @@ -4452,10 +4454,10 @@ void CBotProfileForage::updateProfile(uint ticksSinceLastUpdate) CAngle a = _Bot->theta(); CAngle newAngle(CAIS::randPlusMinus(CAngle::PI/4)); _Bot->setTheta(a+newAngle); - + // begin foraging _Bot->setBehaviour(MBEHAV::EXTRACTING); - + // forage for 10 to 15 sec _ForageTimer.set(100+CAIS::rand32(50)); } @@ -4463,7 +4465,7 @@ void CBotProfileForage::updateProfile(uint ticksSinceLastUpdate) { // end foraging _Bot->setBehaviour(MBEHAV::PROSPECTING); - + // wait 20-30s before next forage _ForageTimer.set(250+CAIS::rand32(50)); } @@ -4515,7 +4517,7 @@ void CGrpProfileNormal::setGroupFighting(bool groupFighting) if (_GroupFighting!=groupFighting) { _GroupFighting=groupFighting; - + CGroupNpc &grp=_Grp->getPersistent(); if (groupFighting) grp.processStateEvent(grp.getEventContainer().EventGroupBeginFight); @@ -4545,7 +4547,7 @@ void CSlaveProfile::beginProfile() continue; addBot(bot); } -} +} void CSlaveProfile::updateProfile(uint ticksSinceLastUpdate) { @@ -4555,7 +4557,7 @@ void CSlaveProfile::updateProfile(uint ticksSinceLastUpdate) // CMoveProfile // ////////////////////////////////////////////////////////////////////////////// -CMoveProfile::CMoveProfile(CProfileOwner* owner) +CMoveProfile::CMoveProfile(CProfileOwner* owner) : CSlaveProfile(owner) , _MaxRunSpeed(FLT_MAX) , _MaxWalkSpeed(FLT_MAX) @@ -4568,11 +4570,11 @@ void CMoveProfile::resumeBot(CBot const* bot) CSpawnBot* spawnBot = bot->getSpawnObj(); if (!spawnBot) return; - + CPathCont* pathCont = getPathCont(bot); if (!pathCont) return; - + spawnBot->setAIProfile(new CBotProfileFollowPos(pathCont, spawnBot)); } diff --git a/ryzom/server/src/ai_service/family_profile_tribe.cpp b/ryzom/server/src/ai_service/family_profile_tribe.cpp index adf33b3c2..292a09010 100644 --- a/ryzom/server/src/ai_service/family_profile_tribe.cpp +++ b/ryzom/server/src/ai_service/family_profile_tribe.cpp @@ -55,7 +55,7 @@ IAiFactory *_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 *_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 &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 &dbgPtr=*it; // CGrpProfileDynFight *dynFight=safe_cast(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 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 *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 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 > &players = Vision.players(); - + std::vector >::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(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(movingProfile.getAIProfile()); - + _CurrentZone=fp->currentZone(); if (!fp->destinationReach()) diff --git a/ryzom/server/src/ai_service/nf_grp.cpp b/ryzom/server/src/ai_service/nf_grp.cpp index b37432457..f3f6b1bdc 100644 --- a/ryzom/server/src/ai_service/nf_grp.cpp +++ b/ryzom/server/src/ai_service/nf_grp.cpp @@ -89,21 +89,21 @@ void despawn_f_(CStateInstance* entity, CScriptStack& stack) { float const immediatly = stack.top(); stack.pop(); - + if (!entity) { nlwarning("despawnInstance failed"); return; } - - CGroup* const grp = entity->getGroup(); + + CGroup* const grp = entity->getGroup(); if (!grp) { - nlwarning("despawn : entity '%s'%s is not a group ? ", + nlwarning("despawn : entity '%s'%s is not a group ? ", entity->aliasTreeOwner()->getAliasFullName().c_str(), entity->aliasTreeOwner()->getAliasString().c_str()); return; - } + } grp->despawnBots(immediatly!=0); } @@ -118,37 +118,37 @@ Arguments: -> f(Immediatly) @return 1 if group is spawned @code -(alive)isAlived(); +(alive)isAlived(); @endcode */ // CGroup void isAlived__f(CStateInstance* entity, CScriptStack& stack) { - + if (!entity) { stack.push(0.0f); return; } - - CGroup* const grp = entity->getGroup(); + + CGroup* const grp = entity->getGroup(); if (!grp) { - nlwarning("isAlived__f : entity '%s'%s is not a group ? ", + nlwarning("isAlived__f : entity '%s'%s is not a group ? ", entity->aliasTreeOwner()->getAliasFullName().c_str(), - entity->aliasTreeOwner()->getAliasString().c_str()); + entity->aliasTreeOwner()->getAliasString().c_str()); stack.push(0.0f); return; - } - + } + if (!grp->isSpawned()) { stack.push(0.0f); return; } - + for (uint i=0; ibots().size(); ++i) { const CBot *const bot = grp->getBot(i); @@ -197,12 +197,12 @@ void newNpcChildGroupPos_ssfff_c(CStateInstance* entity, CScriptStack& stack) stack.pop(); float const x = stack.top(); stack.pop(); - + IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); if (!aiInstance) return; - + if (dispersionRadius<0.) dispersionRadius = 0.; stack.push(spawnNewGroup(entity, stack, aiInstance, CAIVector(x, y), -1, dispersionRadius)); @@ -235,12 +235,12 @@ void newNpcChildGroupPos_ssfff_(CStateInstance* entity, CScriptStack& stack) stack.pop(); float const x = stack.top(); stack.pop(); - + IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); if (!aiInstance) return; - + if (dispersionRadius<0.) dispersionRadius = 0.; spawnNewGroup(entity, stack, aiInstance, CAIVector(x, y), -1, dispersionRadius); @@ -324,12 +324,12 @@ void newNpcChildGroupPosMl_ssffff_c(CStateInstance* entity, CScriptStack& stack) stack.pop(); float const x = stack.top(); stack.pop(); - + IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); if (!aiInstance) return; - + if (dispersionRadius<0.) dispersionRadius = 0.; stack.push(spawnNewGroup(entity, stack, aiInstance, CAIVector(x,y), -1, dispersionRadius)); @@ -363,12 +363,12 @@ void newNpcChildGroupPosMl_ssffff_(CStateInstance* entity, CScriptStack& stack) stack.pop(); float const x = stack.top(); stack.pop(); - + IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); if (!aiInstance) return; - + if (dispersionRadius<0.) dispersionRadius = 0.; spawnNewGroup(entity, stack, aiInstance, CAIVector(x,y), -1, dispersionRadius); @@ -444,17 +444,17 @@ Arguments: -> f(x), f(y) void getMidPos__ff(CStateInstance* entity, CScriptStack& stack) { CGroup* const group = entity->getGroup(); - + CAIVector vect; if (group->isSpawned()) { if (!group->getSpawnObj()->calcCenterPos(vect)) group->getSpawnObj()->calcCenterPos(vect, true); } - + float x((float)vect.x().asDouble()); float y((float)vect.y().asDouble()); - + stack.push(y); stack.push(x); } @@ -484,12 +484,12 @@ void newNpcChildGroup_sssf_c(CStateInstance* entity, CScriptStack& stack) stack.pop(); TStringId const zoneName = CStringMapper::map(stack.top()); stack.pop(); - + IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); if (!aiInstance) return; - + CNpcZone const* spawnZone = aiInstance->getZone(zoneName); if (!spawnZone) { @@ -533,12 +533,12 @@ void newNpcChildGroup_sssf_(CStateInstance* entity, CScriptStack& stack) stack.pop(); TStringId const zoneName = CStringMapper::map(stack.top()); stack.pop(); - + IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); if (!aiInstance) return; - + CNpcZone const* spawnZone = aiInstance->getZone(zoneName); if (!spawnZone) { @@ -633,12 +633,12 @@ void newNpcChildGroupMl_sssff_c(CStateInstance* entity, CScriptStack& stack) stack.pop(); TStringId const zoneName = CStringMapper::map(stack.top()); stack.pop(); - + IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); if (!aiInstance) return; - + CNpcZone const* spawnZone = aiInstance->getZone(zoneName); if (!spawnZone) { @@ -685,12 +685,12 @@ void newNpcChildGroupMl_sssff_(CStateInstance* entity, CScriptStack& stack) stack.pop(); TStringId const zoneName = CStringMapper::map(stack.top()); stack.pop(); - + IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); if (!aiInstance) return; - + CNpcZone const* spawnZone = aiInstance->getZone(zoneName); if (!spawnZone) { @@ -786,7 +786,7 @@ void spawnManager_s_(CStateInstance* entity, CScriptStack& stack) nlwarning("SpawnManager error entity not spawned"); break; } - + IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); if (!aiInstance) @@ -828,7 +828,7 @@ void despawnManager_s_(CStateInstance* entity, CScriptStack& stack) { string ManagerName = stack.top(); stack.pop(); - + breakable { if (!entity) @@ -836,7 +836,7 @@ void despawnManager_s_(CStateInstance* entity, CScriptStack& stack) nlwarning("DespawnManager error entity not spawned"); break; } - + IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); if (!aiInstance) @@ -884,7 +884,7 @@ void getGroupTemplateWithFlags_sss_s(CStateInstance* entity, CScriptStack& stack stack.pop(); string oneOfProperties = stack.top(); stack.pop(); - + // If no AI instance return IManagerParent* managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* aiInstance = dynamic_cast(managerParent); @@ -893,12 +893,12 @@ void getGroupTemplateWithFlags_sss_s(CStateInstance* entity, CScriptStack& stack stack.push(string()); return; } - + // Fill the property sets. AITYPES::CPropertySet oneOfSet = readSet(oneOfProperties); AITYPES::CPropertySet mandatorySet = readSet(mandatoryProperties); AITYPES::CPropertySet exceptSet = readSet(exceptProperties); - + vector const*> groupDescs; FOREACH (itCont, CCont, aiInstance->continents()) { @@ -920,14 +920,14 @@ void getGroupTemplateWithFlags_sss_s(CStateInstance* entity, CScriptStack& stack } } } - + if (groupDescs.size()==0) { nlwarning("getGroupTemplateWithFlags failed: no group template found that contains all of '%s' and a part of'%s' ", mandatoryProperties.c_str(), oneOfProperties.c_str()); stack.push(string()); return; } - + CGroupDesc const* groupDesc = groupDescs[CAIS::rand16((uint32)groupDescs.size())]; stack.push(groupDesc->getFullName()); return; @@ -998,7 +998,7 @@ void getZoneWithFlags_ssss_s(CStateInstance* entity, CScriptStack& stack) stack.pop(); string oneOfProperties = stack.top(); stack.pop(); - + // If no AI instance return IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); @@ -1007,7 +1007,7 @@ void getZoneWithFlags_ssss_s(CStateInstance* entity, CScriptStack& stack) stack.push(string()); return; } - + // Fill the property sets. AITYPES::CPropertySet oneOfSet = readSet(oneOfProperties); AITYPES::CPropertySet mandatorySet = readSet(mandatoryProperties); @@ -1079,7 +1079,7 @@ void getNearestZoneWithFlags_ffsss_s(CStateInstance* entity, CScriptStack& stack stack.pop(); float const x = stack.top(); stack.pop(); - + // If no AI instance return IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); @@ -1088,14 +1088,14 @@ void getNearestZoneWithFlags_ffsss_s(CStateInstance* entity, CScriptStack& stack stack.push(string()); return; } - + // Fill the property sets. AITYPES::CPropertySet oneOfSet = readSet(oneOfProperties); AITYPES::CPropertySet mandatorySet = readSet(mandatoryProperties); AITYPES::CPropertySet exceptSet = readSet(exceptProperties); // Create the scorer CZoneScorerMandatoryAndOneOfAndDistAndSpace const scorer(oneOfSet, mandatorySet, exceptSet, CAIVector(x, y)); - + getZoneWithFlags_helper(entity, stack, aiInstance, scorer); } @@ -1160,7 +1160,7 @@ void getNearestZoneWithFlagsStrict_ffsss_s(CStateInstance* entity, CScriptStack& stack.pop(); float const x = stack.top(); stack.pop(); - + // If no AI instance return IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); @@ -1169,14 +1169,14 @@ void getNearestZoneWithFlagsStrict_ffsss_s(CStateInstance* entity, CScriptStack& stack.push(string()); return; } - + // Fill the property sets. AITYPES::CPropertySet oneOfSet = readSet(oneOfProperties); AITYPES::CPropertySet mandatorySet = readSet(mandatoryProperties); AITYPES::CPropertySet exceptSet = readSet(exceptProperties); // Create the scorer const CZoneScorerMandatoryAndOneOfAndDist scorer(oneOfSet, mandatorySet, exceptSet, CAIVector(x, y)); - + getZoneWithFlags_helper(entity, stack, aiInstance, scorer); } @@ -1239,7 +1239,7 @@ void getNeighbourZoneWithFlags_ssss_s(CStateInstance* entity, CScriptStack& stac stack.pop(); TStringId curZoneId = CStringMapper::map(stack.top()); stack.pop(); - + // If no AI instance return IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); CAIInstance* const aiInstance = dynamic_cast(managerParent); @@ -1248,7 +1248,7 @@ void getNeighbourZoneWithFlags_ssss_s(CStateInstance* entity, CScriptStack& stac stack.push(string()); return; } - + // If curzone is invalid return CNpcZone const* const curZone = aiInstance->getZone(curZoneId); if (!curZone) @@ -1261,21 +1261,21 @@ void getNeighbourZoneWithFlags_ssss_s(CStateInstance* entity, CScriptStack& stac stack.push(string()); return; } - + // Fill the property sets. AITYPES::CPropertySet oneOfSet = readSet(oneOfProperties); AITYPES::CPropertySet mandatorySet = readSet(mandatoryProperties); AITYPES::CPropertySet exceptSet = readSet(exceptProperties); // Create the scorer CZoneScorerMandatoryAndOneOfPlusExcept const scorer(oneOfSet, mandatorySet, exceptSet, curZone); - + vector cells; curZone->getOwner()->getNeighBourgCellList(cells); cells.push_back(curZone->getOwner()); std::random_shuffle(cells.begin(), cells.end()); - + CNpcZone const* const newZone = CCellZone::lookupNpcZoneScorer(cells, scorer); - + if (newZone) { stack.push(newZone->getAliasTreeOwner().getAliasFullName()); @@ -1286,7 +1286,7 @@ void getNeighbourZoneWithFlags_ssss_s(CStateInstance* entity, CScriptStack& stac nlwarning(" - oneOfProperties: %s", oneOfProperties.c_str()); nlwarning(" - mandatoryProperties: %s", mandatoryProperties.c_str()); nlwarning(" - exceptProperties: %s", exceptProperties.c_str()); - + stack.push(string()); return; } @@ -1338,9 +1338,9 @@ void setAggro_ff_(CStateInstance* entity, CScriptStack& stack) { sint32 updateNbTicks = (sint32)(float)stack.top(); stack.pop(); - float aggroRange = stack.top(); + uint32 aggroRange = (uint32)(float)stack.top(); stack.pop(); - + CGroup* const grp = entity->getGroup(); if (grp) { @@ -1369,7 +1369,7 @@ void setCanAggro_f_(CStateInstance* entity, CScriptStack& stack) { bool canAggro = ((float)stack.top())!=0.f; stack.pop(); - + FOREACH(bot, CCont, entity->getGroup()->bots()) { if (!bot->isSpawned()) @@ -1455,11 +1455,11 @@ void setMode_s_(CStateInstance* entity, CScriptStack& stack) { string NewMode = stack.top(); stack.pop(); - + MBEHAV::EMode mode = MBEHAV::stringToMode(NewMode); if (mode==MBEHAV::UNKNOWN_MODE) return; - + FOREACH(botIt, CCont, entity->getGroup()->bots()) { if (botIt->getSpawnObj()) @@ -1487,9 +1487,9 @@ void setAutoSpawn_f_(CStateInstance* entity, CScriptStack& stack) { float const autoSpawn = stack.top(); stack.pop(); - + CGroup* group = entity->getGroup(); - + group->setAutoSpawn(autoSpawn!=0.f); } @@ -1514,14 +1514,14 @@ void setMaxHP_ff_(CStateInstance* entity, CScriptStack& stack) { bool setFull = ((float)stack.top() != 0.f); stack.pop(); float maxHp = ((float)stack.top()); stack.pop(); - + CChangeCreatureMaxHPMsg& msgList = CAIS::instance().getCreatureChangeMaxHP(); - + FOREACH(bot, CCont, entity->getGroup()->bots()) { if (!bot->isSpawned()) continue; - + if (maxHp > 0) { CSpawnBot* const sbot = bot->getSpawnObj(); @@ -1551,16 +1551,16 @@ void setHPLevel_f_(CStateInstance* entity, CScriptStack& stack) { float coef = stack.top(); stack.pop(); - + CChangeCreatureHPMsg& msgList = CAIS::instance().getCreatureChangeHP(); - + FOREACH(bot, CCont, entity->getGroup()->bots()) { if (!bot->isSpawned()) continue; - + CSpawnBot* const sbot = bot->getSpawnObj(); - + msgList.Entities.push_back(sbot->dataSetRow()); msgList.DeltaHp.push_back((sint32)(sbot->maxHitPoints()*coef)); } @@ -1596,16 +1596,16 @@ void setHPScale_f_(CStateInstance* entity, CScriptStack& stack) { float coef = stack.top(); stack.pop(); - + CChangeCreatureHPMsg& msgList = CAIS::instance().getCreatureChangeHP(); - + FOREACH(bot, CCont, entity->getGroup()->bots()) { if (!bot->isSpawned()) continue; - + CSpawnBot* const sbot = bot->getSpawnObj(); - + msgList.Entities.push_back(sbot->dataSetRow()); msgList.DeltaHp.push_back((sint32)( sbot->maxHitPoints() *coef - sbot->currentHitPoints()) ); } @@ -1631,16 +1631,16 @@ Arguments: s(actionName),s(url) -> void setUrl_ss_(CStateInstance* entity, CScriptStack& stack) { CGroup* group = entity->getGroup(); - - std::string url = (std::string)stack.top();stack.pop(); - std::string actionName = (std::string)stack.top();stack.pop(); - + + std::string url = (std::string)stack.top();stack.pop(); + std::string actionName = (std::string)stack.top();stack.pop(); + CCreatureSetUrlMsg msg; FOREACH(botIt, CCont, group->bots()) { CSpawnBot* pbot = botIt->getSpawnObj(); if (pbot!=NULL) - { + { msg.Entities.push_back(pbot->dataSetRow()); } } @@ -1672,16 +1672,16 @@ void scaleHP_f_(CStateInstance* entity, CScriptStack& stack) { float coef = stack.top(); stack.pop(); - + CChangeCreatureHPMsg& msgList = CAIS::instance().getCreatureChangeHP(); - + FOREACH(bot, CCont, entity->getGroup()->bots()) { if (!bot->isSpawned()) continue; - + CSpawnBot* const sbot = bot->getSpawnObj(); - + msgList.Entities.push_back(sbot->dataSetRow()); msgList.DeltaHp.push_back((sint32)(sbot->currentHitPoints()*coef)); } @@ -1707,19 +1707,19 @@ Arguments: f(alias),f(Coef), -> void setBotHPScaleByAlias_fs_(CStateInstance* entity, CScriptStack& stack) { uint32 alias = LigoConfig.aliasFromString((string)stack.top()) ; stack.pop(); - + float coef = stack.top(); stack.pop(); - + CChangeCreatureHPMsg& msgList = CAIS::instance().getCreatureChangeHP(); - + FOREACH(bot, CCont, entity->getGroup()->bots()) { - + if (bot->getAlias() != alias) { continue; } - if (!bot->isSpawned()) return; - + if (!bot->isSpawned()) return; + CSpawnBot* const sbot = bot->getSpawnObj(); - + msgList.Entities.push_back(sbot->dataSetRow()); msgList.DeltaHp.push_back((sint32)( sbot->maxHitPoints() *coef - sbot->currentHitPoints()) ); } @@ -1728,7 +1728,7 @@ void setBotHPScaleByAlias_fs_(CStateInstance* entity, CScriptStack& stack) /** @page code -@subsection downScaleHP_f_ +@subsection downScaleHP_f_ Scales the bots HP down. Arguments: f(Coef) -> @@ -1744,17 +1744,17 @@ void downScaleHP_f_(CStateInstance* entity, CScriptStack& stack) { float coef = stack.top(); stack.pop(); - + CChangeCreatureHPMsg& msgList = CAIS::instance().getCreatureChangeHP(); - + clamp(coef, 0.f, 1.f); FOREACH(bot, CCont, entity->getGroup()->bots()) { if (!bot->isSpawned()) continue; - + CSpawnBot* const sbot = bot->getSpawnObj(); - + msgList.Entities.push_back(sbot->dataSetRow()); msgList.DeltaHp.push_back((sint32)(sbot->currentHitPoints()*(coef-1))); } @@ -1778,9 +1778,9 @@ void upScaleHP_f_(CStateInstance* entity, CScriptStack& stack) { float coef = stack.top(); stack.pop(); - + CChangeCreatureHPMsg& msgList = CAIS::instance().getCreatureChangeHP(); - + clamp(coef, 0.f, 1.f); FOREACH(bot, CCont, entity->getGroup()->bots()) { @@ -1813,16 +1813,16 @@ void addHP_f_(CStateInstance* entity, CScriptStack& stack) { float addHP = stack.top(); stack.pop(); - + CChangeCreatureHPMsg& msgList = CAIS::instance().getCreatureChangeHP(); - + FOREACH(bot, CCont, entity->getGroup()->bots()) { if (!bot->isSpawned()) continue; - + CSpawnBot* const sbot = bot->getSpawnObj(); - + msgList.Entities.push_back(sbot->dataSetRow()); msgList.DeltaHp.push_back((sint32)(sbot->currentHitPoints()+addHP)); } @@ -1859,7 +1859,7 @@ void aiAction_s_(CStateInstance* entity, CScriptStack& stack) nlwarning("Action SheetId Unknown %s", actionName.c_str()); return; } - + FOREACH(botIt, CCont, entity->getGroup()->bots()) { CSpawnBot* pbot = botIt->getSpawnObj(); @@ -1868,18 +1868,18 @@ void aiAction_s_(CStateInstance* entity, CScriptStack& stack) CSpawnBot& bot = *pbot; if (!bot.getAIProfile()) continue; // OK - + CBotProfileFight* profile = dynamic_cast(bot.getAIProfile()); if (!profile) continue; // OK - + if (!profile->atAttackDist()) continue; // NOT OK - + TDataSetRow dataSetRow; if ((CAIEntityPhysical*)bot.getTarget()) dataSetRow = bot.getTarget()->dataSetRow(); - + CEGSExecuteAiActionMsg msg(bot.dataSetRow(), dataSetRow, action->SheetId(), bot._DamageCoef, bot._DamageSpeedCoef); msg.send(egsString); bot.setActionFlags(RYZOMACTIONFLAGS::Attacks); @@ -1919,7 +1919,7 @@ void aiActionSelf_s_(CStateInstance* entity, CScriptStack& stack) nlwarning("Action SheetId Unknown %s", actionName.c_str()); return; } - + FOREACH(botIt, CCont, entity->getGroup()->bots()) { CSpawnBot* pbot = botIt->getSpawnObj(); @@ -1953,9 +1953,9 @@ void addProfileParameter_s_(CStateInstance* entity, CScriptStack& stack) { std::string name = (std::string)stack.top(); stack.pop(); - + CGroup* group = entity->getGroup(); - + if (group->isSpawned()) group->getSpawnObj()->addProfileParameter(name, "", 0.f); } @@ -1983,9 +1983,9 @@ void addProfileParameter_ss_(CStateInstance* entity, CScriptStack& stack) stack.pop(); std::string name = (std::string)stack.top(); stack.pop(); - + CGroup* group = entity->getGroup(); - + if (group->isSpawned()) group->getSpawnObj()->addProfileParameter(name, value, 0.f); } @@ -2012,9 +2012,9 @@ void addProfileParameter_sf_(CStateInstance* entity, CScriptStack& stack) stack.pop(); std::string name = (std::string)stack.top(); stack.pop(); - + CGroup* group = entity->getGroup(); - + if (group->isSpawned()) group->getSpawnObj()->addProfileParameter(name, "", value); } @@ -2038,9 +2038,9 @@ void removeProfileParameter_s_(CStateInstance* entity, CScriptStack& stack) { std::string name = (std::string)stack.top(); stack.pop(); - + CGroup* group = entity->getGroup(); - + if (group->isSpawned()) group->getSpawnObj()->removeProfileParameter(name); } @@ -2064,7 +2064,7 @@ void addPersistentProfileParameter_s_(CStateInstance* entity, CScriptStack& stac { std::string name = (std::string)stack.top(); stack.pop(); - + CGroup* group = entity->getGroup(); if (group->isSpawned()) @@ -2095,8 +2095,8 @@ void addPersistentProfileParameter_ss_(CStateInstance* entity, CScriptStack& sta stack.pop(); std::string name = (std::string)stack.top(); stack.pop(); - - CGroup* group = entity->getGroup(); + + CGroup* group = entity->getGroup(); if (group->isSpawned()) group->getSpawnObj()->addProfileParameter(name, value, 0.f); @@ -2126,7 +2126,7 @@ void addPersistentProfileParameter_sf_(CStateInstance* entity, CScriptStack& sta stack.pop(); std::string name = (std::string)stack.top(); stack.pop(); - + CGroup* group = entity->getGroup(); if (group->isSpawned()) group->getSpawnObj()->addProfileParameter(name, "", value); @@ -2153,7 +2153,7 @@ void removePersistentProfileParameter_s_(CStateInstance* entity, CScriptStack& s { std::string name = (std::string)stack.top(); stack.pop(); - + CGroup* group = entity->getGroup(); if (group->isSpawned()) group->getSpawnObj()->removeProfileParameter(name); @@ -2178,23 +2178,23 @@ Arguments: -> s(StateName) void getOutpostStateName__s(CStateInstance* si, CScriptStack& stack) { string str; - + breakable { if (!si) break; - + CGroup* group = si->getGroup(); if (!group) break; - + COutpostManager* manager = dynamic_cast(group->getOwner()); if (!manager) break; - + str = static_cast(manager->getOwner())->getStateName(); } - + stack.push(str); } @@ -2216,12 +2216,12 @@ Arguments: -> f(TribeOwner) void isOutpostTribeOwner__f(CStateInstance* si, CScriptStack& stack) { float tribeOwner = 0.f; - + breakable { if (!si) break; - + CGroup* group = si->getGroup(); if (!group) break; @@ -2229,11 +2229,11 @@ void isOutpostTribeOwner__f(CStateInstance* si, CScriptStack& stack) COutpostManager* manager = dynamic_cast(group->getOwner()); if (!manager) break; - + if (!static_cast(manager->getOwner())->isBelongingToAGuild()) tribeOwner = 1.f; } - + stack.push(tribeOwner); } @@ -2255,12 +2255,12 @@ Arguments: -> f(TribeOwner) void isOutpostGuildOwner__f(CStateInstance* si, CScriptStack& stack) { float guildOwner = 0.f; - + breakable { if (!si) break; - + CGroup* group = si->getGroup(); if (!group) break; @@ -2268,11 +2268,11 @@ void isOutpostGuildOwner__f(CStateInstance* si, CScriptStack& stack) COutpostManager* manager = dynamic_cast(group->getOwner()); if (!manager) break; - + if (static_cast(manager->getOwner())->isBelongingToAGuild()) guildOwner = 1.f; } - + stack.push(guildOwner); } @@ -2366,7 +2366,7 @@ void getPlayerStat_ss_f(CStateInstance* entity, CScriptStack& stack) // get Dataset of the player to have access to mirror values NLMISC::CEntityId playerEid; - playerEid.fromString(playerEidStr.c_str()); + playerEid.fromString(playerEidStr.c_str()); TDataSetRow playerRow = TheDataset.getDataSetRow( playerEid ); if (! TheDataset.isAccessible( playerRow ) ) { @@ -2376,7 +2376,7 @@ void getPlayerStat_ss_f(CStateInstance* entity, CScriptStack& stack) } if (statName == "Hp" ) - { + { // return DSPropertyCURRENT_HIT_POINTS Mirror value CMirrorPropValue mirrorSymbol( TheDataset, playerRow, DSPropertyCURRENT_HIT_POINTS ); stack.push((float)mirrorSymbol.getValue()); @@ -2402,15 +2402,15 @@ void getPlayerStat_ss_f(CStateInstance* entity, CScriptStack& stack) { nlwarning("Try to call %s with wrong state %s", funName.c_str(), statName.c_str() ); } - stack.push((float)0); + stack.push((float)0); return; - + } /** @page code @subsection getPlayerDistance_fs_f -Get the distance between a player and a bot in meters. +Get the distance between a player and a bot in meters. A player EntityId is used to identify the player. This EntityId is passed as string as argument. The EntityId can be obtains via getCurrentPlayerAggroListTarget or getRandomPlayerAggroListTarget. The player must be in the same AI Instance (same continent). @@ -2445,17 +2445,17 @@ void getPlayerDistance_fs_f(CStateInstance* entity, CScriptStack& stack) // get the Spawn bot by its index CGroup* group = entity->getGroup(); if (!group) - { + { nlwarning("%s on a non Npc Group, doesn't work", funName.c_str()); stack.push((float) -1); return; - } + } if (!group->isSpawned() || botIndex <0 || group->bots().size() <= static_cast(botIndex)) { nlwarning("%s used bad index %d/%d (or group not spawn)", funName.c_str(), botIndex, group->bots().size()); stack.push((float)-1); return; - } + } CBot* bot = group->getBot(botIndex); CSpawnBot* spBot = bot?bot->getSpawnObj():0; if (!spBot) @@ -2483,9 +2483,9 @@ void getPlayerDistance_fs_f(CStateInstance* entity, CScriptStack& stack) const double dist = sqrt(dist2); stack.push(float(dist)); - + return; - + } @@ -2506,15 +2506,15 @@ Arguments: f(botIndex) -> s(playerEidAsString) @param[out] playerEidAsString is EntityId as string from the player we want infos @code -($playerId)getCurrentPlayerAggroListTarget(4); -(distance)getPlayerDistance(4, $playerId); +($playerId)getCurrentPlayerAggroListTarget(4); +(distance)getPlayerDistance(4, $playerId); @endcode */ void getCurrentPlayerAggroListTarget_f_s(CStateInstance* entity, CScriptStack& stack) { - + std::string funName = "getCurrentPlayerAggroListTarget_f_s"; // get input params @@ -2523,11 +2523,11 @@ void getCurrentPlayerAggroListTarget_f_s(CStateInstance* entity, CScriptStack& s // get spawn Bot CGroup* group = entity->getGroup(); if (!group) - { + { nlwarning("%s on a non Npc Group, doesn't work", funName.c_str()); stack.push(std::string("")); return; - } + } if (!group->isSpawned() || botIndex <0 || group->bots().size() <= static_cast(botIndex)) { nlwarning("%s used bad index %d/%d (or group not spawn)", funName.c_str(), botIndex, group->bots().size()); @@ -2545,12 +2545,12 @@ void getCurrentPlayerAggroListTarget_f_s(CStateInstance* entity, CScriptStack& s } // iteratre throug aggro list to have the eid with max aggro - CBotAggroOwner::TBotAggroList const& aggroList = spBot->getBotAggroList(); + CBotAggroOwner::TBotAggroList const& aggroList = spBot->getBotAggroList(); CBotAggroOwner::TBotAggroList::const_iterator aggroIt(aggroList.begin()), aggroEnd(aggroList.end()); TDataSetRow foundRow = TDataSetRow(); float foundAggro = 0; for (; aggroIt != aggroEnd; ++aggroIt) - { + { float aggro = aggroIt->second->finalAggro(); if (aggro > foundAggro) { @@ -2563,7 +2563,7 @@ void getCurrentPlayerAggroListTarget_f_s(CStateInstance* entity, CScriptStack& s { continue; } - + CBotPlayer const* const player = NLMISC::safe_cast(ep); if (!player) { @@ -2583,7 +2583,7 @@ void getCurrentPlayerAggroListTarget_f_s(CStateInstance* entity, CScriptStack& s stack.push(std::string("")); return; } - + const NLMISC::CEntityId& found = CMirrors::getEntityId(foundRow); stack.push(std::string(found.toString())); } @@ -2607,15 +2607,15 @@ Arguments: f(botIndex) -> s(playerEidAsString) @param[out] playerEidAsString is EntityId as string from the player we want infos @code -($playerId)getRandomPlayerAggroListTarget(4); -()setAggroListTarget(4, $playerId); +($playerId)getRandomPlayerAggroListTarget(4); +()setAggroListTarget(4, $playerId); @endcode */ void getRandomPlayerAggroListTarget_f_s(CStateInstance* entity, CScriptStack& stack) { - + std::string funName = "getRandomPlayerAggroListTarget_f_s"; // test botIndex @@ -2637,7 +2637,7 @@ void getRandomPlayerAggroListTarget_f_s(CStateInstance* entity, CScriptStack& st stack.push(std::string("")); return; } - + // make a vector of aggroable player CBotAggroOwner::TBotAggroList const& aggroList = spBot->getBotAggroList(); //typedef std::map TBotAggroList; @@ -2645,7 +2645,7 @@ void getRandomPlayerAggroListTarget_f_s(CStateInstance* entity, CScriptStack& st TDataSetRow foundRow = TDataSetRow(); std::vector playerAggroable; for (; aggroIt != aggroEnd; ++aggroIt) - { + { if (CMirrors::getEntityId(aggroIt->first).getType() != RYZOMID::player) { continue; @@ -2655,7 +2655,7 @@ void getRandomPlayerAggroListTarget_f_s(CStateInstance* entity, CScriptStack& st { continue; } - + CBotPlayer const* const player = NLMISC::safe_cast(ep); if (!player) { @@ -2664,7 +2664,7 @@ void getRandomPlayerAggroListTarget_f_s(CStateInstance* entity, CScriptStack& st if (!player->isAggroable()) { continue; - } + } playerAggroable.push_back(aggroIt->first); } @@ -2677,7 +2677,7 @@ void getRandomPlayerAggroListTarget_f_s(CStateInstance* entity, CScriptStack& st } // chose a randomly a player among the container uint32 index = static_cast( static_cast(playerAggroable.size())*rand()/(RAND_MAX+1.0) ); - + const NLMISC::CEntityId& found = CMirrors::getEntityId(playerAggroable[ index ]); stack.push(std::string(found.toString())); } @@ -2719,7 +2719,7 @@ clearAggroList(); */ void getAggroListElement_ff_s(CStateInstance* entity, CScriptStack& stack) { - + std::string funName = "getAggroListElement_ff_s"; @@ -2727,7 +2727,7 @@ void getAggroListElement_ff_s(CStateInstance* entity, CScriptStack& stack) // get params uint32 elementIndex = (uint32)((float)stack.top()); stack.pop(); sint32 botIndex = (uint32)((float)stack.top()); stack.pop(); - + // get spawn bot by its index CGroup* group = entity->getGroup(); if (!group || !group->isSpawned() || botIndex <0 || group->bots().size() <= static_cast(botIndex)) @@ -2744,7 +2744,7 @@ void getAggroListElement_ff_s(CStateInstance* entity, CScriptStack& stack) stack.push(std::string("")); return; } - + // make a vector of aggroable player CBotAggroOwner::TBotAggroList const& aggroList = spBot->getBotAggroList(); //typedef std::map TBotAggroList; @@ -2753,7 +2753,7 @@ void getAggroListElement_ff_s(CStateInstance* entity, CScriptStack& stack) std::vector playerAggroable; for (; aggroIt != aggroEnd; ++aggroIt) - { + { if (CMirrors::getEntityId(aggroIt->first).getType() != RYZOMID::player) { continue; @@ -2763,7 +2763,7 @@ void getAggroListElement_ff_s(CStateInstance* entity, CScriptStack& stack) { continue; } - + CBotPlayer const* const player = NLMISC::safe_cast(ep); if (!player) { @@ -2772,7 +2772,7 @@ void getAggroListElement_ff_s(CStateInstance* entity, CScriptStack& stack) if (!player->isAggroable()) { continue; - } + } playerAggroable.push_back(aggroIt->first); } @@ -2789,7 +2789,7 @@ void getAggroListElement_ff_s(CStateInstance* entity, CScriptStack& stack) stack.push(std::string("")); return; } - + const NLMISC::CEntityId& found = CMirrors::getEntityId(playerAggroable[ uint32(elementIndex) ]); stack.push(std::string(found.toString())); } @@ -2828,7 +2828,7 @@ clearAggroList(); */ void getAggroListSize_f_f(CStateInstance* entity, CScriptStack& stack) { - + std::string funName = "getRandomPlayerAggroListTarget_f_s"; @@ -2852,7 +2852,7 @@ void getAggroListSize_f_f(CStateInstance* entity, CScriptStack& stack) stack.push(float(0) ); return; } - + // make a vector of aggroable player CBotAggroOwner::TBotAggroList const& aggroList = spBot->getBotAggroList(); //typedef std::map TBotAggroList; @@ -2861,7 +2861,7 @@ void getAggroListSize_f_f(CStateInstance* entity, CScriptStack& stack) std::vector playerAggroable; for (; aggroIt != aggroEnd; ++aggroIt) - { + { if (CMirrors::getEntityId(aggroIt->first).getType() != RYZOMID::player) { continue; @@ -2871,7 +2871,7 @@ void getAggroListSize_f_f(CStateInstance* entity, CScriptStack& stack) { continue; } - + CBotPlayer const* const player = NLMISC::safe_cast(ep); if (!player) { @@ -2880,13 +2880,13 @@ void getAggroListSize_f_f(CStateInstance* entity, CScriptStack& stack) if (!player->isAggroable()) { continue; - } + } playerAggroable.push_back(aggroIt->first); } - // return the size of the aggro list + // return the size of the aggro list stack.push(float(playerAggroable.size())); } @@ -2902,13 +2902,13 @@ If no bot are identified by the bot index (or bot not spawaned) the function dis A player EntityId is used to identify the player. If the entityId is not from the aggro list then a warning message is shown in the log. If the entityId is a empty string nothing no message are displayed. -Arguments: f(botIndex) >s(playerEidAsString) > +Arguments: f(botIndex) >s(playerEidAsString) > @param[in] botIndex is the index of an bot member of the current group @param[in] playerEidAsString is EntityId of the player that will be attacked @code -($playerId)getRandomPlayerAggroListTarget(4); -()setAggroListTarget(4, $playerId); +($playerId)getRandomPlayerAggroListTarget(4); +()setAggroListTarget(4, $playerId); @endcode */ @@ -2916,9 +2916,9 @@ void setAggroListTarget_fs_(CStateInstance* entity, CScriptStack& stack) { std::string funName = "setAggroListTarget_fs_"; - - + + std::string playerEidStr = ((std::string)stack.top()); stack.pop(); sint32 botIndex = (sint32)((float)stack.top());stack.pop(); @@ -2930,14 +2930,14 @@ void setAggroListTarget_fs_(CStateInstance* entity, CScriptStack& stack) CGroup* group = entity->getGroup(); if (!group || !group->isSpawned() || botIndex <0 || group->bots().size() <= static_cast(botIndex)) { - nlwarning("%s used bad index %d/%d (or group not spawn)", funName.c_str(), botIndex, group->bots().size()); + nlwarning("%s used bad index %d/%d (or group not spawn)", funName.c_str(), botIndex, group->bots().size()); return; - } + } CBot* bot = group->getBot(botIndex); CSpawnBot* spBot = bot?bot->getSpawnObj():0; if (!spBot) { - nlwarning("%s used bad index %d/%d (or bot not spawn)", funName.c_str(), botIndex, group->bots().size()); + nlwarning("%s used bad index %d/%d (or bot not spawn)", funName.c_str(), botIndex, group->bots().size()); return; } @@ -2947,15 +2947,15 @@ void setAggroListTarget_fs_(CStateInstance* entity, CScriptStack& stack) TDataSetRow playerRow = TheDataset.getDataSetRow( playerEid ); bool accessible = TheDataset.isAccessible( playerRow ); bool pj = playerEid.getType() == RYZOMID::player; - CAIEntityPhysical* ep = accessible && pj ? CAIS::instance().getEntityPhysical(playerRow):0; + CAIEntityPhysical* ep = accessible && pj ? CAIS::instance().getEntityPhysical(playerRow):0; CBotPlayer const* const player = ep ? NLMISC::safe_cast(ep):0; if (!ep || !player ||!player->isAggroable() ) { - nlwarning("Try to call %s with on a player '%s' that is not accessible (or not aggroable). The isPlayerAlived function must be called to be sure that the player is still alived.", funName.c_str(), playerEidStr.c_str() ); + nlwarning("Try to call %s with on a player '%s' that is not accessible (or not aggroable). The isPlayerAlived function must be called to be sure that the player is still alived.", funName.c_str(), playerEidStr.c_str() ); return; } - + // maximize aggro from the bot for the player spBot->maximizeAggroFor(playerRow); } @@ -2969,18 +2969,18 @@ Maximize the Aggro of a target from the Aggro list of one bot to his group (this A player EntityId is used to identify the player. If the entityId is not from the aggro list then a warning message is shown in the log. If the entityId is a empty string nothing no message are displayed. -Arguments: s(playerEidAsString) > +Arguments: s(playerEidAsString) > @param[in] playerEidAsString is EntityId of the player that will be attacked by the group @code -($playerId)getRandomPlayerAggroListTarget(4); -()setGroupAggroListTarget($playerId); +($playerId)getRandomPlayerAggroListTarget(4); +()setGroupAggroListTarget($playerId); @endcode */ void setGroupAggroListTarget_s_(CStateInstance* entity, CScriptStack& stack) { - + std::string funName = "setGroupAggroListTarget_s_"; // read params @@ -2990,28 +2990,28 @@ void setGroupAggroListTarget_s_(CStateInstance* entity, CScriptStack& stack) NLMISC::CEntityId playerEid; playerEid.fromString(playerEidStr.c_str()); - + // test if player eid is ok if (playerEidStr.empty()) { return; } TDataSetRow playerRow = TheDataset.getDataSetRow( playerEid ); bool accessible = TheDataset.isAccessible( playerRow ); bool pj = playerEid.getType() == RYZOMID::player; - CAIEntityPhysical* ep = accessible && pj ? CAIS::instance().getEntityPhysical(playerRow):0; + CAIEntityPhysical* ep = accessible && pj ? CAIS::instance().getEntityPhysical(playerRow):0; CBotPlayer const* const player = ep ? NLMISC::safe_cast(ep):0; if (!ep || !player ||!player->isAggroable() ) { - nlwarning("Try to call %s with on a player '%s' that is not accessible (or not aggroable). The isPlayerAlived function must be called to be sure that the player is still alived.", funName.c_str(), playerEidStr.c_str() ); + nlwarning("Try to call %s with on a player '%s' that is not accessible (or not aggroable). The isPlayerAlived function must be called to be sure that the player is still alived.", funName.c_str(), playerEidStr.c_str() ); return; } - + // test if group is spawn CGroup* group = entity->getGroup(); if (!group || !group->isSpawned() || group->bots().isEmpty() ) - { + { nlwarning("Call %s on a empty/not spawned group", funName.c_str() ); return; } - + // apply maximizeAggroFor on all member of the group CCont::iterator itBot = group->bots().begin(); CCont::iterator itEnd = group->bots().end(); @@ -3023,7 +3023,7 @@ void setGroupAggroListTarget_s_(CStateInstance* entity, CScriptStack& stack) if (!spBot) { continue; } spBot->maximizeAggroFor(playerRow); } - + } /** @page code @@ -3036,19 +3036,19 @@ A player EntityId is used to identify the player. If the entityId is not from th A string is used to select groups of the manager (groups name must contains this string) -Arguments: f(botIndex), s(playerEidAsString) > +Arguments: f(botIndex), s(playerEidAsString) > @param[in] playerId is EntityId of the player @param[in] nameElement The element of the name of all group we are interest in. @code -($playerId)getRandomPlayerAggroListTarget(0); +($playerId)getRandomPlayerAggroListTarget(0); ()setManagerAggroListTarget($playerId, "group_bandit_"); // all group that have name like "group_bandit_*" will attack the player @endcode */ void setManagerAggroListTarget_ss_(CStateInstance* entity, CScriptStack& stack) { - + std::string funName = "setManagerAggroListTarget_ss_"; @@ -3065,25 +3065,25 @@ void setManagerAggroListTarget_ss_(CStateInstance* entity, CScriptStack& stack) TDataSetRow playerRow = TheDataset.getDataSetRow( playerEid ); bool accessible = TheDataset.isAccessible( playerRow ); bool pj = playerEid.getType() == RYZOMID::player; - CAIEntityPhysical* ep = accessible && pj ? CAIS::instance().getEntityPhysical(playerRow):0; + CAIEntityPhysical* ep = accessible && pj ? CAIS::instance().getEntityPhysical(playerRow):0; CBotPlayer const* const player = ep ? NLMISC::safe_cast(ep):0; if (!ep || !player ||!player->isAggroable() ) { - nlwarning("Try to call %s with on a player '%s' that is not accessible (or not aggroable). The isPlayerAlived function must be called to be sure that the player is still alived.", funName.c_str(), playerEidStr.c_str() ); + nlwarning("Try to call %s with on a player '%s' that is not accessible (or not aggroable). The isPlayerAlived function must be called to be sure that the player is still alived.", funName.c_str(), playerEidStr.c_str() ); return; } - - + + CGroup* group = entity->getGroup(); if (!group ) - { + { nlwarning("Call %s on a non exisiting group", funName.c_str() ); return; } // get the manager of the group CManager* manager = group->getOwner(); if (!manager) - { + { nlwarning("Call %s on a non exisiting manager", funName.c_str() ); return; } @@ -3092,7 +3092,7 @@ void setManagerAggroListTarget_ss_(CStateInstance* entity, CScriptStack& stack) while (group!=NULL) { if ( ! (!group || !group->isSpawned() || group->bots().isEmpty() ) && group->getName().find(groupNameStr) != std::string::npos ) - { + { // apply maximizeAggroFor on all member of the group CCont::iterator itBot = group->bots().begin(); CCont::iterator itEnd = group->bots().end(); @@ -3104,10 +3104,10 @@ void setManagerAggroListTarget_ss_(CStateInstance* entity, CScriptStack& stack) if (!spBot) { continue; } spBot->maximizeAggroFor(playerRow); } - } + } group = manager->getNextValidGroupChild(group); } - + } @@ -3127,8 +3127,8 @@ Arguments:, s(botName) > f(botIndex) @code (botIndex)getBotIndexByName("boss_random_aggro"); -($playerId)getRandomPlayerAggroListTarget(botIndex); -()setAggroListTarget(botIndex, $playerId); +($playerId)getRandomPlayerAggroListTarget(botIndex); +()setAggroListTarget(botIndex, $playerId); } @endcode */ @@ -3142,12 +3142,12 @@ void getBotIndexByName_s_f(CStateInstance* entity, CScriptStack& stack) // test if group is spawned CGroup* group = entity->getGroup(); if (!group || group->bots().isEmpty() ) - { + { nlwarning("Call %s on a empty group", funName.c_str() ); stack.push((float)-1); return; } - + // Search on all persistent bot of the groupe the bot that have the searched name CCont::iterator itBot = group->bots().begin(); @@ -3164,7 +3164,7 @@ void getBotIndexByName_s_f(CStateInstance* entity, CScriptStack& stack) return; } } - + // Bot not found stack.push((float)-1); return; @@ -3188,12 +3188,12 @@ Arguments: s(playerid) > f(success) @code ($alived)isGroupAlived(); if ($alived == 1.0f) { -} +} @endcode */ void isGroupAlived__f(CStateInstance* entity, CScriptStack& stack) -{ +{ isAlived__f(entity, stack); } @@ -3226,11 +3226,11 @@ void isBotAlived_f_f(CStateInstance* entity, CScriptStack& stack) // get Spawn Bot CGroup* group = entity->getGroup(); if (!group) - { + { nlwarning("%s on a non Npc Group, doesn't work", funName.c_str()); stack.push((float)0); return; - } + } if (!group->isSpawned() || group->bots().isEmpty() || botIndex < 0 || group->bots().size() < static_cast(botIndex)) { stack.push(0.0f);return; @@ -3266,7 +3266,7 @@ Arguments: s(playerId) > f(success) ($playerId)getCurrentPlayerAggroListTarget($botIndex): (alived)isPlayerlived($playerId); if (alived == 1.0f) { -} +} @endcode */ void isPlayerAlived_s_f(CStateInstance* entity, CScriptStack& stack) @@ -3276,7 +3276,7 @@ void isPlayerAlived_s_f(CStateInstance* entity, CScriptStack& stack) //get CAIEntityPhysical of the player NLMISC::CEntityId playerEid; - playerEid.fromString(playerEidStr.c_str()); + playerEid.fromString(playerEidStr.c_str()); TDataSetRow playeDataSetRow = TheDataset.getDataSetRow( playerEid) ; if (playerEidStr.empty() || !TheDataset.isAccessible( playeDataSetRow ) || playerEid.getType() != RYZOMID::player ) { @@ -3285,7 +3285,7 @@ void isPlayerAlived_s_f(CStateInstance* entity, CScriptStack& stack) CAIEntityPhysical* ep = CAIS::instance().getEntityPhysical(playeDataSetRow); if (!ep) { - + stack.push(0.0f); return; } // test if the player is alived @@ -3295,7 +3295,7 @@ void isPlayerAlived_s_f(CStateInstance* entity, CScriptStack& stack) } stack.push(0.0f); return; - + } /** @page code @@ -3304,7 +3304,7 @@ void isPlayerAlived_s_f(CStateInstance* entity, CScriptStack& stack) Gets the server time as string "eg 21:17:14 the x" This function is useful for stat purpose or debug (to know when a boss is down) -Arguments: > s(serverTime) +Arguments: > s(serverTime) @param[out] The server time as debug string @@ -3328,7 +3328,7 @@ void getServerTimeStr__s(CStateInstance* entity, CScriptStack& stack) Gets the server time as number (it is the number of seconde since 1970). This value is useful for saving the server date on a file -Arguments: > s(serverTime) +Arguments: > s(serverTime) @param[out] The server time as string (a float is not sharp enough @@ -3367,19 +3367,19 @@ void getRyzomDateStr__s(CStateInstance* entity, CScriptStack& stack) std::string result; const CRyzomTime &rt = CTimeInterface::getRyzomTime(); result = NLMISC::toString("%d:%d:00", (int) floorf(rt.getRyzomTime()) , (int) floorf(60.f * fmodf(rt.getRyzomTime(), 1.f))); - + uint32 month = rt.getRyzomMonth(); MONTH::EMonth monthInCycle = rt.getRyzomMonthInCurrentCycle(); std::string monthName = MONTH::toString((MONTH::EMonth) monthInCycle); - uint32 dayOfMonth = rt.getRyzomDayOfMonth(); + uint32 dayOfMonth = rt.getRyzomDayOfMonth(); std::string dayName = WEEKDAY::toString((WEEKDAY::EWeekDay) rt.getRyzomDayOfWeek()); result += NLMISC::toString(" / %s %d %s(%d) %d", dayName.c_str(), (int) (dayOfMonth + 1), monthName.c_str(), - (int) (month + 1), + (int) (month + 1), (int) rt.getRyzomYear()); - + stack.push( result ); } @@ -3466,7 +3466,7 @@ Some value other can be handled *BUT* the value *MUST* be the C++ code enum va - faction - power_type - race -- damage_type +- damage_type - characteristic - score - body_part @@ -3488,22 +3488,22 @@ Arguments: s(paramType), f(value) -> // CGroup void phrasePushValue_sf_(CStateInstance* entity, CScriptStack& stack) { - float f = (float)stack.top();stack.pop(); // get the value as float + float f = (float)stack.top();stack.pop(); // get the value as float std::string typeStr = (std::string)stack.top(); stack.pop(); // get the param type // create the good STRING_MANAGER::TParam in fonction of its type and is value STRING_MANAGER::TParamType type = STRING_MANAGER::stringToParamType(typeStr); STRING_MANAGER::TParam param; param.Type = type; - switch( type ) - { - + switch( type ) + { + case STRING_MANAGER::money: { param.Money = static_cast(f); break; } - - + + case STRING_MANAGER::integer: { param.Int = static_cast(f); @@ -3514,18 +3514,18 @@ void phrasePushValue_sf_(CStateInstance* entity, CScriptStack& stack) { param.Time = static_cast(f); break; - } + } case STRING_MANAGER::skill: case STRING_MANAGER::faction: case STRING_MANAGER::power_type: case STRING_MANAGER::race: - case STRING_MANAGER::damage_type: + case STRING_MANAGER::damage_type: case STRING_MANAGER::characteristic: case STRING_MANAGER::score: - case STRING_MANAGER::body_part: - { - param.Enum = static_cast( f ); + case STRING_MANAGER::body_part: + { + param.Enum = static_cast( f ); break; } @@ -3534,7 +3534,7 @@ void phrasePushValue_sf_(CStateInstance* entity, CScriptStack& stack) break; } - + PhraseParameters.Values.push_back(param); } @@ -3592,7 +3592,7 @@ Some value other can be handled *BUT* the value *MUST* be the C++ code enum va - faction - power_type - race -- damage_type +- damage_type - characteristic - score - body_part @@ -3626,15 +3626,15 @@ void phrasePushString_ss_(CStateInstance* entity, CScriptStack& stack ) STRING_MANAGER::TParamType type = STRING_MANAGER::stringToParamType(typeStr); STRING_MANAGER::TParam param; param.Type = type; - switch( type ) - { - + switch( type ) + { + case STRING_MANAGER::money: { NLMISC::fromString(s, param.Money); break; } - + case STRING_MANAGER::player: case STRING_MANAGER::bot: case STRING_MANAGER::entity: @@ -3644,14 +3644,14 @@ void phrasePushString_ss_(CStateInstance* entity, CScriptStack& stack ) uint32 alias = 0; id.fromString(s.c_str()); CAIEntityPhysical* entityPhysical=CAIS::instance().getEntityPhysical(TheDataset.getDataSetRow(id)); - if (entityPhysical) + if (entityPhysical) { switch( entityPhysical->getRyzomType()) { case RYZOMID::creature: case RYZOMID::npc: { - + CSpawnBot* sb = NLMISC::safe_cast(entityPhysical); alias = sb->getPersistent().getAlias(); break; @@ -3664,7 +3664,7 @@ void phrasePushString_ss_(CStateInstance* entity, CScriptStack& stack ) param.setEIdAIAlias( id, alias ); } break; - + case STRING_MANAGER::integer: { NLMISC::fromString(s, param.Int); @@ -3676,9 +3676,9 @@ void phrasePushString_ss_(CStateInstance* entity, CScriptStack& stack ) NLMISC::fromString(s, param.Time); break; } - - - case STRING_MANAGER::item: + + + case STRING_MANAGER::item: case STRING_MANAGER::outpost: case STRING_MANAGER::creature_model: case STRING_MANAGER::creature: @@ -3696,10 +3696,10 @@ void phrasePushString_ss_(CStateInstance* entity, CScriptStack& stack ) } break; } - - + + case STRING_MANAGER::place: - case STRING_MANAGER::event_faction: + case STRING_MANAGER::event_faction: case STRING_MANAGER::title: case STRING_MANAGER::bot_name: { @@ -3711,11 +3711,11 @@ void phrasePushString_ss_(CStateInstance* entity, CScriptStack& stack ) case STRING_MANAGER::faction: case STRING_MANAGER::power_type: case STRING_MANAGER::race: - case STRING_MANAGER::damage_type: + case STRING_MANAGER::damage_type: case STRING_MANAGER::characteristic: case STRING_MANAGER::score: - case STRING_MANAGER::body_part: - { + case STRING_MANAGER::body_part: + { NLMISC::fromString(s, param.Enum); break; } @@ -3733,14 +3733,14 @@ void phrasePushString_ss_(CStateInstance* entity, CScriptStack& stack ) case STRING_MANAGER::role: case STRING_MANAGER::compass: case STRING_MANAGER::guild: - case STRING_MANAGER::ecosystem: + case STRING_MANAGER::ecosystem: case STRING_MANAGER::classification_type: default: param.Type = STRING_MANAGER::invalid_value; break; } - + PhraseParameters.Values.push_back(param); } @@ -3749,9 +3749,9 @@ void phrasePushString_ss_(CStateInstance* entity, CScriptStack& stack ) static void phraseEnd(CStateInstance* entity, CScriptStack& stack, CPhraseParameters::TMode mode) { std::string funName = "phraseEnd"; - - // get Function parameters - + + // get Function parameters + std::string phraseId = (std::string)stack.top();stack.pop(); std::string sayMode; if (mode != CPhraseParameters::EmoteMsg) @@ -3759,25 +3759,25 @@ static void phraseEnd(CStateInstance* entity, CScriptStack& stack, CPhraseParam sayMode = (std::string)stack.top();stack.pop(); } sint32 botIndex = (sint32)((float)stack.top());stack.pop(); - + // Verify is bot is alived CGroup* group = entity->getGroup(); if (!group) - { + { nlwarning("%s on a non Npc Group, doesn't work", funName.c_str()); PhraseParameters.Values.clear(); return; - } + } if (!group->isSpawned() || group->bots().isEmpty() || botIndex < 0 || group->bots().size() < static_cast(botIndex)) { PhraseParameters.Values.clear(); return; - } + } const CBot *const bot = group->getBot(botIndex); - if ( !bot || !bot->isSpawned()) + if ( !bot || !bot->isSpawned()) { PhraseParameters.Values.clear(); return; @@ -3788,7 +3788,7 @@ static void phraseEnd(CStateInstance* entity, CScriptStack& stack, CPhraseParam PhraseParameters.Values.clear(); return; } - + // parse type of chat CChatGroup::TGroupType groupType; if (mode != CPhraseParameters::EmoteMsg) @@ -3803,21 +3803,21 @@ static void phraseEnd(CStateInstance* entity, CScriptStack& stack, CPhraseParam return; } - // send chat to client + // send chat to client switch (mode) { case CPhraseParameters::NpcMsg: - npcChatParamToChannel(sp->dataSetRow(), groupType, phraseId.c_str(), PhraseParameters.Values); + npcChatParamToChannel(sp->dataSetRow(), groupType, phraseId.c_str(), PhraseParameters.Values); break; case CPhraseParameters::SystemMsg: STRING_MANAGER::sendSystemStringToClientAudience(sp->dataSetRow(),std::vector(), groupType, phraseId.c_str(), PhraseParameters.Values); break; case CPhraseParameters::EmoteMsg: - STRING_MANAGER::sendCustomEmoteTextToClientAudience(sp->dataSetRow(),std::vector(), phraseId.c_str(), PhraseParameters.Values); + STRING_MANAGER::sendCustomEmoteTextToClientAudience(sp->dataSetRow(),std::vector(), phraseId.c_str(), PhraseParameters.Values); break; } - + PhraseParameters.Values.clear(); } @@ -3825,7 +3825,7 @@ static void phraseEnd(CStateInstance* entity, CScriptStack& stack, CPhraseParam /** @page code @subsection phraseEndNpcMsg_fss_ -Send a message with parameter through a bot says. +Send a message with parameter through a bot says. Parameters are taken from the parameters stack. @see phrasePushValue_sf_ @see phrasePushString_ss_ @@ -3943,10 +3943,10 @@ void phraseEndEmoteMsg_fs_(CStateInstance* entity, CScriptStack& stack) /** @page code @subsection queryEgs_sscfs_ -Send a query msg to egs to know infos on a player. +Send a query msg to egs to know infos on a player. Answer is asynchronous so we have to indicates a group and a user event that will be triggered when answer will come back to AIS -Possible info to know are +Possible info to know are - Name - Hp - MaxHp @@ -3991,7 +3991,7 @@ Answer will be given by the getParam @endcode Answer of the EGS @code - // the user_event 4 of groupToNotify will be trigered + // the user_event 4 of groupToNotify will be trigered ($msgName)getEventParam(0); // the msg name ($ret)getEventParam(1); // the return ($funName)getEventParam(2); // the name of the function @@ -4020,8 +4020,8 @@ void queryEgs_sscfs_(CStateInstance* entity, CScriptStack& stack) std::string funName = "queryEgs_sscfs_"; // read input params string literal = (string)stack.top(); stack.pop(); - float useEventId = (float)stack.top(); stack.pop(); - CGroupNpc* const groupToNotify = dynamic_cast( (IScriptContext*)stack.top() ); stack.pop(); + float useEventId = (float)stack.top(); stack.pop(); + CGroupNpc* const groupToNotify = dynamic_cast( (IScriptContext*)stack.top() ); stack.pop(); string param1 = (string)stack.top(); stack.pop(); string func = (string)stack.top(); stack.pop(); @@ -4048,14 +4048,14 @@ void queryEgs_sscfs_(CStateInstance* entity, CScriptStack& stack) /* @subsection queryEgs_ssscfs_ -Send a query msg to egs to know infos on a player. +Send a query msg to egs to know infos on a player. Answer is asynchronous so we have to indicates a group and a user event that will be triggered when answer will come back to AIS -Possible info to know are: +Possible info to know are: - KnowBrick (to knwo if the player know a specific brick); return value is 0 or 1 (if the player know the brick) -- IsInInventory (to knwo has an item in inventory of in equipement); return value is 0, 1(item in equipment), 2(item in bag) +- IsInInventory (to knwo has an item in inventory of in equipement); return value is 0, 1(item in equipment), 2(item in bag) - Target (to know if a player target a bot; return value is 0, 1(player target the bot) - + Arguments: s(botIndex), s(query), s(queryParam), c(groupThatWillBeTriggered), f(idOfTheUserEvent), s(msgId) @param[in] botIndex the Position of the bot in the group ( see getBotIndexByName_s_f) @param[in] query The query we want to send @@ -4113,8 +4113,8 @@ void queryEgs_ssscfs_(CStateInstance* entity, CScriptStack& stack) std::string funName = "queryEgs_ssscfs_"; // get input params string literal = (string)stack.top(); stack.pop(); - float useEventId = (float)stack.top(); stack.pop(); - CGroupNpc* const groupToNotify = dynamic_cast( (IScriptContext*)stack.top() ); stack.pop(); + float useEventId = (float)stack.top(); stack.pop(); + CGroupNpc* const groupToNotify = dynamic_cast( (IScriptContext*)stack.top() ); stack.pop(); string param2 = (string)stack.top(); stack.pop(); string param1 = (string)stack.top(); stack.pop(); string func = (string)stack.top(); stack.pop(); @@ -4154,12 +4154,12 @@ A player EntityId is used to identify the player. A index is used to identified the bot (index for the current group) -Arguments: f(botIndex), s(playerEid) > +Arguments: f(botIndex), s(playerEid) > @param[in] botIndex is the index of the bot in the current group(static group) @param[in] playerEid The entityId of the player @code -($playerId)getRandomPlayerAggroListTarget(0); +($playerId)getRandomPlayerAggroListTarget(0); ()teleportPlayer(0, $playerEid); // teleport player to the boss. @endcode */ @@ -4169,35 +4169,35 @@ void summonPlayer_fs_(CStateInstance* entity, CScriptStack& stack) std::string funName = "summonPlayer_fffs_"; std::string playerEidStr = ((std::string)stack.top()); stack.pop(); sint32 botIndex = (sint32)((float)stack.top()); stack.pop(); - + // Verify is bot is alived CGroup* group = entity->getGroup(); if (!group) - { - nlwarning("%s on a non Npc Group, doesn't work", funName.c_str()); + { + nlwarning("%s on a non Npc Group, doesn't work", funName.c_str()); return; - } + } if (!group->isSpawned() || group->bots().isEmpty() || botIndex < 0 || group->bots().size() < static_cast(botIndex)) - { + { return; - } + } const CBot *const bot = group->getBot(botIndex); - if ( !bot || !bot->isSpawned()) - { + if ( !bot || !bot->isSpawned()) + { return; } CSpawnBot *const sp= bot->getSpawnObj(); if ( !sp || !sp->isAlive() ) - { + { return; } // Read position for mirror - TDataSetRow row = sp->dataSetRow(); + TDataSetRow row = sp->dataSetRow(); if (! TheDataset.isAccessible( row ) ) - { + { return; } @@ -4222,9 +4222,9 @@ void summonPlayer_fs_(CStateInstance* entity, CScriptStack& stack) TDataSetRow CharacterRowId = charEntity->dataSetRow(); NLMISC::CEntityId player = CMirrors::getEntityId(CharacterRowId); - + if (player != NLMISC::CEntityId::Unknown) - { + { sint32 x2 = mirrorSymbolX.getValue(); sint32 y2 = mirrorSymbolY.getValue(); sint32 z2 = 0; @@ -4233,13 +4233,13 @@ void summonPlayer_fs_(CStateInstance* entity, CScriptStack& stack) NLNET::CMessage msgout( "TELEPORT_PLAYER" ); nlWrite(msgout, serial, player ); msgout.serial( const_cast(x2) ); - msgout.serial( const_cast(y2) ); - msgout.serial( const_cast(z2) ); - msgout.serial( const_cast(t) ); - sendMessageViaMirror( "EGS", msgout ); + msgout.serial( const_cast(y2) ); + msgout.serial( const_cast(z2) ); + msgout.serial( const_cast(t) ); + sendMessageViaMirror( "EGS", msgout ); } - + } /** @page code @@ -4252,12 +4252,12 @@ A player EntityId is used to identify the player. The position is identified by the value x,y,z and the heading -Arguments: s(playerId), f(x), f(y), f(z), f(heading) > +Arguments: s(playerId), f(x), f(y), f(z), f(heading) > @param[in] playerId is EntityId of the player @param[in] x,y,z,heading is the new position of the player @code -($playerId)getRandomPlayerAggroListTarget(0); +($playerId)getRandomPlayerAggroListTarget(0); ()teleportPlayer($playerEid, 1000, 1000, 100, 0); @endcode */ @@ -4269,7 +4269,7 @@ void teleportPlayer_sffff_(CStateInstance* entity, CScriptStack& stack) float y = (float)stack.top(); stack.pop(); float x = (float)stack.top(); stack.pop(); std::string playerEidStr = (std::string)stack.top(); stack.pop(); - NLMISC::CEntityId playerEid; + NLMISC::CEntityId playerEid; playerEid.fromString(playerEidStr.c_str()); // retrieve the CBotPlayer @@ -4285,20 +4285,20 @@ void teleportPlayer_sffff_(CStateInstance* entity, CScriptStack& stack) // teleport player to position if (playerEid != NLMISC::CEntityId::Unknown) - { + { sint32 x2 = static_cast(x*1000); sint32 y2 = static_cast(y*1000); - sint32 z2 = static_cast(z*1000); + sint32 z2 = static_cast(z*1000); NLNET::CMessage msgout( "TELEPORT_PLAYER" ); msgout.serial( const_cast(playerEid) ); msgout.serial( const_cast(x2) ); - msgout.serial( const_cast(y2) ); - msgout.serial( const_cast(z2) ); - msgout.serial( const_cast(t) ); - sendMessageViaMirror( "EGS", msgout ); + msgout.serial( const_cast(y2) ); + msgout.serial( const_cast(z2) ); + msgout.serial( const_cast(t) ); + sendMessageViaMirror( "EGS", msgout ); } - + } //---------------------------------------------------------------------------- /** @page code @@ -4327,18 +4327,18 @@ void getBotEid_f_s(CStateInstance* entity, CScriptStack& stack) // get spawn Bot by its index CGroup* group = entity->getGroup(); if (!group) - { + { nlwarning("%s on a non Npc Group, doesn't work", funName.c_str()); stack.push(std::string(CEntityId::Unknown.toString())); return; - } + } sint32 botIndex = (sint32)((float)stack.top());stack.pop(); if (!group->isSpawned() || group->bots().isEmpty() || botIndex < 0 || group->bots().size() < static_cast(botIndex)) { stack.push(std::string(CEntityId::Unknown.toString())); return; } - + const CBot *const bot = group->getBot(botIndex); if ( !bot || !bot->isSpawned()) { stack.push(std::string(CEntityId::Unknown.toString())); return;} @@ -4380,22 +4380,22 @@ void getBotIndex_s_f(CStateInstance* entity, CScriptStack& stack) std::string funName = "getBotEid_f_s"; CGroup* group = entity->getGroup(); if (!group) - { + { nlwarning("%s on a non Npc Group, doesn't work", funName.c_str()); stack.push(std::string(CEntityId::Unknown.toString())); return; - } + } std::string botEid = (std::string)stack.top(); stack.pop(); - + // look in the group if the bot is alived uint32 botIndex = 0, last = group->bots().size(); for ( ;botIndex != last; ++botIndex) { if (!group->isSpawned() || group->bots().isEmpty() || group->bots().size() < static_cast(botIndex)) { - continue; + continue; } - + const CBot *const bot = group->getBot(botIndex); if ( !bot || !bot->isSpawned()) { continue; } @@ -4413,7 +4413,7 @@ void getBotIndex_s_f(CStateInstance* entity, CScriptStack& stack) } stack.push((float)-1); return; - + } /** @page code @@ -4441,7 +4441,7 @@ void getCurrentPlayerEid__s(CStateInstance* entity, CScriptStack& stack) std::string funName = "getCurrentPlayerEid__s"; CEntityId id = CEntityId::Unknown; // if we are in player_target_npc event TempPlayer is valid - if (!TempPlayer) + if (!TempPlayer) { //TempPlayer is invalid so return Unkwn eid std::string s = id.toString(); @@ -4513,11 +4513,11 @@ void setSheet_s_(CStateInstance* entity, CScriptStack& stack) { string sheetname = stack.top(); stack.pop(); - + CSheetId sheetId(sheetname+".creature"); if (sheetId==CSheetId::Unknown) return; - + FOREACH(itBot, CCont, entity->getGroup()->bots()) { CBot* bot = *itBot; @@ -4548,7 +4548,7 @@ void setClientSheet_s_(CStateInstance* entity, CScriptStack& stack) { string sheetname = stack.top(); stack.pop(); - + if (sheetname.find(".creature") == string::npos) sheetname += ".creature"; @@ -4582,9 +4582,9 @@ void setHealer_f_(CStateInstance* entity, CScriptStack& stack) { bool value = ((float)stack.top())!=0.f; stack.pop(); - + CGroup* group = entity->getGroup(); - + if (group->isSpawned()) { FOREACH(itBot, CCont, group->bots()) @@ -4626,7 +4626,7 @@ void sitDown__(CStateInstance* entity, CScriptStack& stack) nlwarning("sitDown__ failed"); return; } - + CAILogicActionSitDownHelper::sitDown(group); } @@ -4640,7 +4640,7 @@ Make the group stand up (if was previously stand down) Arguments: -> @code -()standUp(); +()standUp(); @endcode @@ -4654,7 +4654,7 @@ void standUp__(CStateInstance* entity, CScriptStack& stack) nlwarning("standUp__ failed"); return; } - + CAILogicActionSitDownHelper::standUp(group); } @@ -4667,7 +4667,7 @@ Use to implement setConditionRet Arguments: -> @code -()setConditionRet(1); +()setConditionRet(1); @endcode @@ -4682,7 +4682,7 @@ void setConditionSuccess_f_(CStateInstance* entity, CScriptStack& stack) nlwarning("setConditionSuccess_f_ failed"); return; } - + CAILogicDynamicIfHelper::setConditionSuccess(conditionState); } @@ -4736,7 +4736,7 @@ void facing_f_(CStateInstance* entity, CScriptStack& stack) spawnBot->setTheta(randomAngle()); else spawnBot->setTheta(theta); - + } } } @@ -4746,11 +4746,11 @@ void facing_f_(CStateInstance* entity, CScriptStack& stack) std::map nfGetGroupNativeFunctions() { std::map functions; - + #define REGISTER_NATIVE_FUNC(cont, func) cont.insert(std::make_pair(std::string(#func), &func)) - + REGISTER_NATIVE_FUNC(functions, spawn__); - REGISTER_NATIVE_FUNC(functions, despawn_f_); + REGISTER_NATIVE_FUNC(functions, despawn_f_); REGISTER_NATIVE_FUNC(functions, isAlived__f); REGISTER_NATIVE_FUNC(functions, newNpcChildGroupPos_ssfff_c); REGISTER_NATIVE_FUNC(functions, newNpcChildGroupPos_ssfff_); @@ -4851,7 +4851,7 @@ std::map nfGetGroupNativeFunctions() REGISTER_NATIVE_FUNC(functions, setAggroListTarget_fs_); REGISTER_NATIVE_FUNC(functions, setGroupAggroListTarget_s_); REGISTER_NATIVE_FUNC(functions, setManagerAggroListTarget_ss_); - + // Boss functions (Time infos) REGISTER_NATIVE_FUNC(functions, getServerTimeStr__s); REGISTER_NATIVE_FUNC(functions, getServerTime__s); @@ -4864,6 +4864,6 @@ std::map nfGetGroupNativeFunctions() #undef REGISTER_NATIVE_FUNC - + return functions; }