mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-16 01:11:28 +00:00
- randomFlip stuff.
To avoid casting from int to flags.
This commit is contained in:
parent
8f0f0e8816
commit
e02f4d8fd1
7 changed files with 34 additions and 20 deletions
|
@ -267,7 +267,7 @@ void lotsofstuff(DDukeActor* actor, int n, int spawntype)
|
|||
{
|
||||
int r1 = krand(), r2 = krand(); // using the RANDCORRECT version from RR.
|
||||
auto j = EGS(s->sector(), s->x, s->y, s->z - (r2 % (47 << 8)), spawntype, -32, 8, 8, r1 & 2047, 0, 0, actor, 5);
|
||||
if (j) j->s->cstat = krand() & 12;
|
||||
if (j) j->s->cstat = randomFlip();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1521,8 +1521,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball)
|
|||
if (s->picnum == stripeball)
|
||||
{
|
||||
s->cstat = CSTAT_SPRITE_BLOCK_ALL;
|
||||
s->cstat |= CSTAT_SPRITE_XFLIP & s->xvel;
|
||||
s->cstat |= CSTAT_SPRITE_YFLIP & s->xvel;
|
||||
s->cstat |= int(CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP) & s->xvel;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1595,7 +1594,7 @@ void forcesphere(DDukeActor* actor, int forcesphere)
|
|||
auto k = spawn(actor, forcesphere);
|
||||
if (k)
|
||||
{
|
||||
k->s->cstat = CSTAT_SPRITE_BLOCK_ALL + 128;
|
||||
k->s->cstat = CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_YCENTER;
|
||||
k->s->clipdist = 64;
|
||||
k->s->ang = j;
|
||||
k->s->zvel = bsin(l, -5);
|
||||
|
@ -2148,7 +2147,7 @@ void frameeffect1(DDukeActor *actor)
|
|||
deletesprite(actor);
|
||||
return;
|
||||
}
|
||||
else if (t[0] > 4) actor->s->cstat |= CSTAT_SPRITE_TRANS_FLIP + 2;
|
||||
else if (t[0] > 4) actor->s->cstat |= CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT;
|
||||
else if (t[0] > 2) actor->s->cstat |= CSTAT_SPRITE_TRANSLUCENT;
|
||||
actor->s->xoffset = Owner->s->xoffset;
|
||||
actor->s->yoffset = Owner->s->yoffset;
|
||||
|
|
|
@ -251,7 +251,7 @@ void animatesprites_d(tspritetype* tsprite, int& spritesortcnt, int x, int y, in
|
|||
if (camsprite != nullptr && h->GetHitOwner() && h->GetHitOwner()->temp_data[0] == 1)
|
||||
{
|
||||
t->picnum = STATIC;
|
||||
t->cstat |= (rand() & 12);
|
||||
t->cstat |= randomFlip();
|
||||
t->xrepeat += 8;
|
||||
t->yrepeat += 8;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ int getlabelvalue(const char* text);
|
|||
static int ccmd_spawn(CCmdFuncPtr parm)
|
||||
{
|
||||
int x = 0, y = 0, z = 0;
|
||||
unsigned int cstat = 0;
|
||||
int16_t cstat = 0;
|
||||
int picnum = 0;
|
||||
unsigned int pal = 0;
|
||||
int ang = 0;
|
||||
|
|
|
@ -213,5 +213,20 @@ inline void hud_draw(double x, double y, int tilenum, int shade, int orientation
|
|||
hud_drawsprite(x, y, 65536, 0, tilenum, shade, p, 2 | orientation);
|
||||
}
|
||||
|
||||
inline ESpriteFlags randomFlip()
|
||||
{
|
||||
int r = krand() & 12;
|
||||
if (r == 0) return 0;
|
||||
if (r == 4) return CSTAT_SPRITE_XFLIP;
|
||||
if (r == 8) return CSTAT_SPRITE_YFLIP;
|
||||
return CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP;
|
||||
}
|
||||
|
||||
inline ESpriteFlags randomXFlip()
|
||||
{
|
||||
int r = krand() & 4;
|
||||
if (r == 0) return 0;
|
||||
return CSTAT_SPRITE_XFLIP;
|
||||
}
|
||||
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -305,7 +305,7 @@ DDukeActor* aim(DDukeActor* actor, int aang)
|
|||
while (auto act = it.Next())
|
||||
{
|
||||
auto sp = act->s;
|
||||
if (sp->xrepeat > 0 && sp->extra >= 0 && (sp->cstat & (257 + 32768)) == 257)
|
||||
if (sp->xrepeat > 0 && sp->extra >= 0 && (sp->cstat & (CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_INVISIBLE)) == CSTAT_SPRITE_BLOCK_ALL)
|
||||
if (badguy(sp) || k < 2)
|
||||
{
|
||||
if (badguy(sp) || sp->picnum == TILE_APLAYER)
|
||||
|
|
|
@ -555,7 +555,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
|
|||
break;
|
||||
case BULLETHOLE:
|
||||
sp->xrepeat = sp->yrepeat = 3;
|
||||
sp->cstat = CSTAT_SPRITE_ALIGNMENT_WALL + (krand() & 12);
|
||||
sp->cstat = CSTAT_SPRITE_ALIGNMENT_WALL | randomFlip();
|
||||
insertspriteq(act);
|
||||
[[fallthrough]];
|
||||
case MONEY:
|
||||
|
@ -564,7 +564,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
|
|||
if (sp->picnum == MONEY || sp->picnum == MAIL || sp->picnum == PAPER)
|
||||
{
|
||||
act->temp_data[0] = krand() & 2047;
|
||||
sp->cstat = krand() & 12;
|
||||
sp->cstat = randomFlip();
|
||||
sp->xrepeat = sp->yrepeat = 8;
|
||||
sp->ang = krand() & 2047;
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
|
|||
{
|
||||
sp->ang = spj->ang;
|
||||
sp->shade = -64;
|
||||
sp->cstat = CSTAT_SPRITE_YCENTER | (krand() & 4);
|
||||
sp->cstat = CSTAT_SPRITE_YCENTER | randomXFlip();
|
||||
}
|
||||
|
||||
if (sp->picnum == EXPLOSION2 || sp->picnum == EXPLOSION2BOT)
|
||||
|
@ -1219,7 +1219,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
|
|||
sp->clipdist = 24;
|
||||
ps[connecthead].max_actors_killed++;
|
||||
}
|
||||
sp->cstat = CSTAT_SPRITE_BLOCK_ALL | (krand() & 4);
|
||||
sp->cstat = CSTAT_SPRITE_BLOCK_ALL | randomXFlip();
|
||||
ChangeActorStat(act, STAT_ZOMBIEACTOR);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -577,14 +577,14 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
|
|||
break;
|
||||
case BULLETHOLE:
|
||||
sp->xrepeat = sp->yrepeat = 3;
|
||||
sp->cstat = CSTAT_SPRITE_ALIGNMENT_WALL + (krand() & 12);
|
||||
sp->cstat = CSTAT_SPRITE_ALIGNMENT_WALL | randomFlip();
|
||||
insertspriteq(act);
|
||||
[[fallthrough]];
|
||||
case MONEY:
|
||||
if (sp->picnum == MONEY)
|
||||
{
|
||||
act->temp_data[0] = krand() & 2047;
|
||||
sp->cstat = krand() & 12;
|
||||
sp->cstat = randomFlip();
|
||||
sp->xrepeat = sp->yrepeat = 8;
|
||||
sp->ang = krand() & 2047;
|
||||
}
|
||||
|
@ -622,7 +622,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
|
|||
{
|
||||
sp->ang = spj->ang;
|
||||
sp->shade = -64;
|
||||
sp->cstat = CSTAT_SPRITE_YCENTER | (krand() & 4);
|
||||
sp->cstat = CSTAT_SPRITE_YCENTER | randomXFlip();
|
||||
}
|
||||
|
||||
if (sp->picnum == EXPLOSION2)
|
||||
|
@ -1168,7 +1168,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
|
|||
sp->zvel = 0;
|
||||
}
|
||||
ssp(act, CLIPMASK0);
|
||||
sp->cstat = krand() & 4;
|
||||
sp->cstat = randomXFlip();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1361,7 +1361,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
|
|||
if (spj)
|
||||
{
|
||||
sp->ang = spj->ang;
|
||||
sp->cstat = CSTAT_SPRITE_ALIGNMENT_WALL + 128 + 2;
|
||||
sp->cstat = CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_YCENTER | CSTAT_SPRITE_TRANSLUCENT;
|
||||
sp->xrepeat = sp->yrepeat = 1;
|
||||
sp->xvel = -8;
|
||||
ssp(act, CLIPMASK0);
|
||||
|
@ -1383,7 +1383,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
|
|||
sp->cstat = CSTAT_SPRITE_INVISIBLE;
|
||||
sp->xrepeat = sp->yrepeat = 0;
|
||||
}
|
||||
else sp->cstat = 1 + 256;
|
||||
else sp->cstat = CSTAT_SPRITE_BLOCK_ALL;
|
||||
sp->extra = gs.impact_damage << 2;
|
||||
act->SetOwner(act);
|
||||
ChangeActorStat(act, STAT_STANDABLE);
|
||||
|
@ -1393,7 +1393,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
|
|||
case CRACK2:
|
||||
case CRACK3:
|
||||
case CRACK4:
|
||||
sp->cstat |= 17;
|
||||
sp->cstat |= CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_ALIGNMENT_WALL;
|
||||
sp->extra = 1;
|
||||
if (ud.multimode < 2 && sp->pal != 0)
|
||||
{
|
||||
|
@ -1482,7 +1482,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
|
|||
{
|
||||
if (sp->picnum == EGG)
|
||||
sp->clipdist = 24;
|
||||
sp->cstat = CSTAT_SPRITE_BLOCK_ALL | (krand() & 4);
|
||||
sp->cstat = CSTAT_SPRITE_BLOCK_ALL | randomXFlip();
|
||||
ChangeActorStat(act, STAT_ZOMBIEACTOR);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue