This commit is contained in:
aozhiwei 2023-01-02 14:33:06 +08:00
parent ccd5f340e0
commit d74a9971e4
2 changed files with 105 additions and 85 deletions

View File

@ -973,93 +973,112 @@ void Skill::ProcSkillPhase(const mt::SkillPhase* phase)
void Skill::ProcShotPhase(const mt::SkillPhase* phase) void Skill::ProcShotPhase(const mt::SkillPhase* phase)
{ {
const mt::Equip* weapon_meta = mt::Equip::GetById(phase->param1.GetInt()); if (meta->skill_target() == kST_SpecDir) {
if (weapon_meta) { ProcSpecDirShotPhase(phase);
const mt::Equip* bullet_meta = } else {
mt::Equip::GetById(weapon_meta->use_bullet()); ProcNormalShotPhase(phase);
if (meta->skill_target() == kST_SpecDir) { }
if (std::abs(owner->skill_dir_.x) > FLT_EPSILON || }
std::abs(owner->skill_dir_.y) > FLT_EPSILON) {
float target_distance = 5; void Skill::ProcSpecDirShotPhase(const mt::SkillPhase* phase)
if (meta->GetMagicId() == MAGIC_FG) { {
target_distance = meta->_number_meta->_float_range; const mt::Equip* weapon_meta = mt::Equip::GetById(phase->param1.GetInt());
} if (!weapon_meta) {
if (weapon_meta->equip_type() == EQUIP_TYPE_THROW && return;
weapon_meta->equip_subtype() == THROW_EQUIP_TYPE_ADD_BUFF) { }
target_distance = owner->skill_distance_; const mt::Equip* bullet_meta =
auto context_pos_p = owner->context_pos; mt::Equip::GetById(weapon_meta->use_bullet());
owner->room->xtimer.SetTimeoutEx
( if (std::abs(owner->skill_dir_.x) > FLT_EPSILON ||
(target_distance / weapon_meta->bullet_speed() + 1.5) * 1000.0f / FRAME_RATE_MS, std::abs(owner->skill_dir_.y) > FLT_EPSILON) {
[this, context_pos_p, weapon_meta] float target_distance = 5;
(int event, const a8::Args* args) if (meta->GetMagicId() == MAGIC_FG) {
{ target_distance = meta->_number_meta->_float_range;
if (a8::TIMER_EXEC_EVENT == event) { }
Position new_context_pos; if (weapon_meta->equip_type() == EQUIP_TYPE_THROW &&
new_context_pos.x = context_pos_p.x; weapon_meta->equip_subtype() == THROW_EQUIP_TYPE_ADD_BUFF) {
new_context_pos.y = context_pos_p.y; target_distance = owner->skill_distance_;
Position old_context_pos = owner->context_pos; auto context_pos_p = owner->context_pos;
owner->context_pos = new_context_pos; owner->room->xtimer.SetTimeoutEx
owner->TryAddBuff(owner, weapon_meta->_int_param1, (
meta); (target_distance / weapon_meta->bullet_speed() + 1.5) * 1000.0f / FRAME_RATE_MS,
owner->context_pos = old_context_pos; [this, context_pos_p, weapon_meta]
} (int event, const a8::Args* args)
}, {
&xtimer_attacher); if (a8::TIMER_EXEC_EVENT == event) {
} Position new_context_pos;
if (meta->GetMagicId() == MAGIC_YLZ) { new_context_pos.x = context_pos_p.x;
target_distance = std::max(0.0001f, target_distance); new_context_pos.y = context_pos_p.y;
} Position old_context_pos = owner->context_pos;
if (bullet_meta && target_distance > 0.00001f) { owner->context_pos = new_context_pos;
int target_id = 0; owner->TryAddBuff(owner, weapon_meta->_int_param1,
if (meta->GetMagicId() == MAGIC_HJHX) { meta);
target_distance = 0; owner->context_pos = old_context_pos;
owner->TryAddBuff(owner, 202013); }
owner->TryAddBuff(owner, 202014); },
target_id = GetTraceTargetId(owner); &xtimer_attacher);
}
if (meta->GetMagicId() == MAGIC_YLZ) {
target_distance = std::max(0.0001f, target_distance);
}
if (bullet_meta && target_distance > 0.00001f) {
int target_id = 0;
if (meta->GetMagicId() == MAGIC_HJHX) {
target_distance = 0;
owner->TryAddBuff(owner, 202013);
owner->TryAddBuff(owner, 202014);
target_id = GetTraceTargetId(owner);
}
glm::vec3 old_attack_dir = owner->GetAttackDir();
glm::vec3 attack_dir = owner->skill_dir_;
GlmHelper::Normalize(attack_dir);
owner->SetAttackDir(attack_dir);
InternalShot
(
owner,
weapon_meta,
bullet_meta,
meta,
target_distance,
0,
0);
owner->SetAttackDir(old_attack_dir);
}
} }
} else { glm::vec3 old_attack_dir = owner->GetAttackDir();
Entity* entity = owner->room->GetEntityByUniId(owner->skill_target_id_); glm::vec3 attack_dir = owner->skill_dir_;
if (entity) { GlmHelper::Normalize(attack_dir);
float target_distance = entity->GetPos().Distance2D2(owner->GetPos()); owner->SetAttackDir(attack_dir);
if (bullet_meta && target_distance > 0.00001f) { InternalShot
if (meta->GetMagicId() == MAGIC_HJHX) { (
owner->TryAddBuff(owner, 202013); owner,
owner->TryAddBuff(owner, 202014); weapon_meta,
} bullet_meta,
glm::vec3 old_attack_dir = owner->GetAttackDir(); meta,
glm::vec3 attack_dir = owner->GetPos().CalcDir(entity->GetPos()); target_distance,
GlmHelper::Normalize(attack_dir); 0,
owner->SetAttackDir(attack_dir); 0);
InternalShot owner->SetAttackDir(old_attack_dir);
( }
owner, }
weapon_meta, }
bullet_meta,
meta, void Skill::ProcNormalShotPhase(const mt::SkillPhase* phase)
target_distance, {
0, const mt::Equip* weapon_meta = mt::Equip::GetById(phase->param1.GetInt());
0); if (!weapon_meta) {
owner->SetAttackDir(old_attack_dir); return;
} }
const mt::Equip* bullet_meta =
mt::Equip::GetById(weapon_meta->use_bullet());
Entity* entity = owner->room->GetEntityByUniId(owner->skill_target_id_);
if (entity) {
float target_distance = entity->GetPos().Distance2D2(owner->GetPos());
if (bullet_meta && target_distance > 0.00001f) {
if (meta->GetMagicId() == MAGIC_HJHX) {
owner->TryAddBuff(owner, 202013);
owner->TryAddBuff(owner, 202014);
} }
glm::vec3 old_attack_dir = owner->GetAttackDir();
glm::vec3 attack_dir = owner->GetPos().CalcDir(entity->GetPos());
GlmHelper::Normalize(attack_dir);
owner->SetAttackDir(attack_dir);
InternalShot
(
owner,
weapon_meta,
bullet_meta,
meta,
target_distance,
0,
0);
owner->SetAttackDir(old_attack_dir);
} }
} }
} }

View File

@ -1,6 +1,5 @@
#pragma once #pragma once
namespace cs namespace cs
{ {
class MFSkill; class MFSkill;
@ -63,6 +62,8 @@ private:
void ProcYSHF(); void ProcYSHF();
void ProcShotPhase(const mt::SkillPhase* phase); void ProcShotPhase(const mt::SkillPhase* phase);
void ProcSpecDirShotPhase(const mt::SkillPhase* phase);
void ProcNormalShotPhase(const mt::SkillPhase* phase);
void ProcForthBackJumpPhase(const mt::SkillPhase* phase); void ProcForthBackJumpPhase(const mt::SkillPhase* phase);
private: private: