mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-21 19:11:06 +00:00
- floatified dodge.
This commit is contained in:
parent
19bca44f37
commit
45f28f666c
1 changed files with 10 additions and 13 deletions
|
@ -4879,10 +4879,7 @@ void makeitfall(DDukeActor* actor)
|
||||||
|
|
||||||
int dodge(DDukeActor* actor)
|
int dodge(DDukeActor* actor)
|
||||||
{
|
{
|
||||||
int bx, by, mx, my, bxvect, byvect, d;
|
auto oldpos = actor->spr.pos.XY();
|
||||||
|
|
||||||
mx = actor->int_pos().X;
|
|
||||||
my = actor->int_pos().Y;
|
|
||||||
|
|
||||||
DukeStatIterator it(STAT_PROJECTILE);
|
DukeStatIterator it(STAT_PROJECTILE);
|
||||||
while (auto ac = it.Next())
|
while (auto ac = it.Next())
|
||||||
|
@ -4890,21 +4887,21 @@ int dodge(DDukeActor* actor)
|
||||||
if (ac->GetOwner() == ac || ac->sector() != actor->sector())
|
if (ac->GetOwner() == ac || ac->sector() != actor->sector())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bx = ac->int_pos().X - mx;
|
auto delta = ac->spr.pos.XY() - oldpos;
|
||||||
by = ac->int_pos().Y - my;
|
auto bvect = ac->spr.angle.ToVector() * 1024;
|
||||||
bxvect = bcos(ac->int_ang());
|
|
||||||
byvect = bsin(ac->int_ang());
|
|
||||||
|
|
||||||
if (bcos(actor->int_ang()) * bx + bsin(actor->int_ang()) * by >= 0)
|
if (actor->spr.angle.ToVector().dot(delta) >= 0)
|
||||||
if (bxvect * bx + byvect * by < 0)
|
{
|
||||||
|
if (bvect.dot(delta) < 0)
|
||||||
{
|
{
|
||||||
d = bxvect * by - byvect * bx;
|
double d = bvect.X * delta.Y - bvect.Y * delta.X;
|
||||||
if (abs(d) < 65536 * 64)
|
if (abs(d) < 256 * 64)
|
||||||
{
|
{
|
||||||
actor->add_int_ang(-(512 + (krand() & 1024)));
|
actor->spr.angle -= DAngle90 + randomAngle(180);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue