state armorline
  mulvar num 19
  divvar num 200
  setvar tmp 19
  subvarvar tmp num
  whilevarn tmp 0 { subvar tmp 1 rotatesprite x y 65536 0 9701 0 0 26 0 0 xdim ydim addvar x -1 }
ends

state drawinvnum
   setvarvar tmp num
   modvar tmp 10
   addvar tmp 7370
   rotatesprite x y 65536 0  tmp 0 col 26 0 0 xdim ydim
   addvar x -5
    ifvarg num 9
   {
      setvarvar tmp num
      divvar tmp 10
      modvar tmp 10
      addvar tmp 7370
      rotatesprite x y 65536 0  tmp 0 col 26 0 0 xdim ydim
      addvar x -5
    }
    ifvarg num 99
    {
      setvarvar tmp num
      divvar tmp 100
      addvar tmp 7370
      rotatesprite x y 65536 0  tmp 0 col 26 0 0 xdim ydim
      
    }
ends

state drawweapnum
   setvarvar tmp num
   modvar tmp 10
   addvar tmp 7350
   rotatesprite x y 65536 0  tmp numshade col 26 0 0 xdim ydim
   addvar x -4
    ifvarg num 9
    {
      setvarvar tmp num
      divvar tmp 10
      modvar tmp 10
      addvar tmp 7350
      rotatesprite x y 65536 0  tmp numshade col 26 0 0 xdim ydim
      addvar x -4
    }
    ifvarg num 99
    {
      setvarvar tmp num
      divvar tmp 100
      addvar tmp 7350
      rotatesprite x y 65536 0  tmp numshade col 26 0 0 xdim ydim
      
    }
setvar col 0
setvar numshade 0
ends

state drawarmnum
   ifvare num 0 break
   setvarvar tmp num
   modvar tmp 10
   addvar tmp 7350
   rotatesprite x y 65536 0  tmp 0 col 26 0 0 xdim ydim
   addvar x -4
    ifvarg num 9
    {
      setvarvar tmp num
      divvar tmp 10
      modvar tmp 10
      addvar tmp 7350
      rotatesprite x y 65536 0  tmp 0 col 26 0 0 xdim ydim
      addvar x -4
    }
    ifvarg num 99
    {
      setvarvar tmp num
      divvar tmp 100
      addvar tmp 7350
      rotatesprite x y 65536 0  tmp 0 col 26 0 0 xdim ydim
      
    }
ends

state drawnumR
   setvarvar tmp num
   modvar tmp 10
   addvar tmp 7310
   rotatesprite x y 65536 0  tmp 0 col 26 0 0 xdim ydim
   addvar x -9
    ifvarg num 9
    {
      setvarvar tmp num
      divvar tmp 10
      modvar tmp 10
      addvar tmp 7310
      rotatesprite x y 65536 0  tmp 0 col 26 0 0 xdim ydim
      addvar x -9
    }
    ifvarg num 99
    {
      setvarvar tmp num
      divvar tmp 100
      addvar tmp 7310
      rotatesprite x y 65536 0  tmp 0 col 26 0 0 xdim ydim
      
    }
ends

state drawnumB
   setvarvar tmp num
   modvar tmp 10
   addvar tmp 7360
   rotatesprite x y 65536 0  tmp 0 col 26 0 0 xdim ydim
   addvar x -9
    ifvarg num 9
    {
      setvarvar tmp num
      divvar tmp 10
      modvar tmp 10
      addvar tmp 7360
      rotatesprite x y 65536 0  tmp 0 col 26 0 0 xdim ydim
      addvar x -9
    }
    ifvarg num 99
    {
      setvarvar tmp num
      divvar tmp 100
      addvar tmp 7360
      rotatesprite x y 65536 0  tmp 0 col 26 0 0 xdim ydim
      
    }
ends

state widearmorline
  mulvar num 19
  divvar num 200
  setvar tmp 19
  subvarvar tmp num
  whilevarn tmp 0 { subvar tmp 1 rotatesprite x y 65536 0 9701 0 0 538 0 0 xdim ydim addvar x -1 }
ends

state widedrawinvnum
   setvarvar tmp num
   modvar tmp 10
   addvar tmp 7370
   rotatesprite x y 65536 0  tmp 0 col 538 0 0 xdim ydim
   addvar x -5
    ifvarg num 9
   {
      setvarvar tmp num
      divvar tmp 10
      modvar tmp 10
      addvar tmp 7370
      rotatesprite x y 65536 0  tmp 0 col 538 0 0 xdim ydim
      addvar x -5
    }
    ifvarg num 99
    {
      setvarvar tmp num
      divvar tmp 100
      addvar tmp 7370
      rotatesprite x y 65536 0  tmp 0 col 538 0 0 xdim ydim
      
    }
ends

state widedrawarmnum
   ifvare num 0 break
   setvarvar tmp num
   modvar tmp 10
   addvar tmp 7350
   rotatesprite x y 65536 0  tmp 0 col 538 0 0 xdim ydim
   addvar x -4
    ifvarg num 9
    {
      setvarvar tmp num
      divvar tmp 10
      modvar tmp 10
      addvar tmp 7350
      rotatesprite x y 65536 0  tmp 0 col 538 0 0 xdim ydim
      addvar x -4
    }
    ifvarg num 99
    {
      setvarvar tmp num
      divvar tmp 100
      addvar tmp 7350
      rotatesprite x y 65536 0  tmp 0 col 538 0 0 xdim ydim
      
    }
ends

state widedrawnumR
   setvarvar tmp num
   modvar tmp 10
   addvar tmp 7310
   rotatesprite x y 65536 0  tmp 0 col 282 0 0 xdim ydim
   addvar x -9
    ifvarg num 9
    {
      setvarvar tmp num
      divvar tmp 10
      modvar tmp 10
      addvar tmp 7310
      rotatesprite x y 65536 0  tmp 0 col 282 0 0 xdim ydim
      addvar x -9
    }
    ifvarg num 99
    {
      setvarvar tmp num
      divvar tmp 100
      addvar tmp 7310
      rotatesprite x y 65536 0  tmp 0 col 282 0 0 xdim ydim
      
    }
ends

state widedrawnumB
   setvarvar tmp num
   modvar tmp 10
   addvar tmp 7360
   rotatesprite x y 65536 0  tmp 0 col 282 0 0 xdim ydim
   addvar x -9
    ifvarg num 9
    {
      setvarvar tmp num
      divvar tmp 10
      modvar tmp 10
      addvar tmp 7360
      rotatesprite x y 65536 0  tmp 0 col 282 0 0 xdim ydim
      addvar x -9
    }
    ifvarg num 99
    {
      setvarvar tmp num
      divvar tmp 100
      addvar tmp 7360
      rotatesprite x y 65536 0  tmp 0 col 282 0 0 xdim ydim
      
    }
