//------------------------------BLOATED BUTCHER CODE

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

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

actor BUCHERFLYAXE 0 AXEFRAME1 sizeat  18 18 enda

defineprojectile BUCHERFLYAXE PROJ_WORKSLIKE 32770
defineprojectile BUCHERFLYAXE PROJ_HITRADIUS 0
defineprojectile BUCHERFLYAXE PROJ_EXTRA 8
defineprojectile BUCHERFLYAXE PROJ_EXTRA_RAND 4
defineprojectile BUCHERFLYAXE PROJ_SPAWNS BUCHERAXESPAWN
defineprojectile BUCHERFLYAXE PROJ_VEL 300 
defineprojectile BUCHERFLYAXE PROJ_CLIPDIST 32
defineprojectile BUCHERFLYAXE PROJ_TRAIL BUCHERFLYAXE
defineprojectile BUCHERFLYAXE PROJ_XREPEAT 18
defineprojectile BUCHERFLYAXE PROJ_YREPEAT 18
defineprojectile BUCHERFLYAXE PROJ_CSTAT 128

actor BUCHERSLIME 0 FRAME1 enda

defineprojectile BUCHERSLIME PROJ_WORKSLIKE 32770
defineprojectile BUCHERSLIME PROJ_HITRADIUS 0
defineprojectile BUCHERSLIME PROJ_EXTRA 6
defineprojectile BUCHERSLIME PROJ_EXTRA_RAND 4
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

defineprojectile BUCHERAXE PROJ_WORKSLIKE 4097
defineprojectile BUCHERAXE PROJ_SPAWNS SHOTSPARK1
defineprojectile BUCHERAXE PROJ_XREPEAT 3
defineprojectile BUCHERAXE PROJ_YREPEAT 3
defineprojectile BUCHERAXE PROJ_DECAL -1
defineprojectile BUCHERAXE PROJ_RANGE 1024

action ABUTCHERWALK  0  4  -5  1  20
action ABUTCHERSTAY  0  1  -5  1  1
action ABUTCHERATTACK1 48 5 -5 1 20
action ABUTCHERATTACK2 48 5 -5 1 20
action ABUTCHERATTACK3 2234 4 -5 1 25
action ABUTCHERDYING 30 6 1 1 20
action ABUTCHERDEAD 35 1 1 1 20
action ABUTCHERGUTS 73 7 1 1 20
action ABUTCHERGUTS2 82 1 1 1 1
action ABUTCHERTESLA 2298 1 -5 1 1
action ABUTCHERVOODOO1 -34 5 1 1 15
action ABUTCHERVOODOO2 -28 1 1 1 15
action ABUTCHERVOODOO3 -28 4 1 1 15
action ABUTCHERVOODOO4 -23 1 1 1 1

move BUTCHERWALK 0 0
move BUTCHERSTOP 

ai AIBUTCHERWALK ABUTCHERWALK BUTCHERWALK 
ai AIBUTCHERWALKLEFT ABUTCHERWALK BUTCHERWALK 
ai AIBUTCHERWALKRIGHT ABUTCHERWALK BUTCHERWALK 
ai AIBUTCHERRANDOM ABUTCHERWALK BUTCHERWALK
ai AIBUTCHERATTACK1 ABUTCHERATTACK1 BUTCHERSTOP  
ai AIBUTCHERATTACK2 ABUTCHERATTACK2 BUTCHERSTOP  
ai AIBUTCHERATTACK3 ABUTCHERATTACK3 BUTCHERSTOP 
ai AIBUTCHERGUTS ABUTCHERGUTS BUTCHERSTOP
ai AIBUTCHERGUTS2 ABUTCHERGUTS2 BUTCHERSTOP
ai AIBUTCHERSTAYPUT ABUTCHERSTAY BUTCHERSTOP
ai AIBUTCHERDYING ABUTCHERDYING BUTCHERSTOP
ai AIBUTCHERDEAD ABUTCHERDEAD BUTCHERSTOP
ai AIBUTCHERTESLA ABUTCHERTESLA BUTCHERSTOP
ai AIBUTCHERVOODOO1 ABUTCHERVOODOO1 BUTCHERSTOP
ai AIBUTCHERVOODOO2 ABUTCHERVOODOO2 BUTCHERSTOP
ai AIBUTCHERVOODOO3 ABUTCHERVOODOO3 BUTCHERSTOP
ai AIBUTCHERVOODOO4 ABUTCHERVOODOO4 BUTCHERSTOP

