
setdefname bloodtc.def
setcfgname btc.cfg
setgamename BloodTC 1.0

action PGROWING   7585
action PSTAND     7585   1   5   1  1
action PEXPLODE   6663   5  1  1  18
action PEXPLODEAD  6669   1   1
action PJPHOUVER  7602   1   5   1
action PWALK    7555   5   5   1   16
action PRUN     7555   5   5   1   10
action PWALKBACK  7570   4   5  -1   16
action PRUNBACK   7570   4   5  -1   10
action PJUMPING   7575   2   5   1   40
action PFALLING   7580   1   5
action PDUCKING   7632   1   5
action PCRAWLING  7632   3   5   1   20
action PAKICKING  7585   1   5   1   25
action PTHROWNBACK  7595  6   1   1   18
action PLYINGDEAD   7601  1   1

action PFATALITY 7656  1   1
action PFALL 7652  3 1 1 18
action PGETUP 7655  3 1 -1 18
action PDAMAGED 7657 6 1 1 18
action PDEAD  7663  1 1 1 1
action PDAMAGED2 7664 5 1 1 18
action PDEAD2 7669 1 1 1 1

action PSWIMMINGGO   7602   1   5   1   10
action PSWIMMING   7602   5   5   1   13
action PSWIMMINGWAIT 7602   1   5   1   13
action PTREDWATER  7602   2   5   1   17

include BloodTC/blcons/DEFS.CON
include BloodTC/blcons/USER.CON

action FRAME1 0 1 5 1 1
action FRAME2 5 1 5 1 1
action FRAME3 10 1 5 1 1
action FRAME4 15 1 5 1 1
action FRAME5 20 1 5 1 1

action FRAME_FRAME1 0 1 1 1 1
action FRAME_FRAME2 1 1 1 1 1
action FRAME_FRAME3 2 1 1 1 1
action FRAME_FRAME4 3 1 1 1 1
action FRAME_FRAME5 4 1 1 1 1
action FRAME_FRAME6 5 1 1 1 1
action FRAME_FRAME7 6 1 1 1 1
action FRAME_FRAME8 7 1 1 1 1

action FLAME2_FRAME1 0 1 1 1 1
action FLAME2_FRAME2 1 1 1 1 1
action FLAME2_FRAME3 2 1 1 1 1
action FLAME2_FRAME4 1 1 1 1 1
action FLAME2_FRAME5 0 1 1 1 1
action FLAME2_FRAME6 1362 1 1 1 1
action FLAME2_FRAME7 1363 1 1 1 1
action FLAME2_FRAME8 1364 1 1 1 1

action HELLFLAME_FRAME1 -1 1 1 1 1
action HELLFLAME_FRAME2 -1 1 1 1 1
action HELLFLAME_FRAME3 0 1 1 1 1
action HELLFLAME_FRAME4 0 1 1 1 1
action HELLFLAME_FRAME5 1 1 1 1 1
action HELLFLAME_FRAME6 1 1 1 1 1
action HELLFLAME_FRAME7 -1268 1 1 1 1
action HELLFLAME_FRAME8 -1268 1 1 1 1

action ONE 1
action TWO 2
action THREE 3
action FOUR 4
action FIVE 5

action ACTIVE 1

action DELAY1 0
action DELAY2 0

defineprojectile FORKSTAB PROJ_WORKSLIKE 4097
defineprojectile FORKSTAB PROJ_SPAWNS -1
defineprojectile FORKSTAB PROJ_DECAL BULLETHOLE
defineprojectile FORKSTAB PROJ_EXTRA 4
defineprojectile FORKSTAB PROJ_EXTRA_RAND 2
defineprojectile FORKSTAB PROJ_XREPEAT 3
defineprojectile FORKSTAB PROJ_YREPEAT 3
defineprojectile FORKSTAB PROJ_RANGE 1152

defineprojectile ATTACK_ENEMY PROJ_WORKSLIKE 4097
defineprojectile ATTACK_ENEMY PROJ_SPAWNS EXPLOSION6
defineprojectile ATTACK_ENEMY PROJ_EXTRA 4
defineprojectile ATTACK_ENEMY PROJ_EXTRA_RAND 2
defineprojectile ATTACK_ENEMY PROJ_XREPEAT 3
defineprojectile ATTACK_ENEMY PROJ_YREPEAT 3
defineprojectile ATTACK_ENEMY PROJ_RANGE 1300

spritenoshade NEWSHELL
defineprojectile NEWSHELL PROJ_WORKSLIKE 6278
defineprojectile NEWSHELL PROJ_EXTRA 0
defineprojectile NEWSHELL PROJ_HITRADIUS 0
defineprojectile NEWSHELL PROJ_VEL 24
defineprojectile NEWSHELL PROJ_SPAWNS FLOORSHEEL
defineprojectile NEWSHELL PROJ_DROP -256
defineprojectile NEWSHELL PROJ_BOUNCES 2
defineprojectile NEWSHELL PROJ_BSOUND SHTSHL
defineprojectile NEWSHELL PROJ_CLIPDIST 16
defineprojectile NEWSHELL PROJ_XREPEAT 4
defineprojectile NEWSHELL PROJ_YREPEAT 4

actor NEWSHELL 0 FRAME_FRAME1 enda

spritenoshade NEWSHSHELL
defineprojectile NEWSHSHELL PROJ_WORKSLIKE 6278
defineprojectile NEWSHSHELL PROJ_EXTRA 0
defineprojectile NEWSHSHELL PROJ_HITRADIUS 0
defineprojectile NEWSHSHELL PROJ_VEL 24
defineprojectile NEWSHSHELL PROJ_SPAWNS FLOORSHSHEEL
defineprojectile NEWSHSHELL PROJ_DROP -256
defineprojectile NEWSHSHELL PROJ_BOUNCES 2
defineprojectile NEWSHSHELL PROJ_BSOUND SHTSHL4
defineprojectile NEWSHSHELL PROJ_CLIPDIST 16
defineprojectile NEWSHSHELL PROJ_XREPEAT 4
defineprojectile NEWSHSHELL PROJ_YREPEAT 4

actor NEWSHSHELL 0 FRAME_FRAME1 enda

defineprojectile TOMMYFIRST PROJ_WORKSLIKE 4097
defineprojectile TOMMYFIRST PROJ_SPAWNS NEWSMOKE
defineprojectile TOMMYFIRST PROJ_DECAL BULLETHOLE
defineprojectile TOMMYFIRST PROJ_EXTRA 12
defineprojectile TOMMYFIRST PROJ_XREPEAT 3
defineprojectile TOMMYFIRST PROJ_YREPEAT 3

defineprojectile ALTTOMMY PROJ_WORKSLIKE 4097
defineprojectile ALTTOMMY PROJ_SPAWNS NEWSMOKE
defineprojectile ALTTOMMY PROJ_DECAL BULLETHOLE
defineprojectile ALTTOMMY PROJ_EXTRA 20
defineprojectile ALTTOMMY PROJ_XREPEAT 3
defineprojectile ALTTOMMY PROJ_YREPEAT 3

defineprojectile SHOTAMMO PROJ_WORKSLIKE 4097
defineprojectile SHOTAMMO PROJ_SPAWNS NEWSMOKE
defineprojectile SHOTAMMO PROJ_DECAL BULLETHOLE
defineprojectile SHOTAMMO PROJ_EXTRA 4
defineprojectile SHOTAMMO PROJ_XREPEAT 3
defineprojectile SHOTAMMO PROJ_YREPEAT 3

spritenoshade FLARE
defineprojectile FLARE PROJ_WORKSLIKE 6146
defineprojectile FLARE PROJ_HITRADIUS 0
defineprojectile FLARE PROJ_SPAWNS FLAREFIRE
defineprojectile FLARE PROJ_VEL 200
defineprojectile FLARE PROJ_OFFSET 192
defineprojectile FLARE PROJ_VEL_MULT 6
defineprojectile FLARE PROJ_CLIPDIST 32
defineprojectile FLARE PROJ_XREPEAT 30
defineprojectile FLARE PROJ_YREPEAT 30
defineprojectile FLARE PROJ_CSTAT 130

spritenoshade PR_NAPALM
defineprojectile PR_NAPALM PROJ_WORKSLIKE 6146
defineprojectile PR_NAPALM PROJ_HITRADIUS 1280
defineprojectile PR_NAPALM PROJ_SPAWNS EXPLOSION6
defineprojectile PR_NAPALM PROJ_EXTRA 100
defineprojectile PR_NAPALM PROJ_EXTRA_RAND 25
defineprojectile PR_NAPALM PROJ_SXREPEAT 32
defineprojectile PR_NAPALM PROJ_SYREPEAT 32
defineprojectile PR_NAPALM PROJ_VEL 1000
defineprojectile PR_NAPALM PROJ_ISOUND EXPLODCM
defineprojectile PR_NAPALM PROJ_SOUND SNGAIR2
defineprojectile PR_NAPALM PROJ_TRAIL NAPALMSMOKE
defineprojectile PR_NAPALM PROJ_TXREPEAT 24
defineprojectile PR_NAPALM PROJ_TYREPEAT 24
defineprojectile PR_NAPALM PROJ_CLIPDIST 32
defineprojectile PR_NAPALM PROJ_XREPEAT 24
defineprojectile PR_NAPALM PROJ_YREPEAT 24
defineprojectile PR_NAPALM PROJ_CSTAT 128

actor PR_NAPALM 0 FRAME1 enda

spritenoshade ALTNAPALM
defineprojectile ALTNAPALM PROJ_WORKSLIKE 6286
defineprojectile ALTNAPALM PROJ_HITRADIUS 2048
defineprojectile ALTNAPALM PROJ_SPAWNS EXPLOSION6
defineprojectile ALTNAPALM PROJ_SXREPEAT 32
defineprojectile ALTNAPALM PROJ_SYREPEAT 32
defineprojectile ALTNAPALM PROJ_VEL 512
defineprojectile ALTNAPALM PROJ_DROP -256
defineprojectile ALTNAPALM PROJ_BOUNCES 2
defineprojectile ALTNAPALM PROJ_BSOUND -1
defineprojectile ALTNAPALM PROJ_ISOUND EXPLODCM
defineprojectile ALTNAPALM PROJ_SOUND SNGAIR2
defineprojectile ALTNAPALM PROJ_CLIPDIST 32
defineprojectile ALTNAPALM PROJ_XREPEAT 32
defineprojectile ALTNAPALM PROJ_YREPEAT 32
defineprojectile ALTNAPALM PROJ_CSTAT 128

actor ALTNAPALM 0 FRAME1 enda

defineprojectile TNTBUNDLE PROJ_WORKSLIKE 6146 //6286
defineprojectile TNTBUNDLE PROJ_HITRADIUS 0
defineprojectile TNTBUNDLE PROJ_VEL 512
defineprojectile TNTBUNDLE PROJ_DROP -368
defineprojectile TNTBUNDLE PROJ_XREPEAT 32
defineprojectile TNTBUNDLE PROJ_YREPEAT 32
defineprojectile TNTBUNDLE PROJ_EXTRA 0
defineprojectile TNTBUNDLE PROJ_CSTAT 128
defineprojectile TNTBUNDLE PROJ_SPAWNS -1

defineprojectile REMOTEBUNDLE PROJ_WORKSLIKE 6146
defineprojectile REMOTEBUNDLE PROJ_HITRADIUS 0
defineprojectile REMOTEBUNDLE PROJ_VEL 512
defineprojectile REMOTEBUNDLE PROJ_DROP -368
defineprojectile REMOTEBUNDLE PROJ_XREPEAT 32
defineprojectile REMOTEBUNDLE PROJ_YREPEAT 32
defineprojectile REMOTEBUNDLE PROJ_EXTRA 0
defineprojectile REMOTEBUNDLE PROJ_SPAWNS REMOTEFLOOR

defineprojectile PROXIMITYBUNDLE PROJ_WORKSLIKE 6146
defineprojectile PROXIMITYBUNDLE PROJ_HITRADIUS 0
defineprojectile PROXIMITYBUNDLE PROJ_VEL 512
defineprojectile PROXIMITYBUNDLE PROJ_DROP -368
defineprojectile PROXIMITYBUNDLE PROJ_XREPEAT 32
defineprojectile PROXIMITYBUNDLE PROJ_YREPEAT 32
defineprojectile PROXIMITYBUNDLE PROJ_EXTRA 0
defineprojectile PROXIMITYBUNDLE PROJ_SPAWNS PROXIMITYFLOOR

spritenoshade FLAME
defineprojectile FLAME PROJ_WORKSLIKE 32770
defineprojectile FLAME PROJ_HITRADIUS 0
defineprojectile FLAME PROJ_EXTRA 0
defineprojectile FLAME PROJ_SPAWNS -1
defineprojectile FLAME PROJ_VEL 600
defineprojectile FLAME PROJ_CLIPDIST 32
defineprojectile FLAME PROJ_XREPEAT 32
defineprojectile FLAME PROJ_YREPEAT 32
defineprojectile FLAME PROJ_CSTAT 128


actor FLAME 0 FRAME_FRAME1 enda

spritenoshade FLAME2
defineprojectile FLAME2 PROJ_WORKSLIKE 32770
defineprojectile FLAME2 PROJ_HITRADIUS 0
defineprojectile FLAME2 PROJ_EXTRA 0
defineprojectile FLAME2 PROJ_VEL 600
defineprojectile FLAME2 PROJ_SPAWNS -1
defineprojectile FLAME2 PROJ_CLIPDIST 32
defineprojectile FLAME2 PROJ_XREPEAT 32
defineprojectile FLAME2 PROJ_YREPEAT 32
defineprojectile FLAME2 PROJ_CSTAT 128

actor FLAME2 0 FLAME2_FRAME1 enda

spritenoshade HELLFLAME
defineprojectile HELLFLAME PROJ_WORKSLIKE 6146 //32770
defineprojectile HELLFLAME PROJ_HITRADIUS 0
defineprojectile HELLFLAME PROJ_EXTRA 0
defineprojectile HELLFLAME PROJ_VEL 600
defineprojectile HELLFLAME PROJ_DROP 100
defineprojectile HELLFLAME PROJ_SPAWNS FIRESPAWN
defineprojectile HELLFLAME PROJ_CLIPDIST 32
defineprojectile HELLFLAME PROJ_XREPEAT 1
defineprojectile HELLFLAME PROJ_YREPEAT 1
defineprojectile HELLFLAME PROJ_CSTAT 128

actor FIRESPAWN
cstat 2 
ifaction NO { sizeat 16 16 action 1 }
ifaction 1 { sizeto 1 1 }
getactor[THISACTOR].xrepeat x
ifvare x 1 { killit }
enda

actor HELLFLAME 0 HELLFLAME_FRAME1 enda

defineprojectile SPRAYBUNDLE PROJ_WORKSLIKE 6146
defineprojectile SPRAYBUNDLE PROJ_HITRADIUS 0
defineprojectile SPRAYBUNDLE PROJ_VEL 268
defineprojectile SPRAYBUNDLE PROJ_DROP -368
defineprojectile SPRAYBUNDLE PROJ_XREPEAT 32
defineprojectile SPRAYBUNDLE PROJ_YREPEAT 32
defineprojectile SPRAYBUNDLE PROJ_EXTRA 0
defineprojectile SPRAYBUNDLE PROJ_SPAWNS -1

spritenoshade PLASMAPROJ
defineprojectile PLASMAPROJ PROJ_WORKSLIKE 32770
defineprojectile PLASMAPROJ PROJ_EXTRA 18
defineprojectile PLASMAPROJ PROJ_OFFSET 192
defineprojectile PLASMAPROJ PROJ_EXTRA_RAND 8
defineprojectile PLASMAPROJ PROJ_HITRADIUS 0
defineprojectile PLASMAPROJ PROJ_SPAWNS -1
defineprojectile PLASMAPROJ PROJ_SXREPEAT 32
defineprojectile PLASMAPROJ PROJ_SYREPEAT 32
defineprojectile PLASMAPROJ PROJ_VEL 200
defineprojectile PLASMAPROJ PROJ_VEL_MULT 6
defineprojectile PLASMAPROJ PROJ_CLIPDIST 32
defineprojectile PLASMAPROJ PROJ_XREPEAT 30
defineprojectile PLASMAPROJ PROJ_YREPEAT 30
defineprojectile PLASMAPROJ PROJ_CSTAT 130

spritenoshade ALTTESLA
defineprojectile ALTTESLA PROJ_WORKSLIKE 71682
defineprojectile ALTTESLA PROJ_HITRADIUS 6144
defineprojectile ALTTESLA PROJ_EXTRA 169
defineprojectile ALTTESLA PROJ_VEL 200
defineprojectile ALTTESLA PROJ_VEL_MULT 12
defineprojectile ALTTESLA PROJ_SPAWNS TESLADECAL
defineprojectile ALTTESLA PROJ_XREPEAT 32
defineprojectile ALTTESLA PROJ_YREPEAT 32
defineprojectile ALTTESLA PROJ_CSTAT 162

spritenoshade STAFFPROJ
defineprojectile STAFFPROJ PROJ_WORKSLIKE 32770
defineprojectile STAFFPROJ PROJ_HITRADIUS 1024
defineprojectile STAFFPROJ PROJ_VEL 200
defineprojectile STAFFPROJ PROJ_VEL_MULT 6
defineprojectile STAFFPROJ PROJ_SPAWNS EXPLOSION6
defineprojectile STAFFPROJ PROJ_ISOUND EXPLODFS
defineprojectile STAFFPROJ PROJ_SXREPEAT 32
defineprojectile STAFFPROJ PROJ_SYREPEAT 32
defineprojectile STAFFPROJ PROJ_XREPEAT 32
defineprojectile STAFFPROJ PROJ_YREPEAT 32
defineprojectile STAFFPROJ PROJ_CSTAT 130

spritenoshade STAFFALTPROJ
defineprojectile STAFFALTPROJ PROJ_WORKSLIKE 36866
defineprojectile STAFFALTPROJ PROJ_EXTRA 30 
defineprojectile STAFFALTPROJ PROJ_ISOUND EXPLODUS
defineprojectile STAFFALTPROJ PROJ_VEL 200
defineprojectile STAFFALTPROJ PROJ_VEL_MULT 6
defineprojectile STAFFALTPROJ PROJ_XREPEAT 32
defineprojectile STAFFALTPROJ PROJ_YREPEAT 32
defineprojectile STAFFALTPROJ PROJ_CSTAT 130