ends

state drawnumW
   setvarvar tmp num
   modvar tmp 10
   addvar tmp 2930
   rotatesprite x y 65536 0  tmp 0 col 0 0 0 xdim ydim
   addvar x -9
    ifvarg num 9
    {
      setvarvar tmp num
      divvar tmp 10
      modvar tmp 10
      addvar tmp 2930
      rotatesprite x y 65536 0  tmp 0 col 0 0 0 xdim ydim
      addvar x -9
    }
    ifvarg num 99
    {
      setvarvar tmp num
      divvar tmp 100
      addvar tmp 2930
      rotatesprite x y 65536 0  tmp 0 col 0 0 0 xdim ydim
    }
ends

// Start menu code

onevent EVENT_DISPLAYMENUREST
getticks a
divvar a 1 // SLOW MOTION
divvar a 150
modvar a 8
setvar picnum BLOODLINE
addvarvar picnum a
getticks b
divvar b 1 // SLOW MOTION
divvar b 3
addvar b 208 setvarvar coor b modvar coor 400 rotatesprite 12 coor 65536 0 7148 0 0 0 0 0 xdim ydim
addvar b 82 setvarvar coor b modvar coor 400 rotatesprite 35 coor 40960 0 7148 0 0 0 0 0 xdim ydim
addvar b 123 setvarvar coor b modvar coor 400 rotatesprite 61 coor 65536 0 7148 0 0 0 0 0 xdim ydim
addvar b 98 setvarvar coor b modvar coor 400 rotatesprite 92 coor 49152 0 7148 0 0 0 0 0 xdim ydim
addvar b -200 setvarvar coor b modvar coor 400 rotatesprite 123 coor 57344 0 7148 0 0 0 0 0 xdim ydim
addvar b -199 setvarvar coor b modvar coor 400 rotatesprite 154 coor 57344 0 7148 0 0 0 0 0 xdim ydim
addvar b -350 setvarvar coor b modvar coor 400 rotatesprite 183 coor 57344 0 7148 0 0 0 0 0 xdim ydim
addvar b -100 setvarvar coor b modvar coor 400 rotatesprite 203 coor 57344 0 7148 0 0 0 0 0 xdim ydim
addvar b -100 setvarvar coor b modvar coor 400 rotatesprite 222 coor 65536 0 7148 0 0 0 0 0 xdim ydim
addvar b -160 setvarvar coor b modvar coor 400 rotatesprite 244 coor 49152 0 7148 0 0 0 0 0 xdim ydim
addvar b -195 setvarvar coor b modvar coor 400 rotatesprite 281 coor 57344 0 7148 0 0 0 0 0 xdim ydim
addvar b -200 setvarvar coor b modvar coor 400 rotatesprite 306 coor 57344 0 7148 0 0 0 0 0 xdim ydim

rotatesprite 160 -2 65536 0 picnum 0 0 0 0 0 xdim ydim
endevent

onevent EVENT_DISPLAYBONUSSCREEN
	
	ifvare peractor 0 { stopallsounds setvar peractor 1 }
	rotatesprite 0 0 65536 0 7169 0 0 24 0 0 xdim ydim
	rotatesprite 160 20 65536 0 7158 0 0 0 0 0 xdim ydim
	
	// LEVEL STATS
	rotatesprite 110 25 65536 0 2951 0 0 0 0 0 xdim ydim
	rotatesprite 120 25 65536 0 2944 0 0 0 0 0 xdim ydim
	rotatesprite 130 25 65536 0 2961 0 0 0 0 0 xdim ydim
	rotatesprite 140 25 65536 0 2944 0 0 0 0 0 xdim ydim
	rotatesprite 150 25 65536 0 2951 0 0 0 0 0 xdim ydim
	
	rotatesprite 165 25 65536 0 2958 0 0 0 0 0 xdim ydim
	rotatesprite 175 25 65536 0 2959 0 0 0 0 0 xdim ydim
	rotatesprite 185 25 65536 0 2940 0 0 0 0 0 xdim ydim
	rotatesprite 195 25 65536 0 2959 0 0 0 0 0 xdim ydim
	rotatesprite 205 25 65536 0 2958 0 0 0 0 0 xdim ydim
	
	//KILLS
	rotatesprite 71 61 65536 0 2950 0 4 0 0 0 xdim ydim
	rotatesprite 81 61 65536 0 2948 0 4 0 0 0 xdim ydim
	rotatesprite 86 61 65536 0 2951 0 4 0 0 0 xdim ydim
	rotatesprite 96 61 65536 0 2951 0 4 0 0 0 xdim ydim
	rotatesprite 106 61 65536 0 2958 0 4 0 0 0 xdim ydim
	rotatesprite 116 56 65536 0 9338 0 4 0 0 0 xdim ydim
	
	rotatesprite 70 60 65536 0 2950 0 0 0 0 0 xdim ydim
	rotatesprite 80 60 65536 0 2948 0 0 0 0 0 xdim ydim
	rotatesprite 85 60 65536 0 2951 0 0 0 0 0 xdim ydim
	rotatesprite 95 60 65536 0 2951 0 0 0 0 0 xdim ydim
	rotatesprite 105 60 65536 0 2958 0 0 0 0 0 xdim ydim
	rotatesprite 115 55 65536 0 9338 0 0 0 0 0 xdim ydim
	
	//OF
	rotatesprite 201 61 65536 0 2954 0 4 0 0 0 xdim ydim
	rotatesprite 211 61 65536 0 2945 0 4 0 0 0 xdim ydim
	rotatesprite 200 60 65536 0 2954 0 0 0 0 0 xdim ydim
	rotatesprite 210 60 65536 0 2945 0 0 0 0 0 xdim ydim
	
	rotatesprite 201 81 65536 0 2954 0 4 0 0 0 xdim ydim
	rotatesprite 211 81 65536 0 2945 0 4 0 0 0 xdim ydim
	rotatesprite 200 80 65536 0 2954 0 0 0 0 0 xdim ydim
	rotatesprite 210 80 65536 0 2945 0 0 0 0 0 xdim ydim
	
	setvar col 4
	getplayer[THISACTOR].actors_killed num
	setvar x 171 setvar y 61 state drawnumW
	getplayer[THISACTOR].max_actors_killed num
    setvar x 246 setvar y 61 state drawnumW
	
	setvar col 0
	getplayer[THISACTOR].actors_killed num
	setvar x 170 setvar y 60 state drawnumW
	getplayer[THISACTOR].max_actors_killed num
    setvar x 245 setvar y 60 state drawnumW
	
	//SECRETS
	rotatesprite 71 81 65536 0 2958 0 4 0 0 0 xdim ydim
	rotatesprite 81 81 65536 0 2944 0 4 0 0 0 xdim ydim
	rotatesprite 91 81 65536 0 2942 0 4 0 0 0 xdim ydim
	rotatesprite 101 81 65536 0 2957 0 4 0 0 0 xdim ydim
	rotatesprite 111 81 65536 0 2944 0 4 0 0 0 xdim ydim
	rotatesprite 121 81 65536 0 2959 0 4 0 0 0 xdim ydim
	rotatesprite 131 81 65536 0 2958 0 4 0 0 0 xdim ydim
	rotatesprite 141 76 65536 0 9338 0 4 0 0 0 xdim ydim
	
	rotatesprite 70 80 65536 0 2958 0 0 0 0 0 xdim ydim
	rotatesprite 80 80 65536 0 2944 0 0 0 0 0 xdim ydim
	rotatesprite 90 80 65536 0 2942 0 0 0 0 0 xdim ydim
	rotatesprite 100 80 65536 0 2957 0 0 0 0 0 xdim ydim
	rotatesprite 110 80 65536 0 2944 0 0 0 0 0 xdim ydim
	rotatesprite 120 80 65536 0 2959 0 0 0 0 0 xdim ydim
	rotatesprite 130 80 65536 0 2958 0 0 0 0 0 xdim ydim
	rotatesprite 140 75 65536 0 9338 0 0 0 0 0 xdim ydim
	
	setvar col 4
	getplayer[THISACTOR].secret_rooms num
	setvar x 171 setvar y 81 state drawnumW
    getplayer[THISACTOR].max_secret_rooms num
    setvar x 246 setvar y 81 state drawnumW

	setvar col 0
	getplayer[THISACTOR].secret_rooms num
	setvar x 170 setvar y 80 state drawnumW
    getplayer[THISACTOR].max_secret_rooms num
    setvar x 245 setvar y 80 state drawnumW
	soundonce MOANS
	
