From cf51132072f128f5357f285c96e0601ed8f1dfab Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 12 Jan 2024 13:50:28 +0800 Subject: [PATCH] 1 --- server/gameserver/commands.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index b28d20e3..4c400308 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -170,6 +170,25 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) hum->GetMutablePos().FromGlmVec3(GetPos().ToGlmVec3()); room->grid_service->MoveCreature(hum); } + } else if (cmd == "findhero" && cmds.size() >= 2) { + int hero_id = a8::XValue(cmds[1]); + bool found = false; + room->TraverseHumanList + ( + [this, hero_id, &found] (Human* hum) -> bool + { + if (!hum->dead && hum->GetHeroMeta()->id() == hero_id) { + hum->GetMovement()->ClearPath(); + hum->GetMutablePos().FromGlmVec3(GetPos().ToGlmVec3()); + room->grid_service->MoveCreature(hum); + found = true; + return false; + } + return true; + }); + if (!found) { + SendDebugMsg(a8::Format("not found", {})); + } } else if (cmd == "find_teammate") { GetTeam()->TraverseMembers (