- bounce, movetongue and rpgexplode.

This commit is contained in:
Christoph Oelckers 2020-10-21 22:29:35 +02:00
parent e001b3117f
commit 6257ebc30c
4 changed files with 71 additions and 66 deletions

View file

@ -1295,29 +1295,27 @@ void movecanwithsomething(DDukeActor* actor)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void bounce(int i) void bounce(DDukeActor* actor)
{ {
int k, l, daang, dax, day, daz, xvect, yvect, zvect; auto s = &actor->s;
int hitsect; int xvect = mulscale10(s->xvel, sintable[(s->ang + 512) & 2047]);
spritetype* s = &sprite[i]; int yvect = mulscale10(s->xvel, sintable[s->ang & 2047]);
int zvect = s->zvel;
xvect = mulscale10(s->xvel, sintable[(s->ang + 512) & 2047]); int hitsect = s->sectnum;
yvect = mulscale10(s->xvel, sintable[s->ang & 2047]);
zvect = s->zvel;
hitsect = s->sectnum; int k = sector[hitsect].wallptr;
int l = wall[k].point2;
int daang = getangle(wall[l].x - wall[k].x, wall[l].y - wall[k].y);
k = sector[hitsect].wallptr; l = wall[k].point2; if (s->z < (actor->floorz + actor->ceilingz) >> 1)
daang = getangle(wall[l].x - wall[k].x, wall[l].y - wall[k].y);
if (s->z < (hittype[i].floorz + hittype[i].ceilingz) >> 1)
k = sector[hitsect].ceilingheinum; k = sector[hitsect].ceilingheinum;
else else
k = sector[hitsect].floorheinum; k = sector[hitsect].floorheinum;
dax = mulscale14(k, sintable[(daang) & 2047]); int dax = mulscale14(k, sintable[(daang) & 2047]);
day = mulscale14(k, sintable[(daang + 1536) & 2047]); int day = mulscale14(k, sintable[(daang + 1536) & 2047]);
daz = 4096; int daz = 4096;
k = xvect * dax + yvect * day + zvect * daz; k = xvect * dax + yvect * day + zvect * daz;
l = dax * dax + day * day + daz * daz; l = dax * dax + day * day + daz * daz;
@ -1340,49 +1338,57 @@ void bounce(int i)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void movetongue(int i, int tongue, int jaw) void movetongue(DDukeActor *actor, int tongue, int jaw)
{ {
spritetype* s = &sprite[i]; auto s = &actor->s;
actor->temp_data[0] = sintable[(actor->temp_data[1]) & 2047] >> 9;
hittype[i].temp_data[0] = sintable[(hittype[i].temp_data[1]) & 2047] >> 9; actor->temp_data[1] += 32;
hittype[i].temp_data[1] += 32; if (actor->temp_data[1] > 2047)
if (hittype[i].temp_data[1] > 2047)
{ {
deletesprite(i); deletesprite(actor);
return; return;
} }
if (sprite[s->owner].statnum == MAXSTATUS) auto Owner = actor->GetOwner();
if (badguy(&sprite[s->owner]) == 0) if (!Owner) return;
if (Owner->s.statnum == MAXSTATUS)
if (badguy(Owner) == 0)
{ {
deletesprite(i); deletesprite(actor);
return; return;
} }
s->ang = sprite[s->owner].ang; s->ang = Owner->s.ang;
s->x = sprite[s->owner].x; s->x = Owner->s.x;
s->y = sprite[s->owner].y; s->y = Owner->s.y;
if (sprite[s->owner].picnum == TILE_APLAYER) if (Owner->s.picnum == TILE_APLAYER)
s->z = sprite[s->owner].z - (34 << 8); s->z = Owner->s.z - (34 << 8);
for (int k = 0; k < hittype[i].temp_data[0]; k++) for (int k = 0; k < actor->temp_data[0]; k++)
{ {
int q = EGS(s->sectnum, auto q = EGS(s->sectnum,
s->x + ((k * sintable[(s->ang + 512) & 2047]) >> 9), s->x + ((k * sintable[(s->ang + 512) & 2047]) >> 9),
s->y + ((k * sintable[s->ang & 2047]) >> 9), s->y + ((k * sintable[s->ang & 2047]) >> 9),
s->z + ((k * ksgn(s->zvel)) * abs(s->zvel / 12)), tongue, -40 + (k << 1), s->z + ((k * ksgn(s->zvel)) * abs(s->zvel / 12)), tongue, -40 + (k << 1),
8, 8, 0, 0, 0, i, 5); 8, 8, 0, 0, 0, actor, 5);
sprite[q].cstat = 128; if (q)
sprite[q].pal = 8; {
q->s.cstat = 128;
q->s.pal = 8;
} }
int k = hittype[i].temp_data[0]; // do not depend on the above loop counter. }
int q = EGS(s->sectnum, int k = actor->temp_data[0]; // do not depend on the above loop counter.
auto spawned = EGS(s->sectnum,
s->x + ((k * sintable[(s->ang + 512) & 2047]) >> 9), s->x + ((k * sintable[(s->ang + 512) & 2047]) >> 9),
s->y + ((k * sintable[s->ang & 2047]) >> 9), s->y + ((k * sintable[s->ang & 2047]) >> 9),
s->z + ((k * ksgn(s->zvel)) * abs(s->zvel / 12)), jaw, -40, s->z + ((k * ksgn(s->zvel)) * abs(s->zvel / 12)), jaw, -40,
32, 32, 0, 0, 0, i, 5); 32, 32, 0, 0, 0, actor, 5);
sprite[q].cstat = 128; if (spawned)
if (hittype[i].temp_data[1] > 512 && hittype[i].temp_data[1] < (1024)) {
sprite[q].picnum = jaw + 1; spawned->s.cstat = 128;
if (actor->temp_data[1] > 512 && actor->temp_data[1] < (1024))
spawned->s.picnum = jaw + 1;
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1391,40 +1397,39 @@ void movetongue(int i, int tongue, int jaw)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void rpgexplode(int i, int j, const vec3_t &pos, int EXPLOSION2, int EXPLOSION2BOT, int newextra, int playsound) void rpgexplode(DDukeActor *actor, int hit, const vec3_t &pos, int EXPLOSION2, int EXPLOSION2BOT, int newextra, int playsound)
{ {
auto act = &hittype[i]; auto s = &actor->s;
auto s = &act->s; auto explosion = spawn(actor, EXPLOSION2);
auto k = spawn(act, EXPLOSION2); explosion->s.pos = pos;
k->s.pos = pos;
if (s->xrepeat < 10) if (s->xrepeat < 10)
{ {
k->s.xrepeat = 6; explosion->s.xrepeat = 6;
k->s.yrepeat = 6; explosion->s.yrepeat = 6;
} }
else if ((j & kHitTypeMask) == kHitSector) else if ((hit & kHitTypeMask) == kHitSector)
{ {
if (s->zvel > 0 && EXPLOSION2BOT >= 0) if (s->zvel > 0 && EXPLOSION2BOT >= 0)
fi.spawn(i, EXPLOSION2BOT); spawn(actor, EXPLOSION2BOT);
else else
{ {
k->s.cstat |= 8; explosion->s.cstat |= 8;
k->s.z += (48 << 8); explosion->s.z += (48 << 8);
} }
} }
if (newextra > 0) s->extra = newextra; if (newextra > 0) s->extra = newextra;
S_PlayActorSound(playsound, i); S_PlayActorSound(playsound, actor);
if (s->xrepeat >= 10) if (s->xrepeat >= 10)
{ {
int x = s->extra; int x = s->extra;
fi.hitradius(&hittype[i], rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x); fi.hitradius(actor, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x);
} }
else else
{ {
int x = s->extra + (global_random & 3); int x = s->extra + (global_random & 3);
fi.hitradius(&hittype[i], (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); fi.hitradius(actor, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x);
} }
} }

View file

@ -1798,7 +1798,7 @@ static bool weaponhitsector(int i, const vec3_t& oldpos, bool fireball)
if (s->picnum == FREEZEBLAST) if (s->picnum == FREEZEBLAST)
{ {
bounce(i); bounce(&hittype[i]);
ssp(i, CLIPMASK1); ssp(i, CLIPMASK1);
s->extra >>= 1; s->extra >>= 1;
if (s->xrepeat > 8) if (s->xrepeat > 8)
@ -1939,7 +1939,7 @@ static void weaponcommon_d(int i)
if (s->picnum == RPG) if (s->picnum == RPG)
{ {
// j is only needed for the hit type mask. // j is only needed for the hit type mask.
rpgexplode(i, j, oldpos, EXPLOSION2, EXPLOSION2BOT, -1, RPG_EXPLODE); rpgexplode(&hittype[i], j, oldpos, EXPLOSION2, EXPLOSION2BOT, -1, RPG_EXPLODE);
} }
else if (s->picnum == SHRINKSPARK) else if (s->picnum == SHRINKSPARK)
{ {
@ -2015,7 +2015,7 @@ void moveweapons_d(void)
deletesprite(i); deletesprite(i);
continue; continue;
case TONGUE: case TONGUE:
movetongue(i, TONGUE, INNERJAW); movetongue(&hittype[i], TONGUE, INNERJAW);
continue; continue;
case FREEZEBLAST: case FREEZEBLAST:

View file

@ -1384,7 +1384,7 @@ bool weaponhitsector(int i, const vec3_t& oldpos)
if (!isRRRA() && s->picnum == FREEZEBLAST) if (!isRRRA() && s->picnum == FREEZEBLAST)
{ {
bounce(i); bounce(&hittype[i]);
ssp(i, CLIPMASK1); ssp(i, CLIPMASK1);
s->extra >>= 1; s->extra >>= 1;
if (s->xrepeat > 8) if (s->xrepeat > 8)
@ -1528,9 +1528,9 @@ static void weaponcommon_r(int i)
if (s->picnum != SPIT) if (s->picnum != SPIT)
{ {
if (s->picnum == RPG) rpgexplode(i, j, oldpos, EXPLOSION2, -1, -1, RPG_EXPLODE); if (s->picnum == RPG) rpgexplode(&hittype[i], j, oldpos, EXPLOSION2, -1, -1, RPG_EXPLODE);
else if (isRRRA() && s->picnum == RPG2) rpgexplode(i, j, oldpos, EXPLOSION2, -1, 150, 247); else if (isRRRA() && s->picnum == RPG2) rpgexplode(&hittype[i], j, oldpos, EXPLOSION2, -1, 150, 247);
else if (isRRRA() && s->picnum == RRTILE1790) rpgexplode(i, j, oldpos, EXPLOSION2, -1, 160, RPG_EXPLODE); else if (isRRRA() && s->picnum == RRTILE1790) rpgexplode(&hittype[i], j, oldpos, EXPLOSION2, -1, 160, RPG_EXPLODE);
else if (s->picnum != FREEZEBLAST && s->picnum != FIRELASER && s->picnum != SHRINKSPARK) else if (s->picnum != FREEZEBLAST && s->picnum != FIRELASER && s->picnum != SHRINKSPARK)
{ {
k = fi.spawn(i, 1441); k = fi.spawn(i, 1441);
@ -1582,7 +1582,7 @@ void moveweapons_r(void)
deletesprite(i); deletesprite(i);
continue; continue;
case TONGUE: case TONGUE:
movetongue(i, TONGUE, INNERJAW); movetongue(&hittype[i], TONGUE, INNERJAW);
continue; continue;
case FREEZEBLAST: case FREEZEBLAST:

View file

@ -40,9 +40,9 @@ void movewaterdrip(DDukeActor* i, int drip);
void movedoorshock(DDukeActor* i); void movedoorshock(DDukeActor* i);
void movetouchplate(DDukeActor* i, int plate); void movetouchplate(DDukeActor* i, int plate);
void movecanwithsomething(DDukeActor* i); void movecanwithsomething(DDukeActor* i);
void bounce(int i); void bounce(DDukeActor* i);
void movetongue(int i, int tongue, int jaw); void movetongue(DDukeActor* i, int tongue, int jaw);
void rpgexplode(int i, int j, const vec3_t& pos, int EXPLOSION2, int EXPLOSION2BOT, 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(int i, int yellow, int green);