endevent

onevent EVENT_GETLOADTILE
setvar RETURN 7169
endevent

onevent EVENT_GETMENUTILE
setvar RETURN 7166
endevent

onevent EVENT_DISPLAYBONUSSCREEN
getactorvar[THISACTOR].bodyshield BODYSHIELD_AMOUNT
getactorvar[THISACTOR].fireshield FIRESHIELD_AMOUNT
getactorvar[THISACTOR].spiritshield SPIRITSHIELD_AMOUNT
setvarvar SAVED_BODYSHIELD BODYSHIELD_AMOUNT
setvarvar SAVED_FIRESHIELD FIRESHIELD_AMOUNT
setvarvar SAVED_SPIRITSHIELD SPIRITSHIELD_AMOUNT
endevent

// Hud code

onevent EVENT_DISPLAYCROSSHAIR
setvar RETURN -1 
{
    setvar x 160
    setvar y 100
    getuserdef[THISACTOR].crosshairscale z
    mulvar z 65536
    divvar z 100
    setvar picnum 7439
    rotatesprite x y z 0 picnum 0 0 0
    windowx1 windowy1 windowx2 windowy2
}
endevent

onevent EVENT_DISPLAYREST

ifvare CRBALLON 1

{

	getplayer[THISACTOR].i r0
	setvar temp 0
	whilevarvarn temp numplayers
	{
		getplayer[temp].i spriteid
		ifvarvarn spriteid r0 { setvarvar peractor temp }
		addvar temp 1
	}
	
	getplayer[peractor].posx x
	getplayer[peractor].posy y
	getplayer[peractor].posz z
	getplayer[peractor].ang ang
	getplayer[peractor].horiz phoriz
	getplayer[peractor].horizoff temp
	getplayer[peractor].cursectnum sect1
	addvar ang 1024
	addvarvar phoriz 100 //temp
/*
	setvar y2 10
	setvar x2 -1120
	whilevarn y2 76
	{
		setvarvar y3 y2
		addvar y3 3
		subvar phoriz 15
		addvar x2 102
		setvar crtmp1 1024
		mulvarvar crtmp1 crtmp1
		setvarvar crtmp2 x2
		mulvarvar crtmp2 crtmp2
		subvarvar crtmp1 crtmp2
		sqrt crtmp1 crtmp2
		
		divvar crtmp2 40
		setvar x3 270
		setvar crtmp3 290
		subvarvar x3 crtmp2
		addvarvar crtmp3 crtmp2
		showview x y z ang phoriz sect1 x3 y2 crtmp3 y3
		addvar y2 3
	}
	rotatesprite 230 8 65536 0 6803 0 0 27 0 0 xdim ydim
*/	
	
	getplayer[THISACTOR].posx x
	getplayer[THISACTOR].posy y
	getplayer[THISACTOR].posz z
	getplayer[THISACTOR].ang ang
	getplayer[THISACTOR].horiz phoriz
	getplayer[THISACTOR].horizoff temp
	addvarvar phoriz temp
	updatesectorz x y z sectorid
	showview x y z ang phoriz sectorid 230 9 307 87
	subvar ang 265
	showview x y z ang phoriz sectorid 192 9 269 87
	rotatesprite 230 8 65536 0 6803 0 0 27 0 0 xdim ydim
	

}

