// VARIABLE DECLARATIONS

gamevar debugvar 0 1
gamevar debugvarb 0 1
gamevar debugvarc 0 1

gamevar mapstarted 0 0
gamevar ONCAR 0 0
gamevar camerasprite -1 0
gamevar spiders 0 0 // the total number of spiders spawned in the map

gamevar mouseox 0 1
gamevar mousex 0 1 // positive or negative, based on player's ang change since last tick
gamevar mouseoy 100 1
gamevar mousey 100 1 // positive or negative, based on player's horiz change since last tick
gamevar mcoordx 159 1
gamevar mcoordy 100 1
gamevar omenuitem 0 1
gamevar soultime 0 1 // a counter used to determine whether it is time to search for soul coins
gamevar soulang -1 1 // the angle of the arrow to soul coin -- -1 if none are around
gamevar souldist 0 1 // the xy distance to the object pointed to by the arrow
gamevar soulsee 0 1 // set to 1 when there is visibility to the target
gamevar lastbootamount 0 1
gamevar boot_on 0 1
gamevar weight 0 1  // total weight of stuff carried
gamevar MAXLOAD 2999 1
gamevar temp 0 0	// used for temporary storage
gamevar tempb 0 0
gamevar tempc 0 0
gamevar tempd 0 0
gamevar target -1 2 // holds the target; used for the Dukebot and EVILDUKE
gamevar spriteid -1 0 // sometimes used for storing the ID of a sprite

gamevar wallpoint 0 0
gamevar numwalls 0 0
gamevar xydist2 0 0
gamevar currwall 0 0

gamevar NOCODE 0 2 // set to 1 when the sprite does not need to execute EVENT_GAME code
gamevar myspawner -1 2

gamevar holosphere 0 1 // amount of holosphere left

gamevar lastring 0 1 // the last ring flown through

gamevar clearlocators 0 0
gamevar locators -1 0 // the highest locator lotag in the map
gamevar locatorids -1 1026

gamevar special1 0 1 // the amount of special ammo for weapon 1 (the pistol)
gamevar special2 0 1
gamevar special3 0 1
gamevar special4 0 1
gamevar special5 0 1
gamevar special6 0 1
gamevar special7 0 1
gamevar special8 0 1
gamevar special9 0 1

gamevar mval 0 2 // the treasure value of the monster in question, used for determining coin drops
gamevar loop 0 2 // used for state dropcoins and a few other things

// special camera vars
gamevar noreccam 0 1
gamevar camxsaved 0 1
gamevar camysaved 0 1
gamevar camzsaved 0 1
gamevar camsectsaved 0 1
gamevar camangsaved 0 1
gamevar camhorizsaved 0 1
gamevar lastcameradist 0 1

// ****The following vars are upgradeable via the upgrade menu*******

gamevar maxhealth 60 1
gamevar maxarmor MAXPLAYERATOMICHEALTH 1 // also max atomic health
gamevar holomult 20 1 // holoduke_energy gets divided by this value to determine holobot life
gamevar running RUNNINGSPEED 1
// increases in increments of 797
gamevar leglevel 0 1
gamevar barrierlevel 0 1 // the force barrier's level
gamevar pdamage 60 1 // % of normal damage that the player's attacks cause
gamevar gogglelevel 0 1 // level of the dimensionx goggles upgrade
gamevar dreduction 100 1 // percentage of enemy damage taken
gamevar combolevel 0 1 // gets set to 1 when barrier purchased
gamevar limits 0 1
gamevar gogglelimit 1500 1
gamevar holodukelimit 3000 1
gamevar firstaidlimit 125 1
gamevar gore 2 0
gamevar tipfield 0 1 // bitfield for which tips have been displayed
gamevar tipdisplay 0 1 // in this var, only the bit corresponding to the tip to be displayed is set, then it is cleared

gamevar weap0lev 60 1 // percent of normal damage caused by weapon 0 (kicks)
gamevar weap1lev 60 1 // percent of normal damage caused by weapon 1 (pistol)
gamevar weap2lev 60 1
gamevar weap3lev 60 1
gamevar weap4lev 60 1
gamevar weap5lev 60 1 // pipebomb and trigger (5 and 10)
gamevar weap6lev 60 1 // shrinker and expander (6 and 11)
gamevar weap7lev 60 1
gamevar weap8lev 100 1
gamevar weap9lev 60 1

gamevar weap0xp 0 1
gamevar weap1xp 0 1
gamevar weap2xp 0 1
gamevar weap3xp 0 1
gamevar weap4xp 0 1
gamevar weap5xp 0 1
gamevar weap6xp 0 1
gamevar weap7xp 0 1
gamevar weap8xp 0 1
gamevar weap9xp 0 1

