
state shadepulse
setvarvar temp timer
shiftvarl temp 7
sin tempb temp
shiftvarr tempb 11
setvarvar shade tempb
ends


onevent EVENT_ANIMATESPRITES

gettspr[THISACTOR].tsprpicnum picnum
switch picnum
case EGGCORPSE
case LIZTROOPCORPSE
case OCTABRAINCORPSE
case COMMANDERCORPSE
case PIGCOPCORPSE
case LIZMANCORPSE
case BOSS1CORPSE
case BOSS2CORPSE
case BOSS3CORPSE
case NEWBEASTCORPSE
case BOSS4CORPSE
gettspr[THISACTOR].tsprowner spriteid
getactor[spriteid].yrepeat digy
addvar digy 10
settspr[THISACTOR].tspryrepeat digy
break
case BLOODPOOL
gettspr[THISACTOR].tsprowner spriteid
ifvare actorvar[spriteid].mtype 6
settspr[THISACTOR].tsprpal 8
break
default break
endswitch

gettspr[THISACTOR].tsprowner spriteid
// ifvare actorvar[spriteid].motionblur YES
// {
// 	subvar picnum 7000
// 	settspr[THISACTOR].tsprpicnum picnum
// }

ifvarg beamhit 0
ifvare sprite[spriteid].htpicnum POWBEAM
{
	gettspr[THISACTOR].tsprpal temp
	ifvare temp 6 settspr[THISACTOR].tsprpal sprite[spriteid].pal else
	ifvarand timer 1 settspr[THISACTOR].tsprpal 6
	settspr[THISACTOR].tsprshade -127
}
getactorvar[spriteid].burning temp
ifvarl temp 0 settspr[spriteid].tsprpal 1
endevent


state quotedisplay

ifvarg fta 0
{
	
	setvar orientation 0
	setvar digy 5
	getplayer[THISACTOR].fta temp
	ifvarg temp 0 addvar digy 10
	setvarvar shade fta
	modvar shade 25
	ifvarl shade 13 mulvar shade 2 else
	ifvare shade 13 setvar shade 24 else
	{ subvar shade 12 setvar temp 13 subvarvar temp shade mulvar temp 2 setvarvar shade temp }
	ifvarl fta 27
	{
		ifvarg shade 2 orvar orientation 1
		ifvarg shade 12 orvar orientation 32
	}
	gametext 2822 320 digy ftq shade 0 orientation 0 0 xdim ydim
	ifvarl fta 26 ifvare shade 24 setvar fta 0
}

ends

onevent EVENT_DISPLAYMENUREST
getplayer[THISACTOR].gm temp
ifvarand temp 4 nullop else
rotatesprite 50 190 24576 0 6320 0 0 0 0 0 xdim ydim

endevent

onevent EVENT_GETMENUTILE

setvarvar temp xdim
shiftvarl temp 3
divvarvar temp ydim
ifvarg temp 12 setvar RETURN 6862
else
setvar RETURN 6863



endevent


state sidekickcoords

ifoutside getsector[THISACTOR].ceilingshade shade else
getsector[THISACTOR].floorshade shade

	ifvarl superkicking 4
	{
		setvar picnum 6339
		setvar angvar 0
		switch superkicking
		
		case 1
		setvar digy 187
		setvar digx 160
		break
		case 2
		setvar digy 184
		setvar digx 140
		break
		case 3
		setvar digy 182
		setvar digx 120
		break
		default break
		endswitch

	}
	else ifvarl superkicking 8
	{
		setvar picnum 6340
		switch superkicking
		case 4
			setvar digx 110
			setvar digy 200
			setvar angvar 64
		break
		case 5
			setvar digx 90
			setvar digy 200
			setvar angvar 28
		break
		case 6
			setvar digx 70
			setvar digy 198
			setvar angvar 20
		break
		
		case 7
			setvar digx 77
			setvar digy 192
			setvar angvar 12
		break
		default break
	    endswitch
	}
	else
	{
		setvar picnum 6341
		switch superkicking
		
		case 8
			setvar digx 150
			setvar digy 185
			setvar angvar 2032 // 0
		break
		
		case 9
			setvar digx 155
			setvar digy 180
			setvar angvar 2016 // 2032
		break
		
		case 10
			setvar digx 160
			setvar digy 175
			setvar angvar 2000 // 2016
		break
		
		case 11
		case 12
			setvar digx 170
			setvar digy 170
			setvar angvar 2032 // 0
		break
		default break
		endswitch
	}
ends

state spinkickcoords

ifoutside getsector[THISACTOR].ceilingshade shade else
getsector[THISACTOR].floorshade shade

	ifvarl superkicking 4
	{
		setvar picnum 6339
		setvar angvar 0
		switch superkicking
		case 1
		ifvare superkickdone 1 setvar digx 300 else	
		setvar digx 160
		setvar digy 187
		break
		case 2
		ifvare superkickdone 1 setvar digx 290 else
		setvar digx 140	
		setvar digy 184

		break
		case 3
		ifvare superkickdone 1 setvar digx 280 else			
		setvar digx 120
		setvar digy 182
		break
		default break
		endswitch

	}
	else ifvarl superkicking 9
	{
		setvar picnum 6340
		switch superkicking
		case 4
			ifvare superkickdone 1 setvar digx 270 else			
			setvar digx 65
			setvar digy 200
			setvar angvar 64
		break
		case 5
			ifvare superkickdone 1 setvar digx 260 else			
			setvar digx 68
			setvar digy 200
			setvar angvar 28
		break
		case 6
			ifvare superkickdone 1 setvar digx 250 else			
			setvar digx 72
			setvar digy 198
			setvar angvar 20
		break
		
		case 7
			ifvare superkickdone 1 setvar digx 240 else		
			setvar digx 76
			setvar digy 194
			setvar angvar 12
		 break
		case 8
			ifvare superkickdone 1 setvar digx 230 else		
			setvar digx 80
			setvar digy 190
			setvar angvar 12
		break
		default 
			ifvare superkickdone 1 setvar digx 230 else		
			setvar digx 80
			setvar digy 190
			setvar angvar 12
		break
	    endswitch
	}
	else
	{
		setvar picnum 6341
		switch superkicking
		
		case 9
			ifvare superkickdone 1 setvar digx 220 else	
			setvar digx 100
			setvar digy 185
			setvar angvar 0
		break
		
		case 10
			ifvare superkickdone 1 setvar digx 205 else
			setvar digx 120
			setvar digy 165
			setvar angvar 2032
		break
		
		case 11
			ifvare superkickdone 1 setvar digx 190 else
			setvar digx 140
			setvar digy 170
			setvar angvar 2016
		break
		
		case 12
			ifvare superkickdone 1 setvar digx 175 else
			setvar digx 160
			setvar digy 165
			setvar angvar 0
		break
		
		case 13
			setvar digx 170
			setvar digy 165
			setvar angvar 0
		break
		default break
		endswitch
	}
ends

state displaykicks
// superkick display
getplayer[THISACTOR].over_shoulder_on temp
ifvarg superkicking 0 ifvare temp 0
{

	setvar orientation 0
	//getsector[THISACTOR].floorpal pal
	//ifvarg pal 25 setvar pal 0
	setvar angvar 0
	setvar digz 32768
	ifvare spinkick 0 state sidekickcoords
	else state spinkickcoords
	getuserdef[THISACTOR].screen_size C
	ifvarg C 4 subvar digy 16
	
	// reverse kicks
	ifvare reversekick YES
	{
		setvar orientation 4
		subvar angvar 1024
		setvar mx 290
		subvarvar mx digx
		setvarvar digx mx
		setvar tempb 2047
		subvarvar tempb angvar
		setvarvar angvar tempb
	}
	
	getplayer[THISACTOR].palookup pal
	rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
}
ends


state adjustrightpos
subvarvar digx looking_angSR1
addvarvar digy looking_arc
subvarvar digy gun_pos
addvarvar digx weapon_xoffset
ends

state adjustleftpos

ifvarn weapswitch 0 { state adjustrightpos break }
addvarvar digx looking_angSR1
addvarvar digy looking_arc
subvarvar digy gun_pos
subvarvar digx weapon_xoffset
addvar digx 22
ends


state idleakimbo

// LEFTPISTOL
setvar digx 90
setvar digy 244
ifvarg C 4 subvar digy 16
state adjustleftpos
ifvarn akimbo 0 ifvarn akimbo 1
{
	setvarvar temp akimbo
	ifvarl akimbo -1 
	{ 
		mulvar temp -1 
		setvar tempb 10
		subvarvar tempb temp 
		setvarvar temp tempb 
	}
	mulvar temp 6
	addvarvar digy temp
}
setvar picnum 2524
setvar orientation 4
guniqhudid 1
rotatesprite digx digy digz 1024 picnum shade pal orientation 0 0 xdim ydim
guniqhudid 0

