- safety commit

This commit is contained in:
Christoph Oelckers 2020-05-14 09:07:07 +02:00
parent 15c744f3da
commit e007b9bceb
15 changed files with 1207 additions and 944 deletions

View file

@ -1077,6 +1077,10 @@ inline int32_t setsprite(int16_t spritenum, int x, int y, int z)
return setsprite(spritenum, &v);
}
void setspritepos(int spnum, int x, int y, int z)
{
sprite[spnum].pos = { x,y,z };
}
int32_t setspritez(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2)));
int32_t spriteheightofsptr(uspriteptr_t spr, int32_t *height, int32_t alsotileyofs);

View file

@ -68,6 +68,8 @@ int ifhitsectors_r(int sectnum);
int ifhitbyweapon_r(int sn);
int ifhitbyweapon_d(int sn);
int adjustfall(spritetype* s, int c);
void fall_d(int g_i, int g_p);
void fall_r(int g_i, int g_p);
bool ceilingspace(int sectnum)
{
@ -137,6 +139,11 @@ int ifhitbyweapon(int sectnum)
return isRR()? ifhitbyweapon_r(sectnum) : ifhitbyweapon_d(sectnum);
}
void fall(int g_i, int g_p)
{
if (isRR()) fall_r(g_i, g_p); else fall_d(g_i, g_p);
}
//---------------------------------------------------------------------------
//
//
@ -5050,6 +5057,98 @@ void alterang(int a, int g_i, int g_p)
}
}
//---------------------------------------------------------------------------
//
// the indirections here are to keep this core function free of game references
//
//---------------------------------------------------------------------------
void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(int, int), void (*falladjustz)(spritetype*))
{
int j;
auto g_sp = &sprite[g_i];
g_sp->xoffset = 0;
g_sp->yoffset = 0;
// if(!gotz)
{
long c;
int sphit = fallspecial? fallspecial(g_i, g_p) : 0;
if (floorspace(g_sp->sectnum))
c = 0;
else
{
if (ceilingspace(g_sp->sectnum) || sector[g_sp->sectnum].lotag == 2)
c = gc / 6;
else c = gc;
}
if (hittype[g_i].cgg <= 0 || (sector[g_sp->sectnum].floorstat & 2))
{
getglobalz(g_i);
hittype[g_i].cgg = 6;
}
else hittype[g_i].cgg--;
if (g_sp->z < (hittype[g_i].floorz - FOURSLEIGHT))
{
g_sp->zvel += c;
g_sp->z += g_sp->zvel;
if (g_sp->zvel > 6144) g_sp->zvel = 6144;
}
else
{
g_sp->z = hittype[g_i].floorz - FOURSLEIGHT;
if (badguy(g_sp) || (g_sp->picnum == APLAYER && g_sp->owner >= 0))
{
if (g_sp->zvel > 3084 && g_sp->extra <= 1)
{
if (g_sp->pal != 1 && g_sp->picnum != DRONE)
{
if (g_sp->picnum == APLAYER && g_sp->extra > 0)
goto SKIPJIBS;
if (sphit)
{
guts(g_sp, JIBS6, 5, g_p);
spritesound(squished, g_i);
}
else
{
guts(g_sp, JIBS6, 15, g_p);
spritesound(squished, g_i);
spawn(g_i, BLOODPOOL);
}
}
SKIPJIBS:
hittype[g_i].picnum = SHOTSPARK1;
hittype[g_i].extra = 1;
g_sp->zvel = 0;
}
else if (g_sp->zvel > 2048 && sector[g_sp->sectnum].lotag != 1)
{
short j = g_sp->sectnum;
int x = g_sp->x, y = g_sp->y, z = g_sp->z;
pushmove(&x, &y, &z, &j, 128, (4 << 8), (4 << 8), CLIPMASK0);
setspritepos(g_i, x, y, z); // wrap this for safety. The renderer may need processing of the new position.
if (j != g_sp->sectnum && j >= 0 && j < MAXSECTORS)
changespritesect(g_i, j);
spritesound(thud, g_i);
}
}
if (sector[g_sp->sectnum].lotag == 1)
falladjustz(g_sp);
else g_sp->zvel = 0;
}
}
}

View file

@ -460,6 +460,8 @@ void lotsofmoney(spritetype* s, short n);
int dodge(spritetype*);
void alterang(int a, int g_i, int g_p);
void fall(int g_i, int g_p);
void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(int, int), void (*falladjustz)(spritetype*));
// tile names which are identical for all games.
enum

View file

@ -4156,4 +4156,29 @@ void move_d(int g_i, int g_p, int g_x)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void falladjustz(spritetype* g_sp)
{
switch (g_sp->picnum)
{
case OCTABRAIN:
case COMMANDER:
case DRONE:
break;
default:
g_sp->z += (24 << 8);
break;
}
}
void fall_d(int g_i, int g_p)
{
fall_common(g_i, g_p, JIBS6, DRONE, BLOODPOOL, SHOTSPARK1, SQUISHED, THUD, nullptr, falladjustz);
}
END_DUKE_NS

View file

