1
This commit is contained in:
parent
ccd5f340e0
commit
d74a9971e4
@ -973,93 +973,112 @@ void Skill::ProcSkillPhase(const mt::SkillPhase* phase)
|
||||
|
||||
void Skill::ProcShotPhase(const mt::SkillPhase* phase)
|
||||
{
|
||||
const mt::Equip* weapon_meta = mt::Equip::GetById(phase->param1.GetInt());
|
||||
if (weapon_meta) {
|
||||
const mt::Equip* bullet_meta =
|
||||
mt::Equip::GetById(weapon_meta->use_bullet());
|
||||
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;
|
||||
if (meta->GetMagicId() == MAGIC_FG) {
|
||||
target_distance = meta->_number_meta->_float_range;
|
||||
}
|
||||
if (weapon_meta->equip_type() == EQUIP_TYPE_THROW &&
|
||||
weapon_meta->equip_subtype() == THROW_EQUIP_TYPE_ADD_BUFF) {
|
||||
target_distance = owner->skill_distance_;
|
||||
auto context_pos_p = owner->context_pos;
|
||||
owner->room->xtimer.SetTimeoutEx
|
||||
(
|
||||
(target_distance / weapon_meta->bullet_speed() + 1.5) * 1000.0f / FRAME_RATE_MS,
|
||||
[this, context_pos_p, weapon_meta]
|
||||
(int event, const a8::Args* args)
|
||||
{
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
Position new_context_pos;
|
||||
new_context_pos.x = context_pos_p.x;
|
||||
new_context_pos.y = context_pos_p.y;
|
||||
Position old_context_pos = owner->context_pos;
|
||||
owner->context_pos = new_context_pos;
|
||||
owner->TryAddBuff(owner, weapon_meta->_int_param1,
|
||||
meta);
|
||||
owner->context_pos = old_context_pos;
|
||||
}
|
||||
},
|
||||
&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);
|
||||
if (meta->skill_target() == kST_SpecDir) {
|
||||
ProcSpecDirShotPhase(phase);
|
||||
} else {
|
||||
ProcNormalShotPhase(phase);
|
||||
}
|
||||
}
|
||||
|
||||
void Skill::ProcSpecDirShotPhase(const mt::SkillPhase* phase)
|
||||
{
|
||||
const mt::Equip* weapon_meta = mt::Equip::GetById(phase->param1.GetInt());
|
||||
if (!weapon_meta) {
|
||||
return;
|
||||
}
|
||||
const mt::Equip* bullet_meta =
|
||||
mt::Equip::GetById(weapon_meta->use_bullet());
|
||||
|
||||
if (std::abs(owner->skill_dir_.x) > FLT_EPSILON ||
|
||||
std::abs(owner->skill_dir_.y) > FLT_EPSILON) {
|
||||
float target_distance = 5;
|
||||
if (meta->GetMagicId() == MAGIC_FG) {
|
||||
target_distance = meta->_number_meta->_float_range;
|
||||
}
|
||||
if (weapon_meta->equip_type() == EQUIP_TYPE_THROW &&
|
||||
weapon_meta->equip_subtype() == THROW_EQUIP_TYPE_ADD_BUFF) {
|
||||
target_distance = owner->skill_distance_;
|
||||
auto context_pos_p = owner->context_pos;
|
||||
owner->room->xtimer.SetTimeoutEx
|
||||
(
|
||||
(target_distance / weapon_meta->bullet_speed() + 1.5) * 1000.0f / FRAME_RATE_MS,
|
||||
[this, context_pos_p, weapon_meta]
|
||||
(int event, const a8::Args* args)
|
||||
{
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
Position new_context_pos;
|
||||
new_context_pos.x = context_pos_p.x;
|
||||
new_context_pos.y = context_pos_p.y;
|
||||
Position old_context_pos = owner->context_pos;
|
||||
owner->context_pos = new_context_pos;
|
||||
owner->TryAddBuff(owner, weapon_meta->_int_param1,
|
||||
meta);
|
||||
owner->context_pos = old_context_pos;
|
||||
}
|
||||
},
|
||||
&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 {
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Skill::ProcNormalShotPhase(const mt::SkillPhase* phase)
|
||||
{
|
||||
const mt::Equip* weapon_meta = mt::Equip::GetById(phase->param1.GetInt());
|
||||
if (!weapon_meta) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace cs
|
||||
{
|
||||
class MFSkill;
|
||||
@ -63,6 +62,8 @@ private:
|
||||
void ProcYSHF();
|
||||
|
||||
void ProcShotPhase(const mt::SkillPhase* phase);
|
||||
void ProcSpecDirShotPhase(const mt::SkillPhase* phase);
|
||||
void ProcNormalShotPhase(const mt::SkillPhase* phase);
|
||||
void ProcForthBackJumpPhase(const mt::SkillPhase* phase);
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user