
// THIS FILE CONTAINS VARIOUS CUSTOMIZATION OPTIONS FOR THE DUKE PLUS
// MODIFICATION OF DUKE NUKEM 3D FOR THE EDUKE32 PORT


definevolumename 4 DUKE PLUS LEVELS

definelevelname 4 0 dpmaps/hallway.map 00:10 00:05 DUKE PLUS HUB
definelevelname 4 1 dpmaps/WCTime.map 08:00 05:00 WONDERFUL CHRISTMAS TIME
definelevelname 4 2 dpmaps/TTA2.map 00:30 00:08 TRIBUTE TO ACTION II
definelevelname 4 3 dpmaps/blackend.map 06:32 03:16 BLACKENED
definelevelname 4 4 dpmaps/DPeffects.map 02:02 01:01 DP EFFECTS
definelevelname 4 5 dpmaps/project-zero.map 24:00 18:00 PROJECT ZERO
definelevelname 4 6 dpmaps/Desertbase.map 12:00 08:00 DESERT BASE
definelevelname 4 7 dpmaps/Blown_Fuses.map 16:00 08:30 BLOWN FUSES
definelevelname 4 8 dpmaps/Skycar1.map 03:00 01:30 SKYCAR DEMO
definelevelname 4 9 dpmaps/castle.map 03:00 01:30 HAUNTED CASTLE
definelevelname 4 10 dpmaps/sunshine.map 15:00 09:00 SUNSHINE COMPLEX
definelevelname 4 11 dpmaps/Dukecide.map 06:45 05:30 DUKECIDE
definelevelname 4 12 dpmaps/dpcbp.map 18:00 09:50 DP COMMUNITY BUILD PROJECT
definelevelname 4 13 dpmaps/FBTB2.map 18:00 09:50 FROM BASE TO BASE 2
definelevelname 4 14 dpmaps/scar-city.map 10:00 04:00 SCAR CITY
definelevelname 4 15 dpmaps/hfstc.map 10:00 04:00 HAVE FUN STORMING THE CASTLE
definelevelname 4 16 dpmaps/NsA.map 10:00 04:00 NIGHTSHADE ARMY


music 5 NULLSOUND.mid dpmaps/WCTime.mid TTA2.mid dpmaps/blackend.mid futurmil.mid
       dpmaps/projectzero.mid dpmaps/hangar18.mid dpmaps/blnfuses.mid NULLSOUND.mid NULLSOUND.mid dpmaps/sunshine.mid
       dpmaps/dukecide.ogg dpmaps/dpcbp.mid dpmaps/PDExtraction.mid dpmaps/GDistrict.mid dpmaps/hfstc.ogg dpmaps/NsA.ogg

gamevar HUBEXITS 0 0
gamevar completed 0 0


define LODHACK NO // change this to YES or NO to turn on or off Level of detail hack
// if LODHACK is on, models will be replaced by sprites in low framerate situations
define LODISTANCE 8192 // models closer than this distance will not become sprites with LODHACK
// LODHACK IS CURRENTLY DISABLED, PENDING AN OPTIMIZATION
define REALRUNNING NO // change this to YES or NO to turn on or off realistic running
define MANTLING NO // change this to YES or NO to turn on or off mantling
define DODGING NO // change this to YES or NO to turn on or off UT style dodge moves (double tap to dodge)
define FREERUNNER YES // allows the player to use repeated wall jumps to climb walls that make a corner
define AKIMBO_PISTOLS YES // change this to YES or NO to turn on or off akimbo pistols
define ALT_SHOTTY NO // if yes, the game uses a better shotgun model with reloading ability
define ALT_CHAINGUN NO // if yes, the game replaces the chaingun with a MP5, complete with reloading ability
define ALT_RPG NO
define GRAVITY_GUN NO  // if yes, gravity gun replaces the expander
define GRABSTUFF NO // if yes, the player can pickup, throw and drop objects (press open on an object to grab)
define USE_FLARES YES // if yes, Duke can use flares to light dark areas
define MAX_FLARES 3 // the maximum number of flares that can be active at one time
define FLARE_FADETIME 910 // flare begins to fade when this time is reached
define FLARE_LIFETIME 2340 // flare dies when this time is reached
define LIGHT_BRIGHTNESS 140 // 60 is about the brightness of a good torch
define LIGHT_COLOR 25 // same effect as wall pals; most do nothing; 1=blue, 2=red, etc.
defineprojectile LIGHTSOURCEPROJ PROJ_PAL LIGHT_COLOR
define LIGHT_FLICKER 30 // 0=no flicker, 100=completely random intensity between 0 and brightness value
define LIGHT_LAG 3 // higher lag improves performance but adds delay to light effects
define DAMAGE_EFFECTS YES // includes damage decals, blood and more
define OVERHEAT YES // if YES, chaingun does more damage and greater ammo capacity but can overheat

define PISTOLSPREAD 16
define SHOTGUNSPREAD 32
define CHAINGUNSPREAD 32
// THE NORMAL SPREAD FOR ALL WEAPONS IS 32
// THE BIGGER THE VALUE, THE GREATER THE SPREAD
// 4 OR LESS MEANS THERE IS NO SPREAD AT ALL, PERFECT ACCURACY
define KNOCKBACK 10
// KNOCKBACK is the distance monsters are knocked back by the shotgun and other high damage weapons
// 13 is a reasonable KNOCKBACK value; it gets silly at higher numbers

define STOREHEALTH YES // HEALTH PICKUPS WILL BE ADDED TO MEDKIT IF PLAYER HAS MAX HEALTH
define FIRSTAID_MAX MAXPLAYERHEALTH // THE MAX STORAGE FOR FIRST AID KIT; CAN BE SET HIGHER THAN 100
define STEROIDKICKS YES // 4X DAMAGE FROM KICKS WHEN STEROIDS IN USE
define HOLODUKEBOT YES // MONSTERS ARE ELECTROCUTED BY THE HOLODUKE HOLOGRAM
define GOGGLESWITCHES YES // NIGHTVISION GOGGLES REVEAL WHICH DIP SWITCHES TO SET
define BOTALLIES NO // player sprites with lotag 1 become bots in single player
define MONLIFEBARS NO // monster life bars
define RANDOM 0
// FOR A GAME WITH RANDOMIZED MONSTERS AND WEATHER, change the value of RANDOM to a number between 1 and 50 
// keep RANDOM below 10 for best results
gamevar randomstart 0 0 // do not change this

// DEFINES FOR RUNNING:  THESE DO NOTHING UNLESS REALRUNNING IS ON
define SPEED1 45000 // the speed that you start at when you begin to run
define SPEED2TIME 30 // the number of ticks of acceleration before reaching RUNNINGSPEED
define RUNACCEL 256 // the rate of acceleration between SPEED1 and SPEED2; note that SPEED2 will still be reached at SPEED2TIME, regardless of how fast player is running prior to that point

// THE FOLLOWING DEFINES DETERMINE THE DEFAULT PROPERTIES OF MONSTERS
// CHANGING THE DEFAULT FLAGS AND DROPS OF MONSTERS WORKS JUST LIKE...
// SETTING EXTRA AND XVEL ON THE SPRITES IN BUILD AS DESCRIBED IN THE DOCUMENTATION

define EGG_FLAGS 0
define EGG_DROPS 0
define LIZTROOP_FLAGS 0
define LIZTROOP_DROPS 0
define OCTABRAIN_FLAGS 0
define OCTABRAIN_DROPS 0
define DRONE_FLAGS 0
define DRONE_DROPS 0
define COMMANDER_FLAGS 0
define COMMANDER_DROPS 0
define TANK_FLAGS 0
define TANK_DROPS 0
define PIGCOP_FLAGS 0
define PIGCOP_DROPS 0
define LIZMAN_FLAGS 0
define LIZMAN_DROPS 0
define ROTATEGUN_FLAGS 0
define ROTATEGUN_DROPS 0
define BOSS1_FLAGS 0
define BOSS1_DROPS 0
define BOSS2_FLAGS 0
define BOSS2_DROPS 0
define BOSS3_FLAGS 0
define BOSS3_DROPS 0
define NEWBEAST_FLAGS 0
define NEWBEAST_DROPS 0
define BOSS4_FLAGS 0
define BOSS4_DROPS 0
define SHARK_FLAGS 0
define SHARK_DROPS 0
define RECONDP_FLAGS 0 // does not affect normal RECON
define RECONDP_DROPS 0 // does not affect normal RECON

define WEIGHT1 20
define WEIGHT2 40
define WEIGHT3 80
define WEIGHT4 160 // takes super-strength to move
define WEIGHT5 240

// COPIES OF NORMAL DUKE PLUS VALUES FOR SAFE KEEPING
// define SPEED1 43835
// define SPEED2TIME 39
// define ACCEL 240

// STUFF BELOW THIS POINT SHOULD NOT BE ALTERED BY CASUAL USERS!!
// ***************************************************************

// VARIABLE DECLARATIONS


// MAP MIRRORING AND DOUBLESIZED MAPS
gamevar gamespeed 120 0
gamevar gamespeed_display 100 0
gamevar mirrored NO 0
gamevar scaled NO 0
gamevar doubled NO 0
gamevar DONE 0 0
gamevar A 0 0
gamevar B 0 0
gamevar C 0 0
gamevar D 0 0
gamevar E 0 0
gamevar I 0 0
gamevar J 0 0
gamevar K 0 0
gamevar L 0 0
gamevar M 0 0

gamearray SWAPWALLS 16384
gamevar NEXTWALL1 0 0
gamevar NEXTSECTOR1 0 0
gamevar NEXTWALL2 0 0
gamevar NEXTSECTOR2 0 0

// DUKEPLUS MENU VARS

