From 8fa5d3d9d252c4b4a7337c4d99e2cec3b7523afa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 17 Sep 2020 22:36:09 +0200 Subject: [PATCH] - added the remaining CON features from EDuke 2.x Not everything will do something, though. This was some incredibly careless code operating without a safety net allowing uncontrolled write access to the map structure. Most of the critical fields have been made read-only, which has been the only mode of access in the mods I checked. Note that this does not enable scripting of the weapon sprite drawer, only the gameplay related features were done. --- source/games/duke/src/cheats.cpp | 2 +- source/games/duke/src/condef.h | 71 + source/games/duke/src/conlabel.h | 294 ++++ source/games/duke/src/conlabeldef.h | 351 +++++ source/games/duke/src/funct.h | 1 + source/games/duke/src/gamedef.cpp | 1241 ++++++++++++++- source/games/duke/src/gameexec.cpp | 2155 ++++++++++++++++++++++++++- source/games/duke/src/gamevar.cpp | 18 + source/games/duke/src/gamevar.h | 4 + source/games/duke/src/player_d.cpp | 17 +- source/games/duke/src/premap_d.cpp | 1 + source/games/duke/src/premap_r.cpp | 1 + source/games/duke/src/savegame.cpp | 2 +- source/games/duke/src/types.h | 12 +- 14 files changed, 4135 insertions(+), 35 deletions(-) create mode 100644 source/games/duke/src/conlabel.h create mode 100644 source/games/duke/src/conlabeldef.h diff --git a/source/games/duke/src/cheats.cpp b/source/games/duke/src/cheats.cpp index a200a4046..e3839dcbd 100644 --- a/source/games/duke/src/cheats.cpp +++ b/source/games/duke/src/cheats.cpp @@ -59,7 +59,7 @@ const char *GameInterface::CheckCheatMode() static const char *cheatGod(int myconnectindex, int state) { - if (state == -1) state = 1 - ud.god; + if (state == -1) state = !ud.god; ud.god = state; sprite[ps[myconnectindex].i].extra = max_player_health; diff --git a/source/games/duke/src/condef.h b/source/games/duke/src/condef.h index 56edfe81a..cf31ebe07 100644 --- a/source/games/duke/src/condef.h +++ b/source/games/duke/src/condef.h @@ -1,3 +1,4 @@ +// original index for reference. Raze never uses literal indices anywhere and should not care about the actual numbers cmd(definelevelname) // 0 cmd(actor) // 1 cmd(addammo) // 2 @@ -171,6 +172,76 @@ cmd(motoloopsnd) // 144 cmd(ifsizedown) // 145 cmd(rndmove) // 146 +// EDuke 2.x additions +cmd(spgetlotag) // 127 +cmd(spgethitag) // 128 +cmd(sectgetlotag) // 129 +cmd(sectgethitag) // 130 +cmd(ifsound) // 131 +cmd(gettexturefloor) // 132 +cmd(gettextureceiling) // 133 +cmd(gettexturewall) // 134 +cmd(starttrack) // 135 +cmd(randvar) // 136 +cmd(enhanced) // 137 +cmd(getangletotarget) // 138 +cmd(getactorangle) // 139 +cmd(setactorangle) // 140 +cmd(mulvar) // 141 +cmd(mulvarvar) // 142 +cmd(divvar) // 143 +cmd(divvarvar) // 144 +cmd(modvar) // 145 +cmd(modvarvar) // 146 +cmd(andvar) // 147 +cmd(andvarvar) // 148 +cmd(orvar) // 149 +cmd(orvarvar) // 150 +cmd(getplayerangle) // 151 +cmd(setplayerangle) // 152 +cmd(lockplayer) // 153 +cmd(setsector) // 154 +cmd(getsector) // 155 +cmd(setactor) // 156 +cmd(getactor) // 157 +cmd(setwall) // 158 +cmd(getwall) // 159 +cmd(findnearactor) // 160 +cmd(findnearactorvar) // 161 +cmd(setactorvar) // 162 +cmd(getactorvar) // 163 +cmd(espawn) // 164 +cmd(getplayer) // 165 +cmd(setplayer) // 166 +cmd(sqrt) // 167 +cmd(eventloadactor) // 168 +cmd(espawnvar) // 169 +cmd(getuserdef) // 170 +cmd(setuserdef) // 171 +cmd(subvarvar) // 172 +cmd(subvar) // 173 +cmd(ifvarn) // 174 +cmd(ifvarvarn) // 175 +cmd(ifvarand) // 176 +cmd(ifvarvarand) // 177 +cmd(myos) // 178 +cmd(myospal) // 179 +cmd(switch) // 180 +cmd(case) // 181 +cmd(default) // 182 +cmd(endswitch) // 183 +cmd(displayrand) // 184 +cmd(sin) // 185 +cmd(xorvarvar) // 186 +cmd(xorvar) // 187 +cmd(randvarvar) // 188 +cmd(myosx) // 189 +cmd(myospalx) // 190 +cmd(gmaxammo) // 191 +cmd(smaxammo) // 192 +cmd(mapvoxel) // 193 +cmd(startlevel) // 194 + // RR Deer Huntin'. These are merely here for reference because the game is not supported. // cmd(iffindnewspot) // cmd(ifpupwind) diff --git a/source/games/duke/src/conlabel.h b/source/games/duke/src/conlabel.h new file mode 100644 index 000000000..8dac9ea85 --- /dev/null +++ b/source/games/duke/src/conlabel.h @@ -0,0 +1,294 @@ +enum +{ + PLAYER_ZOOM = 1, + PLAYER_EXITX = 2, + PLAYER_EXITY = 3, + PLAYER_LOOGIEX = 4, + PLAYER_LOOGIEY = 5, + PLAYER_NUMLOOGS = 6, + PLAYER_LOOGCNT = 7, + PLAYER_POSX = 8, + PLAYER_POSY = 9, + PLAYER_POSZ = 10, + PLAYER_HORIZ = 11, + PLAYER_OHORIZ = 12, + PLAYER_OHORIZOFF = 13, + PLAYER_INVDISPTIME = 14, + PLAYER_BOBPOSX = 15, + PLAYER_BOBPOSY = 16, + PLAYER_OPOSX = 17, + PLAYER_OPOSY = 18, + PLAYER_OPOSZ = 19, + PLAYER_PYOFF = 20, + PLAYER_OPYOFF = 21, + PLAYER_POSXV = 22, + PLAYER_POSYV = 23, + PLAYER_POSZV = 24, + PLAYER_LAST_PISSED_TIME = 25, + PLAYER_TRUEFZ = 26, + PLAYER_TRUECZ = 27, + PLAYER_PLAYER_PAR = 28, + PLAYER_VISIBILITY = 29, + PLAYER_BOBCOUNTER = 30, + PLAYER_WEAPON_SWAY = 31, + PLAYER_PALS_TIME = 32, + PLAYER_RANDOMFLAMEX = 33, + PLAYER_CRACK_TIME = 34, + PLAYER_AIM_MODE = 35, + PLAYER_ANG = 36, + PLAYER_OANG = 37, + PLAYER_ANGVEL = 38, + PLAYER_CURSECTNUM = 39, + PLAYER_LOOK_ANG = 40, + PLAYER_LAST_EXTRA = 41, + PLAYER_SUBWEAPON = 42, + PLAYER_AMMO_AMOUNT = 43, + PLAYER_WACKEDBYACTOR = 44, + PLAYER_FRAG = 45, + PLAYER_FRAGGEDSELF = 945, + PLAYER_CURR_WEAPON = 46, + PLAYER_LAST_WEAPON = 47, + PLAYER_TIPINCS = 48, + PLAYER_HORIZOFF = 49, + PLAYER_WANTWEAPONFIRE = 50, + PLAYER_HOLODUKE_AMOUNT = 51, + PLAYER_NEWOWNER = 52, + PLAYER_HURT_DELAY = 53, + PLAYER_HBOMB_HOLD_DELAY = 54, + PLAYER_JUMPING_COUNTER = 55, + PLAYER_AIRLEFT = 56, + PLAYER_KNEE_INCS = 57, + PLAYER_ACCESS_INCS = 58, + PLAYER_FTA = 59, + PLAYER_FTQ = 60, + PLAYER_ACCESS_WALLNUM = 61, + PLAYER_ACCESS_SPRITENUM = 62, + PLAYER_KICKBACK_PIC = 63, + PLAYER_GOT_ACCESS = 64, + PLAYER_WEAPON_ANG = 65, + PLAYER_FIRSTAID_AMOUNT = 66, + PLAYER_SOMETHINGONPLAYER = 67, + PLAYER_ON_CRANE = 68, + PLAYER_I = 69, + PLAYER_ONE_PARALLAX_SECTNUM = 70, + PLAYER_OVER_SHOULDER_ON = 71, + PLAYER_RANDOM_CLUB_FRAME = 72, + PLAYER_FIST_INCS = 73, + PLAYER_ONE_EIGHTY_COUNT = 74, + PLAYER_CHEAT_PHASE = 75, + PLAYER_DUMMYPLAYERSPRITE = 76, + PLAYER_EXTRA_EXTRA8 = 77, + PLAYER_QUICK_KICK = 78, + PLAYER_HEAT_AMOUNT = 79, + PLAYER_ACTORSQU = 80, + PLAYER_TIMEBEFOREEXIT = 81, + PLAYER_CUSTOMEXITSOUND = 82, + PLAYER_WEAPRECS = 83, + PLAYER_WEAPRECCNT = 84, + PLAYER_INTERFACE_TOGGLE_FLAG = 85, + PLAYER_ROTSCRNANG = 86, + PLAYER_DEAD_FLAG = 87, + PLAYER_SHOW_EMPTY_WEAPON = 88, + PLAYER_SCUBA_AMOUNT = 89, + PLAYER_JETPACK_AMOUNT = 90, + PLAYER_STEROIDS_AMOUNT = 91, + PLAYER_SHIELD_AMOUNT = 92, + PLAYER_HOLODUKE_ON = 93, + PLAYER_PYCOUNT = 94, + PLAYER_WEAPON_POS = 95, + PLAYER_FRAG_PS = 96, + PLAYER_TRANSPORTER_HOLD = 97, + PLAYER_LAST_FULL_WEAPON = 98, + PLAYER_FOOTPRINTSHADE = 99, + PLAYER_BOOT_AMOUNT = 100, + PLAYER_SCREAM_VOICE = 101, + PLAYER_GM = 102, + PLAYER_ON_WARPING_SECTOR = 103, + PLAYER_FOOTPRINTCOUNT = 104, + PLAYER_HBOMB_ON = 105, + PLAYER_JUMPING_TOGGLE = 106, + PLAYER_RAPID_FIRE_HOLD = 107, + PLAYER_ON_GROUND = 108, + PLAYER_NAME = 109, + PLAYER_INVEN_ICON = 110, + PLAYER_BUTTONPALETTE = 111, + PLAYER_JETPACK_ON = 112, + PLAYER_SPRITEBRIDGE = 113, + PLAYER_LASTRANDOMSPOT = 114, + PLAYER_SCUBA_ON = 115, + PLAYER_FOOTPRINTPAL = 116, + PLAYER_HEAT_ON = 117, + PLAYER_HOLSTER_WEAPON = 118, + PLAYER_FALLING_COUNTER = 119, + PLAYER_GOTWEAPON = 120, + PLAYER_REFRESH_INVENTORY = 121, + PLAYER_PALETTE = 122, + PLAYER_TOGGLE_KEY_FLAG = 123, + PLAYER_KNUCKLE_INCS = 124, + PLAYER_WALKING_SND_TOGGLE = 125, + PLAYER_PALOOKUP = 126, + PLAYER_HARD_LANDING = 127, + PLAYER_MAX_SECRET_ROOMS = 128, + PLAYER_SECRET_ROOMS = 129, + PLAYER_PALS = 130, + PLAYER_MAX_ACTORS_KILLED = 131, + PLAYER_ACTORS_KILLED = 132, + PLAYER_RETURN_TO_CENTER = 133, + USERDEFS_GOD = 2, + USERDEFS_WARP_ON = 3, + USERDEFS_CASHMAN = 4, + USERDEFS_EOG = 5, + USERDEFS_SHOWALLMAP = 6, + USERDEFS_SHOW_HELP = 7, + USERDEFS_SCROLLMODE = 8, + USERDEFS_CLIPPING = 9, + USERDEFS_USER_NAME = 10, + USERDEFS_RIDECULE = 11, + USERDEFS_SAVEGAME = 12, + USERDEFS_PWLOCKOUT = 13, + USERDEFS_RTSNAME = 14, + USERDEFS_OVERHEAD_ON = 15, + USERDEFS_LAST_OVERHEAD = 16, + USERDEFS_SHOWWEAPONS = 17, + USERDEFS_PAUSE_ON = 18, + USERDEFS_FROM_BONUS = 19, + USERDEFS_CAMERASPRITE = 20, + USERDEFS_LAST_CAMSPRITE = 21, + USERDEFS_LAST_LEVEL = 22, + USERDEFS_SECRETLEVEL = 23, + USERDEFS_CONST_VISIBILITY = 24, + USERDEFS_UW_FRAMERATE = 25, + USERDEFS_CAMERA_TIME = 26, + USERDEFS_FOLFVEL = 27, + USERDEFS_FOLAVEL = 28, + USERDEFS_FOLX = 29, + USERDEFS_FOLY = 30, + USERDEFS_FOLA = 31, + USERDEFS_RECCNT = 32, + USERDEFS_ENTERED_NAME = 33, + USERDEFS_SCREEN_TILTING = 34, + USERDEFS_SHADOWS = 35, + USERDEFS_FTA_ON = 36, + USERDEFS_EXECUTIONS = 37, + USERDEFS_AUTO_RUN = 38, + USERDEFS_COORDS = 39, + USERDEFS_TICKRATE = 40, + USERDEFS_M_COOP = 41, + USERDEFS_COOP = 42, + USERDEFS_SCREEN_SIZE = 43, + USERDEFS_LOCKOUT = 44, + USERDEFS_CROSSHAIR = 45, + USERDEFS_WCHOICE = 46, + USERDEFS_PLAYERAI = 47, + USERDEFS_RESPAWN_MONSTERS = 48, + USERDEFS_RESPAWN_ITEMS = 49, + USERDEFS_RESPAWN_INVENTORY = 50, + USERDEFS_RECSTAT = 51, + USERDEFS_MONSTERS_OFF = 52, + USERDEFS_BRIGHTNESS = 53, + USERDEFS_M_RESPAWN_ITEMS = 54, + USERDEFS_M_RESPAWN_MONSTERS = 55, + USERDEFS_M_RESPAWN_INVENTORY = 56, + USERDEFS_M_RECSTAT = 57, + USERDEFS_M_MONSTERS_OFF = 58, + USERDEFS_DETAIL = 59, + USERDEFS_M_FFIRE = 60, + USERDEFS_FFIRE = 61, + USERDEFS_M_PLAYER_SKILL = 62, + USERDEFS_M_LEVEL_NUMBER = 63, + USERDEFS_M_VOLUME_NUMBER = 64, + USERDEFS_MULTIMODE = 65, + USERDEFS_PLAYER_SKILL = 66, + USERDEFS_LEVEL_NUMBER = 67, + USERDEFS_VOLUME_NUMBER = 68, + USERDEFS_M_MARKER = 69, + USERDEFS_MARKER = 70, + USERDEFS_MOUSEFLIP = 71, + SECTOR_WALLPTR = 1, + SECTOR_WALLNUM = 2, + SECTOR_CEILINGZ = 3, + SECTOR_FLOORZ = 4, + SECTOR_CEILINGSTAT = 5, + SECTOR_FLOORSTAT = 6, + SECTOR_CEILINGPICNUM = 7, + SECTOR_CEILINGSLOPE = 8, + SECTOR_CEILINGSHADE = 9, + SECTOR_CEILINGPAL = 10, + SECTOR_CEILINGXPANNING = 11, + SECTOR_CEILINGYPANNING = 12, + SECTOR_FLOORPICNUM = 13, + SECTOR_FLOORSLOPE = 14, + SECTOR_FLOORSHADE = 15, + SECTOR_FLOORPAL = 16, + SECTOR_FLOORXPANNING = 17, + SECTOR_FLOORYPANNING = 18, + SECTOR_VISIBILITY = 19, + SECTOR_ALIGNTO = 20, + SECTOR_LOTAG = 21, + SECTOR_HITAG = 22, + SECTOR_EXTRA = 23, + WALL_X = 1, + WALL_Y = 2, + WALL_POINT2 = 3, + WALL_NEXTWALL = 4, + WALL_NEXTSECTOR = 5, + WALL_CSTAT = 6, + WALL_PICNUM = 7, + WALL_OVERPICNUM = 8, + WALL_SHADE = 9, + WALL_PAL = 10, + WALL_XREPEAT = 11, + WALL_YREPEAT = 12, + WALL_XPANNING = 13, + WALL_YPANNING = 14, + WALL_LOTAG = 15, + WALL_HITAG = 16, + WALL_EXTRA = 17, + ACTOR_X = 1, + ACTOR_Y = 2, + ACTOR_Z = 3, + ACTOR_CSTAT = 4, + ACTOR_PICNUM = 5, + ACTOR_SHADE = 6, + ACTOR_PAL = 7, + ACTOR_CLIPDIST = 8, + ACTOR_DETAIL = 9, + ACTOR_XREPEAT = 10, + ACTOR_YREPEAT = 11, + ACTOR_XOFFSET = 12, + ACTOR_YOFFSET = 13, + ACTOR_SECTNUM = 14, + ACTOR_STATNUM = 15, + ACTOR_ANG = 16, + ACTOR_OWNER = 17, + ACTOR_XVEL = 18, + ACTOR_YVEL = 19, + ACTOR_ZVEL = 20, + ACTOR_LOTAG = 21, + ACTOR_HITAG = 22, + ACTOR_EXTRA = 23, + ACTOR_HTCGG = 50, + ACTOR_HTPICNUM = 51, + ACTOR_HTANG = 52, + ACTOR_HTEXTRA = 53, + ACTOR_HTOWNER = 54, + ACTOR_HTMOVFLAG = 55, + ACTOR_HTTEMPANG = 56, + ACTOR_HTACTORSTAYPUT = 57, + ACTOR_HTDISPICNUM = 58, + ACTOR_HTTIMETOSLEEP = 59, + ACTOR_HTFLOORZ = 60, + ACTOR_HTCEILINGZ = 61, + ACTOR_HTLASTVX = 62, + ACTOR_HTLASTVY = 63, + ACTOR_HTBPOSX = 64, + ACTOR_HTBPOSY = 65, + ACTOR_HTBPOSZ = 66, + ACTOR_HTG_T0 = 67, + ACTOR_HTG_T1 = 68, + ACTOR_HTG_T2 = 69, + ACTOR_HTG_T3 = 70, + ACTOR_HTG_T4 = 71, + ACTOR_HTG_T5 = 72, + ACTOR_HTG_T = 73, +}; diff --git a/source/games/duke/src/conlabeldef.h b/source/games/duke/src/conlabeldef.h new file mode 100644 index 000000000..a842c4cee --- /dev/null +++ b/source/games/duke/src/conlabeldef.h @@ -0,0 +1,351 @@ +#include "names.h" + +BEGIN_DUKE_NS +enum +{ + LABEL_HASPARM2= 1, + LABEL_ISSTRING= 2 +}; + +struct LABELS +{ + const char *name; + int lId; + int flags; + int maxParm2; +}; + +LABELS sectorlabels[]= + { + { "wallptr", SECTOR_WALLPTR, 0, 0 }, + { "wallnum", SECTOR_WALLNUM, 0, 0 }, + { "ceilingz", SECTOR_CEILINGZ, 0, 0 }, + { "floorz", SECTOR_FLOORZ, 0, 0 }, + { "ceilingstat", SECTOR_CEILINGSTAT, 0, 0 }, + { "floorstat", SECTOR_FLOORSTAT, 0, 0 }, + { "ceilingpicnum", SECTOR_CEILINGPICNUM, 0, 0 }, + { "ceilingslope", SECTOR_CEILINGSLOPE, 0, 0 }, + { "ceilingshade", SECTOR_CEILINGSHADE, 0, 0 }, + { "ceilingpal", SECTOR_CEILINGPAL, 0, 0 }, + { "ceilingxpanning", SECTOR_CEILINGXPANNING, 0, 0 }, + { "ceilingypanning", SECTOR_CEILINGYPANNING, 0, 0 }, + { "floorpicnum", SECTOR_FLOORPICNUM, 0, 0 }, + { "floorslope", SECTOR_FLOORSLOPE, 0, 0 }, + { "floorshade", SECTOR_FLOORSHADE, 0, 0 }, + { "floorpal", SECTOR_FLOORPAL, 0, 0 }, + { "floorxpanning", SECTOR_FLOORXPANNING, 0, 0 }, + { "floorypanning", SECTOR_FLOORYPANNING, 0, 0 }, + { "visibility", SECTOR_VISIBILITY, 0, 0 }, + { "lotag", SECTOR_LOTAG, 0, 0 }, + { "hitag", SECTOR_HITAG, 0, 0 }, + { "extra", SECTOR_EXTRA, 0, 0 }, + + { "", -1, 0, 0 } // END OF LIST + }; + +LABELS walllabels[]= +{ + { "x", WALL_X, 0, 0 }, + { "y", WALL_Y, 0, 0 }, + { "point2", WALL_POINT2, 0, 0 }, + { "nextwall", WALL_NEXTWALL, 0, 0 }, + { "nextsector", WALL_NEXTSECTOR, 0, 0 }, + { "cstat", WALL_CSTAT, 0, 0 }, + { "picnum", WALL_PICNUM, 0, 0 }, + { "overpicnum", WALL_OVERPICNUM, 0, 0 }, + { "shade", WALL_SHADE, 0, 0 }, + { "pal", WALL_PAL, 0, 0 }, + { "xrepeat", WALL_XREPEAT, 0, 0 }, + { "yrepeat", WALL_YREPEAT, 0, 0 }, + { "xpanning", WALL_XPANNING, 0, 0 }, + { "ypanning", WALL_YPANNING, 0, 0 }, + { "lotag", WALL_LOTAG, 0, 0 }, + { "hitag", WALL_HITAG, 0, 0 }, + { "extra", WALL_EXTRA, 0, 0 }, + + { "", -1, 0, 0 } // END OF LIST + +}; + +LABELS actorlabels[]= +{ + { "x", ACTOR_X, 0, 0 }, + { "y", ACTOR_Y, 0, 0 }, + { "z", ACTOR_Z, 0, 0 }, + { "cstat", ACTOR_CSTAT, 0, 0 }, + { "picnum", ACTOR_PICNUM, 0, 0 }, + { "shade", ACTOR_SHADE, 0, 0 }, + { "pal", ACTOR_PAL, 0, 0 }, + { "clipdist", ACTOR_CLIPDIST, 0, 0 }, + { "detail", ACTOR_DETAIL, 0, 0 }, + { "xrepeat", ACTOR_XREPEAT, 0, 0 }, + { "yrepeat", ACTOR_YREPEAT, 0, 0 }, + { "xoffset", ACTOR_XOFFSET, 0, 0 }, + { "yoffset", ACTOR_YOFFSET, 0, 0 }, + { "sectnum", ACTOR_SECTNUM, 0, 0 }, + { "statnum", ACTOR_STATNUM, 0, 0 }, + { "ang", ACTOR_ANG, 0, 0 }, + { "owner", ACTOR_OWNER, 0, 0 }, + { "xvel", ACTOR_XVEL, 0, 0 }, + { "yvel", ACTOR_YVEL, 0, 0 }, + { "zvel", ACTOR_ZVEL, 0, 0 }, + { "lotag", ACTOR_LOTAG, 0, 0 }, + { "hitag", ACTOR_HITAG, 0, 0 }, + { "extra", ACTOR_EXTRA, 0, 0 }, + + // hittype labels... + { "htcgg", ACTOR_HTCGG, 0, 0 }, + { "htpicnum", ACTOR_HTPICNUM, 0, 0 }, + { "htang", ACTOR_HTANG, 0, 0 }, + { "htextra", ACTOR_HTEXTRA, 0, 0 }, + { "htowner", ACTOR_HTOWNER, 0, 0 }, + { "htmovflag", ACTOR_HTMOVFLAG, 0, 0 }, + { "httempang", ACTOR_HTTEMPANG, 0, 0 }, + { "htactorstayput", ACTOR_HTACTORSTAYPUT, 0, 0 }, + { "htdispicnum", ACTOR_HTDISPICNUM, 0, 0 }, + { "httimetosleep", ACTOR_HTTIMETOSLEEP, 0, 0 }, + { "htfloorz", ACTOR_HTFLOORZ, 0, 0 }, + { "htceilingz", ACTOR_HTCEILINGZ, 0, 0 }, + { "htlastvx", ACTOR_HTLASTVX, 0, 0 }, + { "htlastvy", ACTOR_HTLASTVY, 0, 0 }, + { "htbposx", ACTOR_HTBPOSX, 0, 0 }, + { "htbposy", ACTOR_HTBPOSY, 0, 0 }, + { "htbposz", ACTOR_HTBPOSZ, 0, 0 }, + { "htg_t", ACTOR_HTG_T, LABEL_HASPARM2, 5 }, + { "htg_t[0]", ACTOR_HTG_T0, 0, 0 }, + { "htg_t[1]", ACTOR_HTG_T1, 0, 0 }, + { "htg_t[2]", ACTOR_HTG_T2, 0, 0 }, + { "htg_t[3]", ACTOR_HTG_T3, 0, 0 }, + { "htg_t[4]", ACTOR_HTG_T4, 0, 0 }, + { "htg_t[5]", ACTOR_HTG_T5, 0, 0 }, + + { "", -1, 0, 0 } // END OF LIST + +}; + + +////////////////////////////////// + +LABELS playerlabels[]= +{ + { "zoom", PLAYER_ZOOM, 0, 0 }, + { "exitx", PLAYER_EXITX, 0, 0 }, + { "exity", PLAYER_EXITY, 0, 0 }, + { "loogiex", PLAYER_LOOGIEX, LABEL_HASPARM2, 64 }, + { "loogiey", PLAYER_LOOGIEY, LABEL_HASPARM2, 64 }, + { "numloogs", PLAYER_NUMLOOGS, 0, 0 }, + { "loogcnt", PLAYER_LOOGCNT, 0, 0 }, + { "posx", PLAYER_POSX, 0, 0 }, + { "posy", PLAYER_POSY, 0, 0 }, + { "posz", PLAYER_POSZ, 0, 0 }, + { "horiz", PLAYER_HORIZ, 0, 0 }, + { "ohoriz", PLAYER_OHORIZ, 0, 0 }, + { "ohorizoff", PLAYER_OHORIZOFF, 0, 0 }, + { "invdisptime", PLAYER_INVDISPTIME, 0, 0 }, + { "bobposx", PLAYER_BOBPOSX, 0, 0 }, + { "bobposy", PLAYER_BOBPOSY, 0, 0 }, + { "oposx", PLAYER_OPOSX, 0, 0 }, + { "oposy", PLAYER_OPOSY, 0, 0 }, + { "oposz", PLAYER_OPOSZ, 0, 0 }, + { "pyoff", PLAYER_PYOFF, 0, 0 }, + { "opyoff", PLAYER_OPYOFF, 0, 0 }, + { "posxv", PLAYER_POSXV, 0, 0 }, + { "posyv", PLAYER_POSYV, 0, 0 }, + { "poszv", PLAYER_POSZV, 0, 0 }, + { "last_pissed_time", PLAYER_LAST_PISSED_TIME, 0, 0 }, + { "truefz", PLAYER_TRUEFZ, 0, 0 }, + { "truecz", PLAYER_TRUECZ, 0, 0 }, + { "player_par", PLAYER_PLAYER_PAR, 0, 0 }, + { "visibility", PLAYER_VISIBILITY, 0, 0 }, + { "bobcounter", PLAYER_BOBCOUNTER, 0, 0 }, + { "weapon_sway", PLAYER_WEAPON_SWAY, 0, 0 }, + { "pals_time", PLAYER_PALS_TIME, 0, 0 }, + { "randomflamex", PLAYER_RANDOMFLAMEX, 0, 0 }, + { "crack_time", PLAYER_CRACK_TIME, 0, 0 }, + { "aim_mode", PLAYER_AIM_MODE, 0, 0 }, + { "ang", PLAYER_ANG, 0, 0 }, + { "oang", PLAYER_OANG, 0, 0 }, + { "angvel", PLAYER_ANGVEL, 0, 0 }, + { "cursectnum", PLAYER_CURSECTNUM, 0, 0 }, + { "look_ang", PLAYER_LOOK_ANG, 0, 0 }, + { "last_extra", PLAYER_LAST_EXTRA, 0, 0 }, + { "subweapon", PLAYER_SUBWEAPON, 0, 0 }, + { "ammo_amount", PLAYER_AMMO_AMOUNT, LABEL_HASPARM2, MAX_WEAPONS }, + { "wackedbyactor", PLAYER_WACKEDBYACTOR, 0, 0 }, + { "frag", PLAYER_FRAG, 0, 0 }, + { "fraggedself", PLAYER_FRAGGEDSELF, 0, 0 }, + { "curr_weapon", PLAYER_CURR_WEAPON, 0, 0 }, + { "last_weapon", PLAYER_LAST_WEAPON, 0, 0 }, + { "tipincs", PLAYER_TIPINCS, 0, 0 }, + { "horizoff", PLAYER_HORIZOFF, 0, 0 }, + { "wantweaponfire", PLAYER_WANTWEAPONFIRE, 0, 0 }, + { "holoduke_amount", PLAYER_HOLODUKE_AMOUNT, 0, 0 }, + { "newowner", PLAYER_NEWOWNER, 0, 0 }, + { "hurt_delay", PLAYER_HURT_DELAY, 0, 0 }, + { "hbomb_hold_delay", PLAYER_HBOMB_HOLD_DELAY, 0, 0 }, + { "jumping_counter", PLAYER_JUMPING_COUNTER, 0, 0 }, + { "airleft", PLAYER_AIRLEFT, 0, 0 }, + { "knee_incs", PLAYER_KNEE_INCS, 0, 0 }, + { "access_incs", PLAYER_ACCESS_INCS, 0, 0 }, + { "fta", PLAYER_FTA, 0, 0 }, + { "ftq", PLAYER_FTQ, 0, 0 }, + { "access_wallnum", PLAYER_ACCESS_WALLNUM, 0, 0 }, + { "access_spritenum", PLAYER_ACCESS_SPRITENUM, 0, 0 }, + { "kickback_pic", PLAYER_KICKBACK_PIC, 0, 0 }, + { "got_access", PLAYER_GOT_ACCESS, 0, 0 }, + { "weapon_ang", PLAYER_WEAPON_ANG, 0, 0 }, + { "firstaid_amount", PLAYER_FIRSTAID_AMOUNT, 0, 0 }, + { "somethingonplayer", PLAYER_SOMETHINGONPLAYER, 0, 0 }, + { "on_crane", PLAYER_ON_CRANE, 0, 0 }, + { "i", PLAYER_I, 0, 0 }, + { "one_parallax_sectnum", PLAYER_ONE_PARALLAX_SECTNUM, 0, 0 }, + { "over_shoulder_on", PLAYER_OVER_SHOULDER_ON, 0, 0 }, + { "random_club_frame", PLAYER_RANDOM_CLUB_FRAME, 0, 0 }, + { "fist_incs", PLAYER_FIST_INCS, 0, 0 }, + { "one_eighty_count", PLAYER_ONE_EIGHTY_COUNT, 0, 0 }, + { "cheat_phase", PLAYER_CHEAT_PHASE, 0, 0 }, + { "dummyplayersprite", PLAYER_DUMMYPLAYERSPRITE, 0, 0 }, + { "extra_extra8", PLAYER_EXTRA_EXTRA8, 0, 0 }, + { "quick_kick", PLAYER_QUICK_KICK, 0, 0 }, + { "heat_amount", PLAYER_HEAT_AMOUNT, 0, 0 }, + { "actorsqu", PLAYER_ACTORSQU, 0, 0 }, + { "timebeforeexit", PLAYER_TIMEBEFOREEXIT, 0, 0 }, + { "customexitsound", PLAYER_CUSTOMEXITSOUND, 0, 0 }, + { "weaprecs", PLAYER_WEAPRECS, LABEL_HASPARM2, 256 }, + { "weapreccnt", PLAYER_WEAPRECCNT, 0, 0 }, + { "interface_toggle_flag", PLAYER_INTERFACE_TOGGLE_FLAG, 0, 0 }, + { "rotscrnang", PLAYER_ROTSCRNANG, 0, 0 }, + { "dead_flag", PLAYER_DEAD_FLAG, 0, 0 }, + { "show_empty_weapon", PLAYER_SHOW_EMPTY_WEAPON, 0, 0 }, + { "scuba_amount", PLAYER_SCUBA_AMOUNT, 0, 0 }, + { "jetpack_amount", PLAYER_JETPACK_AMOUNT, 0, 0 }, + { "steroids_amount", PLAYER_STEROIDS_AMOUNT, 0, 0 }, + { "shield_amount", PLAYER_SHIELD_AMOUNT, 0, 0 }, + { "holoduke_on", PLAYER_HOLODUKE_ON, 0, 0 }, + { "pycount", PLAYER_PYCOUNT, 0, 0 }, + { "weapon_pos", PLAYER_WEAPON_POS, 0, 0 }, + { "frag_ps", PLAYER_FRAG_PS, 0, 0 }, + { "transporter_hold", PLAYER_TRANSPORTER_HOLD, 0, 0 }, + { "last_full_weapon", PLAYER_LAST_FULL_WEAPON, 0, 0 }, + { "footprintshade", PLAYER_FOOTPRINTSHADE, 0, 0 }, + { "boot_amount", PLAYER_BOOT_AMOUNT, 0, 0 }, + { "scream_voice", PLAYER_SCREAM_VOICE, 0, 0 }, + { "gm", PLAYER_GM, 0, 0 }, + { "on_warping_sector", PLAYER_ON_WARPING_SECTOR, 0, 0 }, + { "footprintcount", PLAYER_FOOTPRINTCOUNT, 0, 0 }, + { "hbomb_on", PLAYER_HBOMB_ON, 0, 0 }, + { "jumping_toggle", PLAYER_JUMPING_TOGGLE, 0, 0 }, + { "rapid_fire_hold", PLAYER_RAPID_FIRE_HOLD, 0, 0 }, + { "on_ground", PLAYER_ON_GROUND, 0, 0 }, + { "name", PLAYER_NAME, LABEL_ISSTRING, 32 }, + { "inven_icon", PLAYER_INVEN_ICON, 0, 0 }, + { "buttonpalette", PLAYER_BUTTONPALETTE, 0, 0 }, + { "jetpack_on", PLAYER_JETPACK_ON, 0, 0 }, + { "spritebridge", PLAYER_SPRITEBRIDGE, 0, 0 }, + { "lastrandomspot", PLAYER_LASTRANDOMSPOT, 0, 0 }, + { "scuba_on", PLAYER_SCUBA_ON, 0, 0 }, + { "footprintpal", PLAYER_FOOTPRINTPAL, 0, 0 }, + { "heat_on", PLAYER_HEAT_ON, 0, 0 }, + { "holster_weapon", PLAYER_HOLSTER_WEAPON, 0, 0 }, + { "falling_counter", PLAYER_FALLING_COUNTER, 0, 0 }, + { "gotweapon", PLAYER_GOTWEAPON, LABEL_HASPARM2, MAX_WEAPONS }, + { "refresh_inventory", PLAYER_REFRESH_INVENTORY, 0, 0 }, + { "palette", PLAYER_PALETTE, 0, 0 }, + { "toggle_key_flag", PLAYER_TOGGLE_KEY_FLAG, 0, 0 }, + { "knuckle_incs", PLAYER_KNUCKLE_INCS, 0, 0 }, + { "walking_snd_toggle", PLAYER_WALKING_SND_TOGGLE, 0, 0 }, + { "palookup", PLAYER_PALOOKUP, 0, 0 }, + { "hard_landing", PLAYER_HARD_LANDING, 0, 0 }, + { "max_secret_rooms", PLAYER_MAX_SECRET_ROOMS, 0, 0 }, + { "secret_rooms", PLAYER_SECRET_ROOMS, 0, 0 }, + { "pals", PLAYER_PALS, LABEL_HASPARM2, 3 }, + { "max_actors_killed", PLAYER_MAX_ACTORS_KILLED, 0, 0 }, + { "actors_killed", PLAYER_ACTORS_KILLED, 0, 0 }, + { "return_to_center", PLAYER_RETURN_TO_CENTER, 0, 0 }, + + { "", -1, 0, 0 } // END OF LIST + +}; + +/////////////////////////////////////// + +LABELS userdefslabels[]= +{ + { "god", USERDEFS_GOD, 0, 0 }, + { "warp_on", USERDEFS_WARP_ON, 0, 0 }, + { "cashman", USERDEFS_CASHMAN, 0, 0 }, + { "eog", USERDEFS_EOG, 0, 0 }, + { "showallmap", USERDEFS_SHOWALLMAP, 0, 0 }, + { "show_help", USERDEFS_SHOW_HELP, 0, 0 }, + { "scrollmode", USERDEFS_SCROLLMODE, 0, 0 }, + { "clipping", USERDEFS_CLIPPING, 0, 0 }, + { "user_name", USERDEFS_USER_NAME, LABEL_HASPARM2, MAXPLAYERS }, + { "ridecule", USERDEFS_RIDECULE, LABEL_HASPARM2 | LABEL_ISSTRING, 10 }, + { "savegame", USERDEFS_SAVEGAME, LABEL_HASPARM2 | LABEL_ISSTRING, 10 }, + { "pwlockout", USERDEFS_PWLOCKOUT, LABEL_ISSTRING, 128 }, + { "rtsname;", USERDEFS_RTSNAME, LABEL_ISSTRING, 128 }, + { "overhead_on", USERDEFS_OVERHEAD_ON, 0, 0 }, + { "last_overhead", USERDEFS_LAST_OVERHEAD, 0, 0 }, + { "showweapons", USERDEFS_SHOWWEAPONS, 0, 0 }, + + { "pause_on", USERDEFS_PAUSE_ON, 0, 0 }, + { "from_bonus", USERDEFS_FROM_BONUS, 0, 0 }, + { "camerasprite", USERDEFS_CAMERASPRITE, 0, 0 }, + { "last_camsprite", USERDEFS_LAST_CAMSPRITE, 0, 0 }, + { "last_level", USERDEFS_LAST_LEVEL, 0, 0 }, + { "secretlevel", USERDEFS_SECRETLEVEL, 0, 0 }, + + { "const_visibility", USERDEFS_CONST_VISIBILITY, 0, 0 }, + { "uw_framerate", USERDEFS_UW_FRAMERATE, 0, 0 }, + { "camera_time", USERDEFS_CAMERA_TIME, 0, 0 }, + { "folfvel", USERDEFS_FOLFVEL, 0, 0 }, + { "folavel", USERDEFS_FOLAVEL, 0, 0 }, + { "folx", USERDEFS_FOLX, 0, 0 }, + { "foly", USERDEFS_FOLY, 0, 0 }, + { "fola", USERDEFS_FOLA, 0, 0 }, + { "reccnt", USERDEFS_RECCNT, 0, 0 }, + + { "entered_name", USERDEFS_ENTERED_NAME, 0, 0 }, + { "screen_tilting", USERDEFS_SCREEN_TILTING, 0, 0 }, + { "shadows", USERDEFS_SHADOWS, 0, 0 }, + { "fta_on", USERDEFS_FTA_ON, 0, 0 }, + { "executions", USERDEFS_EXECUTIONS, 0, 0 }, + { "auto_run", USERDEFS_AUTO_RUN, 0, 0 }, + { "coords", USERDEFS_COORDS, 0, 0 }, + { "tickrate", USERDEFS_TICKRATE, 0, 0 }, + { "m_coop", USERDEFS_M_COOP, 0, 0 }, + { "coop", USERDEFS_COOP, 0, 0 }, + { "screen_size", USERDEFS_SCREEN_SIZE, 0, 0 }, + { "lockout", USERDEFS_LOCKOUT, 0, 0 }, + { "crosshair", USERDEFS_CROSSHAIR, 0, 0 }, + { "wchoice[MAXPLAYERS][MAX_WEAPONS]", USERDEFS_WCHOICE, 0, 0 }, + { "playerai", USERDEFS_PLAYERAI, 0, 0 }, + { "respawn_monsters", USERDEFS_RESPAWN_MONSTERS, 0, 0 }, + { "respawn_items", USERDEFS_RESPAWN_ITEMS, 0, 0 }, + { "respawn_inventory", USERDEFS_RESPAWN_INVENTORY, 0, 0 }, + { "recstat", USERDEFS_RECSTAT, 0, 0 }, + { "monsters_off", USERDEFS_MONSTERS_OFF, 0, 0 }, + { "brightness", USERDEFS_BRIGHTNESS, 0, 0 }, + { "m_respawn_items", USERDEFS_M_RESPAWN_ITEMS, 0, 0 }, + { "m_respawn_monsters", USERDEFS_M_RESPAWN_MONSTERS, 0, 0 }, + { "m_respawn_inventory", USERDEFS_M_RESPAWN_INVENTORY, 0, 0 }, + { "m_recstat", USERDEFS_M_RECSTAT, 0, 0 }, + { "m_monsters_off", USERDEFS_M_MONSTERS_OFF, 0, 0 }, + { "detail", USERDEFS_DETAIL, 0, 0 }, + { "m_ffire", USERDEFS_M_FFIRE, 0, 0 }, + { "ffire", USERDEFS_FFIRE, 0, 0 }, + { "m_player_skill", USERDEFS_M_PLAYER_SKILL, 0, 0 }, + { "m_level_number", USERDEFS_M_LEVEL_NUMBER, 0, 0 }, + { "m_volume_number", USERDEFS_M_VOLUME_NUMBER, 0, 0 }, + { "multimode", USERDEFS_MULTIMODE, 0, 0 }, + { "player_skill", USERDEFS_PLAYER_SKILL, 0, 0 }, + { "level_number", USERDEFS_LEVEL_NUMBER, 0, 0 }, + { "volume_number", USERDEFS_VOLUME_NUMBER, 0, 0 }, + { "m_marker", USERDEFS_M_MARKER, 0, 0 }, + { "marker", USERDEFS_MARKER, 0, 0 }, + { "mouseflip", USERDEFS_MOUSEFLIP, 0, 0 }, + + { "", -1, 0, 0 } // END OF LIST + +}; +END_DUKE_NS diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 23b0767fa..8a857584c 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -160,6 +160,7 @@ void clearcamera(player_struct* ps); void showtwoscreens(const CompletionFunc& func); void doorders(const CompletionFunc& func); +void LoadActor(int i, int p, int x); void execute(int s, int p, int d); void makeitfall(int s); int furthestangle(int snum, int angDiv); diff --git a/source/games/duke/src/gamedef.cpp b/source/games/duke/src/gamedef.cpp index e1d18a314..f81ebacc7 100644 --- a/source/games/duke/src/gamedef.cpp +++ b/source/games/duke/src/gamedef.cpp @@ -44,9 +44,13 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "global.h" #include "m_argv.h" #include "sounds.h" +#include "conlabel.h" +#include "conlabeldef.h" BEGIN_DUKE_NS +#define VERSIONCHECK 41 + //--------------------------------------------------------------------------- // @@ -103,11 +107,15 @@ class ConCompiler int parsing_state = 0; int num_squigilly_brackets = 0; int checking_ifelse = 0; + int checking_switch = 0; labelstring parselabel= {}; // This is for situations where the music gets defined before the map. Since the map records do not exist yet, we need a temporary buffer. TArray tempMusic; char parsebuf[1024]; TArray parsebuffer; // global so that the storage is persistent across calls. + int casecount = 0; + int casescriptptr; + void ReportError(int error); int getkeyword(const char* text); @@ -126,6 +134,9 @@ class ConCompiler void checkforkeyword(); int parsecommand(); + // EDuke 2.x additions + int CountCaseStatements(); + public: void compilecon(const char* filenam); void setmusic(); @@ -217,6 +228,7 @@ enum ERROR_OPENBRACKET, ERROR_CLOSEBRACKET, ERROR_NOENDSWITCH, + ERROR_SYMBOLNOTRECOGNIZED }; void ConCompiler::ReportError(int error) @@ -264,6 +276,10 @@ void ConCompiler::ReportError(int error) Printf(TEXTCOLOR_RED " * ERROR! (%s, line %d) Did not find endswitch before '%s'.\n", fn, line_number, parsebuf); break; + case ERROR_SYMBOLNOTRECOGNIZED: + Printf(TEXTCOLOR_RED " * ERROR! (%s, line %d) Symbol '%s' is not recognized.\n", + fn, line_number, parsebuf); + break; } } @@ -462,6 +478,29 @@ int ConCompiler::keyword(void) return getkeyword(parsebuf); } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static int getlabeloffset(LABELS* pLabel, const char* psz) +{ + // find the label psz in the table pLabel. + // returns the offset in the array for the label, or -1 + long l = -1; + int i; + + for (i = 0; pLabel[i].lId >= 0; i++) + { + if (!stricmp(pLabel[i].name, psz)) + { + // printf("Label has flags of %02X\n",pLabel[i].flags); + return i; + } + } + return -1; +} //--------------------------------------------------------------------------- // @@ -484,7 +523,7 @@ void ConCompiler::getlabel(void) } i = 0; - while (ispecial(*textptr) == 0) + while (ispecial(*textptr) == 0 && *textptr != ']') parselabel[i++] = *(textptr++); parselabel[i] = 0; @@ -722,6 +761,47 @@ void ConCompiler::checkforkeyword() // //--------------------------------------------------------------------------- +int ConCompiler::CountCaseStatements() +{ + int lCount; + char* temptextptr; + int savescript; + int savecase; + int temp_line_number; + + + temp_line_number = line_number; + + casecount = 0; + temptextptr = textptr; + savescript = scriptpos(); + savecase = casescriptptr; + casescriptptr = 0; + while (parsecommand() == 0) + { + ; + } + // since we processed the endswitch, we need to re-increment checking_switch + checking_switch++; + + textptr = temptextptr; + + ScriptCode.Resize(savescript); + + line_number = temp_line_number; + + lCount = casecount; + casecount = 0; + casescriptptr = savecase; + return lCount; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + int ConCompiler::parsecommand() { const char* fn = fileSystem.GetFileFullName(currentsourcefile); @@ -796,7 +876,7 @@ int ConCompiler::parsecommand() // defines var1 and sets initial value. // flags are used to define usage // (see top of this files for flags) - getlabel(); //GetGameVarLabel(); + getlabel(); // Check to see it's already defined popscriptvalue(); @@ -1230,6 +1310,7 @@ int ConCompiler::parsecommand() case concmd_isdrunk: case concmd_iseat: case concmd_newpic: + case concmd_espawn: transnum(LABEL_DEFINE); return 0; @@ -1271,12 +1352,20 @@ int ConCompiler::parsecommand() return 0; case concmd_setvar: case concmd_addvar: + case concmd_subvar: + case concmd_randvar: + case concmd_mulvar: + case concmd_divvar: + case concmd_modvar: + case concmd_andvar: + case concmd_orvar: + case concmd_xorvar: // syntax: [rand|add|set]var // sets var1 to const1 // adds const1 to var1 (const1 can be negative...) // get the ID of the DEF - getlabel(); //GetGameVarLabel(); + getlabel(); // Check to see if it's a keyword checkforkeyword(); @@ -1302,12 +1391,23 @@ int ConCompiler::parsecommand() case concmd_setvarvar: case concmd_addvarvar: + case concmd_subvarvar: + case concmd_mulvarvar: + case concmd_divvarvar: + case concmd_modvarvar: + case concmd_andvarvar: + case concmd_orvarvar: + case concmd_xorvarvar: + case concmd_randvarvar: + case concmd_sin: + case concmd_gmaxammo: + case concmd_smaxammo: // syntax: [add|set]varvar // sets var1 = var2 // adds var1 and var2 with result in var1 // get the ID of the DEF - getlabel(); //GetGameVarLabel(); + getlabel(); checkforkeyword(); @@ -1328,7 +1428,7 @@ int ConCompiler::parsecommand() appendscriptvalue(i); // the ID of the DEF (offset into array...) // get the ID of the DEF - getlabel(); //GetGameVarLabel(); + getlabel(); checkforkeyword(); i = GetDefID(parselabel); @@ -1345,9 +1445,11 @@ int ConCompiler::parsecommand() case concmd_ifvarvarg: case concmd_ifvarvarl: case concmd_ifvarvare: + case concmd_ifvarvarn: + case concmd_ifvarvarand: // get the ID of the DEF - getlabel(); //GetGameVarLabel(); + getlabel(); checkforkeyword(); @@ -1361,7 +1463,7 @@ int ConCompiler::parsecommand() appendscriptvalue(i); // the ID of the DEF (offset into array...) // get the ID of the DEF - getlabel(); //GetGameVarLabel(); + getlabel(); checkforkeyword(); @@ -1378,9 +1480,11 @@ int ConCompiler::parsecommand() case concmd_ifvarl: case concmd_ifvarg: case concmd_ifvare: + case concmd_ifvarn: + case concmd_ifvarand: // get the ID of the DEF - getlabel(); //GetGameVarLabel(); + getlabel(); checkforkeyword(); i = GetDefID(parselabel); @@ -1402,7 +1506,7 @@ int ConCompiler::parsecommand() appendscriptvalue(line_number); // get the ID of the DEF - getlabel(); //GetGameVarLabel(); + getlabel(); checkforkeyword(); @@ -1437,6 +1541,10 @@ int ConCompiler::parsecommand() appendscriptvalue(j); goto if_common; + case concmd_ifsound: + transnum(LABEL_DEFINE); + goto if_common; + case concmd_ifpinventory: transnum(LABEL_DEFINE); case concmd_ifrnd: @@ -1711,6 +1819,10 @@ int ConCompiler::parsecommand() return 0; case concmd_break: + if (checking_switch) + { + return 1; + } case concmd_fall: case concmd_tip: // case 21: @@ -1817,6 +1929,1117 @@ int ConCompiler::parsecommand() } return 0; } + + case concmd_eventloadactor: + { + if (parsing_state) + { + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) Found 'eventloadactor' within 'state'.\n", fn, line_number); + errorcount++; + } + + if (parsing_actor) + { + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) Found 'eventloadactor' within 'actor'.\n", fn, line_number); + errorcount++; + } + + num_squigilly_brackets = 0; + popscriptvalue(); + parsing_actor = scriptpos(); + + transnum(LABEL_DEFINE); + int n = popscriptvalue(); + tileinfo[n].loadeventscriptptr = parsing_actor; + checking_ifelse = 0; + return 0; + } + case concmd_setsector: + case concmd_getsector: + { + int lLabelID; + // syntax getsector[].x + // gets the value of sector[].xxx into + + // now get name of .xxx + while ((*textptr != '[')) + { + textptr++; + } + if (*textptr == '[') + textptr++; + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); + + // now get name of .xxx + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr != '.') + { + errorcount++; + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) Syntax error.\n", fn, line_number); + return 0; + + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + + lLabelID = getlabeloffset(sectorlabels, parselabel); + + if (lLabelID == -1) + { + errorcount++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + appendscriptvalue(sectorlabels[lLabelID].lId); + if (sectorlabels[lLabelID].flags & LABEL_HASPARM2) + { + getlabel(); + + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); + } + + // now at target VAR... + + // get the ID of the DEF + getlabel(); + + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + if (tw == concmd_getsector && aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) + { + errorcount++; + ReportError(ERROR_VARREADONLY); + return 0; + } + appendscriptvalue(i); + + break; + } + case concmd_findnearactor: + { + // syntax findnearactor + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + + transnum(LABEL_DEFINE); // get + + transnum(LABEL_DEFINE); // get maxdist + + getlabel(); + + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + if (aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) + { + errorcount++; + ReportError(ERROR_VARREADONLY); + return 0; + } + appendscriptvalue(i); + + break; + } + case concmd_findnearactorvar: + { + // syntax findnearactorvar + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + + transnum(LABEL_DEFINE); // get + getlabel(); + + checkforkeyword(); + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + + // target var + getlabel(); + + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + if (aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) + { + errorcount++; + ReportError(ERROR_VARREADONLY); + return 0; + + } + appendscriptvalue(i); + break; + } + case concmd_sqrt: + { + // syntax sqrt + // gets the sqrt of invar into outvar + + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); + + // target var + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + if (aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) + { + errorcount++; + ReportError(ERROR_VARREADONLY); + return 0; + + } + appendscriptvalue(i); + + break; + } + case concmd_setwall: + case concmd_getwall: + { + int lLabelID; + // syntax getwall[].x + // gets the value of wall[].xxx into + + // now get name of .xxx + while ((*textptr != '[')) + { + textptr++; + } + if (*textptr == '[') + textptr++; + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); + + // now get name of .xxx + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr != '.') + { + errorcount++; + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) Syntax error.\n", fn, line_number); + return 0; + + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + + lLabelID = getlabeloffset(walllabels, parselabel); + + if (lLabelID == -1) + { + errorcount++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + appendscriptvalue(walllabels[lLabelID].lId); + + if (walllabels[lLabelID].flags & LABEL_HASPARM2) + { + // get parm2 + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); // the ID of the DEF (offset into array...) + } + + // now at target VAR... + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + if (tw == concmd_getwall && aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) + { + errorcount++; + ReportError(ERROR_VARREADONLY); + return 0; + + } + appendscriptvalue(i); + + break; + } + case concmd_setplayer: + case concmd_getplayer: + { + int lLabelID; + // syntax getwall[].x + // gets the value of wall[].xxx into + + // now get name of .xxx + while ((*textptr != '[')) + { + textptr++; + } + if (*textptr == '[') + textptr++; + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); + + // now get name of .xxx + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr != '.') + { + errorcount++; + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) Syntax error.\n", fn, line_number); + return 0; + + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + + lLabelID = getlabeloffset(playerlabels, parselabel); + if (lLabelID == -1) + { + errorcount++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + + appendscriptvalue(playerlabels[lLabelID].lId); + + if (playerlabels[lLabelID].flags & LABEL_HASPARM2) + { + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); // the ID of the DEF (offset into array...) + } + + // now at target VAR... + getlabel(); + + checkforkeyword(); + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + if (tw == concmd_getplayer && aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) + { + errorcount++; + ReportError(ERROR_VARREADONLY); + return 0; + + } + appendscriptvalue(i); + + break; + } + case concmd_setuserdef: + case concmd_getuserdef: + { + int lLabelID; + // syntax [gs]etuserdef.x + // gets the value of ud.xxx into + + // now get name of .xxx + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr != '.') + { + errorcount++; + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) Syntax error.\n", fn, line_number); + return 0; + + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + + lLabelID = getlabeloffset(userdefslabels, parselabel); + if (lLabelID == -1) + { + errorcount++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + appendscriptvalue(userdefslabels[lLabelID].lId); + + if (userdefslabels[lLabelID].flags & LABEL_HASPARM2) + { + // get parm2 + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); // the ID of the DEF (offset into array...) + } + + + // now at target VAR... + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + if (tw == concmd_getplayer && aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) + { + errorcount++; + ReportError(ERROR_VARREADONLY); + return 0; + + } + appendscriptvalue(i); + + break; + } + case concmd_setactorvar: + case concmd_getactorvar: + { + // syntax [gs]etactorvar[]. + // gets the value of the per-actor variable varx into VAR + + // now get name of + while ((*textptr != '[')) + { + textptr++; + } + if (*textptr == '[') + textptr++; + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); + + // now get name of . + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr != '.') + { + errorcount++; + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) Syntax error.\n", fn, line_number); + return 0; + + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + if (tw == concmd_setactorvar && aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) + { + errorcount++; + ReportError(ERROR_VARREADONLY); + return 0; + + } + if (tw == concmd_setactorvar && !(aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR)) + { + errorcount++; + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) Variable '%s' is not per-actor.\n", fn, line_number, parselabel); + return 0; + + } + appendscriptvalue(i); + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + + if (tw == concmd_getactorvar && aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) + { + errorcount++; + ReportError(ERROR_VARREADONLY); + return 0; + + } + + appendscriptvalue(i); + + break; + } + case concmd_setactor: + case concmd_getactor: + { + int lLabelID; + // syntax getsector[].x + // gets the value of sector[].xxx into + + // now get name of .xxx + while ((*textptr != '[')) + { + textptr++; + } + if (*textptr == '[') + textptr++; + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); + + // now get name of .xxx + while (*textptr != '.') + { + if (*textptr == 0xa) + break; + if (!*textptr) + break; + + textptr++; + } + if (*textptr != '.') + { + errorcount++; + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) Syntax error.\n", fn, line_number); + return 0; + + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + + lLabelID = getlabeloffset(actorlabels, parselabel); + if (lLabelID == -1) + { + errorcount++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + appendscriptvalue(actorlabels[lLabelID].lId); + + if (actorlabels[lLabelID].flags & LABEL_HASPARM2) + { + // get parm2 + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) Symbol '%s' is not a Game Definition.\n", fn, line_number, parselabel); + return 0; + } + appendscriptvalue(i); // the ID of the DEF (offset into array...) + } + + // now at target VAR... + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + if (tw == concmd_getactor && aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) + { + errorcount++; + ReportError(ERROR_VARREADONLY); + return 0; + + } + appendscriptvalue(i); + + break; + } + case concmd_espawnvar: + // syntax: espawnvar + // spawns the sprite of type ID and sets RETURN to spawned sprite ID + // FALL THROUGH: + case concmd_lockplayer: + // syntax: lockplayer + // sets locks the player controls for ticks + + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + if (aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) + { + errorcount++; + ReportError(ERROR_VARREADONLY); + return 0; + + } + appendscriptvalue(i); // the ID of the DEF (offset into array...) + + return 0; + + case concmd_enhanced: + { + popscriptvalue(); + transnum(LABEL_DEFINE); + int k = popscriptvalue(); + if (k > VERSIONCHECK) + { + Printf(TEXTCOLOR_RED, " * ERROR: This CON Code requires at least Build %d, but we are only Build %d\n", k, (int)VERSIONCHECK); + errorcount++; + } + break; + } + + case concmd_spgetlotag: + case concmd_spgethitag: + case concmd_sectgetlotag: + case concmd_sectgethitag: + case concmd_gettexturefloor: + case concmd_gettextureceiling: + // no paramaters... + return 0; + case concmd_starttrack: + // one parameter (track#) + transnum(LABEL_DEFINE); + return 0; + case concmd_gettexturewall: + errorcount++; + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) Command 'gettexturewall' is not yet implemented.\n", fn, line_number); + return 0; + case concmd_displayrand: + // syntax: displayrand + // gets rand (not game rand) into + + // Get The ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); // the ID of the DEF (offset into array...) + break; + case concmd_switch: + checking_switch++; // allow nesting (if other things work) + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEVAR); + return 0; + } + appendscriptvalue(i); + + tempscrptr = scriptpos(); + appendscriptvalue(0); // leave spot for end location (for after processing) + appendscriptvalue(0); // count of case statements + casescriptptr = scriptpos(); // the first case's pointer. + + appendscriptvalue(0); // leave spot for 'default' location (null if none) + + j = keyword(); + while (j == 20) // '//' + { + while (*textptr != 0x0a) + textptr++; + + j = keyword(); + } + // probably does not allow nesting... + + + j = CountCaseStatements(); + if (checking_switch > 1) + { + // sprintf(g_szBuf,"ERROR::%s %d: Checking_switch=",__FILE__,__LINE__, checking_switch); + // AddLog(g_szBuf); + } + if (j < 0) + { + return 1; + } + if (tempscrptr) + { + setscriptvalue(tempscrptr + 1, j); // save count of cases + } + + while (j--) + { + // leave room for statements + appendscriptvalue(0); // value check + appendscriptvalue(0); // code offset + } + + casecount = 0; + while (parsecommand() == 0); + + casecount = 0; + if (tempscrptr) + { + setscriptvalue(tempscrptr, scriptpos()); // save 'end' location + } + + casescriptptr = NULL; + // decremented in endswitch. Don't decrement here... + // checking_switch--; // allow nesting (maybe if other things work) + tempscrptr = NULL; + break; + + + case concmd_case: + //AddLog("Found Case"); + repeatcase: + popscriptvalue(); // don't save in code + if (checking_switch < 1) + { + errorcount++; + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) case statement when not in switch\n", fn, line_number); + return 1; + } + casecount++; + transnum(LABEL_DEFINE); + + j = popscriptvalue(); + if (casescriptptr) + { + setscriptvalue(casescriptptr + (casecount++), j); + setscriptvalue(casescriptptr + casecount, scriptpos()); + } + j = keyword(); + while (j == 20) // '//' + { + while (*textptr != 0x0a) + textptr++; + + j = keyword(); + } + if (j == concmd_case) + { + transword(); // eat 'case' + goto repeatcase; + } + while (parsecommand() == 0); + return 0; + + case concmd_default: + popscriptvalue(); // don't save + if (casescriptptr != 0 && ScriptCode[casescriptptr] != 0) + { + // duplicate default statement + errorcount++; + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) multiple default statements found in switch\n", fn, line_number); + } + if (casescriptptr) + { + setscriptvalue(casescriptptr, scriptpos()); + } + while (parsecommand() == 0); + break; + case concmd_endswitch: + checking_switch--; + if (checking_switch < 0) + { + errorcount++; + Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) endswitch without matching switch\n", fn, line_number); + } + return 1; // end of block + break; + case concmd_startlevel: + // start at specified level + // startlevel +#if 0 + if (!g_bEnhanced) + { + errorcount++; + printf(" * ERROR!(L%ld) Command '%s' is enhanced only. Define enhance with the version number your code needs before using this commands.\n", line_number, tempbuf); + return 0; + } +#endif + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); + break; + case concmd_mapvoxel: + // map a tilenum to a voxel. + // syntax: mapvoxel +#if 0 + if (!g_bEnhanced) + { + errorcount++; + printf(" * ERROR!(L%ld) Command '%s' is enhanced only. Define enhance with the version number your code needs before using this commands.\n", line_number, tempbuf); + return 0; + } +#endif + popscriptvalue(); // don't save in compiled code + + transnum(LABEL_DEFINE); + j = popscriptvalue(); + + while (*textptr == ' ' || *textptr == '\t') textptr++; + + i = 0; +#if 0 + voxel_map[j].name[i] = 0; + voxel_map[j].voxnum = -2; // flag to load later + while ((i < 12) && (isalnum(*textptr) || *textptr == '.')) + { + voxel_map[j].name[i++] = *textptr++; + } + voxel_map[j].name[i] = 0; +#endif + break; + case concmd_myos: + case concmd_myospal: + case concmd_myosx: + case concmd_myospalx: +#if 0 + if (!g_bEnhanced) + { + errorcount++; + printf(" * ERROR!(L%ld) Command '%s' is enhanced only. Define enhance with the version number your code needs before using this commands.\n", line_number, tempbuf); + return 0; + } +#endif + // syntax: + // int x, int y, short tilenum, signed char shade, char orientation + // myospal adds char pal + + // Parse: x + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); + + // Parse: Y + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEVAR); + return 0; + } + appendscriptvalue(i); + + // Parse: tilenum + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEVAR); + return 0; + } + appendscriptvalue(i); + + // Parse: shade + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEVAR); + return 0; + } + appendscriptvalue(i); + + // Parse: orientation + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEVAR); + return 0; + } + appendscriptvalue(i); + + if (tw == concmd_myospal || tw == concmd_myospalx) + { + // Parse: pal + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEVAR); + return 0; + } + appendscriptvalue(i); + } + + break; + + case concmd_getangletotarget: + case concmd_getactorangle: + case concmd_setactorangle: + case concmd_getplayerangle: + case concmd_setplayerangle: + // Syntax: + + // get the ID of the DEF + getlabel(); + checkforkeyword(); + + i = GetDefID(parselabel); + //printf("Label '%s' ID is %d\n",label+(labelcnt<<6), i); + if (i < 0) + { // not a defined DEF + errorcount++; + ReportError(ERROR_NOTAGAMEDEF); + return 0; + } + appendscriptvalue(i); + + return 0; + + } return 0; } diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 9e726ce95..7fe5c082e 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -37,6 +37,8 @@ source as it is released. #include "gamevar.h" #include "mapinfo.h" #include "gamestate.h" +#include "conlabel.h" +#include "automap.h" BEGIN_DUKE_NS @@ -91,6 +93,1254 @@ void addspritetodelete(int spnum) killthesprite = true; } +static void DoUserDef(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPlayer, int lParm2) +{ + int lValue; + + lValue = GetGameVarID((int)lVar2, sActor, sPlayer); + + // most settings have been removed because they are either pointless, no longer existent or simply too dangerous to access. + // Others have been made read-only. + switch (lLabelID) + { + case USERDEFS_GOD: // redid this so that the script won't be able to disable user-set god mode. + if (bSet) ud.god = (ud.god & ~2) | (lValue? 2:0); + else SetGameVarID((int)lVar2, !!ud.god, sActor, sPlayer); + break; + + case USERDEFS_CASHMAN: + if (bSet) ud.cashman = lValue; + else SetGameVarID((int)lVar2, ud.cashman, sActor, sPlayer); + break; + + case USERDEFS_EOG: + if (bSet) ud.eog = lValue; + else SetGameVarID((int)lVar2, ud.eog, sActor, sPlayer); + break; + + case USERDEFS_SHOWALLMAP: + if (bSet) gFullMap = lValue; + else SetGameVarID((int)lVar2, gFullMap, sActor, sPlayer); + break; + + case USERDEFS_SHOWWEAPONS: + if (bSet) ud.showweapons = lValue; + else SetGameVarID((int)lVar2, ud.showweapons, sActor, sPlayer); + break; + + case USERDEFS_FROM_BONUS: + if (bSet) ud.from_bonus = lValue; + else SetGameVarID((int)lVar2, ud.from_bonus, sActor, sPlayer); + break; + + case USERDEFS_CAMERASPRITE: + if (bSet) ud.camerasprite = lValue; + else SetGameVarID((int)lVar2, ud.camerasprite, sActor, sPlayer); + break; + + case USERDEFS_LAST_CAMSPRITE: + if (!bSet) SetGameVarID((int)lVar2, -1, sActor, sPlayer); + break; + + case USERDEFS_LAST_LEVEL: + if (bSet) ud.last_level = lValue; + else SetGameVarID((int)lVar2, ud.last_level, sActor, sPlayer); + break; + + case USERDEFS_SECRETLEVEL: + if (bSet) ud.secretlevel = lValue; + else SetGameVarID((int)lVar2, ud.secretlevel, sActor, sPlayer); + break; + + case USERDEFS_CONST_VISIBILITY: + if (bSet) ud.const_visibility = lValue; + else SetGameVarID((int)lVar2, ud.const_visibility, sActor, sPlayer); + break; + + case USERDEFS_SHADOWS: + if (bSet) ud.shadows = lValue; + else SetGameVarID((int)lVar2, ud.shadows, sActor, sPlayer); + break; + case USERDEFS_M_COOP: + if (!bSet) SetGameVarID((int)lVar2, ud.m_coop, sActor, sPlayer); + break; + + case USERDEFS_COOP: + if (!bSet) SetGameVarID((int)lVar2, ud.coop, sActor, sPlayer); + break; + + case USERDEFS_RESPAWN_MONSTERS: + if (bSet) ud.respawn_monsters = lValue; + else SetGameVarID((int)lVar2, ud.respawn_monsters, sActor, sPlayer); + break; + + case USERDEFS_RESPAWN_ITEMS: + if (bSet) ud.respawn_items = lValue; + else SetGameVarID((int)lVar2, ud.respawn_items, sActor, sPlayer); + break; + + case USERDEFS_RESPAWN_INVENTORY: + if (bSet) ud.respawn_inventory = lValue; + else SetGameVarID((int)lVar2, ud.respawn_inventory, sActor, sPlayer); + break; + + case USERDEFS_RECSTAT: + if (!bSet) SetGameVarID((int)lVar2, ud.recstat, sActor, sPlayer); + break; + + case USERDEFS_MONSTERS_OFF: + if (bSet) ud.monsters_off = lValue; + else SetGameVarID((int)lVar2, ud.monsters_off, sActor, sPlayer); + break; + + case USERDEFS_BRIGHTNESS: + if (bSet) ud.brightness = lValue; + else SetGameVarID((int)lVar2, ud.brightness, sActor, sPlayer); + break; + + case USERDEFS_M_RESPAWN_ITEMS: + if (bSet) ud.m_respawn_items = lValue; + else SetGameVarID((int)lVar2, ud.m_respawn_items, sActor, sPlayer); + break; + + case USERDEFS_M_RESPAWN_MONSTERS: + if (bSet) ud.m_respawn_monsters = lValue; + else SetGameVarID((int)lVar2, ud.m_respawn_monsters, sActor, sPlayer); + break; + + case USERDEFS_M_RESPAWN_INVENTORY: + if (bSet) ud.m_respawn_inventory = lValue; + else SetGameVarID((int)lVar2, ud.m_respawn_inventory, sActor, sPlayer); + break; + + case USERDEFS_M_MONSTERS_OFF: + if (bSet) ud.m_monsters_off = lValue; + else SetGameVarID((int)lVar2, ud.m_monsters_off, sActor, sPlayer); + break; + + case USERDEFS_M_FFIRE: + if (bSet) ud.m_ffire = lValue; + else SetGameVarID((int)lVar2, ud.m_ffire, sActor, sPlayer); + break; + + case USERDEFS_FFIRE: + if (bSet) ud.ffire = lValue; + else SetGameVarID((int)lVar2, ud.ffire, sActor, sPlayer); + break; + + case USERDEFS_MULTIMODE: + if (!bSet) SetGameVarID((int)lVar2, ud.multimode, sActor, sPlayer); + break; + + case USERDEFS_PLAYER_SKILL: + if (bSet) ud.player_skill = lValue; + else SetGameVarID((int)lVar2, ud.player_skill, sActor, sPlayer); + break; + + case USERDEFS_LEVEL_NUMBER: + if (!bSet) SetGameVarID((int)lVar2, mapfromlevelnum(currentLevel->levelNumber), sActor, sPlayer); + break; + + case USERDEFS_VOLUME_NUMBER: + if (!bSet) SetGameVarID((int)lVar2, volfromlevelnum(currentLevel->levelNumber), sActor, sPlayer); + break; + + case USERDEFS_MARKER: + if (bSet) ud.marker = lValue; + else SetGameVarID((int)lVar2, ud.marker, sActor, sPlayer); + break; + + default: + // This will also catch all deleted cases. + // make sure that the return value is always defined. + if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer); + break; + } + return; +} + +/////////////////////////////////////////// +void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPlayer, int lParm2) +{ + int iPlayer; + int lValue; + int lTemp; + + lValue = GetGameVarID((int)lVar2, sActor, sPlayer); + + if (lVar1 == g_iThisActorID) + { + // if they've asked for 'this', then use 'this player'... + iPlayer = sPlayer; + } + else + { + iPlayer = GetGameVarID((int)lVar1, sActor, sPlayer); + } + + if (iPlayer < 0 || iPlayer >= MAXPLAYERS) + return; + + switch (lLabelID) + { + case PLAYER_ZOOM: + SetGameVarID((int)lVar2, 768, sActor, sPlayer); //return default for AM zoom. + break; + + case PLAYER_EXITX: + if (bSet) ps[iPlayer].exitx = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].exitx, sActor, sPlayer); + break; + + case PLAYER_EXITY: + if (bSet) ps[iPlayer].exity = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].exity, sActor, sPlayer); + break; + + case PLAYER_LOOGIEX: + if (bSet) ps[iPlayer].loogiex[lParm2] = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].loogiex[lParm2], sActor, sPlayer); + break; + + case PLAYER_LOOGIEY: + if (bSet) ps[iPlayer].loogiey[64] = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].loogiey[64], sActor, sPlayer); + break; + + case PLAYER_NUMLOOGS: + if (bSet) ps[iPlayer].numloogs = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].numloogs, sActor, sPlayer); + break; + + case PLAYER_LOOGCNT: + if (bSet) ps[iPlayer].loogcnt = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].loogcnt, sActor, sPlayer); + break; + + case PLAYER_POSX: // oh, my... :( Writing to these has been disabled until I know how to do it without the engine shitting all over itself. + if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].posx, sActor, sPlayer); + break; + + case PLAYER_POSY: + if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].posy, sActor, sPlayer); + break; + + case PLAYER_POSZ: + if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].posz, sActor, sPlayer); + break; + + case PLAYER_HORIZ: + if (bSet) playerSetHoriz(&ps[iPlayer], lValue); + else SetGameVarID((int)lVar2, FixedToInt(ps[iPlayer].q16horiz), sActor, sPlayer); + break; + + case PLAYER_OHORIZ: + if (!bSet) SetGameVarID((int)lVar2, FixedToInt(ps[iPlayer].q16horiz), sActor, sPlayer); + break; + + case PLAYER_OHORIZOFF: + if (!bSet) SetGameVarID((int)lVar2, FixedToInt(ps[iPlayer].q16horizoff), sActor, sPlayer); + break; + + case PLAYER_INVDISPTIME: + if (bSet) ps[iPlayer].invdisptime = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].invdisptime, sActor, sPlayer); + break; + + case PLAYER_BOBPOSX: + if (bSet) ps[iPlayer].bobposx = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].bobposx, sActor, sPlayer); + break; + + case PLAYER_BOBPOSY: + if (bSet) ps[iPlayer].bobposy = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].bobposy, sActor, sPlayer); + break; + + case PLAYER_OPOSX: + if (bSet) ps[iPlayer].oposx = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].oposx, sActor, sPlayer); + break; + + case PLAYER_OPOSY: + if (bSet) ps[iPlayer].oposy = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].oposy, sActor, sPlayer); + break; + + case PLAYER_OPOSZ: + if (bSet) ps[iPlayer].oposz = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].oposz, sActor, sPlayer); + break; + + case PLAYER_PYOFF: + if (bSet) ps[iPlayer].pyoff = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].pyoff, sActor, sPlayer); + break; + + case PLAYER_OPYOFF: + if (bSet) ps[iPlayer].opyoff = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].opyoff, sActor, sPlayer); + break; + + case PLAYER_POSXV: + if (bSet) ps[iPlayer].posxv = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].posxv, sActor, sPlayer); + break; + + case PLAYER_POSYV: + if (bSet) ps[iPlayer].posyv = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].posyv, sActor, sPlayer); + break; + + case PLAYER_POSZV: + if (bSet) ps[iPlayer].poszv = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].poszv, sActor, sPlayer); + break; + + case PLAYER_LAST_PISSED_TIME: + if (bSet) ps[iPlayer].last_pissed_time = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].last_pissed_time, sActor, sPlayer); + break; + + case PLAYER_TRUEFZ: + if (bSet) ps[iPlayer].truefz = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].truefz, sActor, sPlayer); + break; + + case PLAYER_TRUECZ: + if (bSet) ps[iPlayer].truecz = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].truecz, sActor, sPlayer); + break; + + case PLAYER_PLAYER_PAR: + if (bSet) ps[iPlayer].player_par = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].player_par, sActor, sPlayer); + break; + + case PLAYER_VISIBILITY: + if (bSet) ps[iPlayer].visibility = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].visibility, sActor, sPlayer); + break; + + case PLAYER_BOBCOUNTER: + if (bSet) ps[iPlayer].bobcounter = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].bobcounter, sActor, sPlayer); + break; + + case PLAYER_WEAPON_SWAY: + if (bSet) ps[iPlayer].weapon_sway = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].weapon_sway, sActor, sPlayer); + break; + + case PLAYER_PALS_TIME: + if (bSet) ps[iPlayer].pals.a = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].pals.a, sActor, sPlayer); + break; + + case PLAYER_RANDOMFLAMEX: + if (bSet) ps[iPlayer].randomflamex = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].randomflamex, sActor, sPlayer); + break; + + case PLAYER_CRACK_TIME: + if (bSet) ps[iPlayer].crack_time = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].crack_time, sActor, sPlayer); + break; + + case PLAYER_AIM_MODE: // game has no business enforcing this in any way. + if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].aim_mode, sActor, sPlayer); + break; + + case PLAYER_ANG: + if (bSet) playerSetAngle(&ps[iPlayer], lValue); + else SetGameVarID((int)lVar2, ps[iPlayer].getang(), sActor, sPlayer); + break; + + case PLAYER_OANG: + if (!bSet) SetGameVarID((int)lVar2, ps[iPlayer].getang(), sActor, sPlayer); + break; + + case PLAYER_ANGVEL: // This no longer exists. + if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer); + break; + + case PLAYER_CURSECTNUM: + if (bSet) ps[iPlayer].cursectnum = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].cursectnum, sActor, sPlayer); + break; + + case PLAYER_LOOK_ANG: + if (bSet) ps[iPlayer].q16look_ang = IntToFixed(lValue); + else SetGameVarID((int)lVar2, FixedToInt(ps[iPlayer].q16look_ang), sActor, sPlayer); + break; + + case PLAYER_LAST_EXTRA: + if (bSet) ps[iPlayer].last_extra = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].last_extra, sActor, sPlayer); + break; + + case PLAYER_SUBWEAPON: + if (bSet) ps[iPlayer].subweapon = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].subweapon, sActor, sPlayer); + break; + + case PLAYER_AMMO_AMOUNT: + lTemp = GetGameVarID((int)lParm2, sActor, sPlayer); + if (bSet) ps[iPlayer].ammo_amount[lTemp] = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].ammo_amount[lTemp], sActor, sPlayer); + break; + + case PLAYER_WACKEDBYACTOR: + if (bSet) ps[iPlayer].wackedbyactor = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].wackedbyactor, sActor, sPlayer); + break; + + case PLAYER_FRAG: + if (bSet) ps[iPlayer].frag = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].frag, sActor, sPlayer); + break; + + case PLAYER_FRAGGEDSELF: + if (bSet) ps[iPlayer].fraggedself = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].fraggedself, sActor, sPlayer); + break; + + case PLAYER_CURR_WEAPON: + if (bSet) ps[iPlayer].curr_weapon = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].curr_weapon, sActor, sPlayer); + break; + + case PLAYER_LAST_WEAPON: + if (bSet) ps[iPlayer].last_weapon = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].last_weapon, sActor, sPlayer); + break; + + case PLAYER_TIPINCS: + if (bSet) ps[iPlayer].tipincs = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].tipincs, sActor, sPlayer); + break; + + case PLAYER_HORIZOFF: + if (bSet) ps[iPlayer].q16horizoff = IntToFixed(lValue); + else SetGameVarID((int)lVar2, FixedToInt(ps[iPlayer].q16horizoff), sActor, sPlayer); + break; + + case PLAYER_WANTWEAPONFIRE: + if (bSet) ps[iPlayer].wantweaponfire = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].wantweaponfire, sActor, sPlayer); + break; + + case PLAYER_HOLODUKE_AMOUNT: + if (bSet) ps[iPlayer].holoduke_amount = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].holoduke_amount, sActor, sPlayer); + break; + + case PLAYER_NEWOWNER: + if (bSet) ps[iPlayer].newowner = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].newowner, sActor, sPlayer); + break; + + case PLAYER_HURT_DELAY: + if (bSet) ps[iPlayer].hurt_delay = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].hurt_delay, sActor, sPlayer); + break; + + case PLAYER_HBOMB_HOLD_DELAY: + if (bSet) ps[iPlayer].hbomb_hold_delay = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].hbomb_hold_delay, sActor, sPlayer); + break; + + case PLAYER_JUMPING_COUNTER: + if (bSet) ps[iPlayer].jumping_counter = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].jumping_counter, sActor, sPlayer); + break; + + case PLAYER_AIRLEFT: + if (bSet) ps[iPlayer].airleft = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].airleft, sActor, sPlayer); + break; + + case PLAYER_KNEE_INCS: + if (bSet) ps[iPlayer].knee_incs = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].knee_incs, sActor, sPlayer); + break; + + case PLAYER_ACCESS_INCS: + if (bSet) ps[iPlayer].access_incs = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].access_incs, sActor, sPlayer); + break; + + case PLAYER_ACCESS_WALLNUM: + if (bSet) ps[iPlayer].access_wallnum = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].access_wallnum, sActor, sPlayer); + break; + + case PLAYER_ACCESS_SPRITENUM: + if (bSet) ps[iPlayer].access_spritenum = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].access_spritenum, sActor, sPlayer); + break; + + case PLAYER_KICKBACK_PIC: + if (bSet) ps[iPlayer].kickback_pic = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].kickback_pic, sActor, sPlayer); + break; + + case PLAYER_GOT_ACCESS: + if (bSet) ps[iPlayer].got_access = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].got_access, sActor, sPlayer); + break; + + case PLAYER_WEAPON_ANG: + if (bSet) ps[iPlayer].weapon_ang = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].weapon_ang, sActor, sPlayer); + break; + + case PLAYER_FIRSTAID_AMOUNT: + if (bSet) ps[iPlayer].firstaid_amount = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].firstaid_amount, sActor, sPlayer); + break; + + case PLAYER_SOMETHINGONPLAYER: + if (bSet) ps[iPlayer].somethingonplayer = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].somethingonplayer, sActor, sPlayer); + break; + + case PLAYER_ON_CRANE: + if (bSet) ps[iPlayer].on_crane = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].on_crane, sActor, sPlayer); + break; + + case PLAYER_I: // This is dangerous!!! + if (bSet) ps[iPlayer].i = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].i, sActor, sPlayer); + break; + + case PLAYER_ONE_PARALLAX_SECTNUM: + if (bSet) ps[iPlayer].one_parallax_sectnum = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].one_parallax_sectnum, sActor, sPlayer); + break; + + case PLAYER_OVER_SHOULDER_ON: + if (bSet) ps[iPlayer].over_shoulder_on = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].over_shoulder_on, sActor, sPlayer); + break; + + case PLAYER_RANDOM_CLUB_FRAME: + if (bSet) ps[iPlayer].random_club_frame = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].random_club_frame, sActor, sPlayer); + break; + + case PLAYER_FIST_INCS: + if (bSet) ps[iPlayer].fist_incs = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].fist_incs, sActor, sPlayer); + break; + + case PLAYER_ONE_EIGHTY_COUNT: + if (bSet) ps[iPlayer].one_eighty_count = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].one_eighty_count, sActor, sPlayer); + break; + + case PLAYER_CHEAT_PHASE: + if (bSet) ps[iPlayer].cheat_phase = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].cheat_phase, sActor, sPlayer); + break; + + case PLAYER_DUMMYPLAYERSPRITE: + if (bSet) ps[iPlayer].dummyplayersprite = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].dummyplayersprite, sActor, sPlayer); + break; + + case PLAYER_EXTRA_EXTRA8: + if (bSet) ps[iPlayer].extra_extra8 = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].extra_extra8, sActor, sPlayer); + break; + + case PLAYER_QUICK_KICK: + if (bSet) ps[iPlayer].quick_kick = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].quick_kick, sActor, sPlayer); + break; + + case PLAYER_HEAT_AMOUNT: + if (bSet) ps[iPlayer].heat_amount = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].heat_amount, sActor, sPlayer); + break; + + case PLAYER_ACTORSQU: + if (bSet) ps[iPlayer].actorsqu = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].actorsqu, sActor, sPlayer); + break; + + case PLAYER_TIMEBEFOREEXIT: + if (bSet) ps[iPlayer].timebeforeexit = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].timebeforeexit, sActor, sPlayer); + break; + + case PLAYER_CUSTOMEXITSOUND: + if (bSet) ps[iPlayer].customexitsound = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].customexitsound, sActor, sPlayer); + break; + + case PLAYER_WEAPRECS: + if (bSet) ps[iPlayer].weaprecs[lParm2] = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].weaprecs[lParm2], sActor, sPlayer); + break; + + case PLAYER_WEAPRECCNT: + if (bSet) ps[iPlayer].weapreccnt = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].weapreccnt, sActor, sPlayer); + break; + + case PLAYER_INTERFACE_TOGGLE_FLAG: + if (bSet) ps[iPlayer].interface_toggle_flag = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].interface_toggle_flag, sActor, sPlayer); + break; + + case PLAYER_ROTSCRNANG: + if (bSet) ps[iPlayer].setrotscrnang(lValue); + else SetGameVarID((int)lVar2, FixedToInt(ps[iPlayer].q16rotscrnang), sActor, sPlayer); + break; + + case PLAYER_DEAD_FLAG: + if (bSet) ps[iPlayer].dead_flag = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].dead_flag, sActor, sPlayer); + break; + + case PLAYER_SHOW_EMPTY_WEAPON: + if (bSet) ps[iPlayer].show_empty_weapon = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].show_empty_weapon, sActor, sPlayer); + break; + + case PLAYER_SCUBA_AMOUNT: + if (bSet) ps[iPlayer].scuba_amount = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].scuba_amount, sActor, sPlayer); + break; + + case PLAYER_JETPACK_AMOUNT: + if (bSet) ps[iPlayer].jetpack_amount = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].jetpack_amount, sActor, sPlayer); + break; + + case PLAYER_STEROIDS_AMOUNT: + if (bSet) ps[iPlayer].steroids_amount = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].steroids_amount, sActor, sPlayer); + break; + + case PLAYER_SHIELD_AMOUNT: + if (bSet) ps[iPlayer].shield_amount = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].shield_amount, sActor, sPlayer); + break; + + case PLAYER_HOLODUKE_ON: + if (bSet) ps[iPlayer].holoduke_on = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].holoduke_on, sActor, sPlayer); + break; + + case PLAYER_PYCOUNT: + if (bSet) ps[iPlayer].pycount = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].pycount, sActor, sPlayer); + break; + + case PLAYER_WEAPON_POS: + if (bSet) ps[iPlayer].weapon_pos = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].weapon_pos, sActor, sPlayer); + break; + + case PLAYER_FRAG_PS: + if (bSet) ps[iPlayer].frag_ps = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].frag_ps, sActor, sPlayer); + break; + + case PLAYER_TRANSPORTER_HOLD: + if (bSet) ps[iPlayer].transporter_hold = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].transporter_hold, sActor, sPlayer); + break; + + case PLAYER_LAST_FULL_WEAPON: + if (bSet) ps[iPlayer].last_full_weapon = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].last_full_weapon, sActor, sPlayer); + break; + + case PLAYER_FOOTPRINTSHADE: + if (bSet) ps[iPlayer].footprintshade = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].footprintshade, sActor, sPlayer); + break; + + case PLAYER_BOOT_AMOUNT: + if (bSet) ps[iPlayer].boot_amount = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].boot_amount, sActor, sPlayer); + break; + + case PLAYER_GM: + if (!bSet) SetGameVarID((int)lVar2, MODE_GAME, sActor, sPlayer); + break; + + case PLAYER_ON_WARPING_SECTOR: + if (bSet) ps[iPlayer].on_warping_sector = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].on_warping_sector, sActor, sPlayer); + break; + + case PLAYER_FOOTPRINTCOUNT: + if (bSet) ps[iPlayer].footprintcount = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].footprintcount, sActor, sPlayer); + break; + + case PLAYER_HBOMB_ON: + if (bSet) ps[iPlayer].hbomb_on = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].hbomb_on, sActor, sPlayer); + break; + + case PLAYER_JUMPING_TOGGLE: + if (bSet) ps[iPlayer].jumping_toggle = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].jumping_toggle, sActor, sPlayer); + break; + + case PLAYER_RAPID_FIRE_HOLD: + if (bSet) ps[iPlayer].rapid_fire_hold = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].rapid_fire_hold, sActor, sPlayer); + break; + + case PLAYER_ON_GROUND: + if (bSet) ps[iPlayer].on_ground = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].on_ground, sActor, sPlayer); + break; + + case PLAYER_INVEN_ICON: + if (bSet) ps[iPlayer].inven_icon = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].inven_icon, sActor, sPlayer); + break; + + case PLAYER_BUTTONPALETTE: + if (bSet) ps[iPlayer].buttonpalette = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].buttonpalette, sActor, sPlayer); + break; + + case PLAYER_JETPACK_ON: + if (bSet) ps[iPlayer].jetpack_on = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].jetpack_on, sActor, sPlayer); + break; + + case PLAYER_SPRITEBRIDGE: + if (bSet) ps[iPlayer].spritebridge = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].spritebridge, sActor, sPlayer); + break; + + case PLAYER_LASTRANDOMSPOT: + if (bSet) ps[iPlayer].lastrandomspot = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].lastrandomspot, sActor, sPlayer); + break; + + case PLAYER_SCUBA_ON: + if (bSet) ps[iPlayer].scuba_on = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].scuba_on, sActor, sPlayer); + break; + + case PLAYER_FOOTPRINTPAL: + if (bSet) ps[iPlayer].footprintpal = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].footprintpal, sActor, sPlayer); + break; + + case PLAYER_HEAT_ON: + if (bSet) ps[iPlayer].heat_on = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].heat_on, sActor, sPlayer); + break; + + case PLAYER_HOLSTER_WEAPON: + if (bSet) ps[iPlayer].holster_weapon = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].holster_weapon, sActor, sPlayer); + break; + + case PLAYER_FALLING_COUNTER: + if (bSet) ps[iPlayer].falling_counter = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].falling_counter, sActor, sPlayer); + break; + + case PLAYER_GOTWEAPON: + if (bSet) ps[iPlayer].gotweapon.Set(lParm2, lValue); + else SetGameVarID((int)lVar2, ps[iPlayer].gotweapon[lParm2], sActor, sPlayer); + break; + + case PLAYER_REFRESH_INVENTORY: + if (bSet) ps[iPlayer].refresh_inventory = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].refresh_inventory, sActor, sPlayer); + break; + + case PLAYER_TOGGLE_KEY_FLAG: + if (bSet) ps[iPlayer].toggle_key_flag = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].toggle_key_flag, sActor, sPlayer); + break; + + case PLAYER_KNUCKLE_INCS: + if (bSet) ps[iPlayer].knuckle_incs = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].knuckle_incs, sActor, sPlayer); + break; + + case PLAYER_WALKING_SND_TOGGLE: + if (bSet) ps[iPlayer].walking_snd_toggle = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].walking_snd_toggle, sActor, sPlayer); + break; + + case PLAYER_PALOOKUP: + if (bSet) ps[iPlayer].palookup = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].palookup, sActor, sPlayer); + break; + + case PLAYER_HARD_LANDING: + if (bSet) ps[iPlayer].hard_landing = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].hard_landing, sActor, sPlayer); + break; + + case PLAYER_MAX_SECRET_ROOMS: + if (bSet) ps[iPlayer].max_secret_rooms = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].max_secret_rooms, sActor, sPlayer); + break; + + case PLAYER_SECRET_ROOMS: + if (bSet) ps[iPlayer].secret_rooms = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].secret_rooms, sActor, sPlayer); + break; + + case PLAYER_MAX_ACTORS_KILLED: + if (bSet) ps[iPlayer].max_actors_killed = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].max_actors_killed, sActor, sPlayer); + break; + + case PLAYER_ACTORS_KILLED: + if (bSet) ps[iPlayer].actors_killed = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].actors_killed, sActor, sPlayer); + break; + + case PLAYER_RETURN_TO_CENTER: + if (bSet) ps[iPlayer].return_to_center = lValue; + else SetGameVarID((int)lVar2, ps[iPlayer].return_to_center, sActor, sPlayer); + break; + + default: + if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer); + break; + } + return; +} + +//////////////////// +void DoWall(char bSet, int lVar1, int lLabelID, int lVar2, short sActor, short sPlayer, int lParm2) +{ + int iWall; + int lValue; + + lValue = GetGameVarID((int)lVar2, sActor, sPlayer); + + iWall = GetGameVarID((int)lVar1, sActor, sPlayer); + + if (iWall < 0 || iWall >= numwalls) + { + if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer); + return; + } + + // All fields affecting map geometry have been made read-only! + switch (lLabelID) + { + case WALL_X: + if (!bSet) SetGameVarID((int)lVar2, wall[iWall].x, sActor, sPlayer); + break; + case WALL_Y: + if (bSet) SetGameVarID((int)lVar2, wall[iWall].y, sActor, sPlayer); + break; + case WALL_POINT2: + if (!bSet) SetGameVarID((int)lVar2, wall[iWall].point2, sActor, sPlayer); + break; + case WALL_NEXTWALL: + if (!bSet) SetGameVarID((int)lVar2, wall[iWall].nextwall, sActor, sPlayer); + break; + case WALL_NEXTSECTOR: + if (!bSet) SetGameVarID((int)lVar2, wall[iWall].nextsector, sActor, sPlayer); + break; + case WALL_CSTAT: + if (bSet) wall[iWall].cstat = lValue; + else SetGameVarID((int)lVar2, wall[iWall].cstat, sActor, sPlayer); + break; + case WALL_PICNUM: + if (bSet) wall[iWall].picnum = lValue; + else SetGameVarID((int)lVar2, wall[iWall].picnum, sActor, sPlayer); + break; + case WALL_OVERPICNUM: + if (bSet) wall[iWall].overpicnum = lValue; + else SetGameVarID((int)lVar2, wall[iWall].overpicnum, sActor, sPlayer); + break; + case WALL_SHADE: + if (bSet) wall[iWall].x = lValue; + else SetGameVarID((int)lVar2, wall[iWall].shade, sActor, sPlayer); + break; + case WALL_PAL: + if (bSet) wall[iWall].pal = lValue; + else SetGameVarID((int)lVar2, wall[iWall].pal, sActor, sPlayer); + break; + case WALL_XREPEAT: + if (bSet) wall[iWall].xrepeat = lValue; + else SetGameVarID((int)lVar2, wall[iWall].xrepeat, sActor, sPlayer); + break; + case WALL_YREPEAT: + if (bSet) wall[iWall].yrepeat = lValue; + else SetGameVarID((int)lVar2, wall[iWall].yrepeat, sActor, sPlayer); + break; + case WALL_XPANNING: + if (bSet) wall[iWall].xpanning = lValue; + else SetGameVarID((int)lVar2, wall[iWall].xpanning, sActor, sPlayer); + break; + case WALL_YPANNING: + if (bSet) wall[iWall].ypanning = lValue; + else SetGameVarID((int)lVar2, wall[iWall].ypanning, sActor, sPlayer); + break; + case WALL_LOTAG: + if (bSet) wall[iWall].lotag = lValue; + else SetGameVarID((int)lVar2, wall[iWall].lotag, sActor, sPlayer); + break; + case WALL_HITAG: + if (bSet) wall[iWall].hitag = lValue; + else SetGameVarID((int)lVar2, wall[iWall].hitag, sActor, sPlayer); + break; + case WALL_EXTRA: + if (bSet) wall[iWall].x = lValue; + else SetGameVarID((int)lVar2, wall[iWall].x, sActor, sPlayer); + break; + default: + break; + } + return; +} + +void DoSector(char bSet, int lVar1, int lLabelID, int lVar2, short sActor, short sPlayer, int lParm2) +{ + int iSector; + int lValue; + + + if (lVar1 == g_iThisActorID) + { + // if they've asked for 'this', then use 'this'... + iSector = sprite[sActor].sectnum; + } + else + { + iSector = GetGameVarID((int)lVar1, sActor, sPlayer); + } + + if (iSector < 0 || iSector >= numsectors) + { + if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer); + return; + } + + lValue = GetGameVarID((int)lVar2, sActor, sPlayer); + + // All fields affecting map geometry have been made read-only! + switch (lLabelID) + { + case SECTOR_WALLPTR: + if (!bSet) SetGameVarID((int)lVar2, sector[iSector].wallptr, sActor, sPlayer); + break; + case SECTOR_WALLNUM: + if (!bSet) SetGameVarID((int)lVar2, sector[iSector].wallnum, sActor, sPlayer); + break; + case SECTOR_CEILINGZ: + if (bSet) sector[iSector].ceilingz = lValue; + else SetGameVarID((int)lVar2, sector[iSector].ceilingz, sActor, sPlayer); + break; + case SECTOR_FLOORZ: + if (bSet) sector[iSector].floorz = lValue; + else SetGameVarID((int)lVar2, sector[iSector].floorz, sActor, sPlayer); + break; + case SECTOR_CEILINGSTAT: + if (bSet) sector[iSector].ceilingstat = lValue; + else SetGameVarID((int)lVar2, sector[iSector].ceilingstat, sActor, sPlayer); + break; + case SECTOR_FLOORSTAT: + if (bSet) sector[iSector].floorstat = lValue; + else SetGameVarID((int)lVar2, sector[iSector].floorstat, sActor, sPlayer); + break; + case SECTOR_CEILINGPICNUM: + if (bSet) sector[iSector].ceilingpicnum = lValue; + else SetGameVarID((int)lVar2, sector[iSector].ceilingpicnum, sActor, sPlayer); + break; + case SECTOR_CEILINGSLOPE: + if (bSet) sector[iSector].ceilingheinum = lValue; + else SetGameVarID((int)lVar2, sector[iSector].ceilingheinum, sActor, sPlayer); + break; + case SECTOR_CEILINGSHADE: + if (bSet) sector[iSector].ceilingshade = lValue; + else SetGameVarID((int)lVar2, sector[iSector].ceilingshade, sActor, sPlayer); + break; + case SECTOR_CEILINGPAL: + if (bSet) sector[iSector].ceilingpal = lValue; + else SetGameVarID((int)lVar2, sector[iSector].ceilingpal, sActor, sPlayer); + break; + case SECTOR_CEILINGXPANNING: + if (bSet) sector[iSector].ceilingxpanning = lValue; + else SetGameVarID((int)lVar2, sector[iSector].ceilingypanning, sActor, sPlayer); + break; + case SECTOR_FLOORPICNUM: + if (bSet) sector[iSector].floorpicnum = lValue; + else SetGameVarID((int)lVar2, sector[iSector].floorpicnum, sActor, sPlayer); + break; + case SECTOR_FLOORSLOPE: + if (bSet) sector[iSector].floorheinum = lValue; + else SetGameVarID((int)lVar2, sector[iSector].floorheinum, sActor, sPlayer); + break; + case SECTOR_FLOORSHADE: + if (bSet) sector[iSector].floorshade = lValue; + else SetGameVarID((int)lVar2, sector[iSector].floorshade, sActor, sPlayer); + break; + case SECTOR_FLOORPAL: + if (bSet) sector[iSector].floorpal = lValue; + else SetGameVarID((int)lVar2, sector[iSector].floorpal, sActor, sPlayer); + break; + case SECTOR_FLOORXPANNING: + if (bSet) sector[iSector].floorxpanning = lValue; + else SetGameVarID((int)lVar2, sector[iSector].floorxpanning, sActor, sPlayer); + break; + case SECTOR_FLOORYPANNING: + if (bSet) sector[iSector].floorypanning = lValue; + else SetGameVarID((int)lVar2, sector[iSector].floorypanning, sActor, sPlayer); + break; + case SECTOR_VISIBILITY: + if (bSet) sector[iSector].visibility = lValue; + else SetGameVarID((int)lVar2, sector[iSector].visibility, sActor, sPlayer); + break; + case SECTOR_LOTAG: + if (bSet) sector[iSector].lotag = lValue; + else SetGameVarID((int)lVar2, sector[iSector].lotag, sActor, sPlayer); + break; + case SECTOR_HITAG: + if (bSet) sector[iSector].hitag = lValue; + else SetGameVarID((int)lVar2, sector[iSector].hitag, sActor, sPlayer); + break; + case SECTOR_EXTRA: + if (bSet) sector[iSector].extra = lValue; + else SetGameVarID((int)lVar2, sector[iSector].extra, sActor, sPlayer); + break; + default: + break; + + } + return; +} +void DoActor(char bSet, int lVar1, int lLabelID, int lVar2, short sActor, short sPlayer, int lParm2) +{ + int iActor; + int lValue; + + lValue = GetGameVarID((int)lVar2, sActor, sPlayer); + + if (lVar1 == g_iThisActorID) + { + // if they've asked for 'this', then use 'this'... + iActor = sActor; + } + else + { + iActor = GetGameVarID((int)lVar1, sActor, sPlayer); + } + + if (iActor < 0 || iActor >= MAXSPRITES || sprite[iActor].statnum == MAXSTATUS) + { + if (!bSet) SetGameVarID((int)lVar2, 0, sActor, sPlayer); + return; + } + + switch (lLabelID) + { + case ACTOR_X: + if (bSet) sprite[iActor].x = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].x, sActor, sPlayer); + break; + case ACTOR_Y: + if (bSet) sprite[iActor].y = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].y, sActor, sPlayer); + break; + case ACTOR_Z: + if (bSet) sprite[iActor].z = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].z, sActor, sPlayer); + break; + case ACTOR_CSTAT: + if (bSet) sprite[iActor].cstat = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].cstat, sActor, sPlayer); + break; + case ACTOR_PICNUM: + if (bSet) sprite[iActor].picnum = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].picnum, sActor, sPlayer); + break; + case ACTOR_SHADE: + if (bSet) sprite[iActor].shade = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].shade, sActor, sPlayer); + break; + case ACTOR_PAL: + if (bSet) sprite[iActor].pal = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].pal, sActor, sPlayer); + break; + case ACTOR_CLIPDIST: + if (bSet) sprite[iActor].clipdist = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].clipdist, sActor, sPlayer); + break; + case ACTOR_DETAIL: + if (bSet) hittype[iActor].spriteextra = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].spriteextra, sActor, sPlayer); + break; + case ACTOR_XREPEAT: + if (bSet) sprite[iActor].xrepeat = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].xrepeat, sActor, sPlayer); + break; + case ACTOR_YREPEAT: + if (bSet) sprite[iActor].yrepeat = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].yrepeat, sActor, sPlayer); + break; + case ACTOR_XOFFSET: + if (bSet) sprite[iActor].xoffset = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].xoffset, sActor, sPlayer); + break; + case ACTOR_YOFFSET: + if (bSet) sprite[iActor].yoffset = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].yoffset, sActor, sPlayer); + break; + case ACTOR_SECTNUM: + if (bSet) changespritesect(iActor, lValue); + else SetGameVarID((int)lVar2, sprite[iActor].sectnum, sActor, sPlayer); + break; + case ACTOR_STATNUM: + if (bSet) changespritestat(iActor, lValue); + else SetGameVarID((int)lVar2, sprite[iActor].statnum, sActor, sPlayer); + break; + case ACTOR_ANG: + if (bSet) sprite[iActor].ang = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].ang, sActor, sPlayer); + break; + case ACTOR_OWNER: + if (bSet) sprite[iActor].owner = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].owner, sActor, sPlayer); + break; + case ACTOR_XVEL: + if (bSet) sprite[iActor].xvel = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].xvel, sActor, sPlayer); + break; + case ACTOR_YVEL: + if (bSet) sprite[iActor].yvel = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].yvel, sActor, sPlayer); + break; + case ACTOR_ZVEL: + if (bSet) sprite[iActor].zvel = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].zvel, sActor, sPlayer); + break; + case ACTOR_LOTAG: + if (bSet) sprite[iActor].lotag = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].lotag, sActor, sPlayer); + break; + case ACTOR_HITAG: + if (bSet) sprite[iActor].hitag = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].hitag, sActor, sPlayer); + break; + case ACTOR_EXTRA: + if (bSet) sprite[iActor].extra = lValue; + else SetGameVarID((int)lVar2, sprite[iActor].extra, sActor, sPlayer); + break; + + case ACTOR_HTCGG: + if (bSet) hittype[iActor].cgg = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].cgg, sActor, sPlayer); + break; + case ACTOR_HTPICNUM: + if (bSet) hittype[iActor].picnum = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].picnum, sActor, sPlayer); + break; + case ACTOR_HTANG: + if (bSet) hittype[iActor].ang = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].ang, sActor, sPlayer); + break; + case ACTOR_HTEXTRA: + if (bSet) hittype[iActor].extra = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].extra, sActor, sPlayer); + break; + case ACTOR_HTOWNER: + if (bSet) hittype[iActor].owner = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].owner, sActor, sPlayer); + break; + case ACTOR_HTMOVFLAG: + if (bSet) hittype[iActor].movflag = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].movflag, sActor, sPlayer); + break; + case ACTOR_HTTEMPANG: + if (bSet) hittype[iActor].tempang = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].tempang, sActor, sPlayer); + break; + case ACTOR_HTACTORSTAYPUT: + if (bSet) hittype[iActor].actorstayput = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].actorstayput, sActor, sPlayer); + break; + case ACTOR_HTDISPICNUM: + if (bSet) hittype[iActor].dispicnum = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].dispicnum, sActor, sPlayer); + break; + case ACTOR_HTTIMETOSLEEP: + if (bSet) hittype[iActor].timetosleep = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].timetosleep, sActor, sPlayer); + break; + case ACTOR_HTFLOORZ: + if (bSet) hittype[iActor].floorz = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].floorz, sActor, sPlayer); + break; + case ACTOR_HTCEILINGZ: + if (bSet) hittype[iActor].ceilingz = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].ceilingz, sActor, sPlayer); + break; + case ACTOR_HTLASTVX: + if (bSet) hittype[iActor].lastvx = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].lastvx, sActor, sPlayer); + break; + case ACTOR_HTLASTVY: + if (bSet) hittype[iActor].lastvy = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].lastvy, sActor, sPlayer); + break; + case ACTOR_HTBPOSX: + if (bSet) hittype[iActor].bposx = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].bposx, sActor, sPlayer); + break; + case ACTOR_HTBPOSY: + if (bSet) hittype[iActor].bposy = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].bposy, sActor, sPlayer); + break; + case ACTOR_HTBPOSZ: + if (bSet) hittype[iActor].bposz = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].bposz, sActor, sPlayer); + break; + case ACTOR_HTG_T0: + if (bSet) hittype[iActor].temp_data[0] = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].temp_data[0], sActor, sPlayer); + break; + case ACTOR_HTG_T1: + if (bSet) hittype[iActor].temp_data[1] = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].temp_data[1], sActor, sPlayer); + break; + case ACTOR_HTG_T2: + if (bSet) hittype[iActor].temp_data[2] = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].temp_data[2], sActor, sPlayer); + break; + case ACTOR_HTG_T3: + if (bSet) hittype[iActor].temp_data[3] = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].temp_data[3], sActor, sPlayer); + break; + case ACTOR_HTG_T4: + if (bSet) hittype[iActor].temp_data[4] = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].temp_data[4], sActor, sPlayer); + break; + case ACTOR_HTG_T5: + if (bSet) hittype[iActor].temp_data[5] = lValue; + else SetGameVarID((int)lVar2, hittype[iActor].temp_data[5], sActor, sPlayer); + break; + + default: + break; + } + return; +} + //--------------------------------------------------------------------------- // // @@ -1595,6 +2845,807 @@ int ParseState::parse(void) parseifelse(false); break; + case concmd_espawnvar: + { + int lReturn; + int lIn; + lReturn = -1; + insptr++; + + lIn = *insptr++; + lIn = GetGameVarID(lIn, g_i, g_p); + if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + lReturn = fi.spawn(g_i, lIn); + + SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); + break; + } + case concmd_espawn: + { + int lReturn; + lReturn = -1; + insptr++; + if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + lReturn = fi.spawn(g_i, *insptr); + insptr++; + SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); + break; + } + case concmd_setsector: + case concmd_getsector: + { + // syntax [gs]etsector[].x + // + int lLabelID; + int lVar1, lVar2; + int lWhat; + int lParm2; + + lWhat = *(insptr++); + lVar1 = *(insptr++); + lLabelID = *(insptr++); + lVar2 = *(insptr++); + DoSector(lWhat == concmd_setsector, lVar1, lLabelID, lVar2, g_i, g_p, lParm2); + break; + } + case concmd_sqrt: + { + // syntax sqrt + + int lInVarID; + int lOutVarID; + int lIn; + + insptr++; + lInVarID = *(insptr++); + lOutVarID = *(insptr++); + lIn = GetGameVarID(lInVarID, g_i, g_p); + SetGameVarID(lOutVarID, ksqrt(lIn), g_i, g_p); + break; + } + case concmd_findnearactor: + { + // syntax findnearactorvar + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + // + int lType; + int lMaxDist; + int lVarID; + int lTemp; + int lFound; + int lDist; + short j; + + insptr++; + + lType = *(insptr++); + lMaxDist = *(insptr++); + lVarID = *(insptr++); + + lFound = -1; + lDist = 32767; // big number + + j = headspritestat[1]; // all sprites + while (j >= 0) + { + if (sprite[j].picnum == lType) + { + lTemp = ldist(&sprite[g_i], &sprite[j]); + if (lTemp < lMaxDist) + { + if (lTemp < lDist) + { + lFound = j; + } + } + + } + j = nextspritestat[j]; + } + SetGameVarID(lVarID, lFound, g_i, g_p); + + break; + } + case concmd_findnearactorvar: + { + // syntax findnearactorvar + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + // + int lType; + int lMaxDistVar; + int lMaxDist; + int lVarID; + int lTemp; + int lFound; + int lDist; + short j; + + insptr++; + + lType = *(insptr++); + lMaxDistVar = *(insptr++); + lVarID = *(insptr++); + lMaxDist = GetGameVarID(lMaxDistVar, g_i, g_p); + lFound = -1; + lDist = 32767; // big number + + j = headspritestat[1]; // all sprites + while (j >= 0) + { + if (sprite[j].picnum == lType) + { + lTemp = ldist(&sprite[g_i], &sprite[j]); + if (lTemp < lMaxDist) + { + if (lTemp < lDist) + { + lFound = j; + } + } + + } + j = nextspritestat[j]; + } + SetGameVarID(lVarID, lFound, g_i, g_p); + + break; + } + case concmd_setplayer: + case concmd_getplayer: + { + // syntax [gs]etplayer[].x + // + int lLabelID; + int lVar1, lVar2; + int lWhat; + int lParm2; + + lWhat = *(insptr++); + lVar1 = *(insptr++); + lLabelID = *(insptr++); + // HACK: need to have access to labels structure at run-time... + if (lLabelID == PLAYER_AMMO_AMOUNT) + { + lParm2 = *(insptr++); + } + else + { + lParm2 = 0; + } + lVar2 = *(insptr++); + + DoPlayer(lWhat == concmd_setplayer, lVar1, lLabelID, lVar2, g_i, g_p, lParm2); + break; + } + case concmd_getuserdef: + case concmd_setuserdef: + { + // syntax [gs]etuserdef.xxx + // + int lLabelID; + int lVar1, lVar2; + int lWhat; + int lParm2; + + lWhat = *(insptr++); + lVar1 = -1; + lLabelID = *(insptr++); + lVar2 = *(insptr++); + + DoUserDef(lWhat == concmd_setuserdef, lVar1, lLabelID, lVar2, g_i, g_p, lParm2); + break; + } + case concmd_setwall: + case concmd_getwall: + { + // syntax [gs]etwall[].x + // + int lLabelID; + int lVar1, lVar2; + int lWhat; + int lParm2; + + lWhat = *(insptr++); + lVar1 = *(insptr++); + lLabelID = *(insptr++); + lVar2 = *(insptr++); + + DoWall(lWhat == concmd_setwall, lVar1, lLabelID, lVar2, g_i, g_p, lParm2); + break; + } + case concmd_setactorvar: + { + // syntax [gs]etactorvar[]. + // gets the value of the per-actor variable varx into VAR + // + int lVar1, lVar2, lVar3; + int lTemp, lSprite; + + insptr++; + + lVar1 = *(insptr++); + lVar2 = *(insptr++); + lVar3 = *(insptr++); + + lSprite = GetGameVarID(lVar1, g_i, g_p); + if (lSprite >= 0) + { + lTemp = GetGameVarID(lVar3, g_i, g_p); + SetGameVarID(lVar2, lTemp, lSprite, g_p); + } + + break; + } + case concmd_getactorvar: + { + // syntax [gs]etactorvar[]. + // gets the value of the per-actor variable varx into VAR + // + int lVar1, lVar2, lVar3; + int lTemp, lSprite; + + insptr++; + + lVar1 = *(insptr++); + lVar2 = *(insptr++); + lVar3 = *(insptr++); + + lSprite = GetGameVarID(lVar1, g_i, g_p); + if (lSprite >= 0) + { + lTemp = GetGameVarID(lVar2, lSprite, g_p); + SetGameVarID(lVar3, lTemp, g_i, g_p); + } + + break; + } + case concmd_setactor: + case concmd_getactor: + { + // syntax [gs]etactor[].x + // + int lLabelID; + int lVar1, lVar2; + int lWhat; + int lParm2; + + lWhat = *(insptr++); + lVar1 = *(insptr++); + lLabelID = *(insptr++); + lVar2 = *(insptr++); + + DoActor(lWhat == concmd_setactor, lVar1, lLabelID, lVar2, g_i, g_p, lParm2); + break; + } + case concmd_getangletotarget: + { + int i; + short ang; + + insptr++; + i = *(insptr++); // ID of def + + // hittype[g_i].lastvx and lastvy are last known location of target. + ang = getangle(hittype[g_i].lastvx - g_sp->x, hittype[g_i].lastvy - g_sp->y); + SetGameVarID(i, ang, g_i, g_p); + break; + } + case concmd_lockplayer: + { + int i; + insptr++; + i = *(insptr++); // ID of def + ps[g_p].transporter_hold = GetGameVarID(i, g_i, g_p); + break; + } + case concmd_getplayerangle: + { + int i; + insptr++; + i = *(insptr++); // ID of def + SetGameVarID(i, ps[g_p].getang(), g_i, g_p); + break; + } + case concmd_setplayerangle: + { + int i; + insptr++; + i = *(insptr++); // ID of def + ps[g_p].setang(GetGameVarID(i, g_i, g_p) & 2047); + break; + } + case concmd_getactorangle: + { + int i; + insptr++; + i = *(insptr++); // ID of def + SetGameVarID(i, g_sp->ang, g_i, g_p); + break; + } + case concmd_setactorangle: + { + int i; + insptr++; + i = *(insptr++); // ID of def + g_sp->ang = GetGameVarID(i, g_i, g_p); + g_sp->ang &= 2047; + break; + } + case concmd_randvar: + { + int i; + insptr++; + i = *(insptr++); // ID of def + SetGameVarID(i, mulscale(rand(), *insptr, 15), g_i, g_p); + insptr++; + break; + } + case concmd_mulvar: + { + int i; + insptr++; + i = *(insptr++); // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) * (*insptr), g_i, g_p); + insptr++; + break; + } + case concmd_divvar: + { + int i; + insptr++; + i = *(insptr++); // ID of def + if ((*insptr) == 0) + { + I_Error("Divide by Zero in CON."); + } + SetGameVarID(i, GetGameVarID(i, g_i, g_p) / (*insptr), g_i, g_p); + insptr++; + break; + } + case concmd_modvar: + { + int i; + int l; + int lResult; + insptr++; + i = *(insptr++); // ID of def + l = (*insptr); + if (l == 0) + { + I_Error("Divide by Zero in CON"); + } + lResult = GetGameVarID(i, g_i, g_p) % l; + SetGameVarID(i, lResult, g_i, g_p); + insptr++; + break; + } + case concmd_andvar: + { + int i; + int l; + int lResult; + insptr++; + i = *(insptr++); // ID of def + l = (*insptr); + lResult = GetGameVarID(i, g_i, g_p) & l; + SetGameVarID(i, lResult, g_i, g_p); + insptr++; + break; + } + case concmd_xorvar: + { + int i; + int l; + int lResult; + insptr++; + i = *(insptr++); // ID of def + l = (*insptr); + lResult = GetGameVarID(i, g_i, g_p) ^ l; + SetGameVarID(i, lResult, g_i, g_p); + insptr++; + break; + } + case concmd_orvar: + { + int i; + int l; + int lResult; + insptr++; + i = *(insptr++); // ID of def + l = (*insptr); + lResult = GetGameVarID(i, g_i, g_p) | l; + SetGameVarID(i, lResult, g_i, g_p); + insptr++; + break; + } + case concmd_randvarvar: + { + int i; + int l1, l2; + int lResult; + insptr++; + i = *(insptr++); // ID of def + l1 = GetGameVarID(i, g_i, g_p); // not used for this command + l2 = GetGameVarID(*insptr, g_i, g_p); + lResult = mulscale(rand(), l2, 15); + SetGameVarID(i, lResult, g_i, g_p); + insptr++; + break; + } + case concmd_gmaxammo: + { + int i; + int l1, l2; + int lResult; + insptr++; + i = *(insptr++); // ID of def + l1 = GetGameVarID(i, g_i, g_p); + l2 = GetGameVarID(*insptr, g_i, g_p); // l2 not used in this one + lResult = max_ammo_amount[l1]; + SetGameVarID(*insptr, lResult, g_i, g_p); + insptr++; + break; + } + case concmd_smaxammo: + { + int i; + int l1, l2; + insptr++; + i = *(insptr++); // ID of def + l1 = GetGameVarID(i, g_i, g_p); + l2 = GetGameVarID(*insptr, g_i, g_p); + max_ammo_amount[l1] = l2; + + insptr++; + break; + } + case concmd_mulvarvar: + { + int i; + int l1, l2; + int lResult; + insptr++; + i = *(insptr++); // ID of def + l1 = GetGameVarID(i, g_i, g_p); + l2 = GetGameVarID(*insptr, g_i, g_p); + lResult = l1 * l2; + SetGameVarID(i, lResult, g_i, g_p); + insptr++; + break; + } + case concmd_divvarvar: + { + int i; + int l1, l2; + int lResult; + insptr++; + i = *(insptr++); // ID of def + l1 = GetGameVarID(i, g_i, g_p); + l2 = GetGameVarID(*insptr, g_i, g_p); + if (l2 == 0) + { + I_Error("Divide by Zero in CON"); + } + lResult = l1 / l2; + SetGameVarID(i, lResult, g_i, g_p); + insptr++; + break; + } + case concmd_modvarvar: + { + int i; + int l1, l2; + int lResult; + insptr++; + i = *(insptr++); // ID of def + l1 = GetGameVarID(i, g_i, g_p); + l2 = GetGameVarID(*insptr, g_i, g_p); + if (l2 == 0) + { + I_Error("Mod by Zero in CON"); + } + lResult = l1 % l2; + SetGameVarID(i, lResult, g_i, g_p); + insptr++; + break; + } + case concmd_andvarvar: + { + int i; + int l1, l2; + int lResult; + insptr++; + i = *(insptr++); // ID of def + l1 = GetGameVarID(i, g_i, g_p); + l2 = GetGameVarID(*insptr, g_i, g_p); + lResult = l1 & l2; + SetGameVarID(i, lResult, g_i, g_p); + insptr++; + break; + } + case concmd_xorvarvar: + { + int i; + int l1, l2; + int lResult; + insptr++; + i = *(insptr++); // ID of def + l1 = GetGameVarID(i, g_i, g_p); + l2 = GetGameVarID(*insptr, g_i, g_p); + lResult = l1 ^ l2; + SetGameVarID(i, lResult, g_i, g_p); + insptr++; + break; + } + case concmd_orvarvar: + { + int i; + int l1, l2; + int lResult; + insptr++; + i = *(insptr++); // ID of def + l1 = GetGameVarID(i, g_i, g_p); + l2 = GetGameVarID(*insptr, g_i, g_p); + lResult = l1 | l2; + SetGameVarID(i, lResult, g_i, g_p); + insptr++; + break; + } + case concmd_subvar: + { + int i; + insptr++; + i = *(insptr++); // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) - *insptr, g_i, g_p); + insptr++; + break; + } + case concmd_subvarvar: + { + int i; + insptr++; + i = *(insptr++); // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) - GetGameVarID(*insptr, g_i, g_p), g_i, g_p); + insptr++; + break; + } + case concmd_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 concmd_spgetlotag: + { + insptr++; + SetGameVarID(g_iLoTagID, g_sp->lotag, g_i, g_p); + break; + } + case concmd_spgethitag: + { + insptr++; + SetGameVarID(g_iHiTagID, g_sp->hitag, g_i, g_p); + break; + } + case concmd_sectgetlotag: + { + insptr++; + SetGameVarID(g_iLoTagID, sector[g_sp->sectnum].lotag, g_i, g_p); + break; + } + case concmd_sectgethitag: + { + insptr++; + SetGameVarID(g_iHiTagID, sector[g_sp->sectnum].hitag, g_i, g_p); + break; + } + case concmd_gettexturefloor: + { + insptr++; + SetGameVarID(g_iTextureID, sector[g_sp->sectnum].floorpicnum, g_i, g_p); + break; + } + + case concmd_startlevel: + { + // from 'level' cheat in game.c (about line 6250) + int volnume; + int levnume; + + insptr++; // skip command + volnume = GetGameVarID(*(insptr++), g_i, g_p); + levnume = GetGameVarID(*(insptr++), g_i, g_p); + auto level = FindMapByLevelNum(levelnum(volnume - 1, levnume - 1)); + if (level != nullptr) + ChangeLevel(level, -1); + break; + } + case concmd_myosx: + case concmd_myospalx: + + case concmd_myos: + case concmd_myospal: + { + int x, y; + int tilenum; + int shade; + int orientation; + int pal; + int tw = *insptr++; + x = GetGameVarID(*insptr++, g_i, g_p); + y = GetGameVarID(*insptr++, g_i, g_p); + tilenum = GetGameVarID(*insptr++, g_i, g_p); + shade = GetGameVarID(*insptr++, g_i, g_p); + orientation = GetGameVarID(*insptr++, g_i, g_p); + if (tw == concmd_myospal) + { + pal = GetGameVarID(*insptr++, g_i, g_p); + //myospal(x, y, tilenum, shade, orientation, pal); + } + else if (tw == concmd_myos) + { + //myos(x, y, tilenum, shade, orientation); + } + else if (tw == concmd_myosx) + { + //myos640(x, y, tilenum, shade, orientation); + } + else if (tw == concmd_myospalx) + { + pal = GetGameVarID(*insptr++, g_i, g_p); + //myospal640(x, y, tilenum, shade, orientation, pal); + } + break; + } + + case concmd_displayrand: + { + int i; + insptr++; + + i = *(insptr++); // ID of def + SetGameVarID(i, rand(), g_i, g_p); + break; + } + case concmd_switch: + { + int lVarID; + int lValue; + int* lpDefault; + int* lpCases; + int lCases; + int lEnd; + int lCheckCase; + char bMatched; + int* lTempInsPtr; + + // command format: + // variable ID to check + // script offset to 'end' + // count of case statements + // script offset to default case (null if none) + // For each case: value, ptr to code + insptr++; // p-code + lVarID = *insptr++; + lValue = GetGameVarID(lVarID, g_i, g_p); + lEnd = *insptr++; + lCases = *insptr++; + lpDefault = insptr++; + lpCases = insptr; + insptr += lCases * 2; + bMatched = 0; + lTempInsPtr = insptr; + for (lCheckCase = 0; lCheckCase < lCases && !bMatched; lCheckCase++) + { + if (lpCases[lCheckCase * 2] == lValue) + { + insptr = &ScriptCode[lpCases[lCheckCase * 2 + 1]]; + while (1) + { + if (parse()) + break; + } + bMatched = 1; + } + } + if (!bMatched) + { + if (*lpDefault) + { + insptr = &ScriptCode[*lpDefault]; + while (1) if (parse()) break; + } + else + { + //AddLog("No Matching Case: No Default to use"); + } + } + insptr = &ScriptCode[lEnd]; + break; + } + case concmd_endswitch: + insptr++; + return 1; + break; + + case concmd_starttrack: + { + insptr++; + int music_select = *insptr++; + auto level = FindMapByLevelNum(levelnum(currentLevel->levelNumber, music_select)); + if (level) S_PlayLevelMusic(level); + break; + } + case concmd_gettextureceiling: + { + insptr++; + SetGameVarID(g_iTextureID, sector[g_sp->sectnum].ceilingpicnum, g_i, g_p); + break; + } + case concmd_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 concmd_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 concmd_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 concmd_ifvarand: + { + int i; + insptr++; + i = *(insptr++); // ID of def + j = 0; + if (GetGameVarID(i, g_i, g_p) & *insptr) + { + j = 1; + } + parseifelse(j); + break; + } + default: Printf(TEXTCOLOR_RED "Unrecognized PCode of %d in parse. Killing current sprite.\n",*insptr); Printf(TEXTCOLOR_RED "Offset=%0X\n",int(insptr-ScriptCode.Data())); @@ -1604,6 +3655,103 @@ int ParseState::parse(void) return 0; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void LoadActor(int i, int p, int x) +{ + char done; + spritetype* g_sp; + + ParseState s; + s.g_i = i; // Sprite ID + s.g_p = p; // Player ID + s.g_x = x; // ?? + g_sp = s.g_sp = &sprite[i]; // Pointer to sprite structure + s.g_t = &hittype[i].temp_data[0]; // Sprite's 'extra' data + + auto addr = tileinfo[s.g_sp->picnum].loadeventscriptptr; + if (addr == 0) return; + + int *insptr = &ScriptCode[addr + 1]; + + s.killit_flag = 0; + + if (g_sp->sectnum < 0 || g_sp->sectnum >= MAXSECTORS) + { + deletesprite(i); + return; + } + do + done = s.parse(); + while (done == 0); + + if (s.killit_flag == 1) + { + // if player was set to squish, first stop that... + if (p >= 0) + { + if (ps[p].actorsqu == i) + ps[p].actorsqu = -1; + } + deletesprite(i); + } + else + { + fi.move(i, p, x); + + if (g_sp->statnum == 1) + { + if (badguy(g_sp)) + { + if (g_sp->xrepeat > 60) return; + if (ud.respawn_monsters == 1 && g_sp->extra <= 0) return; + } + else if (ud.respawn_items == 1 && (g_sp->cstat & 32768)) return; + + if (hittype[i].timetosleep > 1) + hittype[i].timetosleep--; + else if (hittype[i].timetosleep == 1) + changespritestat(i, 2); + } + + else if (g_sp->statnum == 6) + { +#if 0 + switch (g_sp->picnum) + { + case RUBBERCAN: + case EXPLODINGBARREL: + case WOODENHORSE: + case HORSEONSIDE: + case CANWITHSOMETHING: + case FIREBARREL: + case NUKEBARREL: + case NUKEBARRELDENTED: + case NUKEBARRELLEAKED: + case TRIPBOMB: + case EGG: + if (hittype[i].timetosleep > 1) + hittype[i].timetosleep--; + else if (hittype[i].timetosleep == 1) + changespritestat(i, 2); + break; + } +#endif + } + } + +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void execute(int i,int p,int x) { if (actorinfo[sprite[i].picnum].scriptaddress == 0) return; @@ -1724,11 +3872,4 @@ void OnEvent(int iEventID, int p, int i, int x) while (done == 0); } -CCMD(endofgame) -{ - ps[0].timebeforeexit = 120; - ps[0].customexitsound = -1; - ChangeLevel(nullptr, -1); -} - END_DUKE_NS diff --git a/source/games/duke/src/gamevar.cpp b/source/games/duke/src/gamevar.cpp index 5819ac1dd..4746e4d46 100644 --- a/source/games/duke/src/gamevar.cpp +++ b/source/games/duke/src/gamevar.cpp @@ -285,6 +285,10 @@ int GetGameVarID(int id, int sActor, int sPlayer) Printf("GetGameVarID: Invalid Game ID %d\n", id); return -1; } + if (id == g_iThisActorID) + { + return sActor; + } if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER ) { // for the current player @@ -474,6 +478,10 @@ 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" +int g_iLoTagID = -1; // var ID of "LOTAG" +int g_iHiTagID = -1; // ver ID of "HITAG" +int g_iTextureID = -1; // var ID of "TEXTURE" +int g_iThisActorID = -1; // var ID of "THISACTOR" //--------------------------------------------------------------------------- // @@ -1131,6 +1139,11 @@ void AddSystemVars() AddGameVar("ZRANGE", 0, GAMEVAR_FLAG_SYSTEM); AddGameVar("ANGRANGE", 0, GAMEVAR_FLAG_SYSTEM); AddGameVar("AUTOAIMANGLE", 0, GAMEVAR_FLAG_SYSTEM); + AddGameVar("LOTAG", 0, GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYSTEM); + AddGameVar("HITAG", 0, GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYSTEM); + AddGameVar("TEXTURE", 0, GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYSTEM); + AddGameVar("THISACTOR", 0, GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYSTEM); + AddGameVar("ATWITH", 0, GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYSTEM); AddGameVar("RESPAWN_MONSTERS", (intptr_t)&ud.respawn_monsters,GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_PLONG); AddGameVar("RESPAWN_ITEMS",(intptr_t)&ud.respawn_items, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_PLONG); @@ -1211,6 +1224,11 @@ void ResetSystemDefaults(void) g_iZRangeVarID=GetGameID("ZRANGE"); g_iAngRangeVarID=GetGameID("ANGRANGE"); g_iAimAngleVarID=GetGameID("AUTOAIMANGLE"); + g_iAtWithVarID = GetGameID("ATWITH"); + g_iLoTagID = GetGameID("LOTAG"); + g_iHiTagID = GetGameID("HITAG"); + g_iTextureID = GetGameID("TEXTURE"); + g_iThisActorID = GetGameID("THISACTOR"); } diff --git a/source/games/duke/src/gamevar.h b/source/games/duke/src/gamevar.h index 47c1b68d1..4a0b9096b 100644 --- a/source/games/duke/src/gamevar.h +++ b/source/games/duke/src/gamevar.h @@ -112,6 +112,10 @@ extern int g_iWorksLikeVarID; // var ID of "WORKSLIKE" extern int g_iZRangeVarID; // var ID of "ZRANGE" extern int g_iAngRangeVarID; // var ID of "ANGRANGE" extern int g_iAimAngleVarID; // var ID of "AUTOAIMANGLE" +extern int g_iLoTagID; // var ID of "LOTAG" +extern int g_iHiTagID; // ver ID of "HITAG" +extern int g_iTextureID; // var ID of "TEXTURE" +extern int g_iThisActorID; // var ID of "THISACTOR" int AddGameVar(const char *pszLabel, intptr_t lValue, unsigned dwFlags); int GetGameID(const char *szGameLabel); diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index eeac0a790..d0d4ec663 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -413,18 +413,14 @@ void shoot_d(int i, int atwith) if (p >= 0) { - if (isWW2GI()) + SetGameVarID(g_iAimAngleVarID, AUTO_AIM_ANGLE, i, p); + OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j = -1; + if (GetGameVarID(g_iAimAngleVarID, i, p) > 0) { - SetGameVarID(g_iAimAngleVarID, AUTO_AIM_ANGLE, i, p); - OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j = -1; - if (GetGameVarID(g_iAimAngleVarID, i, p) > 0) - { - j = aim(s, GetGameVarID(g_iAimAngleVarID, i, p)); - } + j = aim(s, GetGameVarID(g_iAimAngleVarID, i, p)); } - else - j = aim(s, AUTO_AIM_ANGLE); + if (j >= 0) { dal = ((sprite[j].xrepeat * tilesiz[sprite[j].picnum].y) << 1) + (5 << 8); @@ -2588,7 +2584,6 @@ static void processweapon(int snum, ESyncBits actions, int psect) OnEvent(EVENT_HOLSTER, pi, snum, -1); if (GetGameVarID(g_iReturnVarID, pi, snum) == 0) { - // now it uses the game definitions... if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_HOLSTER_CLEARS_CLIP) { diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index 3b8f19dab..cfcb11b2b 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -280,6 +280,7 @@ void prelevel_d(int g) while (i >= 0) { nexti = nextspritestat[i]; + LoadActor(i, -1, -1); if (sprite[i].lotag == -1 && (sprite[i].cstat & 16)) { diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 6a80eb7a2..188a69997 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -560,6 +560,7 @@ void prelevel_r(int g) while (i >= 0) { nexti = nextspritestat[i]; + LoadActor(i, -1, -1); if (sprite[i].lotag == -1 && (sprite[i].cstat & 16)) { diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index f89775f34..219283e94 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -394,9 +394,9 @@ void GameInterface::SerializeGameState(FSerializer& arc) ("respawn_monsters", ud.respawn_monsters) ("respawn_items", ud.respawn_items) ("respawn_inventory", ud.respawn_inventory) + ("const_visibility", ud.const_visibility) ("god", ud.god) ("eog", ud.eog) - //("auto_run", ud.auto_run) ("monsters_off", ud.monsters_off) ("last_level", ud.last_level) ("coop", ud.coop) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 8e2226308..1cf7ef5d9 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -47,13 +47,14 @@ struct ActorInfo struct TileInfo { int flags; + int loadeventscriptptr; }; struct user_defs { int levelclock; unsigned char god, cashman, eog; - unsigned char show_help, scrollmode, clipping; + unsigned char clipping; char user_name[MAXPLAYERS][32]; unsigned char showweapons; unsigned char user_pals[MAXPLAYERS]; @@ -63,16 +64,15 @@ struct user_defs short last_level, secretlevel; int const_visibility; - int reccnt; int runkey_mode; - int entered_name, shadows, executions, auto_run; - int coords, tickrate, levelstats, m_coop, coop; - int wchoice[MAXPLAYERS][MAX_WEAPONS], playerai; + int shadows; + int coords, levelstats, m_coop, coop; + int wchoice[MAXPLAYERS][MAX_WEAPONS]; int respawn_monsters, respawn_items, respawn_inventory, recstat, monsters_off, brightness; - int m_respawn_items, m_respawn_monsters, m_respawn_inventory, m_recstat, m_monsters_off, detail; + int m_respawn_items, m_respawn_monsters, m_respawn_inventory, m_recstat, m_monsters_off; int m_ffire, ffire, m_player_skill, multimode; int player_skill, marker; //MapRecord* nextLevel;