// RIGHT PISTOL
setvar orientation 0
setvar digx 90
setvar digy 244
ifvarg C 4 subvar digy 16
state adjustrightpos
addvar digx 120
ifvarn akimbo 0 ifvarn akimbo 1
{
	ifvarl akimbo -1 subvar digx 42
	setvarvar temp akimbo
	mulvar temp 5
	subvarvar digx temp
	ifvarl digx 195 setvar digx 195
}
guniqhudid 5
rotatesprite digx digy digz 0 picnum shade pal orientation 0 0 xdim ydim
guniqhudid 0
ends

state initweapondisplay


ifvare currentweapon 2
{
    setvar digx 139
	setvar digy 202
 	setvar digz 65536
}
else
ifvare currentweapon 3 ifvarand ALTCHAINGUN 2
{
	setvar digx 190
 	setvar digy 235
 	setvar digz 65536
}
else ifvare currentweapon 4
{
	 setvar digx 160
	 setvar digy 171
	 setvar digz 65536
}
else
{
 	setvar digx 140
 	setvar digy 230
 	setvar digz 28672
}

 setvar angvar 0
 setvar orientation 0

subvarvar digx looking_angSR1
addvarvar digy looking_arc
subvarvar digy gun_pos
addvarvar digx weapon_xoffset

ifoutside getsector[THISACTOR].ceilingshade shade else
getsector[THISACTOR].floorshade shade
getsector[THISACTOR].floorpal pal
ifvare pal 4 { addvar shade 10 setvar pal 0 }
ifvarg pal 13 setvar pal 0
ends

state displaydbshotgun

state initweapondisplay

setvar digz 131072

// setvar digz 65536 for 8bit

ifvare weaponcount 0 setvar picnum 8826 // 6350 for 8bit
else
{
// first display firing sequence, then IF there is ammo, go through the reload animation

// beginning of firing sequence
// firing and return to center takes 16 ticks

	ifvarl weaponcount 4
	{
		// setvar picnum 6350 for 8bit
		setvar picnum 8826
	} else
	ifvarl weaponcount 16
	{
		ifvarl weaponcount 8 // muzzleflash
		{
			setvar shade 0
			subvar digy 70
			setvar orientation 1
			ifvarg weaponcount 5 setvar orientation 33
			setvar digz 32768
			setvar picnum 8831
			displayrandvar angvar 2047
			rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
			addvar digx 30
			displayrandvar angvar 2047
			rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
			state initweapondisplay
			setvar shade 0
			setvar digz 131072
		}
		// setvar picnum 6351 for 8bit
		setvar picnum 8827
	}
	else
	setvarvar picnum dbpicnum // depends on ammo left
	
}

guniqhudid 2
rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
guniqhudid 0
ends

state displaypistolbullets

ifvare botclip 0 break
setvar pal 0
setvar orientation 0
setvar picnum SHELL
setvar digx 290
setvar digy 175
setvar digz 16384
setvar shade 0

rotatesprite digx digy digz 0 picnum shade pal orientation 0 0 xdim ydim
setvarvar tempb botclip
setvar temp 0
whilevarn tempb 0
{
	  rotatesprite digx digy digz 0 picnum shade pal orientation 0 0 xdim ydim
	  addvar digx 4
	  subvar tempb 1
	  addvar temp 1
	  ifvare temp 6 { subvar digy 4 subvar digx 24 }
	  else ifvare temp 12 { subvar digy 4 subvar digx 24 }
	  else ifvare temp 18 { subvar digy 4 subvar digx 24 }
	  else ifvare temp 24 { subvar digy 4 subvar digx 24 }
	  
	  break
}

ends

state grenadeadjust
setvarvar temp grenadecounter
ifvarg temp 2 ifvarl temp 11
{
	ifvarl temp 7
	{
		mulvar temp 5144
		addvarvar digz temp
	} else
	{
		addvar digz 20576
		subvar temp 5
		mulvar temp 5144
		subvarvar digz temp
	}
}
ends

state displayminigun
	
	getplayer[screenpeek].ammo_amount 3 temp
	ifvarg miniguncount MINIFIRECOUNT ifvarg temp 1
	{
		setvar x 177
		setvar y 204
		setvar z 65536 
		subvarvar x looking_angSR1
		addvarvar y looking_arc
		subvarvar y gun_pos
		addvarvar x weapon_xoffset
		state grenadeadjust
		displayrandvar angvar 2048
		rotatesprite x y z angvar 6212 -127 0 33 0 0 xdim ydim
		addvar angvar 1024
		rotatesprite x y z angvar 6212 -127 0 33 0 0 xdim ydim
	}
 	state initweapondisplay
 	state grenadeadjust
	getplayer[screenpeek].ammo_amount 3 temp
	ifvarg miniguncount MINIFIRECOUNT ifvarg temp 0
	{
		setvar temp 0
		displayrandvar temp 3
		ifvarl temp 6 mulvar temp -1
		addvarvar digx temp
		displayrandvar temp 2
		ifvarl temp 4 mulvar temp -1
		addvarvar digy temp
	}
	ifvare miniguncount MAXSPIN
	{
		ifvare lastdispframe 6208 setvar lastdispframe 6209 else
		ifvare lastdispframe 6209 setvar lastdispframe 6210 else
		ifvare lastdispframe 6210 setvar lastdispframe 6211 else
		ifvare lastdispframe 6211 setvar lastdispframe 6209
		rotatesprite digx digy digz angvar lastdispframe shade pal orientation 0 0 xdim ydim
	}
	else
	{
		rotatesprite digx digy digz angvar gunframe shade pal orientation 0 0 xdim ydim
		setvarvar lastdispframe gunframe
	}
ends

state displaydukeballs

setvar pal 0
setvar orientation 0
gametextz 2822 565 122 1091 0 7 0 0 0 xdim ydim 24576
setvarvar temp dukeballselected
addvar temp 1
digitalnumberz 2837 315 122 temp 0 7 0 0 0 xdim ydim 24576
rotatesprite 300 140 67584 0 183 0 pal orientation 0 0 xdim ydim

setvarvar picnum dukeballpics[dukeballselected]
ifvare picnum 0
{
	gametextz 2822 582 136 1092 0 0 0 0 0 xdim ydim 40960
	gametextz 2822 580 148 1093 0 2 1 0 0 xdim ydim 24576
	digitalnumberz 2837 302 151 dukeballstrength 0 2 1 0 0 xdim ydim 24576
}
else
{
	setvarvar pal dukeballpals[dukeballselected]
	setvar orientation 2
	rotatesprite 300 140 16384 0 picnum 0 pal orientation 0 0 xdim ydim
}

ends

state laserhud
ifvarg LASERCHARGE 0
{
	setvar digx 4
	setvar digz 16384
	setvar orientation 0
	ifvarg LASERCHARGE 25 
	{
		setvarvar temp timer
		ifvarand temp 1 setvar pal 6 else setvar pal 2
	}
	else setvar pal 2
	setvarvar tempb LASERCHARGE
	ifvarg tempb 26 setvar tempb 26
	setvarvar tempc digx
	addvarvar tempc tempb
	setvar temp 0
	whilevarn temp 1
	{
		  ifvarvarg digx tempc setvar temp 1
		  else
		  rotatesprite digx 145 digz 0 199 0 pal orientation 0 0 xdim ydim
		  addvar digx 1
		  break
	}
	gametextz 2822 9 142 1146 0 7 0 0 0 xdim ydim 24576
	
}

setvar digx 4
setvar digz 16384
setvar orientation 0
setvarvar tempb LASERAMMO
shiftvarr tempb 1
setvarvar tempc digx
addvarvar tempc tempb
setvar temp 0
whilevarn temp 1
{
	  ifvarvarg digx tempc setvar temp 1
	  else
	  rotatesprite digx 155 digz 0 199 0 7 orientation 0 0 xdim ydim
	  addvar digx 1
	  break
}
gametextz 2822 9 152 1147 0 7 0 0 0 xdim ydim 24576

ends


state displaylaserpistol

ifvarg LASERFIRE 1 ifvarl LASERFIRE 4 // display muzzleflash
{
	setvar digx 180
	setvar digy 240
	setvar angvar 0

	subvarvar digx looking_angSR1
	addvarvar digy looking_arc
	subvarvar digy gun_pos
	addvarvar digx weapon_xoffset
	subvar digy 51
	displayrandvar angvar 2047
	rotatesprite digx digy 65536 angvar 6152 0 0 0 0 0 xdim ydim
}

state laserhud


 setvar digx 175
 setvar digy 245
 setvar digz 65536
 setvar angvar 0
 setvar orientation 0

ifvare LASERFIRE 0
{
subvarvar digx looking_angSR1
addvarvar digy looking_arc
subvarvar digy gun_pos
addvarvar digx weapon_xoffset
}
else 
{
	subvar digy 65
	addvar digx 25
}