gamevar menunag 1 1
gamevar nomenu 0 0
gamevar nagpos 900 1
gamevar menutoggle 0 1
// 0 = menu off
// 1 = main menu up
// 2 = weapons submenu
// 3 = abilities submenu
// 4 = monsters submenu
// 5 = graphics submenu


gamevar lastchange 0 1
gamevar menuitem 0 1
// 0-5 main menu options
// 10-17 weapons menu options
// 20-29 abilities menu options
// 30-32 monsters menu options
// 40-45 graphical effects options
gamevar lastinput 0 1 // time of last menu input
gamevar headframe 3350 1 // 3350 - 3361
gamevar played 0 0
gamevar playermoves -1 0 // for setting player movement options by map sprite

gamevar playertarg 0 1 // the player's target when locked on in dynamic view mode
gamevar karate YES 0
gamevar smartmonsters NO 0
gamevar goodarmor YES 0
gamevar storehealth STOREHEALTH 0
gamevar maxmedkit FIRSTAID_MAX 0
gamevar steroidkicks STEROIDKICKS 0
gamevar holodukebot HOLODUKEBOT 0
gamevar goggleswitches GOGGLESWITCHES 0
gamevar newjetpack NO 0
gamevar infighting 20 0 // % chance of monster in-fighting after friendly fire incident
gamevar killerpigs 20 0 // some pigcops have db shotguns
gamevar dpsounds YES 0 // replaces some standard sounds
gamevar moretalk NO 0 // extra taunts and shit
gamevar taunt 0 1
gamevar tauntcount 0 1
gamevar stepcount 0 1
gamevar dpcrosshair 6161 0 // custom crosshairs
gamevar dpcrosspal  10 0

gamevar pdamage 100 0 // percent of normal damage inflicted
gamevar mdamage 100 0 // percent of damage received

gamevar WEAPON1_RELOAD 0 1
gamevar PISTOLRELOAD 0 1

gamevar randomize RANDOM 0

// TEMPORARY STORAGE
gamevar xvel 0 0
gamevar yvel 0 0
gamevar zvel 0 0
gamevar temp 0 0
gamevar tempb 0 0
gamevar tempc 0 0
gamevar tempd 0 0
gamevar tempe 0 0
gamevar picnum 0 0
gamevar spriteid 0 0
gamevar zdist 0 0
gamevar mx 0 0
gamevar my 0 0
gamevar mz 0 0
gamevar xydist 0 0
gamevar xydist2 0 0
gamevar angvar 0 0
gamevar canseeplayer 0 2
gamevar canshootplayer 0 2

// MISCELLANEOUS PER-ACTOR VARS

gamevar NOCODE 0 2
gamevar pal 0 2
gamevar hitag 0 2
gamevar lotag 0 2
gamevar laddersound -1 1
gamevar droptile 0 2
gamevar monstflags 0 2
gamevar activator 0 2
gamevar countvar 0 2
gamevar countvarb 0 2
gamevar mysector -1 2
gamevar mywall -1 2
gamevar peractor1 0 2
gamevar peractor2 0 2
gamevar peractor3 0 2
gamevar fallflag 0 2
gamevar peractor4 0 2
gamevar peractor5 0 2
gamevar peractor6 0 2
gamevar peractor7 0 2
gamevar bleeding 0 2
gamevar x 0 2
gamevar y 0 2
gamevar z 0 2
gamevar initx 0 2
gamevar inity 0 2
gamevar initz 0 2
gamevar mtype 0 2
gamevar monstatus 0 2
gamevar playerally 0 2
gamevar monallies 0 1 // countdown var set if there are active monster allies
gamevar target -1 2
gamevar myspawner -1 2
gamevar teleported 0 2
gamevar hp 0 2
gamevar initcstat -1 2
gamevar initshade 0 2
gamevar weight 0 2
gamevar pulse 0 2 // determines whether a sprite's shade pulses
gamevar weap 0 2
gamevar weapcount 0 2
gamevar botclip 0 2
gamevar ammo 200 2
gamevar target2 -1 2
gamevar targetlock 0 2
gamevar traillock 0 2
gamevar underwater 0 2
gamevar burning 0 2
gamevar stun 0 2
gamevar headunder 0 1
gamevar bouncesound -1 2

gamearray mongroup 200 // this array stores the number of monsters left to be killed in each group
gamevar group 0 2 // saves group number of monster

gamevar clearbotarray 1 0
gamearray fusegroups 10 // this array stores the number of fuses that have been placed in each group
gamearray botallies 128 // the array holding the IDs of the BOTALLYs
gamevar botwait 0 0 // indicates if a bot is waiting for the player to proceed
gamevar locatorids -1 1026
gamevar highglass -1 0 // highest member of the glass array
gamevar clearglassarray 1 0
gamearray waypoints 1024 // the array holding the IDs of the waypoints
gamevar numwaypoints 0 0
gamevar clearwaypoints 1 0
gamevar position 0 2
gamevar numallies 0 0
gamevar highally 0 0

gamevar quoterid -1 1 // ID of currently active quoter sprite
gamevar quoteridpic -1 1 // same as above, but for displaying a picture
gamevar sleeping 0 1
gamearray ptrails 100
gamevar ptrailtimer 0 1

// Cutscene gamevars
gamevar cutscene NO 0
gamevar camerasprite -1 1

// portal gamevars
gamevar portalcam -1 1
gamevar portalview 0 1

// survivor gamevars
gamevar showsurvivors 0 0 // countdown variable
gamevar survivors 0 0
gamevar startsurv 0 0
gamevar rescued 0 0
gamevar survkilled 0 0

// Polymer player light vars
gamevar outsideradius 4096 0
gamevar insideradius 4096 0
gamevar outsidered 64 0
gamevar outsidegreen 64 0
gamevar outsideblue 64 0
gamevar insidered 64 0
gamevar insidegreen 64 0
gamevar insideblue 64 0
gamevar outsidepriority 2 0
gamevar insidepriority 2 0

// SKYCAR VARS
gamevar ONCAR 0 1
gamevar lastring 0 1 // the last ring flown through
gamevar booster 0 1 // booster for skycar
gamevar lastcameradist 0 1 // used when the player is in the Skycar
gamevar skyspeed 0 1

// Dynamic F7 mode vars
gamevar viewmode 1 0 // when set, changes F7 to dynamic camera view
gamevar viewcam -1 1 // ID of the active viewmode camera
gamevar lastcameraang 0 1 // what it says
gamevar nextcam -1 1 // ID of the camera in waiting (the next one to be switched to)
gamevar rotcam 0 1
gamevar scanx 0 0
gamevar scany 0 0
gamevar scanz 0 0
gamevar scansect 0 0
define CAMTOLERANCE1 416 // 384
define CAMTOLERANCE2 64
define KILLCAM 4 // higher number means the camera wait longer to switch away if the player is not visible etc
gamevar tolerance 480 0
gamevar distlock -1 0


// bot following vars
gamevar prevsectstartx 0 1
gamevar prevsectstarty 0 1
gamevar prevsectstartz 0 1
gamevar lastsectstartx 0 1
gamevar lastsectstarty 0 1
gamevar lastsectstartz 0 1
gamevar cursectstartx 0 1
gamevar cursectstarty 0 1
gamevar cursectstartz 0 1
gamevar botselected -1 1
gamevar command -1 2

// player's last known location, used by monsters' advanced AI
gamevar lastseenx 0 1
gamevar lastseeny 0 1

gamevar lasttrail 99 2 // saves position of trail array that was last checked by the actor
// this allows them to check one position per tic, rather than doing it all at once
  
// hitscan vars
gamevar mysin 0 1  // The sine of the angle of the actor using hitscan
gamevar mycos 0 1
gamevar hitsector 0 1  // The sector that gets hit by the hitscan
gamevar hitwall 0 1   // The wall that gets hit by the hitscan
gamevar hitwall2 0 1
gamevar nextsector 0 1
gamevar hitsprite -1 1 // The sprite that gets hit by the hitscan
gamevar scannedsprite -1 1
gamevar hitx 0 2  // The x,y,z coordinates that get hit by the hitscan
gamevar hity 0 2
gamevar hitz 0 2
gamevar clipmask 4294901808 0

// laddervars
gamevar onladder 0 1
gamevar topladder 0 2
gamevar laddervel 0 1
gamevar lastladderx 0 1
gamevar lastladdery 0 1
gamevar bits 0 1
gamevar thrust 0 1
gamevar extbits 0 1
gamevar fpress 0 1
gamevar bpress 0 1

gamevar onblock 0 1 // countdown timer; the player is standing on a sprite block

// running vars and defines
gamevar slowrunaccel REALRUNNING 0
gamevar runcount 0 1
gamevar runflag 0 1
gamevar strafedir 0 1
gamevar laststrafedir 0 1
gamevar forbackdir 0 1
gamevar lastforbackdir 0 1
gamevar oposxv 0 1 // velocities from last tick
gamevar oposyv 0 1
gamevar oposzv 0 1

// DUKE PLUS WATER VARS
gamevar oxygen 390 1
gamevar waterpal 0 1
gamevar watereffector -1 2 // ID of the sectoreffector controlling water in the actor's sector

// mantling vars
gamevar canmantle MANTLING 0
gamevar mantling 0 1
gamevar mantwait 0 1
gamevar mantwaittime 0 1
gamevar mantcheck 0 1
define MANTCHECK 6
gamevar mantz 0 1
gamevar jumped 0 1
gamevar backview 0 1