state bucherslimeshoot
sound FZOMPUKE
ezshoot 0 BUCHERSLIME
getactor[THISACTOR].z z
subvarvar z height
subvarvar z 2560
setactor[RETURN].z z
setactor[RETURN].ang enemy_ang
ends

eventloadactor BUTCHER 
setactor[THISACTOR].xrepeat 30
setactor[THISACTOR].yrepeat 30
getactor[THISACTOR].ang ang
setvarvar enemy_ang ang
enda

spriteshadow BUTCHER
spritenoshade BUTCHER
useractor notenemy BUTCHER BUTCHERSTRENGTH sizeat 30 30
	fall
	setvar maxSpeed 40
	setvar weight 1
	setvar addition_weight 2
	setvar width 128
	setvar height 8192
	setvar enemy_nohitscan_z 0
	setvar cantseetarget 0
	setvar fly_enemy 0
	
	ifai NO { addvar TOTALKILLS 1 cstat 257 setvarvar enemy_type STAYPUT setvarvar change_ai enemy_type }
	
	ifvare enemy_type STAYPUT  { 
		ifvare change_ai STAYPUT {
			ai AIBUTCHERSTAYPUT 
			setvar change_ai -1 
		}
		
		ifvare change_ai -1 {
			ifp palive ifcansee {
				state facingstate 
				ifvare set 1 {
					setvarvar target_id PLAYERID 
					soundonce FZOMSPOT 
					setvar enemy_movtype WALK
					setvar change_ai WALK
				}
			}
		}
	}
	
	state mainAI
	
	ifvare enemy_type WALK {
	
		ifvare change_ai WALK {
			ai AIBUTCHERWALK
			setvar change_ai -1 
		}
		
		ifvarl targetdist 650
			ifvarg anglefield -384 ifvarl anglefield 384
				ifvarn enemy_invis 1
					setvarvar enemy_ang enemy_hita
				
		ifvarn target_id -1		
		ifcansee ifvarg sprite[target_id].extra 0 { 
			ifvarl enemyroam 4 soundonce FZOMROAM else ifvarg enemyroam 4 ifvarl enemyroam 8 soundonce FZOMSPOT 
		}
		
		ifvarvare target_id PLAYERID
		ifvarvare enemy_hittid target_id {
			ifvarg anglefield -128 ifvarl anglefield 128 {
				ifvarn enemy_movtype EVASION  
				ifvarn enemy_movtype BLOCK {
					ifvarg sprite[target_id].extra 0
					ifvarn actorvar[target_id].invisible 1 {
						setvarvar enemy_ang enemy_hita
						ifvarg targetdist 1536 ifvarl targetdist 3092 {
							setvar enemy_type ATTACK
							ai AIBUTCHERATTACK3
							setvar change_ai USERAI
						} else
						ifvarg targetdist 3092 ifvarl targetdist 4096 {
							setvar enemy_type ATTACK
							ai AIBUTCHERATTACK2
							setvar change_ai USERAI
						}
					}
				}
			}			
		}	
	}
	
	ifvare enemy_type ATTACK {
		ifvare change_ai ATTACK {
			ai AIBUTCHERATTACK1 
			setvar change_ai USERAI
		}
		
		ifai AIBUTCHERATTACK2 { //fly axe
			ifactioncount 3 
			ifvare shoot_var 0 {
				eshoot BUCHERFLYAXE
				setactor[RETURN].ang enemy_ang
				setvar shoot_var 1
			}
			
			ifactioncount 5 { 
				setvar enemy_type WALK
				setvar change_ai WALK
				setvar shoot_var 0 
				resetactioncount 
			}
		}
		
		ifai AIBUTCHERATTACK3 { //green slime
			ifactioncount 3 
			ifvare shoot_var 0 {
				state bucherslimeshoot
				setvar shoot_var 1
			}
			
			ifactioncount 4 { 
				setvar enemy_type WALK
				setvar change_ai WALK
				setvar shoot_var 0 
				resetactioncount 
			}
		}
		
		ifai AIBUTCHERATTACK1 { 
			ifvare shoot_var 0 {
				ifactioncount 2 {
					sound AZOMSWIP 
					ifvarl targetdist 600 {
						ifvarg anglefield -128 ifvarl anglefield 128 {
							ifvarn enemy_refl 1
								shoot BUCHERAXE 
							else 
								setvar hitself 1
							
						}
						else
							zshoot 8192 BUCHERAXE
					} else zshoot 8192 BUCHERAXE
					setvar shoot_var 1
				}
			}
			ifactioncount 5 { 
				ifvare hitself 1 {
					state bloodspraystate 
					getactor[THISACTOR].extra extra
					getprojectile[BUCHERAXE].extra tmp
					subvarvar extra tmp
					setactor[THISACTOR].extra extra
					ifvarg extra 0 { soundonce AZOMPAIN setvar enemy_type GETDAMAGE setvar change_ai GETDAMAGE } else {
					setvar enemy_type DYING setvar change_ai DYING }
					
				}
			
				getactor[target_id].extra extra
				ifvarg targetdist 550 { 
					ai AIBUTCHERWALK setvar change_ai -1 
				} else {
					ifvarl extra 1 { ai AIBUTCHERWALK setvar change_ai -1 } else
					ifvarg anglefield -128 ifvarl anglefield 128 ifvarn enemy_invis 1 nullop else {
					ai AIBUTCHERWALK setvar change_ai -1
					}
				}
				
				setvar hitself 0
				setvar shoot_var 0 
				resetactioncount 
			}
			ifvarl targetdist 600
				ifvarg anglefield -128 ifvarl anglefield 128 
					ifvarn enemy_invis 1 {
					setactor[THISACTOR].ang enemy_hita
					setvarvar enemy_ang enemy_hita
				}
		}
	}
	
	ifvare enemy_type GETDAMAGE {
		ifvare change_ai GETDAMAGE {
			soundonce FZOMPAIN 
			ifvare teslahitenable 1 ai AIBUTCHERTESLA
			setvar change_ai USERAI
		}
		
		ifvare change_ai USERAI {
			ifvare teslahitenable 1 {
				ifai AIBUTCHERTESLA { sizeat 28 28 setvar enemy_tesla 1 ifcount 30 { ai AIBUTCHERWALK setvar teslahitenable 0 setvar enemy_tesla 0 setvar change_ai -1 }  }			
			} else {
				ifcount 5 { 
					setvar enemy_type WALK
					setvar change_ai WALK
				}
			}			
		}	
	}
	
	ifvare enemy_type GETHEAVYDAMAGE {
		ifvare change_ai GETHEAVYDAMAGE {
			state enemyjibs_state 
			cstat 0
			ai AIBUTCHERGUTS
			setvar burningguyactive 0
			setvar COUNTER 0
			setactor[THISACTOR].extra -100
			setvar change_ai USERAI
		}
		
		ifvare change_ai USERAI {
			ifai AIBUTCHERGUTS { ifactioncount 7 { cstat 0 ai AIBUTCHERGUTS2 setvar enemy_type DEAD setvar change_ai DEAD } }
		}
	}
	
	ifvare enemy_type VOODOO {
		ifvare change_ai VOODOO {
			cstat 0
			ai AIBUTCHERVOODOO1
			ifrnd 85 soundonce FZOMDIE1 else ifrnd 85 soundonce FZOMDIE2 else soundonce FZOMDIE3
			setvar change_ai USERAI
		}
		ifvare change_ai USERAI {
		    ifai AIBUTCHERVOODOO1 ifactioncount 5 ai AIBUTCHERVOODOO2
			ifai AIBUTCHERVOODOO2 ifcount 26 ai AIBUTCHERVOODOO3
			ifai AIBUTCHERVOODOO3 ifactioncount 4 { ai AIBUTCHERVOODOO4 setvar enemy_type DEAD setvar change_ai DEAD }
		}
	}

	ifvare enemy_type BURNING {
		espawn BURNINGGUY 
		setactor[THISACTOR].extra 0
		setactor[RETURN].xrepeat 34
		setactor[RETURN].yrepeat 26
		setactorvar[RETURN].bguy_id 3
		state enemykill_trigger
		setactorvar[RETURN].se_xvel se_xvel
		addkills 1 
		killit 
	}
	
	ifvare enemy_type DYING {
		ifvare change_ai DYING {
			setactor[THISACTOR].extra 0
			state bloodsprayshit 
			ifrnd 85 soundonce FZOMDIE1 else ifrnd 85 soundonce FZOMDIE2 else soundonce FZOMDIE3
			ai AIBUTCHERDYING
			ifrnd 128 cstat 4 else cstat 0
			setvar change_ai USERAI
		}
		
		ifvare change_ai USERAI {
			ifai AIBUTCHERDYING ifactioncount 6 { ai AIBUTCHERDEAD setvar change_ai -1 }
		}
	}

enda