@ -2115,10 +2115,10 @@ static void rrra_specialstats()
i = nexti;
}
if (ps[screenpeek].raat609 > 0)
if (ps[screenpeek].MamaEnd > 0)
{
ps[screenpeek].raat609--;
if (ps[screenpeek].raat609 == 0)
ps[screenpeek].MamaEnd--;
if (ps[screenpeek].MamaEnd == 0)
{
ps[screenpeek].gm = MODE_EOL;
ud.eog = 1;
@ -4350,4 +4350,134 @@ void move_r(int g_i, int g_p, int g_x)
}
}
void fakebubbaspawn(int g_i, int g_p)
{
fakebubba_spawn++;
switch (fakebubba_spawn)
{
default:
break;
case 1:
spawn(g_i, PIG);
break;
case 2:
spawn(g_i, MINION);
break;
case 3:
spawn(g_i, CHEER);
break;
case 4:
spawn(g_i, VIXEN);
operateactivators(666, ps[g_p].i);
break;
}
}
//---------------------------------------------------------------------------
//
// special checks in fall that only apply to RR.
//
//---------------------------------------------------------------------------
static int fallspecial(int g_i, int g_p)
{
int sphit = 0;
auto g_sp = &sprite[g_i];
if (isRRRA())
{
if (sector[g_sp->sectnum].lotag == 801)
{
if (g_sp->picnum == ROCK)
{
spawn(g_i, ROCK2);
spawn(g_i, ROCK2);
deletesprite(g_i);
}
return 0;
}
else if (sector[g_sp->sectnum].lotag == 802)
{
if (g_sp->picnum != APLAYER && badguy(g_sp) && g_sp->z == hittype[g_i].floorz - FOURSLEIGHT)
{
guts(g_sp, JIBS6, 5, g_p);
spritesound(SQUISHED, g_i);
deletesprite(g_i);
}
return 0;
}
else if (sector[g_sp->sectnum].lotag == 803)
{
if (g_sp->picnum == ROCK2)
deletesprite(g_i);
return 0;
}
}
if (sector[g_sp->sectnum].lotag == 800)
{
if (g_sp->picnum == 40)
{
deletesprite(g_i);
return 0;
}
if (g_sp->picnum != APLAYER && (badguy(g_sp) || g_sp->picnum == HEN || g_sp->picnum == COW || g_sp->picnum == PIG || g_sp->picnum == DOGRUN || g_sp->picnum == RABBIT) && (!isRRRA() || g_spriteExtra[g_i] < 128))
{
g_sp->z = hittype[g_i].floorz - FOURSLEIGHT;
g_sp->zvel = 8000;
g_sp->extra = 0;
g_spriteExtra[g_i]++;
sphit = 1;
}
else if (g_sp->picnum != APLAYER)
{
if (!g_spriteExtra[g_i])
deletesprite(g_i);
return 0;
}
hittype[g_i].picnum = SHOTSPARK1;
hittype[g_i].extra = 1;
}
else if (isRRRA() && sector[g_sp->sectnum].floorpicnum == RRTILE7820 || sector[g_sp->sectnum].floorpicnum == RRTILE7768)
{
if (g_sp->picnum != MINION && g_sp->pal != 19)
{
if ((krand() & 3) == 1)
{
hittype[g_i].picnum = SHOTSPARK1;
hittype[g_i].extra = 5;
}
}
}
return sphit;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void falladjustz(spritetype* g_sp)
{
if (isRRRA()) switch (g_sp->picnum)
{
case HULKBOAT:
g_sp->z += (12 << 8);
return;
case MINIONBOAT:
g_sp->z += (3 << 8);
return;
case CHEERBOAT:
case EMPTYBOAT:
g_sp->z += (6 << 8);
return;
}
if (g_sp->picnum != DRONE)
g_sp->z += (24 << 8);
}
void fall_r(int g_i, int g_p)
{
fall_common(g_i, g_p, JIBS6, DRONE, BLOODPOOL, SHOTSPARK1, 69, 158, fallspecial, falladjustz);
}
END_DUKE_NS

View file

@ -32,6 +32,7 @@ source as it is released.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "concmd.h"
#include "duke3d_ed.h"
#include "gamedef.h"
#include "gamevar.h"
@ -39,8 +40,24 @@ source as it is released.
BEGIN_DUKE_NS
#if 0
// curse these global variables for parameter passing...
int g_i, g_p;
int g_x;
int* g_t;
uint8_t killit_flag;
spritetype* g_sp;
char parse(void);
int furthestcanseepoint(int i, spritetype* ts, int* dax, int* day);
bool ifsquished(int i, int p);
void fakebubbaspawn(int g_i, int g_p);
void tearitup(int sect);
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void parseifelse(int condition)
{
@ -52,7 +69,7 @@ void parseifelse(int condition)
}
else
{
insptr = (int *) *(insptr+1);
insptr = apScript + *(insptr+1);
if(*insptr == 10)
{
// else...
@ -65,22 +82,16 @@ void parseifelse(int condition)
}
}
// int *it = 0x00589a04;
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
char parse(void)
static int ifcanshoottarget(int g_i, int g_p, int g_x)
{
int j, l, s;
if(killit_flag) return 1;
switch(*insptr)
{
case 3:
insptr++;
parseifelse( rnd(*insptr));
break;
case 45:
int j;
auto g_sp = &sprite[g_i];
if (g_x > 1024)
{
short temphit, sclip, angdif;
@ -99,8 +110,7 @@ char parse(void)
j = hitasprite(g_i, &temphit);
if (j == (1 << 30))
{
parseifelse(1);
break;
return 1;
}
if (j > sclip)
{
@ -131,30 +141,23 @@ char parse(void)
else j = 0;
}
else j = 1;
return j;
}
parseifelse(j);
break;
case 91:
j = cansee(g_sp->x,g_sp->y,g_sp->z-((TRAND&41)<<8),g_sp->sectnum,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz/*-((TRAND&41)<<8)*/,sprite[ps[g_p].i].sectnum);
parseifelse(j);
if( j ) hittype[g_i].timetosleep = SLEEPTIME;
break;
case 49:
parseifelse(hittype[g_i].actorstayput == -1);
break;
case 5:
static bool ifcansee(int g_i, int g_p)
{
auto g_sp = &sprite[g_i];
spritetype* s;
short sect;
int j;
// select sprite for monster to target
// if holoduke is on, let them target holoduke first.
//
if(ps[g_p].holoduke_on >= 0)
if (ps[g_p].holoduke_on >= 0 && !isRR())
{
s = &sprite[ps[g_p].holoduke_on];
j = cansee(g_sp->x,g_sp->y,g_sp->z-(TRAND&((32<<8)-1)),g_sp->sectnum,
j = cansee(g_sp->x, g_sp->y, g_sp->z - (krand() & ((32 << 8) - 1)), g_sp->sectnum,
s->x, s->y, s->z, s->sectnum);
if (j == 0)
@ -167,8 +170,8 @@ char parse(void)
else s = &sprite[ps[g_p].i]; // holoduke not on. look for player
// can they see player, (or player's holoduke)
j = cansee(g_sp->x,g_sp->y,g_sp->z-(TRAND&((47<<8))),g_sp->sectnum,
s->x,s->y,s->z-(24<<8),s->sectnum);
j = cansee(g_sp->x, g_sp->y, g_sp->z - (krand() & ((47 << 8))), g_sp->sectnum,
s->x, s->y, s->z - ((isRR()? 28 : 24) << 8), s->sectnum);
if (j == 0)
{
@ -204,17 +207,52 @@ char parse(void)
if (j == 1 && (g_sp->statnum == 1 || g_sp->statnum == 6))
hittype[g_i].timetosleep = SLEEPTIME;
parseifelse(j == 1);
break;
return j == 1;
}
case 6:
// int *it = 0x00589a04;
char parse(void)
{
int j, l, s;
if(killit_flag) return 1;
switch (*insptr)
{
case concmd_ifrnd:
insptr++;
parseifelse(rnd(*insptr));
break;
case concmd_ifcanshoottarget:
parseifelse(ifcanshoottarget(g_i, g_p, g_x));
break;
case concmd_ifcanseetarget:
j = cansee(g_sp->x, g_sp->y, g_sp->z - ((krand() & 41) << 8), g_sp->sectnum, ps[g_p].posx, ps[g_p].posy, ps[g_p].posz/*-((krand()&41)<<8)*/, sprite[ps[g_p].i].sectnum);
parseifelse(j);
if (j) hittype[g_i].timetosleep = SLEEPTIME;
break;
case concmd_ifnocover:
j = cansee(g_sp->x, g_sp->y, g_sp->z, g_sp->sectnum, ps[g_p].posx, ps[g_p].posy, ps[g_p].posz, sprite[ps[g_p].i].sectnum);
parseifelse(j);
if (j) hittype[g_i].timetosleep = SLEEPTIME;
break;
case concmd_ifactornotstayput:
parseifelse(hittype[g_i].actorstayput == -1);
break;
case concmd_ifcansee:
parseifelse(ifcansee(g_i, g_p));
break;
case concmd_ifhitweapon:
parseifelse(ifhitbyweapon(g_i) >= 0);
break;
case 27:
case concmd_ifsquished:
parseifelse(ifsquished(g_i, g_p) == 1);
break;
case 26:
case concmd_ifdead:
{
j = g_sp->extra;
if (g_sp->picnum == APLAYER)
@ -222,18 +260,18 @@ char parse(void)
parseifelse(j < 0);
}
break;
case 24:
case concmd_ai:
insptr++;
g_t[5] = *insptr;
g_t[4] = *(int *)(g_t[5]); // Action
g_t[1] = *(int *)(g_t[5]+4); // move
g_sp->hitag = *(int *)(g_t[5]+8); // Ai
g_t[4] = apScript[g_t[5]]; // Action
g_t[1] = apScript[g_t[5] + 1]; // move
g_sp->hitag = apScript[g_t[5] + 2]; // Ai
g_t[0] = g_t[2] = g_t[3] = 0;
if (g_sp->hitag & random_angle)
g_sp->ang = TRAND&2047;
g_sp->ang = krand() & 2047;
insptr++;
break;
case 7:
case concmd_action:
insptr++;
g_t[2] = 0;
g_t[3] = 0;
@ -241,32 +279,104 @@ char parse(void)
insptr++;
break;
case 8:
case concmd_ifpdistl:
insptr++;
parseifelse(g_x < *insptr);
if (g_x > MAXSLEEPDIST && hittype[g_i].timetosleep == 0)
hittype[g_i].timetosleep = SLEEPTIME;
break;
case 9:
case concmd_ifpdistg:
insptr++;
parseifelse(g_x > * insptr);
if (g_x > MAXSLEEPDIST && hittype[g_i].timetosleep == 0)
hittype[g_i].timetosleep = SLEEPTIME;
break;
case 10:
insptr = (int *) *(insptr+1);
case concmd_else:
insptr = apScript + *(insptr + 1);
break;
case 100:
case concmd_addstrength:
insptr++;
g_sp->extra += *insptr;
insptr++;
break;
case 11:
case concmd_strength:
insptr++;
g_sp->extra = *insptr;
insptr++;
break;
case 94:
case concmd_smacksprite:
switch (krand() & 1)
{
case 0:
g_sp->ang = (+512 + g_sp->ang + (krand() & 511)) & 2047;
break;
case 1:
g_sp->ang = (-512 + g_sp->ang - (krand() & 511)) & 2047;
break;
}
insptr++;
break;
case concmd_fakebubba:
insptr++;
fakebubbaspawn(g_i, g_p);
break;
case concmd_rndmove:
g_sp->ang = krand() & 2047;
g_sp->xvel = 25;
insptr++;
break;
case concmd_mamatrigger:
operateactivators(667, ps[g_p].i);
insptr++;
break;
case concmd_mamaspawn:
if (mamaspawn_count)
{
mamaspawn_count--;
spawn(g_i, RABBIT);
}
insptr++;
break;
case concmd_mamaquake:
if (g_sp->pal == 31)
earthquaketime = 4;
else if (g_sp->pal == 32)
earthquaketime = 6;
insptr++;
break;
case concmd_garybanjo:
if (banjosound == 0)
{
short rnum = (krand() & 3) + 1;
if (rnum == 4)
{
banjosound = 262;
}
else if (rnum == 1)
{
banjosound = 272;
}
else if (rnum == 2)
{
banjosound = 273;
}
else
{
banjosound = 273;
}
A_PlaySound(banjosound, g_i, CHAN_WEAPON);
}
else if (!S_CheckSoundPlaying(g_i, banjosound))
A_PlaySound(banjosound, g_i, CHAN_WEAPON);
insptr++;
break;
case concmd_motoloopsnd:
if (!S_CheckSoundPlaying(g_i, 411))
A_PlaySound(411, g_i, CHAN_VOICE);
insptr++;
break;
case concmd_ifgotweaponce:
insptr++;
if (ud.coop >= 1 && ud.multimode > 1)
@ -287,26 +397,26 @@ char parse(void)
}
else parseifelse(0);
break;
case 95:
case concmd_getlastpal:
insptr++;
if (g_sp->picnum == APLAYER)
g_sp->pal = ps[g_sp->yvel].palookup;
else g_sp->pal = hittype[g_i].tempang;
hittype[g_i].tempang = 0;
break;
case 104:
case concmd_tossweapon:
insptr++;
checkweapons(&ps[g_sp->yvel]);
break;
case 106:
case concmd_nullop:
insptr++;
break;
case 97:
case concmd_mikesnd:
insptr++;
if(Sound[g_sp->yvel].num == 0)
spritesound(g_sp->yvel,g_i);
if (!S_CheckSoundPlaying(g_i, g_sp->yvel))
A_PlaySound(g_sp->yvel, g_i, CHAN_VOICE);
break;
case 96:
case concmd_pkick:
insptr++;
if (ud.multimode > 1 && g_sp->picnum == APLAYER)
@ -317,7 +427,7 @@ char parse(void)
else if (g_sp->picnum != APLAYER && ps[g_p].quick_kick == 0)
ps[g_p].quick_kick = 14;
break;
case 28:
case concmd_sizeto:
insptr++;
// JBF 20030805: As I understand it, if xrepeat becomes 0 it basically kills the
@ -339,134 +449,115 @@ char parse(void)
insptr++;
break;
case 99:
case concmd_sizeat:
insptr++;
g_sp->xrepeat = (char) *insptr;
g_sp->xrepeat = (uint8_t)*insptr;
insptr++;
g_sp->yrepeat = (char) *insptr;
g_sp->yrepeat = (uint8_t)*insptr;
insptr++;
break;
case 13:
case concmd_shoot:
insptr++;
shoot(g_i, (short)*insptr);
insptr++;
break;
case 87:
case concmd_ifsoundid:
insptr++;
if( Sound[*insptr].num == 0 )
spritesound((short) *insptr,g_i);
parseifelse((short)*insptr == ambientlotag[g_sp->ang]);
break;
case concmd_ifsounddist:
insptr++;
if (*insptr == 0)
parseifelse(ambienthitag[g_sp->ang] > g_x);
else if (*insptr == 1)
parseifelse(ambienthitag[g_sp->ang] < g_x);
insptr++;
break;
case CON_IFSOUND:
case concmd_soundtag:
insptr++;
parseifelse( Sound[*insptr].num == 0 );
spritesound(ambientlotag[g_sp->ang], g_i);
break;
case 89:
case concmd_soundtagonce:
insptr++;
if( Sound[*insptr].num > 0 )
stopsound((short)*insptr);
if (!S_CheckSoundPlaying(g_i, ambientlotag[g_sp->ang]))
A_PlaySound(ambientlotag[g_sp->ang], g_i);
break;
case concmd_soundonce:
insptr++;
if (!S_CheckSoundPlaying(g_i, *insptr++))
A_PlaySound(*(insptr - 1), g_i);
insptr++;
break;
case 92:
case concmd_stopsound:
insptr++;
if (S_CheckSoundPlaying(g_i, *insptr))
S_StopSound((int)*insptr);
insptr++;
break;
case concmd_globalsound:
insptr++;
if (g_p == screenpeek || ud.coop == 1)
spritesound((short) *insptr,ps[screenpeek].i);
spritesound((int)*insptr, ps[screenpeek].i);
insptr++;
break;
case 15:
case concmd_smackbubba:
insptr++;
if (!isRRRA || g_sp->pal != 105)
{
ps[myconnectindex].gm = MODE_EOL;
ud.level_number++;
if (ud.level_number > 6)
ud.level_number = 0;
ud.m_level_number = ud.level_number;
}
break;
case concmd_mamaend:
insptr++;
ps[myconnectindex].MamaEnd = 150;
break;
case concmd_ifactorhealthg:
insptr++;
parseifelse(g_sp->extra > (short)*insptr);
break;
case concmd_ifactorhealthl:
insptr++;
parseifelse(g_sp->extra < (short)*insptr);
break;
case concmd_sound:
insptr++;
spritesound((short) *insptr,g_i);
insptr++;
break;
case 84:
case concmd_tip:
insptr++;
ps[g_p].tipincs = 26;
break;
case 16:
case concmd_iftipcow:
case concmd_ifhittruck: // both have the same code.
if (g_spriteExtra[g_i] == 1) // TRANSITIONAL 'filler' no longer exists
{
j = 1;
g_spriteExtra[g_i]++;
}
else
j = 0;
parseifelse(j > 0);
break;
case concmd_tearitup:
insptr++;
tearitup(g_sp->sectnum);
break;
case concmd_fall:
insptr++;
g_sp->xoffset = 0;
g_sp->yoffset = 0;
// if(!gotz)
{
int c;
if( floorspace(g_sp->sectnum) )
c = 0;
else
{
if( ceilingspace(g_sp->sectnum) || sector[g_sp->sectnum].lotag == 2)
c = gc/6;
else c = gc;
}
if( hittype[g_i].cgg <= 0 || (sector[g_sp->sectnum].floorstat&2) )
{
getglobalz(g_i);
hittype[g_i].cgg = 6;
}
else hittype[g_i].cgg --;
if( g_sp->z < (hittype[g_i].floorz-FOURSLEIGHT) )
{
g_sp->zvel += c;
g_sp->z+=g_sp->zvel;
if(g_sp->zvel > 6144) g_sp->zvel = 6144;
}
else
{
g_sp->z = hittype[g_i].floorz - FOURSLEIGHT;
if( badguy(g_sp) || ( g_sp->picnum == APLAYER && g_sp->owner >= 0) )
{
if( g_sp->zvel > 3084 && g_sp->extra <= 1)
{
if(g_sp->pal != 1 && g_sp->picnum != DRONE)
{
if(g_sp->picnum == APLAYER && g_sp->extra > 0)
goto SKIPJIBS;
guts(g_sp,JIBS6,15,g_p);
spritesound(SQUISHED,g_i);
spawn(g_i,BLOODPOOL);
}
SKIPJIBS:
hittype[g_i].picnum = SHOTSPARK1;
hittype[g_i].extra = 1;
g_sp->zvel = 0;
}
else if(g_sp->zvel > 2048 && sector[g_sp->sectnum].lotag != 1)
{
j = g_sp->sectnum;
pushmove(&g_sp->x,&g_sp->y,&g_sp->z,&j,128L,(4L<<8),(4L<<8),CLIPMASK0);
if(j != g_sp->sectnum && j >= 0 && j < MAXSECTORS)
changespritesect(g_i,j);
spritesound(THUD,g_i);
}
}
if(sector[g_sp->sectnum].lotag == 1)
switch (g_sp->picnum)
{
case OCTABRAIN:
case COMMANDER:
case DRONE:
fall(g_i, g_p);
break;
default:
g_sp->z += (24<<8);
break;
}
else g_sp->zvel = 0;
}
}
break;
case 4:
case 12:
case 18:
case concmd_enda:
case concmd_break:
case concmd_ends:
case concmd_endevent:
return 1;
case 30:
insptr++;
@ -633,7 +724,7 @@ char parse(void)
g_sp->hitag = *insptr;
insptr++;
if(g_sp->hitag&random_angle)
g_sp->ang = TRAND&2047;
g_sp->ang = krand()&2047;
break;
case 31:
insptr++;
@ -674,13 +765,13 @@ char parse(void)
{
if(g_sp->picnum == BLIMP && dnum == SCRAP1)
s = 0;
else s = (TRAND%3);
else s = (krand()%3);
l = EGS(g_sp->sectnum,
g_sp->x+(TRAND&255)-128,g_sp->y+(TRAND&255)-128,g_sp->z-(8<<8)-(TRAND&8191),
dnum+s,g_sp->shade,32+(TRAND&15),32+(TRAND&15),
TRAND&2047,(TRAND&127)+32,
-(TRAND&2047),g_i,5);
g_sp->x+(krand()&255)-128,g_sp->y+(krand()&255)-128,g_sp->z-(8<<8)-(krand()&8191),
dnum+s,g_sp->shade,32+(krand()&15),32+(krand()&15),
krand()&2047,(krand()&127)+32,
-(krand()&2047),g_i,5);
if(g_sp->picnum == BLIMP && dnum == SCRAP1)
sprite[l].yvel = weaponsandammosprites[j%14];
else sprite[l].yvel = -1;
@ -1027,7 +1118,6 @@ char parse(void)
parseifelse( (( hittype[g_i].floorz - hittype[g_i].ceilingz ) >> 8 ) >= *insptr);
break;
*/
#ifdef WW2
case CON_ADDLOG:
{ int l;
int lFile;
@ -1051,10 +1141,6 @@ char parse(void)
{
// invalid varID
insptr++;
sprintf(g_szBuf,"ADDLOGVAR: %s L=%ld INVALID VARIABLE",g_achSourceFiles[lFile],l);
AddLog(g_szBuf);
sprintf(g_szBuf,"Offset=%0lX\n",scriptptr-script);
AddLog(g_szBuf);
break; // out of switch
}
sprintf(szBuf,"ADDLOGVAR: %s L=%ld %s ",g_achSourceFiles[lFile],l, aGameVars[*insptr].szLabel);
@ -1111,17 +1197,6 @@ char parse(void)
insptr++;
break;
}
case CON_SIN:
{ int i;
int lValue;
insptr++;
i=*(insptr++); // ID of def
lValue=GetGameVarID(*insptr, g_i, g_p);
lValue=sintable[lValue&2047];
SetGameVarID(i, lValue , g_i, g_p );
insptr++;
break;
}
case CON_ADDVARVAR:
{ int i;
@ -1131,63 +1206,6 @@ char parse(void)
insptr++;
break;
}
case CON_SPGETLOTAG:
{
insptr++;
SetGameVarID(g_iLoTagID, g_sp->lotag, g_i, g_p);
break;
}
case CON_SPGETHITAG:
{
insptr++;
SetGameVarID(g_iHiTagID, g_sp->hitag, g_i, g_p);
break;
}
case CON_SECTGETLOTAG:
{
insptr++;
SetGameVarID(g_iLoTagID, sector[g_sp->sectnum].lotag, g_i, g_p);
break;
}
case CON_SECTGETHITAG:
{
insptr++;
SetGameVarID(g_iHiTagID, sector[g_sp->sectnum].hitag, g_i, g_p);
break;
}
case CON_GETTEXTUREFLOOR:
{
insptr++;
SetGameVarID(g_iTextureID, sector[g_sp->sectnum].floorpicnum, g_i, g_p);
break;
}
case CON_IFVARVARAND:
{
int i;
insptr++;
i=*(insptr++); // ID of def
j=0;
if(GetGameVarID(i, g_i, g_p) & GetGameVarID(*(insptr), g_i, g_p) )
{
j=1;
}
parseifelse( j );
break;
}
case CON_IFVARVARN:
{
int i;
insptr++;
i=*(insptr++); // ID of def
j=0;
if(GetGameVarID(i, g_i, g_p) != GetGameVarID(*(insptr), g_i, g_p) )
{
j=1;
}
parseifelse( j );
break;
}
case CON_IFVARVARE:
{
int i;
@ -1240,32 +1258,6 @@ char parse(void)
parseifelse( j );
break;
}
case CON_IFVARN:
{
int i;
insptr++;
i=*(insptr++); // ID of def
j=0;
if(GetGameVarID(i, g_i, g_p) != *insptr)
{
j=1;
}
parseifelse( j );
break;
}
case CON_IFVARAND:
{
int i;
insptr++;
i=*(insptr++); // ID of def
j=0;
if(GetGameVarID(i, g_i, g_p) & *insptr)
{
j=1;
}
parseifelse( j );
break;
}
case CON_IFVARG:
{
int i;
@ -1292,7 +1284,6 @@ char parse(void)
parseifelse( j );
break;
}
#endif
case 78:
insptr++;
parseifelse( sprite[ps[g_p].i].extra < *insptr);

View file

@ -56,16 +56,8 @@ extern int errorcount, warningcount, line_count;
intptr_t *actorLoadEventScrptr[MAXTILES];
intptr_t *apScriptGameEvent[MAXGAMEEVENTS];
// global crap for event management
int g_i,g_p;
int g_x;
int *g_t;
uint8_t killit_flag;
spritetype *g_sp;
#endif
//---------------------------------------------------------------------------
//
//

View file

@ -197,8 +197,8 @@ G_EXTERN int32_t g_winderFlash;
G_EXTERN int32_t g_winderTime;
G_EXTERN int32_t g_brightness;
G_EXTERN int16_t g_ambientLotag[64];
G_EXTERN int16_t g_ambientHitag[64];
G_EXTERN int16_t ambientlotag[64];
G_EXTERN int16_t ambienthitag[64];
G_EXTERN uint32_t g_ambientCnt;
G_EXTERN intptr_t *apScript;
@ -217,7 +217,7 @@ G_EXTERN msx_ msx;
G_EXTERN msy_ msy;
G_EXTERN int32_t g_windTime, WindDir;
G_EXTERN int16_t g_fakeBubbaCnt, g_mamaSpawnCnt, g_banjoSong, g_bellTime, g_bellSprite;
G_EXTERN int16_t fakebubba_spawn, mamaspawn_count, banjosound, g_bellTime, g_bellSprite;
#define BellTime g_bellTime
#define word_119BE0 g_bellSprite
G_EXTERN uint8_t g_spriteExtra[MAXSPRITES], g_sectorExtra[MAXSECTORS]; // move these back into the base structs!

View file

@ -250,7 +250,7 @@ typedef struct player_struct {
int16_t yehaa_timer;
int16_t drink_amt, eat_amt, drink_ang, eat_ang;
int32_t drink_timer, eat_timer;
int16_t level_end_timer;
int16_t MamaEnd;
int16_t MotoSpeed, tilt_status, moto_drink;
uint8_t OnMotorcycle, OnBoat, moto_underwater, not_on_water, moto_on_ground;
uint8_t moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud;
@ -278,7 +278,7 @@ typedef struct player_struct {
#define heat_amount inv_amount[GET_HEATS]
#define scuba_amount inv_amount[GET_SCUBA]
#define boot_amount inv_amount[GET_BOOTS]
#define raat609 level_end_timer // name in RRGDX is 'MamaEnd'
#define raat609 MamaEnd
#define raat5dd sea_sick_stat
@ -396,7 +396,7 @@ void addweapon(DukePlayer_t* pPlayer, int weaponNum);
void P_CheckWeapon(DukePlayer_t *pPlayer);
void P_DisplayScuba(void);
void P_DisplayWeapon(void);
void P_DropWeapon(int playerNum);
void checkweapons(DukePlayer_t* const pPlayer);
int findotherplayer(int p, int* d);
void P_FragPlayer(int playerNum);
#ifdef YAX_ENABLE

View file

@ -25,8 +25,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_DUKE_NS
extern int16_t g_ambientLotag[64];
extern int16_t g_ambientHitag[64];
extern int16_t ambientlotag[64];
extern int16_t ambienthitag[64];
extern int32_t g_levelTextTime;
extern int32_t voting,vote_map,vote_episode;
int G_EnterLevel(int gameMode);

View file

@ -2866,4 +2866,24 @@ void dofurniture(int wl, int sect, int snum)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void tearitup(int sect)
{
int j = headspritesect[sect];
while (j != -1)
{
int nextj = nextspritesect[j];
if (sprite[j].picnum == DESTRUCTO)
{
hittype[j].picnum = SHOTSPARK1;
hittype[j].extra = 1;
}
j = nextj;
}
}
END_DUKE_NS

View file

@ -894,7 +894,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_fakebubba:
insptr++;
switch (++g_fakeBubbaCnt)
switch (++fakebubba_spawn)
{
case 1:
A_Spawn(vm.spriteNum, TILE_PIG);
@ -925,9 +925,9 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_mamaspawn:
insptr++;
if (g_mamaSpawnCnt)
if (mamaspawn_count)
{
g_mamaSpawnCnt--;
mamaspawn_count--;
A_Spawn(vm.spriteNum, TILE_RABBIT);
}
continue;
@ -942,24 +942,24 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_garybanjo:
insptr++;
if (g_banjoSong == 0)
if (banjosound == 0)
{
switch (krand2()&3)
{
case 3:
g_banjoSong = 262;
banjosound = 262;
break;
case 0:
g_banjoSong = 272;
banjosound = 272;
break;
default:
g_banjoSong = 273;
banjosound = 273;
break;
}
A_PlaySound(g_banjoSong, vm.spriteNum);
A_PlaySound(banjosound, vm.spriteNum, CHAN_WEAPON);
}
else if (!S_CheckSoundPlaying(vm.spriteNum, g_banjoSong))
A_PlaySound(g_banjoSong, vm.spriteNum, CHAN_WEAPON);
else if (!S_CheckSoundPlaying(vm.spriteNum, banjosound))
A_PlaySound(banjosound, vm.spriteNum, CHAN_WEAPON);
continue;
case concmd_motoloopsnd:
insptr++;
@ -1004,7 +1004,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_tossweapon:
insptr++;
// NOTE: assumes that current actor is TILE_APLAYER
P_DropWeapon(P_GetP(vm.pSprite));
checkweapons(&ps[P_GetP(vm.pSprite)]);
continue;
case concmd_mikesnd:
@ -1066,18 +1066,18 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_ifsoundid:
insptr++;
VM_CONDITIONAL((int16_t)*insptr == g_ambientLotag[vm.pSprite->ang]);
VM_CONDITIONAL((int16_t)*insptr == ambientlotag[vm.pSprite->ang]);
continue;
case concmd_ifsounddist:
insptr++;
if (*insptr == 0)
{
VM_CONDITIONAL(g_ambientHitag[vm.pSprite->ang] > vm.playerDist);
VM_CONDITIONAL(ambienthitag[vm.pSprite->ang] > vm.playerDist);
}
else if (*insptr == 1)
{
VM_CONDITIONAL(g_ambientHitag[vm.pSprite->ang] < vm.playerDist);
VM_CONDITIONAL(ambienthitag[vm.pSprite->ang] < vm.playerDist);
}
else
{
@ -1088,13 +1088,13 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_soundtag:
insptr++;
A_PlaySound(g_ambientLotag[vm.pSprite->ang], vm.spriteNum);
A_PlaySound(ambientlotag[vm.pSprite->ang], vm.spriteNum);
continue;
case concmd_soundtagonce:
insptr++;
if (!S_CheckSoundPlaying(vm.spriteNum, g_ambientLotag[vm.pSprite->ang]))
A_PlaySound(g_ambientLotag[vm.pSprite->ang], vm.spriteNum);
if (!S_CheckSoundPlaying(vm.spriteNum, ambientlotag[vm.pSprite->ang]))
A_PlaySound(ambientlotag[vm.pSprite->ang], vm.spriteNum);
continue;
case concmd_soundonce:
@ -1158,7 +1158,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_mamaend:
insptr++;
g_player[myconnectindex].ps->level_end_timer = 150;
g_player[myconnectindex].ps->MamaEnd = 150;
continue;
case concmd_ifactorhealthg:

View file

@ -4593,9 +4593,9 @@ int16_t WeaponPickupSprites[MAX_WEAPONS] = { KNEE__STATIC, FIRSTGUNSPRITE__STATI
TRIPBOMBSPRITE__STATIC, FREEZESPRITE__STATIC, HEAVYHBOMB__STATIC, SHRINKERSPRITE__STATIC
};
// this is used for player deaths
void P_DropWeapon(int const playerNum)
void checkweapons(DukePlayer_t* const pPlayer)
{
DukePlayer_t *const pPlayer = g_player[playerNum].ps;
int playerNum = sprite[pPlayer->i].yvel;
int const currentWeapon = WW2GI ? PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) : pPlayer->curr_weapon;
if (RRRA && (g_netServer || numplayers > 1))

View file

@ -1165,7 +1165,7 @@ static void resetprestat(int playerNum, int gameMode)
{
g_windTime = 0;
WindDir = 0;
g_fakeBubbaCnt = 0;
fakebubba_spawn = 0;
RRRA_ExitedLevel = 0;
g_bellTime = 0;
g_bellSprite = 0;
@ -1278,9 +1278,9 @@ static void prelevel(char g)
ufospawnsminion = 0;
pistonsound = 0;
enemysizecheat = 0;
g_player[myconnectindex].ps->level_end_timer = 0;
g_mamaSpawnCnt = 15;
g_banjoSong = 0;
g_player[myconnectindex].ps->MamaEnd = 0;
mamaspawn_count = 15;
banjosound = 0;
RRRA_ExitedLevel = 0;
if (!DEER)
{
@ -1293,11 +1293,11 @@ static void prelevel(char g)
ps->inv_amount[GET_STEROIDS] = 0;
}
if (ud.level_number == 3 && ud.volume_number == 0)
g_mamaSpawnCnt = 5;
mamaspawn_count = 5;
else if (ud.level_number == 2 && ud.volume_number == 1)
g_mamaSpawnCnt = 10;
mamaspawn_count = 10;
else if (ud.level_number == 6 && ud.volume_number == 1)
g_mamaSpawnCnt = 15;
mamaspawn_count = 15;
}
}
@ -1306,8 +1306,8 @@ static void prelevel(char g)
Bmemset(shadedsector, 0, sizeof(shadedsector));
Bmemset(g_geoSectorWarp, -1, sizeof(g_geoSectorWarp));
Bmemset(g_geoSectorWarp2, -1, sizeof(g_geoSectorWarp2));
Bmemset(g_ambientHitag, -1, sizeof(g_ambientHitag));
Bmemset(g_ambientLotag, -1, sizeof(g_ambientLotag));
Bmemset(ambienthitag, -1, sizeof(ambienthitag));
Bmemset(ambientlotag, -1, sizeof(ambientlotag));
show2dsector.Zero();
#ifdef LEGACY_ROR
Bmemset(ror_protectedsectors, 0, MAXSECTORS);
@ -1324,9 +1324,9 @@ static void prelevel(char g)
{
g_windTime = 0;
WindDir = 0;
g_fakeBubbaCnt = 0;
fakebubba_spawn = 0;
RRRA_ExitedLevel = 0;
g_mamaSpawnCnt = 15; // ???
mamaspawn_count = 15; // ???
g_bellTime = 0;
g_bellSprite = 0;
@ -1532,8 +1532,8 @@ static void prelevel(char g)
G_GameExit("\nToo many ambient effects");
else
{
g_ambientHitag[g_ambientCnt] = SHT(i);
g_ambientLotag[g_ambientCnt] = SLT(i);
ambienthitag[g_ambientCnt] = SHT(i);
ambientlotag[g_ambientCnt] = SLT(i);
sprite[i].ang = g_ambientCnt++;
sprite[i].lotag = 0;
sprite[i].hitag = 0;

View file

@ -877,8 +877,8 @@ static const dataspec_t svgm_anmisc[] =
{ 0, &shadedsector[0], sizeof(shadedsector[0]), MAXSECTORS },
{ 0, &g_ambientCnt, sizeof(g_ambientCnt), 1 },
{ 0, &g_ambientHitag[0], sizeof(g_ambientHitag[0]), ARRAY_SIZE(g_ambientHitag) },
{ 0, &g_ambientLotag[0], sizeof(g_ambientLotag[0]), ARRAY_SIZE(g_ambientLotag) },
{ 0, &ambienthitag[0], sizeof(ambienthitag[0]), ARRAY_SIZE(ambienthitag) },
{ 0, &ambientlotag[0], sizeof(ambientlotag[0]), ARRAY_SIZE(ambientlotag) },
{ 0, &g_ufoSpawn, sizeof(g_ufoSpawn), 1 },
{ 0, &g_ufoCnt, sizeof(g_ufoCnt), 1 },
@ -896,9 +896,9 @@ static const dataspec_t svgm_anmisc[] =
{ 0, &g_windTime, sizeof(g_windTime), 1 },
{ 0, &WindDir, sizeof(WindDir), 1 },
{ 0, &g_fakeBubbaCnt, sizeof(g_fakeBubbaCnt), 1 },
{ 0, &g_mamaSpawnCnt, sizeof(g_mamaSpawnCnt), 1 },
{ 0, &g_banjoSong, sizeof(g_banjoSong), 1 },
{ 0, &fakebubba_spawn, sizeof(fakebubba_spawn), 1 },
{ 0, &mamaspawn_count, sizeof(mamaspawn_count), 1 },
{ 0, &banjosound, sizeof(banjosound), 1 },
{ 0, &g_bellTime, sizeof(g_bellTime), 1 },
{ 0, &g_bellSprite, sizeof(g_bellSprite), 1 },