// Weapons code
state sparkstate

	randvar zdist 1024
	ifrnd 128 mulvar zdist -1
	subvar zdist 512
	ezshootvar zdist NEWSCRAP1
	getactor[RETURN].ang ang
	randvar tmp 2048
	ifrnd 128 mulvar tmp -1
	addvarvar ang tmp
	setactor[RETURN].ang ang
	
	getactor[RETURN].x x
	getactor[RETURN].y y
	getactor[RETURN].z z
	randvar tmp 128
	randvar tmp2 128
	randvar tmp3 4092
	ifrnd 128 mulvar tmp -1
	ifrnd 128 mulvar tmp2 -1
	addvarvar x tmp
	addvarvar y tmp2
	addvarvar z tmp3
	setactor[RETURN].x x
	setactor[RETURN].y y
	setactor[RETURN].z z
	
ends


include blcons/qav2tc.con
include blcons/weapons/pitchfork.con
include blcons/weapons/flarepistol.con
include blcons/weapons/shotgun.con
include blcons/weapons/tommygun.con
include blcons/weapons/napalm.con
include blcons/weapons/dynamite.con
include blcons/weapons/spraycan.con
include blcons/weapons/teslagun.con
include blcons/weapons/hellstaff.con
include blcons/weapons/voodoodoll.con

state weaponplayerstate

//------------------------------HUDCOORDFIX

//Thanks to TheLezing for this code

  setvar r8 -16
  whilevarn r8 0 {
    addvar r8 1
    // Evaluate dynamics
    getplayer[THISACTOR].i PLAYERID
    getactor[PLAYERID].x r1
    addvarvar r1 camera_x
    shiftvarl r1 4
    subvarvar r1 HUDpx
    getactor[PLAYERID].y r2
    addvarvar r2 camera_y
    shiftvarl r2 4
    subvarvar r2 HUDpy
    getactor[PLAYERID].z r3
    addvarvar r3 camera_z
    getplayer[THISACTOR].horiz r4
    subvar r4 100
    shiftvarl r4 2
    addvarvar r3 r4
    subvarvar r3 HUDpz
    mulvar r1 -1 mulvar r2 -1 mulvar r3 -1
    // {r1, r2, r3} are current relative weapon coordinates //-2x*16
    setvar r4 256
    setvar r5 16384 //edited 4096
    setvar r6 0
    // {r4, r5, r6} are coordinates of the balanced point
    getactor[PLAYERID].ang r7
    addvar r7 1536
    rotatepoint 0 0 r4 r5 r7 r4 r5 //  x2+y2 = 4103
    subvarvar r4 r1 subvarvar r5 r2 subvarvar r6 r3
    // {r4, r5, r6} is now the acceleration vector (not normalized)

	
    setvarvar r0 r4 ifvarl r0 0 mulvar r0 -1
    setvarvar r1 r5 ifvarl r1 0 mulvar r1 -1
    setvarvar r2 r6 ifvarl r2 0 mulvar r2 -1
    addvarvar r0 r1 addvarvar r0 r2
    ifvarg r0 65536 { // Too fast!
      addvarvar HUDpx r4
      addvarvar HUDpy r5
      addvarvar HUDpz r6
      setvar HUDvx 0
      setvar HUDvy 0
      setvar HUDvz 0
    } else {
      addvarvar HUDpx HUDvx
      addvarvar HUDpy HUDvy
      addvarvar HUDpz HUDvz
      setvarvar r0 r4 mulvarvar r0 r0
      setvarvar r1 r5 mulvarvar r1 r1 addvarvar r0 r1
      setvarvar r1 r6 mulvarvar r1 r1 addvarvar r0 r1
      sqrt r0 r0 //длина вектора ускорения
      mulvarvar r4 r0 mulvarvar r5 r0 mulvarvar r6 r0
      shiftvarr r4 14 shiftvarr r5 14 shiftvarr r6 14
      addvarvar HUDvx r4
      addvarvar HUDvy r5
      addvarvar HUDvz r6
      getplayer[THISACTOR].i PLAYERID
      getactor[PLAYERID].sectnum PLAYERID
      getsector[PLAYERID].lotag lotag
     
	 // edit: чем больше умножаешь, тем меньше двигается оружие
      addvarvar HUDvz 32 // Gravity
      mulvar HUDvx 4 mulvar HUDvy 4 mulvar HUDvz 4
      
      shiftvarr HUDvx 4 shiftvarr HUDvy 4 shiftvarr HUDvz 4
    }
  }
  
  // Get projection
  getplayer[THISACTOR].i PLAYERID
  getactor[PLAYERID].x r1
  addvarvar r1 camera_x
  shiftvarl r1 4
  subvarvar r1 HUDpx
  getactor[PLAYERID].y r2
  addvarvar r2 camera_y
  shiftvarl r2 4
  subvarvar r2 HUDpy
  getactor[PLAYERID].z r3
  addvarvar r3 camera_z
  
  subvarvar r3 HUDpz
  getactor[PLAYERID].ang r4
  addvar r4 1536
  mulvar r4 -1
  rotatepoint 0 0 r1 r2 r4 r1 r2
  mulvar r1 -160
  mulvar r3 100

  ifvarn r2 0 // Prevent division by zero
  {
    divvarvar r1 r2
    divvarvar r3 r2
    subvar r1 16
    // subvar r3 64
    // HUDsx=HUDsx+(r1-HUDsx)*theta
	subvarvar r1 HUDsx
    shiftvarr r1 1
    addvarvar HUDsx r1
    subvarvar r3 HUDsy
    shiftvarr r3 1
    addvarvar HUDsy r3
  }
  
  // shiftvarr HUDsx 8
  // shiftvarr HUDsy 8
  /* findnearactor SIXPAK 2048 PLAYERID // Debug info
  setvarvar r1 HUDpx
  shiftvarr r1 4
  setactor[PLAYERID].x r1
  setvarvar r2 HUDpy
  shiftvarr r2 4
  setactor[PLAYERID].y r2
  updatesector r1 r2 r3
  setactor[PLAYERID].sectnum r3 */
 
 //------------------------------END HUDCOORDFIX
 