ifvarn detonateplayer 0
{
switch detonateplayer
	case 1
	case 2
	case 3
		setvar xweapon 100
	    setvar yweapon 160
		ifvare hudtype 0 { subvarvar yweapon 22 }
	    setvar tilenumweapon DYNAMITE
	    addvar tilenumweapon 46
		rotatesprite xweapon yweapon 65536 128 tilenumweapon shade palweapon 0 0 0 xdim ydim
		
		setvar xweapon 210
	    setvar yweapon 165
		ifvare hudtype 0 { subvarvar yweapon 22 }
	    setvar tilenumweapon DYNAMITE
	    addvar tilenumweapon 47
		rotatesprite xweapon yweapon 65536 -128 tilenumweapon shade palweapon 0 0 0 xdim ydim
	break
	case 4
	case 5
	case 6
		setvar xweapon 80
	    setvar yweapon 160
		ifvare hudtype 0 { subvarvar yweapon 22 }
	    setvar tilenumweapon DYNAMITE
	    addvar tilenumweapon 46
		rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon 0 0 0 xdim ydim
		
		setvar xweapon 230
	    setvar yweapon 165
		ifvare hudtype 0 { subvarvar yweapon 22 }
	    setvar tilenumweapon DYNAMITE
	    addvar tilenumweapon 47
		rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon 0 0 0 xdim ydim
	break
	case 7
	case 8
	case 9
		setvar xweapon 60
	    setvar yweapon 180
		ifvare hudtype 0 { subvarvar yweapon 22 }
	    setvar tilenumweapon DYNAMITE
	    addvar tilenumweapon 46
		rotatesprite xweapon yweapon 65536 -128 tilenumweapon shade palweapon 0 0 0 xdim ydim
		
		setvar xweapon 250
	    setvar yweapon 185
		ifvare hudtype 0 { subvarvar yweapon 22 }
	    setvar tilenumweapon DYNAMITE
	    addvar tilenumweapon 47
		rotatesprite xweapon yweapon 65536 192 tilenumweapon shade palweapon 0 0 0 xdim ydim
	break
	case 10
	case 11
	case 12
		setvar xweapon 40
	    setvar yweapon 200
		ifvare hudtype 0 { subvarvar yweapon 22 }
	    setvar tilenumweapon DYNAMITE
	    addvar tilenumweapon 46
		rotatesprite xweapon yweapon 65536 -256 tilenumweapon shade palweapon 0 0 0 xdim ydim
		
		setvar xweapon 270
	    setvar yweapon 205
		ifvare hudtype 0 { subvarvar yweapon 22 }
	    setvar tilenumweapon DYNAMITE
	    addvar tilenumweapon 47
		rotatesprite xweapon yweapon 65536 384 tilenumweapon shade palweapon 0 0 0 xdim ydim
	break
endswitch
}

getactorvar[THISACTOR].flamedamage temp
ifvarg temp 0
{
	setvar x 10
	whilevarn x 352
	{
		getticks tmp
		divvar tmp 50
		setvarvar x2 x
		mulvarvar x2 4
		addvarvar tmp x2
		modvar tmp 13
		setvar picnum 7221
		addvarvar picnum tmp
		
		switch x
			case 10 
			case 314
			setvarvar tmp2 temp
			subvar tmp2 40
			ifvarl COUNTER 10 { setvarvar SIZE COUNTER mulvar SIZE 9216 } else 
			ifvarg COUNTER 9 ifvarvarl COUNTER tmp2 { setvar SIZE 95027 } else
			ifvarvarg COUNTER tmp2 { setvarvar SIZE COUNTER subvarvar SIZE tmp2 mulvar SIZE -4608 addvar SIZE 95027 }
			break
			case 48 
			case 276 
			ifvarl COUNTER 10 { setvarvar SIZE COUNTER mulvar SIZE 9216 } else 
			ifvarg COUNTER 9 ifvarvarl COUNTER tmp2 { setvar SIZE 95027 } else
			ifvarvarg COUNTER tmp2 { setvarvar SIZE COUNTER subvarvar SIZE tmp2 mulvar SIZE -4608 addvar SIZE 95027 }
			break
			case 86
			case 238
			ifvarl COUNTER 10 { setvarvar SIZE COUNTER mulvar SIZE 6400 } else 
			ifvarg COUNTER 9 ifvarvarl COUNTER tmp2 { setvar SIZE 65536 } else
			ifvarvarg COUNTER tmp2 { setvarvar SIZE COUNTER subvarvar SIZE tmp2 mulvar SIZE -3200 addvar SIZE 65536 }
			break
			case 124
			case 200
			ifvarl COUNTER 10 { setvarvar SIZE COUNTER mulvar SIZE 5312 } else 
			ifvarg COUNTER 9 ifvarvarl COUNTER tmp2 { setvar SIZE 54394 } else
			ifvarvarg COUNTER tmp2 { setvarvar SIZE COUNTER subvarvar SIZE tmp2 mulvar SIZE -2656 addvar SIZE 54394 }
			break
			default 
			ifvarl COUNTER 10 { setvarvar SIZE COUNTER mulvar SIZE 4800 } else 
			ifvarg COUNTER 9 ifvarvarl COUNTER tmp2 { setvar SIZE 49152 } else
			ifvarvarg COUNTER tmp2 { setvarvar SIZE COUNTER subvarvar SIZE tmp2 mulvar SIZE -2400 addvar SIZE 32768 }
			break
		endswitch
		
		ifvare hudtype 0 { setvar y 205 } else setvar y 230 
		rotatesprite x y SIZE 0 picnum -128 palweapon 0 0 0 xdim ydim
		addvar x 38
	}
}

getactorvar[THISACTOR].pfire temp	
ifvarg temp 0
{

	setvar x 10
	whilevarn x 352
	{
		getticks tmp
		divvar tmp 50
		setvarvar x2 x
		mulvarvar x2 4
		addvarvar tmp x2
		modvar tmp 13
		setvar picnum 7221
		addvarvar picnum tmp
		
		switch x
			case 10 
			case 314
			ifvarl COUNTER 10 { setvarvar SIZE COUNTER mulvar SIZE 9216 } else 
			ifvarg COUNTER 9 ifvarvarl COUNTER 162 { setvar SIZE 95027 } else
			ifvarvarg COUNTER 162 { setvarvar SIZE COUNTER subvarvar SIZE 162 mulvar SIZE -4608 addvar SIZE 95027 }
			break
			case 48 
			case 276 
			ifvarl COUNTER 10 { setvarvar SIZE COUNTER mulvar SIZE 9216 } else 
			ifvarg COUNTER 9 ifvarvarl COUNTER 162 { setvar SIZE 95027 } else
			ifvarvarg COUNTER 162 { setvarvar SIZE COUNTER subvarvar SIZE 162 mulvar SIZE -4608 addvar SIZE 95027 }
			break
			case 86
			case 238
			ifvarl COUNTER 10 { setvarvar SIZE COUNTER mulvar SIZE 6400 } else 
			ifvarg COUNTER 9 ifvarvarl COUNTER 162 { setvar SIZE 65536 } else
			ifvarvarg COUNTER 162 { setvarvar SIZE COUNTER subvarvar SIZE 162 mulvar SIZE -3200 addvar SIZE 65536 }
			break
			case 124
			case 200
			ifvarl COUNTER 10 { setvarvar SIZE COUNTER mulvar SIZE 5312 } else 
			ifvarg COUNTER 9 ifvarvarl COUNTER 162 { setvar SIZE 54394 } else
			ifvarvarg COUNTER 162 { setvarvar SIZE COUNTER subvarvar SIZE 162 mulvar SIZE -2656 addvar SIZE 54394 }
			break
			default 
			ifvarl COUNTER 10 { setvarvar SIZE COUNTER mulvar SIZE 4800 } else 
			ifvarg COUNTER 9 ifvarvarl COUNTER 162 { setvar SIZE 49152 } else
			ifvarvarg COUNTER 162 { setvarvar SIZE COUNTER subvarvar SIZE 162 mulvar SIZE -2400 addvar SIZE 32768 }
			break
		endswitch
		
		ifvare hudtype 0 { setvar y 205 } else setvar y 230 
		rotatesprite x y SIZE 0 picnum -128 palweapon 0 0 0 xdim ydim
		addvar x 38
	}
}

