- Duke: documented global variables for eventual scriptification.

Most are only needed internally or for very special uses and do not need any scripting consideration.
This commit is contained in:
Christoph Oelckers 2020-11-29 15:09:23 +01:00
parent 553bb2af19
commit 92bf1232da
10 changed files with 93 additions and 75 deletions

View file

@ -1935,10 +1935,10 @@ void reactor(DDukeActor* actor, int REACTOR, int REACTOR2, int REACTORBURNT, int
{
//Turn on all of those flashing sectoreffector.
fi.hitradius(actor, 4096,
impact_damage << 2,
impact_damage << 2,
impact_damage << 2,
impact_damage << 2);
gs.impact_damage << 2,
gs.impact_damage << 2,
gs.impact_damage << 2,
gs.impact_damage << 2);
DukeStatIterator it(STAT_STANDABLE);
while (auto act2 = it.Next())
{

View file

@ -1887,7 +1887,7 @@ int ConCompiler::parsecommand()
auto parseone = [&]() { return params[pget++]; };
ud.const_visibility = parseone();
impact_damage = parseone();
gs.impact_damage = parseone();
gs.max_player_health = parseone();
gs.max_armour_amount = parseone();
gs.respawnactortime = parseone();
@ -1915,7 +1915,7 @@ int ConCompiler::parsecommand()
if (isRR()) gs.max_ammo_amount[12] = parseone();
gs.camerashitable = parseone();
gs.numfreezebounces = parseone();
freezerhurtowner = parseone();
gs.freezerhurtowner = parseone();
if (isPlutoPak() || isRR())
{
spriteqamount = clamp(parseone(), 0, 1024);

View file

@ -33,71 +33,99 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
BEGIN_DUKE_NS
user_defs ud;
//-------------------------------------------------------------------------
//
// variables that need a script export
//
//-------------------------------------------------------------------------
user_defs ud; // partially serialized
// not serialized - read only
DukeGameInfo gs;
int cameradist = 0, cameraclock = 0;
int otherp;
int actor_tog;
int playerswhenstarted;
int show_shareware;
int screenpeek;
// Variables that must be saved
uint8_t sectorextra[MAXSECTORS]; // move these back into the base structs!
int rtsplaying;
int tempwallptr;
weaponhit hittype[MAXSPRITES+1]; // +1 to have a blank entry for serialization.
bool sound445done; // this was local state inside a function, but this must be maintained globally and serialized
// serialized
player_struct ps[MAXPLAYERS];
int spriteqamount = 64;
uint8_t shadedsector[MAXSECTORS];
int lastvisinc;
animwalltype animwall[MAXANIMWALLS];
int numanimwalls;
int animatecnt;
int numclouds;
DDukeActor* camsprite;
int numcyclers;
int earthquaketime;
int freezerhurtowner;
int global_random;
int impact_damage;
int mirrorcnt;
int numplayersprites;
int spriteqloc;
int thunder_brightness;
//-------------------------------------------------------------------------
//
// variables that only need an export if the entire game logic gets scriptified.
// Otherwise all code referencing these variables should remain native.
//
//-------------------------------------------------------------------------
int lastvisinc; // weapon flash
DDukeActor* camsprite; // active camera
int earthquaketime;
int global_random; // readonly - one single global per-frame random value. Ugh...
// Redneck Rampage
int chickenplant; // readonly - used to trigger some special behavior if a special item is found in a map.
int thunderon; // readonly - enables thunder effect in RR if true.
int ufospawn; // UFO spawn flag
int ufocnt; // UFO spawn count
int hulkspawn; // Spawn a hulk?
int lastlevel; // Set at the end of RRRA's E2L7.
short fakebubba_spawn, mamaspawn_count, banjosound; // RRRA special effects
short BellTime;
DDukeActor* BellSprite /* word_119BE0*/;
int WindTime, WindDir;
uint8_t enemysizecheat /*raat607*/, ufospawnsminion, pistonsound, chickenphase /* raat605*/, RRRA_ExitedLevel, fogactive;
//-------------------------------------------------------------------------
//
// variables that do not need a script export.
//
//-------------------------------------------------------------------------
// not serialized
int cameradist = 0, cameraclock = 0; // only for 3rd person view
int otherp; // internal helper
int actor_tog; // cheat helper
int playerswhenstarted; // why is this needed?
int show_shareware; // display only.
int rtsplaying; // RTS playback state
int tempwallptr; // msx/y index.
int msx[MAXANIMPOINTS], msy[MAXANIMPOINTS];
bool sound445done; // used in checksectors_r. This was local state inside a function, but this must be maintained globally and serialized
// serialized
uint8_t sectorextra[MAXSECTORS]; // something about keys, all access through the haskey function.
weaponhit hittype[MAXSPRITES + 1]; // +1 to have a blank entry for serialization, all access in game code through the iterators.
int spriteqamount = 64; // internal sprite queue
int spriteqloc;
DDukeActor* spriteq[1024];
uint8_t shadedsector[MAXSECTORS]; // display hackiness
animwalltype animwall[MAXANIMWALLS]; // animated walls
int numanimwalls;
int animatecnt; // sector plane movement
int16_t animatesect[MAXANIMATES];
int8_t animatetype[MAXANIMATES];
int16_t animatetarget[MAXANIMATES];
int animategoal[MAXANIMATES];
int animatevel[MAXANIMATES];
int numclouds; // cloudy skies
int16_t clouds[256];
int16_t cloudx;
int16_t cloudy;
int cloudclock;
DDukeActor *spriteq[1024];
int numcyclers; // sector lighting effects
int16_t cyclers[MAXCYCLERS][6];
int16_t mirrorsector[64];
int mirrorcnt;
int16_t mirrorsector[64]; // mirrors
int16_t mirrorwall[64];
int numplayersprites; // player management for some SEs.
player_orig po[MAXPLAYERS];
unsigned ambientfx; // used by soundtag and soundtagonce script commands. If exported, export the commands, not the data!
short ambientlotag[64];
short ambienthitag[64];
uint32_t everyothertime; // Global animation ticker helper.
// Redneck Rampage
int wupass;
int chickenplant;
int thunderon;
int ufospawn;
int ufocnt;
int hulkspawn;
int lastlevel;
int geosectorwarp[MAXGEOSECTORS];
int thunder_brightness;
int wupass; // used to play the level entry sound only once.
int geosectorwarp[MAXGEOSECTORS]; // geometry render hack (overlay a secondary scene)
int geosectorwarp2[MAXGEOSECTORS];
int geosector[MAXGEOSECTORS];
int geox[MAXGEOSECTORS];
@ -106,16 +134,5 @@ int geox2[MAXGEOSECTORS];
int geoy2[MAXGEOSECTORS];
int geocnt;
short ambientlotag[64];
short ambienthitag[64];
unsigned ambientfx;
int msx[MAXANIMPOINTS], msy[MAXANIMPOINTS];
int WindTime, WindDir;
short fakebubba_spawn, mamaspawn_count, banjosound;
short BellTime;
DDukeActor* BellSprite /* word_119BE0*/;
uint8_t enemysizecheat /*raat607*/, ufospawnsminion, pistonsound, chickenphase /* raat605*/, RRRA_ExitedLevel, fogactive;
uint32_t everyothertime;
player_orig po[MAXPLAYERS];
END_DUKE_NS

View file

@ -33,6 +33,9 @@ struct DukeGameInfo
int max_player_health = 0;
int max_armour_amount = 0;
int lasermode = 0;
int freezerhurtowner = 0;
int impact_damage = 0;
TileInfo tileinfo[MAXTILES] = {}; // This is not from EDuke32.
ActorInfo actorinfo[MAXTILES] = {};
int16_t max_ammo_amount[MAX_WEAPONS] = {};
@ -71,9 +74,7 @@ extern int numclouds;
extern DDukeActor* camsprite;
extern int numcyclers;
extern int earthquaketime;
extern int freezerhurtowner;
extern int global_random;
extern int impact_damage;
extern int mirrorcnt;
extern int numplayersprites;
extern int spriteqloc;

View file

@ -347,9 +347,9 @@ void GameInterface::SerializeGameState(FSerializer& arc)
.Array("animwall", animwall, numanimwalls)
("camsprite", camsprite)
("earthquaketime", earthquaketime)
("freezerhurtowner", freezerhurtowner)
("gs.freezerhurtowner", gs.freezerhurtowner)
("global_random", global_random)
("impact_damage", impact_damage)
("gs.impact_damage", gs.impact_damage)
("numplayersprites", numplayersprites)
("spriteqloc", spriteqloc)
("animatecnt", animatecnt)

View file

@ -1424,7 +1424,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
if (s->statnum != 2)
{
if (pspr->picnum == FREEZEBLAST && ((s->picnum == APLAYER && s->pal == 1) || (freezerhurtowner == 0 && proj->GetOwner() == targ)))
if (pspr->picnum == FREEZEBLAST && ((s->picnum == APLAYER && s->pal == 1) || (gs.freezerhurtowner == 0 && proj->GetOwner() == targ)))
return;

View file

@ -2385,7 +2385,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj)
if (s->statnum != 2)
{
if (pspr->picnum == FREEZEBLAST && ((s->picnum == APLAYER && s->pal == 1) || (freezerhurtowner == 0 && proj->GetOwner() == targ)))
if (pspr->picnum == FREEZEBLAST && ((s->picnum == APLAYER && s->pal == 1) || (gs.freezerhurtowner == 0 && proj->GetOwner() == targ)))
return;
targ->picnum = pspr->picnum;

View file

@ -207,7 +207,7 @@ int initspriteforspawn(DDukeActor* actj, int pn, const std::initializer_list<int
{
changespritestat(i, 12);
sp->cstat |= 257;
sp->extra = impact_damage;
sp->extra = gs.impact_damage;
return i;
}
}
@ -600,7 +600,7 @@ int initreactor(DDukeActor* actj, DDukeActor* actor, bool isrecon)
sp->extra = 130;
}
else
sp->extra = impact_damage;
sp->extra = gs.impact_damage;
sp->cstat |= 257; // Make it hitable

View file

@ -1057,7 +1057,7 @@ int spawn_d(int j, int pn)
sp->cstat |= 1+256; //Make it hitable
sp->xrepeat = sp->yrepeat = 24;
sp->shade = -127;
sp->extra = impact_damage<<2;
sp->extra = gs.impact_damage<<2;
changespritestat(act, STAT_ZOMBIEACTOR);
break;
@ -1114,7 +1114,7 @@ int spawn_d(int j, int pn)
sp->xrepeat=sp->yrepeat=0;
}
else sp->cstat = 1+256;
sp->extra = impact_damage<<2;
sp->extra = gs.impact_damage<<2;
act->SetOwner(act);
changespritestat(act, STAT_STANDABLE);
break;
@ -1127,7 +1127,7 @@ int spawn_d(int j, int pn)
if(sp->picnum == FIREEXT)
{
sp->cstat = 257;
sp->extra = impact_damage<<2;
sp->extra = gs.impact_damage<<2;
}
else
{

View file

@ -1374,7 +1374,7 @@ int spawn_r(int j, int pn)
sp->xrepeat=sp->yrepeat=0;
}
else sp->cstat = 1+256;
sp->extra = impact_damage<<2;
sp->extra = gs.impact_damage<<2;
act->SetOwner(act);
changespritestat(act, STAT_STANDABLE);
break;