Merge with develop

This commit is contained in:
kervala 2015-12-18 18:07:11 +01:00
parent 2a2b50cab6
commit fa19cb0f6d
8 changed files with 181 additions and 11 deletions

View file

@ -370,6 +370,7 @@ CBot::CBot(CGroup* owner, CAIAliasDescriptionNode* alias)
: CAliasChild<CGroup>(owner, alias) : CAliasChild<CGroup>(owner, alias)
, _VerticalPos(AITYPES::vp_auto) , _VerticalPos(AITYPES::vp_auto)
, _Sheet(NULL) , _Sheet(NULL)
, _ClientCSheet(NULL)
, _Stuck(false) , _Stuck(false)
, _IgnoreOffensiveActions(false) , _IgnoreOffensiveActions(false)
, _Healer(false) , _Healer(false)
@ -384,6 +385,7 @@ CBot::CBot(CGroup* owner, uint32 alias, std::string const& name)
: CAliasChild<CGroup>(owner,alias, name) : CAliasChild<CGroup>(owner,alias, name)
, _VerticalPos(AITYPES::vp_auto) , _VerticalPos(AITYPES::vp_auto)
, _Sheet(NULL) , _Sheet(NULL)
, _ClientCSheet(NULL)
, _Stuck(false) , _Stuck(false)
, _IgnoreOffensiveActions(false) , _IgnoreOffensiveActions(false)
, _Healer(false) , _Healer(false)
@ -695,6 +697,17 @@ void CBot::setClientSheet(const std::string & clientSheetName)
nlwarning("Invalid CLIENT_SHEET %s", clientSheetName.c_str()); nlwarning("Invalid CLIENT_SHEET %s", clientSheetName.c_str());
return; return;
} }
AISHEETS::ICreatureCPtr sheet = AISHEETS::CSheets::getInstance()->lookup(NLMISC::CSheetId(clientSheetName));
if (!sheet || sheet->SheetId() == NLMISC::CSheetId::Unknown)
{
nlwarning("Unknown sheet %s", clientSheetName.c_str());
return;
}
_ClientCSheet = sheet;
sheetChanged(); sheetChanged();
} }
} }

View file

@ -181,6 +181,19 @@ public:
/// @name AI objects hierarchy access /// @name AI objects hierarchy access
//@{ //@{
CAIInstance* getAIInstance() const; CAIInstance* getAIInstance() const;
AISHEETS::ICreatureCPtr getClientCSheet() const
{
if (_ClientSheet != NLMISC::CSheetId::Unknown && _ClientCSheet)
return _ClientCSheet;
return _Sheet;
}
NLMISC::CSheetId getClientSheet() const
{
return _ClientSheet;
}
CGroup& getGroup() { return *getOwner(); } CGroup& getGroup() { return *getOwner(); }
CAliasTreeOwner const* getAliasTreeOwner() const { return this; } CAliasTreeOwner const* getAliasTreeOwner() const { return this; }
CSpawnBot* getSpawnObj() const; CSpawnBot* getSpawnObj() const;
@ -270,6 +283,7 @@ protected:
private: private:
AISHEETS::ICreatureCPtr _Sheet; AISHEETS::ICreatureCPtr _Sheet;
AISHEETS::ICreatureCPtr _ClientCSheet;
NLMISC::CSheetId _ClientSheet; NLMISC::CSheetId _ClientSheet;
bool _Stuck; bool _Stuck;
bool _IgnoreOffensiveActions; bool _IgnoreOffensiveActions;

View file

