1
This commit is contained in:
parent
92030a7400
commit
98e05a9585
@ -586,7 +586,9 @@ void Bullet::Check(float distance)
|
||||
if (IsBomb()) {
|
||||
ProcBomb();
|
||||
} else {
|
||||
bool hited = false;
|
||||
if (!eat && !objects.empty()) {
|
||||
hited = true;
|
||||
OnHit(objects);
|
||||
}
|
||||
bool need_remove = true;
|
||||
@ -601,6 +603,25 @@ void Bullet::Check(float distance)
|
||||
}
|
||||
}
|
||||
if (need_remove) {
|
||||
if (gun_meta->i->equip_subtype() == GUN_SUB_EQUIP_TYPE_FLY_HOOk) {
|
||||
if (!hited) {
|
||||
sender.Get()->IncDisableMoveTimes();
|
||||
sender.Get()->IncDisableAttackDirTimes();
|
||||
sender.Get()->room->xtimer.AddDeadLineTimerAndAttach
|
||||
(
|
||||
(0.2 + distance / gun_meta->i->bullet_speed() / 2) * SERVER_FRAME_RATE,
|
||||
a8::XParams()
|
||||
.SetSender(sender.Get()),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Creature* c = (Creature*)param.sender.GetUserData();
|
||||
c->DecDisableMoveTimes();
|
||||
c->DecDisableAttackDirTimes();
|
||||
},
|
||||
&sender.Get()->xtimer_attacher.timer_list_
|
||||
);
|
||||
}
|
||||
}
|
||||
ClearBuffList();
|
||||
room->RemoveObjectLater(this);
|
||||
later_removed_ = true;
|
||||
@ -772,7 +793,6 @@ void Bullet::ClearBuffList()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Bullet::ProcFlyHook(Entity* target)
|
||||
{
|
||||
ClearBuffList();
|
||||
@ -791,4 +811,17 @@ void Bullet::ProcFlyHook(Entity* target)
|
||||
sender.Get()->AutoNavigation(GetPos(), gun_meta->i->bullet_speed() * 2);
|
||||
}
|
||||
|
||||
sender.Get()->IncDisableMoveTimes();
|
||||
sender.Get()->room->xtimer.AddDeadLineTimerAndAttach
|
||||
(
|
||||
(distance / gun_meta->i->bullet_speed() / 2) * SERVER_FRAME_RATE,
|
||||
a8::XParams()
|
||||
.SetSender(sender.Get()),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Creature* c = (Creature*)param.sender.GetUserData();
|
||||
c->DecDisableMoveTimes();
|
||||
},
|
||||
&sender.Get()->xtimer_attacher.timer_list_
|
||||
);
|
||||
}
|
||||
|
@ -3515,6 +3515,8 @@ void Creature::AutoNavigation(a8::Vec2 target_pos, float speed)
|
||||
context->dir.Normalize();
|
||||
context->speed = speed;
|
||||
context->distance = distance;
|
||||
|
||||
IncDisableMoveTimes();
|
||||
room->xtimer.AddRepeatTimerAndAttach
|
||||
(1,
|
||||
a8::XParams()
|
||||
@ -3527,16 +3529,27 @@ void Creature::AutoNavigation(a8::Vec2 target_pos, float speed)
|
||||
Room* room = context->c.Get()->room;
|
||||
Creature* c = context->c.Get();
|
||||
|
||||
a8::Vec2 dir = context->target_pos - c->GetPos();
|
||||
dir.Normalize();
|
||||
a8::Vec2 old_pos = c->GetPos();
|
||||
float move_length = context->speed / (float)SERVER_FRAME_RATE;
|
||||
float move_distance = std::min(move_length * context->exec_frameno, context->distance);
|
||||
a8::Vec2 new_pos = context->src_pos + context->dir * move_distance;
|
||||
a8::Vec2 new_pos = context->src_pos + dir * move_distance;
|
||||
c->SetPos(new_pos);
|
||||
|
||||
bool ok = false;
|
||||
if (c->CheckCollision()) {
|
||||
c->SetPos(old_pos);
|
||||
room->xtimer.DeleteTimer(room->xtimer.GetRunningTimer());
|
||||
ok = true;
|
||||
} else {
|
||||
ok = std::abs(move_distance - context->distance) < 0.0001f;
|
||||
room->grid_service->MoveCreature(c);
|
||||
}
|
||||
|
||||
if (ok || c->dead) {
|
||||
c->DecDisableMoveTimes();
|
||||
delete context;
|
||||
room->xtimer.DeleteTimer(room->xtimer.GetRunningTimer());
|
||||
}
|
||||
},
|
||||
&xtimer_attacher.timer_list_);
|
||||
|
Loading…
x
Reference in New Issue
Block a user