ifvarg AKIMBOTIME 0
ifvare tommysweep 0
ifvare akimbotommysweep 0
{
	subvar AKIMBOTIME 1
	ifvare activeakimbo 1
	{
		setvar flakimbo 9
		setvar WEAPON1_FIREDELAY 2
		setvar WEAPON1_TOTALTIME 18
		setvar WEAPON1_FLAGS 68
		
		setvar sgakimbo 9
		setvar WEAPON2_TOTALTIME 14
		setvar WEAPON2_FIREDELAY 2
		setvar WEAPON2_CLIP 0
		setvar WEAPON2_RELOAD 0
				
		setvar tmakimbo 9
				
		setvar npakimbo 9
		setvar WEAPON4_FIREDELAY 2
		setvar WEAPON4_TOTALTIME 21
					
		setvar tsakimbo 9
		setvar activeakimbo 0
	}
	ifvare AKIMBOTIME 0 { setvar deactiveakimbo 1 }
} 

ifvare deactiveakimbo 1 {
	setvar AKIMBOTIME 0
	setvar flakimbo -9
	setvar WEAPON1_FIREDELAY 5
	setvar WEAPON1_TOTALTIME 15
	setvar WEAPON1_FLAGS 4
		
	setvar sgakimbo -9
	setvar WEAPON2_TOTALTIME 12
	setvar WEAPON2_FIREDELAY 4
	setvar WEAPON2_CLIP 2
	setvar WEAPON2_RELOAD 27
				
	setvar tmakimbo -9
		
	setvar npakimbo -9
	setvar WEAPON4_FIREDELAY 4
	setvar WEAPON4_TOTALTIME 15		
	setvar deactiveakimbo 0		
}

	state shotgunplayerstate
	state voodooplayerstate
	state dynamitestate
	state spraystate
	state flareplayerstate
	state hellstaffplayerstate
	state tommygunplayerstate
	state napalmplayerstate
	state teslaplayerstate
	