@ -514,6 +514,8 @@ bool CFightOrganizer::reorganizeIteration(CBot* bot)
CAIVector movingVector; CAIVector movingVector;
double fear=1.0f; double fear=1.0f;
CAIEntityPhysical* target = (CAIEntityPhysical*)spawnBot->getTarget();
FOREACH(it, std::vector<CAIEntityPhysical*>, botList) FOREACH(it, std::vector<CAIEntityPhysical*>, botList)
{ {
CAIEntityPhysical *const entity=(*it); CAIEntityPhysical *const entity=(*it);
@ -565,6 +567,27 @@ bool CFightOrganizer::reorganizeIteration(CBot* bot)
float score = (float)(entity->_AggroScore*slotCoef); float score = (float)(entity->_AggroScore*slotCoef);
if (target && target->getRyzomType() == RYZOMID::player)
{
if (entity != target)
{
CBotPlayer const* const ptarget = NLMISC::safe_cast<CBotPlayer const*>(target);
if (entity->getRyzomType() == RYZOMID::player)
{
CBotPlayer const* const player = NLMISC::safe_cast<CBotPlayer const*>(entity);
if ( ptarget && player && spawnBot->getAggroFor(entity->dataSetRow()) <= spawnBot->getAggroFor(ptarget->dataSetRow()) && (
ptarget->getCurrentTeamId() == CTEAM::InvalidTeamId ||
player->getCurrentTeamId() == CTEAM::InvalidTeamId ||
player->getCurrentTeamId() != ptarget->getCurrentTeamId()
)
)
{
score = 0;
}
}
}
}
if (score>=BestChooseScore) // add distance and bot profile compatibility. if (score>=BestChooseScore) // add distance and bot profile compatibility.
{ {
BestChooseScore=score; BestChooseScore=score;
@ -583,7 +606,7 @@ bool CFightOrganizer::reorganizeIteration(CBot* bot)
{ {
_HaveEnnemy=true; _HaveEnnemy=true;
nlassert(ennemy->getRyzomType()!=debugCheckedType); nlassert(ennemy->getRyzomType()!=debugCheckedType);
if (((CAIEntityPhysical*)spawnBot->getTarget())==ennemy) if (target == ennemy)
{ {
return true; return true;
} }

View file

@ -277,7 +277,11 @@ static void s_calcRanges(
_RangeMax = CBotProfileFightHeal::fightRangeMaxRange; _RangeMax = CBotProfileFightHeal::fightRangeMaxRange;
} }
} }
_RangeMax += _Bot->getPersistent().getSheet()->Radius() * _Bot->getPersistent().getSheet()->Scale(); if (_Bot->getPersistent().getClientSheet() != NLMISC::CSheetId::Unknown && _Bot->getPersistent().getClientCSheet())
_RangeMax += _Bot->getPersistent().getClientCSheet()->Radius() * _Bot->getPersistent().getClientCSheet()->Scale();
else
_RangeMax += _Bot->getPersistent().getSheet()->Radius() * _Bot->getPersistent().getSheet()->Scale();
_RangeCalculated = true; _RangeCalculated = true;
} }

View file

@ -31,6 +31,7 @@
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
using namespace NLNET;
using namespace MULTI_LINE_FORMATER; using namespace MULTI_LINE_FORMATER;
CAIInstance::CAIInstance(CAIS* owner) CAIInstance::CAIInstance(CAIS* owner)
@ -694,6 +695,11 @@ CGroupNpc* CAIInstance::eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const&
bot->equipmentInit(); bot->equipmentInit();
bot->initEnergy(/*groupEnergyCoef()*/0); bot->initEnergy(/*groupEnergyCoef()*/0);
CAIVector rpos(pos); CAIVector rpos(pos);
if (dispersionRadius == 0)
{
nlinfo("Stucked !");
bot->setStuck(true);
}
// Spawn all randomly except if only 1 bot // Spawn all randomly except if only 1 bot
if (nbBots > 1) if (nbBots > 1)
{ {
@ -853,6 +859,7 @@ void cbEventCreateNpcGroup( NLNET::CMessage& msgin, const std::string &serviceNa
uint32 instanceNumber; uint32 instanceNumber;
sint32 x; sint32 x;
sint32 y; sint32 y;
sint32 z;
sint32 orientation; sint32 orientation;
uint32 nbBots; uint32 nbBots;
NLMISC::CSheetId sheetId; NLMISC::CSheetId sheetId;
@ -861,12 +868,14 @@ void cbEventCreateNpcGroup( NLNET::CMessage& msgin, const std::string &serviceNa
bool spawnBots; bool spawnBots;
std::string botsName; std::string botsName;
std::string look; std::string look;
sint32 cell;
msgin.serial(messageVersion); msgin.serial(messageVersion);
nlassert(messageVersion==1); nlassert(messageVersion==1);
msgin.serial(instanceNumber); msgin.serial(instanceNumber);
msgin.serial(playerId); msgin.serial(playerId);
msgin.serial(x); msgin.serial(x);
msgin.serial(y); msgin.serial(y);
msgin.serial(z);
msgin.serial(orientation); msgin.serial(orientation);
msgin.serial(nbBots); msgin.serial(nbBots);
msgin.serial(sheetId); msgin.serial(sheetId);
@ -874,13 +883,39 @@ void cbEventCreateNpcGroup( NLNET::CMessage& msgin, const std::string &serviceNa
msgin.serial(spawnBots); msgin.serial(spawnBots);
msgin.serial(botsName); msgin.serial(botsName);
msgin.serial(look); msgin.serial(look);
msgin.serial(cell);
CAIInstance* instance = CAIS::instance().getAIInstance(instanceNumber); CAIInstance* instance = CAIS::instance().getAIInstance(instanceNumber);
if (instance) if (instance)
{ {
CGroupNpc* npcGroup = instance->eventCreateNpcGroup(nbBots, sheetId, CAIVector((double)x/1000., (double)y/1000.), dispersionRadius, spawnBots, (double)orientation/1000., 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);
if (npcGroup != NULL) if (npcGroup != NULL)
{ {
_PlayersLastCreatedNpcGroup[playerId] = npcGroup->getName(); _PlayersLastCreatedNpcGroup[playerId] = npcGroup->getName();
FOREACH(botIt, CCont<CBot>, npcGroup->bots())
{
CSpawnBot* pbot = botIt->getSpawnObj();
if (pbot!=NULL)
{
CEntityId id = pbot->getEntityId();
float t = 0;
uint8 cont = 0;
uint8 one = 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( one );
sendMessageViaMirror("GPMS", msgout2);
}
}
} }
} }
} }

View file

@ -1665,6 +1665,35 @@ bool execScriptGroupByName(CStringWriter& stringWriter, TCommand const& args)
return true; return true;
} }
NLMISC_COMMAND(getDatasetId,"get datasetid of bots with name matchiong the given filter", "<groupFilter>")
{
if (args.size()!=1)
return false;
string const& botName = args[0];
string DatasetIds;
vector<CBot*> bots;
/// try to find the bot name
buildFilteredBotList(bots, botName);
if (bots.empty())
{
log.displayNL("ERR: No bot correspond to name %s", botName.c_str());
return false;
}
else
{
FOREACH(itBot, vector<CBot*>, bots)
{
CBot* bot = *itBot;
DatasetIds += bot->getSpawnObj()->dataSetRow().toString()+"|";
}
}
log.displayNL("%s", DatasetIds.c_str());
return true;
}
NLMISC_COMMAND(script,"execute a script for groups matching the given filter [buffered]","<groupFilter> <code>") NLMISC_COMMAND(script,"execute a script for groups matching the given filter [buffered]","<groupFilter> <code>")
{ {
clearBufferedRetStrings(); clearBufferedRetStrings();

View file

@ -985,11 +985,63 @@ void CBSAIDeathReport::callback(const std::string &name, NLNET::TServiceId id)
spawnGrp.botHaveDied (bot); spawnGrp.botHaveDied (bot);
bot->notifyBotDeath(); bot->notifyBotDeath();
std::string eventBotKilled;
if (spawnGrp.getProfileParameter("event_bot_killed", eventBotKilled) && !eventBotKilled.empty())
{
nlinfo("NPC: TRIGGER EVENT BOT KILLED");
}
spawnGrp.getPersistent().processStateEvent(mgr.EventBotKilled); spawnGrp.getPersistent().processStateEvent(mgr.EventBotKilled);
if (!spawnGrp.isGroupAlive(0*1)) std::string eventGroupKilled;
if (!spawnGrp.isGroupAlive(0*1))
{
if (spawnGrp.getProfileParameter("event_group_killed", eventGroupKilled) && !eventGroupKilled.empty())
{
nlinfo("NPC: TRIGGER EVENT GROUP KILLED");
}
spawnGrp.getPersistent().processStateEvent(mgr.EventGrpEliminated); spawnGrp.getPersistent().processStateEvent(mgr.EventGrpEliminated);
}
if (!eventBotKilled.empty() || !eventGroupKilled.empty())
{
CSpawnBot *const spBot = static_cast<CSpawnBot*>(phys);
// make a vector of aggroable player
CBotAggroOwner::TBotAggroList const& aggroList = spBot->getBotAggroList();
//typedef std::map<TDataSetRow, TAggroEntryPtr> TBotAggroList;
CBotAggroOwner::TBotAggroList::const_iterator aggroIt(aggroList.begin()), aggroEnd(aggroList.end());
TDataSetRow foundRow = TDataSetRow();
std::vector<TDataSetRow> playerAggroable;
for (; aggroIt != aggroEnd; ++aggroIt)
{
if (CMirrors::getEntityId(aggroIt->first).getType() != RYZOMID::player)
continue;
CAIEntityPhysical* ep = CAIS::instance().getEntityPhysical(aggroIt->first);
if (!ep)
continue;
CBotPlayer const* const player = NLMISC::safe_cast<CBotPlayer const*>(ep);
if (!player)
continue;
if (!player->isAggroable())
continue;
playerAggroable.push_back(aggroIt->first);
}
NLNET::CMessage msgout("TRIGGER_WEBIG");
if (!eventBotKilled.empty())
msgout.serial(eventBotKilled);
else
msgout.serial(eventGroupKilled);
uint32 nbPlayers = (uint32)playerAggroable.size();
msgout.serial(nbPlayers);
for (uint32 i = 0; i < nbPlayers; i++)
{
msgout.serial(playerAggroable[i]);
}
sendMessageViaMirror("EGS", msgout);
}
} }
break; break;
case RYZOMID::creature: case RYZOMID::creature:

View file

@ -1482,14 +1482,14 @@ void setPlayerController_ss_(CStateInstance* entity, CScriptStack& stack)
CAIEntityPhysical *botEntity = inst->getEntity(botId); CAIEntityPhysical *botEntity = inst->getEntity(botId);
if (botEntity) if (botEntity)
{ {
if ((bot = dynamic_cast<CSpawnBotNpc*>(botEntity)) if ((bot = dynamic_cast<CSpawnBotNpc*>(botEntity)) && (&bot->getPersistent().getGroup())==entity->getGroup())
&& (&bot->getPersistent().getGroup())==entity->getGroup())
{ {
CBotPlayer* player = NULL; if (playerId != NLMISC::CEntityId::Unknown)
if (playerId!=NLMISC::CEntityId::Unknown
&& (player = dynamic_cast<CBotPlayer*>(CAIEntityPhysicalLocator::getInstance()->getEntity(playerId))))
{ {
bot->setPlayerController(player); CAIEntityPhysical *playerEntity = inst->getEntity(playerId);
CBotPlayer* player = NULL;
if (playerEntity && (player = dynamic_cast<CBotPlayer*>(playerEntity)))
bot->setPlayerController(player);
} }
else else
bot->setPlayerController(NULL); bot->setPlayerController(NULL);