//------------------------------------------------------------------------- /* Copyright (C) 1996, 2003 - 3D Realms Entertainment Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition Duke Nukem 3D is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Original Source: 1996 - Todd Replogle Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms EDuke enhancements integrated: 04/13/2003 - Matt Saettler Note: EDuke source was in transition. Changes are in-progress in the source as it is released. */ //------------------------------------------------------------------------- #include "ns.h" #include "global.h" #include "gamedef.h" #include "serializer.h" #include "namesdyn.h" #include "build.h" #include "mmulti.h" #include "gamevar.h" // This currently only works for Duke and related games #include "names.h" BEGIN_DUKE_NS MATTGAMEVAR aGameVars[MAXGAMEVARS]; int iGameVarCount; extern int errorcount, warningcount, line_count; #if 0 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 //--------------------------------------------------------------------------- // // to do // //--------------------------------------------------------------------------- void SerializeGameVars(FSerializer &arc) { } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- bool AddGameVar(const char *pszLabel, intptr_t lValue, unsigned dwFlags) { int i; int j; int b=0; if(dwFlags & GAMEVAR_FLAG_PLONG) dwFlags|=GAMEVAR_FLAG_SYSTEM; // force system if PLONG if(strlen(pszLabel) > (MAXVARLABEL-1) ) { warningcount++; Printf(TEXTCOLOR_RED " * WARNING.(L%ld) Variable Name '%s' too int (max is %d)\n", line_number, pszLabel, MAXVARLABEL - 1); return 0; } for(i=0;i= iGameVarCount) { Printf("GetGameVarID: Invalid Game ID %d\n", id); return -1; } if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER ) { // for the current player if(sPlayer >=0 && sPlayer < MAXPLAYERS) { return aGameVars[id].plArray[sPlayer]; } else { return aGameVars[id].lValue; } } else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR ) { // for the current actor if(sActor >= 0 && sActor <=MAXSPRITES) { return aGameVars[id].plArray[sActor]; } else { return aGameVars[id].lValue; } } else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG ) { if( !aGameVars[id].plValue) { Printf("GetGameVarID NULL PlValues for PLONG Var=%s\n",aGameVars[id].szLabel); } return *aGameVars[id].plValue; } else { return aGameVars[id].lValue; } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- void SetGameVarID(int id, int lValue, int sActor, int sPlayer) { if(id<0 || id >= iGameVarCount) { Printf("Invalid Game ID %d\n", id); return; } if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER ) { // for the current player aGameVars[id].plArray[sPlayer]=lValue; } else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR ) { // for the current actor aGameVars[id].plArray[sActor]=lValue; } else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG ) { // set the value at pointer *aGameVars[id].plValue=lValue; } else { aGameVars[id].lValue=lValue; } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- int GetGameVar(const char *szGameLabel, int lDefault, int sActor, int sPlayer) { for (int i = 0; i < iGameVarCount; i++) { if (strcmp(szGameLabel, aGameVars[i].szLabel) == 0) { return GetGameVarID(i, sActor, sPlayer); } } return lDefault; } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- int *GetGameValuePtr(char *szGameLabel) { int i; for(i=0;i=MAXGAMEEVENTS) return 0; return (apScriptGameEvent[i]!=NULL); } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- void OnEvent(int iEventID, short i,short p,long x) { int og_i,og_p; int og_x; int *og_t; spritetype *og_sp; uint8_t okillit_flag; intptr_t *oinsptr; char done; if( iEventID >= MAXGAMEEVENTS) { Printf("Invalid Event ID\n"); return; } if( apScriptGameEvent[iEventID] == 0 ) { return; } // save current values... og_i=g_i; og_p=g_p; og_x=g_x; og_sp=g_sp; og_t=g_t; okillit_flag=killit_flag; oinsptr=insptr; g_i = i; // current sprite ID g_p = p; /// current player ID g_x = x; // ? g_sp = &sprite[g_i]; g_t = &hittype[g_i].temp_data[0]; insptr = (apScriptGameEvent[iEventID]); killit_flag = 0; do done = parse(); while( done == 0 ); // restore old values... g_i=og_i; g_p=og_p; g_x=og_x; g_sp=og_sp; g_t=og_t; killit_flag=okillit_flag; insptr=oinsptr; } #endif //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- int *aplWeaponClip[MAX_WEAPONS]; // number of items in clip int *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) int *aplWeaponFireDelay[MAX_WEAPONS]; // delay to fire int *aplWeaponHoldDelay[MAX_WEAPONS]; // delay after release fire button to fire (0 for none) int *aplWeaponTotalTime[MAX_WEAPONS]; // The total time the weapon is cycling before next fire. int *aplWeaponFlags[MAX_WEAPONS]; // Flags for weapon int *aplWeaponShoots[MAX_WEAPONS]; // what the weapon shoots int *aplWeaponSpawnTime[MAX_WEAPONS]; // the frame at which to spawn an item int *aplWeaponSpawn[MAX_WEAPONS]; // the item to spawn int *aplWeaponShotsPerBurst[MAX_WEAPONS]; // number of shots per 'burst' (one ammo per 'burst' int *aplWeaponWorksLike[MAX_WEAPONS]; // What original the weapon works like int *aplWeaponInitialSound[MAX_WEAPONS]; // Sound made when initialy firing. zero for no sound int *aplWeaponFireSound[MAX_WEAPONS]; // Sound made when firing (each time for automatic) int *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time int *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID int g_iReturnVarID = -1; // var ID of "RETURN" int g_iWeaponVarID = -1; // var ID of "WEAPON" int g_iWorksLikeVarID = -1; // var ID of "WORKSLIKE" int g_iZRangeVarID = -1; // var ID of "ZRANGE" int g_iAngRangeVarID = -1; // var ID of "ANGRANGE" int g_iAimAngleVarID = -1; // var ID of "AUTOAIMANGLE" int g_iAtWithVarID = -1; // var ID of "AtWith" //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- void InitGameVarPointers(void) { int i; char aszBuf[64]; // called from game Init AND when level is loaded... for(i=0;i