ifoutside getsector[THISACTOR].ceilingshade shade else
getsector[THISACTOR].floorshade shade
getsector[THISACTOR].floorpal pal
ifvare pal 4 { addvar shade 10 setvar pal 0 }

setvar picnum 6146

ifvarg LASERFIRE 1 //shooting
{
	ifvarl LASERFIRE 4
	{
		setvar picnum 6147
		ifvare LASERFIRE 2 
		{
			subvar digy 4
			addvar digz 4096
		}
		else
		{
			subvar digy 8
			addvar digz 8192
		}
		
	}
	else ifvarl LASERFIRE 8
	{
		setvar digz 73728
		subvar digy 8
		ifvare LASERFIRE 5
		{
			subvar digz 4096
			subvar digy 4
		}
		else ifvarg LASERFIRE 5
		{
			setvar digz 65536
			addvar digy 8
		}
	}
	
} else ifvarg LASERCHARGE 0
{
	setvar digz 69632
	displayrandvar temp 4
	subvar digx 2
	addvarvar digx temp
	displayrandvar temp 3
	addvar digy 1
	subvarvar digy temp
}

rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim


ends

state scoredisplay


rotatesprite 265 6 65536 1536 387 0 hudcolor 5 0 0 xdim ydim
setvar pal 7
setvar digx 315
ifvarg score 99 subvar digx 4
ifvarg score 999 subvar digx 4
ifvarg score 9999 subvar digx 4
ifvarg score 99999 subvar digx 4
ifvarg score 999999 subvar digx 4
digitalnumberz 2837 digx 6 score 0 pal 0 0 0 xdim ydim 40960

ends

state weaponleveldisplay


ifvarg superkicking 0
{
	ifvare weaplev0 0 setvar temp 0 else
	{
		setvarvar zdist weaplev0
		subvar zdist 1
		setvarvar temp xpcaps0[zdist]
	}
	setvarvar tempb xpcaps0[weaplev0]
	setvarvar tempc weapxp0
	setvarvar tempd weaplev0
}
else
{
	
	switch CURRWEAP
	case 0
	
	ifvarg LASERAMMO 0
	{
		ifvare weaplev10 0 setvar temp 0 else
		{
			setvarvar zdist weaplev10
			subvar zdist 1
			setvarvar temp xpcaps10[zdist]
		}
		setvarvar tempb xpcaps10[weaplev10]
		setvarvar tempc weapxp10
		setvarvar tempd weaplev10
	}
	else
	{
		ifvare weaplev0 0 setvar temp 0 else
		{
			setvarvar zdist weaplev0
			subvar zdist 1
			setvarvar temp xpcaps0[zdist]
		}
		setvarvar tempb xpcaps0[weaplev0]
		setvarvar tempc weapxp0
		setvarvar tempd weaplev0
	}
	
	
	
	break
	case 1
	ifvare weaplev1 0 setvar temp 0 else
	{
		setvarvar zdist weaplev1
		subvar zdist 1
		setvarvar temp xpcaps1[zdist]
	}
	setvarvar tempb xpcaps1[weaplev1]
	setvarvar tempc weapxp1
	setvarvar tempd weaplev1
	break
	case 2
	ifvare weaplev2 0 setvar temp 0 else
	{
		setvarvar zdist weaplev2
		subvar zdist 1
		setvarvar temp xpcaps2[zdist]
	}
	setvarvar tempb xpcaps2[weaplev2]
	setvarvar tempc weapxp2
	setvarvar tempd weaplev2
	break
	case 3
	ifvare weaplev3 0 setvar temp 0 else
	{
		setvarvar zdist weaplev3
		subvar zdist 1
		setvarvar temp xpcaps3[zdist]
	}
	setvarvar tempb xpcaps3[weaplev3]
	setvarvar tempc weapxp3
	setvarvar tempd weaplev3
	break
	case 4
	ifvare weaplev4 0 setvar temp 0 else
	{
		setvarvar zdist weaplev4
		subvar zdist 1
		setvarvar temp xpcaps4[zdist]
	}
	setvarvar tempb xpcaps4[weaplev4]
	setvarvar tempc weapxp4
	setvarvar tempd weaplev4
	break
	case 5
	case 10
	ifvare weaplev5 0 setvar temp 0 else
	{
		setvarvar zdist weaplev5
		subvar zdist 1
		setvarvar temp xpcaps5[zdist]
	}
	setvarvar tempb xpcaps5[weaplev5]
	setvarvar tempc weapxp5
	setvarvar tempd weaplev5
	break
	
	case 6
	ifvare weaplev6 0 setvar temp 0 else
	{
		setvarvar zdist weaplev6
		subvar zdist 1
		setvarvar temp xpcaps6[zdist]
	}
	setvarvar tempb xpcaps6[weaplev6]
	setvarvar tempc weapxp6
	setvarvar tempd weaplev6
	break
	case 7
	ifvare weaplev7 0 setvar temp 0 else
	{
		setvarvar zdist weaplev7
		subvar zdist 1
		setvarvar temp xpcaps7[zdist]
	}
	setvarvar tempb xpcaps7[weaplev7]
	setvarvar tempc weapxp7
	setvarvar tempd weaplev7
	break
	case 8
	ifvare weaplev8 0 setvar temp 0 else
	{
		setvarvar zdist weaplev8
		subvar zdist 1
		setvarvar temp xpcaps8[zdist]
	}
	setvarvar tempb xpcaps8[weaplev8]
	setvarvar tempc weapxp8
	setvarvar tempd weaplev8
	break
	case 9
	ifvare weaplev9 0 setvar temp 0 else
	{
		setvarvar zdist weaplev9
		subvar zdist 1
		setvarvar temp xpcaps9[zdist]
	}
	setvarvar tempb xpcaps9[weaplev9]
	setvarvar tempc weapxp9
	setvarvar tempd weaplev9
	break
	
	case 11
	ifvare weaplev11 0 setvar temp 0 else
	{
		setvarvar zdist weaplev11
		subvar zdist 1
		setvarvar temp xpcaps11[zdist]
	}
	setvarvar tempb xpcaps11[weaplev11]
	setvarvar tempc weapxp11
	setvarvar tempd weaplev11
	break
	default break
	endswitch
}

// temp is the starting xp for current weapon level
// tempb is the ending xp for current weapon level
// tempc is the actual amount of xp
// tempd is the current weapon level

subvarvar tempb temp // xp range
subvarvar tempc temp // distance from start xp
mulvar tempc 50
divvarvar tempc tempb // percentage of range weapon has completed divided by two

setvar digz 16384
// bar is 50 pixels across
setvar X 265
setvar digx 315
addvarvar tempc X

setvar tempe 0
ifvarvarg tempc X setvar orientation 0 else setvar orientation 33
setvar pal 2
rotatesprite 264 195 digz 0 6171 0 pal orientation 0 0 xdim ydim
whilevarn tempe 1
{
	ifvarvarg X tempc setvar orientation 33
	ifvarvarg X digx setvar tempe 1
	else
	rotatesprite X 195 digz 0 6172 0 pal orientation 0 0 xdim ydim
	addvar X 1
	break
}
subvar X 1
rotatesprite X 195 digz 0 6173 0 pal orientation 0 0 xdim ydim
digitalnumberz 2930 260 197 tempd 0 10 0 0 0 xdim ydim 24576

ends


onevent EVENT_DRAWWEAPON

ifvarn menutoggle 0 { setvar RETURN -1 break }
ifvarg superkicking 0 
{
	state displaykicks 
	ifvare currentweapon 0 ifvarg LASERAMMO 0 state laserhud
	ifvare currentweapon 1 state displaypistolbullets
	setvar RETURN -1 
	break
}


ifvare currentweapon 0 
{
	ifvarg LASERAMMO 0 { state displaylaserpistol break }
	else
	ifvarg LASERFIRE 0 { state displaylaserpistol break }
}
ifvare currentweapon 1 state displaypistolbullets


