1
This commit is contained in:
parent
7ced148ff7
commit
dfd0ac51fa
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
struct BulletCheckResult
|
struct BulletCheckResult
|
||||||
{
|
{
|
||||||
|
float flyed_distance = 0.0f;
|
||||||
int c_hit_num = 0;
|
int c_hit_num = 0;
|
||||||
int t_hit_num = 0;
|
int t_hit_num = 0;
|
||||||
int o_hit_num = 0;
|
int o_hit_num = 0;
|
||||||
@ -477,69 +478,19 @@ float Bullet::GetExplosionRange()
|
|||||||
void Bullet::Check(float distance)
|
void Bullet::Check(float distance)
|
||||||
{
|
{
|
||||||
BulletCheckResult result;
|
BulletCheckResult result;
|
||||||
|
result.flyed_distance = distance;
|
||||||
GetHitThings(result);
|
GetHitThings(result);
|
||||||
if (result.o_hit_num <= 0) {
|
if (result.o_hit_num <= 0) {
|
||||||
GetHitCreatures(result);
|
GetHitCreatures(result);
|
||||||
}
|
}
|
||||||
float bullet_range = gun_meta->range();
|
if (!result.objects.empty() || (!IsBomb() && distance > gun_meta->range()) || result.eat ||
|
||||||
if (!result.objects.empty() || (!IsBomb() && distance > bullet_range) || result.eat ||
|
|
||||||
(gun_meta->id() == 30918 && distance >= fly_distance) ||
|
(gun_meta->id() == 30918 && distance >= fly_distance) ||
|
||||||
(IsBomb() && meta->_inventory_slot() != IS_RPG && distance >= fly_distance)
|
(IsBomb() && meta->_inventory_slot() != IS_RPG && distance >= fly_distance)
|
||||||
) {
|
) {
|
||||||
if (IsBomb()) {
|
if (IsBomb()) {
|
||||||
ProcBomb();
|
ProcBomb();
|
||||||
} else {
|
} else {
|
||||||
bool hited = false;
|
ProcNormalBullet(result);
|
||||||
if (!result.eat && !result.objects.empty()) {
|
|
||||||
hited = true;
|
|
||||||
OnHit(result.objects);
|
|
||||||
}
|
|
||||||
bool need_remove = true;
|
|
||||||
if (distance < bullet_range) {
|
|
||||||
if (!gun_meta->is_penetrate_thing() && !gun_meta->ispenetrate()) {
|
|
||||||
} else {
|
|
||||||
if ((!gun_meta->is_penetrate_thing() && (result.t_hit_num > 0)) ||
|
|
||||||
(!gun_meta->ispenetrate() && (result.c_hit_num > 0))) {
|
|
||||||
} else {
|
|
||||||
need_remove = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (need_remove) {
|
|
||||||
if (IsFlyHook()) {
|
|
||||||
if (!hited) {
|
|
||||||
sender.Get()->IncDisableMoveTimes();
|
|
||||||
sender.Get()->IncDisableAttackDirTimes();
|
|
||||||
auto sender_p = sender;
|
|
||||||
sender.Get()->room->xtimer.SetTimeoutEx
|
|
||||||
(
|
|
||||||
std::ceil((distance / gun_meta->bullet_speed() / 2) * SERVER_FRAME_RATE),
|
|
||||||
[sender_p] (int event, const a8::Args* args) mutable
|
|
||||||
{
|
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
|
||||||
sender_p.Get()->RemoveBuffById(kKeepShotAnimiBuffId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
&sender.Get()->xtimer_attacher
|
|
||||||
);
|
|
||||||
sender.Get()->room->xtimer.SetTimeoutEx
|
|
||||||
(
|
|
||||||
(0.75 + distance / gun_meta->bullet_speed() / 2) * SERVER_FRAME_RATE,
|
|
||||||
[sender_p] (int event, const a8::Args* args) mutable
|
|
||||||
{
|
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
|
||||||
sender_p.Get()->DecDisableMoveTimes();
|
|
||||||
sender_p.Get()->DecDisableAttackDirTimes();
|
|
||||||
sender_p.Get()->GetTrigger()->FlyHookDestory();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
&sender.Get()->xtimer_attacher
|
|
||||||
);
|
|
||||||
sender.Get()->TryAddBuff(sender.Get(), gun_meta->_int_param2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ForceRemove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -948,3 +899,59 @@ void Bullet::GetHitCreatures(BulletCheckResult& result)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Bullet::ProcNormalBullet(BulletCheckResult& result)
|
||||||
|
{
|
||||||
|
bool hited = false;
|
||||||
|
if (!result.eat && !result.objects.empty()) {
|
||||||
|
hited = true;
|
||||||
|
OnHit(result.objects);
|
||||||
|
}
|
||||||
|
bool need_remove = true;
|
||||||
|
if (result.flyed_distance < gun_meta->range()) {
|
||||||
|
if (!gun_meta->is_penetrate_thing() && !gun_meta->ispenetrate()) {
|
||||||
|
} else {
|
||||||
|
if ((!gun_meta->is_penetrate_thing() && (result.t_hit_num > 0)) ||
|
||||||
|
(!gun_meta->ispenetrate() && (result.c_hit_num > 0))) {
|
||||||
|
} else {
|
||||||
|
need_remove = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (need_remove) {
|
||||||
|
if (IsFlyHook()) {
|
||||||
|
if (!hited) {
|
||||||
|
sender.Get()->IncDisableMoveTimes();
|
||||||
|
sender.Get()->IncDisableAttackDirTimes();
|
||||||
|
auto sender_p = sender;
|
||||||
|
sender.Get()->room->xtimer.SetTimeoutEx
|
||||||
|
(
|
||||||
|
std::ceil((result.flyed_distance / gun_meta->bullet_speed() / 2) * SERVER_FRAME_RATE),
|
||||||
|
[sender_p] (int event, const a8::Args* args) mutable
|
||||||
|
{
|
||||||
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
|
sender_p.Get()->RemoveBuffById(kKeepShotAnimiBuffId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&sender.Get()->xtimer_attacher
|
||||||
|
);
|
||||||
|
sender.Get()->room->xtimer.SetTimeoutEx
|
||||||
|
(
|
||||||
|
(0.75 + result.flyed_distance / gun_meta->bullet_speed() / 2) * SERVER_FRAME_RATE,
|
||||||
|
[sender_p] (int event, const a8::Args* args) mutable
|
||||||
|
{
|
||||||
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
|
sender_p.Get()->DecDisableMoveTimes();
|
||||||
|
sender_p.Get()->DecDisableAttackDirTimes();
|
||||||
|
sender_p.Get()->GetTrigger()->FlyHookDestory();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&sender.Get()->xtimer_attacher
|
||||||
|
);
|
||||||
|
sender.Get()->TryAddBuff(sender.Get(), gun_meta->_int_param2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ForceRemove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -61,6 +61,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
void ProcBomb();
|
void ProcBomb();
|
||||||
|
void ProcNormalBullet(BulletCheckResult& result);
|
||||||
void ProcSmokeBomb();
|
void ProcSmokeBomb();
|
||||||
void ProcFragBomb(int delay_time);
|
void ProcFragBomb(int delay_time);
|
||||||
void ProcPosionGasBomb(int delay_time);
|
void ProcPosionGasBomb(int delay_time);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user