Merge branch 'fixes'

feature/prepare-cross-merge
Nuno 4 years ago committed by kaetemi
parent 7f33e9bdd6
commit 0e833c37ef
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -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<CSpawnGroup>& 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.
@ -343,8 +346,31 @@ void CSpawnGroupNpc::spawnBots()
FOREACH(itBot, CCont<CBot>, 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);
}
}
}
}

@ -68,12 +68,17 @@ public:
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<uint32> _SlowUpdateBuckets;

@ -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<CNpcZonePlaceNoPrim> destZone = NLMISC::CSmartPtr<CNpcZonePlaceNoPrim>(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();

@ -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);

@ -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);
}
}

Loading…
Cancel
Save