// dodging vars
gamevar candodge DODGING 0
gamevar dodge 0 1
gamevar botdodge 0 2
gamevar dodgeagain 0 1
gamevar dodgeang 0 1
gamevar walljump 0 1
gamevar ftap 0 1
gamevar fpresstime 0 1
gamevar btap 0 1
gamevar bpresstime 0 1
gamevar ltap 0 1
gamevar lpresstime 0 1
gamevar rtap 0 1
gamevar rpresstime 0 1
gamevar fhold 0 1
gamevar bhold 0 1
gamevar lhold 0 1
gamevar rhold 0 1
gamevar jumpadxvel 0 1
gamevar nofalldamage 0 1 // temporarily prevents falling damage

// jumping vars
gamevar jumptap 0 1

// soda and object vars
gamevar holding -1 1
gamevar pickup 0 1
gamevar holdingpic 0 1
gamevar drinksoda 0 1 // counts up to 78 during drinking sequence

// Misc. global vars
gamevar effects DAMAGE_EFFECTS 0
gamevar morefx 31 0 // 63 0
gamevar ppowers 0 0
// bitfield
// 1 bleeding wounds
// 2 burning explosives
// 4 weapon stun
// 8 piercing bullets

gamevar chainsparksprite -1 1
gamevar smokecount 0 0
gamevar activemonsters 0 0
gamevar kickasscount 0 1
gamevar lastspeechtime 0 1
gamevar headsound 0 1
gamevar gogmsgs 0 1

gamevar timer 0 0
gamevar colamachines 0 0
gamevar lifebars MONLIFEBARS 0
gamevar startweapons -1 0 // bitfield determining which weapon options the player must use for the map
// 1 pistol
// 2 shotgun
// 4 chaingun
// 8 rpg
// 16 shrinker (mindblast)
// 32 karate kicks
// 64 expander (gravgun)
// 128 tripbombs (dukemon)
// 256 freezer
// 512 devastator (bfg)
// 1024 DEPISTOLS
gamevar startmonsters -1 0
// 1 advanced ai
// 2 pal 21 liztroops drop laser guns
// 4 double monsters and extra ammo
gamevar startlocks -1 0 // for locking certain options
// 1 lock randomization
// 2 lock damage %
// 4 lock pigs with DB %
gamevar startinventory -1 0
// 1 health storage
// 2 holoduke spawns bot
// 4 dp steroids
// 8 dp goggles
// 16 dp armor
// 32 jump jet
gamevar clearlocators 0 0
gamevar locators -1 0 // the highest locator lotag in the map

// WEATHER VARS
gamevar rainstart 0 0 // only set if a weather sprite is in the map
gamevar raining 0 0 // number of rain or snow sprites spawned per tick, negative when snowing
gamevar rainpal 0 0
gamevar raincstat 0 0
gamevar rainradius 32768 0
gamevar snowceiling 65536 0

// DISPLAY AND WEAPON VARS
gamevar digx 0 1
gamevar digy 0 1
gamevar digz 0 1
gamevar orientation 0 1
gamevar shade 0 1
gamevar knockdist KNOCKBACK 0
gamevar weapswitch 0 1
gamevar akimbo -1 1 
// -1 = you don't have two pistols, 0 = you have two, but you are only using one, > 0 = akimbo
gamevar useakimbo AKIMBO_PISTOLS 0
gamevar usebots 0 0
// bitfield
// 1 = respawn
// 2 =  use pickups
// 4 = show lifebars
// 8 = bot medics
gamevar numbots 0 0
gamevar botspawntime 26 0
gamevar chaingunheat 0 1
gamevar cangrab GRABSTUFF 0
gamevar gravgun GRAVITY_GUN 0
gamevar gravitysprite -1 1
gamevar gravonce 0 1 // nags player with gg instruction until set
gamevar ttime 0 0
gamevar quotestyle 0 1 // 0 = dp style 1 = classic; 2 = mini
gamevar fta 0 1
gamevar ftq 0 1
gamevar mp5ang 0 1
gamevar cannonid -1 1
gamevar quikpipe 0 1

gamevar superkicking 0 1
gamevar superkickdone 0 1
gamevar spinkick 0 1
gamevar reversekick 0 1
gamevar kicktarg -1 1
gamevar kickimpact 0 1 // set when the kick hits an enemy, so it only hits them once
define KENERGY 780 //650
gamevar kickenergy KENERGY 1


// various dp weapon vars
gamevar uselaser YES 0
gamevar usemossberg ALT_SHOTTY 0
gamevar usemp5 ALT_CHAINGUN 0
gamevar usebigrox ALT_RPG 0
gamevar pipethrow YES 0
gamevar altshrinker 0 0
gamevar usemindblast YES 0
gamevar dukemon NO 0 // dukeballs replace tripbombs
gamevar depistols NO 0 // desert eagle style pistols
gamevar usebfg YES 0
gamevar devshotty 1 1
gamevar gunparts 0 1
gamevar wow 0 1
gamevar beamhit 0 1

gamevar altfreeze NO 0 // alt freezer
gamevar shotpitch 0 0
gamevar pipecontrol 1 1
gamearray dukeballpics MAXTRIPBOMBAMMO // picnums of monsters held in dukeballs
gamearray dukeballflags MAXTRIPBOMBAMMO // monstflags of monsters held in dukeballs
gamearray dukeballpals MAXTRIPBOMBAMMO // colors of captured monsters
gamevar dukeballselected 0 1 // which dukeball is held (0-9)
gamevar dukeballstrength 50 1
gamevar reloadonce 0 1 // nags player with reload instruction until set
gamevar reloadpicnum -1 1 // used for the mossberg
gamevar dbpicnum -1 1 // used for double barreled shotgun
gamevar shellstarted -1 1
gamevar CURRWEAP 0 1
gamevar KICKBACKPIC 0 1
gamevar STOPRELOAD 0 1 // set when player tries to fire when reloading the shotgun
gamevar SHOTGUNCLIP 0 1 // the number of shells in the mossberg shotgun; you need to track this for reloading purposes
gamevar ALTSHOTGUN 0 1 
// bitfield:  1 you have mossberg, 2 you have db, 4 db is selected, 
// 8 in the process of switching, 16 you have the REGULAR shotgun
gamevar ALTCHAINGUN 0 1
// bitfield:  1 you have minigun, 2 minigun is selected, 4 in the process of switching
// 8 you have regular chaingun or mp5
gamevar MINIGUNAMMO 0 1 // saves ammo amount of either minigun or regular chaingun weapon while other is in use
gamevar grenadecounter 0 1
gamevar miniguncount 0 1
gamevar gunframe 6208 1
gamevar lastdispframe 0 1 // used for a trick to allow gun animation to be faster than tick rate
// minigun defines
define MINIFIRECOUNT 14 // The minigun begins to fire when it has spun up for this count
define MINISPEEDCOUNT 46 // The minigun fires more rapidly at this count
define MAXSPIN 52 // The maximum amount of spin build up (making this higher makes it take longer to spin down)

gamevar FAKERELOAD 0 1
gamevar ALTMELEE 0 1 // used for db shotgun coldcock attack
gamevar LASERAMMO 0 1 // laser replaces mighty boot when > 0
gamevar LASERFIRE 0 1 // counter that acts as a fake weaponcount/kickback_pic for the laser gun
gamevar LASERCHARGE 0 1
gamevar MP5AMMO 0 1
gamevar MP5INCLIP 0 1

gamevar triphack -1 1 // used for the alt-fire tripbomb
gamevar tripz 0 1

state redefinequotes
redefinequote  2        ACTIVATED
redefinequote  3        ^8PORTABLE MEDKIT
redefinequote  4        LOCKED
redefinequote  6        ^8BOOTS
redefinequote 12        ^23USED STEROIDS
redefinequote 14        ^2AMMO FOR DEVASTATOR
redefinequote 19        ^8ATOMIC HEALTH!
redefinequote 37        ^8STEROIDS
redefinequote 38        ^8ARMOR
redefinequote 39        ^8SCUBA GEAR
redefinequote 41        ^8JETPACK
redefinequote 47        ^23HOLODUKE ON
redefinequote 48        ^23HOLODUKE OFF
redefinequote 51        ^8HOLODUKE
redefinequote 52        ^23JETPACK ON
redefinequote 53        ^23JETPACK OFF
redefinequote 54        ^7CHAINGUN CANNON!
redefinequote 55        ^2PIPEBOMB!
redefinequote 56        ^7ROCKET LAUNCHER!
redefinequote 57        ^7SHOTGUN
redefinequote 58        ^2LASER TRIPBOMB!
redefinequote 59        ^7FREEZETHROWER!
redefinequote 60        ^7GOT SHRINKER/EXPANDER!
redefinequote 61        ^8SMALL MEDKIT: +10
redefinequote 62        ^8LARGE MEDKIT: +30
redefinequote 63        ^2AMMO FOR CHAINGUN CANNON!
redefinequote 64        ^2AMMO FOR RPG!
redefinequote 65        ^2AMMO FOR PISTOL!
redefinequote 66        ^2AMMO FOR FREEZETHROWER!
redefinequote 69        ^2AMMO FOR SHOTGUN
redefinequote 70        ^1BLUE ACCESS CARD REQUIRED
redefinequote 71        ^10RED ACCESS CARD REQUIRED
redefinequote 72        ^7YELLOW ACCESS CARD REQUIRED
redefinequote 75        ^23PROTECTIVE BOOTS ON
redefinequote 76        ^23SCUBA GEAR ON
redefinequote 78        ^2AMMO FOR SHRINKER
redefinequote 87        ^7DEVASTATOR WEAPON
redefinequote 88        ^8JET PACK
redefinequote 89        ^8AIRTANK
redefinequote 90        ^8STEROIDS
redefinequote 91        ^8HOLODUKE
redefinequote 101       ^8NIGHT VISION GOGGLES
redefinequote 104       ^8GOT USED ARMOR
redefinequote 106       ^23NIGHT VISION ON
redefinequote 107       ^23NIGHT VISION OFF
redefinequote 123       ^2AMMO FOR EXPANDER
ends

