From 37c7df063e89f9ad5b5443f13072759dd8b5d67f Mon Sep 17 00:00:00 2001 From: Nuno Date: Thu, 5 Oct 2023 12:43:57 +0200 Subject: [PATCH] Added groupBots and displayInfos commands --- ryzom/server/src/ai_service/commands.cpp | 98 ++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/ryzom/server/src/ai_service/commands.cpp b/ryzom/server/src/ai_service/commands.cpp index 10db3a862..c017af8a7 100644 --- a/ryzom/server/src/ai_service/commands.cpp +++ b/ryzom/server/src/ai_service/commands.cpp @@ -1697,6 +1697,42 @@ NLMISC_COMMAND(getDatasetId,"get datasetid of bots with name matchiong the given return true; } + +NLMISC_COMMAND(groupBots,"get number of bots (total and alive (spawned))", "") +{ + if (args.size()!=1) + return false; + + string const& grpName = args[0]; + uint8 spawneds = 0; + uint8 total = 0; + + vector grps; + /// try to find the bot name + buildFilteredGroupList(grps, grpName); + if (!grps.empty()) + { + FOREACHC(itGrp, vector, grps) + { + CGroup* grp = *itGrp; + if (grp == NULL) + continue; + + FOREACH(itBot, CCont, grp->bots()) + { + CBot* bot = *itBot; + CSpawnBot* spawnBot = bot->getSpawnObj(); + total++; + if (spawnBot != NULL && spawnBot->isAlive()) + spawneds++; + } + } + } + log.displayNL("%u/%u", spawneds, total); + return true; +} + + NLMISC_COMMAND(script,"execute a script for groups matching the given filter [buffered]"," ") { clearBufferedRetStrings(); @@ -1968,6 +2004,68 @@ NLMISC_COMMAND(displayTarget,"display bot target status for given bot(s) or play return true; } + + +NLMISC_COMMAND(displayInfos,"display bot status for given bot(s) or player(s)","[...]") +{ + if(args.size() <1) + return false; + + CLogStringWriter stringWriter(&log); + + for (uint i=0;i can't find entity: %s", args[i].c_str()); + continue; + } + + CAIEntityPhysical *phys=EntityPtr->getTarget(); + + if (!phys) + { + log.displayNL("=> bot %s have no target", args[i].c_str()); + continue; + } + + bool found=false; + + switch (phys->getRyzomType()) + { + case RYZOMID::npc: + case RYZOMID::creature: + case RYZOMID::pack_animal: + break; + case RYZOMID::player: + log.displayNL("=> target is a player"); + break; + default: + { + CSpawnBot* spawnBot=dynamic_cast(phys); + if (spawnBot) + { + vector strings = spawnBot->getPersistent().getMultiLineInfoString(); + FOREACHC(itString, vector, strings) + log.displayNL("%s", itString->c_str()); + found=true; + } + + } + break; + } + + if (!found) + { + log.displayNL("=> can't display information for the target of: %s", args[i].c_str()); + } + + } + return true; +} + + NLMISC_COMMAND(displayVision3x3,"display 3x3 cell vision centred on a given coordinate in the given aIInstance"," ") { if(args.size()!=3) -- 2.11.4.GIT