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

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

spritenoshade HELLFLAME
defineprojectile HELLFLAME PROJ_WORKSLIKE 6146
defineprojectile HELLFLAME PROJ_HITRADIUS 0
defineprojectile HELLFLAME PROJ_EXTRA 0
defineprojectile HELLFLAME PROJ_VEL 400
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 HELLFLAME 0 HELLFLAME_FRAME1 enda

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



//------------------------------HELL HOUND CODE

eventloadactor HELLDOG 
setactor[THISACTOR].xrepeat 30
setactor[THISACTOR].yrepeat 30
setactor[THISACTOR].extra HELLDOGSTRENGTH
enda

action AHELLDOGWALK  0  7  -5  1  8
action AHELLDOGSTAY  0  1  -5  1  8
action AHELLDOGATTACK 35 3 -5 1 22
action AHELLDOGBITE 40 1 -5 1 10
action AHELLDOGGUTS 50 5 1 1 20
action AHELLDOGGUTS2 55 1 1 1 1
action AHELLDOGDYING 405 7 1 1 15
action AHELLDOGDEAD 412 1 1 1 1
action AHELLDOGTESLA 2454 1 -5 1 1

move HELLDOGWALK //280
move HELLDOGSTOP 

ai AIHELLDOGWALK AHELLDOGWALK HELLDOGWALK faceplayer
ai AIHELLDOGSTAY AHELLDOGSTAY HELLDOGSTOP
ai AIHELLDOGBITE AHELLDOGBITE HELLDOGSTOP 
ai AIHELLDOGATTACK AHELLDOGATTACK HELLDOGSTOP faceplayer
ai AIHELLDOGDYING AHELLDOGDYING HELLDOGSTOP
ai AIHELLDOGGUTS AHELLDOGGUTS HELLDOGSTOP faceplayer
ai AIHELLDOGGUTS2 AHELLDOGGUTS2 HELLDOGSTOP faceplayer
ai AIHELLDOGDEAD AHELLDOGDEAD HELLDOGSTOP
ai AIHELLDOGTESLA AHELLDOGTESLA HELLDOGSTOP

spriteshadow HELLDOG
spritenoshade HELLDOG