definequote 1000       ^8PLAYER HEALED BY MEDIC
definequote 1001       ^8DUKEBOT HEALED BY MEDIC
definequote 1002       A DUKEBOT HAS DIED
definequote 1003       DUKEBOT PATROL POINT SET
definequote 1004       DUKEBOT PATROL CANCELLED
definequote 1005       DUKEBOT SELECTED
definequote 1006       PRESS OPEN KEY TO SELECT PATROL AREA
definequote 1007       STRAFE LEFT + STRAFE RIGHT CANCELS
definequote 1008       A DUKEBOT WAS SQUISHED!
definequote 1009	   OVERHEAT
definequote 1010       ^7MP5 SMG!
definequote 1011       ^2MP5 CLIP!
definequote 1012       OUT OF FLARES
definequote 1013       ^7DP 220
definequote 1014	   GOT SHRINKER/GRAVITY GUN!'
definequote 1015	WEATHER
definequote 1016	DUKE PLUS  GAME OPTIONS
definequote 1017	WEAPON OPTIONS
definequote 1018	PLAYER ABILITIES
definequote 1019	ENEMY OPTIONS
definequote 1020	SPECIAL EFFECTS
definequote 1021	GAME SPEED %
definequote 1022	RETURN TO GAME
definequote 1023	WEAPON OPTIONS
definequote 1024	AKIMBO PISTOLS
definequote 1025	CRUIZER SHOTGUN
definequote 1026	MP5 - REPLACES CHAINGUN
definequote 1027	HEAVY RPG
definequote 1028	GRAVITY GUN FOR EXPANDER
definequote 1029	TROOP CAPTAINS USE LASERGUN
definequote 1030	KNOCKBACK DISTANCE
definequote 1031	STRAFE LEFT/RIGHT OR FIRE TO CHANGE VALUES
definequote 1032	TO CHANGE VALUES
definequote 1033	PLAYER ABILITIES
definequote 1034	REALISTIC RUNNING
definequote 1035	MANTLING
definequote 1036	WALL JUMPING
definequote 1037	GRAB/THROW OBJECTS
definequote 1038	HEALTH STORAGE
definequote 1039	MEDKIT MAX
definequote 1040	DP STEROID EFFECTS
definequote 1041	HOLODUKE SPAWNS BOT
definequote 1042	GOGGLES SHOW SWITCH PUZZLES
definequote 1043	ENEMY OPTIONS
definequote 1044	SHOW LIFE BARS
definequote 1045	RANDOM ATTRIBUTES
definequote 1046	EDIT USERPLUS.CON TO CHANGE DEFAULT PROPERTIES
definequote 1047	SPECIAL EFFECTS
definequote 1048	DAMAGE EFFECTS
definequote 1049	WEATHER TYPE
definequote 1050	WEATHER COLOR
definequote 1051	WEATHER TRANSPARENCY
definequote 1052	WEATHER SEVERITY
definequote 1053	YES
definequote 1054	NO
definequote 1055	RAIN
definequote 1056	SNOW
definequote 1057    PRESS FIRE TO MAKE SELECTION
definequote 1058	RETURN TO MAIN MENU
definequote 1059	MUST START NEW GAME!
definequote 1060	SOME OPTIONS LOCKED BY MAP AUTHOR!
definequote 1061    0%
definequote 1062    33%
definequote 1063	66%
definequote 1064	ENHANCED ENEMY AI
definequote 1065	RADIUS
definequote 1066	FORWARD/BACKWARD MOVES CURSOR
definequote 1067	PRESS THE DUKEPLUS MENU KEY TO ACCESS SPECIAL OPTIONS AND DISABLE THIS MESSAGE!
definequote 1068	DAMAGE INFLICTED
definequote 1069	DAMAGE RECEIVED
definequote 1070	RESTORE DUKE PLUS DEFAULTS
definequote 1071	DEFAULT SETTINGS RESTORED
definequote 1072    CLASSIC SETTINGS RESTORED
definequote 1073    PRESS USE TO PICK UP OBJECT
definequote 1074    PRESS ALT-FIRE TO RELOAD
definequote 1075    PRESS ALT-FIRE FOR GRAVITY GRAB
definequote 1076	TIMER MODE
definequote 1077	TRIGGER MODE
definequote 1078	SHRINKER MODE
definequote 1079	MIND BLAST MODE
definequote 1080    RESTORE CLASSIC DEFAULTS
definequote 1081    MIND BLAST - ALT SHRINKER
definequote 1082    FIRE SHOOTS OBJECT, ALT-FIRE DROPS
definequote 1083    SHOTGUN DEVASTATOR
definequote 1084    ROCKET DEVASTATOR
definequote 1085    BFG REPLACES DEVASTATOR
definequote 1086    YOU NEED TO PLACE A FUSE HERE
definequote 1087    MONSTER IN-FIGHTING
definequote 1088    MONSTER CAPTURED!
definequote 1089    ^8GOT EMPTY MONCAPSULE!
definequote 1090    ^2GOT LOADED MONCAPSULE
definequote 1091    MONCAPSULE
definequote 1092    EMPTY
definequote 1093    STRENGTH
definequote 1094    ^7CAPTURE STRENGTH INCREASED!
definequote 1095    MONCAPSULES FOR TRIPBOMBS
definequote 1096    MIRRORED MAPS
definequote 1097    DOUBLE-SIZED MAPS
definequote 1098    DOUBLE MONSTERS & EXTRA AMMO
definequote 1099    USE THE GOGGLES TO REVEAL DIPSWITCH PATTERNS
definequote 1100    MORTAR SHELL!
definequote 1101    HERE COME REINFORCEMENTS!
definequote 1102    SOME AREAS CAN ONLY BE PASSED BY MANTLING ON LEDGES
definequote 1103    ^7DOUBLE BARRELED SHOTGUN!
definequote 1104    % OF PIGS WITH DB SHOTGUN
definequote 1105    NEW SOUNDS
definequote 1106    SUPPLY DROP OFF!
definequote 1107    ENJOY A REFRESHING DUKE COLA
definequote 1108    GOGGLES CAN REVEAL SECRETS
definequote 1109    THESE BOXES CAN BE MOVED...
definequote 1110    MONSTERS CAN BE ALLIES
definequote 1111    ENJOY YOUR ARSENAL
definequote 1112    GRAB THE LEDGE
definequote 1113    PLACE THE FUSES IN THE FUSE BOX
definequote 1114    USE THE GRAVITY GUN ALT-FIRE ON OBJECTS
definequote 1115    HAVE A NICE NAP...
definequote 1116    MONSTERS CAN DROP IMPORTANT ITEMS
definequote 1117    THIS LEVEL IS DESIGNED FOR POLYMOST
definequote 1118    ^7GOT PISTOL!
definequote 1119    CLASSIC
definequote 1120    DUKEMATCH
definequote 1121    DUKE PLUS
definequote 1122    ITEM QUOTE STYLE
definequote 1123    KICK ENERGY
definequote 1124    AN ACCESS CARD HAS BEEN DROPPED!
definequote 1125    KARATE KICKS
definequote 1126    ^2USES OPENGL
definequote 1127    HIRES EXPLOSIONS
definequote 1128    WATER SPLASHES
definequote 1129    PIGCOP JIBS
definequote 1130    SMOKE & TRANSTAR
definequote 1131    FORWARD / BACK
definequote 1132    STRAFE L/R
definequote 1133    PRIMARY FIRE
definequote 1134    ALT FIRE
definequote 1135    ACCELERATES
definequote 1136    BARREL ROLL
definequote 1137    MACHINE GUNS
definequote 1138    BIG BOMB
definequote 1139    MOUSELOOK
definequote 1140    STEER
definequote 1141    OPEN
definequote 1142    EJECT
definequote 1143    ^23ALL RINGS COMPLETED!!
definequote 1144    TIME
definequote 1145    :
definequote 1146    CHARGE
definequote 1147    BATTERY
definequote 1148    GOT LASER PISTOL!
definequote 1149    BETTER ARMOR
definequote 1150    DUKEBOTS
definequote 1151    QUANTITY
definequote 1152    RESPAWN
definequote 1153    BOTS USE PICKUPS
definequote 1154    BOT MEDICS
definequote 1155    BETTER PIPEBOMB THROWS
definequote 1156    F7 VIEW MODE
definequote 1157    CLASSIC
definequote 1158    DYNAMIC
definequote 1159    ENEMY MUZZLEFLASH
definequote 1160    FREEZER PLUS
definequote 1161    PRESS OPEN TO USE CANNON
definequote 1162    DUKE TAUNTS PLUS
definequote 1164    SHOW CHARACTER MODELS
definequote 1165    ^7BATTLELORD AUTO CANNON!
definequote 1166    ^2AUTO CANNON AMMO!
definequote 1167	DOUBLE JUMP STARTS JETPACK
definequote 1168    IMPERIUM CANNON BASE
definequote 1169    IMPERIUM CANNON BARREL
definequote 1170    IMPERIUM CANNON ENERGY UPGRADE
definequote 1171    IMPERIUM CANNON ALT-FIRE
definequote 1172    IMPERIUM CANNON
definequote 1173	KPH
definequote 1174	CUTSCENES AND CAMERA VIEW EFFECTS
definequote 1175	PROPS CAN BE USED IN CREATIVE WAYS
definequote 1176	SCENES CAN BE RENDERED ON ANY SURFACE
definequote 1177	DUKEBOTS FIGHT ALONGSIDE THE PLAYER
definequote 1178	CHECK POINT REACHED
definequote 1179    DUKEPLUS MENU IS DISABLED
definequote 1180	PRESS USE TO EAT FOOD
definequote 1181	WAITING
definequote 1182    HEAVY PISTOLS
definequote 1183    ^1MAX HEALTH UPGRADE!
definequote 1184    ^12MAX ARMOR UPGRADE!
definequote 1185    ^10BLEEDING WOUNDS UPGRADE!
definequote 1186    ^2BURNING EXPLOSIVES UPGRADE!
definequote 1187    ^23WEAPONS STUN UPGRADE!
definequote 1188    ^13PIERCING BULLETS UPGRADE!
definequote 1189	SURVIVORS
definequote 1190    RESCUED:
definequote 1191    REMAINING:
definequote 1192    KILLED:
definequote 1193    ^2A CIVILIAN HAS BEEN KILLED!