getactor[THISACTOR].sectnum num
getsector[num].lotag num
ifvare num 2 palfrom 12 0 0 64

getplayer[THISACTOR].scuba_on num 
ifvare num 1 
{  
  rotatesprite 0 -1 65536 0 7464 shade pal 0 0 0 xdim ydim
  rotatesprite 320 -1 65536 512 7464 shade pal 0 0 0 xdim ydim
  rotatesprite 320 200 65536 1024 7464 shade pal 0 0 0 xdim ydim
  rotatesprite 0 200 65536 1536 7464 shade pal 0 0 0 xdim ydim
  rotatesprite 60 95 65536 0 7466 shade pal 33 0 0 xdim ydim
  rotatesprite 260 130 65536 0 7467 shade pal 33 0 0 xdim ydim
  setvar RETURN 1
}

getuserdef[THISACTOR].screen_size num
ifvare num 4
{ 
ifvare hudtype 0 setvar hudtype 1 else
ifvare hudtype 1 setvar hudtype 2 else
ifvare hudtype 2 setvar hudtype 0
savegamevar hudtype
}
setuserdef[THISACTOR].screen_size 0

ifvare hudtype 0
{
  //Bar
  rotatesprite 0 144 65536 0 7320 0 0 26 0 0 xdim ydim
  rotatesprite 114 184 65536 0 7322 0 0 26 0 0 xdim ydim
  rotatesprite 197 184 65536 0 7322 0 0 26 0 0 xdim ydim
  //Version
  rotatesprite 10 191 65536 0 9654 0 0 26 0 0 xdim ydim
  rotatesprite 15 191 65536 0 9617 0 0 26 0 0 xdim ydim
  rotatesprite 20 191 65536 0 9614 0 0 26 0 0 xdim ydim
  rotatesprite 23 191 65536 0 9616 0 0 26 0 0 xdim ydim
  rotatesprite 28 191 65536 0 9616 0 0 26 0 0 xdim ydim
  //TNTCOUNT
  setvarvar num TNTCOUNT
  setvar x 124 setvar y 175
  mulvar num 71
  divvar num 64
  setvar tmp 71
  subvarvar tmp num
  whilevarn tmp 71 { addvar tmp 1 rotatesprite x y 65536 0 9702 0 0 26 0 0 xdim ydim addvar x 1 }
  //Health
  ifvare fatalvar 0 { getplayer[THISACTOR].last_extra num } else { setvar num 0 }
  setvar x 100 setvar y 178 state drawnumR
  //Ammo
  getplayer[THISACTOR].curr_weapon tmp
  getplayer[THISACTOR].ammo_amount tmp num
  ifvare tmp 8 ifvare num 1 { setvar num 0 }
  setvar x 230 setvar y 178 state drawnumB
  
  //Keys
  rotatesprite 69 167 65536 0 9695 0 0 26 0 0 xdim ydim
  rotatesprite 242 167 65536 0 9696 0 0 26 0 0 xdim ydim
  rotatesprite 69 178 65536 0 9697 0 0 26 0 0 xdim ydim
  rotatesprite 242 178 65536 0 9698 0 0 26 0 0 xdim ydim
  rotatesprite 69 189 65536 0 9699 0 0 26 0 0 xdim ydim
  rotatesprite 242 189 65536 0 9700 0 0 26 0 0 xdim ydim

  ifvare VAR_SKULLKEY 1 rotatesprite 69 167 65536 0 7340 0 0 26 0 0 xdim ydim
  ifvare VAR_EYEKEY 1 rotatesprite 242 167 65536 0 7341 0 0 26 0 0 xdim ydim
  ifvare VAR_FIREKEY 1 rotatesprite 69 178 65536 0 7342 0 0 26 0 0 xdim ydim
  ifvare VAR_DAGGERKEY 1 rotatesprite 242 178 65536 0 7343 0 0 26 0 0 xdim ydim
  ifvare VAR_SPIDERKEY 1 rotatesprite 69 189 65536 0 7344 0 0 26 0 0 xdim ydim
  ifvare VAR_MOONKEY 1 rotatesprite 242 189 65536 0 7345 0 0 26 0 0 xdim ydim
  
  //Weapons
  getplayer[THISACTOR].ammo_amount 1 num
  setvar x 142 setvar y 180 setvar col 6 ifvarn CURRWEAP 1 setvar numshade 32 state drawweapnum
  getplayer[THISACTOR].ammo_amount 2 num
  setvar x 142 setvar y 186 setvar col 6 ifvarn CURRWEAP 2 setvar numshade 32 state drawweapnum
  getplayer[THISACTOR].ammo_amount 3 num
  setvar x 142 setvar y 192 setvar col 6 ifvarn CURRWEAP 3 setvar numshade 32 state drawweapnum
  getplayer[THISACTOR].ammo_amount 4 num
  setvar x 165 setvar y 180 setvar col 6 ifvarn CURRWEAP 4 setvar numshade 32 state drawweapnum
  setvarvar num TNT_AMMOAMOUNT
  setvar x 165 setvar y 186 setvar col 6 ifvarn currdinamite 1 setvar numshade 32 state drawweapnum
  getplayer[THISACTOR].ammo_amount 6 num
  setvar x 165 setvar y 192 setvar col 6 ifvarn CURRWEAP 6 setvar numshade 32 state drawweapnum
  getplayer[THISACTOR].ammo_amount 7 num
  setvar x 188 setvar y 180 setvar col 6 ifvarn CURRWEAP 7 setvar numshade 32 state drawweapnum
  getplayer[THISACTOR].ammo_amount 8 num
  ifvare num 1 { setvar num 0 }
  setvar x 188 setvar y 186 setvar col 6 ifvarn CURRWEAP 8 setvar numshade 32 state drawweapnum
  getplayer[THISACTOR].ammo_amount 9 num
  setvar x 188 setvar y 192 setvar col 6 ifvarn CURRWEAP 9 setvar numshade 32 state drawweapnum
  setvarvar num REMOTETNT_AMMOAMOUNT
  setvar x 312 setvar y 192 setvar col 6 ifvarn currdinamite 3 setvar numshade 32 state drawweapnum
  setvarvar num PROXIMITYMINE_AMMOAMOUNT
  setvar x 294 setvar y 192 setvar col 6 ifvarn currdinamite 2 setvar numshade 32 state drawweapnum

  //INV

  ifvare DISPLAYINVENTORY 1
  {
		setarray INVARRAY[0] DOCTORSBAGAM
		setarray INVARRAY[1] DIVINGSUITAM
		setarray INVARRAY[2] CRYSTALLBALLAM
		setarray INVARRAY[3] BEASTVISIONAM
		setarray INVARRAY[4] BOOTSOFJUMPINGAM
	  
		setvar tmp2 0 // Thanks to TheLezing for this code
		setvar x2 170
		whilevarn tmp2 5
		{
			ifvarg INVARRAY[tmp2] 0 subvar x2 10
			addvar tmp2 1
		}
		setvar tmp2 0
	    whilevarn tmp2 5
	    {
			ifvarg INVARRAY[tmp2] 0 
			{ 
				switch tmp2
					case 0 setvar picnum 7689 break
					case 1 setvar picnum 7684 break
					case 2 setvar picnum 7686 break
					case 3 setvar picnum 7688 break
					case 4 setvar picnum 7680 break
				endswitch
				rotatesprite x2 147 NORMALSIZE 0 picnum 0 0 0 0 0 xdim ydim
				rotatesprite x2 133 NORMALSIZE 0 9726 0 0 0 0 0 xdim ydim
				ifvarvare ICPOSITION tmp2 { rotatesprite x2 147 NORMALSIZE 0 7679 0 0 0 0 0 xdim ydim }
				setvarvar num INVARRAY[tmp2]
				ifvarg tmp2 0 divvar num 12
				setvarvar x x2
				addvar x 3
				setvar y 130 state drawinvnum
				addvar x2 19
			}
		    addvar tmp2 1
	    }
  }  

  getplayer[THISACTOR].inven_icon tmp
  ifvarn tmp 0
  {
  ifvare tmp 8 // DOCTORSBAGAM
	{
	rotatesprite 265 186 65536 0 7689 0 0 0 0 0 xdim ydim
	setvarvar num DOCTORSBAGAM
	setvar x 268 setvar y 169 state drawinvnum
	} 
  ifvare tmp 9 // DIVINGSUITAM
	{
	rotatesprite 265 186 65536 0 7684 0 0 0 0 0 xdim ydim
	setvarvar num DIVINGSUITAM
        divvar num 12
	setvar x 268 setvar y 169 state drawinvnum
	}  
  ifvare tmp 10 // CRYSTALLBALLAM
	{
	rotatesprite 265 186 65536 0 7686 0 0 0 0 0 xdim ydim
	setvarvar num CRYSTALLBALLAM
        divvar num 12
	setvar x 268 setvar y 169 state drawinvnum
	}  
  ifvare tmp 11 // BEASTVISIONAM 
	{
	rotatesprite 265 186 65536 0 7688 0 0 0 0 0 xdim ydim
	setvarvar num BEASTVISIONAM 
        divvar num 12
	setvar x 268 setvar y 169 state drawinvnum
	}  
  ifvare tmp 12 // BOOTSOFJUMPINGAM
	{
	rotatesprite 265 186 65536 0 7680 0 0 0 0 0 xdim ydim
	setvarvar num BOOTSOFJUMPINGAM
        divvar num 12
	setvar x 268 setvar y 169 state drawinvnum
	}              
  }

 //Armors
  setvarvar num FIRESHIELD_AMOUNT
  ifvarn num 0 { rotatesprite 44 174 65536 0 7327 0 0 26 0 0 xdim ydim }
  setvar x 62 setvar y 174
  state armorline
  setvarvar num FIRESHIELD_AMOUNT
  setvar x 57 setvar y 175 state drawarmnum
  
  setvarvar num BODYSHIELD_AMOUNT 
  ifvarn num 0 { rotatesprite 44 182 65536 0 7329 0 0 26 0 0 xdim ydim }
  setvar x 62 setvar y 182
  state armorline
  setvarvar num BODYSHIELD_AMOUNT 
  setvar x 57 setvar y 183 state drawarmnum
  
  setvarvar num SPIRITSHIELD_AMOUNT
  ifvarn num 0 { rotatesprite 44 190 65536 0 7328 0 0 26 0 0 xdim ydim }
  setvar x 62 setvar y 190
  state armorline
  setvarvar num SPIRITSHIELD_AMOUNT
  setvar x 57 setvar y 191 state drawarmnum
  
  setvar RETURN 1
}
ifvare hudtype 1
{
  //Bar
  rotatesprite 0 175 65536 0 7321 0 0 282 0 0 xdim ydim //26
  rotatesprite 248 175 65536 0 7293 0 0 538 0 0 xdim ydim //26
  
  //TNTCOUNT
  setvarvar num TNTCOUNT
  setvar x 124 setvar y 175
  mulvar num 71
  divvar num 64
  setvar tmp 71
  subvarvar tmp num
  whilevarn tmp 71 { addvar tmp 1 rotatesprite x y 65536 0 9702 0 0 26 0 0 xdim ydim addvar x 1 }
  
  //Health
  ifvare fatalvar 0 { getplayer[THISACTOR].last_extra num } else { setvar num 0 }
  setvar x 22 setvar y 179 state widedrawnumR
  //Ammo
  getplayer[THISACTOR].curr_weapon tmp
  getplayer[THISACTOR].ammo_amount tmp num
  ifvare tmp 8 ifvare num 1 { setvar num 0 }
  setvar x 56 setvar y 179 state widedrawnumB
  //INV

  ifvare DISPLAYINVENTORY 1
  {
  
  		setarray INVARRAY[0] DOCTORSBAGAM
		setarray INVARRAY[1] DIVINGSUITAM
		setarray INVARRAY[2] CRYSTALLBALLAM
		setarray INVARRAY[3] BEASTVISIONAM
		setarray INVARRAY[4] BOOTSOFJUMPINGAM
	  
		setvar tmp2 0 // Thanks to TheLezing for this code
		setvar x2 170
		whilevarn tmp2 5
		{
			ifvarg INVARRAY[tmp2] 0 subvar x2 10
			addvar tmp2 1
		}
		setvar tmp2 0
	    whilevarn tmp2 5
	    {
			ifvarg INVARRAY[tmp2] 0 
			{ 
				switch tmp2
					case 0 setvar picnum 7689 break
					case 1 setvar picnum 7684 break
					case 2 setvar picnum 7686 break
					case 3 setvar picnum 7688 break
					case 4 setvar picnum 7680 break
				endswitch
				rotatesprite x2 187 NORMALSIZE 0 picnum 0 0 0 0 0 xdim ydim
				rotatesprite x2 173 NORMALSIZE 0 9726 0 0 0 0 0 xdim ydim
				ifvarvare ICPOSITION tmp2 { rotatesprite x2 187 NORMALSIZE 0 7679 0 0 0 0 0 xdim ydim }
				setvarvar num INVARRAY[tmp2]
				ifvarg tmp2 0 divvar num 12
				setvarvar x x2
				addvar x 3
				setvar y 170 state drawinvnum
				addvar x2 19
			}
		    addvar tmp2 1
	    }

  }

  getplayer[THISACTOR].inven_icon tmp
  ifvarn tmp 0
  {
  ifvare tmp 8 // DOCTORSBAGAM
	{
	rotatesprite 286 187 65536 0 7689 0 0 512 0 0 xdim ydim
	setvarvar num DOCTORSBAGAM
	setvar x 310 setvar y 181 state widedrawinvnum
	} 
  ifvare tmp 9 // DIVINGSUITAM
	{
	rotatesprite 286 187 65536 0 7684 0 0 512 0 0 xdim ydim
	setvarvar num DIVINGSUITAM
        divvar num 12
	setvar x 310 setvar y 181 state widedrawinvnum
	}  
  ifvare tmp 10 // CRYSTALLBALLAM
	{
	rotatesprite 286 187 65536 0 7686 0 0 512 0 0 xdim ydim
	setvarvar num CRYSTALLBALLAM
        divvar num 12
	setvar x 310 setvar y 181 state widedrawinvnum
	}  
  ifvare tmp 11 // BEASTVISIONAM 
	{
	rotatesprite 286 187 65536 0 7688 0 0 512 0 0 xdim ydim
	setvarvar num BEASTVISIONAM 
        divvar num 12
	setvar x 310 setvar y 181 state widedrawinvnum
	}  
  ifvare tmp 12 // BOOTSOFJUMPINGAM
	{
	rotatesprite 286 187 65536 0 7680 0 0 512 0 0 xdim ydim
	setvarvar num BOOTSOFJUMPINGAM
        divvar num 12
	setvar x 310 setvar y 181 state widedrawinvnum
	}              

  }
  //Armors
  
  setvarvar num FIRESHIELD_AMOUNT
  ifvarn num 0 { rotatesprite 250 176 65536 0 7327 0 0 538 0 0 xdim ydim }
  setvar x 268 setvar y 176
  state widearmorline
  setvarvar num FIRESHIELD_AMOUNT
  setvar x 263 setvar y 177 state widedrawarmnum
  
  setvarvar num BODYSHIELD_AMOUNT 
  ifvarn num 0 { rotatesprite 250 184 65536 0 7329 0 0 538 0 0 xdim ydim }
  setvar x 268 setvar y 184
  state widearmorline
  setvarvar num BODYSHIELD_AMOUNT
  setvar x 263 setvar y 185 state widedrawarmnum
  
  setvarvar num SPIRITSHIELD_AMOUNT
  ifvarn num 0 { rotatesprite 250 192 65536 0 7328 0 0 538 0 0 xdim ydim }
  setvar x 268 setvar y 192
  state widearmorline
  setvarvar num SPIRITSHIELD_AMOUNT
  setvar x 263 setvar y 193 state widedrawarmnum
}
ifvare hudtype 2
{
  //TNTCOUNT
  setvarvar num TNTCOUNT
  setvar x 124 setvar y 175
  mulvar num 71
  divvar num 64
  setvar tmp 71
  subvarvar tmp num
  whilevarn tmp 71 { addvar tmp 1 rotatesprite x y 65536 0 9702 0 0 26 0 0 xdim ydim addvar x 1 }
  
  ifvare DISPLAYINVENTORY 1
  {
  
  		setarray INVARRAY[0] DOCTORSBAGAM
		setarray INVARRAY[1] DIVINGSUITAM
		setarray INVARRAY[2] CRYSTALLBALLAM
		setarray INVARRAY[3] BEASTVISIONAM
		setarray INVARRAY[4] BOOTSOFJUMPINGAM
	  
		setvar tmp2 0 // Thanks to TheLezing for this code
		setvar x2 170
		whilevarn tmp2 5
		{
			ifvarg INVARRAY[tmp2] 0 subvar x2 10
			addvar tmp2 1
		}
		setvar tmp2 0
	    whilevarn tmp2 5
	    {
			ifvarg INVARRAY[tmp2] 0 
			{ 
				switch tmp2
					case 0 setvar picnum 7689 break
					case 1 setvar picnum 7684 break
					case 2 setvar picnum 7686 break
					case 3 setvar picnum 7688 break
					case 4 setvar picnum 7680 break
				endswitch
				rotatesprite x2 187 NORMALSIZE 0 picnum 0 0 0 0 0 xdim ydim
				rotatesprite x2 173 NORMALSIZE 0 9726 0 0 0 0 0 xdim ydim
				ifvarvare ICPOSITION tmp2 { rotatesprite x2 187 NORMALSIZE 0 7679 0 0 0 0 0 xdim ydim }
				setvarvar num INVARRAY[tmp2]
				ifvarg tmp2 0 divvar num 12
				setvarvar x x2
				addvar x 3
				setvar y 170 state drawinvnum
				addvar x2 19
			}
		    addvar tmp2 1
	    }

  }
}

