This commit is contained in:
aozhiwei 2023-11-08 13:24:12 +08:00
parent cf3eb7a1e0
commit 9b633fd125
6 changed files with 135 additions and 4 deletions

View File

@ -34,6 +34,7 @@
#include "buff/rescuer.h"
#include "buff/reverse.h"
#include "buff/select_target_with_self_pos.h"
#include "buff/select_target_with_spec_pos.h"
#include "buff/sprint.h"
#include "buff/summon_loot.h"
#include "buff/summon_obstacle.h"
@ -121,6 +122,8 @@ std::shared_ptr<Buff> BuffFactory::MakeBuff(const mt::Buff* buff_meta)
return std::make_shared<ReverseBuff>();
case kBET_SelectTargetWithSelfPos:
return std::make_shared<SelectTargetWithSelfPosBuff>();
case kBET_SelectTargetWithSpecPos:
return std::make_shared<SelectTargetWithSpecPosBuff>();
case kBET_Sprint:
return std::make_shared<SprintBuff>();
case kBET_SummonObstacle:

View File

@ -0,0 +1,93 @@
#include "precompile.h"
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/vec2.hpp>
#include "buff/select_target_with_spec_pos.h"
#include "creature.h"
#include "mt/Buff.h"
void SelectTargetWithSpecPosBuff::Activate()
{
hold_param3_ = meta->GetBuffParam3(this);
hold_param4_ = meta->GetBuffParam4(this);
std::vector<Creature*> targets;
owner->TraverseCreatures
(
[this, &targets] (Creature* c, bool& stop)
{
float distance = owner->GetPos().Distance2D2(c->GetPos());
float angle = 0.0f;
if (distance > 0.0001f) {
glm::vec3 dir = owner->GetAttackDir();
if (GlmHelper::IsZero(dir)){
dir = c->GetPos().ToGlmVec3() - owner->GetPos().ToGlmVec3();
GlmHelper::Normalize(dir);
}
angle = GlmHelper::CalcAngle(dir,
c->GetPos().ToGlmVec3() - owner->GetPos().ToGlmVec3());
}
if (distance < hold_param3_ && std::abs(angle) <= glm::radians(hold_param4_) / 2.0f / A8_PI) {
switch (meta->_int_buff_param1) {
case kBST_All:
{
targets.push_back(c);
}
break;
case kBST_Self:
{
if (c == owner) {
targets.push_back(c);
}
}
break;
case kBST_FriendlyIncludeSelf:
{
if (c->team_id == owner->team_id) {
targets.push_back(c);
}
}
break;
case kBST_FriendlyExcludeSelf:
{
if (c->team_id == owner->team_id && c != owner) {
targets.push_back(c);
}
}
break;
case kBST_Enemy:
{
if (c->team_id != owner->team_id) {
targets.push_back(c);
}
}
break;
case kBST_EnemyAndSelf:
{
if (c->team_id != owner->team_id || c == owner) {
targets.push_back(c);
}
}
break;
default:
{
}
break;
}
}
}
);
for (auto& target : targets) {
for (int buff_id : meta->_buff_param2_int_list) {
target->TryAddBuff(caster_.Get(), buff_id, skill_meta);
}
}
}
void SelectTargetWithSpecPosBuff::Deactivate()
{
}

View File

@ -0,0 +1,16 @@
#pragma once
#include "buff.h"
class SelectTargetWithSpecPosBuff : public Buff
{
public:
virtual void Activate() override;
virtual void Deactivate() override;
private:
float hold_param3_ = 0.0f;
float hold_param4_ = 0.0f;
};

View File

@ -70,7 +70,7 @@ A8_DECLARE_ENUM(BuffEffectType_e,
kBET_Sprint = 35, //冲刺
kBET_SummonObstacle = 36, //召唤物件
kBET_FlashMove = 37, //瞬间移动
kBET_UnUse38 = 38,
kBET_SelectTargetWithSpecPos = 38, //指定中心范围内选取目标,并且批量添加buff
kBET_ShotCharge = 39, //射击蓄力
kBET_SelectTargetWithSelfPos = 40, //已自己坐标为中心范围内选取目标,并且批量添加buff
kBET_EventAdd = 41, //even添加buff

View File

@ -3421,9 +3421,9 @@ Obstacle* Creature::InternalSummonObstacle(Buff* buff, const mt::MapThing* thing
bool Creature::CanShot(bool try_reload)
{
if (!GetCurrWeapon()) {
return false;
}
if (!GetCurrWeapon()) {
return false;
}
if (!GetCurrWeapon()->meta) {
return false;
}
@ -3673,3 +3673,18 @@ void Creature::InitMobaRoad()
path_dir = side == 2 ? 1 : 0;
}
}
void Creature::ClearSkillLocalVars(int skill_id)
{
}
float Creature::GetSkillLocalVar(int skill_id, int idx)
{
}
void Creature::SetSkillLocalVar(int skill_id, int idx, float val)
{
}

View File

@ -389,6 +389,9 @@ class Creature : public MoveableEntity
void ActivateTargetValidPos();
void RemoveHideEffect(int reason);
void InitMobaRoad();
void ClearSkillLocalVars(int skill_id);
float GetSkillLocalVar(int skill_id, int idx);
void SetSkillLocalVar(int skill_id, int idx, float val);
protected:
virtual void OnBuffRemove(Buff& buff);
@ -475,6 +478,7 @@ private:
std::shared_ptr<Compose> compose_;
std::map<int, a8::XTimerWp> ignore_target_hash_;
std::map<int, std::map<int, float>> skill_local_vars_;
CreatureWeakPtr last_attacker_;
int last_attacker_revive_times_ = 0;