spritenoshade NEWSCRAP1
defineprojectile NEWSCRAP1 PROJ_WORKSLIKE 6274
defineprojectile NEWSCRAP1 PROJ_EXTRA 0
defineprojectile NEWSCRAP1 PROJ_HITRADIUS 0
defineprojectile NEWSCRAP1 PROJ_VEL 64
defineprojectile NEWSCRAP1 PROJ_SPAWNS -1
defineprojectile NEWSCRAP1 PROJ_DROP -256
defineprojectile NEWSCRAP1 PROJ_BSOUND -1
defineprojectile NEWSCRAP1 PROJ_CLIPDIST 16
defineprojectile NEWSCRAP1 PROJ_XREPEAT 18
defineprojectile NEWSCRAP1 PROJ_YREPEAT 18

actor NEWSCRAP1 0 FRAME_FRAME1 enda

spritenoshade TESLASPARK
defineprojectile TESLASPARK PROJ_WORKSLIKE 6274
defineprojectile TESLASPARK PROJ_EXTRA 0
defineprojectile TESLASPARK PROJ_HITRADIUS 0
defineprojectile TESLASPARK PROJ_VEL 64
defineprojectile TESLASPARK PROJ_SPAWNS -1
defineprojectile TESLASPARK PROJ_DROP 32
defineprojectile TESLASPARK PROJ_BSOUND -1
defineprojectile TESLASPARK PROJ_CLIPDIST 16
defineprojectile TESLASPARK PROJ_XREPEAT 18
defineprojectile TESLASPARK PROJ_YREPEAT 18

actor TESLASPARK 0 FRAME_FRAME1 enda

spritenoshade NEWFIRE
defineprojectile NEWFIRE PROJ_WORKSLIKE 4226
defineprojectile NEWFIRE PROJ_DROP 64
defineprojectile NEWFIRE PROJ_HITRADIUS 0
defineprojectile NEWFIRE PROJ_SPAWNS -1
defineprojectile NEWFIRE PROJ_EXTRA 0
defineprojectile NEWFIRE PROJ_VEL 0
defineprojectile NEWFIRE PROJ_XREPEAT 18
defineprojectile NEWFIRE PROJ_YREPEAT 18
defineprojectile NEWFIRE PROJ_CSTAT 128
defineprojectile NEWFIRE PROJ_RANGE 1152

actor NEWFIRE 0 FRAME_FRAME1 enda

spritenoshade BLOODSPRAY
defineprojectile BLOODSPRAY PROJ_WORKSLIKE 6274
defineprojectile BLOODSPRAY PROJ_HITRADIUS 0
defineprojectile BLOODSPRAY PROJ_VEL 100
defineprojectile BLOODSPRAY PROJ_DROP -256
defineprojectile BLOODSPRAY PROJ_XREPEAT 32
defineprojectile BLOODSPRAY PROJ_YREPEAT 32
defineprojectile BLOODSPRAY PROJ_TRAIL BLOODSPRAY
defineprojectile BLOODSPRAY PROJ_BSOUND -1
defineprojectile BLOODSPRAY PROJ_SPAWNS BLOODDROP

defineprojectile ZOMBIEHEAD PROJ_WORKSLIKE 6150
defineprojectile ZOMBIEHEAD PROJ_HITRADIUS 0
defineprojectile ZOMBIEHEAD PROJ_BOUNCES 5
defineprojectile ZOMBIEHEAD PROJ_VEL 300
defineprojectile ZOMBIEHEAD PROJ_DROP -120
defineprojectile ZOMBIEHEAD PROJ_BSOUND BODYHIT1
defineprojectile ZOMBIEHEAD PROJ_XREPEAT 24
defineprojectile ZOMBIEHEAD PROJ_YREPEAT 24
defineprojectile ZOMBIEHEAD PROJ_EXTRA 0
defineprojectile ZOMBIEHEAD PROJ_SPAWNS -1
defineprojectile ZOMBIEHEAD PROJ_SXREPEAT 24
defineprojectile ZOMBIEHEAD PROJ_SYREPEAT 24

defineprojectile GARGHEAD PROJ_WORKSLIKE 6278
defineprojectile GARGHEAD PROJ_EXTRA 0
defineprojectile GARGHEAD PROJ_BOUNCES 1
defineprojectile GARGHEAD PROJ_HITRADIUS 0
defineprojectile GARGHEAD PROJ_VEL 64
defineprojectile GARGHEAD PROJ_SPAWNS GARGHEAD
defineprojectile GARGHEAD PROJ_DROP -128
defineprojectile GARGHEAD PROJ_BSOUND -1
defineprojectile GARGHEAD PROJ_CLIPDIST 16
defineprojectile GARGHEAD PROJ_XREPEAT 30
defineprojectile GARGHEAD PROJ_YREPEAT 30

defineprojectile GARGWING PROJ_WORKSLIKE 6278
defineprojectile GARGWING PROJ_EXTRA 0
defineprojectile GARGWING PROJ_BOUNCES 1
defineprojectile GARGWING PROJ_HITRADIUS 0
defineprojectile GARGWING PROJ_VEL 64
defineprojectile GARGWING PROJ_SPAWNS GARGWINGFLOOR
defineprojectile GARGWING PROJ_DROP -128
defineprojectile GARGWING PROJ_BSOUND -1
defineprojectile GARGWING PROJ_CLIPDIST 16
defineprojectile GARGWING PROJ_XREPEAT 30
defineprojectile GARGWING PROJ_YREPEAT 30

action ABAXESPAWN 0 3 1 1 15
actor BUCHERAXESPAWN 0 ABAXESPAWN
sizeat 32 32 cstat 130
ifactioncount 3 killit
enda

action AXEFRAME1 0 1 1 1 1
action AXEFRAME2 8 1 1 1 1

actor BUCHERAXE 0 AXEFRAME1 sizeat  18 18 enda

defineprojectile BUCHERAXE PROJ_WORKSLIKE 32770
defineprojectile BUCHERAXE PROJ_HITRADIUS 0
defineprojectile BUCHERAXE PROJ_EXTRA 0
defineprojectile BUCHERAXE PROJ_SPAWNS BUCHERAXESPAWN
defineprojectile BUCHERAXE PROJ_VEL 300 
defineprojectile BUCHERAXE PROJ_CLIPDIST 32
defineprojectile BUCHERAXE PROJ_TRAIL BUCHERAXE
defineprojectile BUCHERAXE PROJ_XREPEAT 18
defineprojectile BUCHERAXE PROJ_YREPEAT 18
defineprojectile BUCHERAXE PROJ_CSTAT 128

actor BUCHERSLIME 0 FRAME1 enda

defineprojectile BUCHERSLIME PROJ_WORKSLIKE 32770
defineprojectile BUCHERSLIME PROJ_HITRADIUS 0
defineprojectile BUCHERSLIME PROJ_EXTRA 0
defineprojectile BUCHERSLIME PROJ_SPAWNS -1
defineprojectile BUCHERSLIME PROJ_VEL 300 
defineprojectile BUCHERSLIME PROJ_CLIPDIST 32
defineprojectile BUCHERSLIME PROJ_XREPEAT 18
defineprojectile BUCHERSLIME PROJ_YREPEAT 18
defineprojectile BUCHERSLIME PROJ_CSTAT 128

actor PHANTOMSKULL 0 FRAME1 sizeat 40 40 enda

defineprojectile PHANTOMSKULL PROJ_WORKSLIKE 32770
defineprojectile PHANTOMSKULL PROJ_HITRADIUS 0
defineprojectile PHANTOMSKULL PROJ_EXTRA 0
defineprojectile PHANTOMSKULL PROJ_SPAWNS BUCHERAXESPAWN
defineprojectile PHANTOMSKULL PROJ_VEL 300 
defineprojectile PHANTOMSKULL PROJ_CLIPDIST 40
defineprojectile PHANTOMSKULL PROJ_XREPEAT 40
defineprojectile PHANTOMSKULL PROJ_YREPEAT 40
defineprojectile PHANTOMSKULL PROJ_CSTAT 130

defineprojectile JIBS7 PROJ_WORKSLIKE 6278
defineprojectile JIBS7 PROJ_EXTRA 0
defineprojectile JIBS7 PROJ_BOUNCES 2
defineprojectile JIBS7 PROJ_HITRADIUS 0
defineprojectile JIBS7 PROJ_VEL 64
defineprojectile JIBS7 PROJ_SPAWNS JIBS7FLOOR
defineprojectile JIBS7 PROJ_DROP -128
defineprojectile JIBS7 PROJ_BSOUND -1
defineprojectile JIBS7 PROJ_CLIPDIST 16
defineprojectile JIBS7 PROJ_XREPEAT 18
defineprojectile JIBS7 PROJ_YREPEAT 18

defineprojectile JIBS8 PROJ_WORKSLIKE 6278
defineprojectile JIBS8 PROJ_EXTRA 0
defineprojectile JIBS8 PROJ_HITRADIUS 0
defineprojectile JIBS8 PROJ_BOUNCES 2
defineprojectile JIBS8 PROJ_VEL 64
defineprojectile JIBS8 PROJ_SPAWNS JIBS8FLOOR
defineprojectile JIBS8 PROJ_DROP -128
defineprojectile JIBS8 PROJ_BSOUND -1
defineprojectile JIBS8 PROJ_CLIPDIST 16
defineprojectile JIBS8 PROJ_XREPEAT 18
defineprojectile JIBS8 PROJ_YREPEAT 18

defineprojectile JIBS9 PROJ_WORKSLIKE 6278
defineprojectile JIBS9 PROJ_EXTRA 0
defineprojectile JIBS9 PROJ_HITRADIUS 0
defineprojectile JIBS9 PROJ_BOUNCES 2
defineprojectile JIBS9 PROJ_VEL 64
defineprojectile JIBS9 PROJ_SPAWNS JIBS9FLOOR
defineprojectile JIBS9 PROJ_DROP -128
defineprojectile JIBS9 PROJ_BSOUND -1
defineprojectile JIBS9 PROJ_CLIPDIST 16
defineprojectile JIBS9 PROJ_XREPEAT 18
defineprojectile JIBS9 PROJ_YREPEAT 18

defineprojectile JIBS10 PROJ_WORKSLIKE 6278
defineprojectile JIBS10 PROJ_EXTRA 0
defineprojectile JIBS10 PROJ_HITRADIUS 0
defineprojectile JIBS10 PROJ_BOUNCES 2
defineprojectile JIBS10 PROJ_VEL 64
defineprojectile JIBS10 PROJ_SPAWNS JIBS10
defineprojectile JIBS10 PROJ_DROP -128
defineprojectile JIBS10 PROJ_BSOUND FLSHDOR2
defineprojectile JIBS10 PROJ_CLIPDIST 16
defineprojectile JIBS10 PROJ_XREPEAT 18
defineprojectile JIBS10 PROJ_YREPEAT 18

defineprojectile JIBS11 PROJ_WORKSLIKE 6278
defineprojectile JIBS11 PROJ_EXTRA 0
defineprojectile JIBS11 PROJ_HITRADIUS 0
defineprojectile JIBS11 PROJ_BOUNCES 2
defineprojectile JIBS11 PROJ_VEL 64
defineprojectile JIBS11 PROJ_SPAWNS JIBS11
defineprojectile JIBS11 PROJ_DROP -128
defineprojectile JIBS11 PROJ_BSOUND FLSHDOR1
defineprojectile JIBS11 PROJ_CLIPDIST 16
defineprojectile JIBS11 PROJ_XREPEAT 18
defineprojectile JIBS11 PROJ_YREPEAT 18

defineprojectile JIBS12 PROJ_WORKSLIKE 6278
defineprojectile JIBS12 PROJ_EXTRA 0
defineprojectile JIBS12 PROJ_HITRADIUS 0
defineprojectile JIBS12 PROJ_BOUNCES 2
defineprojectile JIBS12 PROJ_VEL 64
defineprojectile JIBS12 PROJ_SPAWNS -1
defineprojectile JIBS12 PROJ_DROP -128
defineprojectile JIBS12 PROJ_BSOUND -1
defineprojectile JIBS12 PROJ_CLIPDIST 16
defineprojectile JIBS12 PROJ_XREPEAT 18
defineprojectile JIBS12 PROJ_YREPEAT 18

defineprojectile GREENLEAF PROJ_WORKSLIKE 6274
defineprojectile GREENLEAF PROJ_HITRADIUS 0
defineprojectile GREENLEAF PROJ_VEL 64
defineprojectile GREENLEAF PROJ_DROP -256
defineprojectile GREENLEAF PROJ_BSOUND -1
defineprojectile GREENLEAF PROJ_XREPEAT 32
defineprojectile GREENLEAF PROJ_YREPEAT 32
defineprojectile GREENLEAF PROJ_SPAWNS GREENLEAFFLOOR

defineprojectile YELLOWLEAF PROJ_WORKSLIKE 6274
defineprojectile YELLOWLEAF PROJ_HITRADIUS 0
defineprojectile YELLOWLEAF PROJ_VEL 64
defineprojectile YELLOWLEAF PROJ_DROP -256
defineprojectile YELLOWLEAF PROJ_BSOUND -1
defineprojectile YELLOWLEAF PROJ_XREPEAT 32
defineprojectile YELLOWLEAF PROJ_YREPEAT 32
defineprojectile YELLOWLEAF PROJ_SPAWNS YELLOWLEAFFLOOR

defineprojectile ENEMYTNTBUNDLE PROJ_WORKSLIKE 6146
defineprojectile ENEMYTNTBUNDLE PROJ_HITRADIUS 0
defineprojectile ENEMYTNTBUNDLE PROJ_VEL 512
defineprojectile ENEMYTNTBUNDLE PROJ_DROP -512
defineprojectile ENEMYTNTBUNDLE PROJ_XREPEAT 32
defineprojectile ENEMYTNTBUNDLE PROJ_YREPEAT 32
defineprojectile ENEMYTNTBUNDLE PROJ_EXTRA 0
defineprojectile ENEMYTNTBUNDLE PROJ_CSTAT 128
defineprojectile ENEMYTNTBUNDLE PROJ_SPAWNS ENEMYTNTFLOOR

move RESPAWN_ACTOR_FLAG
move PSTOPED

state checkb_armor
ifvare reflmode 0
ifvare godmode 0
ifvare DEATHMASK_ON 0
ifvarg paextra 0
ifvarg HEALTHAMOUNT 0
{
	getactorvar[PLAYERID].bodyshield BODYSHIELD_AMOUNT
	ifvarg BODYSHIELD_AMOUNT 0
	{
		divvar paextra 2
		ifvarvarg BODYSHIELD_AMOUNT paextra
		{
			subvarvar BODYSHIELD_AMOUNT paextra
			addvarvar HEALTHAMOUNT paextra
			setactor[PLAYERID].extra HEALTHAMOUNT
			setactorvar[PLAYERID].bodyshield BODYSHIELD_AMOUNT
		}
		else
		{
			subvarvar BODYSHIELD_AMOUNT paextra	
			addvarvar HEALTHAMOUNT paextra
			addvarvar HEALTHAMOUNT BODYSHIELD_AMOUNT
			setactorvar[PLAYERID].bodyshield 0
		}
	}
}
ends

state checkf_armor
ifvare reflmode 0
ifvare godmode 0
ifvare DEATHMASK_ON 0
ifvarg paextra 0
ifvarg HEALTHAMOUNT 0
{
	getactorvar[PLAYERID].fireshield FIRESHIELD_AMOUNT
	ifvarg FIRESHIELD_AMOUNT 0
	{
		divvar paextra 2
		ifvarvarg FIRESHIELD_AMOUNT paextra
		{
			 subvarvar FIRESHIELD_AMOUNT paextra
			 addvarvar HEALTHAMOUNT paextra
			 setactor[PLAYERID].extra HEALTHAMOUNT
			 setactorvar[PLAYERID].fireshield FIRESHIELD_AMOUNT
		}
		else
		{
			subvarvar FIRESHIELD_AMOUNT paextra	
			addvarvar HEALTHAMOUNT paextra
			addvarvar HEALTHAMOUNT FIRESHIELD_AMOUNT
			setactorvar[PLAYERID].fireshield 0
		}
	}
}
ends

state checks_armor
ifvare reflmode 0
ifvare godmode 0
ifvare DEATHMASK_ON 0
ifvarg paextra 0
ifvarg HEALTHAMOUNT 0
{
	getactorvar[PLAYERID].spiritshield SPIRITSHIELD_AMOUNT
	ifvarg SPIRITSHIELD_AMOUNT  0
	{
		divvar paextra 2
		ifvarvarg SPIRITSHIELD_AMOUNT paextra
		{
			 subvarvar SPIRITSHIELD_AMOUNT paextra
			 addvarvar HEALTHAMOUNT paextra
			 setactor[PLAYERID].extra HEALTHAMOUNT
			 setactorvar[PLAYERID].spiritshield SPIRITSHIELD_AMOUNT
		} 
		else
		{
			subvarvar SPIRITSHIELD_AMOUNT paextra	
			addvarvar HEALTHAMOUNT paextra
			addvarvar HEALTHAMOUNT SPIRITSHIELD_AMOUNT
			setactorvar[PLAYERID].spiritshield 0
		}
	}
}
ends

state spawnlight
	setactorvar[RETURN].fire_id THISACTOR
	setactorvar[RETURN].movelightse 1
	setactor[RETURN].lotag 49 
	setactor[RETURN].hitag light_radius 
	setactor[RETURN].shade 0
	setactor[RETURN].xvel red 
	setactor[RETURN].yvel green
	setactor[RETURN].zvel blue
	setactor[RETURN].picnum SECTOREFFECTOR
	changespritestat RETURN 3
ends

state teslasparkstate

	ezshootvar zdist TESLASPARK
	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
	ifrnd 128 setprojectile[TESLASPARK].drop -256 else setprojectile[TESLASPARK].drop 32
	
ends

state altteslasparkstate

	randvar zdist 256
	ifrnd 128 mulvar zdist -1
	subvar zdist 256
	ezshootvar zdist TESLASPARK
	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
	setprojectile[TESLASPARK].drop -64
	setprojectile[TESLASPARK].vel 192
	
ends

state sparkstate

	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	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

