- merged both movefta functions, using the already defined flags instead of explicit picnum checks.

This commit is contained in:
Christoph Oelckers 2022-01-02 15:44:52 +01:00
parent a6845f55e4
commit 1d091ae395
4 changed files with 107 additions and 219 deletions

View file

@ -5223,6 +5223,110 @@ void recordoldspritepos()
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void movefta(void)
{
int x, px, py, sx, sy;
int canseeme, p;
sectortype* psect, * ssect;
DukeStatIterator it(STAT_ZOMBIEACTOR);
while (auto act = it.Next())
{
p = findplayer(act, &x);
canseeme = 0;
ssect = psect = act->sector();
if (ps[p].GetActor()->spr.extra > 0)
{
if (x < 30000)
{
act->timetosleep++;
if (act->timetosleep >= (x >> 8))
{
if (badguy(act))
{
px = ps[p].opos.X + 64 - (krand() & 127);
py = ps[p].opos.Y + 64 - (krand() & 127);
updatesector(px, py, &psect);
if (psect == nullptr)
{
continue;
}
sx = act->spr.pos.X + 64 - (krand() & 127);
sy = act->spr.pos.Y + 64 - (krand() & 127);
updatesector(px, py, &ssect);
if (ssect == nullptr)
{
continue;
}
// SFLAG_MOVEFTA_CHECKSEE is set for all actors in Duke.
if (act->spr.pal == 33 || actorflag(act, SFLAG_MOVEFTA_CHECKSEE) ||
(actorflag(act, SFLAG2_MOVEFTA_CHECKSEEWITHPAL8) && act->spr.pal == 8) ||
(bcos(act->spr.ang) * (px - sx) + bsin(act->spr.ang) * (py - sy) >= 0))
{
int r1 = krand();
int r2 = krand();
canseeme = cansee(sx, sy, act->spr.pos.Z - (r2 % (52 << 8)), act->sector(), px, py, ps[p].opos.Z - (r1 % (32 << 8)), ps[p].cursector);
}
}
else
{
int r1 = krand();
int r2 = krand();
canseeme = cansee(act->spr.pos.X, act->spr.pos.Y, act->spr.pos.Z - ((r2 & 31) << 8), act->sector(), ps[p].opos.X, ps[p].opos.Y, ps[p].opos.Z - ((r1 & 31) << 8), ps[p].cursector);
}
if (canseeme)
{
if (actorflag(act, SFLAG2_NOVEFTA_MAKESTANDABLE))
{
if (act->sector()->ceilingstat & CSTAT_SECTOR_SKY)
act->spr.shade = act->sector()->ceilingshade;
else act->spr.shade = act->sector()->floorshade;
act->timetosleep = 0;
ChangeActorStat(act, STAT_STANDABLE);
}
else
{
act->timetosleep = 0;
check_fta_sounds_r(act);
ChangeActorStat(act, STAT_ACTOR);
}
}
else act->timetosleep = 0;
}
}
if (badguy(act))
{
if (act->sector()->ceilingstat & CSTAT_SECTOR_SKY)
act->spr.shade = act->sector()->ceilingshade;
else act->spr.shade = act->sector()->floorshade;
if (actorflag(act, SFLAG2_MOVEFTA_WAKEUPCHECK))
{
if (wakeup(act, p))
{
act->timetosleep = 0;
check_fta_sounds_r(act);
ChangeActorStat(act, STAT_ACTOR);
}
}
}
}
}
}
END_DUKE_NS

View file

@ -587,107 +587,6 @@ void guts_d(DDukeActor* actor, int gtype, int n, int p)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void movefta_d(void)
{
int x, px, py, sx, sy;
int p;
sectortype* psect, *ssect;
int j;
DukeStatIterator iti(STAT_ZOMBIEACTOR);
while (auto act = iti.Next())
{
p = findplayer(act, &x);
ssect = psect = act->sector();
auto pa = ps[p].GetActor();
if (pa->spr.extra > 0)
{
if (x < 30000)
{
act->timetosleep++;
if (act->timetosleep >= (x >> 8))
{
if (badguy(act))
{
px = ps[p].opos.X + 64 - (krand() & 127);
py = ps[p].opos.Y + 64 - (krand() & 127);
updatesector(px, py, &psect);
if (psect == nullptr)
{
continue;
}
sx = act->spr.pos.X + 64 - (krand() & 127);
sy = act->spr.pos.Y + 64 - (krand() & 127);
updatesector(px, py, &ssect);
if (ssect == nullptr)
{
continue;
}
int r1 = krand();
int r2 = krand();
j = cansee(sx, sy, act->spr.pos.Z - (r2 % (52 << 8)), act->sector(), px, py, ps[p].opos.Z - (r1 % (32 << 8)), ps[p].cursector);
}
else
{
int r1 = krand();
int r2 = krand();
j = cansee(act->spr.pos.X, act->spr.pos.Y, act->spr.pos.Z - ((r2 & 31) << 8), act->sector(), ps[p].opos.X, ps[p].opos.Y, ps[p].opos.Z - ((r1 & 31) << 8), ps[p].cursector);
}
if (j) switch(act->spr.picnum)
{
case RUBBERCAN:
case EXPLODINGBARREL:
case WOODENHORSE:
case HORSEONSIDE:
case CANWITHSOMETHING:
case CANWITHSOMETHING2:
case CANWITHSOMETHING3:
case CANWITHSOMETHING4:
case FIREBARREL:
case FIREVASE:
case NUKEBARREL:
case NUKEBARRELDENTED:
case NUKEBARRELLEAKED:
case TRIPBOMB:
if (act->sector()->ceilingstat & CSTAT_SECTOR_SKY)
act->spr.shade = act->sector()->ceilingshade;
else act->spr.shade = act->sector()->floorshade;
act->timetosleep = 0;
ChangeActorStat(act, STAT_STANDABLE);
break;
default:
act->timetosleep = 0;
check_fta_sounds_d(act);
ChangeActorStat(act, STAT_ACTOR);
break;
}
else act->timetosleep = 0;
}
}
if (badguy(act))
{
if (act->sector()->ceilingstat & CSTAT_SECTOR_SKY)
act->spr.shade = act->sector()->ceilingshade;
else act->spr.shade = act->sector()->floorshade;
}
}
}
}
//---------------------------------------------------------------------------
//
//
@ -3907,7 +3806,7 @@ void think_d(void)
thinktime.Clock();
recordoldspritepos();
movefta_d(); //ST 2
movefta(); //ST 2
moveweapons_d(); //ST 4
movetransports_d(); //ST 9
moveplayers(); //ST 10