//------------------------------RESET ALTFIRE

ifvare player[THISACTOR].kickback_pic 0 
{
setvar shotgunalt 0
setvar napalmalt 0
}

ends

action AFIREPL 0 1 5 1 1
actor PLAYERFIRE 0 AFIREPL
sizeat 28 28 cstat 2
getactor[THISACTOR].mdflags  tmp
orvar  tmp 16
setactor[THISACTOR].mdflags  tmp
ifcount 1 killit
enda

state playerfirestate
	espawn PLAYERFIRE 
	getactor[THISACTOR].x x
	getactor[THISACTOR].y y
	getactor[THISACTOR].z z
	getactor[THISACTOR].ang ang
	setvarvar x2 x
	addvarvar x2 128
	setvarvar y2 y
	addvarvar y2 64
	rotatepoint x y x2 y2 ang x3 y3
			
	subvar z 7000
	setactor[RETURN].x x3
	setactor[RETURN].y y3
	setactor[RETURN].z z
	getactor[RETURN].ang ang
	addvar ang 1024
	setactor[RETURN].ang ang
	setactorvar[RETURN].spriteid THISACTOR
ends

state weaponchangestate

	getplayer[THISACTOR].last_weapon lastweapon
	ifvarn lastweapon -1 
		setvarvar savelastweap lastweapon

	getplayer[THISACTOR].ammo_amount savelastweap ammo
	ifvarl ammo 1 setvar savelastweap 0

	// WEAPON CHANGER

	ifvare changeweappos 1
	{
		getplayer[THISACTOR].weapon_pos pos
		ifvarg pos 8 { ifvarn CURRWEAP 5 { setplayer[THISACTOR].curr_weapon 5 setvar curr_weapon 5 } setvar WEAPON_VAR_TNT 1 setvar changeweappos 0 }
	}
	ifvare changeweappos 2
	{
		getplayer[THISACTOR].weapon_pos pos
		ifvarg pos 8 { ifvarn CURRWEAP 5 { setplayer[THISACTOR].curr_weapon 5 setvar curr_weapon 5 } setvar WEAPON_VAR_TNT 2 setvar changeweappos 0 }
	}
	ifvare changeweappos 3
	{
		getplayer[THISACTOR].weapon_pos pos
		ifvarg pos 8 { ifvarn CURRWEAP 5 { setplayer[THISACTOR].curr_weapon 5 setvar curr_weapon 5 } setvar WEAPON_VAR_TNT 3 setvar changeweappos 0 }
	}
	ifvare changeweappos 4
	{
		getplayer[THISACTOR].weapon_pos pos
		ifvarg pos 8 { setplayer[THISACTOR].curr_weapon 6 setvar curr_weapon 6 setvar changeweappos 0 }
	}
	ifvare changeweappos 5
	{
		getplayer[THISACTOR].weapon_pos pos
		ifvarg pos 8 
		{	
			ifinwater {
				ifvare savelastweap 5 {
					setplayer[THISACTOR].curr_weapon 0
					setvar curr_weapon 0
				}
				else
				ifvare savelastweap 6 {
					setplayer[THISACTOR].curr_weapon 0
					setvar curr_weapon 0
				}
				else {
					setplayer[THISACTOR].curr_weapon savelastweap
					setvarvar curr_weapon savelastweap
				}
			} else {
				setplayer[THISACTOR].curr_weapon savelastweap
				setvarvar curr_weapon savelastweap
			}
			setvar changeweappos 0 
		}
	}

	ifvare changeweappos 10
	{
		getplayer[THISACTOR].weapon_pos pos
		ifvarg pos 8 ifvarn CURRWEAP 10 {  setvar WEAPON_VAR_TNT 3 setplayer[THISACTOR].curr_weapon 10 setvar curr_weapon 10 setvar changeweappos 0 }
	}
ends

