mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-22 11:31:11 +00:00
- refactored GetSpriteZOfMiddle (and all s() close by)
This commit is contained in:
parent
123e19e355
commit
8e8f59caa1
6 changed files with 25 additions and 42 deletions
|
@ -425,7 +425,6 @@ int NullEel(DSWActor* actor)
|
||||||
int DoEelMatchPlayerZ(DSWActor* actor)
|
int DoEelMatchPlayerZ(DSWActor* actor)
|
||||||
{
|
{
|
||||||
USER* u = actor->u();
|
USER* u = actor->u();
|
||||||
SPRITEp tsp = &u->targetActor->s();
|
|
||||||
int zdiff,zdist;
|
int zdiff,zdist;
|
||||||
int loz,hiz;
|
int loz,hiz;
|
||||||
int dist,a,b,c;
|
int dist,a,b,c;
|
||||||
|
@ -448,7 +447,7 @@ int DoEelMatchPlayerZ(DSWActor* actor)
|
||||||
|
|
||||||
// actor does a sine wave about u->sz - this is the z mid point
|
// actor does a sine wave about u->sz - this is the z mid point
|
||||||
|
|
||||||
zdiff = (GetSpriteZOfBottom(tsp) - Z(8)) - u->sz;
|
zdiff = (ActorZOfBottom(u->targetActor) - Z(8)) - u->sz;
|
||||||
|
|
||||||
// check z diff of the player and the sprite
|
// check z diff of the player and the sprite
|
||||||
zdist = Z(20 + RandomRange(64)); // put a random amount
|
zdist = Z(20 + RandomRange(64)); // put a random amount
|
||||||
|
|
|
@ -266,11 +266,6 @@ inline int GetSpriteZOfBottom(const spritetypebase* sp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// mid and upper/lower sprite calculations
|
// mid and upper/lower sprite calculations
|
||||||
inline int GetSpriteZOfMiddle(const spritetypebase* sp)
|
|
||||||
{
|
|
||||||
return (GetSpriteZOfTop(sp) + GetSpriteZOfBottom(sp)) >> 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr int Z(int value)
|
constexpr int Z(int value)
|
||||||
{
|
{
|
||||||
return value << 8;
|
return value << 8;
|
||||||
|
@ -2181,7 +2176,6 @@ inline int ActorZOfMiddle(DSWActor* actor)
|
||||||
return (ActorZOfTop(actor) + ActorZOfBottom(actor)) >> 1;
|
return (ActorZOfTop(actor) + ActorZOfBottom(actor)) >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int ActorSizeZ(DSWActor* actor)
|
inline int ActorSizeZ(DSWActor* actor)
|
||||||
{
|
{
|
||||||
return (tileHeight(actor->spr.picnum) * actor->spr.yrepeat) << 2;
|
return (tileHeight(actor->spr.picnum) * actor->spr.yrepeat) << 2;
|
||||||
|
@ -2208,11 +2202,6 @@ inline int ActorSizeToBottom(DSWActor* a)
|
||||||
return ((ActorSizeZ(a)) - (tileTopOffset(a->spr.picnum) << 8)) >> 1;
|
return ((ActorSizeZ(a)) - (tileTopOffset(a->spr.picnum) << 8)) >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int ActorMid(DSWActor* actor)
|
|
||||||
{
|
|
||||||
return GetSpriteZOfMiddle(&actor->s());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int ActorSizeX(DSWActor* sp)
|
inline int ActorSizeX(DSWActor* sp)
|
||||||
{
|
{
|
||||||
return MulScale(tileWidth(sp->spr.picnum), sp->spr.xrepeat, 6);
|
return MulScale(tileWidth(sp->spr.picnum), sp->spr.xrepeat, 6);
|
||||||
|
|
|
@ -347,7 +347,6 @@ enum { HORNET_BOB_AMT = (Z(16)) };
|
||||||
int DoHornetMatchPlayerZ(DSWActor* actor)
|
int DoHornetMatchPlayerZ(DSWActor* actor)
|
||||||
{
|
{
|
||||||
USERp u = actor->u();
|
USERp u = actor->u();
|
||||||
SPRITEp tsp = &u->targetActor->s();
|
|
||||||
int zdiff,zdist;
|
int zdiff,zdist;
|
||||||
int loz,hiz;
|
int loz,hiz;
|
||||||
|
|
||||||
|
@ -355,7 +354,7 @@ int DoHornetMatchPlayerZ(DSWActor* actor)
|
||||||
|
|
||||||
// actor does a sine wave about u->sz - this is the z mid point
|
// actor does a sine wave about u->sz - this is the z mid point
|
||||||
|
|
||||||
zdiff = (GetSpriteZOfMiddle(tsp)) - u->sz;
|
zdiff = (ActorZOfMiddle(u->targetActor)) - u->sz;
|
||||||
|
|
||||||
// check z diff of the player and the sprite
|
// check z diff of the player and the sprite
|
||||||
zdist = Z(20 + RandomRange(200)); // put a random amount
|
zdist = Z(20 + RandomRange(200)); // put a random amount
|
||||||
|
|
|
@ -2011,15 +2011,14 @@ int DoCarryFlag(DSWActor* actor)
|
||||||
SPRITEp fp = &fown->s();
|
SPRITEp fp = &fown->s();
|
||||||
USERp fu = fown->u();
|
USERp fu = fown->u();
|
||||||
|
|
||||||
|
DSWActor* attached = u->attachActor;
|
||||||
|
|
||||||
// if no Owner then die
|
// if no Owner then die
|
||||||
if (u->attachActor != nullptr)
|
if (attached != nullptr)
|
||||||
{
|
{
|
||||||
SPRITEp ap = &u->attachActor->s();
|
vec3_t pos = { attached->spr.pos.X, attached->spr.pos.Y, ActorZOfMiddle(attached) };
|
||||||
|
|
||||||
vec3_t pos = { ap->pos.X, ap->pos.Y, GetSpriteZOfMiddle(ap) };
|
|
||||||
SetActorZ(actor, &pos);
|
SetActorZ(actor, &pos);
|
||||||
actor->spr.ang = NORM_ANGLE(ap->ang + 1536);
|
actor->spr.ang = NORM_ANGLE(attached->spr.ang + 1536);
|
||||||
}
|
}
|
||||||
|
|
||||||
// not activated yet
|
// not activated yet
|
||||||
|
@ -2160,8 +2159,8 @@ int DoCarryFlagNoDet(DSWActor* actor)
|
||||||
{
|
{
|
||||||
USER* u = actor->u();
|
USER* u = actor->u();
|
||||||
|
|
||||||
SPRITEp ap = &u->attachActor->s();
|
DSWActor* attached = u->attachActor;
|
||||||
USERp au = u->attachActor->u();
|
USERp au = attached->u();
|
||||||
DSWActor* fown = u->flagOwnerActor;
|
DSWActor* fown = u->flagOwnerActor;
|
||||||
if (!fown) return 0;
|
if (!fown) return 0;
|
||||||
SPRITEp fp = &fown->s();
|
SPRITEp fp = &fown->s();
|
||||||
|
@ -2172,12 +2171,12 @@ int DoCarryFlagNoDet(DSWActor* actor)
|
||||||
fu->WaitTics = 30 * 120; // Keep setting respawn tics so it won't respawn
|
fu->WaitTics = 30 * 120; // Keep setting respawn tics so it won't respawn
|
||||||
|
|
||||||
// if no Owner then die
|
// if no Owner then die
|
||||||
if (ap != nullptr)
|
if (attached != nullptr)
|
||||||
{
|
{
|
||||||
vec3_t pos = { ap->pos.X, ap->pos.Y, GetSpriteZOfMiddle(ap) };
|
vec3_t pos = { attached->spr.pos.X, attached->spr.pos.Y, ActorZOfMiddle(attached) };
|
||||||
SetActorZ(actor, &pos);
|
SetActorZ(actor, &pos);
|
||||||
actor->spr.ang = NORM_ANGLE(ap->ang + 1536);
|
actor->spr.ang = NORM_ANGLE(attached->spr.ang + 1536);
|
||||||
actor->spr.pos.Z = ap->pos.Z - DIV2(GetSpriteSizeZ(ap));
|
actor->spr.pos.Z = attached->spr.pos.Z - (ActorSizeZ(attached) >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!au || au->Health <= 0)
|
if (!au || au->Health <= 0)
|
||||||
|
|
|
@ -3581,7 +3581,7 @@ int ActorCoughItem(DSWActor* actor)
|
||||||
actorNew->spr.extra = 0;
|
actorNew->spr.extra = 0;
|
||||||
actorNew->spr.pos.X = sp->pos.X;
|
actorNew->spr.pos.X = sp->pos.X;
|
||||||
actorNew->spr.pos.Y = sp->pos.Y;
|
actorNew->spr.pos.Y = sp->pos.Y;
|
||||||
actorNew->spr.pos.Z = GetSpriteZOfMiddle(sp);
|
actorNew->spr.pos.Z = ActorZOfMiddle(actor);
|
||||||
actorNew->spr.ang = 0;
|
actorNew->spr.ang = 0;
|
||||||
actorNew->spr.extra = 0;
|
actorNew->spr.extra = 0;
|
||||||
|
|
||||||
|
@ -3622,7 +3622,7 @@ int ActorCoughItem(DSWActor* actor)
|
||||||
actorNew->spr.extra = 0;
|
actorNew->spr.extra = 0;
|
||||||
actorNew->spr.pos.X = sp->pos.X;
|
actorNew->spr.pos.X = sp->pos.X;
|
||||||
actorNew->spr.pos.Y = sp->pos.Y;
|
actorNew->spr.pos.Y = sp->pos.Y;
|
||||||
actorNew->spr.pos.Z = GetSpriteZOfMiddle(sp);
|
actorNew->spr.pos.Z = ActorZOfMiddle(actor);
|
||||||
actorNew->spr.ang = 0;
|
actorNew->spr.ang = 0;
|
||||||
actorNew->spr.extra = 0;
|
actorNew->spr.extra = 0;
|
||||||
|
|
||||||
|
@ -3650,7 +3650,7 @@ int ActorCoughItem(DSWActor* actor)
|
||||||
actorNew->spr.extra = 0;
|
actorNew->spr.extra = 0;
|
||||||
actorNew->spr.pos.X = sp->pos.X;
|
actorNew->spr.pos.X = sp->pos.X;
|
||||||
actorNew->spr.pos.Y = sp->pos.Y;
|
actorNew->spr.pos.Y = sp->pos.Y;
|
||||||
actorNew->spr.pos.Z = GetSpriteZOfMiddle(sp);
|
actorNew->spr.pos.Z = ActorZOfMiddle(actor);
|
||||||
actorNew->spr.ang = 0;
|
actorNew->spr.ang = 0;
|
||||||
actorNew->spr.extra = 0;
|
actorNew->spr.extra = 0;
|
||||||
|
|
||||||
|
@ -3681,7 +3681,7 @@ int ActorCoughItem(DSWActor* actor)
|
||||||
actorNew->spr.extra = 0;
|
actorNew->spr.extra = 0;
|
||||||
actorNew->spr.pos.X = sp->pos.X;
|
actorNew->spr.pos.X = sp->pos.X;
|
||||||
actorNew->spr.pos.Y = sp->pos.Y;
|
actorNew->spr.pos.Y = sp->pos.Y;
|
||||||
actorNew->spr.pos.Z = GetSpriteZOfMiddle(sp);
|
actorNew->spr.pos.Z = ActorZOfMiddle(actor);
|
||||||
actorNew->spr.ang = 0;
|
actorNew->spr.ang = 0;
|
||||||
actorNew->spr.extra = 0;
|
actorNew->spr.extra = 0;
|
||||||
|
|
||||||
|
@ -3743,7 +3743,7 @@ int ActorCoughItem(DSWActor* actor)
|
||||||
actorNew->spr.extra = 0;
|
actorNew->spr.extra = 0;
|
||||||
actorNew->spr.pos.X = sp->pos.X;
|
actorNew->spr.pos.X = sp->pos.X;
|
||||||
actorNew->spr.pos.Y = sp->pos.Y;
|
actorNew->spr.pos.Y = sp->pos.Y;
|
||||||
actorNew->spr.pos.Z = GetSpriteZOfMiddle(sp);
|
actorNew->spr.pos.Z = ActorZOfMiddle(actor);
|
||||||
actorNew->spr.ang = 0;
|
actorNew->spr.ang = 0;
|
||||||
actorNew->spr.extra = 0;
|
actorNew->spr.extra = 0;
|
||||||
|
|
||||||
|
@ -5988,7 +5988,7 @@ KeyMain:
|
||||||
RESET(actorNew->spr.cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
|
RESET(actorNew->spr.cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
|
||||||
SET(actorNew->spr.cstat, CSTAT_SPRITE_ALIGNMENT_WALL);
|
SET(actorNew->spr.cstat, CSTAT_SPRITE_ALIGNMENT_WALL);
|
||||||
SetAttach(pp->Actor(), actorNew);
|
SetAttach(pp->Actor(), actorNew);
|
||||||
nu->sz = GetSpriteZOfMiddle(&pp->Actor()->s()); // Set mid way up who it hit
|
nu->sz = ActorZOfMiddle(pp->Actor()); // Set mid way up who it hit
|
||||||
nu->spal = actorNew->spr.pal = sp->pal; // Set the palette of the flag
|
nu->spal = actorNew->spr.pal = sp->pal; // Set the palette of the flag
|
||||||
|
|
||||||
SetOwner(pp->Actor(), actorNew); // Player now owns the flag
|
SetOwner(pp->Actor(), actorNew); // Player now owns the flag
|
||||||
|
|
|
@ -11539,7 +11539,6 @@ int DoRing(DSWActor* actor)
|
||||||
auto own = GetOwner(actor);
|
auto own = GetOwner(actor);
|
||||||
if (!own) return 0; // this would crash.
|
if (!own) return 0; // this would crash.
|
||||||
PLAYERp pp = own->user.PlayerP;;
|
PLAYERp pp = own->user.PlayerP;;
|
||||||
SPRITEp so = &own->s();
|
|
||||||
int cz,fz;
|
int cz,fz;
|
||||||
|
|
||||||
if (TEST(u->Flags, SPR_UNDERWATER))
|
if (TEST(u->Flags, SPR_UNDERWATER))
|
||||||
|
@ -11554,12 +11553,12 @@ int DoRing(DSWActor* actor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// move the center with the player
|
// move the center with the player
|
||||||
actor->spr.pos.X = so->pos.X;
|
actor->spr.pos.X = own->spr.pos.X;
|
||||||
actor->spr.pos.Y = so->pos.Y;
|
actor->spr.pos.Y = own->spr.pos.Y;
|
||||||
if (pp)
|
if (pp)
|
||||||
actor->spr.pos.Z = pp->pos.Z + Z(20);
|
actor->spr.pos.Z = pp->pos.Z + Z(20);
|
||||||
else
|
else
|
||||||
actor->spr.pos.Z = GetSpriteZOfMiddle(so) + Z(30);
|
actor->spr.pos.Z = ActorZOfMiddle(own) + Z(30);
|
||||||
|
|
||||||
// go out until its time to come back in
|
// go out until its time to come back in
|
||||||
if (u->Counter2 == false)
|
if (u->Counter2 == false)
|
||||||
|
@ -12492,7 +12491,7 @@ int InitFistAttack(PLAYERp pp)
|
||||||
{
|
{
|
||||||
if (SpriteOverlapZ(pp->Actor(), itActor, Z(20)) || face == 190)
|
if (SpriteOverlapZ(pp->Actor(), itActor, Z(20)) || face == 190)
|
||||||
{
|
{
|
||||||
if (FAFcansee(itActor->spr.pos.X, itActor->spr.pos.Y, ActorZOfMiddle(itActor), itActor->spr.sector(), psp->pos.X, psp->pos.Y, GetSpriteZOfMiddle(psp), psp->sector()))
|
if (FAFcansee(itActor->spr.pos.X, itActor->spr.pos.Y, ActorZOfMiddle(itActor), itActor->spr.sector(), psp->pos.X, psp->pos.Y, ActorZOfMiddle(plActor), psp->sector()))
|
||||||
DoDamage(itActor, plActor);
|
DoDamage(itActor, plActor);
|
||||||
if (face == 190)
|
if (face == 190)
|
||||||
{
|
{
|
||||||
|
@ -12775,21 +12774,19 @@ int InitSumoStompAttack(DSWActor* actor)
|
||||||
SWStatIterator it(StatDamageList[stat]);
|
SWStatIterator it(StatDamageList[stat]);
|
||||||
while (auto itActor = it.Next())
|
while (auto itActor = it.Next())
|
||||||
{
|
{
|
||||||
tsp = &itActor->s();
|
|
||||||
|
|
||||||
if (itActor != u->targetActor)
|
if (itActor != u->targetActor)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!TEST(tsp->extra, SPRX_PLAYER_OR_ENEMY))
|
if (!TEST(itActor->spr.extra, SPRX_PLAYER_OR_ENEMY))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dist = Distance(actor->spr.pos.X, actor->spr.pos.Y, tsp->pos.X, tsp->pos.Y);
|
dist = Distance(actor->spr.pos.X, actor->spr.pos.Y, itActor->spr.pos.X, itActor->spr.pos.Y);
|
||||||
|
|
||||||
reach = 16384;
|
reach = 16384;
|
||||||
|
|
||||||
if (dist < CloseRangeDist(itActor, actor, reach))
|
if (dist < CloseRangeDist(itActor, actor, reach))
|
||||||
{
|
{
|
||||||
if (FAFcansee(tsp->pos.X,tsp->pos.Y,GetSpriteZOfMiddle(tsp),tsp->sector(),actor->spr.pos.X,actor->spr.pos.Y,ActorZOfMiddle(actor),actor->spr.sector()))
|
if (FAFcansee(itActor->spr.pos.X, itActor->spr.pos.Y, ActorZOfMiddle(itActor), itActor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, ActorZOfMiddle(actor), actor->spr.sector()))
|
||||||
DoDamage(itActor, actor);
|
DoDamage(itActor, actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue