- moveeffectors, actors.c complete.

This commit is contained in:
Christoph Oelckers 2020-05-10 09:08:02 +02:00
parent 4c99eae4f6
commit 8cc273955d
15 changed files with 3323 additions and 2495 deletions

View file

@ -71,6 +71,11 @@ typedef struct
extern int16_t clipsectorlist[MAXCLIPSECTORS];
int clipinsidebox(vec2_t *vect, int wallnum, int walldist);
inline int clipinsidebox(int x, int y, int wall, int dist)
{
vec2_t v = { x, y };
return clipinsidebox(&v, wall, dist);
}
int clipinsideboxline(int x, int y, int x1, int y1, int x2, int y2, int walldist);
extern int32_t clipmoveboxtracenum;

File diff suppressed because it is too large Load diff

View file

@ -273,8 +273,11 @@ inline int LocateTheLocator(int const tag, int const sectNum)
return A_FindLocator(tag, sectNum);
}
int A_CheckNoSE7Water(uspritetype const *pSprite, int sectNum, int sectLotag, int32_t *pOther);
int A_CheckSwitchTile(int spriteNum);
inline int wallswitchcheck(int s)
{
return A_CheckSwitchTile(s);
}
int A_IncurDamage(int spriteNum);
void A_AddToDeleteQueue(int spriteNum);
void A_DeleteSprite(int spriteNum);
@ -375,6 +378,8 @@ inline int wakeup(int sn, int pn)
}
// shared functions
int ifhitsectors(int sn);
void ms(short i);
void movecrane(int i, int crane);
void movefountain(int i, int fountain);
void moveflammable(int i, int tire, int box, int pool);
@ -407,6 +412,34 @@ void shell(int i, bool morecheck);
void glasspieces(int i);
void scrap(int i, int SCRAP1, int SCRAP6);
void handle_se00(int i, int LASERLINE);
void handle_se01(int i);
void handle_se14(int i, bool checkstat, int RPG, int JIBS6);
void handle_se30(int i, int JIBS6);
void handle_se02(int i);
void handle_se03(int i);
void handle_se04(int i);
void handle_se05(int i, int FIRELASER);
void handle_se08(int i, bool checkhitag1);
void handle_se10(int i, const int *);
void handle_se11(int i);
void handle_se12(int i, int planeonly = 0);
void handle_se13(int i);
void handle_se15(int i);
void handle_se16(int i, int REACTOR, int REACTOR2);
void handle_se17(int i);
void handle_se18(int i, bool morecheck);
void handle_se19(int i, int BIGFORCE);
void handle_se20(int i);
void handle_se21(int i);
void handle_se22(int i);
void handle_se26(int i);
void handle_se27(int i);
void handle_se32(int i);
void handle_se35(int i, int SMALLSMOKE, int EXPLOSION2);
void handle_se128(int i);
void handle_se130(int i, int countmax, int EXPLOSION2);
void respawn_rrra(int i, int j);
void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4);

View file

@ -892,7 +892,7 @@ void movefallers_d(void)
if (s->extra <= 0)
{
hittype[i].temp_data[0] = 1;
j = headspritestat[12];
j = headspritestat[STAT_FALLER];
while (j >= 0)
{
if (sprite[j].hitag == sprite[i].hitag)
@ -1008,7 +1008,7 @@ static void movetripbomb(int i)
sprite[j].xvel = 348;
ssp(j, CLIPMASK0);
j = headspritestat[5];
j = headspritestat[STAT_MISC];
while (j >= 0)
{
if (sprite[j].picnum == LASERLINE && s->hitag == sprite[j].hitag)
@ -1181,7 +1181,7 @@ static void movefireext(int i)
if (s->hitag > 0)
{
j = headspritestat[6];
j = headspritestat[STAT_STANDABLE];
while (j >= 0)
{
if (s->hitag == sprite[j].hitag && (sprite[j].picnum == OOZFILTER || sprite[j].picnum == SEENINE))
@ -1221,7 +1221,7 @@ static void moveviewscreen(int i)
if (x < 2048)
{
#if 0
if (SP == 1)
if (sprite[i].yvel == 1)
camsprite = i;
#endif
}
@ -2381,7 +2381,7 @@ static void greenslime(int i)
updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum);
setpal(&ps[p]);
j = headspritestat[1];
j = headspritestat[STAT_ACTOR];
while (j >= 0)
{
if (sprite[j].picnum == CAMERA1) sprite[j].yvel = 0;
@ -2532,7 +2532,7 @@ static void greenslime(int i)
case LIZMAN:
case PIGCOP:
case NEWBEAST:
if (ldist(s, &sprite[j]) < 768 && (klabs(s->z - sprite[j].z) < 8192)) //Gulp them
if (ldist(s, &sprite[j]) < 768 && (abs(s->z - sprite[j].z) < 8192)) //Gulp them
{
t[5] = j;
t[0] = -2;
@ -2593,7 +2593,7 @@ static void greenslime(int i)
s->yrepeat = 16 + (sintable[t[1] & 2047] >> 13);
if (rnd(4) && (sector[sect].ceilingstat & 1) == 0 &&
klabs(hittype[i].floorz - hittype[i].ceilingz)
abs(hittype[i].floorz - hittype[i].ceilingz)
< (192 << 8))
{
s->zvel = 0;
@ -2978,7 +2978,7 @@ void moveactors_d(void)
unsigned short k;
int nexti;
for (int i = headspritestat[1]; i >= 0; i = nexti)
for (int i = headspritestat[STAT_ACTOR]; i >= 0; i = nexti)
{
nexti = nextspritestat[i];
@ -3025,7 +3025,7 @@ void moveactors_d(void)
s->cstat = 32 + 128;
k = 1;
j = headspritestat[1];
j = headspritestat[STAT_ACTOR];
while (j >= 0)
{
if (sprite[j].lotag == s->lotag &&
@ -3340,5 +3340,566 @@ void moveexplosions_d(void) // STATNUM 5
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void moveeffectors_d(void) //STATNUM 3
{
int q = 0, l, x, st, j, * t;
int nexti, p, sh, nextj;
short k;
spritetype* s;
sectortype* sc;
walltype* wal;
clearfriction();
for (int i = headspritestat[STAT_EFFECTOR]; i >= 0; i = nexti)
{
nexti = nextspritestat[i];
s = &sprite[i];
sc = &sector[s->sectnum];
st = s->lotag;
sh = s->hitag;
t = &hittype[i].temp_data[0];
switch (st)
{
case SE_0_ROTATING_SECTOR:
handle_se00(i, LASERLINE);
break;
case SE_1_PIVOT: //Nothing for now used as the pivot
handle_se01(i);
break;
case SE_6_SUBWAY:
k = sc->extra;
if (t[4] > 0)
{
t[4]--;
if (t[4] >= (k - (k >> 3)))
s->xvel -= (k >> 5);
if (t[4] > ((k >> 1) - 1) && t[4] < (k - (k >> 3)))
s->xvel = 0;
if (t[4] < (k >> 1))
s->xvel += (k >> 5);
if (t[4] < ((k >> 1) - (k >> 3)))
{
t[4] = 0;
s->xvel = k;
}
}
else s->xvel = k;
j = headspritestat[STAT_EFFECTOR];
while (j >= 0)
{
if ((sprite[j].lotag == 14) && (sh == sprite[j].hitag) && (hittype[j].temp_data[0] == t[0]))
{
sprite[j].xvel = s->xvel;
// if( t[4] == 1 )
{
if (hittype[j].temp_data[5] == 0)
hittype[j].temp_data[5] = dist(&sprite[j], s);
x = sgn(dist(&sprite[j], s) - hittype[j].temp_data[5]);
if (sprite[j].extra)
x = -x;
s->xvel += x;
}
hittype[j].temp_data[4] = t[4];
}
j = nextspritestat[j];
}
x = 0;
case SE_14_SUBWAY_CAR:
handle_se14(i, true, RPG, JIBS6);
break;
case SE_30_TWO_WAY_TRAIN:
handle_se30(i, JIBS6);
break;
case SE_2_EARTHQUAKE:
handle_se02(i);
break;
//Flashing sector lights after reactor EXPLOSION2
case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT:
handle_se03(i);
break;
case SE_4_RANDOM_LIGHTS:
handle_se04(i);
break;
//BOSS
case SE_5_BOSS:
handle_se05(i, FIRELASER);
break;
case SE_8_UP_OPEN_DOOR_LIGHTS:
case SE_9_DOWN_OPEN_DOOR_LIGHTS:
handle_se08(i, false);
break;
case SE_10_DOOR_AUTO_CLOSE:
{
static const int tags[] = { 20, 21, 22, 26, 0};
handle_se10(i, tags);
break;
}
case SE_11_SWINGING_DOOR:
handle_se11(i);
break;
case SE_12_LIGHT_SWITCH:
handle_se12(i);
break;
case SE_13_EXPLOSIVE:
handle_se13(i);
break;
case SE_15_SLIDING_DOOR:
handle_se15(i);
break;
case SE_16_REACTOR:
handle_se16(i, REACTOR, REACTOR2);
break;
case SE_17_WARP_ELEVATOR:
handle_se17(i);
break;
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
handle_se18(i, true);
break;
case SE_19_EXPLOSION_LOWERS_CEILING:
handle_se19(i, BIGFORCE);
break;
case SE_20_STRETCH_BRIDGE:
handle_se20(i);
break;
case SE_21_DROP_FLOOR:
handle_se21(i);
break;
case SE_22_TEETH_DOOR:
handle_se22(i);
break;
case SE_24_CONVEYOR:
case 34:
if (t[4]) break;
x = (sprite[i].yvel * sintable[(s->ang + 512) & 2047]) >> 18;
l = (sprite[i].yvel * sintable[s->ang & 2047]) >> 18;
k = 0;
j = headspritesect[s->sectnum];
while (j >= 0)
{
nextj = nextspritesect[j];
if (sprite[j].zvel >= 0)
switch (sprite[j].statnum)
{
case 5:
switch (sprite[j].picnum)
{
case BLOODPOOL:
case PUKE:
case FOOTPRINTS:
case FOOTPRINTS2:
case FOOTPRINTS3:
case FOOTPRINTS4:
case BULLETHOLE:
case BLOODSPLAT1:
case BLOODSPLAT2:
case BLOODSPLAT3:
case BLOODSPLAT4:
sprite[j].xrepeat = sprite[j].yrepeat = 0;
j = nextj;
continue;
case LASERLINE:
j = nextj;
continue;
}
case 6:
if (sprite[j].picnum == TRIPBOMB) break;
case 1:
case 0:
if (
sprite[j].picnum == BOLT1 ||
sprite[j].picnum == BOLT1 + 1 ||
sprite[j].picnum == BOLT1 + 2 ||
sprite[j].picnum == BOLT1 + 3 ||
sprite[j].picnum == SIDEBOLT1 ||
sprite[j].picnum == SIDEBOLT1 + 1 ||
sprite[j].picnum == SIDEBOLT1 + 2 ||
sprite[j].picnum == SIDEBOLT1 + 3 ||
wallswitchcheck(j)
)
break;
if (!(sprite[j].picnum >= CRANE && sprite[j].picnum <= (CRANE + 3)))
{
if (sprite[j].z > (hittype[j].floorz - (16 << 8)))
{
hittype[j].bposx = sprite[j].x;
hittype[j].bposy = sprite[j].y;
sprite[j].x += x >> 2;
sprite[j].y += l >> 2;
setsprite(j, sprite[j].x, sprite[j].y, sprite[j].z);
if (sector[sprite[j].sectnum].floorstat & 2)
if (sprite[j].statnum == 2)
makeitfall(j);
}
}
break;
}
j = nextj;
}
for (p = connecthead; p >= 0; p = connectpoint2[p])
{
if (ps[p].cursectnum == s->sectnum && ps[p].on_ground)
{
if (abs(ps[p].pos.z - ps[p].truefz) < PHEIGHT + (9 << 8))
{
ps[p].fric.x += x << 3;
ps[p].fric.y += l << 3;
}
}
}
sc->floorxpanning += sprite[i].yvel >> 7;
break;
case 35:
handle_se35(i, SMALLSMOKE, EXPLOSION2);
break;
case 25: //PISTONS
if (t[4] == 0) break;
if (sc->floorz <= sc->ceilingz)
s->shade = 0;
else if (sc->ceilingz <= t[3])
s->shade = 1;
if (s->shade)
{
sc->ceilingz += sprite[i].yvel << 4;
if (sc->ceilingz > sc->floorz)
sc->ceilingz = sc->floorz;
}
else
{
sc->ceilingz -= sprite[i].yvel << 4;
if (sc->ceilingz < t[3])
sc->ceilingz = t[3];
}
break;
case 26:
handle_se26(i);
break;
case SE_27_DEMO_CAM:
handle_se27(i);
break;
case 28:
if (t[5] > 0)
{
t[5]--;
break;
}
if (hittype[i].temp_data[0] == 0)
{
p = findplayer(s, &x);
if (x > 15500)
break;
hittype[i].temp_data[0] = 1;
hittype[i].temp_data[1] = 64 + (krand() & 511);
hittype[i].temp_data[2] = 0;
}
else
{
hittype[i].temp_data[2]++;
if (hittype[i].temp_data[2] > hittype[i].temp_data[1])
{
hittype[i].temp_data[0] = 0;
ps[screenpeek].visibility = ud.const_visibility;
break;
}
else if (hittype[i].temp_data[2] == (hittype[i].temp_data[1] >> 1))
spritesound(THUNDER, i);
else if (hittype[i].temp_data[2] == (hittype[i].temp_data[1] >> 3))
spritesound(LIGHTNING_SLAP, i);
else if (hittype[i].temp_data[2] == (hittype[i].temp_data[1] >> 2))
{
j = headspritestat[0];
while (j >= 0)
{
if (sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == s->hitag)
sprite[j].cstat |= 32768;
j = nextspritestat[j];
}
}
else if (hittype[i].temp_data[2] > (hittype[i].temp_data[1] >> 3) && hittype[i].temp_data[2] < (hittype[i].temp_data[1] >> 2))
{
if (cansee(s->x, s->y, s->z, s->sectnum, ps[screenpeek].posx, ps[screenpeek].posy, ps[screenpeek].posz, ps[screenpeek].cursectnum))
j = 1;
else j = 0;
if (rnd(192) && (hittype[i].temp_data[2] & 1))
{
if (j)
ps[screenpeek].visibility = 0;
}
else if (j)
ps[screenpeek].visibility = ud.const_visibility;
j = headspritestat[0];
while (j >= 0)
{
if (sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == s->hitag)
{
if (rnd(32) && (hittype[i].temp_data[2] & 1))
{
sprite[j].cstat &= 32767;
spawn(j, SMALLSMOKE);
p = findplayer(s, &x);
x = ldist(&sprite[ps[p].i], &sprite[j]);
if (x < 768)
{
if (S_CheckSoundPlaying(DUKE_LONGTERM_PAIN) < 1)
spritesound(DUKE_LONGTERM_PAIN, ps[p].i);
spritesound(SHORT_CIRCUIT, ps[p].i);
sprite[ps[p].i].extra -= 8 + (krand() & 7);
SetPlayerPal(&ps[p], PalEntry(32, 16, 0, 0));
}
break;
}
else sprite[j].cstat |= 32768;
}
j = nextspritestat[j];
}
}
}
break;
case 29:
s->hitag += 64;
l = mulscale12((int)s->yvel, sintable[s->hitag & 2047]);
sc->floorz = s->z + l;
break;
case 31: // True Drop Floor
if (t[0] == 1)
{
// Choose dir
if (t[3] > 0)
{
t[3]--;
break;
}
if (t[2] == 1) // Retract
{
if (sprite[i].ang != 1536)
{
if (abs(sc->floorz - s->z) < sprite[i].yvel )
{
sc->floorz = s->z;
t[2] = 0;
t[0] = 0;
t[3] = s->hitag;
callsound(s->sectnum, i);
}
else
{
l = sgn(s->z - sc->floorz) * sprite[i].yvel ;
sc->floorz += l;
j = headspritesect[s->sectnum];
while (j >= 0)
{
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (ps[sprite[j].yvel].on_ground == 1)
ps[sprite[j].yvel].posz += l;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4)
{
hittype[j].bposz = sprite[j].z += l;
hittype[j].floorz = sc->floorz;
}
j = nextspritesect[j];
}
}
}
else
{
if (abs(sc->floorz - t[1]) < sprite[i].yvel )
{
sc->floorz = t[1];
callsound(s->sectnum, i);
t[2] = 0;
t[0] = 0;
t[3] = s->hitag;
}
else
{
l = sgn(t[1] - sc->floorz) * sprite[i].yvel ;
sc->floorz += l;
j = headspritesect[s->sectnum];
while (j >= 0)
{
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (ps[sprite[j].yvel].on_ground == 1)
ps[sprite[j].yvel].posz += l;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4)
{
hittype[j].bposz = sprite[j].z += l;
hittype[j].floorz = sc->floorz;
}
j = nextspritesect[j];
}
}
}
break;
}
if ((s->ang & 2047) == 1536)
{
if (abs(s->z - sc->floorz) < sprite[i].yvel )
{
callsound(s->sectnum, i);
t[0] = 0;
t[2] = 1;
t[3] = s->hitag;
}
else
{
l = sgn(s->z - sc->floorz) * sprite[i].yvel ;
sc->floorz += l;
j = headspritesect[s->sectnum];
while (j >= 0)
{
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (ps[sprite[j].yvel].on_ground == 1)
ps[sprite[j].yvel].posz += l;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4)
{
hittype[j].bposz = sprite[j].z += l;
hittype[j].floorz = sc->floorz;
}
j = nextspritesect[j];
}
}
}
else
{
if (abs(sc->floorz - t[1]) < sprite[i].yvel )
{
t[0] = 0;
callsound(s->sectnum, i);
t[2] = 1;
t[3] = s->hitag;
}
else
{
l = sgn(s->z - t[1]) * sprite[i].yvel ;
sc->floorz -= l;
j = headspritesect[s->sectnum];
while (j >= 0)
{
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (ps[sprite[j].yvel].on_ground == 1)
ps[sprite[j].yvel].posz -= l;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4)
{
hittype[j].bposz = sprite[j].z -= l;
hittype[j].floorz = sc->floorz;
}
j = nextspritesect[j];
}
}
}
}
break;
case 32: // True Drop Ceiling
handle_se32(i);
break;
case 33:
if (earthquaketime > 0 && (krand() & 7) == 0)
RANDOMSCRAP(s, i);
break;
case 36:
if (t[0])
{
if (t[0] == 1)
shoot(i, sc->extra);
else if (t[0] == 26 * 5)
t[0] = 0;
t[0]++;
}
break;
case 128: //SE to control glass breakage
handle_se128(i);
break;
case 130:
handle_se130(i, 80, EXPLOSION2);
break;
case 131:
handle_se130(i, 40, EXPLOSION2);
break;
}
}
//Sloped sin-wave floors!
for (int i = headspritestat[STAT_EFFECTOR]; i >= 0; i = nextspritestat[i])
{
s = &sprite[i];
if (s->lotag != 29) continue;
sc = &sector[s->sectnum];
if (sc->wallnum != 4) continue;
wal = &wall[sc->wallptr + 2];
alignflorslope(s->sectnum, wal->x, wal->y, sector[wal->nextsector].floorz);
}
}
END_DUKE_NS

View file

@ -850,7 +850,7 @@ void movefallers_r(void)
if (s->extra <= 0)
{
hittype[i].temp_data[0] = 1;
j = headspritestat[12];
j = headspritestat[STAT_FALLER];
while (j >= 0)
{
if (sprite[j].hitag == sprite[i].hitag)
@ -1661,7 +1661,7 @@ void movetransports_r(void)
{
char warpdir, warpspriteto;
short i, j, k, p, sect, sectlotag, nexti, nextj;
long ll2, ll, onfloorz;
int ll2, ll, onfloorz;
i = headspritestat[STAT_TRANSPORT]; //Transporters
@ -2469,7 +2469,7 @@ void rr_specialstats()
sprite[i].z = sector[sprite[i].sectnum].floorz - 15168;
sprite[i].extra = 0;
sprite[i].picnum = RRTILE3410;
j = headspritestat[0];
j = headspritestat[STAT_DEFAULT];
while (j >= 0)
{
nextj = nextspritestat[j];
@ -2991,7 +2991,7 @@ void moveactors_r(void)
}
rr_specialstats();
for (int i = headspritestat[1]; i >= 0; i = nexti)
for (int i = headspritestat[STAT_ACTOR]; i >= 0; i = nexti)
{
nexti = nextspritestat[i];
bool deleteafterexecute = false; // taking a cue here from RedNukem to not run scripts on deleted sprites.
@ -3493,5 +3493,537 @@ void moveexplosions_r(void) // STATNUM 5
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void moveeffectors_r(void) //STATNUM 3
{
int l, x, st, j, * t;
int nexti, p, sh, nextj, ns, pn;
short k;
spritetype* s;
sectortype* sc;
walltype* wal;
clearfriction();
for (int i = headspritestat[STAT_EFFECTOR]; i >= 0; i = nexti)
{
nexti = nextspritestat[i];
s = &sprite[i];
sc = &sector[s->sectnum];
st = s->lotag;
sh = s->hitag;
t = &hittype[i].temp_data[0];
switch (st)
{
case SE_0_ROTATING_SECTOR:
handle_se00(i, -1);
break;
case SE_1_PIVOT: //Nothing for now used as the pivot
handle_se01(i);
break;
case SE_6_SUBWAY:
k = sc->extra;
if (t[4] > 0)
{
t[4]--;
if (t[4] >= (k - (k >> 3)))
s->xvel -= (k >> 5);
if (t[4] > ((k >> 1) - 1) && t[4] < (k - (k >> 3)))
s->xvel = 0;
if (t[4] < (k >> 1))
s->xvel += (k >> 5);
if (t[4] < ((k >> 1) - (k >> 3)))
{
t[4] = 0;
s->xvel = k;
if ((!isRRRA() || lastlevel) && hulkspawn)
{
hulkspawn--;
ns = spawn(i, HULK);
sprite[ns].z = sector[sprite[ns].sectnum].ceilingz;
sprite[ns].pal = 33;
if (!hulkspawn)
{
ns = EGS(s->sectnum, s->x, s->y, sector[s->sectnum].ceilingz + 119428, 3677, -8, 16, 16, 0, 0, 0, i, 5);
sprite[ns].cstat = 514;
sprite[ns].pal = 7;
sprite[ns].xrepeat = 80;
sprite[ns].yrepeat = 255;
ns = spawn(i, 296);
sprite[ns].cstat = 0;
sprite[ns].cstat |= 32768;
sprite[ns].z = sector[s->sectnum].floorz - 6144;
deletesprite(i);
break;
}
}
}
}
else
{
s->xvel = k;
j = headspritesect[s->sectnum];
while (j >= 0)
{
nextj = nextspritesect[j];
if (sprite[j].picnum == UFOBEAM)
if (ufospawn)
if (++ufocnt == 64)
{
ufocnt = 0;
ufospawn--;
if (!isRRRA())
{
switch (krand() & 3)
{
default:
case 0:
pn = UFO1_RR;
break;
case 1:
pn = UFO2;
break;
case 2:
pn = UFO3;
break;
case 3:
pn = UFO4;
break;
}
}
else pn = UFO1_RRRA;
ns = spawn(i, pn);
sprite[ns].z = sector[sprite[ns].sectnum].ceilingz;
}
j = nextj;
}
}
j = headspritestat[STAT_EFFECTOR];
while (j >= 0)
{
if ((sprite[j].lotag == 14) && (sh == sprite[j].hitag) && (hittype[j].temp_data[0] == t[0]))
{
sprite[j].xvel = s->xvel;
// if( t[4] == 1 )
{
if (hittype[j].temp_data[5] == 0)
hittype[j].temp_data[5] = dist(&sprite[j], s);
x = sgn(dist(&sprite[j], s) - hittype[j].temp_data[5]);
if (sprite[j].extra)
x = -x;
s->xvel += x;
}
hittype[j].temp_data[4] = t[4];
}
j = nextspritestat[j];
}
x = 0;
case SE_14_SUBWAY_CAR:
handle_se14(i, false, RPG, JIBS6);
break;
case SE_30_TWO_WAY_TRAIN:
handle_se30(i, JIBS6);
break;
case SE_2_EARTHQUAKE:
handle_se02(i);
break;
//Flashing sector lights after reactor EXPLOSION2
case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT:
handle_se03(i);
break;
case SE_4_RANDOM_LIGHTS:
handle_se04(i);
break;
//BOSS
case SE_5_BOSS:
handle_se05(i, FIRELASER);
break;
case SE_8_UP_OPEN_DOOR_LIGHTS:
case SE_9_DOWN_OPEN_DOOR_LIGHTS:
handle_se08(i, true);
break;
case SE_10_DOOR_AUTO_CLOSE:
handle_se10(i, nullptr);
break;
case SE_11_SWINGING_DOOR:
handle_se11(i);
break;
case SE_12_LIGHT_SWITCH:
handle_se12(i);
break;
case SE_47_LIGHT_SWITCH:
if (isRRRA()) handle_se12(i, 1);
break;
case SE_48_LIGHT_SWITCH:
if (isRRRA()) handle_se12(i, 2);
break;
case SE_13_EXPLOSIVE:
handle_se13(i);
break;
case SE_15_SLIDING_DOOR:
handle_se15(i);
break;
case SE_16_REACTOR:
handle_se16(i, REACTOR, REACTOR2);
break;
case SE_17_WARP_ELEVATOR:
handle_se17(i);
break;
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
handle_se18(i, true);
break;
case SE_19_EXPLOSION_LOWERS_CEILING:
handle_se19(i, BIGFORCE);
break;
case SE_20_STRETCH_BRIDGE:
handle_se20(i);
break;
case SE_21_DROP_FLOOR:
handle_se21(i);
break;
case SE_22_TEETH_DOOR:
handle_se22(i);
break;
case 156:
if (!isRRRA()) break;
case SE_24_CONVEYOR:
case 34:
if (t[4]) break;
x = (sprite[i].yvel * sintable[(s->ang + 512) & 2047]) >> 18;
l = (sprite[i].yvel * sintable[s->ang & 2047]) >> 18;
k = 0;
j = headspritesect[s->sectnum];
while (j >= 0)
{
nextj = nextspritesect[j];
if (sprite[j].zvel >= 0)
switch (sprite[j].statnum)
{
case 5:
switch (sprite[j].picnum)
{
case BLOODPOOL:
case FOOTPRINTS:
case FOOTPRINTS2:
case FOOTPRINTS3:
sprite[j].xrepeat = sprite[j].yrepeat = 0;
k = 1;
break;
case BULLETHOLE:
j = nextj;
continue;
}
case 6:
case 1:
case 0:
if (
sprite[j].picnum == BOLT1 ||
sprite[j].picnum == BOLT1 + 1 ||
sprite[j].picnum == BOLT1 + 2 ||
sprite[j].picnum == BOLT1 + 3 ||
wallswitchcheck(j)
)
break;
if (!(sprite[j].picnum >= CRANE && sprite[j].picnum <= (CRANE + 3)))
{
if (sprite[j].z > (hittype[j].floorz - (16 << 8)))
{
hittype[j].bposx = sprite[j].x;
hittype[j].bposy = sprite[j].y;
sprite[j].x += x >> 1;
sprite[j].y += l >> 1;
setsprite(j, sprite[j].x, sprite[j].y, sprite[j].z);
if (sector[sprite[j].sectnum].floorstat & 2)
if (sprite[j].statnum == 2)
makeitfall(j);
}
}
break;
}
j = nextj;
}
for (p = connecthead; p >= 0; p = connectpoint2[p])
{
if (ps[p].cursectnum == s->sectnum && ps[p].on_ground)
{
if (abs(ps[p].pos.z - ps[p].truefz) < PHEIGHT + (9 << 8))
{
ps[p].fric.x += x << 3;
ps[p].fric.y += l << 3;
}
}
}
sc->floorxpanning += sprite[i].yvel >> 7;
break;
case 35:
handle_se35(i, SMALLSMOKE, EXPLOSION2);
break;
case 25: //PISTONS
if (t[4] == 0) break;
if (sc->floorz <= sc->ceilingz)
s->shade = 0;
else if (sc->ceilingz <= t[4])
s->shade = 1;
if (s->shade)
{
sc->ceilingz += sprite[i].yvel << 4;
if (sc->ceilingz > sc->floorz)
{
sc->ceilingz = sc->floorz;
if (isRRRA() && pistonsound)
spritesound(371, i);
}
}
else
{
sc->ceilingz -= sprite[i].yvel << 4;
if (sc->ceilingz < t[4])
{
sc->ceilingz = t[4];
if (isRRRA() && pistonsound)
spritesound(167, i);
}
}
break;
case 26:
handle_se26(i);
break;
case SE_27_DEMO_CAM:
handle_se27(i);
break;
case 29:
s->hitag += 64;
l = mulscale12((int)s->yvel, sintable[s->hitag & 2047]);
sc->floorz = s->z + l;
break;
case 31: // True Drop Floor
if (t[0] == 1)
{
if (t[2] == 1) // Retract
{
if (sprite[i].ang != 1536)
{
if (abs(sc->floorz - s->z) < sprite[i].yvel )
{
sc->floorz = s->z;
t[2] = 0;
t[0] = 0;
callsound(s->sectnum, i);
}
else
{
l = sgn(s->z - sc->floorz) * sprite[i].yvel ;
sc->floorz += l;
j = headspritesect[s->sectnum];
while (j >= 0)
{
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (ps[sprite[j].yvel].on_ground == 1)
ps[sprite[j].yvel].posz += l;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3)
{
hittype[j].bposz = sprite[j].z += l;
hittype[j].floorz = sc->floorz;
}
j = nextspritesect[j];
}
}
}
else
{
if (abs(sc->floorz - t[1]) < sprite[i].yvel )
{
sc->floorz = t[1];
callsound(s->sectnum, i);
t[2] = 0;
t[0] = 0;
}
else
{
l = sgn(t[1] - sc->floorz) * sprite[i].yvel ;
sc->floorz += l;
j = headspritesect[s->sectnum];
while (j >= 0)
{
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (ps[sprite[j].yvel].on_ground == 1)
ps[sprite[j].yvel].posz += l;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3)
{
hittype[j].bposz = sprite[j].z += l;
hittype[j].floorz = sc->floorz;
}
j = nextspritesect[j];
}
}
}
break;
}
if ((s->ang & 2047) == 1536)
{
if (abs(s->z - sc->floorz) < sprite[i].yvel )
{
callsound(s->sectnum, i);
t[0] = 0;
t[2] = 1;
}
else
{
l = sgn(s->z - sc->floorz) * sprite[i].yvel ;
sc->floorz += l;
j = headspritesect[s->sectnum];
while (j >= 0)
{
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (ps[sprite[j].yvel].on_ground == 1)
ps[sprite[j].yvel].posz += l;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3)
{
hittype[j].bposz = sprite[j].z += l;
hittype[j].floorz = sc->floorz;
}
j = nextspritesect[j];
}
}
}
else
{
if (abs(sc->floorz - t[1]) < sprite[i].yvel )
{
t[0] = 0;
callsound(s->sectnum, i);
t[2] = 1;
}
else
{
l = sgn(s->z - t[1]) * sprite[i].yvel ;
sc->floorz -= l;
j = headspritesect[s->sectnum];
while (j >= 0)
{
if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0)
if (ps[sprite[j].yvel].on_ground == 1)
ps[sprite[j].yvel].posz -= l;
if (sprite[j].zvel == 0 && sprite[j].statnum != 3)
{
hittype[j].bposz = sprite[j].z -= l;
hittype[j].floorz = sc->floorz;
}
j = nextspritesect[j];
}
}
}
}
break;
case 32: // True Drop Ceiling
handle_se32(i);
break;
case 33:
if (earthquaketime > 0 && (krand() & 7) == 0)
RANDOMSCRAP(s, i);
break;
case 36:
if (t[0])
{
if (t[0] == 1)
shoot(i, sc->extra);
else if (t[0] == 26 * 5)
t[0] = 0;
t[0]++;
}
break;
case 128: //SE to control glass breakage
handle_se128(i);
break;
case 130:
handle_se130(i, 80, EXPLOSION2);
break;
case 131:
handle_se130(i, 40, EXPLOSION2);
break;
}
}
//Sloped sin-wave floors!
for (int i = headspritestat[STAT_EFFECTOR]; i >= 0; i = nextspritestat[i])
{
s = &sprite[i];
if (s->lotag != 29) continue;
sc = &sector[s->sectnum];
if (sc->wallnum != 4) continue;
wal = &wall[sc->wallptr + 2];
alignflorslope(s->sectnum, wal->x, wal->y, sector[wal->nextsector].floorz);
}
}
END_DUKE_NS

File diff suppressed because it is too large Load diff

View file

@ -1688,7 +1688,7 @@ default_case:
if (!RRRA) goto default_case;
pSprite->xrepeat = 0;
pSprite->yrepeat = 0;
g_pistonSound = 1;
pistonsound = 1;
break;
case RRTILE8165__STATICRR:
if (!RRRA) goto default_case;
@ -4009,7 +4009,7 @@ rr_badguy:
fallthrough__;
case SE_0_ROTATING_SECTOR:
case SE_2_EARTHQUAKE: // Earthquakemakers
case SE_5: // Boss Creature
case SE_5_BOSS: // Boss Creature
case SE_6_SUBWAY: // Subway
case SE_14_SUBWAY_CAR: // Caboos
case SE_15_SLIDING_DOOR: // Subwaytype sliding door
@ -4070,7 +4070,7 @@ rr_badguy:
}
}
if (pSprite->lotag == SE_5 || pSprite->lotag == SE_30_TWO_WAY_TRAIN ||
if (pSprite->lotag == SE_5_BOSS || pSprite->lotag == SE_30_TWO_WAY_TRAIN ||
pSprite->lotag == SE_6_SUBWAY || pSprite->lotag == SE_14_SUBWAY_CAR)
{
#ifdef YAX_ENABLE
@ -4176,7 +4176,7 @@ rr_badguy:
fallthrough__;
case SE_0_ROTATING_SECTOR:
case SE_1_PIVOT:
case SE_5:
case SE_5_BOSS:
case SE_11_SWINGING_DOOR:
case SE_15_SLIDING_DOOR:
case SE_16_REACTOR:

View file

@ -339,7 +339,7 @@ enum
SE_2_EARTHQUAKE = 2,
SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT = 3,
SE_4_RANDOM_LIGHTS = 4,
SE_5 = 5,
SE_5_BOSS = 5,
SE_6_SUBWAY = 6,
// ^^ potentially incomplete substitution in code
// vv almost surely complete substitution
@ -373,6 +373,8 @@ enum
SE_34 = 34, // XXX
SE_35 = 35, // XXX
SE_36_PROJ_SHOOTER = 36,
SE_47_LIGHT_SWITCH = 47,
SE_48_LIGHT_SWITCH = 48,
SE_49_POINT_LIGHT = 49,
SE_50_SPOT_LIGHT = 50,
SE_130 = 130,

View file

@ -162,10 +162,14 @@ G_EXTERN int32_t g_chickenPlant;
#define chickenplant g_chickenPlant
G_EXTERN int32_t g_thunderOn;
G_EXTERN int32_t g_ufoSpawn;
#define ufospawn g_ufoSpawn
G_EXTERN int32_t g_ufoCnt;
#define ufocnt g_ufoCnt
G_EXTERN int32_t g_hulkSpawn;
#define hulkspawn g_hulkSpawn
G_EXTERN int32_t g_vixenLevel;
G_EXTERN int32_t g_lastLevel;
#define lastlevel g_lastLevel
G_EXTERN int32_t g_turdLevel;
@ -207,7 +211,7 @@ G_EXTERN msy_ msy;
G_EXTERN int32_t g_windTime, g_windDir;
G_EXTERN int16_t g_fakeBubbaCnt, g_mamaSpawnCnt, g_banjoSong, g_bellTime, g_bellSprite;
G_EXTERN uint8_t g_spriteExtra[MAXSPRITES], g_sectorExtra[MAXSECTORS];
G_EXTERN uint8_t enemysizecheat, ufospawnsminion, g_pistonSound, g_chickenWeaponTimer, g_RAendLevel, g_RAendEpisode, g_fogType;
G_EXTERN uint8_t enemysizecheat, ufospawnsminion, pistonsound, g_chickenWeaponTimer, g_RAendLevel, g_RAendEpisode, g_fogType;
G_EXTERN int32_t g_cdTrack;
#define raat607 enemysizecheat // only as a reminder
@ -223,6 +227,7 @@ playerdata_t *const g_player = &g_player_s[1];
extern playerdata_t *const g_player;
#endif
G_EXTERN playerspawn_t g_playerSpawnPoints[MAXPLAYERS];
#define po g_playerSpawnPoints
G_EXTERN input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS];
#pragma pack(pop)
@ -271,7 +276,16 @@ extern int16_t g_blimpSpawnItems[15];
extern int32_t g_gametypeFlags[MAXGAMETYPES];
extern const char *s_buildDate;
#endif
#endif
inline void clearfriction()
{
for (int playerNum = 0; playerNum != -1; playerNum = connectpoint2[playerNum])
{
vec2_t& fric = g_player[playerNum].ps->fric;
fric.x = fric.y = 0;
}
}
enum
{

View file

@ -107,8 +107,17 @@ enum playeraction_t {
};
typedef struct {
vec3_t pos;
int16_t ang, sect;
union
{
vec3_t pos;
struct { int ox, oy, oz; };
};
int16_t ang;
union
{
int16_t sect;
int16_t os;
};
} playerspawn_t;
typedef struct {
@ -166,6 +175,7 @@ typedef struct player_struct {
int getang() { return q16ang >> FRACBITS; }
int getoang() { return oq16ang >> FRACBITS; }
void setang(int v) { q16ang = v << FRACBITS; }
void addang(int v) { q16ang = (q16ang + (v << FRACBITS)) & ((2048 << FRACBITS)-1); }
void setoang(int v) { oq16ang = v << FRACBITS; }
void addhoriz(int v) { q16horiz += (v << FRACBITS); }
int gethoriz() { return q16horiz >> FRACBITS; }

View file

@ -1276,7 +1276,7 @@ static void prelevel(char g)
G_SetFog(0);
g_fogType = 0;
ufospawnsminion = 0;
g_pistonSound = 0;
pistonsound = 0;
enemysizecheat = 0;
g_player[myconnectindex].ps->level_end_timer = 0;
g_mamaSpawnCnt = 15;

View file

@ -117,7 +117,7 @@ void G_ResetInterpolations(void)
G_SetInterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case SE_0_ROTATING_SECTOR:
case SE_5:
case SE_5_BOSS:
case SE_6_SUBWAY:
case SE_11_SWINGING_DOOR:
case SE_14_SUBWAY_CAR:
@ -931,7 +931,7 @@ static const dataspec_t svgm_anmisc[] =
{ 0, &enemysizecheat, sizeof(enemysizecheat), 1 },
{ 0, &ufospawnsminion, sizeof(ufospawnsminion), 1 },
{ 0, &g_pistonSound, sizeof(g_pistonSound), 1 },
{ 0, &pistonsound, sizeof(pistonsound), 1 },
{ 0, &g_chickenWeaponTimer, sizeof(g_chickenWeaponTimer), 1 },
{ 0, &g_RAendLevel, sizeof(g_RAendLevel), 1 },
{ 0, &g_RAendEpisode, sizeof(g_RAendEpisode), 1 },

View file

@ -3860,7 +3860,7 @@ CHECKINV1:
if (weaponNum == HANDBOMB_WEAPON && pPlayer->ammo_amount[HANDBOMB_WEAPON] == 0)
{
int spriteNum = headspritestat[1];
int spriteNum = headspritestat[STAT_ACTOR];
while (spriteNum >= 0)
{
if (sprite[spriteNum].picnum == TILE_HEAVYHBOMB && sprite[spriteNum].owner == pPlayer->i)

View file

@ -104,9 +104,17 @@ typedef struct {
void G_ActivateBySector(int sect,int spriteNum);
inline void activatebysector(int s, int sn)
{
G_ActivateBySector(s, sn);
}
int S_FindMusicSFX(int sectNum, int *sndptr);
void A_CallSound2(int soundNum, int playerNum);
int A_CallSound(int sectNum,int spriteNum);
inline int callsound(int s, int sp)
{
return A_CallSound(s, sp);
}
int A_CheckHitSprite(int spriteNum,int16_t *hitSprite);
inline int hitasprite(int s, int16_t* h)
{
@ -134,6 +142,10 @@ int CheckBlockDoorTile(int tileNum);
void G_AnimateCamSprite(int smoothRatio);
void G_AnimateWalls(void);
int G_ActivateWarpElevators(int s,int warpDir);
inline int activatewarpelevators(int s, int w)
{
return G_ActivateWarpElevators(s, w);
}
int G_CheckActivatorMotion(int lotag);
inline int check_activator_motion(int lotag)
{

View file

@ -74,6 +74,10 @@ inline int sound(int num)
}
int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos, int channel = CHAN_AUTO, EChanFlags flags = 0);
void S_StopEnvSound(int sndNum,int sprNum, int flags = -1);
inline void stopsound(int snd)
{
S_StopEnvSound(snd, -1);
}
void S_Update(void);
void S_ChangeSoundPitch(int soundNum, int spriteNum, int pitchoffset);
int S_GetUserFlags(int sndnum);