gamevar xpmult 0 1 // determines the XP penalty, if any (higher = more penalty)
gamevar kickxp 0 1 // just like xpmult but only for kicks

define MAXSTAMINA 1560
gamevar stamina MAXSTAMINA 1

gamevar bits 0 1
gamevar extbits 0 1

// holobot's starting ammo amounts, corresponding to the standard weapon number keys
gamevar hammo2 0 2 // 12
gamevar hammo3 0 2 // 3
gamevar hammo4 0 2 // 20
gamevar hammo5 0 2 // 1
gamevar hammo7 0 2
gamevar hammo8 0 2 // 20
gamevar hammo10 0 2
gamevar botclip 12 1

gamevar M1 -1 1
gamevar M2 -1 1  // used to hold monster IDs for the lightning gun
gamevar M3 -1 1

gamevar D1 -1 1 // used to hold dead body monster IDs for the SUPERBRAIN (for resurrection)
gamevar D2 -1 1
gamevar D3 -1 1

gamevar nuclear 0 2 // set when Dukebot goes nuclear; also used for burning on other actors
gamevar railed 0 2
gamevar score 0 1 // the player's score
gamevar lastscoredisp 0 1 // last score displayed; increases gradually in HUD
gamevar goggles 0 1 // set when goggles on
gamevar pheal 0 1 // counts down and adds health gradually; replaces instant healing
gamevar doublejumpflag 0 1  // true when player has double jumped and hasn't landed yet
gamevar walljump 0 1 // set when dodge-jumping off a wall, reset when dodge ends
gamevar jpresstime 0 1
gamevar superkicking 0 1
gamevar superkickdone 0 1
gamevar spinkick 0 1
gamevar kickimpact 0 1 // set when the kick hits an enemy, so it only hits them once
gamevar MID 181 0     // this value is put in the jump_counter to give player a second jump
gamevar bfgid -1 1 // holds the sprite id of the main bfg blast
gamevar railflag 0 1 // set when railgun is fired; used for checking headshots and stuff
gamevar headshot 0 2 // set on monster when they are a victim of a headshot
gamevar dtripflag 0 1 // 1 means it's okay to place a dtrip
gamevar sideswitch 1 1 // 0 to fire BLASTER (left side) 1 to fire BLASTER2 (right side) for alt fire of Devastator
gamevar dodgeang 0 2 // stores the angle towards which the player is dodging
gamevar dodgeagain 0 1 // time at which player is allowed to dodge again
gamevar mtype 0 2 // set when monster is a variant type (used instead of spritepal)
gamevar revives 3 2 // number of times monster can be revived
gamevar lotag 0 2
gamevar hitag 0 2
gamevar immunity 0 2 // bitfield 1 = bullets 2 = explosives, 4 = kicks, 8 = elements

gamevar countvar 0 2 // used as counter for Dukebots, holds score requirement for upgrades in player
gamevar countvarb 0 2
gamevar countvarc 0 2
gamevar hweapcount 0 2 // used for holobot weapon timing stuff
gamevar hshoot 0 1
gamevar hammtarg 0 2 // the pickup item that the holobot is going for
gamevar holostrength 0 1 // holds the starting strength of the holobot -- will depend on the holoamount when you spawned it
gamevar targetstrength 0 1 // holds the strength of the holobot's current target
gamevar holocansee 0 1 // set if the holobot can see its target
gamevar currholo -1 1 // holds the id of the holobot
gamevar holoweap 0 2
gamevar dodge 0 2 // set when holobot dodging
// holobot weapon selected:  0=none, 1=pistol, 2=shotgun, 3=flak, 4=chaingun, 5=plasma, 6=RPG, 7=shrinker, 8=freezer, 9=hurricane kick, 10=railgun, 11=bfg, 12=devastator
gamevar holostore 0 1 // stores hit points of holobot to respawn him next level

gamevar barrierup -1 2 // holds the ID of the barrier when the barrier is alive
gamevar barriergrow 0 1 // a countdown timer set when monsters can shoot the player, keeping barrier awake
gamevar startflag 0 0
gamevar eventholodukeon 0 1
gamevar nukepart 0 1 // 0 nukeparts (coins):  5  = 1 nuke
gamevar skillpoint STARTSKILL 1 // skillpoints of player 
gamevar ammocoins 0 1 // the number of ammo coins possessed by the player
gamevar nukecount 0 1 // compared to player_par in conjunction with nukehold to determine whether to lay a nuke
gamevar nukehold 0 1 // how long the player has been holding the button to place the nuke
gamevar darthit 0 2 // set when an actor is hit by a BOMBDART; the next hit by any other weapon will cause a huge explosion
gamevar dartstuck 0 1

