From cf903a114406b3c41fba6b0a6af90ba7e4cf9328 Mon Sep 17 00:00:00 2001 From: Nuno Date: Mon, 15 May 2023 15:34:48 +0200 Subject: [PATCH] Added ai command setEquipment --- ryzom/server/src/ai_service/nf_grp_npc.cpp | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/ryzom/server/src/ai_service/nf_grp_npc.cpp b/ryzom/server/src/ai_service/nf_grp_npc.cpp index 7190c063d..0a67aea43 100644 --- a/ryzom/server/src/ai_service/nf_grp_npc.cpp +++ b/ryzom/server/src/ai_service/nf_grp_npc.cpp @@ -2725,6 +2725,55 @@ void maxHitRange_f_(CStateInstance* entity, CScriptStack& stack) } } +//---------------------------------------------------------------------------- +/** @page code + +@subsection setEquipement_s_ + +Arguments: -> + +arg1: is the equipment list (in hex) + +@code +()setEquipement("xxxxx"); +@endcode + +*/ +void setEquipment_s_(CStateInstance* entity, CScriptStack& stack) +{ + string script = stack.top(); + stack.pop(); + + IManagerParent* const managerParent = entity->getGroup()->getOwner()->getOwner(); + CAIInstance* const aiInstance = dynamic_cast(managerParent); + if (!aiInstance) + return; + + std::vector args; + std::vector equipements; + NLMISC::splitString(script, ";", equipements); + + CGroup* group = entity->getGroup(); + + FOREACH(botIt, CCont, group->bots()) + { + CBot* bot = *botIt; + + if (bot->getRyzomType() == RYZOMID::npc) + { + CBotNpc* botNpc = NLMISC::safe_cast(bot); + if (botNpc==NULL) + return; + botNpc->equipmentInit(); + + FOREACHC(it, std::vector, equipements) + { + botNpc->equipmentAdd(*it); + } + } + } +} + //---------------------------------------------------------------------------- /** @page code @@ -3370,6 +3419,7 @@ std::map nfGetNpcGroupNativeFunctions() REGISTER_NATIVE_FUNC(functions, setParent_s_); REGISTER_NATIVE_FUNC(functions, addHealGroup_s_); + REGISTER_NATIVE_FUNC(functions, setEquipment_s_); REGISTER_NATIVE_FUNC(functions, addUserModel_sss_); REGISTER_NATIVE_FUNC(functions, addCustomLoot_ss_); REGISTER_NATIVE_FUNC(functions, setUserModel_s_); -- 2.11.4.GIT