state random_param

	getprojectile[JIBS7].vel tmp
	randvar tmp2 32
	addvarvar tmp tmp2
	setprojectile[JIBS7].vel tmp
	getprojectile[JIBS8].vel tmp
	randvar tmp2 32
	addvarvar tmp tmp2
	setprojectile[JIBS8].vel tmp
	getprojectile[JIBS9].vel tmp
	randvar tmp2 32
	addvarvar tmp tmp2
	setprojectile[JIBS9].vel tmp
	getprojectile[JIBS10].vel tmp
	randvar tmp2 32
	addvarvar tmp tmp2
	setprojectile[JIBS10].vel tmp
	getprojectile[JIBS11].vel tmp
	randvar tmp2 32
	addvarvar tmp tmp2
	setprojectile[JIBS11].vel tmp
	getprojectile[JIBS12].vel tmp
	randvar tmp2 32
	addvarvar tmp tmp2
	setprojectile[JIBS12].vel tmp
	getactor[RETURN].ang ang
	randvar tmp 2048
	ifrnd 128 mulvar tmp -1
	addvarvar ang tmp
	setactor[RETURN].ang ang
	
	getactor[THISACTOR].x x
	getactor[THISACTOR].y y
	getactor[THISACTOR].xrepeat xrepeat
	getactor[THISACTOR].yrepeat yrepeat
	setvarvar x2 x
	mulvar xrepeat 2
	addvarvar x2 xrepeat
	randvar ang 2048
	ifrnd 128 mulvar ang -1
	rotatepoint x y x2 y ang x3 y3
	setactor[RETURN].x x3
	setactor[RETURN].y y3
	getactor[RETURN].z z
	randvar tmp3 4092
	addvarvar z tmp3
	setactor[RETURN].z z
	
ends

state bloodspraystate

	randvar zdist 4096
	ifrnd 128 mulvar zdist -1
	subvar zdist 4096
	ezshootvar zdist BLOODSPRAY
	getactor[RETURN].ang ang
	randvar tmp 2048
	ifrnd 128 mulvar tmp -1
	addvarvar ang tmp
	setactor[RETURN].ang ang
	
	getactor[THISACTOR].x x
	getactor[THISACTOR].y y
	getactor[THISACTOR].xrepeat xrepeat
	getactor[THISACTOR].yrepeat yrepeat
	setvarvar x2 x
	mulvar xrepeat 2
	addvarvar x2 xrepeat
	randvar ang 2048
	ifrnd 128 mulvar ang -1
	rotatepoint x y x2 y ang x3 y3
	setactor[RETURN].x x3
	setactor[RETURN].y y3
	getactor[RETURN].z z
	randvar tmp3 4092
	addvarvar z tmp3
	setactor[RETURN].z z
	
ends

state jibs_state

	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS7
	state random_param
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS8
	state random_param
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS9
	state random_param
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS9
	state random_param
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS9
	state random_param
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS9
	state random_param
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS9
	state random_param
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS9
	state random_param
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS10
	state random_param
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS10
	state random_param
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS11
	state random_param
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS11
	state random_param
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS12
	state random_param
	ifrnd 6
	{
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS9
	state random_param
	randvar zdist 2048
	ifrnd 128 mulvar zdist -1
	subvar zdist 1024
	ezshootvar zdist JIBS9
	state random_param
    spawn BLOODPOOL2
	}
	ifrnd 64 { sound FLSHDOR1 }
	ifrnd 64 { sound FLSHDOR2 }
	ifrnd 127 { sound FLSHSTP1 sound FLSHSTP2 }
	state bloodspraystate
	state bloodspraystate

ends

state bloodsprayshit
	state bloodspraystate
	state bloodspraystate
	state bloodspraystate
ends

state randomleafstate

	randvar zdist 1024
	ifrnd 128 mulvar zdist -1
	subvar zdist 4096
	ifrnd 128 ezshootvar zdist GREENLEAF else ezshootvar zdist YELLOWLEAF
	state random_param

ends

state leafs_state
	state randomleafstate
	state randomleafstate
	state randomleafstate
	state randomleafstate
	state randomleafstate
	state randomleafstate
	state randomleafstate
ends

state newfirestate
ifinwater { setactorvar[THISACTOR].burningguyactive 0 setactorvar[THISACTOR].flamedamage 0 }
else
{
	eshoot NEWFIRE
	getactor[THISACTOR].x x
	getactor[THISACTOR].y y
	getactor[THISACTOR].xrepeat xrepeat
	getactor[THISACTOR].yrepeat yrepeat
	setvarvar x2 x
	mulvar xrepeat 2
	addvarvar x2 xrepeat
	randvar ang 2048
	ifrnd 128 mulvar ang -1
	rotatepoint x y x2 y ang x3 y3
	setactor[RETURN].x x3
	setactor[RETURN].y y3
	
	getactor[RETURN].z z
	divvar yrepeat 2
	mulvar yrepeat 256
	addvarvar z yrepeat
	randvar tmp 2048
	ifrnd 128 mulvar tmp -1
	addvarvar z tmp
	setactor[RETURN].z z

	getactor[THISACTOR].extra extra
	ifvarg extra 0
	{
		getactorvar[THISACTOR].fireshield FIRESHIELD_AMOUNT
		ifvare FIRESHIELD_AMOUNT 0 { subvar extra 1 } else
		{ ifcount 2 { subvar extra 1 subvar FIRESHIELD_AMOUNT 1 setactorvar[THISACTOR].fireshield FIRESHIELD_AMOUNT resetcount } }
		ifvarl extra 1 { setvar extra 1 setactorvar[THISACTOR].burningguyactive 1 setactorvar[THISACTOR].flamedamage 0 }
		setactor[THISACTOR].extra extra
	}
}
ends

state check_pstandard
  ifp pwalking
    action PWALK
  else
    ifp pkicking
      action PAKICKING
  else
    ifp pwalkingback
      action PWALKBACK
  else
    ifp prunning
      action PRUN
  else
    ifp prunningback
      action PRUNBACK
  else
    ifp pjumping
      action PJUMPING
  else
    ifp pducking
      action PDUCKING
ends

state random_ooz
  ifrnd 128
    spawn OOZ2
  else
    spawn OOZ
ends

state standard_pjibs
  guts JIBS1 1
  guts JIBS3 2
  guts JIBS4 1
  guts JIBS5 1
  guts JIBS6 2
  guts DUKETORSO 1
  guts DUKELEG 2
  guts DUKEGUN 1
  ifrnd 16 money 1
ends

state random_wall_jibs
  ifrnd 96
    shoot BLOODSPLAT1
  ifrnd 96
    shoot BLOODSPLAT2
  ifrnd 96
    shoot BLOODSPLAT3
  ifrnd 96
    shoot BLOODSPLAT4
  ifrnd 96
    shoot BLOODSPLAT1
ends

state randgetweapsnds
  ifrnd 64
    globalsound DUKE_GETWEAPON1
  else
    ifrnd 96
      globalsound DUKE_GETWEAPON2
  else
    ifrnd 128
      globalsound DUKE_GETWEAPON3
  else
    ifrnd 140
      globalsound DUKE_GETWEAPON4
  else
    globalsound DUKE_GETWEAPON6
ends

state quikweaponget
  state randgetweapsnds
  palfrom 32 0 32
  ifgotweaponce 1
    break
  killit
ends

state getweaponcode

  state randgetweapsnds

  palfrom 32 0 32
  ifgotweaponce 1
    break
  ifrespawn
  {
    move RESPAWN_ACTOR_FLAG
    spawn RESPAWNMARKERRED
    cstat 32768
  }
  else
    killit
ends

state respawnit
  ifcount RESPAWNITEMTIME
  {
    spawn TRANSPORTERSTAR
    move 0
    cstat 0
    sound TELEPORTER
  }
ends

state getcode
  ifactor ATOMICHEALTH
    globalsound GETATOMICHEALTH
  else
    globalsound DUKE_GET
  palfrom 16 0 32
  ifrespawn
  {
    move RESPAWN_ACTOR_FLAG
    spawn RESPAWNMARKERRED
    cstat 32768
  }
  else
    killit
ends

state quikget
  ifactor ATOMICHEALTH
    globalsound GETATOMICHEALTH
  else
    globalsound DUKE_GET
  palfrom 16 0 32
  killit
ends

actor WATERBUBBLEMAKER 0 0 randomangle
  ifpdistl 3084
    ifrnd 24
      spawn WATERBUBBLE
enda

action BUBBLE
action CRACKEDBUBBLE  1
move BUBMOVE       -10 -36
move BUBMOVEFAST     -10 -52

actor WATERBUBBLE 0 BUBBLE BUBMOVE getv geth randomangle

  ifaction CRACKEDBUBBLE
  {
    ifinwater
      ifrnd 192
        killit
    ifactioncount 7
      killit
  }
  else
  {
    ifcount 4
    {
      ifrnd 192
        move BUBMOVE getv geth randomangle
      else
        move BUBMOVEFAST getv geth randomangle
      resetcount

      ifrnd 84
        sizeat 8 10
      else
        ifrnd 84
          sizeat 10 8
      else
        sizeat 9 9
    }

    ifonwater
    {
      iffloordistl 8
        action CRACKEDBUBBLE
    }
    else
      ifactioncount 40
        action CRACKEDBUBBLE
  }
enda

move SMOKEVEL 8 -16
move ENGINE_SMOKE 64 -64
move SMOKESHOOTOUT -192
action SMOKEFRAMES 0 4 1 1 10
actor SMALLSMOKE 0 SMOKEFRAMES
  ifmove 0
  {
    ifspawnedby RECON
      move SMOKESHOOTOUT geth
    else
      ifspawnedby SECTOREFFECTOR
        move ENGINE_SMOKE geth getv
    else
      move SMOKEVEL geth getv faceplayer
    ifspawnedby RPG
      cstat 2
  }
  ifpdistl 1596
    ifspawnedby RPG
      killit
  ifactioncount 4
    killit
enda

action WEAP2FRAMES 0  4  1  1  6
actor SHOTSPARK1 PISTOL_WEAPON_STRENGTH WEAP2FRAMES
  ifdead
    killit
  ifactioncount 4
    killit
  else
  {
    ifactioncount 3
    {
      ifinwater
      spawn WATERBUBBLE
    }
    else
      ifcount 2 nullop
      else
        ifonwater
          spawn WATERSPLASH2
  }
enda



include BloodTC/blcons/hud.con
include BloodTC/blcons/cheats.con
include BloodTC/blcons/weapons.con
include BloodTC/blcons/sprites.con
include BloodTC/blcons/enemies.con


// New armors system

onevent EVENT_INCURDAMAGE

	getplayer[THISACTOR].i PLAYERID
	getactor[PLAYERID].extra HEALTHAMOUNT
	getactorvar[PLAYERID].reflective reflmode
	getuserdef[PLAYERID].god godmode

	ifactor APLAYER
	{
		ifwasweapon KNEE { state checkb_armor } else
		ifwasweapon SHOTSPARK1 { state checkb_armor } else
		ifwasweapon RADIUSEXPLOSION { state checkf_armor } else
		ifwasweapon BUCHERSLIME { state checks_armor }
	}

	ifvare player[THISACTOR].extra_extra8 256 //inwater damage
	ifvare player[THISACTOR].airleft 0
	{
		subvar HEALTHAMOUNT 1 
		setactor[PLAYERID].extra HEALTHAMOUNT  
		setplayer[THISACTOR].extra_extra8 0
	}

	setvar RETURN -1
	
endevent

// Process input

onevent EVENT_PROCESSINPUT
getinput[THISACTOR].bits num
ifvarand num 1073741824
{
	getplayer[THISACTOR].inven_icon tmp
	ifvare tmp 11
	{
		ifvarg BEASTVISIONAM 0
		ifcount 13
		{ ifvare BEASTVON 0 { sound POWERUP setvar BEASTVON 1 } else { setvar BEASTVON 0 } resetcount } 
	}
	ifvare tmp 9
	{
		ifinwater
		ifvarg DIVINGSUITAM 0
		ifcount 13
		{ ifvare DIVINGSUITON 0 { sound POWERUP setvar DIVINGSUITON 1 } else { setvar DIVINGSUITON 0 } resetcount } 
	}
	ifvare tmp 8
	{
		ifvarg DOCTORSBAGAM 0
		ifcount 13 { setvar DOCTORSBAGON 1 resetcount } 
	}
	ifvare tmp 12
	{
		ifvarg BOOTSOFJUMPINGAM 0
		ifcount 13
		{ ifvare JBOOTSON 0 { sound POWERUP setvar JBOOTSON 1 } else { setvar JBOOTSON 0 } resetcount } 
	}
	ifvare tmp 10
	{
		ifvarg CRYSTALLBALLAM 0
		ifcount 13
		{ ifvare CRBALLON 0 { sound POWERUP setvar CRBALLON 1 } else { setvar CRBALLON 0 } resetcount } 
	}
}
getplayer[THISACTOR].inven_icon tmp
ifvare tmp 1 { setplayer[THISACTOR].inven_icon 8 }

	state weapon_processinput

endevent

onevent EVENT_DISPLAYROOMS
ifactor APLAYER
{
	setvarvar camera_x camerax
	setvarvar camera_y cameray
	setvarvar camera_z cameraz
	
	ifvarg DRUNKCOUNT 0
	{
		cos crd hz1
		mulvarvar crd DRUNKCOUNT
		shiftvarr crd 13
		addvarvar cameraang crd
		sin crd hz2
		shiftvarr crd 9
		addvarvar camerahoriz crd
	} 
}

ifp pducking 
{ 
	ifvare TIMECOUNT 1	{ addvar cameraz 200 }
	ifvare TIMECOUNT 2	{ addvar cameraz 400 }
	ifvare TIMECOUNT 3	{ addvar cameraz 600 }
	ifvare TIMECOUNT 4	{ addvar cameraz 800 }
	ifvare TIMECOUNT 5	{ addvar cameraz 850 }
	ifvare TIMECOUNT 6	{ addvar cameraz 900 }
	ifvare TIMECOUNT 7	{ addvar cameraz 950 }
	ifvare TIMECOUNT 8	{ addvar cameraz 1000 }
	ifvare TIMECOUNT 9	{ addvar cameraz 900 }
	ifvare TIMECOUNT 10	{ addvar cameraz 700 }
	ifvare TIMECOUNT 11	{ addvar cameraz 500 }
	ifvare TIMECOUNT 12	{ addvar cameraz 300 }
	ifvare TIMECOUNT 13	{ addvar cameraz 250 }
	ifvare TIMECOUNT 14	{ addvar cameraz 200 }
	ifvare TIMECOUNT 15	{ addvar cameraz 150 }
	ifvare TIMECOUNT 16	{ addvar cameraz 100 }
	ifvare TIMECOUNT 17	{ addvar cameraz 50 }
} else setvar TIMECOUNT 0
ifvare fataldead 1 
{ 
	addvar cameraz 6144
}
endevent

// Main code

state checkhitscan
	getplayer[THISACTOR].posx px
	getplayer[THISACTOR].posy py
	getplayer[THISACTOR].posz pz
	getplayer[THISACTOR].cursectnum psector
	getplayer[THISACTOR].ang pang
	getplayer[THISACTOR].horiz phoriz
	subvar phoriz 100
	mulvar phoriz -2048
	cos mycos pang
	sin mysin pang
	hitscan px py pz psector mycos mysin phoriz HITSECTOR HITWALL HITSPRITE HITX HITY HITZ 1
ends

onevent EVENT_GAME
ifactor APLAYER
{
	state checkhitscan
	setvar spriteid 0
	setvar minimum 16777216 //Thanks to The Lizing for this code
	whilevarn spriteid 16384
	{
		getactor[spriteid].picnum picnum
		switch picnum
		case LOCKER
			ldist EDIST spriteid PLAYERID
			ifvarvarl EDIST minimum { setvarvar minimum EDIST }
		break
		endswitch
		addvar spriteid 1
	}

	/*
	 getplayer[THISACTOR].posx x
	 getplayer[THISACTOR].posy y
	 getplayer[THISACTOR].posz z
	 ifvare godmode 0
     ifvarg k_damage 0 
     {
          addvar COUNTER1 1
          getactor[THISACTOR].htang r0
          setvarvar temp k_damage
          cos x r0
          sin y r0
          divvar temp 2
		  ifvarl temp 0 setvar temp 0 else
          subvarvar temp COUNTER1  		  
          mulvarvar x temp                
          mulvarvar y temp
          shiftvarr x 8
          shiftvarr y 8
          setvar z 0
          movesprite THISACTOR x y z CLIPMASK0 RETURN
          ifvare temp 0 { setvar COUNTER1 0 setvar k_damage 0 }
     }
	*/
}
ifactor LOCKER
{
	getplayer[THISACTOR].i PLAYERID
	ldist EDIST THISACTOR PLAYERID
	ifvarvare EDIST minimum { setactor[THISACTOR].pal 1 } else { setactor[THISACTOR].pal 0 }
}

state weapon_game


ifactor SECTOREFFECTOR // Light of particles in polymer
{
	getactorvar[THISACTOR].movelightse peractor
	ifvare peractor 1
	{
		getactor[THISACTOR].lotag lotag
		ifvare lotag 49
		{
			getactorvar[THISACTOR].fire_id tmp
			getactorvar[tmp].active tmp2
			ifvare tmp2 1
			{
			getactor[tmp].x x
			getactor[tmp].y y
			getactor[tmp].z z
			getactor[tmp].sectnum sectnum
			
			setactor[THISACTOR].x x
			setactor[THISACTOR].y y
			ifspawnedby BURNINGGUY { subvar z 6144 }
			ifspawnedby BURNINGGUYDEAD { subvar z 1024 }
			ifspawnedby PROXIMITYFLOOR 
			{ 
				subvar z 128
				addvar COUNTER 128
				sin light_radius COUNTER
				divvar light_radius 12
				setactor[THISACTOR].hitag light_radius 
			}
			ifspawnedby REMOTEFLOOR
			{
				subvar z 128
				addvar COUNTER 128
				sin light_radius COUNTER
				divvar light_radius 12
				setactor[THISACTOR].hitag light_radius 
			}
			ifspawnedby EXPLOSION5
			{
				subvar z 128
				getactor[THISACTOR].hitag light_radius 
				subvar light_radius 96
				setactor[THISACTOR].hitag light_radius 
			}
			ifspawnedby EXPLOSION6
			{
				subvar z 128
				getactor[THISACTOR].hitag light_radius 
				subvar light_radius 128
				setactor[THISACTOR].hitag light_radius 
			}

			setactor[THISACTOR].z z
			setactor[THISACTOR].sectnum sectnum
			} else killit
		}
	}
}

