mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
- Blood: Floatify LifeLeechOperate()
.
* These divscales hurt my soul...
This commit is contained in:
parent
1255fda4c1
commit
ef4b72d18e
1 changed files with 11 additions and 25 deletions
|
@ -262,38 +262,24 @@ void LifeLeechOperate(DBloodActor* actor, EVENT event)
|
||||||
{
|
{
|
||||||
if (target->spr.statnum == kStatDude && !(target->spr.flags & 32) && target->hasX())
|
if (target->spr.statnum == kStatDude && !(target->spr.flags & 32) && target->hasX())
|
||||||
{
|
{
|
||||||
int top, bottom;
|
double top, bottom;
|
||||||
GetActorExtents(actor, &top, &bottom);
|
GetActorExtents(actor, &top, &bottom);
|
||||||
int nType = target->spr.type - kDudeBase;
|
DUDEINFO* pDudeInfo = getDudeInfo(target->spr.type);
|
||||||
DUDEINFO* pDudeInfo = getDudeInfo(nType + kDudeBase);
|
auto pos = target->spr.pos;
|
||||||
int z1 = (top - actor->int_pos().Z) - 256;
|
auto nDist = (pos.XY() - actor->spr.pos.XY()).Length();
|
||||||
int x = target->int_pos().X;
|
if (nDist != 0 && cansee(DVector3(actor->spr.pos.XY(), top), actor->sector(), pos, target->sector()))
|
||||||
int y = target->int_pos().Y;
|
|
||||||
int z = target->int_pos().Z;
|
|
||||||
int nDist = approxDist(x - actor->int_pos().X, y - actor->int_pos().Y);
|
|
||||||
if (nDist != 0 && cansee(actor->int_pos().X, actor->int_pos().Y, top, actor->sector(), x, y, z, target->sector()))
|
|
||||||
{
|
{
|
||||||
int t = DivScale(nDist, 0x1aaaaa, 12);
|
pos.XY() += target->spr.pos.XY() * nDist * (65536. / 0x1aaaaa);
|
||||||
x += (target->int_vel().X * t) >> 12;
|
|
||||||
y += (target->int_vel().Y * t) >> 12;
|
|
||||||
auto angBak = actor->spr.angle;
|
auto angBak = actor->spr.angle;
|
||||||
actor->spr.angle = VecToAngle(x - actor->int_pos().X, y - actor->int_pos().Y);
|
actor->spr.angle = VecToAngle(pos.XY() - actor->spr.pos.XY());
|
||||||
int dx = bcos(actor->int_ang());
|
double tz = target->spr.pos.Z - (target->spr.yrepeat * pDudeInfo->aimHeight) * REPEAT_SCALE;
|
||||||
int dy = bsin(actor->int_ang());
|
auto dvec = DVector3(actor->spr.angle.ToVector(), ((tz - top - 1) / nDist) * (1. / 16.));
|
||||||
int tz = target->int_pos().Z - (target->spr.yrepeat * pDudeInfo->aimHeight) * 4;
|
|
||||||
int dz = DivScale(tz - top - 256, nDist, 10);
|
|
||||||
int nMissileType = kMissileLifeLeechAltNormal + (actor->xspr.data3 ? 1 : 0);
|
int nMissileType = kMissileLifeLeechAltNormal + (actor->xspr.data3 ? 1 : 0);
|
||||||
int t2;
|
if (auto missile = actFireMissile(actor, 0, (top - actor->spr.pos.Z) - 1, dvec, nMissileType))
|
||||||
if (!actor->xspr.data3)
|
|
||||||
t2 = 120 / 10;
|
|
||||||
else
|
|
||||||
t2 = (3 * 120) / 10;
|
|
||||||
auto missile = actFireMissile(actor, 0, z1, dx, dy, dz, nMissileType);
|
|
||||||
if (missile)
|
|
||||||
{
|
{
|
||||||
missile->SetOwner(actor);
|
missile->SetOwner(actor);
|
||||||
actor->xspr.stateTimer = 1;
|
actor->xspr.stateTimer = 1;
|
||||||
evPostActor(actor, t2, kCallbackLeechStateTimer);
|
evPostActor(actor, (!actor->xspr.data3 ? 120 : 3 * 120) / 10, kCallbackLeechStateTimer);
|
||||||
actor->xspr.data3 = ClipLow(actor->xspr.data3 - 1, 0);
|
actor->xspr.data3 = ClipLow(actor->xspr.data3 - 1, 0);
|
||||||
if (!VanillaMode()) // disable collisions so lifeleech doesn't do that weird bobbing
|
if (!VanillaMode()) // disable collisions so lifeleech doesn't do that weird bobbing
|
||||||
missile->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
missile->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
||||||
|
|
Loading…
Reference in a new issue