From 6ccadd6d0ba8185ac2a5f7707b62d70fdb9c5ba1 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Jun 2023 11:34:56 +0800 Subject: [PATCH] 1 --- server/gameserver/commands.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index 44d43162..409ebef4 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -9,6 +9,7 @@ #include "movement.h" #include "android.h" #include "airraid.h" +#include "car.h" #include "cs_proto.pb.h" @@ -326,6 +327,21 @@ void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg) #endif } } + } else if (cmd == "use_skill") { + if (cmds.size() >= 2) { + int skill_id = a8::XValue(cmds[1]); + Skill* skill = GetSkill(skill_id); + Human* enemy = room->FindEnemy(this, 300); + if (enemy && skill && GetCar() && GetCar()->IsDriver(this)) { + if (CanUseSkill(skill_id) && enemy->GetPos().Distance2D2(GetPos()) > 0.0001f) { + glm::vec3 skill_dir = enemy->GetPos().ToGlmVec3() - GetPos().ToGlmVec3(); + float skill_distance = GlmHelper::Norm(skill_dir); + GlmHelper::Normalize(skill_dir); + + DoSkill(skill_id, enemy->GetUniId(), skill_dir, skill_distance); + } + } + } } #ifdef DEBUG a8::XPrintf("exec_cmd:%s\n", {cmd});