ifactor BUCHERAXE
{
	getplayer[THISACTOR].i PLAYERID
	getactor[THISACTOR].ang ang
	getactor[PLAYERID].ang pang
	getincangle pang pang ang
	ifvarl pang 0 mulvar pang -1
	ifvarg pang 384 ifvarl pang 896 { action AXEFRAME1 } else { action AXEFRAME2 }
	ifcount 2 { cstat 2 } ifcount 4 { cstat 514 } ifcount 5 killit
}
ifactor FLARE
{
	getactorvar[THISACTOR].flarealtproj tmp
	ifvare tmp 1
	{
		addvar COUNTER 1
		ifvare COUNTER 8
		{	
			setprojectile[FLARE].spawns EXPLOSION6
			setprojectile[FLARE].sxrepeat 32
			setprojectile[FLARE].syrepeat 32
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			getactor[THISACTOR].ang ang
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar zvel -115
			addvar ang 10
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			setactor[RETURN].ang ang
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			getactor[THISACTOR].ang ang
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar zvel -115
			addvar ang -10
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			setactor[RETURN].ang ang
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			getactor[THISACTOR].ang ang
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar zvel 115
			addvar ang 10
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			setactor[RETURN].ang ang
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			getactor[THISACTOR].ang ang
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar zvel 115
			addvar ang -10
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			setactor[RETURN].ang ang
			

			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar zvel -300
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar zvel 300
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			getactor[THISACTOR].ang ang
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar ang -30
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			setactor[RETURN].ang ang
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			getactor[THISACTOR].ang ang
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar ang 30
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			setactor[RETURN].ang ang
			
			killit
			setprojectile[FLARE].spawns FLAREFIRE
			setprojectile[FLARE].sxrepeat -1
			setprojectile[FLARE].syrepeat -1
			
			setactorvar[THISACTOR].flarealtproj 0
		}
	}
	setactorvar[THISACTOR].active 1
	ifaction 0
	{
		espawn SMALLSMOKE
		setvar light_radius 1024
		setvar red 208
		setvar green 38
		setvar blue 38
		state spawnlight
		action ACTIVE
	}
}
ifactor PLASMAPROJ
{

ifpdistl 1152 { setactor[THISACTOR].xrepeat 0 setactor[THISACTOR].yrepeat 0 } else { setactor[THISACTOR].xrepeat 32 setactor[THISACTOR].yrepeat 32 }

	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 1024
		setvar red 0
		setvar green 64
		setvar blue 255
		state spawnlight
		setvar peractor 1
	}
}

ifactor TNTFLOOR { addvar detonatecount 1 }
ifactor SPRAYFLOOR { addvar detonatecount 1 }
ifactor EXPLOSION4
{
	findnearactor ZOMBIERISE 2048 spriteid
	ifvarn spriteid -1 { setactorvar[spriteid].flamedamage 25 } else

	ifspawnedby TNTFLOOR nullop else
	{
		findnearactor ZOMBIE 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor HERETIC 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor EVILHAND 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor FATRAT 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BATSLEEP 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BAT 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor GARGOYLE 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BUTCHER 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor GILLBEAST 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor HELLDOG 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS1 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS2 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS3 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS4 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearsprite APLAYER 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[THISACTOR].flamedamage 25 }
	}
}
ifactor EXPLOSION3
{
	findnearactor ZOMBIERISE 2048 spriteid
	ifvarn spriteid -1 { setactorvar[spriteid].flamedamage 25 } else

	ifspawnedby TNTFLOOR nullop else
	{
		findnearactor ZOMBIE 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor HERETIC 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor EVILHAND 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor FATRAT 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BATSLEEP 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BAT 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor GARGOYLE 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BUTCHER 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor GILLBEAST 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor HELLDOG 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS1 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS2 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS3 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS4 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearsprite 2 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[THISACTOR].flamedamage 25 }
	}
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 3072
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}
ifactor EXPLOSION6
{
	findnearactor ZOMBIERISE 2048 spriteid
	ifvarn spriteid -1 { setactorvar[spriteid].flamedamage 25 } else

	ifspawnedby TNTFLOOR nullop else
	{
		ifspawnedby PR_NAPALM setvar DIST 2304 else setvar DIST 1024
		findnearactorvar ZOMBIE DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar HERETIC DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar EVILHAND DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar FATRAT DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar BATSLEEP DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar BAT DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar GARGOYLE DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar BUTCHER DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar GILLBEAST DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar HELLDOG DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar BOSS1 DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar BOSS2 DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar BOSS3 DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar BOSS4 DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearspritevar APLAYER DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
	}
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 3072
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}

ifactor PR_NAPALM
{
	addvar COUNTER 1
	ifvare COUNTER 3
	{
		setvar COUNTER 0
		ifaction FRAME1 action FRAME2 else
		ifaction FRAME2 action FRAME3 else
		ifaction FRAME3 action FRAME1
	}
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 2048
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}
ifactor PHANTOMSKULL
{
	addvar COUNTER 1
	ifvare COUNTER 4
	{
		setvar COUNTER 0
		ifaction FRAME1 action FRAME2 else
		ifaction FRAME2 action FRAME3 else
		ifaction FRAME3 action FRAME4 else 
		ifaction FRAME4 action FRAME1
	}
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 2048
		setvar red 255
		setvar green 255
		setvar blue 255
		state spawnlight
		setvar peractor 1
	}
}
ifactor BUCHERSLIME
{
	addvar COUNTER 1
	ifvare COUNTER 5
	{
		setvar COUNTER 0
		ifaction FRAME1 action FRAME2 else
		ifaction FRAME2 action FRAME3 else
		ifaction FRAME3 action FRAME4 else
		ifaction FRAME4 action FRAME5 else
		ifaction FRAME5 action FRAME1
	}
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 2048
		setvar red 0
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}

ifactor NEWSCRAP1
{
	addvar COUNTER 1
	ifvare COUNTER 3
	{
		setvar COUNTER 0
		ifaction FRAME_FRAME1 action FRAME_FRAME2 else
		ifaction FRAME_FRAME2 action FRAME_FRAME3 else
		ifaction FRAME_FRAME3 action FRAME_FRAME4 else
		ifaction FRAME_FRAME4 action FRAME_FRAME5 else
		ifaction FRAME_FRAME5 killit
	}
	ifspawnedby FLAREFIRE
	{
		setactorvar[THISACTOR].active 1
		ifvare peractor 0
		{
			espawn SMALLSMOKE
			setvar light_radius 512
			setvar red 208
			setvar green 38
			setvar blue 38
			state spawnlight
			setvar peractor 1
		}
	} else
	ifspawnedby STAFFALTPROJ
	{
		setactorvar[THISACTOR].active 1
		ifvare peractor 0
		{
			espawn SMALLSMOKE
			setvar light_radius 512
			setvar red 0
			setvar green 64
			setvar blue 255
			state spawnlight
			setvar peractor 1
		}
	}
}
ifactor ALTNAPALM
{
	addvar COUNTER 1
	ifvare COUNTER 3
	{
		setvar COUNTER 0
		ifaction FRAME1 action FRAME2 else
		ifaction FRAME2 action FRAME3 else
		ifaction FRAME3 action FRAME1
	}	
	state newfirestate
	getactor[THISACTOR].z z
	subvar z 2048
	setactor[RETURN].z z
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 2048
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}
ifactor ALTTESLA
{
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 3072
		setvar red 0
		setvar green 64
		setvar blue 255
		state spawnlight
		setvar peractor 1
	}
}
ifactor STAFFPROJ 
{ 
	ifrnd 128 state newfirestate 
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 2048
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}
ifactor FLAME
{
	addvar COUNTER 1
	ifvare COUNTER 2
	{
		setvar COUNTER 0
		ifaction FRAME_FRAME1 action FRAME_FRAME2 else
		ifaction FRAME_FRAME2 action FRAME_FRAME3 else
		ifaction FRAME_FRAME3 action FRAME_FRAME4 else
		ifaction FRAME_FRAME4 action FRAME_FRAME5 else
		ifaction FRAME_FRAME5 action FRAME_FRAME6 else
		ifaction FRAME_FRAME6 action FRAME_FRAME7 else
		ifaction FRAME_FRAME7 action FRAME_FRAME8 else
		ifaction FRAME_FRAME8 killit
	}
	ifinwater killit
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 1536
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}
ifactor FLAME2
{
	addvar COUNTER 1
	ifvare COUNTER 2
	{
		setvar COUNTER 0
		ifaction FLAME2_FRAME1 action FLAME2_FRAME2 else
		ifaction FLAME2_FRAME2 action FLAME2_FRAME3 else
		ifaction FLAME2_FRAME3 action FLAME2_FRAME4 else
		ifaction FLAME2_FRAME4 action FLAME2_FRAME5 else
		ifaction FLAME2_FRAME5 action FLAME2_FRAME6 else
		ifaction FLAME2_FRAME6 action FLAME2_FRAME7 else
		ifaction FLAME2_FRAME7 action FLAME2_FRAME8 else
		ifaction FLAME2_FRAME8 killit
	}
	ifinwater killit
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 1536
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}

ifactor HELLFLAME
{
	addvar COUNTER 1
	ifvare COUNTER 2
	{
		setvar COUNTER 0
		ifaction HELLFLAME_FRAME1 { sizeat 8 8 action HELLFLAME_FRAME2 } else
		ifaction HELLFLAME_FRAME2 { sizeat 10 10 action HELLFLAME_FRAME3 } else
		ifaction HELLFLAME_FRAME3 { sizeat 14 14 action HELLFLAME_FRAME4 } else
		ifaction HELLFLAME_FRAME4 { sizeat 18 18 action HELLFLAME_FRAME5 } else
		ifaction HELLFLAME_FRAME5 { sizeat 22 22 action HELLFLAME_FRAME6 } else
		ifaction HELLFLAME_FRAME6 { sizeat 14 14 action HELLFLAME_FRAME7 } else
		ifaction HELLFLAME_FRAME7 { cstat 642 sizeat 10 10 action HELLFLAME_FRAME8 } else
		ifaction HELLFLAME_FRAME8 killit
	}
	ifinwater killit
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 1536
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}


ifactor TESLASPARK
{
	addvar COUNTER 1
	ifvare COUNTER 2
	{
		setvar COUNTER 0
		ifaction FRAME_FRAME1 action FRAME_FRAME2 else
		ifaction FRAME_FRAME2 action FRAME_FRAME3 else
		ifaction FRAME_FRAME3 action FRAME_FRAME4 else
		ifaction FRAME_FRAME4 action FRAME_FRAME5 else
		ifaction FRAME_FRAME5 killit
	}
	ifspawnedby ALTTESLA
	{
		addvar COUNTER 1
		ifvare COUNTER 14
		{
			setvar COUNTER 0
			ifaction FRAME_FRAME1 action FRAME_FRAME2 else
			ifaction FRAME_FRAME2 action FRAME_FRAME3 else
			ifaction FRAME_FRAME3 action FRAME_FRAME4 else
			ifaction FRAME_FRAME4 action FRAME_FRAME5 else
			ifaction FRAME_FRAME5 killit
		}
	}
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 512
		setvar red 0
		setvar green 64
		setvar blue 255
		state spawnlight
		setvar peractor 1
	}
}

ifactor STAFFALTPROJ
{
	setprojectile[NEWSCRAP1].pal 1
	state sparkstate state sparkstate
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 2048
		setvar red 0
		setvar green 64
		setvar blue 255
		state spawnlight
		setvar peractor 1
	}
}

ifactor NEWFIRE
{
	ifvare peractor 0
	{
		ifrnd 128 { cstat 4 } else cstat 0
		setvar peractor 1
	}
	addvar COUNTER 1
	ifspawnedby ALTNAPALM 
	{ 
		ifvare COUNTER 2
		{
			setvar COUNTER 0
			ifaction FRAME_FRAME1 action FRAME_FRAME2 else
			ifaction FRAME_FRAME2 action FRAME_FRAME3 else
			ifaction FRAME_FRAME3 action FRAME_FRAME4 else
			ifaction FRAME_FRAME4 action FRAME_FRAME5 else
			ifaction FRAME_FRAME5 action FRAME_FRAME6 else
			ifaction FRAME_FRAME6 action FRAME_FRAME7 else
			ifaction FRAME_FRAME7 killit
		} 
	} else 
	ifspawnedby STAFFPROJ
	{ 
		ifvare COUNTER 1
		{
			setvar COUNTER 0
			ifaction FRAME_FRAME1 action FRAME_FRAME2 else
			ifaction FRAME_FRAME2 action FRAME_FRAME3 else
			ifaction FRAME_FRAME3 action FRAME_FRAME4 else
			ifaction FRAME_FRAME4 killit
		} 
	} else 
	ifvare COUNTER 4
	{
		setvar COUNTER 0
		ifaction FRAME_FRAME1 action FRAME_FRAME2 else
		ifaction FRAME_FRAME2 action FRAME_FRAME3 else
		ifaction FRAME_FRAME3 action FRAME_FRAME4 else
		ifaction FRAME_FRAME4 action FRAME_FRAME5 else
		ifaction FRAME_FRAME5 action FRAME_FRAME6 else
		ifaction FRAME_FRAME6 action FRAME_FRAME7 else
		ifaction FRAME_FRAME7 killit
	}
	ifinwater killit
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 512
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}
ifactor SPRAYBUNDLE
{
espawn NAPALMSMOKE
getactor[RETURN].x x
getactor[RETURN].y y
getactor[RETURN].ang ang
setvarvar y2 y
addvar y2 -128
rotatepoint x y x y2 ang x3 y3
setactor[RETURN].x x3
setactor[RETURN].y y3

setactor[RETURN].xrepeat 5
setactor[RETURN].yrepeat 5
}
ifactor TNTBUNDLE
{
espawn NAPALMSMOKE
getactor[RETURN].x x
getactor[RETURN].y y
getactor[RETURN].ang ang
setvarvar y2 y
addvar y2 -128
rotatepoint x y x y2 ang x3 y3
setactor[RETURN].x x3
setactor[RETURN].y y3

setactor[RETURN].xrepeat 5
setactor[RETURN].yrepeat 5
}

ifactor HEART  //VOXEL ANIMATION
{
	addvar COUNTER 1
	ifvare COUNTER 4
	{
		setvar COUNTER 0
		ifaction FRAME_FRAME1 action FRAME_FRAME2 else
		ifaction FRAME_FRAME2 action FRAME_FRAME3 else
		ifaction FRAME_FRAME3 action FRAME_FRAME4 else
		ifaction FRAME_FRAME4 action FRAME_FRAME1
	}
}
ifactor ZOMBIEHEAD
{
	addvar COUNTER 64
	ifvarg COUNTER 2048 { setvar COUNTER 0 }
	{
		cos zdist COUNTER
		divvar zdist 4
		ezshootvar zdist BLOODSPRAY
		getactor[RETURN].ang ang
		addvarvar ang COUNTER
		setactor[RETURN].ang ang
		
		getactor[THISACTOR].x x
		getactor[THISACTOR].y y
		getactor[THISACTOR].z z
		setactor[RETURN].x x
		setactor[RETURN].y y
		setactor[RETURN].z z
	}
}

endevent

onevent EVENT_KILLIT