useractor notenemy SHRAPNELSPAWNER 0

setvar countvar 0
whilevarn countvar 5
{
	addvar countvar 1
	randvar angvar 2047
	setactor[THISACTOR].ang angvar
	randvar zvel 2048
	ifrnd 128 mulvar zvel -1
	zshoot zvel SHRAPNEL
}
killit

enda

move SPARKMOVE 192
move SLOWSPARK 96
move SPARKUP 96 -96
move SPARKDOWN 96 96
useractor notenemy SPARKPROJ 0
ifcount 9 killit
enda

useractor notenemy SPARK2 0
ifmove 0
{
	getactor[THISACTOR].ang angvar
	addvar angvar 512
	randvar temp 1024
	addvarvar angvar temp
	setactor[THISACTOR].ang angvar
	cstat 128
	sizeat 32 32
	ifrnd 85
	move SPARKUP geth
	else
	ifrnd 128
	move SPARKUP getv geth
	else
	move SPARKDOWN getv geth
}
sizeto 0 0
sizeto 0 0
sizeto 0 0
sizeto 0 0
enda

useractor notenemy SPARK3 0
ifcount 1
{
	ifmove 0
	{
		ifrnd 248 killit else
		move SPARKMOVE randomangle
	}
	sizeto 0 0
	sizeto 0 0
	sizeto 0 0
}
enda

action LIGHTNINGFRAME 3491 1 1 1 1
//action ELECTROFRAMES -2 1 1 1 2

useractor notenemy ELECTROSPAWN 0 LIGHTNINGFRAME

ifmove 0
{
	move INIT
	sizeat 32 64
	ifrnd 128 cstator 4
	cstator 128
	sound 351
	
	ifvare countvar 0
	{
		whilevarn countvar 3
		{
			addvar countvar 1
			espawn ELECTROSPAWN
			setactorvar[RETURN].countvar countvar
		}
	}
}
getactor[THISACTOR].x x
getactor[THISACTOR].y y
randvar temp 256
ifrnd 128 addvarvar x temp else subvarvar x temp
randvar temp 256
ifrnd 128 addvarvar y temp else subvarvar y temp
setactor[THISACTOR].x x
setactor[THISACTOR].y y

ifactioncount 12 killit

ifrnd 64
	hitradius 640 10 10 10 10

enda

spritenoshade RAILTRAIL
action RAILTRAILFRAMES -6629 6 1 1 4
useractor notenemy RAILTRAIL TOUGH RAILTRAILFRAMES

ifvare countvar 0
{
	cstator 130
	ifrnd 128 cstator 4
	ifrnd 128 cstator 8
	sizeat 3 3
	setvar countvar 1
}

ifactioncount 6 killit

enda


spritenoshade RAILHIT
action RAILHITFRAMES -6628 6 1 1 6
useractor notenemy RAILHIT TOUGH RAILHITFRAMES

ifvare countvar 0
{
	setvar countvar 1
	cstator 130
	ifrnd 128 cstator 4
	ifrnd 128 cstator 8
	sizeat 24 24
	spritepal 19
	ifcansee flash
}


ifactioncount 6 killit

enda

// 0 DEFAULT
// 1 WOOD
// 2 TIN
// 3 GRATE
// 4 GRASS
// 5 TILE
// 6 CARPET
// 7 CONCRETE
// 8 SNOW
// 9 WATER
// 10 ELECTRONIC
// 11 ORGANIC

gamevar STEPSOUNDFX 0 1
gamevar FLOORTEX 0 1
gamevar FOOTSTEPCOUNT 0 1

state CHECKSTEPS

// ifvarg underwater 0 { setvar STEPSOUNDFX 9 break }

setvar STEPSOUNDFX 0

switch FLOORTEX

case 0 setvar STEPSOUNDFX 0 break

case 70 case 370 case 735 case 745 case 749 case 821 case 822 case 879 case 880 case 884
case 1188 case 1200 case 1201 case 4110 case 4111 case 4303 case 4428 case 1170
// DC steps
case 3684 case 3685 case 3691

setvar STEPSOUNDFX 1 break

case 150 case 151 case 152 case 153 case 154 case 155 case 156 case 157 case 158 case 159
case 182 case 195 case 196 case 216 case 218 case 220 case 221 case 222 case 223 case 224
case 226 case 227 case 231 case 232 case 242 case 243 case 244 case 257 case 258 case 259
case 278 case 283 case 284 case 285 case 286 case 287 case 288 case 289 case 290 case 291
case 292 case 294 case 295 case 296 case 300 case 302 case 303 case 309 case 311 case 312 
case 313 case 314 case 315 case 317 case 318 case 319 case 322 case 325 case 327 case 342 case 344 
case 345 case 346 case 347 case 348 case 350 case 354 case 365 case 366 case 369 case 378 
case 379 case 380 case 381 case 382 case 383 case 384 case 385 case 392 case 393 case 394 
case 395 case 396 case 397 case 399 case 400 case 412 case 413 case 418 case 419 case 420 
case 441 case 442 case 447 case 448 case 449 case 450 case 451 case 452 case 453 case 454 
case 455 case 456 case 457 case 458 case 459 case 460 case 467 case 469 case 470 case 471 
case 513 case 514 case 515 case 609 case 665 case 709 case 711 case 715 case 717 case 736 
case 737 case 738 case 739 case 754 case 755 case 756 case 767 case 795 case 797 case 798 
case 829 case 843 case 883 case 886 case 913 case 962 case 946 case 947 case 948 
case 1024 case 1097 case 1098 case 1099 case 1102 case 1103
case 1107 case 1108 case 1109 case 1110 case 1117 case 1118 case 1119 case 1120 case 1124
case 1144 case 1173 case 1178 case 1179 case 1187 case 1190 case 4097 case 4098
case 4099 case 4105 case 4106 case 4108 case 4109 case 4117 case 4118 case 4119 case 4162
case 4163 case 4164 case 4165 case 4168 case 4201 case 4202 case 4206 case 4276 case 4277
case 4278 case 4279 case 4282 case 4283 case 4284 case 4285 case 4286 case 4287 case 4288
case 4300 case 4301 case 4302 case 4304 case 4305 case 4308 case 4309 case 4310 case 4330
case 4331 case 4334 case 4335 case 4349 case 4350

// DC steps
case 3693 case 3694 case 3727 case 3779

setvar STEPSOUNDFX 2 break

case 183 case 710 case 915 case 4154 case 4155
// DC steps
case 3712 case 3732

setvar STEPSOUNDFX 3 break

case 803 setvar STEPSOUNDFX 4 break

case 186 case 187 case 188 case 189 case 190 case 191 case 192 case 332 case 720 case 857 case 4102
case 246
// DC steps
case 3692

setvar STEPSOUNDFX 5 break

case 545 case 898 case 899 case 900 case 1218 case 1219
// DC steps
case 3604 case 3612 case 3613 case 3614 case 3615 case 3616

setvar STEPSOUNDFX 6 break

case 181 case 184 case 197 case 207 case 209 case 236 case 237 
case 238 case 239 case 240 case 251 case 252 case 331 
case 334 case 335 case 349 case 367 case 368 case 372 
case 376 case 377 case 414 case 417 case 429 case 430 case 431 case 432 
case 433 case 434 case 435 case 437 case 461 case 465 case 466 case 468 
case 478 case 718 case 723 case 724 case 725 case 734 case 742 
case 743 case 747 case 748 case 750 case 757 case 759 case 760 
case 761 case 763 case 764 case 770 case 772 case 773 case 775 case 780 
case 781 case 782 case 783 case 790 case 793 case 794 case 796 case 799 case 800 
case 801 case 802 case 804 case 805 case 812 case 814 case 815 case 816 
case 817 case 818 case 819 case 823 case 824 case 825 case 827 case 828 
case 852 case 853 case 859 case 876 case 887 case 893 case 894 
case 895 case 1169 case 1171 case 1182 case 1183 case 1184 case 1185 
case 1186 case 1189 case 1191 case 1193 case 1204 case 1205 case 1279 case 2922 
case 3381 case 3384 case 3385 case 3386 case 3387 case 3394 case 3395 case 3396 
case 3398 case 3407 case 4112 case 4151 case 4152 case 4190 case 4208 
case 4210 case 4211 case 4212 case 4213 case 4214 case 4215 case 4216 case 4217 
case 4218 case 4219 case 4220 case 4221 case 4222 case 4223 case 4234 case 4235 
case 4236 case 4255 case 4259 case 4319 case 4320 case 4321 
case 4322 case 4323 case 4332 case 4333 case 5065 case 5066 case 5067 case 5068 
case 5069 case 5070 case 5071 case 5072 case 5073 case 5074 case 5075 case 5076 
case 5077 case 5078 case 5083

setvar STEPSOUNDFX 7 break

