/*
0 - uh ah uh ah - no armor
1 - it burns - fire
2 - uh ah uh ah - body
3 - uh ah uh ah - fire
4 - undchoke - no armor
5 - uh ah uh ah - spirit
*/

eventloadactor DAMAGE_SECT
cstat 32768
getactor[THISACTOR].lotag LOTAGSAVED
setactor[THISACTOR].lotag 0
getactor[THISACTOR].hitag HITAGSAVED
setactor[THISACTOR].hitag 0
enda

gamevar armorcount 0 2
gamevar healthcount 0 2
gamevar blood_corr 0 2

actor DAMAGE_SECT
getuserdef[PLAYERID].god godmode
getactor[THISACTOR].sectnum sect2
getplayer[THISACTOR].cursectnum sect1
ifvarvare sect2 sect1
ifp palive
ifvare godmode 0
{
	getplayer[THISACTOR].i PLAYERID
	getplayer[THISACTOR].posx x
	getplayer[THISACTOR].posy y
	getplayer[THISACTOR].posz z
	addvar z 9216
	getflorzofslope sect1 x y mz
	subvarvar mz z
	ifvarl mz 2048
	{
		addvarvar COUNTER HITAGSAVED
		switch LOTAGSAVED
			case 0
			case 4
				ifvarg COUNTER 29 {
					addphealth -1
					ifvare LOTAGSAVED 0 { ifrnd 64 soundonce PLAY1118 else ifrnd 64 soundonce PLAY1119 else soundonce PLAY1120 } 
						else soundonce PAIN5
					setvar COUNTER 0
				}
			break
			case 1
			case 2
			case 3
			case 5
				ifvare LOTAGSAVED 1 getactorvar[PLAYERID].fireshield tmp
				ifvare LOTAGSAVED 2 getactorvar[PLAYERID].bodyshield tmp
				ifvare LOTAGSAVED 3 getactorvar[PLAYERID].fireshield tmp
				ifvare LOTAGSAVED 5 getactorvar[PLAYERID].spiritshield tmp
				ifvarg tmp 0
				{
					addvarvar armorcount HITAGSAVED
					ifvarg armorcount 30 {
						subvar tmp 1
						
						ifvare LOTAGSAVED 1 setactorvar[PLAYERID].fireshield tmp
						ifvare LOTAGSAVED 2 setactorvar[PLAYERID].bodyshield tmp
						ifvare LOTAGSAVED 3 setactorvar[PLAYERID].fireshield tmp
						ifvare LOTAGSAVED 5 setactorvar[PLAYERID].spiritshield tmp
						setvar armorcount 0
						
					}
					setvarvar healthcount tmp
					shiftvarr healthcount 1
					ifvarl healthcount 30
						setvar healthcount 30	
					ifvarvarg COUNTER healthcount {
						addphealth -1
						setvar COUNTER 0
					}	
				} else {
					ifvarg COUNTER 29 { addphealth -1 setvar COUNTER 0 }
				}
				
				
				ifvare LOTAGSAVED 1 { ifrnd 64 soundonce PLAY1118 else ifrnd 64 soundonce PLAY1119 else soundonce PLAY1120 } 
					else { ifrnd 64 soundonce PLAY1106 else ifrnd 64 soundonce PLAY1107 else soundonce PLAY1108 }
			break
		endswitch

	}
}
			
enda