ifactor TNTBUNDLE
{
	getactorvar[THISACTOR].detonatetime tmp
	espawn TNTFLOOR
	setactorvar[RETURN].detonatetime tmp
	setvar RETURN 0
}
ifactor SPRAYBUNDLE
{
	getactorvar[THISACTOR].detonatetime tmp
	espawn SPRAYFLOOR
	setactorvar[RETURN].detonatetime tmp
	setvar RETURN 0
}
ifactor FLARE
{

	getactor[THISACTOR].htmovflag spriteid
	getactorvar[THISACTOR].noflarefire tmp2
	setactorvar[THISACTOR].active 0
	addvar spriteid 16384
	ifvarl spriteid 16384 ifvarg spriteid -1
	{ 
		espawn FLAREFIRE
		setactorvar[RETURN].noflarefire tmp2
		setactorvar[RETURN].id_s tmp
	}
	setactorvar[RETURN].id_s spriteid
	setvar RETURN 0
	getactorvar[THISACTOR].flarefulldamage peractor
	ifvare peractor 1
	{
		setvar DIST 1536
		findnearactorvar ZOMBIE DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp addvar tmp 100 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar HERETIC DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp addvar tmp 100 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar ZOMBIERISE DIST spriteid
		ifvarn spriteid -1 { getactorvar[spriteid].flamedamage tmp addvar tmp 100 setactorvar[spriteid].flamedamage tmp }
		findnearspritevar APLAYER DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp addvar tmp 100 setactorvar[spriteid].flamedamage tmp } }
	}
}
ifactor FLAME
{
	getactor[THISACTOR].htmovflag spriteid
	addvar spriteid 16384
	ifvarl spriteid 16384 ifvarg spriteid -1
	{ 	
			getactor[spriteid].picnum picnum
			switch picnum
				case ZOMBIE
				case HERETIC
				case EVILHAND
				case FATRAT
				case BATSLEEP
				case BAT
				case GARGOYLE
				case BUTCHER
				case PHANTASM
				case GILLBEAST
				case HELLDOG
				case SPIDER
				case BOSS2
				case BOSS3
				case BOSS4
				case APLAYER
				{ 
					getactor[spriteid].extra extra ifvarg extra 0
					{
						getactorvar[spriteid].flamedamage tmp
						addvar tmp 12
						setactorvar[spriteid].flamedamage tmp
					}
				}
				break
			endswitch 
	}
	setvar RETURN 1
	getplayer[THISACTOR].horiz temp
	subvar temp 100
	mulvar temp -6
	getactor[THISACTOR].z z
	
	getactor[THISACTOR].sectnum sect2
	getsector[sect2].floorz z2
	getsector[sect2].ceilingz z3
	ifvarvarg z z2  { setvarvar z z2 subvarvar z 3072 } else addvarvar z temp
	ifvarvarl z z3  { setvarvar z z3 addvarvar z 3072 } else addvarvar z temp
	setactor[THISACTOR].z z
	ifaction FRAME_FRAME8 setvar RETURN 0
	setactorvar[THISACTOR].active 0
}
ifactor FLAME2
{
	getactor[THISACTOR].htmovflag spriteid
	addvar spriteid 16384
	ifvarl spriteid 16384 ifvarg spriteid -1
	{ 	
			getactor[spriteid].picnum picnum
			switch picnum
				case ZOMBIE
				case HERETIC
				case EVILHAND
				case FATRAT
				case BATSLEEP
				case BAT
				case GARGOYLE
				case BUTCHER
				case PHANTASM
				case GILLBEAST
				case HELLDOG
				case SPIDER
				case BOSS2
				case BOSS3
				case BOSS4
				case APLAYER
				{ 
					getactor[spriteid].extra extra ifvarg extra 0
					{
						getactorvar[spriteid].flamedamage tmp
						addvar tmp 12
						setactorvar[spriteid].flamedamage tmp
					}
				}
				break
			endswitch 
	}
	setvar RETURN 1
	getplayer[THISACTOR].horiz temp
	subvar temp 100
	mulvar temp -6
	getactor[THISACTOR].z z
	
	getactor[THISACTOR].sectnum sect2
	getsector[sect2].floorz z2
	getsector[sect2].ceilingz z3
	ifvarvarg z z2  { setvarvar z z2 subvarvar z 3072 } else addvarvar z temp
	ifvarvarl z z3  { setvarvar z z3 addvarvar z 3072 } else addvarvar z temp
	setactor[THISACTOR].z z
	ifaction FLAME2_FRAME8 setvar RETURN 0
	setactorvar[THISACTOR].active 0
}
ifactor HELLFLAME
{
	getactor[THISACTOR].htmovflag spriteid
	addvar spriteid 16384
	ifvarl spriteid 16384 ifvarg spriteid -1
	{ 	
			getactor[spriteid].picnum picnum
			switch picnum
				case ZOMBIE
				case HERETIC
				case EVILHAND
				case FATRAT
				case BATSLEEP
				case BAT
				case GARGOYLE
				case BUTCHER
				case PHANTASM
				case GILLBEAST
				case HELLDOG
				case SPIDER
				case APLAYER
				{ 
					getactor[spriteid].extra extra ifvarg extra 0
					{
						getactorvar[spriteid].flamedamage tmp
						addvar tmp 12
						setactorvar[spriteid].flamedamage tmp
					}
				}
				break
			endswitch 
	}
	setactorvar[THISACTOR].active 0
}
ifactor PLASMAPROJ
{
	iffloordistl 5
	{
		setvar zdist 0
		state teslasparkstate
		state teslasparkstate
		state teslasparkstate
		state teslasparkstate
		setprojectile[TESLASPARK].vel 96
		setprojectile[TESLASPARK].drop 0
	} 
	else
	{
		randvar zdist 1024
		ifrnd 128 mulvar zdist -1
		subvar zdist 1024
		setprojectile[TESLASPARK].vel 64
	}
	state teslasparkstate
	state teslasparkstate
	state teslasparkstate
	state teslasparkstate
	state teslasparkstate
	state teslasparkstate
	state teslasparkstate
	state teslasparkstate
	setvar RETURN 0
	setactorvar[THISACTOR].active 0
	
	getactor[THISACTOR].htmovflag tmp
	addvar tmp 16384
	ifvarl tmp 16384 ifvarg tmp -1
	{ setactorvar[tmp].teslahitenable 1 }
}
ifactor ALTTESLA
{
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	setvar RETURN 0
	setactorvar[THISACTOR].active 0
}
ifactor TESLASPARK { setactorvar[THISACTOR].active 0 }
ifactor ALTNAPALM
{
	setactorvar[THISACTOR].active 0
	getactorvar[THISACTOR].napalmammo np_ammo
	quake 36
	stopsound EARTHQUAKE
	ifvarg np_ammo 3
	{
		subvar np_ammo 2
		espawn FIREBALL
		setactorvar[RETURN].napalmammo np_ammo
		setactor[RETURN].xrepeat 24
		setactor[RETURN].yrepeat 24
		espawn FIREBALL 
		setactorvar[RETURN].napalmammo np_ammo
		setactor[RETURN].xrepeat 24
		setactor[RETURN].yrepeat 24
	} 
	else
	ifvare np_ammo 3
	{
		espawn FIREBALL
		setactorvar[RETURN].napalmammo 0
		setactor[RETURN].xrepeat 24
		setactor[RETURN].yrepeat 24
		espawn FIREBALL 
		setactorvar[RETURN].napalmammo 0
		setactor[RETURN].xrepeat 24
		setactor[RETURN].yrepeat 24
	} 
	else
	ifvare np_ammo 2
	{
		espawn FIREBALL 
		setactorvar[RETURN].napalmammo 0
		setactor[RETURN].xrepeat 24
		setactor[RETURN].yrepeat 24
	}
	setvar RETURN 0
	setactorvar[THISACTOR].active 0
}

ifactor PR_NAPALM { setactorvar[THISACTOR].active 0 }
ifactor PHANTOMSKULL { setactorvar[THISACTOR].active 0 }
ifactor BUCHERSLIME { setactorvar[THISACTOR].active 0 }
ifactor STAFFPROJ { setactorvar[THISACTOR].active 0 }
ifactor STAFFALTPROJ { setactorvar[THISACTOR].active 0 }
ifactor NEWSCRAP1 { setactorvar[THISACTOR].active 0 }
ifactor NEWFIRE { setactorvar[THISACTOR].active 0 }
ifactor EXPLOSION5 { setactorvar[THISACTOR].active 0 }
ifactor EXPLOSION3 { setactorvar[THISACTOR].active 0 }
ifactor EXPLOSION6 { setactorvar[THISACTOR].active 0 }
		
ifactor ZOMBIEHEAD
{
	getactorvar[THISACTOR].active peractor
	espawn ZHEADFLOOR
	setactorvar[RETURN].active peractor
	setvar RETURN 0
}
ifactor BEERBOTTLE
{
	findnearactor3d BCHECK 2048 spriteid
	ifvarn spriteid -1 
	{ 
		getactor[THISACTOR].pal pal
		ifvare pal 1
		{
			getactorvar[spriteid].active tmp 
			addvar tmp 1 
			setactorvar[spriteid].active tmp 
		}
	}
}


//--------------------------------define killit variable for Gargoyle

getactor[THISACTOR].hitag HITAG
getactor[THISACTOR].pal pal
ifvare HITAG 200 ifvare pal 30 { setactorvar[THISACTOR].skillit 1 }

//--------------------------------end code define killit variable for Gargoyle


endevent

onevent EVENT_EGS

	state weapon_egs

ifactor ZOMBIEHEAD
{
  getplayer[THISACTOR].ang tmp
  setactor[THISACTOR].ang tmp
}
endevent


actor APLAYER MAXPLAYERHEALTH PSTAND 0 0
getactor[THISACTOR].extra HEALTHAMOUNT
getuserdef[THISACTOR].ffire ffirevar
getplayer[THISACTOR].i r0
setplayer[THISACTOR].knuckle_incs 0
getsector[THISACTOR].floorshade shade
getplayer[THISACTOR].curr_weapon CURRWEAP
getactor[PLAYERID].htextra paextra

getplayer[THISACTOR].last_weapon lastweapon
ifvarn lastweapon -1 
{ 
	getplayer[THISACTOR].ammo_amount lastweapon ammo
	ifvarg ammo 0 { setvarvar savelastweap lastweapon }
}

// WEAPON CHANGER

ifvare changeweappos 1
{
	getplayer[THISACTOR].weapon_pos pos
	ifvarg pos 8 { ifvarn CURRWEAP 5 { setplayer[THISACTOR].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 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 WEAPON_VAR_TNT 3 setvar changeweappos 0 }
}
ifvare changeweappos 4
{
	getplayer[THISACTOR].weapon_pos pos
	ifvarg pos 8 { setplayer[THISACTOR].curr_weapon 6 setvar changeweappos 0 }
}
ifvare changeweappos 5
{
	getplayer[THISACTOR].weapon_pos pos
	ifvarg pos 8 
	{	
		setplayer[THISACTOR].curr_weapon savelastweap
		setvar changeweappos 0 
	}
}

setplayer[THISACTOR].max_actors_killed TOTALKILLS

ifvare peractor 0
{
	ifvarn SAVED_BODYSHIELD 0 setactorvar[THISACTOR].bodyshield SAVED_BODYSHIELD
	ifvarn SAVED_FIRESHIELD 0 setactorvar[THISACTOR].fireshield SAVED_FIRESHIELD
	ifvarn SAVED_SPIRITSHIELD 0 setactorvar[THISACTOR].spiritshield SAVED_SPIRITSHIELD
	setvar peractor 1 
}

getactorvar[THISACTOR].bodyshield BODYSHIELD_AMOUNT
getactorvar[THISACTOR].fireshield FIRESHIELD_AMOUNT
getactorvar[THISACTOR].spiritshield SPIRITSHIELD_AMOUNT

getactorvar[THISACTOR].playerdrunk DRUNKCOUNT
ifvarg DRUNKCOUNT 0
{
	addvar hz1 8
	andvar hz1 2047
	setvarvar hz2 hz1
	mulvar hz2 2
	palfrom 32 0 0 0
	subvar DRUNKCOUNT 1
	setactorvar[THISACTOR].playerdrunk DRUNKCOUNT
	cos cmang hz1
	mulvarvar cmang DRUNKCOUNT
	shiftvarr cmang 14
	
	setplayer[THISACTOR].rotscrnang cmang
}

getactorvar[THISACTOR].handattack temp
ifvare temp 1 
{ 
	randvar temp 6
	ifvare phandvar 0
	{
		addvar peractor 1
		sin perplayer peractor
		divvar perplayer 600
		modvar perplayer 19
		ifvarg perplayer 17 setvar phandvar 1
	}
	
	palfrom 32 0 0 0 
	getplayer[THISACTOR].pals_time pal
	addvarvar pal temp
	addvarvar pal perplayer
	setplayer[THISACTOR].pals_time pal
	
	ifvarl phandtime 40
	{
		addvar phandtime 1
		ifcount 2 { subvar HEALTHAMOUNT 1 resetcount }
		setactor[THISACTOR].extra HEALTHAMOUNT
	} else ifcount 3 setvar phandtime 0
	
	ifrnd 128 { addvar phandcount 2 } else addvar phandcount 3
	ifvarg phandcount 150 setvar phandcount 150
	
	ifhitspace 
	{
		ifvare phandspace 0
		{ 
			ifrnd 127 { subvar phandcount 15 } else ifrnd 127 { subvar phandcount 10 } else subvar phandcount 30
			setvar phandspace 1
			ifvarl phandcount 0 
			{
				espawn EVILHAND 
				getactor[THISACTOR].x x
				getactor[THISACTOR].y y
				getplayer[THISACTOR].ang ang
				setvarvar x2 x
				addvar x2 512
				rotatepoint x y x2 y ang x3 y3
				setactor[RETURN].x x3
				setactor[RETURN].y y3
				setactorvar[RETURN].handshock 1
				setactorvar[THISACTOR].handattack 0 
				setvar peractor 0
				setvar perplayer 0
				setvar phandvar 0
				setvar phandcount 35
			}
		} 
	} else setvar phandspace 0
}

ifvare cheat_on 1
{
	setactorvar[THISACTOR].bodyshield 200
	setactorvar[THISACTOR].fireshield 200
	setactorvar[THISACTOR].spiritshield 200
	setvar cheat_on 0
}

ifvare DEATHMASK_ON 1
{
	addvar GODTIME 1
	setactor[THISACTOR].htextra -1
	getplayer[THISACTOR].i PLAYERID
	getactor[PLAYERID].extra HEALTHAMOUNT
	ifvare GODTIME 1 { getactor[PLAYERID].extra HPGOD }
	ifvarvarg HEALTHAMOUNT HPGOD { getactor[PLAYERID].extra HPGOD }
	ifvarvarl HEALTHAMOUNT HPGOD { setactor[PLAYERID].extra HPGOD }
	ifvare GODTIME 780 { setvar DEATHMASK_ON 0 setvar GODTIME 0 }
}

randvar voodooprobability 40

ifvare player[THISACTOR].crack_time 1 
{
	ifrnd 28 sound VOICE1 else
	ifrnd 28 sound VOICE2 else
	ifrnd 28 sound VOICE3 else
	ifrnd 28 sound VOICE4 else
	ifrnd 28 sound VOICE5 else
	ifrnd 28 sound VOICE6 else
	ifrnd 28 sound VOICE7 else
	ifrnd 28 sound VOICE8 else
	sound VOICE9
}

getactorvar[THISACTOR].pfire temp
ifvarg temp 0 { addvar COUNTER 1 } 
ifinwater { setvar COUNTER 0 setactorvar[THISACTOR].pfire 0 }
ifvarvare COUNTER 182 { setactorvar[THISACTOR].pfire 0 setvar COUNTER 0 }
	
getactorvar[THISACTOR].reflective temp
ifvare temp 1
{
	palfrom 16 1 12 32
	addvar REFLTIME 1
	ifvarg paextra 0
	{
		getactor[THISACTOR].htowner spriteid
		ifvarn spriteid -1
		{
			getactor[spriteid].extra extra
			ifvarg extra 0
			{
				setactorvar[spriteid].reflective 1
				setactor[THISACTOR].htextra -1
				subvarvar extra paextra
				setactor[spriteid].extra extra
			}
		}
	}
	ifvare REFLTIME 1 { espawn PREFLBALL setactorvar[RETURN].spriteid THISACTOR }
	ifvare REFLTIME 780 { setactorvar[THISACTOR].reflective 0 setvar REFLTIME 0 }
}
/*
	ifvare LIGHTERENABLE 1
	{
		setactorvar[THISACTOR].active 1
		ifvare peractor 0
		{
			espawn SMALLSMOKE
			setvar light_radius 2048
			setvar red 255
			setvar green 144
			setvar blue 0
			state spawnlight
			setvar peractor 1
		}
	} else { setactorvar[THISACTOR].active 0 setvar peractor 0 }
*/

getactorvar[THISACTOR].voodoohitenemy temp
ifvare temp 1 
{ 
	setactor[THISACTOR].extra -1 
	action PTHROWNBACK 
	setactorvar[THISACTOR].voodoohitenemy 0 
}
getactorvar[THISACTOR].voodoohitenemy temp
ifvare temp 2
{
	palfrom 64 0 0 0
	setactorvar[THISACTOR].voodoohitenemy 0 
}

getactorvar[THISACTOR].invisible temp
getactor[THISACTOR].cstat pcstat
ifvare temp 1
{
	orvar pcstat 514
	addvar INVISTIME 1
	setvar orientationweapon 33
	ifvare INVISTIME 780 { subvar pcstat 514 setactorvar[THISACTOR].invisible 0 setvar orientationweapon 0 setvar INVISTIME 0 }
} 
setactor[THISACTOR].cstat pcstat

getactorvar[THISACTOR].flamedamage temp
ifvarg temp 0 { addvar COUNTER 1 state newfirestate  { ifrnd 96 sound PLAY1118 else ifrnd 96 sound PLAY1119 else sound PLAY1120 } } 
ifinwater { setvarvar COUNTER temp }
ifvarvare COUNTER temp { stopsound PLAY1118 stopsound PLAY1119 stopsound PLAY1120 setactorvar[THISACTOR].flamedamage 0 setvar COUNTER 0 }

getactorvar[THISACTOR].burningguyactive temp
ifvare temp 1 
{ 

    { stopsound PLAY1118 stopsound PLAY1119 stopsound PLAY1120 ifrnd 96 sound DIE1 else ifrnd 96 sound DIE2 else sound DIE3 }
	setactor[THISACTOR].extra -1 
	action PTHROWNBACK 
	setactorvar[THISACTOR].burningguyactive 0 
	setactorvar[THISACTOR].flamedamage 0 
	setvar COUNTER 0 
}

getactor[r0].extra HEALTHAMOUNT
getactorvar[r0].reflective reflmode
getuserdef[r0].god godmode
ifvare godmode 1 { setactor[THISACTOR].htextra 0 }

getactor[THISACTOR].htpicnum htpicnum
ifvare htpicnum ALTTESLA 
{ 
	getactor[THISACTOR].htowner temp
	palfrom 32 32
	getactor[temp].htextra paextra
	ifvarg paextra 128
	{
		divvar paextra 4
		setactor[temp].htextra paextra
		state checkb_armor
		setactor[temp].htpicnum -1
	} else { palfrom 0 setactor[temp].htextra -1 setactor[temp].htpicnum -1 }
}

// -------------- Underwater damage

ifvare player[THISACTOR].airleft 0
{ setvar airleft 1 }
getactor[THISACTOR].sectnum num
getsector[num].lotag lotag
ifvare lotag 1 ifvare airleft 1 ifp palive { sound PAIN6 setvar airleft 0 }

addvar TIMECOUNT 1

// INVENTORY CODE

ifvare DISPLAYINVENTORY 1
{
	ifvare ICPOSITION 0
	{
        ifvarg DOCTORSBAGAM 0 { setplayer[THISACTOR].inven_icon 8 }
	}
	ifvare ICPOSITION 1
	{
	ifvarg DIVINGSUITAM 0 { setplayer[THISACTOR].inven_icon 9 }
	}
	ifvare ICPOSITION 2
	{
	ifvarg CRYSTALLBALLAM 0 { setplayer[THISACTOR].inven_icon 10 }
        }
        ifvare ICPOSITION 3
	{
	ifvarg BEASTVISIONAM 0 { setplayer[THISACTOR].inven_icon 11 }
        }
        ifvare ICPOSITION 4
	{
	ifvarg BOOTSOFJUMPINGAM 0 { setplayer[THISACTOR].inven_icon 12 }
	}
}

//BEAST VISION ACTION

ifvarg BEASTVISIONAM 0
ifvare BEASTVON 1
{
subvar BEASTVISIONAM 1
setvar VISION 1
} else setvar VISION 0

// DIVING SUIT ACTION

ifinwater
ifvarg DIVINGSUITAM 0
ifvare DIVINGSUITON 1
{
setplayer[THISACTOR].scuba_on 1
subvar DIVINGSUITAM 1
} else { setvar DIVINGSUITON 0 setplayer[THISACTOR].scuba_on 0 }

// DOCTOR'S BAG Thanks to TheLezing for this code

ifvarg DOCTORSBAGAM 0
ifvarn DOCTORSBAGON 0
{ 
setvar DOCTORSBAGON 0
getplayer[THISACTOR].i PLAYERID
getactor[PLAYERID].extra HEALTHAMOUNT
ifvarl HEALTHAMOUNT 100 
 { 
  globalsound PICKHEAL
  mulvar HEALTHAMOUNT -1
  addvar HEALTHAMOUNT 100
  setvarvar tmp DOCTORSBAGAM
  ifvarvarl tmp HEALTHAMOUNT setvarvar HEALTHAMOUNT tmp
  getactor[PLAYERID].extra tmp
  addvarvar tmp HEALTHAMOUNT
  subvarvar DOCTORSBAGAM HEALTHAMOUNT
  setactor[PLAYERID].extra tmp
 }
}

// BOOTS OF JUMPING

ifvarg BOOTSOFJUMPINGAM 0
ifvare JBOOTSON 1
{
subvar BOOTSOFJUMPINGAM 1
getplayer[THISACTOR].jumping_counter tmp
ifvarg tmp 0 { setplayer[THISACTOR].poszv -11584 }
iffloordistl 32
{
getplayer[THISACTOR].falling_counter tmp
ifvarl tmp 61
ifvarg BOOTSOFJUMPINGAM 0
{
  setvar tmp 8
  setplayer[THISACTOR].falling_counter tmp
}
}
}

//CRISTALL BALL

ifvarg CRYSTALLBALLAM 0
{
	ifvare CRBALLON 1 {	subvar CRYSTALLBALLAM 1	}
} 	else setvar CRBALLON 0

// AUTOCLOSE INVMENU

ifvare DISPLAYINVENTORY 1
{
	ifvarn INVENTORYCHECK 0 { subvar INVENTORYCHECK 1 }
	ifvare INVENTORYCHECK 0
	{
	setvar DISPLAYINVENTORY 0
	}
}

//AKIMBO ITEM CODE

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 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 tsakimbo -9
	}
} 
ifvare deactiveakimbo 1 { setvar deactiveakimbo 0 }
ifvare CURRWEAP 2
{
	getplayer[THISACTOR].kickback_pic tmp
	ifvare tmp 16
	{ 
		state shotgunshellstate 
		state shotgunshellstate 	
		getactor[RETURN].xoffset xoffset
		addvar xoffset -15
		setactor[RETURN].xoffset xoffset 
	}
}	