case 3416
case 241 
getsector[THISACTOR].floorpal temp
ifvare temp 0 setvar STEPSOUNDFX 8
else ifvare temp 6 setvar STEPSOUNDFX 4
else setvar STEPSOUNDFX 7
break

case 336 case 337 case 338 case 889 case 890 case 891 case 892

setvar STEPSOUNDFX 9 break

case 203 case 268 case 269 case 270 case 271 case 272 case 273 case 274
case 293 case 297 case 298 case 299 case 357 case 358 case 359 
case 360 case 361 case 362 case 363 case 426 case 427 case 428
case 806 case 4127 case 4130 case 4131 case 4132 case 4133 case 4134
case 4135 case 4136 case 4137 case 4138 case 4139 case 4140
case 4141 case 4142 case 4143 case 4144 case 4145 case 4146 case 4147
case 4924 case 4932

ifactor BULLETHOLE setvar STEPSOUNDFX 10 else
ifactor SHOTSPARK1 setvar STEPSOUNDFX 10 else
ifactor 1 setvar STEPSOUNDFX 10 else
ifactor 2 setvar STEPSOUNDFX 10 else
setvar STEPSOUNDFX 7

break

case 1116 case 1130 case 1131 case 1137 case 1139 case 1140 case 1141
case 5079 case 5080 case 5099 case 5102
setvar STEPSOUNDFX 11

break
default break
endswitch

ends

state STOPSTEPSOUNDS
stopsound DUKE_LAND
stopsound STEP1
stopsound STEP2
stopsound STEP3
stopsound STEP4
stopsound WOOD1
stopsound WOOD2
stopsound WOOD3
stopsound WOOD4
stopsound TIN1
stopsound TIN2
stopsound TIN3
stopsound TIN4
stopsound GRATES1
stopsound GRATE2
stopsound GRATE3
stopsound GRATE4
stopsound GRASS1
stopsound GRASS2
stopsound GRASS3
stopsound GRASS4
stopsound TILE1
stopsound TILE2
stopsound TILE3
stopsound TILE4
stopsound CARPET1
stopsound CARPET2
stopsound CARPET3
stopsound CARPET4
stopsound SNOW1
stopsound SNOW2
stopsound SNOW3
stopsound SNOW4
ends

state getfloorz
   getactor[THISACTOR].x x
   getactor[THISACTOR].y y
   updatesector x y mysector
   ifvare mysector -1 getsector[THISACTOR].floorz z
   else
   getflorzofslope mysector x y z
ends


state landsounds
ifvare STEPSOUNDFX 1 { soundonce LANDWOOD  } else
ifvare STEPSOUNDFX 2 { soundonce LANDMETAL  } else
ifvare STEPSOUNDFX 3 { soundonce LANDMETAL  } else
ifvare STEPSOUNDFX 4 { soundonce LANDDIRT } else
ifvare STEPSOUNDFX 7 { soundonce LANDNORMAL  } else
ifvare STEPSOUNDFX 8 { soundonce LANDSNOW  } else
ifvare STEPSOUNDFX 9 { soundonce LANDWATER  } else
ifvare STEPSOUNDFX 11 { soundonce JIBLAND  } else
{  soundonce LANDNORMAL  }
ends

state stepsounds
ifvarg underwater 0 break
randvar FOOTSTEPCOUNT 3
switch STEPSOUNDFX	
		case 0
		case 7
		ifvare FOOTSTEPCOUNT 0 sound STEP1 else
		ifvare FOOTSTEPCOUNT 1 sound STEP2 else
		ifvare FOOTSTEPCOUNT 2 sound STEP3 else
		ifvare FOOTSTEPCOUNT 3 sound STEP4
		break
		
		case 1
		ifvare FOOTSTEPCOUNT 0 sound WOOD1 else
		ifvare FOOTSTEPCOUNT 1 sound WOOD2 else
		ifvare FOOTSTEPCOUNT 2 sound WOOD3 else
		ifvare FOOTSTEPCOUNT 3 sound WOOD4
		break
		
		case 2
		ifvare FOOTSTEPCOUNT 0 sound TIN1 else
		ifvare FOOTSTEPCOUNT 1 sound TIN2 else
		ifvare FOOTSTEPCOUNT 2 sound TIN3 else
		ifvare FOOTSTEPCOUNT 3 sound TIN4
		break
		
		case 3
		ifvare FOOTSTEPCOUNT 0 sound GRATES1 else
		ifvare FOOTSTEPCOUNT 1 sound GRATE2 else
		ifvare FOOTSTEPCOUNT 2 sound GRATE3 else
		ifvare FOOTSTEPCOUNT 3 sound GRATE4
		break
		
		case 4
		ifvare FOOTSTEPCOUNT 0 sound GRASS1 else
		ifvare FOOTSTEPCOUNT 1 sound GRASS2 else
		ifvare FOOTSTEPCOUNT 2 sound GRASS3 else
		ifvare FOOTSTEPCOUNT 3 sound GRASS4
		break
		
		case 5
		ifvare FOOTSTEPCOUNT 0 sound TILE1 else
		ifvare FOOTSTEPCOUNT 1 sound TILE2 else
		ifvare FOOTSTEPCOUNT 2 sound TILE3 else
		ifvare FOOTSTEPCOUNT 3 sound TILE4
		break
		
		case 6
		ifvare FOOTSTEPCOUNT 0 sound CARPET1 else
		ifvare FOOTSTEPCOUNT 1 sound CARPET2 else
		ifvare FOOTSTEPCOUNT 2 sound CARPET3 else
		ifvare FOOTSTEPCOUNT 3 sound CARPET4
		break
		
		case 8
		ifvare FOOTSTEPCOUNT 0 sound SNOW1 else
		ifvare FOOTSTEPCOUNT 1 sound SNOW2 else
		ifvare FOOTSTEPCOUNT 2 sound SNOW3 else
		ifvare FOOTSTEPCOUNT 3 sound SNOW4
		ifactor APLAYER
		{
			  setplayer[THISACTOR].footprintcount 2
			  setplayer[THISACTOR].footprintpal 13
			  setplayer[THISACTOR].footprintshade 0
		}
		break
		
		case 9 
		// soundonce DUKE_ONWATER
		break // STEPSOUNDFX 9 IS FOR WATER
		
		default 
		ifvare FOOTSTEPCOUNT 0 sound STEP1 else
		ifvare FOOTSTEPCOUNT 1 sound STEP2 else
		ifvare FOOTSTEPCOUNT 2 sound STEP3 else
		ifvare FOOTSTEPCOUNT 3 sound STEP4
		break	
		endswitch	
	resetactioncount
ends

state stepsoundstuff

getsector[THISACTOR].floorpicnum FLOORTEX

ifinwater break
ifonwater break
ifp pfalling break

ifp pjetpack break
ifvarn dodge 0 break

state CHECKSTEPS // CHECKS THE STEP DEFINES

ifp pducking break
ifp pstanding { setvar stepcount 32000 break }

// ifactioncount 2 nullop else break

// setvar temp 0
// ifp prunning setvar temp 1
// ifp pwalking setvar temp 1
// ifp pducking setvar temp 0

// ifvare temp 1

getplayer[THISACTOR].posxv mx
divvar mx 644
mulvarvar mx mx
getplayer[THISACTOR].posyv my
divvar my 644
mulvarvar my my
addvarvar mx my
sqrt mx mx
addvarvar stepcount mx

ifvarg stepcount 32768
{
	subvar stepcount 32768
	getplayer[THISACTOR].spritebridge temp // IF THE PLAYER IS ON A FLAT SPRITE
	ifvare temp 1 
	{ 
		getplayer[THISACTOR].sbs tempb // GET THE FLATSPRITE'S ID TAG
		getactor[tempb].picnum temp // CHECK IT'S TEXTURE
		setvarvar FLOORTEX temp // SET THE VARIABLE FLOORTEX TO IT'S TEXTURE
		
	}
	
	state stepsounds
}

ends

state HITMETALSOUND

randvar temp 4
switch temp
case 0
	sound HITMETAL break
case 1
	sound HITMETAL2 break
case 2
	sound HITMETAL3 break
case 3
	sound HITMETAL4 break
case 4
	sound HITMETAL5 break
default break
endswitch


ends

state HITSTONESOUND

randvar temp 4
switch temp
case 0
	sound HITSTONE break
case 1
	sound HITSTONE2 break
case 2
	sound HITSTONE3 break
case 3
	sound HITSTONE4 break
case 4
	sound HITSTONE5 break
default break
endswitch

ends

state WOODHITSOUND

randvar temp 4
switch temp
case 0
	sound HITWOOD break
case 1
	sound HITWOOD2 break
case 2
	sound HITWOOD3 break
case 3
	sound HITWOOD4 break
case 4
	sound HITWOOD5 break
default break
endswitch


ends

state HITDIRTSOUND

randvar temp 2
switch temp
case 0
	sound HITDIRT break
case 1
	sound HITDIRT2 break
case 2
	sound HITDIRT3 break
default break
endswitch


ends

state HITWATERSOUND

randvar temp 2
switch temp
case 0
	sound HITWATER break
case 1
	sound HITWATER2 break
case 2
	sound HITWATER3 break
default break
endswitch


ends

state shootscrap

getactor[THISACTOR].picnum x
cactor ROTATEGUN
getactor[THISACTOR].ang angvar
addvar angvar 1024
randvar temp 480
ifrnd 128 mulvar temp -1
addvarvar angvar temp
setactor[THISACTOR].ang angvar
randvar zdist 2048
ifrnd 128 mulvar zdist -1
subvar zdist 1024
ezshootvar zdist monstflags
randvar temp 24
ifvare monstflags NEWSCRAP3 addvar temp 12
setthisprojectile[RETURN].vel temp
ifvare monstflags NEWSCRAP3
{
	setactor[RETURN].xrepeat 18
	setactor[RETURN].yrepeat 12	
}
else ifvare monstflags NEWSCRAP4
{
	setactor[RETURN].xrepeat 24
	setactor[RETURN].yrepeat 16
}