useractor notenemy HELLDOG HELLDOGSTRENGTH sizeat 30 30
	fall
	setvar maxSpeed 200
	setvar weight 1
	setvar width 128
	setvar height 4096
	setvar enemy_nohitscan_z 1
	setvar cantseetarget 0
	setvar fly_enemy 0
	
	ifai NO { addvar TOTALKILLS 1 cstat 257 setvarvar enemy_type STAYPUT setvarvar change_ai enemy_type }
	ifinwater ifvarg sprite[THISACTOR].extra 0 { setvar enemy_type DYING setvar change_ai DYING } 
	ifonwater ifvarg sprite[THISACTOR].extra 0 { setvar enemy_type DYING setvar change_ai DYING } 
	
	ifvare enemy_type STAYPUT  { 
		ifvare change_ai STAYPUT {
			ai AIHELLDOGSTAY 
			setvar change_ai -1 
		}
		
		ifvare change_ai -1 {
			ifp palive ifcansee {
				state facingstate 
				ifvare set 1 {
					setvarvar target_id PLAYERID 
					soundonce CERBSPOT 
					setvar enemy_movtype WALK
					setvar change_ai WALK
				}
			}
		}
	}
	
	state mainAI
	
	ifvare enemy_type WALK {
	
		ifvare change_ai WALK {
			ai AIHELLDOGWALK
			setvar change_ai -1 
		}
		
		ifvarn target_id -1		
		ifcansee ifvarg sprite[target_id].extra 0 { 
			ifvarl enemyroam 2 soundonce CERBSPOT
		}
		
		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
					ifvarg targetdist 1536 ifvarl targetdist 2560 {
						setvar enemy_type ATTACK
						ai AIHELLDOGBITE
						setvar change_ai USERAI
					}
				}
			}			
		}	
	}
	
	ifvare enemy_type ATTACK {
		ifvare change_ai ATTACK {
			ai AIHELLDOGATTACK 
			setvar change_ai USERAI
		}
		
		ifai AIHELLDOGATTACK { 
			ifvare shoot_var 0 {
				ifactioncount 2 {
					ifvarl targetdist 600 {
						ifvarg anglefield -128 ifvarl anglefield 128 {
							ifvarn enemy_refl 1
								shoot HELLHIT 
							else 
								setvar hitself 1
							
						}
						else
							zshoot 8192 HELLHIT 
					} else zshoot 8192 HELLHIT 
					setvar shoot_var 1
				}
			}
			ifactioncount 3 { 
				ifvare hitself 1 {
					state bloodspraystate 
					getactor[THISACTOR].extra extra
					getprojectile[HELLHIT].extra tmp
					subvarvar extra tmp
					setactor[THISACTOR].extra extra
					ifvarg extra 0 { soundonce CERBPAIN 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 { 
					setvar enemy_type WALK
					setvarvar change_ai enemy_type
				} else {
					ifvarl extra 1 { setvar enemy_type WALK setvarvar change_ai enemy_type } else
					ifvarg anglefield -128 ifvarl anglefield 128 ifvarn enemy_invis 1 nullop else {
					setvar enemy_type WALK setvarvar change_ai enemy_type
					}
				}
				
				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
				}
		}
		
		ifai AIHELLDOGBITE {
			ifcount 5 {
				randvar peractor 32
				randvar zvel 1024
				getactor[THISACTOR].ang saveang
				getactor[THISACTOR].ang ang 
				ifrnd 128 addvarvar ang peractor 
				else subvarvar ang peractor
				ifrnd 128 mulvar zvel -1
				setactor[THISACTOR].ang ang 
				ezshootvar zvel HELLFLAME 
				getactor[THISACTOR].x x
				getactor[THISACTOR].y y
				setvarvar x2 x
				addvar x2 256
				rotatepoint x y x2 y ang x y
				setactor[RETURN].x x
				setactor[RETURN].y y
				setactor[THISACTOR].ang saveang 
				
				ifvare teslahitenable 1 {  //иначе анимация поражения не появляется, а собака продолжает стрелять
					ai AIHELLDOGTESLA 
					setvar enemy_type GETDAMAGE
				}
			}
			ifcount 26 { 
				ai AIHELLDOGWALK
				setvar change_ai -1
			}
		}
	}
	
	ifvare enemy_type GETDAMAGE {
		ifvare change_ai GETDAMAGE {
			soundonce CERBPAIN 
			ifvare teslahitenable 1 ai AIHELLDOGTESLA
			setvar change_ai USERAI
		}
		
		ifvare change_ai USERAI {
			ifvare teslahitenable 1 {
				ifai AIHELLDOGTESLA { sizeat 30 30 setvar enemy_tesla 1 ifcount 30 { ai AIHELLDOGWALK 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 AIHELLDOGGUTS
			setvar burningguyactive 0
			setvar COUNTER 0
			setactor[THISACTOR].extra -100
			setvar change_ai USERAI
		}
		
		ifvare change_ai USERAI {
			ifai AIHELLDOGGUTS { ifactioncount 5 { cstat 0 ai AIHELLDOGGUTS2 setvar enemy_type DEAD setvar change_ai DEAD } }
		}
	}
	
	ifvare enemy_type VOODOO {
		setvar enemy_type DYING 
		setvar change_ai DYING
	}

	
	ifvare enemy_type BURNING {
		setvar enemy_type DYING 
		setvar change_ai DYING
	}
	
	
	ifvare enemy_type DYING {
		ifvare change_ai DYING {
			setactor[THISACTOR].extra 0 //чтобы при утоплении код не повторялся несколько раз
			state bloodsprayshit 
			ifrnd 85 soundonce CERBDIE1 else ifrnd 85 soundonce CERBDIE2 else soundonce CERBDIE3
			ai AIHELLDOGDYING
			ifrnd 128 cstat 4 else cstat 0
			setvar change_ai USERAI
		}
		
		ifvare change_ai USERAI {
			ifai AIHELLDOGDYING ifactioncount 5 { ai AIHELLDOGDEAD setvar change_ai -1 }
		}
	}
	
enda


/*
useractor notenemy HELLDOG HELLDOGSTRENGTH fall
ifvare VISION 1 { setactor[THISACTOR].shade -127 } 
setactor[THISACTOR].clipdist 80
getplayer[THISACTOR].i PLAYERID	
getactorvar[PLAYERID].invisible invisible
ifp pdead setvar invisible 1
ifhitweapon { state helldoghurt }
ifai NO { addvar TOTALKILLS 1 sizeat 28 28 cstat 257 ai AIHELLDOGSTAY }
ifvarn invisible 1
{
ifai AIHELLDOGSTAY ifcansee ifp palive { state facingstate ifvare set 1 { soundonce CERBSPOT ai AIHELLDOGWALK } }
ifai AIHELLDOGWALK { ifrnd 1 ifcansee soundonce CERBSPOT ifpdistg 1536 ifpdistl 4096 ifcount 8 ai AIHELLDOGBITE else ifpdistl 1200 ai AIHELLDOGATTACK }
 
ifai AIHELLDOGBITE 
{ 
	randvar peractor 32
	randvar zvel 1024
	getactor[THISACTOR].ang saveang
	{ 
		getactor[THISACTOR].ang ang 
		ifrnd 128 
		addvarvar ang peractor else 
		{ subvarvar ang peractor ifrnd 128 mulvar zvel -1 }
		setactor[THISACTOR].ang ang 
		ezshootvar zvel HELLFLAME 
		getactor[THISACTOR].x x
		getactor[THISACTOR].y y
		setvarvar x2 x
		addvar x2 256
		rotatepoint x y x2 y ang x3 y3
		setactor[RETURN].x x3
		setactor[RETURN].y y3
		setactor[THISACTOR].ang saveang 
	} 
	ifcount 26 ai AIHELLDOGWALK
} 
ifai AIHELLDOGATTACK 
{ 
	getactorvar[PLAYERID].reflective reflective
	ifactioncount 2 
	ifpdistl 1200
	ifp palive
	ifvare peractor 0 
	{ 
		ifvare reflective 1
		{
			soundonce PFLESH  
			getactor[THISACTOR].extra extra
			subvar extra 10
			setactor[THISACTOR].extra extra
			state helldoghurt
		} 
		else
		{
			soundonce PFLESH  
			getactor[THISACTOR].ang ang
			setactor[PLAYERID].htang ang
			setactor[PLAYERID].htextra 10 
			getactor[PLAYERID].htextra paextra
			state checkb_armor
			palfrom 32 0 0 0
		}
		setvar peractor 1
	}
	ifactioncount 3 { ifpdistg 1200 { ai AIHELLDOGWALK } setvar peractor 0 resetactioncount } 
}
ifai AIHELLDOGRANDOM ifcansee ifp palive { ai AIHELLDOGSTAY } 
}
else
{
ifai AIHELLDOGATTACK ifactioncount 3 {  setvar peractor 0 ai AIHELLDOGRANDOM }
ifai AIHELLDOGBITE { ai AIHELLDOGRANDOM }
ifai AIHELLDOGWALK { ai AIHELLDOGRANDOM }
ifai AIHELLDOGRANDOM { ifrnd 1 ifcansee soundonce CERBSPOT ifcount 390 { ai AIHELLDOGSTAY resetcount break } }
}
ifai AIHELLDOGDYING { ifactioncount 7 { ai AIHELLDOGDEAD } }
ifai AIHELLDOGGUTS ifactioncount 5 { cactor 6445 }
getactorvar[THISACTOR].teslahitenable teslahitenable
ifvare teslahitenable 1 { getactor[THISACTOR].extra extra ifvarg extra 0 { ai AIHELLDOGTESLA } else { addkills 1 ifrnd 128 cstat 4 else cstat 0 ifrnd 85 soundonce CERBDIE1 else ifrnd 85 soundonce CERBDIE2 else soundonce CERBDIE3 ai AIHELLDOGDYING } setactorvar[THISACTOR].teslahitenable 0 }
ifai AIHELLDOGTESLA { randvar enemyshade 64 setactor[THISACTOR].shade enemyshade ifcount 10 { ai AIHELLDOGWALK }  }


ifvarg flamedamage 0 
{ 
	addvar COUNTER 1 
	ifinwater { setactorvar[THISACTOR].flamedamage 0 }
	else
	{
		eshoot NEWFIRE
		getactor[THISACTOR].x x
		getactor[THISACTOR].y y
		setvarvar x2 x
		addvarvar x2 256
		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
		addvarvar z 5120
		randvar tmp 8192
		ifrnd 128 mulvar tmp -1
		addvarvar z tmp
		setactor[RETURN].z z
	}
} 
ifinwater 
ifvare peractor2 0
{ 
	setvar COUNTER 0
	addkills 1
	setactor[THISACTOR].extra 0
	state helldoghurt
	setvar peractor2 1
}
ifvarvare COUNTER flamedamage { setvar flamedamage 0 setvar COUNTER 0 }

ifvare voodoohitenemy 1 
{ 
	setactor[THISACTOR].extra 0
	state helldoghurt
	setvar voodoohitenemy 0
}
getactorvar[THISACTOR].burningguyactive burningguyactive
ifvare burningguyactive 1
{
    addkills 1
	setactor[THISACTOR].extra 0
	state helldoghurt
	setactorvar[THISACTOR].burningguyactive 0
}
enda
*/