// ----------------------------- VOODOO DOLL CODE

	setvar spriteid 0
	setvar minimum 16777216
	setvar minid -1
	whilevarn spriteid 16384
	{
		getactor[spriteid].picnum picnum
		switch picnum
		case ZOMBIE
		case HERETIC
		case BUTCHER
		case GILLBEAST
		case FATRAT
		case EVILHAND
		case FISH
		case HELLDOG
		case BAT
		case BATSLEEP
		case GARGOYLE
		{
			getactor[spriteid].x mx
			getactor[spriteid].y my
			getactor[spriteid].z mz
			getactor[spriteid].extra extra
			getactor[THISACTOR].x x
			getactor[THISACTOR].y y
			getactor[THISACTOR].z z
			subvarvar mx x
			subvarvar my y
			getangle mang mx my
		    getactor[THISACTOR].ang ang
			getincangle mang mang ang
			ifvarg extra 0
			ifvarg mang -256 ifvarl mang 256
			{
				dist temp THISACTOR spriteid
				ifvarvarl temp minimum { setvarvar minimum temp }
				ifvarvare temp minimum ifvarvarn spriteid THISACTOR 
				{ setvarvar minid spriteid }
			}
		}
		break
		endswitch
		addvar spriteid 1
	}

	setvar temp 0
	setvar pminimum 16777216
	setvar pminid -1
	getplayer[THISACTOR].i r0
	whilevarvarn temp numplayers
	{
		getplayer[temp].i pid
		ifvarvarn pid r0 { setvarvar peractor2 temp }
		getplayer[peractor2].i pid
		getactor[pid].x px
		getactor[pid].y py
		getactor[pid].z pz
		getactor[pid].extra HEALTHAMOUNT
		getactor[THISACTOR].x x
		getactor[THISACTOR].y y
		getactor[THISACTOR].z z
		subvarvar px x
		subvarvar py y
		getangle pang px py
		getactor[THISACTOR].ang ang
		getincangle pang pang ang
		ifvarg HEALTHAMOUNT 0
		ifvarg pang -256 ifvarl pang 256
		{
			dist xydist THISACTOR pid
			ifvarvarl xydist minimum { setvarvar minimum xydist }
			ifvarvare xydist minimum ifvarvarn pid r0 { setvarvar pminid pid }
		}
		addvar temp 1
	}
	
	ifvarn pminid -1
	{
		getactor[pminid].x px
		getactor[pminid].y py
		getactor[pminid].z pz
		getactor[pminid].sectnum sect2
		getactor[THISACTOR].x x
		getactor[THISACTOR].y y
		getactor[THISACTOR].z z
		getactor[THISACTOR].sectnum sect1
		subvar pz 8192

		ifvarn sect2 4096 { cansee x y z sect1 px py pz sect2 psee } else setvar psee 0
		ifvare psee 1
		{
			getactor[pminid].extra HEALTHAMOUNT
			ifvarg HEALTHAMOUNT 0 { setvar voodoohit 1 }
			
			ifvare voodoocount2 3 { ifvarg HEALTHAMOUNT 0 { state pvoodoohitstate } else setvar voodoohit 0 }
			ifvare voodoocount3 3 { ifvarg HEALTHAMOUNT 0 { state pvoodoohitstate } else setvar voodoohit 0 }
			ifvare voodoocount4 3 { ifvarg HEALTHAMOUNT 0 { state pvoodoohitstate } else setvar voodoohit 0 }
			ifvare voodoocount5 3 { ifvarg HEALTHAMOUNT 0 { state pvoodoohitstate } else setvar voodoohit 0 }
		} else setvar voodoohit 0
	} else
	ifvarn minid -1
	{	
		getactor[minid].x mx
		getactor[minid].y my
		getactor[minid].z mz
		getactor[minid].sectnum sect2
		getplayer[THISACTOR].posx px
		getplayer[THISACTOR].posy py
		getplayer[THISACTOR].posz pz
		getplayer[THISACTOR].cursectnum sect1
		subvar mz 8192

		ifvarn sect2 4096 { cansee px py pz sect1 mx my mz sect2 see } else setvar see 0
		ifvare see 1
		{
			getactor[minid].extra extra
			ifvarg extra 0 { setvar voodoohit 1 }
			ifvare voodoocount2 3 { ifvarg extra 0 { state voodoohitstate } else setvar voodoohit 0 }
			ifvare voodoocount3 3 { ifvarg extra 0 { state voodoohitstate } else setvar voodoohit 0 }
			ifvare voodoocount4 3 { ifvarg extra 0 { state voodoohitstate } else setvar voodoohit 0 }
			ifvare voodoocount5 3 { ifvarg extra 0 { state voodoohitstate } else setvar voodoohit 0 }
		} else setvar voodoohit 0

	} else setvar voodoohit 0

	ifvare voodoohit 0
	ifvare voodoocount1 3
	{
			getactor[THISACTOR].extra temp
			subvar temp 1
			setactor[THISACTOR].extra temp
	} 

ifvarn voodoocount1 0
{
	addvar voodoocount1 1
	ifvarg voodoocount1 15 setvar voodoocount1 0
}	
ifvarn voodoocount2 0
{
	addvar voodoocount2 1
	ifvarg voodoocount2 15 setvar voodoocount2 0
}	
ifvarn voodoocount3 0
{
	addvar voodoocount3 1
	ifvarg voodoocount3 15 setvar voodoocount3 0
}	
ifvarn voodoocount4 0
{
	addvar voodoocount4 1
	ifvarg voodoocount4 23 setvar voodoocount4 0
}
ifvarn voodoocount5 0
{
	addvar voodoocount5 1
	ifvarg voodoocount5 35 setvar voodoocount5 0
}	
ifvarn voodooalt 0
ifvare voodoocount1 0 
ifvare voodoocount2 0 
ifvare voodoocount3 0 
ifvare voodoocount4 0 
ifvare voodoocount5 0
{
	setplayer[THISACTOR].curr_weapon 9
	setplayer[THISACTOR].weapon_pos 0
	stopsound INSERT_CLIP
	stopsound SHOTGUN_COCK
	stopsound SELECT_WEAPON

	ifvare voodooalt 20 
	{
		ifvarn pminid -1
		{
			getactor[pminid].extra HEALTHAMOUNT
			ifvarg HEALTHAMOUNT 0
			{ 
				getplayer[THISACTOR].ammo_amount 9 temp
				ifvare psee 1
				{
					mulvar temp 2
					subvarvar HEALTHAMOUNT temp ifvarl HEALTHAMOUNT 0 { setvar HEALTHAMOUNT 0 setactorvar[pminid].playerdrunk 150 setactorvar[pminid].voodoohitenemy 1 setactor[pminid].extra HEALTHAMOUNT }
				}
			}
		} else
		ifvarn minid -1
		{
			getactor[minid].extra extra
			ifvarg extra 0
			{ 
				ifvare see 1
				{
					getplayer[THISACTOR].ammo_amount 9 temp
					mulvar temp 2
					subvarvar extra temp 
					setactor[minid].extra extra
					ifvarl extra 0 { setvar extra 0 setactorvar[minid].voodoohitenemy 1 }
				}
			}
		}
		globalsound VOODOOKILL 
		setplayer[THISACTOR].ammo_amount 9 0
	}
	
	addvar voodooalt 1
	ifvarg voodooalt 30 { setvar changeweappos 5
		setplayer[THISACTOR].weapon_pos 10 setvar voodooalt 0 }
}	

//------------------------------DYNAMITE CODE

ifvare CURRWEAP 10 
{ 
	ifvare WEAPON_VAR_TNT 1 { setplayer[THISACTOR].curr_weapon 5 }
	ifvare WEAPON_VAR_TNT 2 { setplayer[THISACTOR].curr_weapon 5 }
}
ifvare CURRWEAP 5 { setvarvar currdinamite WEAPON_VAR_TNT } else { setvar currdinamite 0 }

ifvarn detonateplayer 0
{
	addvar detonateplayer 1
	ifvarg detonateplayer 14 setvar detonateplayer 0
}

ifvarn tntalt 0
{
	setplayer[THISACTOR].curr_weapon 5
	setplayer[THISACTOR].weapon_pos 0
	stopsound INSERT_CLIP
	stopsound SHOTGUN_COCK
	stopsound SELECT_WEAPON
	addvar tntalt 1
	ifvarg tntalt 14 setvar tntalt 14
}

	ifvare SHOOTTNT 1 
	{ 
	getprojectile[TNTBUNDLE].vel tmp
	mulvar TNTCOUNT 8
	addvarvar tmp TNTCOUNT
	setprojectile[TNTBUNDLE].vel tmp

	eshoot TNTBUNDLE
	setactorvar[RETURN].detonatetime dtime
	getactor[RETURN].zvel zvel
	mulvar TNTCOUNT -25
	addvarvar zvel TNTCOUNT
	setactor[RETURN].zvel zvel
	subvar TNT_AMMOAMOUNT 1
	setvar SHOOTTNT 0 
	setvar TNTCOUNT 0
	setvar dtime 0
	setprojectile[TNTBUNDLE].vel 512
	}

	ifvare SHOOTTNT 2
	{ 
	getprojectile[PROXIMITYBUNDLE].vel tmp
	mulvar TNTCOUNT 8
	addvarvar tmp TNTCOUNT
	setprojectile[PROXIMITYBUNDLE].vel tmp

	eshoot PROXIMITYBUNDLE
	getactor[RETURN].zvel zvel
	mulvar TNTCOUNT -25
	addvarvar zvel TNTCOUNT
	setactor[RETURN].zvel zvel
	subvar PROXIMITYMINE_AMMOAMOUNT 1
	setvar SHOOTTNT 0 
	setvar TNTCOUNT 0
	setprojectile[PROXIMITYBUNDLE].vel 512
	}

	ifvare SHOOTTNT 3 
	{ 
	getprojectile[REMOTEBUNDLE].vel tmp
	mulvar TNTCOUNT 8
	addvarvar tmp TNTCOUNT
	setprojectile[REMOTEBUNDLE].vel tmp

	eshoot REMOTEBUNDLE
	getactor[RETURN].zvel zvel
	mulvar TNTCOUNT -25
	addvarvar zvel TNTCOUNT
	setactor[RETURN].zvel zvel
	subvar REMOTETNT_AMMOAMOUNT 1
	setvar SHOOTTNT 0 
	setvar TNTCOUNT 0
	setprojectile[REMOTEBUNDLE].vel 512
	}
	
ifvare CURRWEAP 5
{
ifvare WEAPON_VAR_TNT 1 { setplayer[THISACTOR].ammo_amount 5 TNT_AMMOAMOUNT }
ifvare WEAPON_VAR_TNT 2 { setplayer[THISACTOR].ammo_amount 5 PROXIMITYMINE_AMMOAMOUNT }
ifvare WEAPON_VAR_TNT 3 { setplayer[THISACTOR].ammo_amount 5 REMOTETNT_AMMOAMOUNT }

getplayer[THISACTOR].kickback_pic tmp
ifvare tmp 15 { soundonce TNTTOSS }

getplayer[THISACTOR].ammo_amount 5 tmp
ifvare tmp 0
{
	getplayer[THISACTOR].kickback_pic tmp
	ifvare tmp 0
	{
		ifvare TNT_AMMOAMOUNT 0 ifvare REMOTETNT_AMMOAMOUNT 0 ifvare PROXIMITYMINE_AMMOAMOUNT 0 { setvar changeweappos 5 setplayer[THISACTOR].weapon_pos 10 }
		ifrnd 85 { ifvarg TNT_AMMOAMOUNT 0 { setvar WEAPON_VAR_TNT 1 } } else
		ifrnd 85 { ifvarg REMOTETNT_AMMOAMOUNT 0 { setvar WEAPON_VAR_TNT 3 } } else
		ifvarg PROXIMITYMINE_AMMOAMOUNT 0 { setvar WEAPON_VAR_TNT 2 } else
		setvar LIGHTERENABLE 0
	}
}

ifvare WEAPON_VAR_TNT 1
{
	setvar WEAPON5_FIREDELAY 14
	setvar WEAPON5_HOLDDELAY 15
	ifinwater { setplayer[THISACTOR].weapon_pos 20 setvar LIGHTERENABLE 0 setvar tntalt 0 }
} 
else ifvare WEAPON_VAR_TNT 2
{
	setvar WEAPON5_FIREDELAY 4
	setvar WEAPON5_HOLDDELAY 12
}
else ifvare WEAPON_VAR_TNT 3
{
	setvar WEAPON5_FIREDELAY 4
	setvar WEAPON5_HOLDDELAY 12
}
	
	ifvare tntalt 14
	{
	addvar dtime 1 soundonce TNTFUSE
	ifvarg dtime 156
			{
			setplayer[THISACTOR].kickback_pic 0
			setplayer[THISACTOR].weapon_pos 20
			palfrom 32 32
			setvar detonateplayer 1
			globalsound EXPLODCM
			espawn EXPLOSION3
	    	getactor[THISACTOR].x x
	    	getactor[THISACTOR].y y
	    	getplayer[THISACTOR].ang tmp
	    	setvarvar x2 x
	    	addvar x2 512
	    	rotatepoint x y x2 y tmp x3 y3
	    	setactor[RETURN].x x3
	    	setactor[RETURN].y y3
			hitradius 2048 60 100 160 300

			getplayer[THISACTOR].ang ang
			addvar ang 1024
			setactor[THISACTOR].htang ang
			setactor[THISACTOR].htextra 150
			setvarvar k_damage 25
			getplayer[THISACTOR].ammo_amount 5 tmp
			ifvarg tmp 0 subvar tmp 1
			setplayer[THISACTOR].ammo_amount 5 tmp
			setvar dtime 0
			setvar tntalt 0
			}
	}
	getplayer[THISACTOR].kickback_pic tmp
	ifvare tmp 14
	ifvare WEAPON_VAR_TNT 1
	{
	addvar dtime 1 soundonce TNTFUSE
	ifvarg dtime 156
			{
			setplayer[THISACTOR].kickback_pic 0
			setplayer[THISACTOR].weapon_pos 20
			palfrom 32 32
			setvar detonateplayer 1
			globalsound EXPLODCM
			espawn EXPLOSION3
	    	getactor[THISACTOR].x x
	    	getactor[THISACTOR].y y
	    	getplayer[THISACTOR].ang tmp
	    	setvarvar x2 x
	    	addvar x2 512
	    	rotatepoint x y x2 y tmp x3 y3
	    	setactor[RETURN].x x3
	    	setactor[RETURN].y y3
			hitradius 2048 60 100 160 300

			getplayer[THISACTOR].ang ang
			addvar ang 1024
			setactor[THISACTOR].htang ang
			setactor[THISACTOR].htextra 150
			setvarvar k_damage 25
			getplayer[THISACTOR].ammo_amount 5 tmp
			ifvarg tmp 0 subvar tmp 1
			setplayer[THISACTOR].ammo_amount 5 tmp
			setvar dtime 0
			setvar tntalt 0
			}
	}
	ifvare dtime 0 { stopsound TNTFUSE }
}

ifvare CURRWEAP 10
{
	getplayer[THISACTOR].kickback_pic tmp
	ifvare tmp 3 { globalsound PROXDET }
	
	ifvare  REMOTETNT_AMMOAMOUNT 0
	{
		ifrnd 128 { ifvarg TNT_AMMOAMOUNT 0 { setplayer[THISACTOR].ammo_amount 5 TNT_AMMOAMOUNT } } else
		ifvarg PROXIMITYMINE_AMMOAMOUNT 0 { setplayer[THISACTOR].ammo_amount 5 PROXIMITYMINE_AMMOAMOUNT }
	}
}


//LIGHTER CODE

ifvare CURRWEAP 6 ifvare LIGHTERENABLE 0 { ifvare player[THISACTOR].weapon_pos 2 globalsound ZIPLIGHT }
ifvare CURRWEAP 5 ifvare LIGHTERENABLE 0 ifvare WEAPON_VAR_TNT 1 { ifvare player[THISACTOR].weapon_pos 2 globalsound ZIPLIGHT } 
	
ifvarn CURRWEAP 6 ifvarn currdinamite 1 { setvar LIGHTERENABLE 0 }
ifvare CURRWEAP 10 { setvar LIGHTERENABLE 1 }
ifvarn CURRWEAP 5 ifvarn CURRWEAP 6 { setvar TNTCOUNT 0 }


// SPRAY CODE