setactor[THISACTOR].picnum x
ends

spritenoshade SPARKFALL
move DRIFT 64

useractor notenemy SPARKFALL 0

ifmove 0
{
	move DRIFT geth
	ifspawnedby SHOTSPARK1 sizeat 2 2 else
	sizeat 3 3
	setactor[THISACTOR].shade -127
	randvar mtype 512
	subvar mtype 1024
}

movesprite THISACTOR 0 0 mtype CLIPMASK0 RETURN
iffloordistl 8
{
	ifvare peractor1 1 killit
	ifrnd 128 killit else
	{
		setvar peractor1 1
		getactor[THISACTOR].z z
		subvar z 1024
		setactor[THISACTOR].z z
		setactor[THISACTOR].zvel -1024
		setvar mtype 0
	}
}
addvar mtype 160
ifvarg mtype 3072 ifrnd 16 killit
ifcount 6 sizeat 2 2
ifcount 13 sizeat 1 1
ifnotmoving ifcount 3 { resetcount move SLOWSPARK randomangle ifrnd 64 killit }

enda

state sparkstate

randvar A 2
addvar A 1
setvar B 0
getactor[THISACTOR].picnum x
cactor ROTATEGUN
getactor[THISACTOR].ang peractor1
whilevarvarn B A
{
	addvar B 1
	ifvare x SHOTSPARK1
	{
		setvarvar angvar peractor1
		addvar angvar 512
		randvar temp 1024
		addvarvar angvar temp
		setactor[THISACTOR].ang angvar
	}
	else
	{
		randvar angvar 2047
		setactor[THISACTOR].ang angvar
	}
	randvar zdist 3072
	mulvar zdist -1
	espawn SPARKFALL
	setactor[RETURN].zvel zdist
	setactor[RETURN].htpicnum x
}
setactor[THISACTOR].ang peractor1	
setactor[THISACTOR].picnum x
ends

state BULLETHITSOUNDS

switch STEPSOUNDFX
case 0
break

case 1
case 5
	state WOODHITSOUND
	ifvare effects YES
	{
		setvar monstflags NEWSCRAP4
		ifrnd 128 state shootscrap
	}
	break
case 2
case 3
	state HITMETALSOUND
	ifvare effects YES state sparkstate
	break
	
case 4
case 8
	state HITDIRTSOUND
 break

case 7
	state HITSTONESOUND
	ifvare effects YES
	{
		setvar monstflags NEWSCRAP3
		ifrnd 128 state shootscrap 
	}
	break
case 9
	state HITWATERSOUND break
case 10
	state HITSTONESOUND
	ifvare effects YES
	{
		state sparkstate
	}
	break
case 11
    sound HITFLESH 
    spritepal 6
    espawn JIBS6
	setactor[RETURN].xrepeat 32
	setactor[RETURN].yrepeat 32
	setactor[RETURN].zvel 0
	//guts JIBS6 1
    break
default break
endswitch

ends

state pythagoras
// next code gets distance between (x,y) and (hitx,hity), puts result in xydist

setvarvar xydist x
subvarvar xydist hitx
mulvarvar xydist xydist
setvarvar tempb y
subvarvar tempb hity
mulvarvar tempb tempb
addvarvar xydist tempb
sqrt xydist xydist

ends


move PHOLDING

state movespriteprep

changespritestat THISACTOR 1
getplayer[THISACTOR].posx mx
getplayer[THISACTOR].posy my
getactor[THISACTOR].x x
getactor[THISACTOR].y y
subvarvar mx x
subvarvar my y
getangle angvar mx my
cos xvel angvar
sin yvel angvar

ends

// state checkabove

// getactor[THISACTOR].z z
// subvar z 9216
// setactor[THISACTOR].z z
// cactor 1
// findnearactorz CRATE1 384 4096 spriteid
// ifvarn spriteid -1 
// {
// 	setvar weight WEIGHT3
// 	getactorvar[spriteid].weight temp
// 	addvarvar weight temp
// 	 
// }
// else setvar weight WEIGHT3
// cactor CRATE1
// addvar z 9216
// setactor[THISACTOR].z z

// ends

state gravitygrabstate

ifvare initcstat -1 getactor[THISACTOR].cstat initcstat

setvar temp 0
ifvarvare THISACTOR scannedsprite setvar temp 1
ifvarvare THISACTOR gravitysprite setvar temp 1
ifpdistl 1024 setvar temp 1
ifvarvare holding THISACTOR setvar temp 0
ifvarg weight 100 setvar temp 0
findplayer xydist
ifvare temp 1
{
	setvar fallflag 1
	setvarvar gravitysprite THISACTOR
	ifactor TOILET break
	ifactor HYDRENT break
	state movespriteprep
	shiftvarr xydist 6
	getactorvar[gravitysprite].weight tempb
	ifvarl tempb 20 setvar tempb 20
	//shiftvarr tempb 1
	addvarvar xydist tempb
	shiftvarr xydist 2
	divvarvar xvel xydist
	divvarvar yvel xydist
	getplayer[THISACTOR].posz mz
	addvar mz 2048
	getactor[THISACTOR].z z
	ifvarvarl mz z { setactor[THISACTOR].zvel -256 ifpdistg 1024 setvar zvel -4096 } else setvar zvel -1024
	movesprite THISACTOR xvel yvel zvel CLIPMASK0 RETURN
	ifpdistl 1024 //RETRIEVEDISTANCE
	{
		ifvarand initcstat 64 subvar initcstat 64
		setvarvar temp initcstat
		ifvarand temp 1 subvar temp 1
		setactor[THISACTOR].cstat temp
		move PHOLDING faceplayer geth getv
		setvarvar holding THISACTOR
		soundonce KICK_HIT
		getactor[THISACTOR].picnum holdingpic
	}
	break
}
else // SHAKE IT BABY!
{
	ifactor TOILET break
	ifactor HYDRENT break
	//ifactor CRATE1 state checkabove
	getactor[THISACTOR].ang angvar
	randvar temp 32
	ifrnd 128 mulvar temp -1
	addvarvar angvar temp
	setactor[THISACTOR].ang angvar
	state movespriteprep
	
	shiftvarr xydist 6
	setvarvar tempb weight
	//getactorvar[gravitysprite].weight tempb
	ifvarl tempb 20 setvar tempb 20
	shiftvarr tempb 1
	addvarvar xydist tempb
	shiftvarr xydist 1
	divvarvar xvel xydist
	divvarvar yvel xydist
	randvar zvel 644
	subvarvar zvel xydist
	mulvar zvel -1
	ifvarg zvel 0 setvar zvel 0
	ifvarl zvel -256 iffloordistl 16 setactor[THISACTOR].zvel -256
	movesprite THISACTOR xvel yvel zvel CLIPMASK0 RETURN
	
}
	

ends

state gravpickupcode

ifvare CURRWEAP 11 ifvare gravgun YES
{
	ifvare holding -1
	  ifvare gravitysprite -1
			ifvarand bits 262144
			  ifvare pickup 0
				ifcanseetarget
				{
					ifp pfacing
						state gravitygrabstate
					else
					ifpdistl 1280 state gravitygrabstate
				}
	else
	ifvarvare gravitysprite THISACTOR
	ifvare holding -1
	  state gravitygrabstate
}
ends


spritenoshade NEWBLOOD1
spritenoshade NEWBLOOD2
spritenoshade NEWBLOOD3
spritenoshade NEWBLOOD4
spritenoshade NEWBLOOD5

state pickupcode

ifvarg targetlock 0 subvar targetlock 1

ifspritepal 66
{
	getplayer[THISACTOR].heat_on temp
	ifvare temp 0 break
}

setvarvar temp cangrab
ifactor CRATE1 setvar temp YES else
ifactor COLACANSIDE setvar temp YES else
ifactor COLACANSTAND setvar temp YES else
ifactor FUSE setvar temp YES

ifp ponsteroids nullop else ifvarg weight 100 break

ifp pshrunk nullop
else
  ifp palive
    ifp pfacing
      ifpdistl 1024
    	ifvare pickup 0
		  // ifhitspace
		    ifvare holding -1
		      ifvare temp YES
{
	getplayer[THISACTOR].fta temp
	ifvarl temp 6 
	{
		setplayer[THISACTOR].fta 6
		ifvarg sprite[THISACTOR].picnum 4539 ifvarl sprite[THISACTOR].picnum 4549
		setplayer[THISACTOR].ftq 1180
		else
		setplayer[THISACTOR].ftq 1073 
	}
	ifhitspace
	{
		ifcanseetarget addvar targetlock 2
		ifvarg targetlock 3 setvar targetlock 3
		ifvarvare scannedsprite THISACTOR setvar targetlock 3
	            
		ifvarg targetlock 2
		{
			ifvare initcstat -1 getactor[THISACTOR].cstat initcstat
			ifvarand initcstat 64 subvar initcstat 64 // one sided not allowed
			setvarvar temp initcstat
			ifvarand temp 1 subvar temp 1
			setactor[THISACTOR].cstat temp
			setvarvar holding THISACTOR
			resetcount
			setactor[THISACTOR].pitch 0
			setactor[THISACTOR].roll 0
			getactor[THISACTOR].picnum holdingpic
			//sound PICKUPSOUND
			ifmove PHOLDING nullop else
			move PHOLDING faceplayer
			setvar pickup 13 // initiates picking up sequence
			ifvare headsound 0
			{
				ifactor PIGHEADG { globalsound GETAHEAD setvar headsound 1 }
				ifactor 1770 { globalsound GETAHEAD setvar headsound 1 }
				ifactor 2203 { globalsound GETAHEAD setvar headsound 1 }
			}
		}
	}
}