state lighterdisplay
getplayer[THISACTOR].weapon_pos pos
ifvare player[THISACTOR].kickback_pic 0
{

ifvare LIGHTERENABLE 1
{
	getsector[THISACTOR].floorshade le_shade
	setvar qav_sh -24
	addvarvar le_shade qav_sh
	ifvarl le_shade -127 setvar le_shade -127
	ifvare CURRWEAP 5 
	{ 
		switch pos
		case 0
		setvar xweapon 110
		setvar yweapon 177
		setvar tilenumweapon	LIGHTER
		addvar tilenumweapon	3
		state hudcoordfix addvar yweapon 64
		setvarvar yweapsave yweapon
		rotatesprite xweapon yweapon 65536 0 tilenumweapon le_shade palweapon orientationweapon 0 0 xdim ydim
		addvar tilenumweapon 7
		addvar xweapon 34
		addvar yweapon -50
		rotatesprite xweapon yweapon 65536 0 tilenumweapon -128 palweapon orientationweapon 0 0 xdim ydim
		setvar displayfire 0
		break
		default
		setvar xweapon 110
		setvar yweapon 177
		setvar tilenumweapon LIGHTER
		addvar tilenumweapon 3
		state hudcoordfix addvar yweapon 64
		ifvarn yweapsave 0 ifvare displayfire 0 { ifvarvarl yweapon yweapsave nullop else setvarvar yweapon yweapsave }
		rotatesprite xweapon yweapon 65536 0 tilenumweapon le_shade palweapon orientationweapon 0 0 xdim ydim
		addvar tilenumweapon 7
		addvar xweapon 34
		addvar yweapon -50
		rotatesprite xweapon yweapon 65536 0 tilenumweapon -128 palweapon orientationweapon 0 0 xdim ydim
		break

		endswitch
	} else
	ifvare CURRWEAP 6 
	{ 
		switch pos
		case 0
		setvar xweapon 110
		setvar yweapon 177
		setvar tilenumweapon	LIGHTER
		addvar tilenumweapon	3
		state hudcoordfix addvar yweapon 64
		setvarvar yweapsave yweapon
		rotatesprite xweapon yweapon 65536 0 tilenumweapon le_shade palweapon orientationweapon 0 0 xdim ydim
		addvar tilenumweapon 7
		addvar xweapon 34
		addvar yweapon -50
		rotatesprite xweapon yweapon 65536 0 tilenumweapon -128 palweapon orientationweapon 0 0 xdim ydim
		setvar displayfire 0
		break
		default
		setvar xweapon 110
		setvar yweapon 177
		setvar tilenumweapon LIGHTER
		addvar tilenumweapon 3
		state hudcoordfix addvar yweapon 64
		ifvarn yweapsave 0 ifvare displayfire 0 {  ifvarvarl yweapon yweapsave nullop else setvarvar yweapon yweapsave }
		rotatesprite xweapon yweapon 65536 0 tilenumweapon le_shade palweapon orientationweapon 0 0 xdim ydim
		addvar tilenumweapon 7
		addvar xweapon 34
		addvar yweapon -50
		rotatesprite xweapon yweapon 65536 0 tilenumweapon -128 palweapon orientationweapon 0 0 xdim ydim
		break
		endswitch
	}
} else 
ifvare LIGHTERENABLE 0
{
	switch pos
	case	10 //LITEOPEN.QAV + LITEFLAM.QAV
	setvar xweapon	88
	setvar yweapon	218
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	0
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim
	break			
	case	9
	setvar xweapon	98
	setvar yweapon	203
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	0
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break		
	case	8
	setvar xweapon	103
	setvar yweapon	192
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	0
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break		
	case	7
	setvar xweapon	107
	setvar yweapon	180
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	1
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break			
	case	6
	setvar xweapon	107
	setvar yweapon	180
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	1
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break			
	case	5
	setvar xweapon	104
	setvar yweapon	178
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	2
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break			
	case	4
	setvar xweapon	104
	setvar yweapon	178
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	2
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break		
	case	3
	case    2
	setvar xweapon	110
	setvar yweapon	177
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	3
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim
	setvar xweapon	146
	setvar yweapon	134
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	7
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon -128 palweapon orientationweapon 0 0 xdim ydim	
	break			
	case	1
	setvar xweapon	110
	setvar yweapon	177
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	3
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim
	setvar xweapon	143
	setvar yweapon	131
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	8
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon -128 palweapon orientationweapon 0 0 xdim ydim	
	break		
	case	0
	setvar xweapon	110
	setvar yweapon	177
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	3
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	setvar xweapon	144
	setvar yweapon	128
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	9
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon -128 palweapon orientationweapon 0 0 xdim ydim	
	break			
	case -1 //LITECLO2.QAV
	case -2
	case -3
	setvar xweapon	106
	setvar yweapon	182
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	4
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	setvar xweapon	148
	setvar yweapon	142
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	9
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon -128 palweapon orientationweapon 0 0 xdim ydim	
	break		
	case	-4
	setvar xweapon	108
	setvar yweapon	181
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	5
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	setvar xweapon	146
	setvar yweapon	145
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	9
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon -128 palweapon orientationweapon 0 0 xdim ydim	
	break	
	case	-5
	setvar xweapon	107
	setvar yweapon	184
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	5
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim
	setvar xweapon	107
	setvar yweapon	184
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	5
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break			
	case	-6
	setvar xweapon	108
	setvar yweapon	194
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	6
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break			
	case	-7
	setvar xweapon	101
	setvar yweapon	208
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	6
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break			
	case	-8
	setvar xweapon	92
	setvar yweapon	221
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	6
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break	
	endswitch
}
	
ifvarn CURRWEAP 5 //LITECLO2.QAV
ifvarn CURRWEAP 6
{
	switch pos
	case -1
	case -2
	case -3
	setvar xweapon	106
	setvar yweapon	182
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	4
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	setvar xweapon	148
	setvar yweapon	142
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	9
	state hudcoordfix addvar yweapon 64
	rotatesprite xweapon yweapon 65536 0 tilenumweapon -128 palweapon orientationweapon 0 0 xdim ydim	
	break			
	case	-4
	setvar xweapon	108
	setvar yweapon	181
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	5
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	setvar xweapon	146
	setvar yweapon	145
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	9
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon -128 palweapon orientationweapon 0 0 xdim ydim	
	break		
	case	-5
	setvar xweapon	107
	setvar yweapon	184
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	5
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim
	setvar xweapon	107
	setvar yweapon	184
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	5
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break			
	case	-6
	setvar xweapon	108
	setvar yweapon	194
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	6
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break			
	case	-7
	setvar xweapon	101
	setvar yweapon	208
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	6
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break			
	case	-8
	setvar xweapon	92
	setvar yweapon	221
	setvar tilenumweapon	LIGHTER
	addvar tilenumweapon	6
	state hudcoordfix addvar yweapon 64	
	rotatesprite xweapon yweapon 65536 0 tilenumweapon shade palweapon orientationweapon 0 0 xdim ydim	
	break	
	endswitch
	}
}
ends