ifvare currentweapon 2
{
	setvar RETURN -1
	state initweapondisplay
	setvar picnum 6220
	setvar orientation 0
	
	ifvarg weaponcount 2 ifvarl weaponcount 7 // muzzleflash for when cruizer is used
	{
		setvarvar mx digx
		addvar mx 30
		setvarvar my digy
		subvar my 10
		displayrandvar angvar 2047
		rotatesprite mx my 24576 angvar 8831 0 0 1 0 0 xdim ydim
	}
	
	switch weaponcount
	case 0
	break
	case 1 case 2
	break
	
	case 3 case 4 case 5 
	setvar picnum 6221
	setvar angvar 96
	addvar digx 20
	addvar digy 10
	break
	
	case 6 case 7 case 8
	setvar picnum 6222
	setvar angvar 96
	addvar digx 20
	addvar digy 10
	break
	
	case 9 case 10 
	setvar picnum 6223
	addvar digy 13
	break
	
	case 11 case 12 case 13
	addvar digx 30
	subvar digy 5
	setvar picnum 6224
	break
	

	case 28 case 29 case 30 case 31
	case 14 case 15 case 16
	addvar digx 70
	subvar digy 5
	setvar picnum 6225
	break
	
	case 17 case 18
	case 19 case 20
	case 24 case 25 case 26 case 27
	addvar digx 70
	subvar digy 5
	setvar picnum 6226
	break
	
	case 21 case 22 case 23
	addvar digx 70
	subvar digy 5
	setvar picnum 6227
	break
	default break
	endswitch
	guniqhudid 5
	rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
	guniqhudid 0
}
ifvare currentweapon 3
{
	ifvarand ALTCHAINGUN 2
	{
		setvar RETURN -1
		state displayminigun
	}
}
ifvare currentweapon 4
{
	setvar RETURN -1
	state initweapondisplay
	ifvare weaponcount 0
	setvar picnum 6228 
	else ifvarl weaponcount 4
	setvar picnum 6229
	else ifvarl weaponcount 7
	setvar picnum 6230
	else setvar picnum 6228

	switch weaponcount
	case 1 addvar digx 3 addvar digy 3 break
	case 2 addvar digx 6 addvar digy 6 break
	case 3 addvar digx 9 addvar digy 9 break
	case 4 addvar digx 12 addvar digy 12 break
	case 5 addvar digx 15 addvar digy 15 break
	case 6 addvar digx 17 addvar digy 17 break
	case 7 addvar digx 18 addvar digy 18 break
	case 8 addvar digx 17 addvar digy 17 break
	case 9 addvar digx 15 addvar digy 15 break
	case 10 addvar digx 13 addvar digy 13 break
	case 11 addvar digx 11 addvar digy 11 break
	case 12 addvar digx 9 addvar digy 9 break
	case 13 addvar digx 7 addvar digy 7 break
	case 14 addvar digx 5 addvar digy 5 break
	case 15 addvar digx 4 addvar digy 4 break
	case 16 addvar digx 3 addvar digy 3 break
	case 17 addvar digx 2 addvar digy 2 break
	case 18 addvar digx 1 addvar digy 1 break
	default break
	endswitch
	
	ifvarg weaponcount 0 ifvarl weaponcount 4
	{
		setvarvar mx digx
		addvar mx 50
		setvarvar my digy
		addvar my 30
		rotatesprite mx my 24576 0 8832 0 0 0 0 0 xdim ydim
	}
 
	else
	ifvarg weaponcount 3 ifvarl weaponcount 7
	{
		setvarvar mx digx
		addvar mx 45
		setvarvar my digy
		addvar my 27
		ifvare weaponcount 6 setvar temp 1 else setvar temp 0
		rotatesprite mx my 32768 0 8832 0 0 0 temp 0 xdim ydim
	} 
		
	rotatesprite digx digy digz 0 picnum shade pal orientation 0 0 xdim ydim

	
}

ifvare CURRWEAP 8 ifvare dukemon YES
{
	getplayer[THISACTOR].ammo_amount 8 temp
	ifvare temp 0 { setvar RETURN -1 break }
	state displaydukeballs
}

ifvare useakimbo YES nullop else break

ifoutside getsector[THISACTOR].ceilingshade shade else
getsector[THISACTOR].floorshade shade
getsector[THISACTOR].floorpal pal
ifvare pal 4 { addvar shade 10 setvar pal 0 }
setvar digz 65536
getuserdef[THISACTOR].screen_size C

ifvare currentweapon 1 ifvarn akimbo -1 ifvarn akimbo 0
{
	setvar RETURN -1
	
	switch weaponcount
	case 0 case 1 // idle frame
		state idleakimbo
	break
	

	case 2 case 3 // right gun fires
		setvar digx 90
		setvar digy 244
		ifvarg C 4 subvar digy 16
		state adjustleftpos
		guniqhudid 1
		setvar picnum 2524 // LEFTPISTOL
		setvar orientation 4
		rotatesprite digx digy digz 1024 picnum shade pal orientation 0 0 xdim ydim
		guniqhudid 5
		setvar picnum 2525 // RIGHT PISTOL FIRING
		ifvare weaponcount 3 addvar picnum 1
		setvar orientation 0
		setvar digx 90
		setvar digy 244
		ifvarg C 4 subvar digy 16
		state adjustrightpos
		addvar digx 120
		setvar shade -127
		rotatesprite digx digy digz 0 picnum shade pal orientation 0 0 xdim ydim
		guniqhudid 0
	break
	
	case 4 case 5
	state idleakimbo
	break
	
		
	case 6 case 7 // left gun is firing
		setvar digx 90
		setvar digy 244
		ifvarg C 4 subvar digy 16
		state adjustleftpos
		setvar picnum 2525 // LEFTPISTOL
		ifvare weaponcount 7 addvar picnum 1
		setvar orientation 4
		setvar shade -127
		guniqhudid 1
		rotatesprite digx digy digz 1024 picnum shade pal orientation 0 0 xdim ydim
		guniqhudid 5
		setvar picnum 2524 // RIGHT PISTOL
		setvar orientation 0
		setvar digx 90
		setvar digy 244
		ifvarg C 4 subvar digy 16
		state adjustrightpos
		addvar digx 120
		ifoutside getsector[THISACTOR].ceilingshade shade else
		getsector[THISACTOR].floorshade shade
		ifvare sector[THISACTOR].floorpal 4 addvar shade 10
		rotatesprite digx digy digz 0 picnum shade pal orientation 0 0 xdim ydim
		guniqhudid 0
	break
	
	case 8 state idleakimbo break
	
	case 9 case 10 case 11 case 12 case 13 case 14 case 15 case 16 case 17
	case 18 case 19 case 20 case 21 case 22 case 23 case 24 case 25 case 26
		setvar digx 90
		setvar digy 238
		ifvarg C 4 subvar digy 14
		state adjustrightpos
		setvar orientation 4
		ifvarl weaponcount 13 // LEFT PISTOL IS GOING DOWN
		{
			setvar picnum 2524 // LEFTPISTOL
			setvarvar temp weaponcount
			subvar temp 7
			mulvar temp 6
			addvarvar digy temp
			guniqhudid 1
			rotatesprite digx digy digz 1024 picnum shade pal orientation 0 0 xdim ydim
		}
		else ifvarg weaponcount 17 // clip hand and clip for reloading the right pistol
		{
			addvar digx 70
			addvar digy 122
			setvarvar temp weaponcount
			mulvar temp 5
			subvarvar digy temp
			setvar orientation 0
			ifvarl weaponcount 21 setvar picnum 2531 else
			setvar picnum 2532
			guniqhudid 6
			rotatesprite digx digy digz 0 picnum shade pal orientation 0 0 xdim ydim
			ifvarg weaponcount 20 ifvarl weaponcount 24 // the clip
			{
				setvar picnum 2530
				addvar digx 20
				guniqhudid 7
				rotatesprite digx digy digz 0 picnum shade pal orientation 0 0 xdim ydim
			}
		}
		setvar digx 90
		setvar digy 238
		ifvarg C 4 subvar digy 14
		state adjustrightpos
		setvar picnum 2528 // RIGHT PISTOL RELOAD 1
		ifvarg weaponcount 15
		{
			setvar picnum 2529 
			subvar digy 40
			addvarvar digy weaponcount
		}
		setvar orientation 0
		addvar digx 120
		guniqhudid 5
		rotatesprite digx digy digz 0 picnum shade pal orientation 0 0 xdim ydim
		guniqhudid 0
	break
	
	case 27 case 28 case 29 case 30 case 31 case 32 case 33 case 34 case 35 case 36
	case 37 case 38 case 39 case 40 case 41 case 42 case 43 
	case 44 case 45
	//case 46 case 47 case 48
		setvar digx 90
		setvar digy 238
		ifvarg C 4 subvar digy 14
		state adjustrightpos
		setvar orientation 4
		ifvarl weaponcount 32  // right pistol is going down
		{
			setvar picnum 2524 // RIGHT PISTOL
			setvar orientation 0
			addvar digx 120
			setvarvar temp weaponcount
			subvar temp 26
			mulvar temp 6
			addvarvar digy temp
			guniqhudid 5
			rotatesprite digx digy digz 0 picnum shade pal orientation 0 0 xdim ydim
		}
		else ifvarg weaponcount 36 // clip hand and clip for reloading left pistol
		{
			setvar picnum 2532
			addvar digx 40
			setvarvar temp weaponcount
			//subvar temp 26
			subvar temp 19
			mulvar temp 5
			addvar digy 120
			subvarvar digy temp
			ifvarl weaponcount 40 setvar picnum 2531 else
			setvar picnum 2532
			guniqhudid 8
			rotatesprite digx digy digz 1024 picnum shade pal orientation 0 0 xdim ydim
			
			ifvarg weaponcount 39 ifvarl weaponcount 43 // the clip
			{
				setvar picnum 2530
				subvar digx 10
				subvar digy 10
				guniqhudid 9
				rotatesprite digx digy digz 1024 picnum shade pal orientation 0 0 xdim ydim
			}
			
		}
		setvar digx 90
		setvar digy 238
		ifvarg C 4 subvar digy 14
		state adjustrightpos
		
		setvar picnum 2528 // LEFT PISTOL RELOAD 1
		ifvarg weaponcount 34
		{
			setvar picnum 2529 // LEFT PISTOL RELOAD 2
			subvar digy 59
			addvarvar digy weaponcount
		}
		setvar orientation 4
		guniqhudid 1
		rotatesprite digx digy digz 1024 picnum shade pal orientation 0 0 xdim ydim
		guniqhudid 0
	break
	
	default
		state idleakimbo
	break
	
	endswitch
}