getactorvar[THISACTOR].handattack temp
ifvare temp 1
{

getticks picnum
divvar picnum 65
modvar picnum 39
	
switch picnum
case 0
rotatesprite 160 190 65536 32 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 105 135 65536 32 5854 shade palweapon 0 0 0 xdim ydim
break
case 1
rotatesprite 160 190 65536 0 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 95 130 65536 32 5856 shade palweapon 0 0 0 xdim ydim
rotatesprite 140 145 65536 -128 5855 shade palweapon 0 0 0 xdim ydim
break
case 2
rotatesprite 155 185 65536 -32 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 85 130 65536 32 5855 shade palweapon 0 0 0 xdim ydim
rotatesprite 140 135 65536 64 5856 shade palweapon 0 0 0 xdim ydim
break
case 3
rotatesprite 155 185 65536 -64 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 50 150 65536 32 5857 shade palweapon 0 0 0 xdim ydim
rotatesprite 140 120 65536 92 5857 shade palweapon 0 0 0 xdim ydim
break
case 4
rotatesprite 155 185 65536 -64 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 30 165 65536 -256 5854 shade palweapon 0 0 0 xdim ydim
rotatesprite 135 125 65536 92 5855 shade palweapon 0 0 0 xdim ydim
break
case 5
rotatesprite 155 185 65536 -32 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 19 195 65536 0 5855 shade palweapon 0 0 0 xdim ydim
rotatesprite 135 130 65536 0 5856 shade palweapon 0 0 0 xdim ydim
break
case 6
rotatesprite 155 185 65536 0 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 135 140 92000 0 5857 shade palweapon 0 0 0 xdim ydim
break
case 7
rotatesprite 142 158 92000 512 5857 shade palweapon 0 0 0 xdim ydim
rotatesprite 155 185 65536 16 7131 shade palweapon 0 0 0 xdim ydim
break
case 8
rotatesprite 155 185 65536 0 7131 shade palweapon 0 0 0 xdim ydim
break
case 9
rotatesprite 155 185 65536 -16 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 105 140 65536 1056 5854 shade palweapon 0 0 0 xdim ydim
break
case 10
rotatesprite 155 185 65536 -32 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 100 130 65536 1056 5855 shade palweapon 0 0 0 xdim ydim
break
case 11
rotatesprite 155 185 65536 -64 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 95 125 65536 1056 5856 shade palweapon 0 0 0 xdim ydim
break
case 12
rotatesprite 155 185 65536 -96 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 93 128 65536 1056 5857 shade palweapon 0 0 0 xdim ydim
break
case 13
rotatesprite 155 185 65536 -96 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 90 134 65536 1056 5854 shade palweapon 0 0 0 xdim ydim
break
case 14
rotatesprite 155 185 65536 -64 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 90 140 65536 1056 5855 shade palweapon 0 0 0 xdim ydim
break
case 15
rotatesprite 155 185 65536 -32 7131 shade palweapon 0 0 0 xdim ydim
break
case 16
rotatesprite 155 185 65536 0 7131 shade palweapon 0 0 0 xdim ydim
break
case 17
rotatesprite 155 185 65536 16 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 90 140 65536 1056 5855 shade palweapon 0 0 0 xdim ydim
break
case 18
rotatesprite 155 185 65536 32 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 85 147 65536 1056 5856 shade palweapon 0 0 0 xdim ydim
break
case 19
rotatesprite 155 185 65536 48 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 82 152 65536 1056 5857 shade palweapon 0 0 0 xdim ydim
break
case 20
rotatesprite 155 185 65536 48 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 80 155 65536 1056 5855 shade palweapon 0 0 0 xdim ydim
break
case 21
rotatesprite 155 185 65536 32 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 77 160 65536 1056 5856 shade palweapon 0 0 0 xdim ydim
break
case 22
rotatesprite 155 185 65536 16 7131 shade palweapon 0 0 0 xdim ydim
break
case 23
rotatesprite 155 185 65536 -16 7131 shade palweapon 0 0 0 xdim ydim
break
case 24
rotatesprite 155 190 65536 -16 7131 shade palweapon 0 0 0 xdim ydim
break
case 25
rotatesprite 155 190 65536 -32 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 133 147 65536 1664 5854 shade palweapon 0 0 0 xdim ydim
break
case 26
rotatesprite 155 193 65536 -32 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 133 150 65536 1664 5854 shade palweapon 0 0 0 xdim ydim
break
case 27
rotatesprite 155 193 65536 -32 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 133 150 65536 1664 5854 shade palweapon 0 0 0 xdim ydim
break
case 28
rotatesprite 155 193 65536 -48 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 155 150 65536 1664 5855 shade palweapon 0 0 0 xdim ydim
break
case 29
rotatesprite 155 193 65536 -48 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 155 151 65536 1664 5855 shade palweapon 0 0 0 xdim ydim
break
case 30
rotatesprite 155 193 65536 -64 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 165 151 65536 1664 5856 shade palweapon 0 0 0 xdim ydim
break
case 31
rotatesprite 155 193 65536 -64 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 165 150 65536 1664 5856 shade palweapon 0 0 0 xdim ydim
break
case 32
rotatesprite 155 193 65536 -96 7131 shade palweapon 0 0 0 xdim ydim
rotatesprite 179 154 65536 1664 5857 shade palweapon 0 0 0 xdim ydim
break
case 33
rotatesprite 205 174 65536 1664 5854 shade palweapon 0 0 0 xdim ydim
rotatesprite 155 193 65536 -96 7131 shade palweapon 0 0 0 xdim ydim
break
case 34
rotatesprite 155 193 65536 -64 7131 shade palweapon 0 0 0 xdim ydim
break
case 35
rotatesprite 155 193 65536 -32 7131 shade palweapon 0 0 0 xdim ydim
break
case 36
rotatesprite 155 193 65536 -16 7131 shade palweapon 0 0 0 xdim ydim
break
case 37
rotatesprite 157 192 65536 0 7131 shade palweapon 0 0 0 xdim ydim
break
case 38
rotatesprite 160 190 65536 16 7131 shade palweapon 0 0 0 xdim ydim
break
endswitch
}

