action AHANDWALK  0  4  5  1  10
action AHANDSTOP  0  1  5  1  1
action AHANDATTACK 29 2 1 1 5
action AHANDDYING 34 5 1 1 10
action AHANDDEAD 39 1 1 1 10
action AHANDBURNING -287 6 1 1 15
action AHANDBURNED -280 1 1 1 1

move HANDWALK 0 //150
move HANDSTOP 

ai AIHANDWALK AHANDWALK HANDWALK faceplayer
ai AIHANDSEEK AHANDWALK HANDWALK seekplayer
ai AIHANDSTOP AHANDSTOP HANDSTOP
ai AIHANDATTACK AHANDATTACK HANDSTOP 
ai AIHANDDYING AHANDDYING HANDSTOP
ai AIHANDDEAD AHANDDEAD HANDSTOP
ai AIHANDBURNING AHANDBURNING HANDSTOP
ai AIHANDBURNED AHANDBURNED HANDSTOP

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

spritenoshade EVILHAND
spriteshadow EVILHAND

useractor notenemy EVILHAND EVILHANDSTRANGTH sizeat 30 30

	fall
	setvar maxSpeed 150
	setvar weight 2
	setvar width 64
	setvar height 768
	setvar enemy_nohitscan_z 1
	setvar cantseetarget 0
	setvar fly_enemy 0
	setactor[THISACTOR].clipdist 16
	
	ifvare handshock 1 {
		randvar peractor 16
		ifvare peractor 16
			setvar handshock 0 
	}
	
	ifai NO { addvar TOTALKILLS 1 cstat 257 setvarvar enemy_type STAYPUT setvarvar change_ai enemy_type }
	ifp phigher ifpdistl 600 ifvarg sprite[THISACTOR].extra 0 { setvar enemy_type DYING setvar change_ai DYING } 
	
	ifvare enemy_type STAYPUT  { 
		ifvare change_ai STAYPUT {
			ai AIHANDSTOP
			setvar change_ai -1 
		}
		
		ifvare change_ai -1 {
			ifp palive ifcansee {
				state facingstate 
				ifvare set 1 {
					setvarvar target_id PLAYERID 
					soundonce HANDROAM
					setvar enemy_movtype EVASION
					setvar change_ai WALK
				}
			}
		}
	}
	
	state mainAI
	
	ifvare enemy_type WALK {
		ifvare change_ai WALK {
			ai AIHANDWALK
			setvar change_ai -1 
		}
		ifcansee ifvarg sprite[target_id].extra 0 { ifvare enemyroam 1 soundonce HANDROAM else ifvare enemyroam 2 soundonce HANDSPOT }
	}
	
	ifvare enemy_type ATTACK {
		ifvare change_ai ATTACK {
			hitscan enemy_x enemy_y enemy_z enemy_hits enemy_hitcos enemy_hitsin 0 RETURN wallid RETURN RETURN RETURN RETURN 0x00000030h
			ifvarand wall[wallid].cstat 1 setvar change_ai -1 else {
				ifvare handshock 0 {
					ifvarl targetdist 550 {
						setactorvar[target_id].handattack 1
						killit
					} else setvar change_ai -1
				} else setvar change_ai -1
			}
		}
	}
	
	ifvare enemy_type GETDAMAGE {

		ifvare change_ai GETDAMAGE {
			soundonce HANDPAIN
			setvar change_ai USERAI
		}
		
		ifvare change_ai USERAI {
			ifcount 5 { 
				setvar enemy_type WALK
				setvar change_ai -1
			}	
		}	
		
	}
	
	ifvare enemy_type GETHEAVYDAMAGE {
		setvar enemy_type DYING 
		setvar change_ai DYING
	}
	
	ifvare enemy_type VOODOO {
		setvar enemy_type DYING 
		setvar change_ai DYING
	}

	ifvare enemy_type BURNING {
		ifvare change_ai BURNING {
			ai AIHANDBURNING
			setvar flamedamage 0
			setvar change_ai USERAI 
		}
		
		ifvare change_ai USERAI {
			ifai AIHANDBURNING { 
				ifactioncount 6 { ifrnd 128 cstat 4 else cstat 0 ai AIHANDBURNED } 
			}
			ifai AIHANDBURNED { setvar enemy_type DEAD setvar change_ai DEAD }
		}
	}
	
	ifvare enemy_type DYING {
		ifvare change_ai DYING {
			ifrnd 128 cstat 4 else cstat 0
			setactor[THISACTOR].extra 0 //чтобы при раздавливании код не повторялся несколько раз
			state bloodsprayshit 
			ifrnd 128 soundonce HANDDIE1 else soundonce HANDDIE2
			ai AIHANDDYING
			setvar change_ai USERAI
		}
		
		ifvare change_ai USERAI {
			ifai AIHANDDYING ifactioncount 5 { cstat 0 ai AIHANDDEAD setvar change_ai -1 }
		}
	}
	
enda