onevent EVENT_QUICKKICK
	setvar RETURN -1
	state flarealtstate
	state shotgunaltstate
	ifvarn EOL_VAR 1 ifvarn EOG_VAR 1 state tommygunaltstate
	state napalmaltstate
	ifvarn EOL_VAR 1 ifvarn EOG_VAR 1 state dynamitealtstate
	ifvarn EOL_VAR 1 ifvarn EOG_VAR 1 state spraycanaltstate
	ifvarn EOL_VAR 1 ifvarn EOG_VAR 1 state teslaaltstate
	ifvarn EOL_VAR 1 ifvarn EOG_VAR 1 state hellstaffaltstate
	ifvarn EOL_VAR 1 ifvarn EOG_VAR 1 state voodooaltstate
endevent

onevent EVENT_DISPLAYWEAPON
setvar palweapon 0 //getsector[THISACTOR].floorpal palweapon
getsector[THISACTOR].floorshade shade

getplayer[THISACTOR].weapon_pos pos
getactorvar[THISACTOR].invisible invisible

ifvare current_weapon 0
{
   setvar RETURN -1
   state pitchforkdisplay
}
ifvare current_weapon 1
{
   setvar RETURN -1
   ifvarn flakimbo -1 ifvarn flakimbo 0
   { state flareakimbodisplay } else state flaregundisplay
}
ifvare current_weapon 2
{
   setvar RETURN -1
   ifvarn sgakimbo -1 ifvarn sgakimbo 0
   { state shotgunakimbodisplay } else state shotgundisplay
}
ifvare current_weapon 3
{
   setvar RETURN -1
   ifvarn tmakimbo -1 ifvarn tmakimbo 0
   { state tommyakimbodisplay } else state tommygundisplay
}
ifvare current_weapon 4
{
   setvar RETURN -1
   getticks tmp
   ifvarn npakimbo -1 ifvarn npakimbo 0
   { state napalmakimbodisplay } else state napalmdisplay
}
ifvare current_weapon 5
{
    setvar RETURN -1
	ifvare WEAPON_VAR_TNT 1
    {	ifinwater nullop else
		{
	    ifvare tntalt 0 { state lighterdisplay }
		ifvare pos 0 { setvar LIGHTERENABLE 1 }
		state dynamitedisplay
		}
    } 
	else ifvare WEAPON_VAR_TNT 2
    { 
		 state proximityminedisplay
    } 
	else ifvare WEAPON_VAR_TNT 3
	{
		 getticks tmp
		 state remotetntdisplay
	}
}
ifvare current_weapon 6
{
   setvar RETURN -1
   ifvare sprayalt 0 { state lighterdisplay }
   ifvare pos 0 { setvar LIGHTERENABLE 1 }
   state spraycandisplay
}
ifvare current_weapon 7
{
   setvar RETURN -1
   ifvarn tsakimbo -1 ifvarn tsakimbo 0
   { state plasmaakimbogundisplay } else state plasmagundisplay
}
ifvare current_weapon 9
{
   ifp pwalking setvar temp 1 else ifp prunning setvar temp 1 else setvar temp 0
   ifvare temp 1 ifvare voodooprobability 0 ifvare voodoomovincs 0 setvar voodoomovincs 1	
   state voodoodisplay
   setvar RETURN -1
}
ifvare currentweapon 11
{
   setvar RETURN -1
   state lifeleechdisplay
}
endevent