endevent

onevent EVENT_DISPLAYCROSSHAIR

ifvarn menutoggle 0 setvar RETURN -1

endevent

state showhighscores

// High Scores

	setvar shade 0
	setvar pal 0
	rotatesprite 160 100 65536 0 3245 shade pal 0 0 0 xdim ydim
	
	// Main banner "HIGH SCORES"
   
   gametext 2908 320 5 1061 0 0 16 0 0 xdim ydim
   
   // EPISODE 1
   ifvare VOLUME 0 setvar pal 8 else setvar pal 0
   gametextz STARTALPHANUM 35 30 1124 shade pal 0 0 0 xdim ydim 40960
   ifvarand finished 1 
   rotatesprite 5 28 4096 0 COMPLETED_STAR shade 0 0 0 0 xdim ydim
   setvar I 0
   setvar digx 55
   setvar digy 37
   whilevarn I 6
   {
	   digitalnumberz 2837 digx digy attscores[I] shade 12 0 0 0 xdim ydim 32768
	   addvar digy 6
	   addvar I 1
   }
   
   // EPISODE 2
   ifvare VOLUME 1 setvar pal 8 else setvar pal 0
   gametextz STARTALPHANUM 35 80 1125 shade pal 0 0 0 xdim ydim 40960
   ifvarand finished 2 
   rotatesprite 5 78 4096 0 COMPLETED_STAR shade 0 0 0 0 xdim ydim
   setvar I 10
   setvar digx 55
   setvar digy 87
   whilevarn I 16
   {
	   digitalnumberz 2837 digx digy attscores[I] shade 12 0 0 0 xdim ydim 32768
	   addvar digy 6
	   addvar I 1
   }

   // EPISODE 3
   ifvare VOLUME 2 setvar pal 8 else setvar pal 0
   gametextz STARTALPHANUM 35 130 1126 shade pal 0 0 0 xdim ydim 40960
   ifvarand finished 4 
   rotatesprite 5 128 4096 0 COMPLETED_STAR shade 0 0 0 0 xdim ydim
   setvar I 20
   setvar digx 55
   setvar digy 137
   whilevarn I 26
   {
	   digitalnumberz 2837 digx digy attscores[I] shade 12 0 0 0 xdim ydim 32768
	   addvar digy 6
	   addvar I 1
   }
    
   // EPISODE 3
   ifvare VOLUME 3 setvar pal 8 else setvar pal 0
   gametextz STARTALPHANUM 285 30 1127 shade pal 0 0 0 xdim ydim 40960
   ifvarand finished 8 
   rotatesprite 134 28 4096 0 COMPLETED_STAR shade 0 0 0 0 xdim ydim
   setvar I 30
   setvar digx 180
   setvar digy 37
   whilevarn I 36
   {
	   digitalnumberz 2837 digx digy attscores[I] shade 12 0 0 0 xdim ydim 32768
	   addvar digy 6
	   addvar I 1
   }
   
   // EPISODE 4
   ifvare VOLUME 3 setvar pal 8 else setvar pal 0
   gametextz STARTALPHANUM 285 80 1128 shade pal 0 0 0 xdim ydim 40960
   ifvarand finished 16 
   rotatesprite 134 78 4096 0 COMPLETED_STAR shade 0 0 0 0 xdim ydim
   setvar I 40
   setvar digx 180
   setvar digy 87
   whilevarn I 46
   {
	   digitalnumberz 2837 digx digy attscores[I] shade 12 0 0 0 xdim ydim 32768
	   addvar digy 6
	   addvar I 1
   }
     
ends

state weapstats
	rotatesprite digx digy 65536 0 LASERLINE 0 0 0 0 0 xdim ydim
	addvar digx 20
	switch upweap
	case 0 setvarvar statmsg weapup0 setvar picnum BOOTS setvar digz 20480 break
	case 1 setvarvar statmsg weapup1 setvar picnum FIRSTGUNSPRITE setvar digz 16384 break
	case 2 setvarvar statmsg weapup2 setvar picnum SHOTGUNSPRITE setvar digz 12288 break
	case 3 setvarvar statmsg weapup3 setvar picnum CHAINGUNSPRITE	setvar digz 12288 break
	case 4 setvarvar statmsg weapup4 setvar picnum RPGSPRITE setvar digz 16384 break
	case 5 setvarvar statmsg weapup5 setvar picnum HEAVYHBOMB setvar digz 8192 break
	case 6 setvarvar statmsg weapup6 setvar picnum SHRINKERSPRITE setvar digz 10240 break
	case 7 setvarvar statmsg weapup7 setvar picnum DEVISTATORSPRITE setvar digz 16384 break
	case 8 setvarvar statmsg weapup8 setvar picnum TRIPBOMBSPRITE setvar digz 16384 break
	case 9 setvarvar statmsg weapup9 setvar picnum FREEZESPRITE setvar digz 12288 break
	case 10 setvarvar statmsg weapup10 setvar picnum LASERPISTOL setvar digz 16384 break
	case 11 setvarvar statmsg weapup11 setvar picnum GROWSPRITEICON setvar digz 10240 break
	default setvar picnum 1 setvar digz 20480 break
	endswitch
	mulvar digz 3 shiftvarr digz 1
	
	ifvare picnum LASERPISTOL setvar pal 1 else setvar pal 0
	rotatesprite digx digy digz 0 picnum 0 pal 0 0 0 xdim ydim
	shiftvarl digx 1 addvar digx 40 addvar digy 1
	gametextz 2822 digx digy 1005 0 12 0 0 0 xdim ydim 32768
	addvar digy 6
	setvar tempb 1007 // starting quote
	setvar tempd 1 // starting bit
	setvarvar temp statmsg
	subvar digx 48
	whilevarn temp 0
	{
		ifvarvarand temp tempd
		{
			gametextz 2822 digx digy tempb 0 0 0 0 10 xdim ydim 32768
			addvar digy 4
			xorvarvar temp tempd
		}
// 		else ifvarl temp 0
// 		{
// 			gametextz 2822 digx digy 1038 0 0 0 0 10 xdim ydim 32768
// 			addvar digy 4
// 			mulvar temp -1
// 		}
		shiftvarl tempd 1
		addvar tempb 1
	}
ends

onevent EVENT_DISPLAYREST

ifvare rendmode 0 // software renderer
{
	rotatesprite 160 100 65536 0 6314 0 0 0 0 0 xdim ydim
	setvar RETURN -1
	break
}

