This commit is contained in:
aozhiwei 2024-01-19 17:47:33 +08:00
parent baabbb4328
commit b41a83eea2
4 changed files with 60 additions and 11 deletions

View File

@ -1446,16 +1446,60 @@ void CallFuncBuff::Shot()
float z = meta->GetBuffParam5(this);
const mt::Equip* bullet_meta = mt::Equip::GetById(id);
if (bullet_meta) {
glm::vec3 target_pos = glm::vec3(x, y, z);
glm::vec3 attack_dir = target_pos - owner->GetPos().ToGlmVec3();
glm::vec3 old_attack_dir = owner->GetAttackDir();
float fly_distance = 0.0f;
if (GlmHelper::IsZero(attack_dir)) {
attack_dir = owner->GetAttackDir();
} else {
GlmHelper::Normalize(attack_dir);
bool force_client_report = meta->_buff_param6_int_set.find(1) != meta->_buff_param6_int_set.end();
bool spec_target_pos = meta->_buff_param6_int_set.find(2) != meta->_buff_param6_int_set.end();
bool ignore_original_dmg = meta->_buff_param6_int_set.find(3) != meta->_buff_param6_int_set.end();
bool no_adjust_attack_dir = meta->_buff_param6_int_set.find(4) != meta->_buff_param6_int_set.end();
if (force_client_report) {
owner->GetAbility()->IncSwitch(kForceClientReportBullet);
}
if (ignore_original_dmg) {
owner->GetAbility()->IncSwitch(kIgnoreOriginalDmg);
}
auto on_bullet_exit =
[] (Bullet* bullet)
{
};
glm::vec3 old_attack_dir = owner->GetAttackDir();
if (spec_target_pos) {
glm::vec3 target_pos = glm::vec3(x, y, z);
glm::vec3 attack_dir = target_pos - owner->GetPos().ToGlmVec3();
float fly_distance = 0.0f;
if (GlmHelper::IsZero(attack_dir)) {
attack_dir = owner->GetAttackDir();
} else {
GlmHelper::Normalize(attack_dir);
}
fly_distance = std::max(1.0f, fly_distance);
InternalShot(owner,
owner->GetCurrWeapon()->meta,
bullet_meta,
skill_meta,
fly_distance,
owner->GetCurrWeapon()->weapon_uniid,
0,
on_bullet_exit);
} else {
InternalShot(owner,
owner->GetCurrWeapon()->meta,
owner->GetCurrWeapon()->bullet_meta,
skill_meta,
0,
owner->GetCurrWeapon()->weapon_uniid,
0,
on_bullet_exit);
}
if (force_client_report) {
owner->GetAbility()->DecSwitch(kForceClientReportBullet);
}
if (ignore_original_dmg) {
owner->GetAbility()->DecSwitch(kIgnoreOriginalDmg);
}
if (!no_adjust_attack_dir) {
owner->SetAttackDir(old_attack_dir);
}
owner->SetAttackDir(old_attack_dir);
}
}

View File

@ -511,6 +511,8 @@ enum SwitchTimesType_e
kImmuneGasTimes,
kAniHideTimes,
kAccumulatePowerTimes,
kForceClientReportBullet,
kIgnoreOriginalDmg,
kSwitchTimeEnd,
};

View File

@ -323,7 +323,8 @@ void InternalShot(Creature* c,
const mt::Skill* skill_meta,
float fly_distance,
long long weapon_uniid,
int trace_target_uniid)
int trace_target_uniid,
std::function<void(Bullet*)> on_bullet_exit)
{
bool is_player = c->IsPlayer();
bool is_car = c->IsCar();

View File

@ -1,6 +1,7 @@
#pragma once
class Creature;
class Bullet;
void InternalShot(Creature* sender,
const mt::Equip* weapon_meta,
@ -8,4 +9,5 @@ void InternalShot(Creature* sender,
const mt::Skill* skill_meta,
float fly_distance,
long long weapon_uniid,
int trace_target_uniid);
int trace_target_uniid,
std::function<void(Bullet*)> on_bullet_exit = nullptr);