ifvarn sprayalt 0
{
	setvar WEAPON6_TOTALTIME 16
	setplayer[THISACTOR].curr_weapon 6
	setplayer[THISACTOR].weapon_pos 0
	stopsound INSERT_CLIP
	stopsound SHOTGUN_COCK
	stopsound SELECT_WEAPON
	addvar sprayalt 1
	ifvarg sprayalt 14 setvar sprayalt 14
}

ifvare sprayalt 14
{
	addvar dtime 1 soundonce SPRAYFIR
	ifvarg dtime 156
			{
			setplayer[THISACTOR].weapon_pos 20
			palfrom 32 32
			setvar detonateplayer 1
			globalsound EXPLODCM
			stopsound SPRAYFIR
			espawn EXPLOSION3
	    	getactor[THISACTOR].x x
	    	getactor[THISACTOR].y y
	    	getplayer[THISACTOR].ang tmp
	    	setvarvar x2 x
	    	addvar x2 512
	    	rotatepoint x y x2 y tmp x3 y3
	    	setactor[RETURN].x x3
	    	setactor[RETURN].y y3
			hitradius 2048 60 100 160 300
			getplayer[THISACTOR].ang ang
			addvar ang 1024
			setactor[THISACTOR].htang ang
			setactor[THISACTOR].htextra 150
			setvarvar k_damage 25
			getplayer[THISACTOR].ammo_amount 6 tmp
			subvar tmp 48
			setplayer[THISACTOR].ammo_amount 6 tmp
			setvar dtime 0
			setvar sprayalt 0
			}
}
ifp palive
{
	ifvare SHOOTSPRAY 1 
	{ 
	getprojectile[SPRAYBUNDLE].vel tmp
	mulvar TNTCOUNT 8
	addvarvar tmp TNTCOUNT
	setprojectile[SPRAYBUNDLE].vel tmp

	eshoot SPRAYBUNDLE
	getactor[RETURN].zvel zvel
	mulvar TNTCOUNT -25
	addvarvar zvel TNTCOUNT
	setactor[RETURN].zvel zvel
	getplayer[THISACTOR].ammo_amount 6 tmp
	subvar tmp 48
	setplayer[THISACTOR].ammo_amount 6 tmp
	setvar SHOOTSPRAY 0 
	setvar TNTCOUNT 0
	setvar dtime 0
	setprojectile[SPRAYBUNDLE].vel 512
	}
}
ifvare CURRWEAP 6
{
getplayer[THISACTOR].kickback_pic tmp
ifvare tmp 6 { globalsound TNTTOSS }
ifinwater { setplayer[THISACTOR].weapon_pos 20 setvar LIGHTERENABLE 0 setvar sprayalt 0 }
}

// TESLA CODE

ifvare CURRWEAP 7
ifp palive
ifvare akimboteslaalt 0
ifvare teslaalt 0
{
	getplayer[THISACTOR].ammo_amount 7 tmp
	ifvarg tmp 0
	{
		getplayer[THISACTOR].kickback_pic temp
		ifvarand temp 1 { modvar temp 1 }
		ifvarg temp 0
		{ 
			ifvare tsakimbo 0
			{
				subvar tmp 1
				setplayer[THISACTOR].ammo_amount 7 tmp
				sound TESSNGFR
				sound TESSNGHT
				shoot PLASMAPROJ 
			} 
			else 
			{
				subvar tmp 1
				setplayer[THISACTOR].ammo_amount 7 tmp
				sound TESSNGFR
				sound TESSNGHT
				eshoot PLASMAPROJ
				getactor[RETURN].xoffset xoffset
				addvar xoffset -12
				setactor[RETURN].xoffset xoffset
			}
		}
	}
}

// TESLA ALT FIRE

ifvarn teslaalt 0
ifvare akimboteslaalt 0
{
	setplayer[THISACTOR].curr_weapon 7
	setplayer[THISACTOR].weapon_pos 0
	stopsound INSERT_CLIP
	stopsound SHOTGUN_COCK
	stopsound SELECT_WEAPON
	
	ifvare teslaalt 1 { sound TESLA1 }
	ifvare teslaalt 60 
	{
		shoot ALTTESLA
		globalsound TESALTFR 
		getplayer[THISACTOR].ammo_amount 7 tmp
		subvar tmp 35
		setplayer[THISACTOR].ammo_amount 7 tmp
	}
	addvar teslaalt 1
	ifvarg teslaalt 71 setvar teslaalt 0
	getplayer[THISACTOR].ammo_amount 7 tmp
	ifvarl tmp 35 { setvar teslaalt 0 }
}

ifvarn akimboteslaalt 0
ifvare teslaalt 0
{
	setplayer[THISACTOR].curr_weapon 7
	setplayer[THISACTOR].weapon_pos 0
	stopsound INSERT_CLIP
	stopsound SHOTGUN_COCK
	stopsound SELECT_WEAPON
	
	ifvare akimboteslaalt 35
	{
		eshoot ALTTESLA
		globalsound TESALTFR 
		getactor[RETURN].xoffset xoffset
		addvar xoffset -24
		setactor[RETURN].xoffset xoffset
		getplayer[THISACTOR].ammo_amount 7 tmp
		subvar tmp 35
		setplayer[THISACTOR].ammo_amount 7 tmp
	}
	ifvare akimboteslaalt 38
	{
		eshoot ALTTESLA
		globalsound TESALTHT
		getactor[RETURN].xoffset xoffset
		addvar xoffset 24
		setactor[RETURN].xoffset xoffset
		getplayer[THISACTOR].ammo_amount 7 tmp
		subvar tmp 35
		setplayer[THISACTOR].ammo_amount 7 tmp
	}
	ifvare akimboteslaalt  7 { sound TALTAC3 }
	ifvare akimboteslaalt 10 { sound TESLAZ1 sound TESLAZ2 }
	
	
	addvar akimboteslaalt 1
	ifvarg akimboteslaalt 43 setvar akimboteslaalt 0
}

//------------------------------HELLSTAFF CODE

ifvare CURRWEAP 8
ifp palive
{
	getplayer[THISACTOR].kickback_pic temp
	ifvare temp 1 { globalsound LALTFR1 }
	ifvarg temp 9 ifvarl temp 62
	{
		ifvarand temp 3 { modvar temp 3 }
		ifvare temp 1
		{ 
			getplayer[THISACTOR].ammo_amount 8 tmp
			ifvarg tmp 0
			ifvarn tmp 1
			{ 
				subvar tmp 1
				setplayer[THISACTOR].ammo_amount 8 tmp
				eshoot STAFFPROJ
				getplayer[THISACTOR].ang temp
				randvar tmp 32
				ifrnd 128  addvarvar temp tmp else subvarvar temp tmp
				setactor[RETURN].ang temp
				getactor[RETURN].zvel zvel
				subvar zvel 128
				setvar tmp 0
				randvar tmp 256
				addvarvar zvel tmp
				setactor[RETURN].zvel zvel
			} 
			else
			{
				getactor[r0].extra extra
				subvar extra 1
				setactor[r0].extra extra
				getplayer[THISACTOR].ammo_amount 8 tmp
				subvar tmp 1
				setplayer[THISACTOR].ammo_amount 8 tmp
				eshoot STAFFPROJ
				getplayer[THISACTOR].ang temp
				randvar tmp 32
				ifrnd 128  addvarvar temp tmp else subvarvar temp tmp
				setactor[RETURN].ang temp
				getactor[RETURN].zvel zvel
				subvar zvel 128
				setvar tmp 0
				randvar tmp 256
				addvarvar zvel tmp
				setactor[RETURN].zvel zvel
			}
		} 
	}
	getplayer[THISACTOR].ammo_amount 8 temp
	ifvare temp 0 { setplayer[THISACTOR].ammo_amount 8 1 }
}

	
//------------------------------RESET ALTFIRE

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

//------------------------------AKIMBOCODE

// FLARE AKIMBO

ifvarg flakimbo 1 subvar flakimbo 1
ifvarl flakimbo -1
{
	addvar flakimbo 1
	ifvare flakimbo -1 setvar flakimbo 0
}

//SHOTGUN AKIMBO

ifvarg sgakimbo 1 subvar sgakimbo 1
ifvarl sgakimbo -1
{
	addvar sgakimbo 1
	ifvare sgakimbo -1 setvar sgakimbo 0
}

//TOMMYGUN AKIMBO

ifvarg tmakimbo 1 subvar tmakimbo 1
ifvarl tmakimbo -1
{
	addvar tmakimbo 1
	ifvare tmakimbo -1 setvar tmakimbo 0
}

//NAPALM AKIMBO

ifvarg npakimbo 1 subvar npakimbo 1
ifvarl npakimbo -1
{
	addvar npakimbo 1
	ifvare npakimbo -1 setvar npakimbo 0
}

//TESLAGUN AKIMBO

ifvarg tsakimbo 1 subvar tsakimbo 1
ifvarl tsakimbo -1
{
	addvar tsakimbo 1
	ifvare tsakimbo -1 setvar tsakimbo 0
}

ifvare CURRWEAP 1 ifvarg flakimbo 0
ifvare player[THISACTOR].kickback_pic 7
ifp palive
{
ifvare flarealt 0
	{	
		sound FLAREF
		eshoot FLARE
		getactor[RETURN].xoffset xoffset
		addvar xoffset 24
		setactor[RETURN].xoffset xoffset
		getplayer[THISACTOR].ammo_amount 1 tmp
		ifvarg tmp 0 subvar tmp 1
		setplayer[THISACTOR].ammo_amount 1 tmp
	} 
	else 
	{ 
		getplayer[THISACTOR].ammo_amount 1 ammo
		ifvarg ammo 7
		{
			setprojectile[FLARE].spawns EXPLOSION6
			setprojectile[FLARE].sxrepeat 32
			setprojectile[FLARE].syrepeat 32
			subvar ammo 8
			setplayer[THISACTOR].ammo_amount 1 ammo
			sound FLAREF
			eshoot FLARE
			setactorvar[RETURN].flarealtproj 1
			setactorvar[RETURN].flarefulldamage 1
			setactorvar[RETURN].noflarefire 1
			ifvarl flakimbo 1 { setvar flarealt 0 }
			setprojectile[FLARE].spawns FLAREFIRE
			setprojectile[FLARE].sxrepeat -1
			setprojectile[FLARE].syrepeat -1
		} else setplayer[THISACTOR].kickback_pic 0
		setvar flarealt 0
	}
}
ifvare CURRWEAP 2 ifvarg sgakimbo 0
ifvare player[THISACTOR].kickback_pic 5
ifp palive
{
ifvare shotgunalt 0
	{	
		sound SHOTFIRE
		shoot SHOTAMMO
		shoot SHOTAMMO
		shoot SHOTAMMO
		shoot SHOTAMMO
		shoot SHOTAMMO
		shoot SHOTAMMO
		shoot SHOTAMMO
		shoot SHOTAMMO
		shoot SHOTAMMO
		shoot SHOTAMMO
		shoot SHOTAMMO
		shoot SHOTAMMO
		shoot SHOTAMMO
		shoot SHOTAMMO

		getplayer[THISACTOR].ammo_amount 2 tmp
		ifvarg tmp 0 subvar tmp 1
		setplayer[THISACTOR].ammo_amount 2 tmp
		setvar shotgunalt 0
	} 
}
ifvarn akimboshotgunalt 0
{
		switch akimboshotgunalt
		case 1
		getplayer[THISACTOR].ammo_amount 2 tmp
		ifvarg tmp 3 
		{
			sound SHOTFIR2
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			shoot SHOTAMMO
			
			subvar tmp 4
			setplayer[THISACTOR].ammo_amount 2 tmp
		}
		break
		default break
		endswitch
		
		addvar akimboshotgunalt 1
		ifvarg akimboshotgunalt 24 setvar akimboshotgunalt 0
}

ifvare CURRWEAP 3 
{
getplayer[THISACTOR].kickback_pic temp
ifvarand temp 1
ifvare tmakimbo 1
ifp palive
ifvare akimbotommysweep 0
	{	
		sound TOM
		flash
		shoot TOMMYFIRST
		setvar xoffset 65 state tommyshellstate
		getplayer[THISACTOR].ammo_amount 3 tmp
		ifvarg tmp 0 subvar tmp 1
		setplayer[THISACTOR].ammo_amount 3 tmp
	} 
}

ifvarn akimbotommysweep 0
{
		setplayer[THISACTOR].curr_weapon 3
		setplayer[THISACTOR].weapon_pos 1
		stopsound INSERT_CLIP
		stopsound SHOTGUN_COCK
		stopsound SELECT_WEAPON
	
		getplayer[THISACTOR].ang ang
		setvarvar saveang ang
		switch akimbotommysweep
		case 2
		subvar ang 48
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 110 state tommyshellstate
		break
		case 4
		subvar ang 72
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 120 state tommyshellstate
		break
		case 6
		subvar ang 96
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 120 state tommyshellstate
		break
		case 8
		subvar ang 144
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 120 state tommyshellstate
		break
		case 10
		subvar ang 144
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 120 state tommyshellstate
		break
		case 12
		subvar ang 96
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 120 state tommyshellstate
		break
		case 14
		subvarvar ang 72
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 75 state tommyshellstate
		break
		case 16
		subvar ang 48
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 75 state tommyshellstate
		break
		case 18
		addvar ang 72
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 75 state tommyshellstate
		break
		case 20
		addvar ang 96
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 75 state tommyshellstate
		break
		case 22
		addvar ang 144
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 40 state tommyshellstate
		break
		case 24
		case 26
		addvar ang 144
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 40 state tommyshellstate
		break
		case 28
		addvar ang 96
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 60 state tommyshellstate
		break
		case 30
		addvar ang 72
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		setvar xoffset 75 state tommyshellstate
		break
		default break
		endswitch
		
		addvar akimbotommysweep 1 
		ifvarg akimbotommysweep 28 setvar akimbotommysweep 0
		getplayer[THISACTOR].ammo_amount 3 tmp
		ifvarl tmp 1 { setvar akimbotommysweep 0 }
}

ifvare CURRWEAP 4 ifvarg npakimbo 0
ifvare player[THISACTOR].kickback_pic 7
ifp palive
{
ifvare napalmalt 0
	{	
		sound NAPEXPL
		eshoot PR_NAPALM
		getactor[RETURN].xoffset xoffset
		addvar xoffset 24
		setactor[RETURN].xoffset xoffset
		getplayer[THISACTOR].ammo_amount 4 tmp
		ifvarg tmp 0 subvar tmp 1
		setplayer[THISACTOR].ammo_amount 4 tmp
	} 
	else 
	{ 
		getplayer[THISACTOR].ammo_amount 4 temp
		ifvarg temp 0
		{
		 sound NAPEXPL
		 eshoot ALTNAPALM
		 ifvarg temp 12 { setactorvar[RETURN].napalmammo 12 } else setactorvar[RETURN].napalmammo temp
		 ifvarg temp 11 { subvar tmp 12 } else setvar temp 0
		 getactor[RETURN].xoffset xoffset
		 addvar xoffset 24
	     setactor[RETURN].xoffset xoffset
		 setplayer[THISACTOR].ammo_amount 4 temp
		} 
		setvar napalmalt 0
	}
}

ifvare CURRWEAP 7 
ifvarg tsakimbo 0
ifvare teslaalt 0
ifvare akimboteslaalt 0
{	
		getplayer[THISACTOR].kickback_pic temp
		ifvarand temp 1 { modvar temp 1 }
		ifvarg temp 0
		{
			getplayer[THISACTOR].ammo_amount 7 tmp
			ifvarg tmp 0
			{
					subvar tmp 1
					setplayer[THISACTOR].ammo_amount 7 tmp
					sound TESSNGFR
					sound TESSNGHT
					eshoot PLASMAPROJ 
					getactor[RETURN].xoffset xoffset
					addvar xoffset 24
					setactor[RETURN].xoffset xoffset
			}
		}
} 

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