ifvarn menutoggle 0 
{
	rotatesprite 160 100 65536 0 3281 0 4 1 0 0 xdim ydim
	ifvare menutoggle 12
	{
		setvar upweap 0 setvar digx 0 setvar digy 10 state weapstats
		setvar upweap 1 setvar digx 80 setvar digy 10 state weapstats
		setvar upweap 2 setvar digx 160 setvar digy 10 state weapstats
		setvar upweap 3 setvar digx 240 setvar digy 10 state weapstats
		setvar upweap 4 setvar digx 0 setvar digy 60 state weapstats
		setvar upweap 5 setvar digx 80 setvar digy 60 state weapstats
		setvar upweap 6 setvar digx 160 setvar digy 60 state weapstats
		setvar upweap 7 setvar digx 240 setvar digy 60 state weapstats
		setvar upweap 8 setvar digx 0 setvar digy 110 state weapstats
		setvar upweap 9 setvar digx 80 setvar digy 110 state weapstats
		setvar upweap 10 setvar digx 160 setvar digy 110 state weapstats
		setvar upweap 11 setvar digx 240 setvar digy 110 state weapstats
		
		rotatesprite 0 155 65536 0 LASERLINE 0 0 0 0 0 xdim ydim
		gametextz 2822 40 155 1067 0 12 0 0 0 xdim ydim 40960
		rotatesprite 20 165 12288 0 STEROIDS 0 0 0 0 0 xdim ydim
		digitalnumberz 2837 36 166 steroidlevel 0 12 0 0 0 xdim ydim 40960
		rotatesprite 20 180 10240 0 HOLODUKE 0 0 0 0 0 xdim ydim
		digitalnumberz 2837 36 181 botlevel 0 12 0 0 0 xdim ydim 40960
		rotatesprite 80 165 10240 0 FIRSTAID 0 0 0 0 0 xdim ydim
		digitalnumberz 2837 96 166 maxmedkit 0 12 0 0 0 xdim ydim 40960
		rotatesprite 80 180 16384 0 SHIELD 0 0 0 0 0 xdim ydim
		digitalnumberz 2837 96 181 player[THISACTOR].max_shield_amount 0 12 0 0 0 xdim ydim 40960
		
		rotatesprite 190 155 65536 0 LASERLINE 0 0 0 0 0 xdim ydim
		gametextz 2822 400 155 1069 0 12 0 0 0 xdim ydim 40960
		ifvarg weaptotal 11 gametextz 2822 400 165 1070 0 0 0 0 0 xdim ydim 40960
		ifvarg weaptotal 23 gametextz 2822 400 172 1049 0 6 0 0 0 xdim ydim 40960
		ifvarg weaptotal 35 gametextz 2822 400 179 1071 0 7 0 0 0 xdim ydim 40960
		ifvarg weaptotal 47 gametextz 2822 400 186 1072 0 6 0 0 0 xdim ydim 40960
	}
	else
	ifvare menutoggle 13 state showhighscores
	else
	{
		// TILE 144 FOR RESTART MISSION
		// VIEWSCREEN2 (EDF logo) could be used in the middle
		ifvare menutoggle 2 { state shadepulse setvar digz 45056 } else
		{ setvar shade 0 setvar digz 36864 }
		rotatesprite 80 100 digz 0 UPGRADEBUTTON shade 0 0 0 0 xdim ydim
		gametext 2822 90 140 1005 shade 11 0 0 0 xdim ydim
		ifvare menutoggle 3 { state shadepulse setvar digz 20480 } else
		{ setvar shade 0 setvar digz 16384 }
		rotatesprite 240 100 digz 0 3245 shade 0 0 0 0 xdim ydim
		gametext 2822 400 140 1061 shade 11 0 0 0 xdim ydim
		ifvare menutoggle 4 { state shadepulse setvar digz 32768 } else 
		{ setvar shade 0 setvar digz 24576 }
		rotatesprite 160 30 digz 0 144 shade 0 0 0 0 xdim ydim
		gametext 2822 205 60 1062 shade 11 0 0 0 xdim ydim
	}
	rotatesprite cursorx cursory 32768 cursorang 100 0 0 0 0 0 xdim ydim
	
	qsprintf 1066 1063 1065
	// qsprintf <target quote> <first quote> <second quote to append to first>
	gametext 2822 320 195 1066 0 10 0 0 0 xdim ydim
	
	setvar RETURN -1 
	break 
}
else ifvarl timer 260
{
	ifvarl timer 83
	{
		// qsprintf 1068 1067 truelevel // <result quote> <source quote> <var1> <var2> ...
		setvarvar shade timer
		subvar shade 64
		ifvarg timer 79 setvar orientation 33 else
		ifvarg timer 76 setvar orientation 1 else
		setvar orientation 0
		// gametext 2908 320 50 1068 shade 0 orientation 0 0 xdim ydim
		setvar temp 1095
		addvarvar temp truelevel
		gametext 2908 320 50 temp shade 0 orientation 0 0 xdim ydim
		
	}
	qsprintf 1066 1064 1065
	// qsprintf <target quote> <first quote> <second quote to append to first>
	gametext 2822 320 170 1066 0 10 0 0 0 xdim ydim
}

ifvarn player[THISACTOR].newowner -1 break

//debugging var display

// getplayer[THISACTOR].posz debugvar
// getplayer[THISACTOR].i spriteid
// getactor[spriteid].z digz
// digitalnumberz 3010 150 14 debugvar 0 0 0 0 0 xdim ydim 65536
// digitalnumberz 3010 150 22 digz 0 0 0 0 0 xdim ydim 65536

ifvarg rage 0 ifvarl rage FULLRAGE // rage mode
{
	rotatesprite 160 100 65536 rageang 6468 0 0 1 0 0 xdim ydim
	rotatesprite 160 30 32768 0 6476 0 0 0 0 0 xdim ydim
}

state scoredisplay

state weaponleveldisplay

state quotedisplay

getplayer[THISACTOR].airleft tempb
getplayer[THISACTOR].scuba_on tempc
ifvarl tempb 390 ifvarg tempb 0 ifvare tempc 0
{
	setvar digy 10
	setvar digx 30
	setvar digz 16384
	setvar orientation 0
	setvar pal 1
	
	
	divvar tempb 4
	setvarvar tempc digx
	addvarvar tempc tempb
	setvar temp 0
	whilevarn temp 1
	{
		  ifvarvarg digx tempc setvar temp 1
		  rotatesprite digx digy digz 0 199 0 pal orientation 0 0 xdim ydim
		  addvar digx 1
		  break
	}
	setvar pal 0
	setvar digz 32768
	setvar digx 20
	setvar picnum 2868
    rotatesprite digx digy digz 0 picnum 0 pal orientation 0 0 xdim ydim
    setvar picnum 2839
    setvar digx 24
    setvar digz 20480
    rotatesprite digx digy digz 0 picnum 0 pal orientation 0 0 xdim ydim
}

ifvarl kickenergy KENERGY
{
	setvar digx 4
	setvar digy 163
	ifvarl kickenergy 130 setvar pal 4 else
	setvar pal 8
	setvarvar tempb kickenergy
	shiftvarr tempb 5
	setvarvar tempc digx
	addvarvar tempc tempb
	setvar temp 0
	whilevarn temp 1
	{
		  ifvarvarg digx tempc setvar temp 1
		  rotatesprite digx digy 16384 0 199 0 pal 0 0 0 xdim ydim
		  addvar digx 1
		  break
	}
	subvar digy 3
	gametextz 2822 9 digy 1123 0 7 0 0 0 xdim ydim 24576
	
}

ifvare player[THISACTOR].over_shoulder_on YES
{
	ifvare CURRWEAP 0 ifvarg LASERAMMO 0 state laserhud
	ifvare CURRWEAP 1 state displaypistolbullets
	ifvare CURRWEAP 8 ifvare dukemon YES
	{
		getplayer[THISACTOR].ammo_amount 8 temp
		ifvare temp 0 { setvar RETURN -1 break }
		state displaydukeballs
	}
}

setuserdef[THISACTOR].screen_size 0
// HEALTH DISPLAY



rotatesprite 11 186 49152 0 COLA 0 4 33 0 0 xdim ydim
rotatesprite 10 185 49152 0 COLA 0 0 0 0 0 xdim ydim

ifvarl rage FULLRAGE 
rotatesprite 10 185 6144 0 6160 0 10 0 0 0 xdim ydim

getplayer[screenpeek].i temp
getactor[temp].extra tempb
digitalnumber 2930 46 191 tempb 0 4 33 0 0 xdim ydim
digitalnumber 2930 45 190 tempb 0 2 0 0 0 xdim ydim

rotatesprite 60 188 32768 0 3008 0 2 0 0 0 xdim ydim

getplayer[screenpeek].max_player_health tempb
digitalnumberz 2930 74 191 tempb 0 2 0 0 0 xdim ydim 32768




// ARMOR DISPLAY
getplayer[screenpeek].shield_amount temp
ifvarg temp 0
{
	ifvarg helmflash 0 ifvarand timer 1 setvar pal 6
	else setvar pal 0
	rotatesprite 91 184 32768 0 SHIELD 0 4 33 0 0 xdim ydim
	rotatesprite 90 183 32768 0 SHIELD 0 pal 0 0 0 xdim ydim
	
	digitalnumber 2930 125 191 temp 0 4 33 0 0 xdim ydim
	digitalnumber 2930 124 190 temp 0 pal 0 0 0 xdim ydim
}

// AMMO DISPLAY FOR CURRENT WEAPON