setvar RETURN 1

endevent

onevent EVENT_DISPLAYSBAR
setvar RETURN 1
endevent

onevent EVENT_INVENTORYRIGHT
setvar DISPLAYINVENTORY 1
setvar INVENTORYCHECK 130
ifvare DISPLAYINVENTORY 1
{
  setplayer[THISACTOR].inven_icon 0

  setarray INVARRAY[0] DOCTORSBAGAM
  setarray INVARRAY[1] DIVINGSUITAM
  setarray INVARRAY[2] CRYSTALLBALLAM
  setarray INVARRAY[3] BEASTVISIONAM
  setarray INVARRAY[4] BOOTSOFJUMPINGAM

  setvar temp 0
  whilevarn temp 5
  {
	addvar ICPOSITION 1
	ifvarg ICPOSITION 4 setvar ICPOSITION 0
	ifvarg INVARRAY[ICPOSITION] 0 setvar temp 4
	addvar temp 1
  }
}
setvar RETURN -1
endevent

onevent EVENT_INVENTORYLEFT
setvar DISPLAYINVENTORY 1
setvar INVENTORYCHECK 130
ifvare DISPLAYINVENTORY 1
{
  setplayer[THISACTOR].inven_icon 0

  setarray INVARRAY[0] DOCTORSBAGAM
  setarray INVARRAY[1] DIVINGSUITAM
  setarray INVARRAY[2] CRYSTALLBALLAM
  setarray INVARRAY[3] BEASTVISIONAM
  setarray INVARRAY[4] BOOTSOFJUMPINGAM

  setvar temp 0
  whilevarn temp 5
  {
	subvar ICPOSITION 1
	ifvarl ICPOSITION 0 setvar ICPOSITION 4
	ifvarg INVARRAY[ICPOSITION] 0 setvar temp 4
	addvar temp 1
  }

}
setvar RETURN -1
endevent