View file

@ -497,122 +497,6 @@ void guts_r(DDukeActor* actor, int gtype, int n, int p)
//
//---------------------------------------------------------------------------
void movefta_r(void)
{
int x, px, py, sx, sy;
int j, p;
sectortype* psect, *ssect;
DukeStatIterator it(STAT_ZOMBIEACTOR);
while(auto act = it.Next())
{
p = findplayer(act, &x);
j = 0;
ssect = psect = act->sector();
if (ps[p].GetActor()->spr.extra > 0)
{
if (x < 30000)
{
act->timetosleep++;
if (act->timetosleep >= (x >> 8))
{
if (badguy(act))
{
px = ps[p].opos.X + 64 - (krand() & 127);
py = ps[p].opos.Y + 64 - (krand() & 127);
updatesector(px, py, &psect);
if (psect == nullptr)
{
continue;
}
sx = act->spr.pos.X + 64 - (krand() & 127);
sy = act->spr.pos.Y + 64 - (krand() & 127);
updatesector(px, py, &ssect);
if (ssect == nullptr)
{
continue;
}
if (act->spr.pal == 33 || act->spr.picnum == VIXEN ||
(isRRRA() && (isIn(act->spr.picnum, COOT, COOTSTAYPUT, BIKER, BIKERB, BIKERBV2, CHEER, CHEERB,
CHEERSTAYPUT, MINIONBOAT, HULKBOAT, CHEERBOAT, RABBIT, COOTPLAY, BILLYPLAY, MAKEOUT, MAMA)
|| (act->spr.picnum == MINION && act->spr.pal == 8)))
|| (bcos(act->spr.ang) * (px - sx) + bsin(act->spr.ang) * (py - sy) >= 0))
{
int r1 = krand();
int r2 = krand();
j = cansee(sx, sy, act->spr.pos.Z - (r2 % (52 << 8)), act->sector(), px, py, ps[p].opos.Z - (r1 % (32 << 8)), ps[p].cursector);
}
}
else
{
int r1 = krand();
int r2 = krand();
j = cansee(act->spr.pos.X, act->spr.pos.Y, act->spr.pos.Z - ((r2 & 31) << 8), act->sector(), ps[p].opos.X, ps[p].opos.Y, ps[p].opos.Z - ((r1 & 31) << 8), ps[p].cursector);
}
if (j) switch (act->spr.picnum)
{
case RUBBERCAN:
case EXPLODINGBARREL:
case WOODENHORSE:
case HORSEONSIDE:
case CANWITHSOMETHING:
case FIREBARREL:
case FIREVASE:
case NUKEBARREL:
case NUKEBARRELDENTED:
case NUKEBARRELLEAKED:
if (act->sector()->ceilingstat & CSTAT_SECTOR_SKY)
act->spr.shade = act->sector()->ceilingshade;
else act->spr.shade = act->sector()->floorshade;
act->timetosleep = 0;
ChangeActorStat(act, STAT_STANDABLE);
break;
default:
#if 0
// TRANSITIONAL: RedNukem has this here. Needed?
if (actorflag(act, SFLAG_USEACTIVATOR) && sector [act->s.lotag & 16384) break;
#endif
act->timetosleep = 0;
check_fta_sounds_r(act);
ChangeActorStat(act, STAT_ACTOR);
break;
}
else act->timetosleep = 0;
}
}
if (/*!j &&*/ badguy(act)) // this is like RedneckGDX. j is uninitialized here, i.e. most likely not 0.
{
if (act->sector()->ceilingstat & CSTAT_SECTOR_SKY)
act->spr.shade = act->sector()->ceilingshade;
else act->spr.shade = act->sector()->floorshade;
if (act->spr.picnum == HEN || act->spr.picnum == COW || act->spr.picnum == PIG || act->spr.picnum == DOGRUN || ((isRRRA()) && act->spr.picnum == RABBIT))
{
if (wakeup(act, p))
{
act->timetosleep = 0;
check_fta_sounds_r(act);
ChangeActorStat(act, STAT_ACTOR);
}
}
}
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int ifhitbyweapon_r(DDukeActor *actor)
{
int p;
@ -4202,7 +4086,7 @@ void think_r(void)
thinktime.Clock();
recordoldspritepos();
movefta_r(); //ST 2
movefta(); //ST 2
moveweapons_r(); //ST 4
movetransports_r(); //ST 9
moveplayers(); //ST 10

View file

@ -27,6 +27,7 @@ void moveplayers();
void doanimations();
void movefx();
void moveclouds(double smoothratio);
void movefta();
void RANDOMSCRAP(DDukeActor* i);
void ms(DDukeActor* i);