setvar pal 23
getplayer[screenpeek].curr_weapon temp
ifvare temp 10 setvar temp 5
ifvarg temp 0
{
	setvar x 241
	setvar z 24576
	switch temp
	case 1 
	getplayer[screenpeek].ammo_amount 1 tempb
	addvar x 5
	subvar z 8192
	setvar picnum AMMO
	break
	
	case 2
	getplayer[screenpeek].ammo_amount 2 tempb
	setvar picnum SHOTGUNAMMO
	addvar x 10
	break
	
	case 3 	
	getplayer[screenpeek].ammo_amount 3 tempb
	setvar picnum BATTERYAMMO
	subvar z 4096
	addvar x 5
	break
	
	case 4 
	getplayer[screenpeek].ammo_amount 4 tempb
	setvar picnum RPGAMMO
	subvar z 8192
	addvar x 10
	break
	
	case 5
	setvar picnum HBOMBAMMO
	getplayer[screenpeek].ammo_amount 5 tempb
	subvar z 4096
	addvar x 10
	break
	
	case 6
	getplayer[screenpeek].ammo_amount 6 tempb
	setvar picnum CRYSTALAMMO
	addvar x 10
	break
	
	case 7 setvar picnum DEVISTATORAMMO
	getplayer[screenpeek].ammo_amount 7 tempb
	addvar x 5
	break
	
	case 8 setvar picnum TRIPBOMBSPRITE
	getplayer[screenpeek].ammo_amount 8 tempb
	addvar z 8192
	addvar x 10
	break
	
	case 9 setvar picnum FREEZEAMMO
	getplayer[screenpeek].ammo_amount 9 tempb
	addvar x 5
	addvar z 8192
	break
	
	case 11 setvar picnum GROWAMMO
	getplayer[screenpeek].ammo_amount 11 tempb
	addvar x 5
	break
	default break
	endswitch
	
	rotatesprite x 186 z 0 picnum 0 4 33 0 0 xdim ydim
	subvar x 1
	rotatesprite x 185 z 0 picnum 0 0 0 0 0 xdim ydim
	
	digitalnumber 2930 281 191 tempb 0 4 33 0 0 xdim ydim
	digitalnumber 2930 280 190 tempb 0 pal 0 0 0 xdim ydim
	
	rotatesprite 295 188 32768 0 3008 0 pal 0 0 0 xdim ydim
	getplayer[screenpeek].max_ammo_amount temp tempc
	digitalnumberz 2930 310 191 tempc 0 pal 0 0 0 xdim ydim 32768	
}

// MINI AMMO DISPLAY FOR ALL WEAPONS

ifvare player[screenpeek].gotweapon 1 YES
{
	getplayer[THISACTOR].ammo_amount 1 temp
	ifvare temp 0 setvar orientation 33 else setvar orientation 0
	ifvare CURRWEAP 1 setvar pal 6 else setvar pal 0
	rotatesprite 18 195 12288 0 FIRSTGUNSPRITE 0 pal orientation 0 0 xdim ydim
	digitalnumberz 2837 26 196 temp 0 7 orientation 0 0 xdim ydim 24576
}
ifvare player[screenpeek].gotweapon 2 YES
{
	getplayer[THISACTOR].ammo_amount 2 temp
	ifvare temp 0 setvar orientation 33 else setvar orientation 0
	ifvare CURRWEAP 2 setvar pal 6 else setvar pal 0
	rotatesprite 37 196 8192 0 SHOTGUNSPRITE 0 pal orientation 0 0 xdim ydim
	digitalnumberz 2837 46 196 temp 0 7 orientation 0 0 xdim ydim 24576
}
ifvare player[screenpeek].gotweapon 3 YES
{
	getplayer[screenpeek].ammo_amount 3 temp
	ifvarl temp 1 setvar orientation 33 else setvar orientation 0
	ifvare CURRWEAP 3 setvar pal 6 else setvar pal 0
	rotatesprite 57 195 9216 0 CHAINGUNSPRITE 0 pal orientation 0 0 xdim ydim
	digitalnumberz 2837 66 196 temp 0 7 orientation 0 0 xdim ydim 24576
}
ifvare player[THISACTOR].gotweapon 4 YES
{
	getplayer[screenpeek].ammo_amount 4 temp
	ifvare temp 0 setvar orientation 33 else setvar orientation 0
	ifvare CURRWEAP 4 setvar pal 6 else setvar pal 0
	rotatesprite 78 195 10240 0 RPGSPRITE 0 pal orientation 0 0 xdim ydim
	digitalnumberz 2837 86 196 temp 0 7 orientation 0 0 xdim ydim 24576
}
ifvare player[screenpeek].gotweapon 5 YES
{
	getplayer[THISACTOR].ammo_amount 5 temp
	ifvare temp 0 setvar orientation 33 else setvar orientation 0
	ifvare CURRWEAP 5 setvar pal 6 else setvar pal 0
	rotatesprite 95 195 5120 0 HEAVYHBOMB 0 pal orientation 0 0 xdim ydim
	digitalnumberz 2837 102 196 temp 0 7 orientation 0 0 xdim ydim 24576
}
ifvare player[screenpeek].gotweapon 6 YES
{
	getplayer[THISACTOR].ammo_amount 6 temp
	ifvare temp 0 setvar orientation 33 else setvar orientation 0
	ifvare CURRWEAP 6 setvar pal 6 else setvar pal 0
	rotatesprite 114 195 9216 0 SHRINKERSPRITE 0 pal orientation 0 0 xdim ydim
	digitalnumberz 2837 124 196 temp 0 7 orientation 0 0 xdim ydim 24576
}
ifvare player[screenpeek].gotweapon 7 YES
{
	getplayer[screenpeek].ammo_amount 7 temp
	ifvare temp 0 setvar orientation 33 else setvar orientation 0
	ifvare CURRWEAP 7 setvar pal 6 else setvar pal 0
	rotatesprite 134 196 10240 0 DEVISTATORSPRITE 0 pal orientation 0 0 xdim ydim
	digitalnumberz 2837 142 196 temp 0 7 orientation 0 0 xdim ydim 24576
}
ifvare player[screenpeek].gotweapon 8 YES
{
	getplayer[screenpeek].ammo_amount 8 temp
	ifvare temp 0 setvar orientation 33 else setvar orientation 0
	ifvare CURRWEAP 8 setvar pal 6 else setvar pal 0
	rotatesprite 150 196 12288 0 TRIPBOMBSPRITE 0 pal orientation 0 0 xdim ydim
	digitalnumberz 2837 157 196 temp 0 7 orientation 0 0 xdim ydim 24576
}
ifvare player[screenpeek].gotweapon 9 YES
{
	getplayer[screenpeek].ammo_amount 9 temp
	ifvare temp 0 setvar orientation 33 else setvar orientation 0
	ifvare CURRWEAP 9 setvar pal 6 else setvar pal 0
	rotatesprite 166 195 8192 0 FREEZESPRITE 0 pal orientation 0 0 xdim ydim
	digitalnumberz 2837 174 196 temp 0 7 orientation 0 0 xdim ydim 24576
}

ifvare player[screenpeek].gotweapon 11 YES
{
	getplayer[screenpeek].ammo_amount 11 temp
	ifvare temp 0 setvar orientation 33 else setvar orientation 0
	ifvare CURRWEAP 11 setvar pal 6 else setvar pal 0
	rotatesprite 183 196 8192 0 GROWSPRITEICON 0 pal orientation 0 0 xdim ydim
	digitalnumberz 2837 192 196 temp 0 7 orientation 0 0 xdim ydim 24576
}

ifvarg LASERAMMO 0
{
	setvarvar temp LASERAMMO
	ifvare temp 0 setvar orientation 33 else setvar orientation 0
	ifvare CURRWEAP 0 setvar pal 6 else setvar pal 1
	rotatesprite 199 195 12288 0 FIRSTGUNSPRITE 0 pal orientation 0 0 xdim ydim
	digitalnumberz 2837 207 196 temp 0 7 orientation 0 0 xdim ydim 24576
}


// INVENTORY DISPLAY

ifvarg nukes 0
{
	ifvare invicon 0 setvar orientation 0 else setvar orientation 1
	ifvare invicon 0 
	rotatesprite 12 33 49152 0 20 0 0 0 0 0 xdim ydim
	rotatesprite 12 34 32768 0 ATOMICHEALTH 0 4 33 0 0 xdim ydim
	rotatesprite 11 33 32768 0 ATOMICHEALTH 0 8 orientation 0 0 xdim ydim
	digitalnumberz 2837 13 39 nukes 0 0 orientation 0 0 xdim ydim 32768
	ifvare invicon 0 ifvarg invmsg 0 
	gametextz 2822 40 33 1003 0 0 orientation 0 0 xdim ydim 32768
}
getplayer[screenpeek].firstaid_amount temp
ifvarg temp 0
{
	ifvare invicon 1 setvar orientation 0 else setvar orientation 1
	rotatesprite 12 50 10240 0 FIRSTAID 0 4 33 0 0 xdim ydim
	ifvare invicon 1
	rotatesprite 12 50 49152 0 20 0 0 0 0 0 xdim ydim
	rotatesprite 11 49 10240 0 FIRSTAID 0 0 orientation 0 0 xdim ydim
	digitalnumberz 2837 13 56 player[THISACTOR].firstaid_amount 0 0 orientation 0 0 xdim ydim 32768
	ifvare invicon 1 ifvarg invmsg 0 
	gametextz 2822 40 50 3 0 0 orientation 0 0 xdim ydim 32768
}

