From e070f8df3bca12db8b304f782a5b98c99f23f36e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 12 Apr 2023 17:24:41 +0800 Subject: [PATCH] 1 --- server/gameserver/commands.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index 832c4829..c12a1695 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -7,6 +7,7 @@ #include "app.h" #include "ability.h" #include "movement.h" +#include "android.h" #include "cs_proto.pb.h" @@ -14,6 +15,7 @@ #include "mt/Text.h" #include "mt/Param.h" #include "mt/Buff.h" +#include "mt/Robot.h" void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg) { @@ -114,6 +116,26 @@ void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg) hum->GetMutablePos().FromGlmVec3(GetPos().ToGlmVec3()); room->grid_service->MoveCreature(hum); } + } else if (cmd == "randomobj" && cmds.size() >= 2) { + int weapon_id = a8::XValue(cmds[1]); + Human* target = nullptr; + room->TraverseHumanList + ( + [weapon_id, &target] (Human* hum) mutable + { + if (hum->IsAndroid() && !hum->dead) { + if (hum->AsAndroid()->robot_meta->weapon_id() == weapon_id) { + target = hum; + return false; + } + } + return true; + }); + if (target) { + target->GetMovement()->ClearPath(); + target->GetMutablePos().FromGlmVec3(GetPos().ToGlmVec3()); + room->grid_service->MoveCreature(target); + } } else if (cmd == "getattr" && cmds.size() >= 2) { int attr_id = a8::XValue(cmds[1]); float abs_val = GetAbility()->GetAttrAbs(attr_id);