- respawnmarker, rat and queball.

This commit is contained in:
Christoph Oelckers 2020-10-21 22:34:45 +02:00
parent 6257ebc30c
commit 3d16d9f44a
4 changed files with 46 additions and 48 deletions

View file

@ -1439,19 +1439,19 @@ void rpgexplode(DDukeActor *actor, int hit, const vec3_t &pos, int EXPLOSION2, i
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool respawnmarker(int i, int yellow, int green) bool respawnmarker(DDukeActor *actor, int yellow, int green)
{ {
hittype[i].temp_data[0]++; actor->temp_data[0]++;
if (hittype[i].temp_data[0] > respawnitemtime) if (actor->temp_data[0] > respawnitemtime)
{ {
deletesprite(i); deletesprite(actor);
return false; return false;
} }
if (hittype[i].temp_data[0] >= (respawnitemtime >> 1) && hittype[i].temp_data[0] < ((respawnitemtime >> 1) + (respawnitemtime >> 2))) if (actor->temp_data[0] >= (respawnitemtime >> 1) && actor->temp_data[0] < ((respawnitemtime >> 1) + (respawnitemtime >> 2)))
sprite[i].picnum = yellow; actor->s.picnum = yellow;
else if (hittype[i].temp_data[0] > ((respawnitemtime >> 1) + (respawnitemtime >> 2))) else if (actor->temp_data[0] > ((respawnitemtime >> 1) + (respawnitemtime >> 2)))
sprite[i].picnum = green; actor->s.picnum = green;
makeitfall(i); makeitfall(actor);
return true; return true;
} }
@ -1461,21 +1461,21 @@ bool respawnmarker(int i, int yellow, int green)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool rat(int i, bool makesound) bool rat(DDukeActor* actor, bool makesound)
{ {
spritetype* s = &sprite[i]; auto s = &actor->s;
makeitfall(i); makeitfall(actor);
if (ssp(i, CLIPMASK0)) if (ssp(actor, CLIPMASK0))
{ {
if (makesound && (krand() & 255) == 0) S_PlayActorSound(RATTY, i); if (makesound && (krand() & 255) == 0) S_PlayActorSound(RATTY, actor);
s->ang += (krand() & 31) - 15 + (sintable[(hittype[i].temp_data[0] << 8) & 2047] >> 11); s->ang += (krand() & 31) - 15 + (sintable[(actor->temp_data[0] << 8) & 2047] >> 11);
} }
else else
{ {
hittype[i].temp_data[0]++; actor->temp_data[0]++;
if (hittype[i].temp_data[0] > 1) if (actor->temp_data[0] > 1)
{ {
deletesprite(i); deletesprite(actor);
return false; return false;
} }
else s->ang = (krand() & 2047); else s->ang = (krand() & 2047);
@ -1492,41 +1492,40 @@ bool rat(int i, bool makesound)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool queball(int i, int pocket, int queball, int stripeball) bool queball(DDukeActor *actor, int pocket, int queball, int stripeball)
{ {
spritetype* s = &sprite[i]; auto s = &actor->s;
if (s->xvel) if (s->xvel)
{ {
StatIterator it(STAT_DEFAULT); DukeStatIterator it(STAT_DEFAULT);
int j; while (auto aa = it.Next())
while ((j = it.NextIndex()) >= 0)
{ {
if (sprite[j].picnum == pocket && ldist(&sprite[j], s) < 52) if (aa->s.picnum == pocket && ldist(aa, actor) < 52)
{ {
deletesprite(i); deletesprite(actor);
return false; return false;
} }
} }
j = clipmove(&s->x, &s->y, &s->z, &s->sectnum, int j = clipmove(&s->x, &s->y, &s->z, &s->sectnum,
(((s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14) * TICSPERFRAME) << 11, (((s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14) * TICSPERFRAME) << 11,
(((s->xvel * (sintable[s->ang & 2047])) >> 14) * TICSPERFRAME) << 11, (((s->xvel * (sintable[s->ang & 2047])) >> 14) * TICSPERFRAME) << 11,
24L, (4 << 8), (4 << 8), CLIPMASK1); 24L, (4 << 8), (4 << 8), CLIPMASK1);
if (j & 49152) if (j & kHitTypeMask)
{ {
if ((j & 49152) == 32768) if ((j & kHitTypeMask) == kHitWall)
{ {
j &= (MAXWALLS - 1); j &= kHitIndexMask;
int k = getangle( int k = getangle(
wall[wall[j].point2].x - wall[j].x, wall[wall[j].point2].x - wall[j].x,
wall[wall[j].point2].y - wall[j].y); wall[wall[j].point2].y - wall[j].y);
s->ang = ((k << 1) - s->ang) & 2047; s->ang = ((k << 1) - s->ang) & 2047;
} }
else if ((j & 49152) == 49152) else if ((j & kHitTypeMask) == kHitSprite)
{ {
j &= (MAXSPRITES - 1); j &= kHitIndexMask;
fi.checkhitsprite(i, j); fi.checkhitsprite(actor->GetIndex(), j);
} }
} }
s->xvel--; s->xvel--;
@ -1541,22 +1540,21 @@ bool queball(int i, int pocket, int queball, int stripeball)
else else
{ {
int x; int x;
int p = findplayer(s, &x); int p = findplayer(&actor->s, &x);
if (x < 1596) if (x < 1596)
{ {
// if(s->pal == 12) // if(s->pal == 12)
{ {
int j = getincangle(ps[p].angle.ang.asbuild(), getangle(s->x - ps[p].posx, s->y - ps[p].posy)); int j = getincangle(ps[p].angle.ang.asbuild(), getangle(s->x - ps[p].posx, s->y - ps[p].posy));
if (j > -64 && j < 64 && PlayerInput(p, SB_OPEN)) if (j > -64 && j < 64 && PlayerInput(p, SB_OPEN))
if (ps[p].toggle_key_flag == 1) if (ps[p].toggle_key_flag == 1)
{ {
StatIterator it(STAT_ACTOR); DukeStatIterator it(STAT_ACTOR);
int a; DDukeActor *act2;
while ((a = it.NextIndex()) >= 0) while ((act2 = it.Next()))
{ {
auto sa = &sprite[a]; auto sa = &act2->s;
if (sa->picnum == queball || sa->picnum == stripeball) if (sa->picnum == queball || sa->picnum == stripeball)
{ {
j = getincangle(ps[p].angle.ang.asbuild(), getangle(sa->x - ps[p].posx, sa->y - ps[p].posy)); j = getincangle(ps[p].angle.ang.asbuild(), getangle(sa->x - ps[p].posx, sa->y - ps[p].posy));
@ -1568,7 +1566,7 @@ bool queball(int i, int pocket, int queball, int stripeball)
} }
} }
} }
if (a == -1) if (act2 == nullptr)
{ {
if (s->pal == 12) if (s->pal == 12)
s->xvel = 164; s->xvel = 164;

View file

@ -3207,7 +3207,7 @@ void moveactors_d(void)
case RESPAWNMARKERRED: case RESPAWNMARKERRED:
case RESPAWNMARKERYELLOW: case RESPAWNMARKERYELLOW:
case RESPAWNMARKERGREEN: case RESPAWNMARKERGREEN:
if (!respawnmarker(i, RESPAWNMARKERYELLOW, RESPAWNMARKERGREEN)) continue; if (!respawnmarker(&hittype[i], RESPAWNMARKERYELLOW, RESPAWNMARKERGREEN)) continue;
break; break;
case HELECOPT: case HELECOPT:
@ -3232,11 +3232,11 @@ void moveactors_d(void)
ssp(i, CLIPMASK0); ssp(i, CLIPMASK0);
break; break;
case RAT: case RAT:
if (!rat(i, true)) continue; if (!rat(&hittype[i], true)) continue;
break; break;
case QUEBALL: case QUEBALL:
case STRIPEBALL: case STRIPEBALL:
if (!queball(i, POCKET, QUEBALL, STRIPEBALL)) continue; if (!queball(&hittype[i], POCKET, QUEBALL, STRIPEBALL)) continue;
break; break;
case FORCESPHERE: case FORCESPHERE:
forcesphere(i, FORCESPHERE); forcesphere(i, FORCESPHERE);

View file

@ -2968,10 +2968,10 @@ void moveactors_r(void)
case RESPAWNMARKERRED: case RESPAWNMARKERRED:
case RESPAWNMARKERYELLOW: case RESPAWNMARKERYELLOW:
case RESPAWNMARKERGREEN: case RESPAWNMARKERGREEN:
if (!respawnmarker(i, RESPAWNMARKERYELLOW, RESPAWNMARKERGREEN)) continue; if (!respawnmarker(&hittype[i], RESPAWNMARKERYELLOW, RESPAWNMARKERGREEN)) continue;
break; break;
case RAT: case RAT:
if (!rat(i, !isRRRA())) continue; if (!rat(&hittype[i], !isRRRA())) continue;
break; break;
case RRTILE3190: case RRTILE3190:
case RRTILE3191: case RRTILE3191:
@ -3099,7 +3099,7 @@ void moveactors_r(void)
case QUEBALL: case QUEBALL:
case STRIPEBALL: case STRIPEBALL:
if (!queball(i, POCKET, QUEBALL, STRIPEBALL)) continue; if (!queball(&hittype[i], POCKET, QUEBALL, STRIPEBALL)) continue;
break; break;
case FORCESPHERE: case FORCESPHERE:
forcesphere(i, FORCESPHERE); forcesphere(i, FORCESPHERE);

View file

@ -45,9 +45,9 @@ void movetongue(DDukeActor* i, int tongue, int jaw);
void rpgexplode(DDukeActor* i, int j, const vec3_t& pos, int EXPLOSION2, int EXPLOSIONBOT2, int newextra, int playsound); void rpgexplode(DDukeActor* i, int j, const vec3_t& pos, int EXPLOSION2, int EXPLOSIONBOT2, int newextra, int playsound);
void moveooz(DDukeActor* i, int seenine, int seeninedead, int ooz, int explosion); void moveooz(DDukeActor* i, int seenine, int seeninedead, int ooz, int explosion);
void lotsofstuff(DDukeActor* s, int n, int spawntype); void lotsofstuff(DDukeActor* s, int n, int spawntype);
bool respawnmarker(int i, int yellow, int green); bool respawnmarker(DDukeActor* i, int yellow, int green);
bool rat(int i, bool makesound); bool rat(DDukeActor* i, bool makesound);
bool queball(int i, int pocket, int queball, int stripeball); bool queball(DDukeActor* i, int pocket, int queball, int stripeball);
void forcesphere(int i, int forcesphere); void forcesphere(int i, int forcesphere);
void recon(int i, int explosion, int firelaser, int attacksnd, int painsnd, int roamsnd, int shift, int (*getspawn)(int i)); void recon(int i, int explosion, int firelaser, int attacksnd, int painsnd, int roamsnd, int shift, int (*getspawn)(int i));
void ooz(int i); void ooz(int i);