//Thanks to TheLezing for this code

  setvar r8 -16
  whilevarn r8 0 {
    addvar r8 1
    // Evaluate dynamics
    getplayer[THISACTOR].i r0
    getactor[r0].x r1
    addvarvar r1 camera_x
    shiftvarl r1 4
    subvarvar r1 HUDpx
    getactor[r0].y r2
    addvarvar r2 camera_y
    shiftvarl r2 4
    subvarvar r2 HUDpy
    getactor[r0].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
    setvar r4 256
    setvar r5 4096
    setvar r6 0
    // {r4, r5, r6} are coordinates of the balanced point
    getactor[r0].ang r7
    addvar r7 1536
    rotatepoint 0 0 r4 r5 r7 r4 r5
    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 r0
      getactor[r0].sectnum r0
      getsector[r0].lotag r0
      ifvare r0 2 {
        addvarvar HUDvz 16 // Gravity
        mulvar HUDvx 5 mulvar HUDvy 5 mulvar HUDvz 6
      } else {
        addvarvar HUDvz 32 // Gravity
        mulvar HUDvx 7 mulvar HUDvy 7 mulvar HUDvz 7
      }
      shiftvarr HUDvx 4 shiftvarr HUDvy 4 shiftvarr HUDvz 4
    }
  }
  // Get projection
  getplayer[THISACTOR].i r0
  getactor[r0].x r1
  addvarvar r1 camera_x
  shiftvarl r1 4
  subvarvar r1 HUDpx
  getactor[r0].y r2
  addvarvar r2 camera_y
  shiftvarl r2 4
  subvarvar r2 HUDpy
  getactor[r0].z r3
  addvarvar r3 camera_z
  
  subvarvar r3 HUDpz
  getactor[r0].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 r0 // Debug info
  setvarvar r1 HUDpx
  shiftvarr r1 4
  setactor[r0].x r1
  setvarvar r2 HUDpy
  shiftvarr r2 4
  setactor[r0].y r2
  updatesector r1 r2 r3
  setactor[r0].sectnum r3 */
  
 //------------------------------END HUDCOORDFIX
 
 //Thanks to DeeperThought for this code
 
 	// check floor type
	getsector[THISACTOR].floorpicnum picnum
	ifvare picnum 6236
	{
		getplayer[THISACTOR].cursectnum temp
		ifvarn temp -1 
		{
			getplayer[THISACTOR].posx x
			getplayer[THISACTOR].posy y
			getplayer[THISACTOR].posz z
			addvar z 8192
			getflorzofslope temp x y mz
			subvarvar mz z
			ifvarl mz 2048
			{
				addphealth -1
				palfrom 16 16
			}
		}
	}	

  ifvarn tommysweep 0
	{
		setplayer[THISACTOR].curr_weapon 3
		setplayer[THISACTOR].weapon_pos 1
		stopsound INSERT_CLIP
		stopsound SHOTGUN_COCK
		stopsound SELECT_WEAPON
		
		getplayer[THISACTOR].ang ang
		setvarvar saveang ang
		switch tommysweep
		case 2
		state tommyfire
		ifvare tmakimbo 0 { setvar xoffset -5 state tommyshellstate } else { setvar xoffset -70 state tommyshellstate }
		break
		case 4
		subvar ang 24
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		ifvare tmakimbo 0 { setvar xoffset 30 state tommyshellstate } else { setvar xoffset -40 state tommyshellstate }
		break
		case 6
		subvar ang 48
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		ifvare tmakimbo 0 { setvar xoffset 30 state tommyshellstate } else { setvar xoffset -40 state tommyshellstate }
		break
		case 8
		subvar ang 72
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		ifvare tmakimbo 0 { setvar xoffset 30 state tommyshellstate } else { setvar xoffset -40 state tommyshellstate }
		break
		case 10
		subvar ang 72
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		ifvare tmakimbo 0 { setvar xoffset 30 state tommyshellstate } else { setvar xoffset -40 state tommyshellstate }
		break
		case 12
		subvar ang 48
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		ifvare tmakimbo 0 { setvar xoffset 30 state tommyshellstate } else { setvar xoffset -40 state tommyshellstate }
		break
		case 14
		subvar ang 24
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		ifvare tmakimbo 0 { setvar xoffset 10 state tommyshellstate } else { setvar xoffset -70 state tommyshellstate }
		break
		case 16
		state tommyfire
		ifvare tmakimbo 0 { setvar xoffset -10 state tommyshellstate } else { setvar xoffset -70 state tommyshellstate }
		break
		case 18
		addvar ang 24
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		ifvare tmakimbo 0 { setvar xoffset -15 state tommyshellstate } else { setvar xoffset -70 state tommyshellstate }
		break
		case 20
		addvar ang 48
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		ifvare tmakimbo 0 { setvar xoffset -30 state tommyshellstate } else { setvar xoffset -90 state tommyshellstate }
		break
		case 22
		addvar ang 72
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		ifvare tmakimbo 0 { setvar xoffset -70 state tommyshellstate } else { setvar xoffset -120 state tommyshellstate }
		break
		case 24
		addvar ang 72
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		ifvare tmakimbo 0 { setvar xoffset -70 state tommyshellstate } else { setvar xoffset -120 state tommyshellstate }
		break
		case 26
		addvar ang 48
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		ifvare tmakimbo 0 { setvar xoffset -70 state tommyshellstate } else { setvar xoffset -120 state tommyshellstate }
		break
		case 28
		case 30
		addvar ang 24
		setplayer[THISACTOR].ang ang
		state tommyfire
		setplayer[THISACTOR].ang saveang
		ifvare tmakimbo 0 { setvar xoffset -50 state tommyshellstate } else { setvar xoffset -80 state tommyshellstate }
		break
		default break
		endswitch
		
		addvar tommysweep 1
		ifvarg tommysweep 28 setvar tommysweep 0
		getplayer[THISACTOR].ammo_amount 3 tmp
		ifvarl tmp 1 { setvar tommysweep 0 }
	}

	ifp pjumping ifcount 12 { globalsound JUMP resetcount }
	
	ifinwater
	{
		stopsound DUKE_LONGTERM_PAIN
		ifvarl HEALTHAMOUNT 45 ifvare player[THISACTOR].airleft 0 { ifp palive sound PAIN5 }
	}
	
  ifaction 0
    action PSTAND
	
  ifdead
  {
	setactorvar[THISACTOR].handattack 0 
	setactorvar[THISACTOR].active 0
	setplayer[THISACTOR].kickback_pic 0
	setvar COUNTER 0
	setactorvar[THISACTOR].pfire 0
	setactorvar[THISACTOR].bodyshield 0
	setactorvar[THISACTOR].fireshield 0
	setactorvar[THISACTOR].spiritshield 0
	setvarvar SAVED_BODYSHIELD 0
	setvarvar SAVED_FIRESHIELD 0
	setvarvar SAVED_SPIRITSHIELD 0
	
	setactorvar[THISACTOR].reflective 0
	setvar TNT_AMMOAMOUNT 0
	setvar REMOTETNT_AMMOAMOUNT 0
	setvar PROXIMITYMINE_AMMOAMOUNT 0
	setactorvar[THISACTOR].burningguyactive 0
	setactorvar[THISACTOR].flamedamage 0
	stopsound PROXDET
	stopsound TNTFUSE
	setvar teslaalt 0
	setvar akimboteslaalt 0
	setvar dtime 0
	setvar deactiveakimbo 1
	setvar LIGHTERENABLE 0
	setvar TNTCOUNT 0
	setvar SHOOTTNT 0
	setvar sprayfire -1
	setvar sprayalt 0
	
    ifaction PGROWING
    {
	      ifmove 1
	      {
	        quote 13
	        ifhitspace
	        {
	          action 0
	          resetplayer
	        }
	        break
	      }
	      else
	      {
	        ifcount 32
	        {
	          sound SQUISHED
	          palfrom 48 64

	          state standard_pjibs

	          guts JIBS4 20
	          guts JIBS6 20
	          move 1
	          cstat 32768

	          hitradius 2048 60 70 80 90

	        }
	        else
	          sizeto MAXXSTRETCH MAXYSTRETCH
	      }
	      break
    }

    ifsquished
      palfrom 32 63 63 63
    else
      fall

    ifactioncount 7
      move 0

    ifaction PLYINGDEAD
    {
      ifactioncount 3
        move PSTOPED
      quote 13
      ifhitspace
      {
        action PSTAND
        spawn CALEBLYINGDEAD
        resetplayer
      }
      break
    }

    ifaction PTHROWNBACK
    {
      ifactioncount 5
      {
        spawn BLOODPOOL
        action PLYINGDEAD
      }
      else
        ifactioncount 1
          move 0
      break
    }

    ifaction PEXPLODEAD
    {
      quote 13
      ifhitspace
      {
        resetplayer
        action PSTAND
      }
      break
    }
    ifaction PEXPLODE
    {
      ifactioncount 5
      {
        action PEXPLODEAD
        spawn BLOODPOOL
      }
      break
    }

     ifinwater
     {
        action PLYINGDEAD
        spawn WATERBUBBLE
        spawn WATERBUBBLE
     }
     else
     {
       action PEXPLODE
       state standard_pjibs
	   state jibs_state
       sound SQUISHED
       { ifrnd 96 sound DIE1 else ifrnd 96 sound DIE2 else sound DIE3 }
     }
    break
  }
  
  // end ifdead

  
  // ----- FATALITY CODE

  ifmultiplayer
  ifvarn COOP 1
  {
	  ifvarl HEALTHAMOUNT 20
	  ifvare pmultivar 0  
	  {      
		getplayer[THISACTOR].posx fx
		getplayer[THISACTOR].posy fy
		getplayer[THISACTOR].posz fz
		getplayer[THISACTOR].ang fang
		action PFALL
		randvar FCOUNTRAND 100
		addvar FCOUNTRAND 150
		setplayer[THISACTOR].movement_lock 15
		setactorvar[THISACTOR].playerdrunk 300
		setvar fatalvar 1
		setvar pmultivar 1
		break
	  }
	  ifaction PFALL
	  {
		setplayer[THISACTOR].posx fx
		setplayer[THISACTOR].posy fy
		setplayer[THISACTOR].posz fz
		setplayer[THISACTOR].ang fang
		setplayer[THISACTOR].weapon_pos 20
		
	    ifactioncount 3 
			action PFATALITY
				break 
	  }
	  ifaction PFATALITY
	  {
		setplayer[THISACTOR].posx fx
		setplayer[THISACTOR].posy fy
		setplayer[THISACTOR].posz fz
		setplayer[THISACTOR].ang fang
		setplayer[THISACTOR].weapon_pos 20
		addvar FCOUNT 1
		getinput[THISACTOR].extbits temp
		ifvarvarg FCOUNT FCOUNTRAND 
		{ 
			ifvarn temp 0 { action PGETUP globalsound LIVEAGAIN setplayer[THISACTOR].movement_lock 0 setvar FCOUNT 0 setvar FCOUNTRAND 0 setvar fatalvar 0 setactorvar[THISACTOR].playerdrunk 0 break } 
			else ifcount 100 { action PDAMAGED break }
		}
		getactor[THISACTOR].htextra htextra
		ifhitweapon { strength 1 ifvarl htextra 20 action PDAMAGED else action PDAMAGED2 }
	  }

	ifaction PDAMAGED
    {
		setvar FCOUNT 0 setvar FCOUNTRAND 0 
		setplayer[THISACTOR].posx fx
		setplayer[THISACTOR].posy fy
		setplayer[THISACTOR].posz fz
		setplayer[THISACTOR].ang fang
		setplayer[THISACTOR].weapon_pos 20
		palfrom 64 64
		setvar fataldead 1
		sound DIE1
		  ifactioncount 6
		  {
			spawn BLOODPOOL
			action PDEAD
		  }
		  break
    }
	
	ifaction PDAMAGED2
    {
		setvar FCOUNT 0 setvar FCOUNTRAND 0 
		setplayer[THISACTOR].posx fx
		setplayer[THISACTOR].posy fy
		setplayer[THISACTOR].posz fz
		setplayer[THISACTOR].ang fang
		setplayer[THISACTOR].weapon_pos 20
		
		ifvare fataltmp 0
		{
			setprojectile[ZOMBIEHEAD].vel 60 
			ezshoot -1024 ZOMBIEHEAD 
			getactor[RETURN].z z 
			addvar z -3800 
			setactor[RETURN].z z
			setvar fataltmp 1
		}
		
		palfrom 64 64
		setvar fataldead 1
		sound DIE1
		  ifactioncount 5
		  {
			spawn BLOODPOOL
			action PDEAD2
		  }
		  break
    }
	  
	  ifaction PGETUP
	  {
		setplayer[THISACTOR].posx fx
		setplayer[THISACTOR].posy fy
		setplayer[THISACTOR].posz fz
		setplayer[THISACTOR].ang fang
		
		ifactioncount 3
			action PSTAND
				break
	  }
	  
	  ifaction PDEAD
	  {
		setplayer[THISACTOR].posx fx
		setplayer[THISACTOR].posy fy
		setplayer[THISACTOR].posz fz
		setplayer[THISACTOR].weapon_pos 20
		ifactioncount 3
        move PSTOPED
		quote 13
	    ifhitspace
		{	
			setactorvar[THISACTOR].playerdrunk 0
			setplayer[THISACTOR].movement_lock 0
			action PSTAND
			spawn PDEAD_FATALITY1
			setvar pmultivar 0
			setvar fatalvar 0
			setvar fataldead 0
			resetplayer
		}
	    break
	  }
	  ifaction PDEAD2
	  {
		setplayer[THISACTOR].posx fx
		setplayer[THISACTOR].posy fy
		setplayer[THISACTOR].posz fz
		setplayer[THISACTOR].weapon_pos 20
		ifactioncount 3
        move PSTOPED
		quote 13
	    ifhitspace
		{
			setactorvar[THISACTOR].playerdrunk 0
			setplayer[THISACTOR].movement_lock 0
			action PSTAND
			spawn PDEAD_FATALITY1
			setvar pmultivar 0
			setvar fataltmp 0
			setvar fatalvar 0
			setvar fataldead 0
			resetplayer
		}
	    break
	  }

	  ifvarg HEALTHAMOUNT 20 { setvar pmultivar 0 }
  }
  
  ifsquished
  {
    strength -1
    sound SQUISHED
    state random_ooz
    break
  }

  ifp ponsteroids
  {
    ifp pstanding nullop
    else
      spawn FRAMEEFFECT1
  }
  else ifhitweapon
  {
	  state bloodsprayshit
	  ifdead { ifrnd 96 sound DIE1 else ifrnd 96 sound DIE2 else sound DIE3 } else
	    {
			ifvarg HEALTHAMOUNT 89 sound DUKE_LONGTERM_PAIN else
			ifvarg HEALTHAMOUNT 79 ifvarl HEALTHAMOUNT 90 sound DUKE_LONGTERM_PAIN2 else
			ifvarg HEALTHAMOUNT 69 ifvarl HEALTHAMOUNT 80 sound DUKE_LONGTERM_PAIN3 else
			ifvarg HEALTHAMOUNT 59 ifvarl HEALTHAMOUNT 70 sound DUKE_LONGTERM_PAIN6 else
			ifvarg HEALTHAMOUNT 49 ifvarl HEALTHAMOUNT 60 sound DUKE_LONGTERM_PAIN5 else
			ifvarg HEALTHAMOUNT 39 ifvarl HEALTHAMOUNT 50 sound DUKE_LONGTERM_PAIN4 else
			ifvarg HEALTHAMOUNT 29 ifvarl HEALTHAMOUNT 40 sound PAIN1 else
			ifvarg HEALTHAMOUNT 19 ifvarl HEALTHAMOUNT 30 sound DUKE_LONGTERM_PAIN8 else
			ifvarg HEALTHAMOUNT 0 ifvarl HEALTHAMOUNT 20 sound DUKE_LONGTERM_PAIN7
	    }
	    ifstrength TOUGH
	    {
	      sound DUKE_GRUNT
		}

	    ifwasweapon RPG
	    {
	      ifrnd 32
	        spawn BLOOD
	      ifdead
		  ifvarn DEATHMASK_ON 1
	        state standard_pjibs
	      palfrom 48 52
	      break
	    }
	    ifwasweapon RADIUSEXPLOSION
	    {
	      ifrnd 32
	        spawn BLOOD
	      ifdead
	        state standard_pjibs
			stopsound PLAY1118 stopsound PLAY1119 stopsound PLAY1120 ifrnd 96 sound DIE1 else ifrnd 96 sound DIE2 else sound DIE3
	      palfrom 48 52
	      break
	    }
	    ifwasweapon FIREEXT
	    {
	      ifrnd 32
	        spawn BLOOD
	      ifdead
	        state standard_pjibs
	      palfrom 48 52
	      break
	    }
	    ifwasweapon SHOTSPARK1
	      palfrom 24 48
	    ifwasweapon COOLEXPLOSION1
	      palfrom 48 48 0 48
	    ifwasweapon KNEE
	      palfrom 16 32
	    ifwasweapon FIRELASER
	      palfrom 32 32

	    ifdead
	    {
	      action PTHROWNBACK
	      //tossweapon
	    }

	    state random_wall_jibs

	    break
  }

  ifinwater
  {
    ifaction PTREDWATER
    {
      ifp pwalking prunning
        action PSWIMMINGGO
    }
    else
      ifp pstanding pwalkingback prunningback
        action PTREDWATER
    else
    {
      ifaction PSWIMMING
      {
        ifrnd 4
          spawn WATERBUBBLE
        ifactioncount 4
          action PSWIMMINGWAIT
      }
      else
        ifaction PSWIMMINGWAIT
      {
        ifactioncount 2
          action PSWIMMINGGO
      }
      else
        ifaction PSWIMMINGGO
      {
        ifactioncount 2
          action PSWIMMING
      }
      else
        action PTREDWATER
    }

    ifrnd 4
      spawn WATERBUBBLE // For effect

    break
  }
  else ifp pjetpack
  {
    ifaction PJPHOUVER
    {
      ifactioncount 4
        resetactioncount
    }
    else
      action PJPHOUVER
    break
  }
  else
  {
    ifaction PTREDWATER
      action PSTAND
    ifaction PSWIMMING
      action PSTAND
    ifaction PSWIMMINGWAIT
      action PSTAND
    ifaction PSWIMMINGGO
      action PSTAND
    ifaction PJPHOUVER
      action PFALLING
  }

  ifaction PFALLING
  {
    ifp ponground
      action PSTAND
    else
    {
      ifp pfalling
        break
      else
        state check_pstandard
    }
  }

  ifaction PDUCKING
  {
    ifgapzl 48
    {
      ifp pwalking pwalkingback prunning prunningback
        action PCRAWLING
    }
    else ifp pducking
    {
      ifp pwalking pwalkingback prunning prunningback
        action PCRAWLING
    }
    else
    {
      ifp pstanding
        action PSTAND
      else
        state check_pstandard
    }
  }

  else ifaction PCRAWLING
  {
    ifgapzl 48
    {
      ifp pstanding
        action PCRAWLING
    }
    else
      ifp pducking
    {
      ifp pstanding
        action PDUCKING
    }
    else
    {
      ifp pstanding
        action PSTAND
      else
        state check_pstandard
    }
  }
  else
    ifgapzl 48
      action PDUCKING

  else
    ifaction PJUMPING
  {
    ifp ponground
      action PSTAND
    else
      ifactioncount 4
        ifp pfalling
          action PFALLING
  }

  ifp pfalling
    action PFALLING
  else
    ifaction PSTAND
      state check_pstandard
  else
    ifaction PAKICKING
  {
    ifactioncount 2
      action PSTAND
    break
  }
  else
    ifaction PWALK
  {
    ifp pfalling
      action PFALLING
    else
      ifp pstanding
        action PSTAND
    else
      ifp prunning
        action PRUN
    else
      ifp pwalkingback
        action PWALKBACK
    else
      ifp prunningback
        action PRUNBACK
    else
      ifp pjumping
        action PJUMPING
    else
      ifp pducking
        action PDUCKING
  }

  else
    ifaction PRUN
  {
    ifp pstanding
      action PSTAND
    else
      ifp pwalking
        action PWALK
    else
      ifp pwalkingback
        action PWALKBACK
    else
      ifp prunningback
        action PRUNBACK
    else
      ifp pjumping
        action PJUMPING
    else
      ifp pducking
        action PDUCKING
  }

  else
    ifaction PWALKBACK
  {
    ifp pstanding
      action PSTAND
    else
      ifp pwalking
        action PWALK
    else
      ifp prunning
        action PRUN
    else
      ifp prunningback
        action PRUNBACK
    else
      ifp pjumping
        action PJUMPING
    else
      ifp pducking
        action PDUCKING
  }

  else
    ifaction PRUNBACK
  {
    ifp pstanding
      action PSTAND
    else
      ifp pwalking
        action PWALK
    else
      ifp prunning
        action PRUN
    else
      ifp pwalkingback
        action PWALKBACK
    else
      ifp pjumping
        action PJUMPING
    else
      ifp pducking
        action PDUCKING
  }
 enda