getplayer[THISACTOR].steroids_amount temp
ifvarg temp 0
{
	ifvare invicon 2 setvar orientation 0 else setvar orientation 1
	rotatesprite 12 66 16384 0 STEROIDS 0 4 33 0 0 xdim ydim
	ifvare invicon 2 
	rotatesprite 12 65 49152 0 20 0 0 0 0 0 xdim ydim
	rotatesprite 11 65 16384 0 STEROIDS 0 0 orientation 0 0 xdim ydim
	shiftvarr temp 2
	digitalnumberz 2837 13 71 temp 0 0 orientation 0 0 xdim ydim 32768
	ifvare invicon 2 ifvarg invmsg 0 
	gametextz 2822 40 65 37 0 0 orientation 0 0 xdim ydim 32768
	
}
getplayer[screenpeek].holoduke_amount temp
ifvarg temp 0
{
	ifvare invicon 3 setvar orientation 0 else setvar orientation 1
	rotatesprite 12 80 10240 0 HOLODUKE 0 4 33 0 0 xdim ydim
	ifvare invicon 3 
	rotatesprite 12 80 49152 0 20 0 0 0 0 0 xdim ydim
	rotatesprite 11 79 10240 0 HOLODUKE 0 0 orientation 0 0 xdim ydim
	divvar temp 24
	digitalnumberz 2837 13 86 temp 0 0 orientation 0 0 xdim ydim 32768
	ifvare invicon 3 ifvarg invmsg 0 
	gametextz 2822 40 80 91 0 0 orientation 0 0 xdim ydim 32768
	
}
getplayer[screenpeek].jetpack_amount temp
ifvarg temp 0
{
	ifvare invicon 4 setvar orientation 0 else setvar orientation 1
	rotatesprite 12 95 16384 0 JETPACK 0 4 33 0 0 xdim ydim
	ifvare invicon 4 
	rotatesprite 12 95 49152 0 20 0 0 0 0 0 xdim ydim
	rotatesprite 11 94 24576 0 JETPACK 0 0 orientation 0 0 xdim ydim
	shiftvarr temp 4
	digitalnumberz 2837 13 101 temp 0 0 orientation 0 0 xdim ydim 32768
	ifvare invicon 4 ifvarg invmsg 0 
	gametextz 2822 40 95 88 0 0 orientation 0 0 xdim ydim 32768
}
getplayer[screenpeek].heat_amount temp
ifvarg temp 0
{
	ifvare invicon 5 setvar orientation 0 else setvar orientation 1
	rotatesprite 12 110 24576 0 HEATSENSOR 0 4 33 0 0 xdim ydim
	ifvare invicon 5 
	rotatesprite 12 110 49152 0 20 0 0 0 0 0 xdim ydim
	rotatesprite 11 109 24576 0 HEATSENSOR 0 0 orientation 0 0 xdim ydim
	divvar temp 12
	digitalnumberz 2837 13 116 temp 0 0 orientation 0 0 xdim ydim 32768
	ifvare invicon 5 ifvarg invmsg 0 
	gametextz 2822 40 110 101 0 0 orientation 0 0 xdim ydim 32768
}
getplayer[screenpeek].scuba_amount temp
ifinwater
ifvarg temp 0
{
	ifvare invicon 6 setvar orientation 0 else setvar orientation 1
	rotatesprite 12 125 12288 0 AIRTANK 0 4 33 0 0 xdim ydim
	ifvare invicon 6 
	rotatesprite 12 125 49152 0 20 0 0 0 0 0 xdim ydim
	rotatesprite 11 124 12288 0 AIRTANK 0 0 orientation 0 0 xdim ydim
	shiftvarr temp 6
	digitalnumberz 2837 13 131 temp 0 0 orientation 0 0 xdim ydim 32768
	ifvare invicon 6 ifvarg invmsg 0 
	gametextz 2822 40 125 39 0 0 orientation 0 0 xdim ydim 32768
}
getplayer[screenpeek].boot_amount temp
ifvarg temp 0
ifvarg bootsinuse 0
{
	ifvare invicon 7 setvar orientation 0 else setvar orientation 1
	rotatesprite 12 140 20480 0 BOOTS 0 4 33 0 0 xdim ydim
	ifvare invicon 7 
	rotatesprite 12 140 49152 0 20 0 0 0 0 0 xdim ydim
	ifvarand timer 1
	ifvarg bootsinuse 20
	setvar pal 6 else setvar pal 0
	rotatesprite 11 139 20480 0 BOOTS 0 pal orientation 0 0 xdim ydim
	shiftvarr temp 1
	digitalnumberz 2837 13 146 temp 0 0 orientation 0 0 xdim ydim 32768
	ifvare invicon 7 ifvarg invmsg 0 
	gametextz 2822 40 140 6 0 0 orientation 0 0 xdim ydim 32768
}
ifvarn player[THISACTOR].got_access 0
{
	ifvarand player[THISACTOR].got_access 1 rotatesprite 150 182 20480 0 ACCESSCARD 0 0 0 0 0 xdim ydim
	ifvarand player[THISACTOR].got_access 2 rotatesprite 153 184 20480 0 ACCESSCARD 0 21 0 0 0 xdim ydim
	ifvarand player[THISACTOR].got_access 4 rotatesprite 156 186 20480 0 ACCESSCARD 0 23 0 0 0 xdim ydim
}

ifvarg upmsgtime 0
{
	rotatesprite 205 182 32768 0 6861 0 0 0 0 0 xdim ydim
	switch upweap
	case 0 setvar picnum BOOTS setvar digz 20480 break
	case 1 setvar picnum FIRSTGUNSPRITE setvar digz 16384 break
	case 2 setvar picnum SHOTGUNSPRITE setvar digz 12288 break
	case 3 setvar picnum CHAINGUNSPRITE	setvar digz 12288 break
	case 4 setvar picnum RPGSPRITE setvar digz 16384 break
	case 5 setvar picnum HEAVYHBOMB setvar digz 8192 break
	case 6 setvar picnum SHRINKERSPRITE setvar digz 10240 break
	case 7 setvar picnum DEVISTATORSPRITE setvar digz 16384 break
	case 8 setvar picnum TRIPBOMBSPRITE setvar digz 16384 break
	case 9 setvar picnum FREEZESPRITE setvar digz 12288 break
	case 10 setvar picnum LASERPISTOL setvar digz 16384 break
	case 11 setvar picnum GROWSPRITEICON setvar digz 10240 break
	default setvar picnum 1 setvar digz 20480 break
	endswitch
	
	rotatesprite 190 171 digz 0 picnum 0 0 0 0 0 xdim ydim
	gametextz 2822 405 172 1005 0 12 orientation 0 0 xdim ydim 32768
	setvar digy 176
	setvar tempb 1007 // starting quote
	setvar tempd 1 // starting bit
	setvarvar temp upmsg
	whilevarn temp 0
	{
		ifvarvarand temp tempd
		{
			gametextz 2822 357 digy tempb 0 0 orientation 0 10 xdim ydim 32768
			addvar digy 4
			xorvarvar temp tempd
		}
		shiftvarl tempd 1
		addvar tempb 1
	}
		// weapon mastery bonuses
		ifvare weaptotal 12
		{
			rotatesprite 190 154 65536 0 LASERLINE 0 0 0 0 0 xdim ydim
			gametextz 2822 400 154 1069 0 12 0 0 0 xdim ydim 40960
			gametextz 2822 400 163 1070 0 0 0 0 0 xdim ydim 40960
			
		}
		ifvare weaptotal 24
		{
			rotatesprite 190 154 65536 0 LASERLINE 0 0 0 0 0 xdim ydim
			gametextz 2822 400 154 1069 0 12 0 0 0 xdim ydim 40960
			gametextz 2822 400 163 1049 0 6 0 0 0 xdim ydim 40960
			
		}
		ifvare weaptotal 36
		{
			rotatesprite 190 154 65536 0 LASERLINE 0 0 0 0 0 xdim ydim
			gametextz 2822 400 154 1069 0 12 0 0 0 xdim ydim 40960
			gametextz 2822 400 163 1071 0 7 0 0 0 xdim ydim 40960
			
		}
		ifvare weaptotal 48
		{
			rotatesprite 190 154 65536 0 LASERLINE 0 0 0 0 0 xdim ydim
			gametextz 2822 400 154 1069 0 12 0 0 0 xdim ydim 40960
			gametextz 2822 400 163 1072 0 6 0 0 0 xdim ydim 40960
			
		}
}

endevent

