This commit is contained in:
aozhiwei 2023-04-07 18:46:20 +08:00
parent 876fb6e6fa
commit e5f590b9d1
4 changed files with 34 additions and 6 deletions

View File

@ -1,5 +1,8 @@
#include "precompile.h"
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#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;
}

View File

@ -19,6 +19,9 @@ public:
behaviac::EBTStatus DoAttack();
behaviac::EBTStatus DoPursuit();
private:
glm::vec3& AdjustShotDir(glm::vec3& shot_dir);
private:
Android* owner_ = nullptr;
};

View File

@ -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; };

View File

@ -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;