state gravpickupcode

ends

state pickupcode2 // for non actors

ifvarg targetlock 0 subvar targetlock 1

ifspritepal 66
{
	getplayer[THISACTOR].heat_on temp
	ifvare temp 0 break
}

ifp pshrunk nullop
else
 ifhitspace
  ifvare cangrab YES
   ifpdistl 1024
    ifp palive
     ifp pfacing
      ifvare pickup 0
	   ifvare holding -1 		    
{
	ifcanseetarget addvar targetlock 2
	ifvarg targetlock 3 setvar targetlock 3
	ifvarvare scannedsprite THISACTOR setvar targetlock 3
            
	ifvarg targetlock 2
	{
		ifvare initcstat -1 getactor[THISACTOR].cstat initcstat
		ifvarand initcstat 64 subvar initcstat 64 // one sided not allowed
		setvarvar temp initcstat
		ifvarand temp 1 subvar temp 1
		setactor[THISACTOR].cstat temp
		setvarvar holding THISACTOR
		resetcount
		setactor[THISACTOR].pitch 0
		setactor[THISACTOR].roll 0
		getactor[THISACTOR].picnum holdingpic
		//sound PICKUPSOUND
		ifmove PHOLDING nullop else
		move PHOLDING faceplayer
		setvar pickup 13 // initiates picking up sequence
	}
}


state gravpickupcode

ends


move ITEMFLY 384
move ITEMFLY2 480
move ITEMSHOOT 1536 //2048

state throwitem

setactor[THISACTOR].htextra -1
setactor[THISACTOR].htpicnum -1
setactor[THISACTOR].cstat initcstat
setvar holding -1
setvar pickup -12
setvar fallflag 1

setvarvar temp weight
ifvarl temp WEIGHT2 setvar peractor4 36 else
ifvarl temp WEIGHT3 setvar peractor4 26 else
setvar peractor4 16
ends

state moveitem

setactor[THISACTOR].htcgg 0
ifvare gravgun YES ifvare CURRWEAP 11 cstator 256

ifvarvare holding THISACTOR ifvarvare gravitysprite THISACTOR
{
	getplayer[THISACTOR].i spriteid
	getactorvar[spriteid].droptile digz
	ifvarand bits 262144 
	{
		ifvare digz 1
		{
			move INIT
			setvar holding -1 
			ifvarand initcstat 64 subvar initcstat 64
			setactor[THISACTOR].cstat initcstat
			setvar gravitysprite -1 
			setvar pickup -12 
			setvar fallflag 1 
		}
	}
	else
	{
		setactorvar[spriteid].droptile 1
		ifvarand bits 4 
		{
			getplayer[THISACTOR].ammo_amount 11 temp
			ifvarg temp 0
			{
				orvar gravonce 2
				subvar temp 1
				setplayer[THISACTOR].ammo_amount 11 temp
				sound GRAVSHOOT
				// throw it
				setvar holding -1
				setvar gravitysprite -1
				move ITEMSHOOT geth
				setvar peractor4 32
				setvar fallflag 1 // used to tell objects that haven't fallen before that they should start now
				setvar pickup -12
				ifvarand initcstat 64 subvar initcstat 64
				setactor[THISACTOR].cstat initcstat
				spriteflags 16
				getplayer[THISACTOR].ang angvar
				setactor[THISACTOR].ang angvar
				getplayer[THISACTOR].horiz temp
				subvar temp 100
				mulvar temp -120
				subvar zvel -2048
				ifvarl temp -16384 setvar temp -16384
				ifvarg temp 16384 setvar temp 16384
				setactor[THISACTOR].zvel temp
			}
		}
	}
	break
}

ifvarvare holding THISACTOR 
{
	ifhitspace ifvare pickup 0
	{
		setactor[THISACTOR].cstat initcstat
		setvar holding -1
		setvar pickup -12
		setvar fallflag 1
	}
	// don't know whether ifhitweapon has been called before this point, so it gets ugly
	setvar tempc 0
	getactor[THISACTOR].htextra temp
	ifwasweapon KNEE { setvar tempc 1 ifvarl temp 1 setactor[THISACTOR].htpicnum -1 }
	ifvarg temp 0
	{
		getactor[THISACTOR].htpicnum tempb
		ifvare tempb KNEE
		setvar tempc 1
	}	
	ifvare tempc 1
	{
		state throwitem
		mulvar peractor4 2
	}
	break
}

ifvare CURRWEAP 11
{
	getactor[THISACTOR].htextra temp
	ifvarg temp 0
	{
		getactor[THISACTOR].htpicnum picnum
		ifvare picnum SHOTSPARK1
		{
			getactor[THISACTOR].htowner spriteid
			getactor[spriteid].picnum picnum
			ifvare picnum APLAYER ifvarl weight 160
			{
				setvar peractor4 26
				ifvarl weight 40 move ITEMSHOOT geth else
				ifvarl weight 60 move ITEMFLY2 geth else
				ifvarl weight 100 move ITEMFLY geth
				setactor[THISACTOR].htowner THISACTOR
				spriteflags 16
				setvar fallflag 1
				getplayer[THISACTOR].ang angvar
				setactor[THISACTOR].ang angvar
				getplayer[THISACTOR].horiz temp
				subvar temp 100
				mulvar temp -60
				ifvarl temp -6144 setvar temp -6144
				ifvarg temp 6144 setvar temp 6144
				getactor[THISACTOR].zvel tempb
				addvarvar temp tempb
				setactor[THISACTOR].zvel temp
				iffloordistl 8
				{
					getactor[THISACTOR].z z
					subvar z 1024
					setactor[THISACTOR].z z
					setactor[THISACTOR].zvel -2048
				}
			}
		}
	}
}
	

ifmove 0
{
	 ifvare weight 0 setvar weight WEIGHT2
	 move INIT
}

ifvarg peractor4 0 
{
	getactor[THISACTOR].clipdist temp
	ifvarl temp 48 clipdist 48
	ifactor 1769 ifrnd 16 spawn NEWBLOOD1
	ifactor 2202 ifrnd 16 spawn NEWBLOOD1
	ifmove ITEMFLY nullop else ifmove ITEMSHOOT nullop else ifmove ITEMFLY2 nullop else
	{
		ifactor CRATE1 move ITEMFLY geth else
		ifvare peractor4 13 move ITEMFLY geth else
		move ITEMFLY2 geth
		spriteflags 16
		setvar fallflag 1
		ifvare peractor4 13 // for when thrown by an enemy
		{
			setactor[THISACTOR].zvel -1024
		}
		else
		{
			getplayer[THISACTOR].ang angvar
			setactor[THISACTOR].ang angvar
			getplayer[THISACTOR].horiz temp
			subvar temp 100
			mulvar temp -80 //-60
			ifvarl temp -6144 setvar temp -6144
			ifvarg temp 6144 setvar temp 6144
			getactor[THISACTOR].zvel tempb
			addvarvar temp tempb
			// weight adjustment
			ifvarl temp 0 ifvarg weight 40 
				divvar temp 2
			
			
			setactor[THISACTOR].zvel temp
		}
		
	}
	
	getactor[THISACTOR].htmovflag RETURN	
	ifvare RETURN 0
	{
		findnearactorz SHOOTME 480 10240 spriteid 
		ifvarn spriteid -1 { getactorvar[spriteid].myspawner RETURN subvar RETURN 16384 }
	}
	ifvarn RETURN 0 
	{
		// hit something
		addvar RETURN 16384
        ifvarl RETURN 16384
        
        ifvarg RETURN -1
        {
	        // impact sound
	        getactorvar[RETURN].monstatus tempb
	        ifvare tempb 1 sound THROWSMACK
	        setvarvar tempb weight
	        mulvar tempb 2
	        ifmove ITEMSHOOT nullop else shiftvarr tempb 2
	        // add something to prevent ridiculous things, like bottles destroying garbage cans 
	        ifmove ITEMFLY ifvarl weight WEIGHT3 nullop else
	        {
			    setactor[RETURN].htextra tempb
			    setactor[RETURN].htpicnum SHOTSPARK1
			    setactor[RETURN].htowner THISACTOR
			    getactor[THISACTOR].ang angvar
			    setactor[RETURN].htang angvar
		    }
  
        }
        ifmove ITEMSHOOT 
        {
	        setvarvar tempb weight
	        mulvar tempb 2
	        move ITEMFLY2 geth  
	        setactor[THISACTOR].htextra tempb
	        setactor[THISACTOR].htpicnum RADIUSEXPLOSION //SHOTSPARK1
	        setactor[THISACTOR].htowner THISACTOR
        }
	    else
	    ifmove ITEMFLY2 move ITEMFLY geth 
	    else
	    {
		    getactor[THISACTOR].owner spriteid
		    ifvarvarn RETURN spriteid
	    	ifvarg peractor4 1 setvar peractor4 1
    	}
	}
	iffloordistl 4 
	{
		ifvarg peractor4 6
		{
			ifvarg weight 40 subvar peractor4 2
			subvar peractor4 2
			ifvarn bouncesound -1 soundvar bouncesound
			getactor[THISACTOR].z z
			subvar z 1024
			setactor[THISACTOR].z z
			setvarvar temp peractor4
			mulvar temp -64
			setactor[THISACTOR].zvel temp
		}
	}
	subvar peractor4 1
	iffloordistl 2 nullop else 
	ifvarg underwater 0 nullop else ifinwater nullop else
	ifvare peractor4 0 setvar peractor4 1
	ifvare peractor4 0
		move INIT
	
}

ends