onevent EVENT_GETSHOTRANGE
	state pitchforkshotrange
	state shotgunshotrange
	state tommygunshotrange
endevent

onevent EVENT_FIRE
	state flarefirestate
	state shotgunfirestate
	state tommygunfirestate
	state spraycanfirestate
	state voodoofirestate
endevent

onevent EVENT_DOFIRE
	state flaredofirestate
	state shotgundofirestate
	state napalmdofirestate
	state spraycandofirestate
endevent

onevent EVENT_PRESSEDFIRE
	setvar fire_shoot 1
	ifvarn EOL_VAR 1 ifvarn EOG_VAR 1 
	{
		state tommygunpressedfire
		state dynamitepressedfire
		state spraycanpressedfire
	}
	setvar cheat_ammo_on 0
	setvar cheat_weapon_on 0
	setplayer[THISACTOR].ammo_amount 11 0
endevent


onevent EVENT_RESETWEAPONS
	setplayer[THISACTOR].curr_weapon 0
	setplayer[THISACTOR].gotweapon 1 0
	setplayer[THISACTOR].ammo_amount 1 0
endevent

onevent EVENT_SELECTWEAPON
	ifvare player[THISACTOR].ammo_amount RETURN 0 
		setvar RETURN -1
	ifvarn CURRWEAP 6 ifvarn CURRWEAP 5 ifvarn currdinamite 1 ifvare LIGHTERENABLE 1 { sound ZIPCLOSE setvar LIGHTERENABLE 0 }
	ifvare CURRWEAP 5 { ifvare WEAPON_VAR_TNT 3 { ifvarg player[THISACTOR].kickback_pic 0 ifvarl player[THISACTOR].kickback_pic 20 setvar RETURN -1 } else ifvarg player[THISACTOR].kickback_pic 0 setvar RETURN -1 } else ifvarg player[THISACTOR].kickback_pic 0 setvar RETURN -1
endevent