diff --git a/ryzom/server/src/ai_service/ai_grp_npc.cpp b/ryzom/server/src/ai_service/ai_grp_npc.cpp index e6b16c9a0..8ddfb013a 100644 --- a/ryzom/server/src/ai_service/ai_grp_npc.cpp +++ b/ryzom/server/src/ai_service/ai_grp_npc.cpp @@ -19,6 +19,7 @@ #include "stdpch.h" #include "server_share/r2_variables.h" +#include "messages.h" #include "ai_grp_npc.h" #include "ai_mgr_npc.h" #include "ai_bot_npc.h" @@ -35,6 +36,7 @@ extern bool simulateBug(int bugId); using namespace MULTI_LINE_FORMATER; using namespace NLMISC; +using namespace NLNET; using namespace std; using namespace AITYPES; @@ -60,6 +62,7 @@ CSpawnGroupNpc::CSpawnGroupNpc(CPersistent& owner) { sint32 const randomVal = (sint32)CTimeInterface::gameCycle()-CAIS::rand32(20); _LastUpdate = (randomVal>=0)?randomVal:CTimeInterface::gameCycle(); + _Cell = 0; _LastBotUpdate = CTimeInterface::gameCycle(); activityProfile().setAIProfile(new CGrpProfileNormal(this)); _BotUpdateTimer.set((CAIS::rand32(40)+((intptr_t)this>>2))%20); // start with a random value. @@ -148,10 +151,10 @@ void CSpawnGroupNpc::sendInfoToEGS() const void CSpawnGroupNpc::update() { H_AUTO(GrpNpcUpdate); - + ++AISStat::GrpTotalUpdCtr; ++AISStat::GrpNpcUpdCtr; - + uint32 const Dt = CTimeInterface::gameCycle()-_LastUpdate; bool const inFight = activityProfile().getAIProfileType()==FIGHT_NORMAL; @@ -174,27 +177,27 @@ void CSpawnGroupNpc::update() { updateTrigger = 30; } - + bool const haveToUpdateGroupBehaviour = (Dt>=updateTrigger); // every second. - + if (haveToUpdateGroupBehaviour) { H_AUTO(GrpNpcUpdateBehaviour); // record the tick at which we ran this update (for future refference) _LastUpdate = CTimeInterface::gameCycle(); - + checkDespawn(); checkRespawn(); getPersistent().updateStateInstance(); } - + // bot update()s -------------------------------------------------- { if (haveToUpdateGroupBehaviour) { H_AUTO(GrpNpcUpdateBots); _GroupInVision = false; - + FOREACH(first,CCont, bots()) { CSpawnBotNpc const* const bot = static_cast(*first)->getSpawn(); @@ -212,21 +215,21 @@ void CSpawnGroupNpc::update() } if (!bot->havePlayersAround()) continue; - + _GroupInVision = true; break; } } - + // TODO : hack : remove this when the "can't reach and turn arround" debility is corrected bool fastUpdate = _GroupInVision || inFight; bool slowUpdate = (CTimeInterface::gameCycle()%_SlowUpdatePeriod)==_SlowUpdateCycle; - + if (fastUpdate || slowUpdate) { uint32 const botDt = CTimeInterface::gameCycle()-_LastBotUpdate; _LastBotUpdate = CTimeInterface::gameCycle(); - + FOREACH(first, CCont, bots()) { CSpawnBotNpc* const bot = static_cast(*first)->getSpawn(); @@ -239,9 +242,9 @@ void CSpawnGroupNpc::update() _BotUpdateTimer.set(10); } } - + if (haveToUpdateGroupBehaviour) - { + { H_AUTO(GrpNpcUpdateGrpBehaviour); if (!activityProfile().getAISpawnProfile().isNull()) // Check if we have a behaviour. activityProfile().updateProfile(Dt); // If so, then update it ! @@ -263,27 +266,27 @@ void CSpawnGroupNpc::stateChange(CAIState const* oldState, CAIState const* newSt // Find changing group profiles. { setProfileParameters(getPersistent().profileParameters()); - + IAIProfileFactory* moveProfile = newState->moveProfile(); IAIProfileFactory* actProfile = newState->activityProfile(); - + mergeProfileParameters(newState->profileParameters()); - + FOREACHC(it, CCont, newState->profiles()) { if (!it->testCompatibility(getPersistent())) continue; - + if (it->moveProfile()!= RYAI_GET_FACTORY(CGrpProfileNoChangeFactory)) moveProfile = it->moveProfile(); - + if (it->activityProfile()!=RYAI_GET_FACTORY(CGrpProfileNoChangeFactory)) actProfile = it->activityProfile(); - + mergeProfileParameters(it->profileParameters()); break; } - + breakable { if (oldState) @@ -294,36 +297,36 @@ void CSpawnGroupNpc::stateChange(CAIState const* oldState, CAIState const* newSt // need to backup the current profiles _PunctualHoldActivityProfile = activityProfile(); _PunctualHoldMovingProfile = movingProfile(); - + activityProfile() = CProfilePtr(); movingProfile() = CProfilePtr(); break; } - + if (newState->isPositional() && !oldState->isPositional()) { // end of punctual state // need to restore the backuped profile activityProfile() = _PunctualHoldActivityProfile; movingProfile() = _PunctualHoldMovingProfile; - + _PunctualHoldActivityProfile = CProfilePtr(); _PunctualHoldMovingProfile = CProfilePtr(); - + // resume the profiles activityProfile().getAISpawnProfile()->resumeProfile(); movingProfile().getAISpawnProfile()->resumeProfile(); break; } } - + // normal behavior, transition from positionnal to positionnal state if (moveProfile!=RYAI_GET_FACTORY(CGrpProfileNoChangeFactory)) setMoveProfileFromStateMachine(moveProfile); - + if (actProfile!=RYAI_GET_FACTORY(CGrpProfileNoChangeFactory)) setActivityProfileFromStateMachine(actProfile); - + break; } } @@ -343,8 +346,31 @@ void CSpawnGroupNpc::spawnBots() FOREACH(itBot, CCont, bots()) { CBot* bot = *itBot; - if (!bot->isSpawned()) + if (!bot->isSpawned()) { bot->spawn(); + if (_Cell < 0) { + CEntityId id = bot->getSpawnObj()->getEntityId(); + sint32 x = bot->getSpawnObj()->pos().x(); + sint32 y = bot->getSpawnObj()->pos().y(); + sint32 z = bot->getSpawnObj()->pos().h(); + float t = bot->getSpawnObj()->pos().theta().asRadians(); + uint8 cont = 0; + uint8 slide = 1; + NLMISC::TGameCycle tick = CTickEventHandler::getGameCycle() + 1; + CMessage msgout2("ENTITY_TELEPORTATION"); + msgout2.serial( id ); + msgout2.serial( x ); + msgout2.serial( y ); + msgout2.serial( z ); + msgout2.serial( t ); + msgout2.serial( tick ); + msgout2.serial( cont ); + msgout2.serial( _Cell ); + msgout2.serial( slide ); + + sendMessageViaMirror("GPMS", msgout2); + } + } } } @@ -355,7 +381,7 @@ void CSpawnGroupNpc::despawnBots(bool immediately) CBot* const bot = *itBot; if (!bot->isSpawned()) continue; - + if (TheDataset.getOnlineTimestamp( bot->getSpawnObj()->dataSetRow()) >= CTickEventHandler::getGameCycle()) nlwarning("Bots %s:%s spawn/despawn in the same tick ! despawn ignored", getPersistent().getName().c_str(), bot->getName().c_str()); else @@ -380,7 +406,7 @@ CGroupNpc::CGroupNpc(CMgrNpc* mgr, CAIAliasDescriptionNode* aliasTree, RYAI_MAP_ , CPersistentStateInstance(*mgr->getStateMachine()) { _BotsAreNamed = true; - + _PlayerAttackable = false; _BotAttackable = false; _AggroDist = 0; @@ -393,25 +419,25 @@ CGroupNpc::CGroupNpc(CMgrNpc* mgr, uint32 alias, std::string const& name, RYAI_M , CPersistentStateInstance(*mgr->getStateMachine()) { _BotsAreNamed = true; - + _PlayerAttackable = false; _BotAttackable = false; _AggroDist = 0; } -CGroupNpc::~CGroupNpc() +CGroupNpc::~CGroupNpc() { // avoid re-deletion by despawn _AutoDestroy = false; if (isSpawned()) // to avoid bad CDbgPtr link interpretation despawnGrp(); - + // clear all persistent state instance while (!_PSIChilds.empty()) { _PSIChilds.back()->setParentStateInstance(NULL); } - + _PSIChilds.clear(); } @@ -424,7 +450,7 @@ std::vector CGroupNpc::getMultiLineInfoString() const { std::vector container; std::vector strings; - + pushTitle(container, "CGroupNpc"); strings = CGroup::getMultiLineInfoString(); FOREACHC(itString, std::vector, strings) @@ -435,7 +461,7 @@ std::vector CGroupNpc::getMultiLineInfoString() const pushEntry(container, NLMISC::toString("attackable: player=%s bot=%s", _PlayerAttackable?"yes":"no", _BotAttackable?"yes":"no")); pushEntry(container, "state=" + (getState()?getState()->getName():string(""))); pushFooter(container); - + return container; } @@ -445,9 +471,9 @@ CMgrNpc& CGroupNpc::mgr() const } void CGroupNpc::updateDependencies(CAIAliasDescriptionNode const& aliasTree, CAliasTreeOwner* aliasTreeOwner) -{ +{ switch(aliasTree.getType()) - { + { case AITypeEvent: { CAIEventReaction* const eventPtr = NLMISC::safe_cast(mgr().getStateMachine()->eventReactions().getChildByAlias(aliasTree.getAlias())); @@ -477,19 +503,19 @@ IAliasCont* CGroupNpc::getAliasCont(TAIType type) CAliasTreeOwner* CGroupNpc::createChild(IAliasCont* cont, CAIAliasDescriptionNode* aliasTree) { CAliasTreeOwner* child = NULL; - + switch (aliasTree->getType()) { case AITypeOutpostBuilding: case AITypeBot: child = new CBotNpc(this, aliasTree); break; - + case AITypeFolder: default: break; } - + if (child!=NULL) cont->addAliasChild(child); return (child); @@ -503,7 +529,7 @@ CSmartPtr CGroupNpc::createSpawnGroup() void CGroupNpc::serviceEvent (const CServiceEvent &info) { CGroup::serviceEvent(info); - + // If the EGS crash if ( (info.getServiceName() == "EGS") && (info.getEventType() == CServiceEvent::SERVICE_DOWN) ) { @@ -527,19 +553,19 @@ void CGroupNpc::serviceEvent (const CServiceEvent &info) { processStateEvent(getEventContainer().EventEGSUp); } - + } bool CGroupNpc::spawn () -{ +{ if (CGroup::spawn()) { setStartState(getStartState()); // stateInstance. - + // inform the EGS of our existence - simulate connection of EGS serviceEvent (CServiceEvent(NLNET::TServiceId(0),std::string("EGS"),CServiceEvent::SERVICE_UP)); - + if (isAutoSpawn()) { CCont::iterator first(bots().begin()), last(bots().end()); @@ -550,7 +576,7 @@ bool CGroupNpc::spawn () bot->spawn(); } } - return true; + return true; } return false; } @@ -604,19 +630,19 @@ void CGroupNpc::addParameter(std::string const& parameter) _BotAttackable = true; break; } - + if (key == ATTACKABLE || key == PLAYER_ATTACKABLE) { - // the bots are attackable ! + // the bots are attackable ! _PlayerAttackable = true; - if (!IsRingShard) // In Ring shard, BotAttackable means attackable by bot not vulnerable - { + if (!IsRingShard) // In Ring shard, BotAttackable means attackable by bot not vulnerable + { // attackable implie vulnerable! _BotAttackable = true; } break; } - + if (key == BADGUY) { // the bots are bad guys! they will attack players in their aggro range. @@ -648,7 +674,7 @@ void CGroupNpc::addParameter(std::string const& parameter) } break; } - + if (key == ESCORT_RANGE) { if (!tail.empty()) @@ -663,7 +689,7 @@ void CGroupNpc::addParameter(std::string const& parameter) } break; } - + if (key == RESPAWN_TIME) { if (!tail.empty()) @@ -681,7 +707,7 @@ void CGroupNpc::addParameter(std::string const& parameter) } break; } - + if (key == DESPAWN_TIME) { if (!tail.empty()) @@ -699,7 +725,7 @@ void CGroupNpc::addParameter(std::string const& parameter) } break; } - + if (key == DENIED_ASTAR_FLAGS) { if (!tail.empty()) @@ -724,7 +750,7 @@ void CGroupNpc::addParameter(std::string const& parameter) if (parameter.empty()) break; - + nlwarning("CAIBotNpc::addParameter unknown parameter '%s'", parameter.c_str()); } } @@ -740,7 +766,7 @@ void CGroupNpc::delHpUpTrigger(float threshold, int eventId) CGroupNpc::THpTriggerList::iterator first, last, trigger; first = hpTriggers.lower_bound(threshold); last = hpTriggers.upper_bound(threshold); - + for (; first!=last; ++first) { if (first->second==eventId) @@ -761,7 +787,7 @@ void CGroupNpc::delHpDownTrigger(float threshold, int eventId) CGroupNpc::THpTriggerList::iterator first, last, trigger; first = hpTriggers.lower_bound(threshold); last = hpTriggers.upper_bound(threshold); - + for (; first!=last; ++first) { if (first->second==eventId) @@ -782,7 +808,7 @@ void CGroupNpc::delHpUpTrigger(float threshold, std::string cbFunc) CGroupNpc::THpTriggerList2::iterator first, last, trigger; first = hpTriggers.lower_bound(threshold); last = hpTriggers.upper_bound(threshold); - + for (; first!=last; ++first) { if (first->second==cbFunc) @@ -803,7 +829,7 @@ void CGroupNpc::delHpDownTrigger(float threshold, std::string cbFunc) CGroupNpc::THpTriggerList2::iterator first, last, trigger; first = hpTriggers.lower_bound(threshold); last = hpTriggers.upper_bound(threshold); - + for (; first!=last; ++first) { if (first->second==cbFunc) @@ -944,7 +970,7 @@ void CGroupNpc::addHandle(TDataSetRow playerRowId, uint32 missionAlias, uint32 D { _AutoSpawnWhenNoMoreHandle = isAutoSpawn(); } - + setAutoSpawn(true); // There is always a spawned object for group if (getSpawnObj() != NULL) @@ -959,7 +985,7 @@ void CGroupNpc::addHandle(TDataSetRow playerRowId, uint32 missionAlias, uint32 D SHandle h; h.MissionAlias = missionAlias; h.PlayerRowId = playerRowId; - + set::const_iterator it = _Handles.find(h); if (it != _Handles.end()) @@ -1033,7 +1059,7 @@ std::string CSpawnGroupNpc::buildDebugString(uint idx) const std::string CGroupNpc::buildDebugString(uint idx) const { - + switch(idx) { case 0: return "-- CGroupNpc -----------------------------"; @@ -1227,10 +1253,10 @@ NLMISC_COMMAND(verboseNPCGrp,"Turn on or off or check the state of verbose npc g { if(args.size()>1) return false; - + if(args.size()==1) StrToBool (VerboseLog, args[0]); - + nlinfo("VerboseLogging is %s",VerboseLog?"ON":"OFF"); return true; } diff --git a/ryzom/server/src/ai_service/ai_grp_npc.h b/ryzom/server/src/ai_service/ai_grp_npc.h index 518662e1a..a2cdf6509 100644 --- a/ryzom/server/src/ai_service/ai_grp_npc.h +++ b/ryzom/server/src/ai_service/ai_grp_npc.h @@ -39,43 +39,48 @@ class CSpawnGroupNpc { public: CSpawnGroupNpc(CPersistent& owner); - + virtual ~CSpawnGroupNpc() { } - + CGroupNpc& getPersistent() const; - + virtual void spawnBots(); virtual void despawnBots(bool immediately); - + void update(); - + void sendInfoToEGS() const; - + std::string buildDebugString(uint idx) const; - + void stateChange(CAIState const* oldState, CAIState const* newState); - + void botHaveDied(CBotNpc* bot); void botHaveDespawn(CBotNpc* bot); void botHaveSpawn(CBotNpc* bot); - + public: void resetSlowUpdateCycle(); static void setSlowUpdatePeriod(uint32 ticks); static uint32 getSlowUpdatePeriod(); static void displaySlowUpdateBuckets(); - + void noMoreHandle(uint32 nNbTickBeforeDespawn); void handlePresent(); + // set the cell + void setCell(sint32 cell) { _Cell = cell; } + sint32 getCell() { return _Cell; } + private: bool _GroupInVision; CAITimer _BotUpdateTimer; uint32 _LastUpdate; // gamecycle at which update() last called uint32 _LastBotUpdate; uint32 _SlowUpdateCycle; + sint32 _Cell; static uint32 _SlowUpdatePeriod; - static std::vector _SlowUpdateBuckets; + static std::vector _SlowUpdateBuckets; bool _DespawnBotsWhenNoMoreHandleTimerActive; CAITimer _DespawnBotsWhenNoMoreHandleTimer; @@ -93,13 +98,13 @@ class CGroupNpc { public: typedef std::set > TFactionAttackableSet; - + public: CGroupNpc(CMgrNpc* mgr, CAIAliasDescriptionNode* aliasTree, RYAI_MAP_CRUNCH::TAStarFlag denyFlags); CGroupNpc(CMgrNpc* mgr, uint32 alias, std::string const& name, RYAI_MAP_CRUNCH::TAStarFlag denyFlags); - + virtual ~CGroupNpc(); - + /// @name CChild implementation //@{ // virtual std::string getIndexString() const; @@ -107,63 +112,63 @@ public: virtual std::vector getMultiLineInfoString() const; // virtual std::string getFullName() const; //@} - + CDynGrpBase* getGrpDynBase() { return this; } - - ////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////// // PersistentStateInstance - + CAliasTreeOwner* aliasTreeOwner() { return this; } - + void stateChange(CAIState const* oldState, CAIState const* newState); - + CGroup* getGroup() { return this; } - + ////////////////////////////////////////////////////////////////////////// - + virtual void lastBotDespawned(); virtual void firstBotSpawned(); - + // debugging stuff CDebugHistory* getDebugHistory() { return this; } - + CAIS::CCounter& getSpawnCounter(); - + RYZOMID::TTypeId getRyzomType() { return RYZOMID::npc; } - + NLMISC::CSmartPtr createSpawnGroup(); - + CSpawnGroupNpc* getSpawnObj() const { return NLMISC::type_cast(CGroup::getSpawnObj()); } - + CPersistentStateInstance* getPersistentStateInstance() { return this; } - + void setEvent(uint eventId); virtual void serviceEvent (const CServiceEvent &info); - + void init() { } - + void release() { } - + // inheritted virtual interface ------------------------------------ virtual bool spawn(); virtual void despawnGrp(); - + virtual std::string buildDebugString(uint idx) const; virtual void display(CStringWriter& stringWriter) const; - + void updateDependencies(CAIAliasDescriptionNode const& aliasTree, CAliasTreeOwner* aliasTreeOwner); IAliasCont* getAliasCont(AITYPES::TAIType type); - CAliasTreeOwner* createChild(IAliasCont* cont, CAIAliasDescriptionNode* aliasTree); - + CAliasTreeOwner* createChild(IAliasCont* cont, CAIAliasDescriptionNode* aliasTree); + // basic utilities ------------------------------------------------- CMgrNpc& mgr() const; - + // management of the bot population -------------------------------- // allocator for allocating new bot objects - CGroupNpc* newBot(); - + CGroupNpc* newBot(); + bool botsAreNamed() { return _BotsAreNamed; } void setBotsAreNamedFlag() { _BotsAreNamed = true; } void clrBotsAreNamedFlag() { _BotsAreNamed = false; } @@ -176,7 +181,7 @@ public: void setStateEventAlias(const std::string &stateEvent, uint32 alias); uint32 getStateEventAlias(const std::string &stateEvent); - + // Parameter management ------------------------------------- void clearParameters(); // Parse a paremeter for this group. @@ -185,65 +190,65 @@ public: // set if the bots of the group are attackable by players void setPlayerAttackable(bool playerAttackable) { _PlayerAttackable = playerAttackable; } bool getPlayerAttackable() { return _PlayerAttackable; } - + // set if the bots of the group are attackable by other bots void setBotAttackable(bool botAttackable) { _BotAttackable = botAttackable; } bool getBotAttackable() { return _BotAttackable; } - + void setFactionAttackableAbove(std::string faction, sint32 threshold, bool botAttackable); TFactionAttackableSet const& getFactionAttackableAbove() const { return _FactionAttackableAbove; } void setFactionAttackableBelow(std::string faction, sint32 threshold, bool botAttackable); TFactionAttackableSet const& getFactionAttackableBelow() const { return _FactionAttackableBelow; } bool isFactionAttackable(std::string faction, sint32 fame); - + uint32 getAggroDist() { return _AggroDist; } - + uint32& despawnTime() { return _DespawnTime; } uint32& respawnTime() { return _RespawnTime; } - + AITYPES::CPropertySetWithExtraList& faction() { return _faction; } AITYPES::CPropertySetWithExtraList& ennemyFaction() { return _ennemyFaction; } AITYPES::CPropertySetWithExtraList& friendFaction() { return _friendFaction; } - + AITYPES::CPropertySetWithExtraList const& faction() const { return _faction; } AITYPES::CPropertySetWithExtraList const& ennemyFaction() const { return _ennemyFaction; } AITYPES::CPropertySetWithExtraList const& friendFaction() const { return _friendFaction; } - + public: void addHpUpTrigger(float threshold, int eventId); void delHpUpTrigger(float threshold, int eventId); void addHpUpTrigger(float threshold, std::string cbFunc); void delHpUpTrigger(float threshold, std::string cbFunc); - + void addHpDownTrigger(float threshold, int eventId); void delHpDownTrigger(float threshold, int eventId); void addHpDownTrigger(float threshold, std::string cbFunc); void delHpDownTrigger(float threshold, std::string cbFunc); - + bool haveHpTriggers(); void hpTriggerCb(float oldVal, float newVal); - + void addNamedEntityListener(std::string const& name, std::string const& prop, int event); void delNamedEntityListener(std::string const& name, std::string const& prop, int event); void addNamedEntityListener(std::string const& name, std::string const& prop, std::string functionName); void delNamedEntityListener(std::string const& name, std::string const& prop, std::string functionName); void namedEntityListenerCb(std::string const& name, std::string const& prop); - + void addHandle(TDataSetRow playerRowId, uint32 missionAlias, uint32 DespawnTimeInTick); void delHandle(TDataSetRow playerRowId, uint32 missionAlias); - + uint32 getTimerWhenNoMoreHandle(); void setSpawnZone(const CNpcZone *zone) { _SpawnZone = zone; } const CNpcZone *getSpawnZone() const { return _SpawnZone; } - + void setColour(uint8 colour); - + void setOutpostSide(OUTPOSTENUMS::TPVPSide side); void setOutpostFactions(std::string const& alias, OUTPOSTENUMS::TPVPSide side); bool isRingGrp() const { return _RingGrp;} - + private: /// group basics bool _BotsAreNamed; // true if the bots in the group are explicitly placed in level editor tool - false otherwise @@ -261,20 +266,20 @@ private: uint32 _RespawnTime; /// Despawn time in ticks uint32 _DespawnTime; - - - + + + AITYPES::CPropertySetWithExtraList _faction; AITYPES::CPropertySetWithExtraList _ennemyFaction; AITYPES::CPropertySetWithExtraList _friendFaction; - + typedef std::multimap THpTriggerList; typedef std::multimap THpTriggerList2; THpTriggerList _hpUpTriggers; THpTriggerList _hpDownTriggers; THpTriggerList2 _hpUpTriggers2; THpTriggerList2 _hpDownTriggers2; - + typedef std::multimap, int> TNamedEntityListenerList; TNamedEntityListenerList _namedEntityListeners; typedef std::multimap, std::string> TNamedEntityListenerList2; @@ -287,11 +292,11 @@ private: { TDataSetRow PlayerRowId; uint32 MissionAlias; - + bool operator < (const SHandle &h) const { if (PlayerRowId < h.PlayerRowId) return true; - + if (PlayerRowId == h.PlayerRowId) if (MissionAlias < h.MissionAlias) return true; diff --git a/ryzom/server/src/ai_service/ai_instance.cpp b/ryzom/server/src/ai_service/ai_instance.cpp index 5c7cf70fd..a4caf11fe 100644 --- a/ryzom/server/src/ai_service/ai_instance.cpp +++ b/ryzom/server/src/ai_service/ai_instance.cpp @@ -675,8 +675,7 @@ static float randomAngle() return val; } -CGroupNpc* CAIInstance::eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const& sheetId, CAIVector const& pos, double dispersionRadius, bool spawnBots, double orientation, const std::string &botsName, const std::string &look) -{ +CGroupNpc* CAIInstance::eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const& sheetId, CAIVector const& pos, double dispersionRadius, bool spawnBots, double orientation, const std::string &botsName, const std::string &look, sint32 cell) { if (!_EventNpcManager) return NULL; @@ -772,6 +771,8 @@ CGroupNpc* CAIInstance::eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const& return NULL; } + spawnGroup->setCell(cell); + NLMISC::CSmartPtr destZone = NLMISC::CSmartPtr(new CNpcZonePlaceNoPrim()); destZone->setPosAndRadius(AITYPES::vp_auto, CAIPos(pos, 0, 0), (uint32)(dispersionRadius*1000.)); spawnGroup->movingProfile().setAIProfile(new CGrpProfileWanderNoPrim(spawnGroup, destZone)); @@ -941,7 +942,7 @@ void cbEventCreateNpcGroup( NLNET::CMessage& msgin, const std::string &serviceNa CAIInstance* instance = CAIS::instance().getAIInstance(instanceNumber); if (instance) { - CGroupNpc* npcGroup = instance->eventCreateNpcGroup(nbBots, sheetId, CAIVector(((double)x)/1000.0, ((double)y)/1000.0), dispersionRadius, spawnBots, ((double)orientation)/1000.0, botsName, look); + CGroupNpc* npcGroup = instance->eventCreateNpcGroup(nbBots, sheetId, CAIVector(((double)x)/1000.0, ((double)y)/1000.0), dispersionRadius, spawnBots, ((double)orientation)/1000.0, botsName, look, cell); if (npcGroup != NULL) { _PlayersLastCreatedNpcGroup[playerId] = npcGroup->getName(); diff --git a/ryzom/server/src/ai_service/ai_instance.h b/ryzom/server/src/ai_service/ai_instance.h index 2b5114441..0d7cf647a 100644 --- a/ryzom/server/src/ai_service/ai_instance.h +++ b/ryzom/server/src/ai_service/ai_instance.h @@ -208,7 +208,7 @@ public: return NULL; } - CGroupNpc* eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const& sheetId, CAIVector const& pos, double dispersionRadius, bool spawnBots, double orientation, const std::string &botsName, const std::string &look); + CGroupNpc* eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const& sheetId, CAIVector const& pos, double dispersionRadius, bool spawnBots, double orientation, const std::string &botsName, const std::string &look, sint32 cell=0); /// create a new easter egg CBotEasterEgg* createEasterEgg(uint32 easterEggId, NLMISC::CSheetId const& sheetId, std::string const& botName, double x, double y, double z, double heading, const std::string& look); diff --git a/ryzom/server/src/gpm_service/messages.cpp b/ryzom/server/src/gpm_service/messages.cpp index 36f4c0b4c..ef2508cd7 100644 --- a/ryzom/server/src/gpm_service/messages.cpp +++ b/ryzom/server/src/gpm_service/messages.cpp @@ -46,7 +46,7 @@ using namespace NLNET; /****************************************************************\ - cbAddEntity() + cbAddEntity() \****************************************************************/ /* void cbAddEntity( CMessage& msgin, const string &serviceName, uint16 serviceId ) @@ -91,7 +91,7 @@ void cbAddEntity( CMessage& msgin, const string &serviceName, uint16 serviceId ) */ /****************************************************************\ - cbAddIAObject() + cbAddIAObject() \****************************************************************/ /* void cbAddIAObject( CMessage& msgin, const string &serviceName, uint16 serviceId ) @@ -102,12 +102,12 @@ void cbAddIAObject( CMessage& msgin, const string &serviceName, uint16 serviceId */ /****************************************************************\ - cbAddEntities() + cbAddEntities() \****************************************************************/ /*void cbAddEntities( CMessage& msgin, const string &serviceName, uint16 serviceId ) { //nlinfo("received ADD_ENTITIES request"); - + uint32 entitiesCount; msgin.serial( entitiesCount ); @@ -153,7 +153,7 @@ void cbRemoveEntity( CMessage& msgin, const string &serviceName, uint16 serviceI CEntityId id; id.serial( msgin ); - + nlinfo("received REMOVE_ENTITY request for id %s", id.toString().c_str() ); CWorldPositionManager::onRemoveEntity( id ); @@ -170,7 +170,7 @@ void cbRemoveEntity( CMessage& msgin, const string &serviceName, uint16 serviceI list ids; msgin.serialCont( ids ); - + list idsAgents; list::iterator it; @@ -180,7 +180,7 @@ void cbRemoveEntity( CMessage& msgin, const string &serviceName, uint16 serviceI nlinfo(" REMOVE_ENTITY id %s", (*it).toString().c_str() ); if( (*it).getType() == RYZOMID::npc ) - { + { idsAgents.push_back( *it ); } } @@ -188,7 +188,7 @@ void cbRemoveEntity( CMessage& msgin, const string &serviceName, uint16 serviceI if( idsAgents.size() != 0 ) { CMessage msgout("REMOVE_ENTITY"); - + for ( it = idsAgents.begin() ; it != idsAgents.end() ; ++it) msgout.serial( const_cast (*it) ); @@ -199,7 +199,7 @@ void cbRemoveEntity( CMessage& msgin, const string &serviceName, uint16 serviceI /****************************************************************\ - CGPMPlayerPrivilegeInst::callback + CGPMPlayerPrivilegeInst::callback \****************************************************************/ void CGPMPlayerPrivilegeInst::callback (const std::string &name, NLNET::TServiceId id) { @@ -216,7 +216,7 @@ void CGPMPlayerPrivilegeInst::callback (const std::string &name, NLNET::TService } /****************************************************************\ - cbSetPlayerFlags() + cbSetPlayerFlags() \****************************************************************/ void cbSetPlayerFlags( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) { @@ -250,7 +250,7 @@ void cbBag( CMessage& msgin, const string &serviceName, NLNET::TServiceId servic /****************************************************************\ - cbLoadContinent() + cbLoadContinent() \****************************************************************/ void cbLoadContinent( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) { @@ -272,7 +272,7 @@ void cbLoadContinent( CMessage& msgin, const string &serviceName, NLNET::TServic } /****************************************************************\ - cbRemoveContinent() + cbRemoveContinent() \****************************************************************/ void cbRemoveContinent( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) { @@ -284,10 +284,10 @@ void cbRemoveContinent( CMessage& msgin, const string &serviceName, NLNET::TServ // remove continent from position manager CWorldPositionManager::removeContinent(continent); } - - + + /****************************************************************\ - cbCreateIndoorUnit() + cbCreateIndoorUnit() \****************************************************************/ void cbCreateIndoorUnit( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) { @@ -310,7 +310,7 @@ void cbCreateIndoorUnit( CMessage& msgin, const string &serviceName, NLNET::TSer } /****************************************************************\ - cbCreateBuilding() + cbCreateBuilding() \****************************************************************/ void cbCreateBuilding( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) { @@ -321,12 +321,12 @@ void cbCreateBuilding( CMessage& msgin, const string &serviceName, NLNET::TServi msgin.serial(continent); msgin.serial(id); msgin.serial(position); - + CWorldPositionManager::createBuildingInstance(continent, id, position); } /****************************************************************\ - cbCreateObstacle() + cbCreateObstacle() \****************************************************************/ void cbCreateObstacle( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) { @@ -342,7 +342,7 @@ void cbCreateObstacle( CMessage& msgin, const string &serviceName, NLNET::TServi } /****************************************************************\ - cbRemoveObstacle() + cbRemoveObstacle() \****************************************************************/ void cbRemoveObstacle( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) { @@ -356,7 +356,7 @@ void cbRemoveObstacle( CMessage& msgin, const string &serviceName, NLNET::TServi } /****************************************************************\ - cbSetObstacle() + cbSetObstacle() \****************************************************************/ void cbSetObstacle( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) { @@ -371,7 +371,7 @@ void cbSetObstacle( CMessage& msgin, const string &serviceName, NLNET::TServiceI } /****************************************************************\ - cbUpdateEntityPosition() + cbUpdateEntityPosition() \****************************************************************/ /* void cbUpdateEntityPosition( CMessage& msgin, const string &serviceName, uint16 serviceId ) @@ -403,7 +403,7 @@ void cbUpdateEntityPosition( CMessage& msgin, const string &serviceName, uint16 */ /****************************************************************\ - cbUpdateEntitiesPositions() + cbUpdateEntitiesPositions() \****************************************************************/ /* void cbUpdateEntitiesPositions( CMessage& msgin, const string &serviceName, uint16 serviceId ) @@ -439,7 +439,7 @@ void cbUpdateEntitiesPositions( CMessage& msgin, const string &serviceName, uint */ /****************************************************************\ - cbUpdateEntitiesPositions() + cbUpdateEntitiesPositions() \****************************************************************/ /* void cbUpdateEntitiesPositionsUsingSize( CMessage& msgin, const string &serviceName, uint16 serviceId ) @@ -484,7 +484,7 @@ void cbUpdateEntitiesOrientationsUsingSize( CMessage& msgin, const string &servi /****************************************************************\ - cbEntityTeleport() + cbEntityTeleport() \****************************************************************/ void cbEntityTeleportation( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId ) { @@ -493,7 +493,7 @@ void cbEntityTeleportation( CMessage& msgin, const string &serviceName, NLNET::T id.serial( msgin ); TDataSetRow index = CWorldPositionManager::getEntityIndex(id); - + if (!index.isValid()) return; @@ -506,7 +506,7 @@ void cbEntityTeleportation( CMessage& msgin, const string &serviceName, NLNET::T pCGPMS->RingVisionUniverse->setEntityPosition(index,0,0); // update the player coordinates in the mirror - CMirrorPropValue1DS( TheDataset, index, DSPropertyPOSX )= 0; + CMirrorPropValue1DS( TheDataset, index, DSPropertyPOSX )= 0; CMirrorPropValue1DS( TheDataset, index, DSPropertyPOSY )= 0; CMirrorPropValue1DS( TheDataset, index, DSPropertyPOSZ )= 0; } @@ -559,7 +559,7 @@ void cbEntityTeleportation( CMessage& msgin, const string &serviceName, NLNET::T pCGPMS->MoveChecker->teleport(index, x, y, tick); // update the player coordinates in the mirror - CMirrorPropValue1DS( TheDataset, index, DSPropertyPOSX )= x; + CMirrorPropValue1DS( TheDataset, index, DSPropertyPOSX )= x; CMirrorPropValue1DS( TheDataset, index, DSPropertyPOSY )= y; CMirrorPropValue1DS( TheDataset, index, DSPropertyPOSZ )= z; CMirrorPropValue1DS( TheDataset, index, DSPropertyORIENTATION )= t; @@ -573,7 +573,7 @@ void cbEntityTeleportation( CMessage& msgin, const string &serviceName, NLNET::T } else { - nlinfo("MSG: Teleporting entity %d to continent %d cell %d (%d, %d, %d) at tick: %d",index.getIndex(),continent,cell,x,y,z,tick); + //nlinfo("MSG: Teleporting entity %d to continent %d cell %d (%d, %d, %d) at tick: %d",index.getIndex(),continent,cell,x,y,z,tick); CWorldPositionManager::teleport(index, x, y, z, t, continent, cell, tick); } } @@ -592,25 +592,25 @@ void cbEntityPosition( CMessage& msgin, const string &serviceName, NLNET::TServi { // CEntityId sender; // sender.serial( msgin ); - + CEntityId id; id.serial( msgin ); TDataSetRow index = CWorldPositionManager::getEntityIndex(id); const CWorldEntity *pEntity = CWorldPositionManager::getEntity( index ); - + if( pEntity ) { CMessage msgout( "ENTITY_POS" ); // msgout.serial( sender ); msgout.serial( id ); - + sint32 val; val = pEntity->X(); msgout.serial( val ); - + val = pEntity->Y(); msgout.serial( val ); @@ -824,7 +824,7 @@ void cbEntitiesArroundEntity( NLNET::CMessage& msgin, const std::string &service void cbEndEntitiesArroundEntity( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId ) { CEntityId id; // base entity for decide list of entities arround this - + msgin.serial( id ); CWorldPositionManager::unrequestForEntityAround( serviceId, id ); @@ -870,10 +870,10 @@ void cbR2ForceVisionReset( NLNET::CMessage& msgin, const std::string &serviceNam msgin.serial(eid); - + TDataSetRow entityIndex = TheDataset.getDataSetRow( eid ); BOMB_IF(!entityIndex.isValid() , "Try to reset the vision of a invalid player "+eid.toString(), return); - + pCGPMS->RingVisionUniverse->forceResetVision(entityIndex); } @@ -925,14 +925,14 @@ TUnifiedCallbackItem CbGPMSArray[]= // / *?DEAD?* / { "DISABLE_VISION_PROC", cbDisableVisionProcessing }, // ask for player vision not to be updated any longer /*?DEAD?*/ { "ENTITY_POS", cbEntityPosition }, // ask for position of an entity - + /*?DEAD?*/ { "ASK_VISION_ARROUND_ENTITY", cbEntitiesArroundEntity }, // ask for vision update around an entity /*?DEAD?*/ { "UNASK_VISION_ARROUND_ENTITY",cbEndEntitiesArroundEntity }, // remove vision update around an entity /*?DEAD?*/ { "VISION_REQUEST", cbVisionRequest }, { "SET_PLAYER_FLAGS", cbSetPlayerFlags }, // set flags for player (limit speed, etc) { "R2_VISION_REFRESH", cbR2ForceVisionReset }, // force the update of the vision (because some message must have been discared in Ring (in edition mode the network is not listen) -}; +};