From e5f590b9d124876dc20ae9de107c8fa15183c047 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 7 Apr 2023 18:46:20 +0800 Subject: [PATCH] 1 --- server/gameserver/android_agent.cc | 27 +++++++++++++++++++++------ server/gameserver/android_agent.h | 3 +++ server/gameserver/creature.h | 2 ++ server/gameserver/netdata.cc | 8 ++++++++ 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/server/gameserver/android_agent.cc b/server/gameserver/android_agent.cc index 9612a9df..a23e773b 100644 --- a/server/gameserver/android_agent.cc +++ b/server/gameserver/android_agent.cc @@ -1,5 +1,8 @@ #include "precompile.h" +#include +#include + #include "android_agent.h" #include "android.h" #include "room.h" @@ -7,6 +10,8 @@ #include "trigger.h" #include "glmhelper.h" +#include "mt/Robot.h" + AndroidAgent::AndroidAgent():BaseAgent() { @@ -108,7 +113,7 @@ behaviac::EBTStatus AndroidAgent::DoRandomShot() GetOwner()->SetAttackDir(dir); bool shot_ok = false; glm::vec3 shot_dir = dir; - GetOwner()->Shot(shot_dir, shot_ok, 0, 0); + GetOwner()->Shot(AdjustShotDir(shot_dir), shot_ok, 0, 0); auto context = A8_MAKE_SMART_ANON_STRUCT_SHARED ( @@ -153,7 +158,7 @@ behaviac::EBTStatus AndroidAgent::DoRandomShot() bool shot_ok = false; glm::vec3 shot_dir = GetOwner()->GetAttackDir(); GetOwner()->shot_hold = true; - GetOwner()->Shot(shot_dir, shot_ok, 0, 0); + GetOwner()->Shot(AdjustShotDir(shot_dir), shot_ok, 0, 0); return behaviac::BT_RUNNING; } @@ -188,7 +193,7 @@ behaviac::EBTStatus AndroidAgent::DoAttack() GetOwner()->SetAttackDir(dir); bool shot_ok = false; glm::vec3 shot_dir = dir; - GetOwner()->Shot(shot_dir, shot_ok, 0, 0); + GetOwner()->Shot(AdjustShotDir(shot_dir), shot_ok, 0, 0); auto context = A8_MAKE_SMART_ANON_STRUCT_SHARED @@ -212,7 +217,7 @@ behaviac::EBTStatus AndroidAgent::DoAttack() bool shot_ok = false; glm::vec3 shot_dir = GetOwner()->GetAttackDir(); GetOwner()->shot_hold = true; - GetOwner()->Shot(shot_dir, shot_ok, 0, 0); + GetOwner()->Shot(AdjustShotDir(shot_dir), shot_ok, 0, 0); return behaviac::BT_RUNNING; } @@ -313,8 +318,8 @@ behaviac::EBTStatus AndroidAgent::DoPursuit() bool shot_ok = false; glm::vec3 shot_dir = dir; GetOwner()->shot_hold = true; - GetOwner()->SetAttackDir(dir); - GetOwner()->Shot(shot_dir, shot_ok, 0, 0); + GetOwner()->SetAttackDir(shot_dir); + GetOwner()->Shot(AdjustShotDir(shot_dir), shot_ok, 0, 0); } else { GetOwner()->shot_hold = false; } @@ -329,3 +334,13 @@ behaviac::EBTStatus AndroidAgent::DoPursuit() }; return StartCoroutine(co); } + +glm::vec3& AndroidAgent::AdjustShotDir(glm::vec3& shot_dir) +{ + if (GetOwner()->IsAndroid()) { + float angle_offset = GetOwner()->AsAndroid()->robot_meta->RandBulletAngleOfsset(); + GlmHelper::RotateY(shot_dir, glm::radians(angle_offset)); + GetOwner()->SetAttackDir(shot_dir); + } + return shot_dir; +} diff --git a/server/gameserver/android_agent.h b/server/gameserver/android_agent.h index 170b7ca8..7ca2d52e 100644 --- a/server/gameserver/android_agent.h +++ b/server/gameserver/android_agent.h @@ -19,6 +19,9 @@ public: behaviac::EBTStatus DoAttack(); behaviac::EBTStatus DoPursuit(); +private: + glm::vec3& AdjustShotDir(glm::vec3& shot_dir); + private: Android* owner_ = nullptr; }; diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 74ad049b..352caaba 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -64,6 +64,7 @@ class DelayAddBuffHandle; class Movement; class Player; class GunGrasp; +class Android; class Creature : public MoveableEntity { public: @@ -228,6 +229,7 @@ class Creature : public MoveableEntity bool IsCar() const; bool IsHero() const { return IsEntityType(ET_Hero); }; Human* AsHuman() { return IsHuman() ? (Human*)this : nullptr; }; + Android* AsAndroid() { return IsAndroid() ? (Android*)this : nullptr; }; Player* AsPlayer() { return IsPlayer() ? (Player*)this : nullptr; }; Car* AsCar() { return IsCar() ? (Car*)this : nullptr; }; Hero* AsHero() { return IsHero() ? (Hero*)this : nullptr; }; diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index 7bfec4eb..7cfea4c6 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -14,6 +14,7 @@ #include "roommgr.h" #include "ability.h" #include "stats.h" +#include "android.h" #include "buff/distance_dmg_addition.h" @@ -29,6 +30,7 @@ #include "mt/Skill.h" #include "mt/SkillNumber.h" #include "mt/FormulaPvp.h" +#include "mt/Robot.h" #include "attrhelper.h" @@ -657,6 +659,12 @@ float BattleDataContext::CalcDmg(Creature* target, IBullet* bullet) finaly_dmg *= (1 + dmg_addition); //连加 finaly_dmg *= (1 - target->GetAbility()->GetAttrRuduce(kHVAT_Dmg)); //(1-减免) 连乘 +#if 1 + if (owner_.Get()->IsAndroid() && owner_.Get()->AsAndroid()->robot_meta->dmg_ratio() > 0.0001f) { + finaly_dmg *= owner_.Get()->AsAndroid()->robot_meta->dmg_ratio(); + } +#endif + finaly_dmg = std::max(1.0f, finaly_dmg); if (g_calc_dmg_context.is_crit) { g_calc_dmg_context.crit_dmg = finaly_dmg;