mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-29 20:30:54 +00:00
Merge with develop
This commit is contained in:
parent
2a2b50cab6
commit
fa19cb0f6d
8 changed files with 181 additions and 11 deletions
|
@ -370,6 +370,7 @@ CBot::CBot(CGroup* owner, CAIAliasDescriptionNode* alias)
|
|||
: CAliasChild<CGroup>(owner, alias)
|
||||
, _VerticalPos(AITYPES::vp_auto)
|
||||
, _Sheet(NULL)
|
||||
, _ClientCSheet(NULL)
|
||||
, _Stuck(false)
|
||||
, _IgnoreOffensiveActions(false)
|
||||
, _Healer(false)
|
||||
|
@ -384,6 +385,7 @@ CBot::CBot(CGroup* owner, uint32 alias, std::string const& name)
|
|||
: CAliasChild<CGroup>(owner,alias, name)
|
||||
, _VerticalPos(AITYPES::vp_auto)
|
||||
, _Sheet(NULL)
|
||||
, _ClientCSheet(NULL)
|
||||
, _Stuck(false)
|
||||
, _IgnoreOffensiveActions(false)
|
||||
, _Healer(false)
|
||||
|
@ -695,6 +697,17 @@ void CBot::setClientSheet(const std::string & clientSheetName)
|
|||
nlwarning("Invalid CLIENT_SHEET %s", clientSheetName.c_str());
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,6 +181,19 @@ public:
|
|||
/// @name AI objects hierarchy access
|
||||
//@{
|
||||
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(); }
|
||||
CAliasTreeOwner const* getAliasTreeOwner() const { return this; }
|
||||
CSpawnBot* getSpawnObj() const;
|
||||
|
@ -270,6 +283,7 @@ protected:
|
|||
|
||||
private:
|
||||
AISHEETS::ICreatureCPtr _Sheet;
|
||||
AISHEETS::ICreatureCPtr _ClientCSheet;
|
||||
NLMISC::CSheetId _ClientSheet;
|
||||
bool _Stuck;
|
||||
bool _IgnoreOffensiveActions;
|
||||
|
|
|
@ -514,6 +514,8 @@ bool CFightOrganizer::reorganizeIteration(CBot* bot)
|
|||
CAIVector movingVector;
|
||||
double fear=1.0f;
|
||||
|
||||
CAIEntityPhysical* target = (CAIEntityPhysical*)spawnBot->getTarget();
|
||||
|
||||
FOREACH(it, std::vector<CAIEntityPhysical*>, botList)
|
||||
{
|
||||
CAIEntityPhysical *const entity=(*it);
|
||||
|
@ -565,6 +567,27 @@ bool CFightOrganizer::reorganizeIteration(CBot* bot)
|
|||
|
||||
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.
|
||||
{
|
||||
BestChooseScore=score;
|
||||
|
@ -583,7 +606,7 @@ bool CFightOrganizer::reorganizeIteration(CBot* bot)
|
|||
{
|
||||
_HaveEnnemy=true;
|
||||
nlassert(ennemy->getRyzomType()!=debugCheckedType);
|
||||
if (((CAIEntityPhysical*)spawnBot->getTarget())==ennemy)
|
||||
if (target == ennemy)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -277,7 +277,11 @@ static void s_calcRanges(
|
|||
_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;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
using namespace NLNET;
|
||||
using namespace MULTI_LINE_FORMATER;
|
||||
|
||||
CAIInstance::CAIInstance(CAIS* owner)
|
||||
|
@ -694,6 +695,11 @@ CGroupNpc* CAIInstance::eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const&
|
|||
bot->equipmentInit();
|
||||
bot->initEnergy(/*groupEnergyCoef()*/0);
|
||||
CAIVector rpos(pos);
|
||||
if (dispersionRadius == 0)
|
||||
{
|
||||
nlinfo("Stucked !");
|
||||
bot->setStuck(true);
|
||||
}
|
||||
// Spawn all randomly except if only 1 bot
|
||||
if (nbBots > 1)
|
||||
{
|
||||
|
@ -853,6 +859,7 @@ void cbEventCreateNpcGroup( NLNET::CMessage& msgin, const std::string &serviceNa
|
|||
uint32 instanceNumber;
|
||||
sint32 x;
|
||||
sint32 y;
|
||||
sint32 z;
|
||||
sint32 orientation;
|
||||
uint32 nbBots;
|
||||
NLMISC::CSheetId sheetId;
|
||||
|
@ -861,12 +868,14 @@ void cbEventCreateNpcGroup( NLNET::CMessage& msgin, const std::string &serviceNa
|
|||
bool spawnBots;
|
||||
std::string botsName;
|
||||
std::string look;
|
||||
sint32 cell;
|
||||
msgin.serial(messageVersion);
|
||||
nlassert(messageVersion==1);
|
||||
msgin.serial(instanceNumber);
|
||||
msgin.serial(playerId);
|
||||
msgin.serial(x);
|
||||
msgin.serial(y);
|
||||
msgin.serial(z);
|
||||
msgin.serial(orientation);
|
||||
msgin.serial(nbBots);
|
||||
msgin.serial(sheetId);
|
||||
|
@ -874,13 +883,39 @@ void cbEventCreateNpcGroup( NLNET::CMessage& msgin, const std::string &serviceNa
|
|||
msgin.serial(spawnBots);
|
||||
msgin.serial(botsName);
|
||||
msgin.serial(look);
|
||||
msgin.serial(cell);
|
||||
CAIInstance* instance = CAIS::instance().getAIInstance(instanceNumber);
|
||||
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)
|
||||
{
|
||||
_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1665,6 +1665,35 @@ bool execScriptGroupByName(CStringWriter& stringWriter, TCommand const& args)
|
|||
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>")
|
||||
{
|
||||
clearBufferedRetStrings();
|
||||
|
|
|
@ -984,12 +984,64 @@ void CBSAIDeathReport::callback(const std::string &name, NLNET::TServiceId id)
|
|||
CBotNpc* bot = NLMISC::safe_cast<CBotNpc*>(&(sb->getPersistent()));
|
||||
spawnGrp.botHaveDied (bot);
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
case RYZOMID::creature:
|
||||
|
|
|
@ -1482,14 +1482,14 @@ void setPlayerController_ss_(CStateInstance* entity, CScriptStack& stack)
|
|||
CAIEntityPhysical *botEntity = inst->getEntity(botId);
|
||||
if (botEntity)
|
||||
{
|
||||
if ((bot = dynamic_cast<CSpawnBotNpc*>(botEntity))
|
||||
&& (&bot->getPersistent().getGroup())==entity->getGroup())
|
||||
if ((bot = dynamic_cast<CSpawnBotNpc*>(botEntity)) && (&bot->getPersistent().getGroup())==entity->getGroup())
|
||||
{
|
||||
CBotPlayer* player = NULL;
|
||||
if (playerId!=NLMISC::CEntityId::Unknown
|
||||
&& (player = dynamic_cast<CBotPlayer*>(CAIEntityPhysicalLocator::getInstance()->getEntity(playerId))))
|
||||
if (playerId != NLMISC::CEntityId::Unknown)
|
||||
{
|
||||
bot->setPlayerController(player);
|
||||
CAIEntityPhysical *playerEntity = inst->getEntity(playerId);
|
||||
CBotPlayer* player = NULL;
|
||||
if (playerEntity && (player = dynamic_cast<CBotPlayer*>(playerEntity)))
|
||||
bot->setPlayerController(player);
|
||||
}
|
||||
else
|
||||
bot->setPlayerController(NULL);
|
||||
|
|
Loading…
Reference in a new issue