gamevar hp 0 2 // hit points of the actor or some other actor of interest
gamevar mx 0 0 // The x coordinate of the enemy being targeted
gamevar my 0 0
gamevar mz 0 0
gamevar x 0 0  // The x coordinate of the current actor
gamevar y 0 0
gamevar z 0 0
gamevar xydist 0 1 // 2d distance
gamevar zdist 0 1 // 3d distance, z angle, sometimes the z vel
gamevar angvar 0 0 // The angle of the current actor

gamevar monstx 0 2
gamevar monsty 0 2
gamevar monstz 0 2
gamevar initx 0 2
gamevar inity 0 2
gamevar initz 0 2
gamevar monstatus -1 2
// -1 means it is the starting tick; after that it is 0 until the monster is seen, then 1 until it dies, then 2

gamevar mysector 0 2 // The sector of the actor using hitscan
gamevar mysin 0 1  // The sine of the angle of the actor using hitscan
gamevar mycos 0 1
gamevar hitsector 0 2  // The sector that gets hit by the hitscan
gamevar hitwall 0 1   // The wall that gets hit by the hitscan
gamevar hitsprite -1 2 // The sprite that gets hit by the hitscan
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 // Determines what sort of things can get hit by the hitscan
gamevar xvel 0 0
gamevar yvel 0 0
gamevar zvel 0 0
gamevar scanned -1 2 // set by player on the target when the target is scanned by hitscan

gamevar shade 0 0
gamevar pal 0 0
gamevar orientation 26 1
gamevar digx 0 0
gamevar digy 0 0
gamevar digz 24576 1 // 32768 1
gamevar tilenum 0 0
gamevar holoframe 1348 1
gamevar holotime 0 1
gamevar cursorang 0 1
gamevar menubackang 0 1
gamevar timer 0 1
gamevar message 0 1
gamevar messagetime 0 1

gamevar menutoggle 0 1 // 0 when upgrade menu is off, 1 when on
gamevar menuitem 1 1 // corresponds to the line in the upgrade menu that is highlighted
gamevar cost 0 1 // the cost of the currently selected menu item
gamevar mpresstime 0 1 // used for controlling the menu toggle, so it doesn't toggle when holding key
gamevar fpresstime 0 1 // like above, except for going up the menu
gamevar bpresstime 0 1 // like above, except for going down the menu
gamevar lpresstime 0 1
gamevar rpresstime 0 1
gamevar upresstime 0 1 // for pressing the use key so you don't do instant multiple purchases
gamevar fhold 0 1
gamevar bhold 0 1 // length of time keys have been held
gamevar lhold 0 1
gamevar rhold 0 1
gamevar btap 0 1 // how many times the player has tapped back within a short timeframe
gamevar ftap 0 1 // how many times the player has tapped forward within a short timeframe
gamevar ltap 0 1
gamevar rtap 0 1

gamevar pipeon 1 1 // weapon 5 is the pipebomb; 1 in regular mode, 0 in turret mode
gamevar pipefire 0 1 // set when players presses trigger to blow pipebomb -- signals special exposion
gamevar tripon 1 1 // weapon 8 is laser tripbomb; 1 in regular mode, 0 in alt mode

gamevar gunally 0 1 // a countdown timer indicating that a rotategunally is in the map; used for optimization
gamevar fireinmap 0 1 // same but for STICKYFIRE

// 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 0 0
gamevar snowceiling 32768 0

// high score vars
gamevar ep1hi1 0 1
gamevar ep1hi2 0 1
gamevar ep1hi3 0 1
gamevar ep2hi1 0 1
gamevar ep2hi2 0 1
gamevar ep2hi3 0 1
gamevar ep3hi1 0 1
gamevar ep3hi2 0 1
gamevar ep3hi3 0 1
gamevar ep4hi1 0 1
gamevar ep4hi2 0 1
gamevar ep4hi3 0 1
gamevar ep5hi1 0 1
gamevar ep5hi2 0 1
gamevar ep5hi3 0 1
gamevar ep6hi1 0 1
gamevar ep6hi2 0 1
gamevar ep6hi3 0 1
gamevar ep7hi1 0 1
gamevar ep7hi2 0 1
gamevar ep7hi3 0 1

// episode completion var
gamevar complete 0 1
// it's a bitfield:  1 = ep1, 2 = ep2, 4 = ep3, 8 = ep4, 16 = ep5, 32 = ep6, 64 = ep7

gamevar updatehiscore 0 1 // set to 1 when a game ends, triggering high score save

gamevar WEAPON11_SHOOTS NOVA 1
gamevar WEAPON11_TOTALTIME 26 1
gamevar WEAPON11_FIREDELAY 5 1
gamevar WEAPON11_FIRESOUND NOVA_FIRE 1