:: fight
<<set $here = 'fight'>>
<<set $ARGS = $location_var[$here]>>
<!-- !2020/10/14/Gwen-->
<!-- !{  To Use Fight:
1) Initialize fight to make sure previous fighter are cleared out.
2) Add Opponents and Allies
3) Set Fight Ending
4) Start Fight
Example:
Let''s make a fight where Tatiana helps us beat Kisame and a bandit
gs 'fight','initFight'
gs 'fight_npcdata', 'tatiana', 'pcs'
gs 'fight_npcdata', 'kisame', 'opp'
gs 'fight_npcdata', 'bandit', 'opp'
fightEnding = 2
gt 'fight', 'start'
} -->
<!-- !! Variables to be set for each participant before fight - in brackets so you can copy/paste-->
<!-- !!{
$opp_name[0] = <<name of opponent>>
$opp_image[0] = opponent image ie. '<<image 'images/characters/city/tobi/tobi.jpg'>>'
opp_def[0] = opponent defence
opp_run[0] = Opponent running skill used for player escape
opp_wrstlng[0] = Wrestling skill
opp_kick[0] = Kicking
opp_punch[0] = Power punch
opp_jab[0] = Light punch
opp_stren[0] = Strengh
opp_agil[0] = Agility
opp_vital[0] = vitality
opp_react[0] = Reactions
opp_health[0] = Health
opp_willpwr[0] = willpower
opp_shoot[0] = opponent marksmanship (only required if they are armed)
opp_magik[0] = only if they have magic
opp_mana[0] = only if they have magic
opp_fog[0] = (tuman): Obscures vision, makes hitting harder.
opp_clone[0] = (klon): Copies of the char that absorb 1 hit and disappear.  A char may have some number of them.
opp_shield[0] = (defence): Shielding that absorbs damage before hitpoints.
opp_dambonus[0] = (magweapbonus): damage added to melee attacks
opp_init[0] = (initBonus): attack faster/first
opp_stun[0] = (stunner): make target unable to act for some amount of time
opp_spells[0] = comma delimited list of spell names
} -->
<!-- !! Use the above with [1] and [2] for extra opponents-->
<!-- !! Use pcs_ prefix for Sveta and add [1] and [2] for allies. ie. $pcs_name[1] = 'Reinhold'-->
<<if $location_var[$here][0] == 'initFight'>>
	<!-- !! Clear Opponents from previous battle-->
	<<set $opp_name to null>>
	<<set $opp_image to null>>
	<<set $opp_def to null>>
	<<set $opp_run to null>>
	<<set $opp_wrstlng to null>>
	<<set $opp_kick to null>>
	<<set $opp_punch to null>>
	<<set $opp_jab to null>>
	<<set $opp_stren to null>>
	<<set $opp_agil to null>>
	<<set $opp_vital to null>>
	<<set $opp_react to null>>
	<<set $opp_health to null>>
	<<set $opp_willpwr to null>>
	<<set $opp_shoot to null>>
	<<set $opp_magik to null>>
	<<set $opp_mana to null>>
	<<set $opp_fog to null>>
	<<set $opp_clone to null>>
	<<set $opp_shield to null>>
	<<set $opp_dambonus to null>>
	<<set $opp_init to null>>
	<<set $opp_stun to null>>
	<<set $opp_spells to null>>
	<<set $opp_timer to null>>
	<!-- !! Clear any allies from previous battle-->
	<<set $i = arrsize('pcs_health')>>
	<<warn 'JUMP MARKER ENCOUNTERED: :ClearAllyLoop'>>
	<<if getvar("$i") > 1>>
		<<gs 'fight' 'clearPCSArray' $i - 1>>
		<<set $i -= 1>>
		<<warn 'JUMP COMMAND ENCOUNTERED: jump ClearAllyLoop'>>
	<</if>>
	<<set $i to null>>
	<!-- !! Initialize $pcs_name for Sveta-->
	<<setinit $pcs_name[0] = 'You'>>
	<<if $location_var[$here][1] == 1>>
		<<setinit $pcs_image[0] = 'images/system/1_openings/1_tf/mikhail_1.jpg'>>
	<<else>>
		<<setinit $pcs_image[0] = $pc.image>>
	<</if>>
<</if>>
<<if $location_var[$here][0] == 'clearPCSArray'>>
	<!-- !{ Delete an Ally from the pcs data arrays
	ARGS[1] = Which ally slot tot delete
	} -->
	<<set $i = $ARGS[1]>>
	<<set $pcs_name[$i] to null>>
	<<set $pcs_image[$i] to null>>
	<<set $pc.skillLevel("defense")[$i] to null>>
	<<set $pc.skillLevel("run")[$i] to null>>
	<<set $pc.skillLevel("wrestling")[$i] to null>>
	<<set $pc.skillLevel("kick")[$i] to null>>
	<<set $pc.skillLevel("punch")[$i] to null>>
	<<set $pc.skillLevel("jabs")[$i] to null>>
	<<set $pc.skillLevel("strength")[$i] to null>>
	<<set $pc.skillLevel("agility")[$i] to null>>
	<<set $pc.vitality[$i] to null>>
	<<set $pc.skillLevel("reaction")[$i] to null>>
	<<set $pc.pcs_health[$i] to null>>
	<<set $pc.pcs_willpwr[$i] to null>>
	<<set $pc.skillLevel("shoot")[$i] to null>>
	<<set $pcs_magik[$i] to null>>
	<<set $pcs_mana[$i] to null>>
	<<set $pcs_fog[$i] to null>>
	<<set $pcs_clone[$i] to null>>
	<<set $pcs_shield[$i] to null>>
	<<set $pcs_dambonus[$i] to null>>
	<<set $pcs_init[$i] to null>>
	<<set $pcs_stun[$i] to null>>
	<<set $pcs_spells[$i] to null>>
	<<set $pcs_timer[$i] to null>>
	<<set $i to null>>
<</if>>
<<if $location_var[$here][0] == 'randomOpp'>>
	<!-- !{ Generate a random Opponent
	ARGS[1] = Optional, raise difficulty of the attacker, 0 - 50
	} -->
	<<set $OppDiffBonus = $ARGS[1]>>
	<<set $i = arrsize('opp_health')>>
	<<setinit $opp_name[$i] = 'Opponent 1'>>
	<<setinit $opp_image[$i] = 'images/locations/shared/street/mugger.jpg'>>
	<<setinit $opp_def[$i] = rand(1,50) + $OppDiffBonus>>
	<<setinit $opp_run[$i] = rand(1,50) + $OppDiffBonus>>
	<<setinit $opp_wrstlng[$i] = rand(1,50) + $OppDiffBonus>>
	<<setinit $opp_kick[$i] = rand(1,50) + $OppDiffBonus>>
	<<setinit $opp_punch[$i] = rand(1,50) + $OppDiffBonus>>
	<<setinit $opp_jab[$i] = rand(1,50) + $OppDiffBonus>>
	<<setinit $opp_stren[$i] = rand(1,50) + $OppDiffBonus>>
	<<setinit $opp_agil[$i] = rand(1,50) + $OppDiffBonus>>
	<<setinit $opp_vital[$i] = rand(1,50) + $OppDiffBonus>>
	<<setinit $opp_health[$i] = ($opp_vital * 10 + $opp_stren * 5)>>
	<<setinit $opp_react[$i] = rand(1,50) + $OppDiffBonus>>
	<<setinit $opp_willpwr[$i] = rand(1,50) + $OppDiffBonus>>
	<<setinit $opp_shoot[$i] = rand(1,50) + $OppDiffBonus>>
	<<set $OppDiffBonus to null>>
	<<set $i to null>>
<</if>>
<<if $location_var[$here][0] == 'applyDamage'>>
	<!-- !{ Apply Damage to a participant taking into account clones and shields
	$ARGS[1] = Target Type ('opp','pcs')
	ARGS[2] = Target number
	ARGS[3] = damage to be applied
	} -->
	<<setinit $fightAppDam['TargetType'] = $location_var[$here][1]>>
	<<setinit $fightAppDam['TargetNumber'] = $ARGS[2]>>
	<<setinit $fightAppDam['Damage'] = $ARGS[3]>>
	<!-- FAILED TO CONVERT
		$fightAppDam['TargetName'] = dyneval('$result=$<<$fightAppDam[''TargetType'']>>_name[<<fightAppDam[''TargetNumber'']>>]')
	-----
		<<setinit $fightAppDam['TargetName'] = dyneval('$result=$<<$fightAppDam['TargetType']>>_name[ERROR: FAILED TO CONVERT LITERAL: """<<fightAppDam['TargetNumber']>>"""]')>>

	-->
	<<warn "CONVERSION ERROR 4269922a5940166c72312aac8bbb1d3f">>
	<!-- FAILED TO CONVERT
		fightAppDam['Shield'] = dyneval('result=<<$fightAppDam[''TargetType'']>>_shield[<<fightAppDam[''TargetNumber'']>>]')
	-----
		<<setinit $fightAppDam['Shield'] = dyneval('result=<<$fightAppDam['TargetType']>>_shield[ERROR: FAILED TO CONVERT LITERAL: """<<fightAppDam['TargetNumber']>>"""]')>>

	-->
	<<warn "CONVERSION ERROR ecc45d781178f4cf6c5e106c089783f6">>
	<!-- FAILED TO CONVERT
		fightAppDam['OverShieldDamage'] = dyneval('result=<<fightAppDam[''Damage'']>> - <<$fightAppDam[''TargetType'']>>_shield[<<fightAppDam[''TargetNumber'']>>]')
	-----
		<<setinit $fightAppDam['OverShieldDamage'] = dyneval('result=<<fightAppDam['Damage']>> - <<$fightAppDam['TargetType']>>_shield[ERROR: FAILED TO CONVERT LITERAL: """<<fightAppDam['TargetNumber']>>"""]')>>

	-->
	<<warn "CONVERSION ERROR 7e56c29ca297d06403611902eec6c653">>
	dynamic "
	<!-- !!If the target has clones, destroy one-->
	<!-- FAILED TO CONVERT
		if <<$fightAppDam['TargetType']>>_clone[<<fightAppDam['TargetNumber']>>] > 0:
	-----
		<<if ERROR: FAILED TO CONVERT CONDITION: <<$fightAppDam['TargetType']>>_clone[<<fightAppDam['TargetNumber']>>] > 0>>

	-->
	<<warn "CONVERSION ERROR 0e70c8daff97ebbbdadabb918b46206a">>
		<!-- FAILED TO CONVERT
			<<$fightAppDam['TargetType']>>_clone[<<fightAppDam['TargetNumber']>>] -= 1
		-----
			<<setinit $fightAppDam['TargetType']_clone[ERROR: FAILED TO CONVERT LITERAL: """<<fightAppDam['TargetNumber']>>"""] -= 1>>

		-->
		<<warn "CONVERSION ERROR c00fb8a7d413f63087ec3478b6c67e6b">>
		<<if $fightAppDam['TargetName'] == 'you'>>
			""$fightAppDam['TargetName'] lose a clone.""
		<<else>>
			""$fightAppDam['TargetName'] loses a clone.""
		<</if>>
		<!-- !!if the target has enough shields to mitigate, remove some shields-->
	<!-- FAILED TO CONVERT
		elseif <<$fightAppDam['TargetType']>>_shield[<<fightAppDam['TargetNumber']>>] >= <<fightAppDam['Damage']>>:
	-----
		<<elseif ERROR: FAILED TO CONVERT CONDITION: <<$fightAppDam['TargetType']>>_shield[<<fightAppDam['TargetNumber']>>] >= <<fightAppDam['Damage']>>>>

	-->
	<<warn "CONVERSION ERROR 2f5f733a2918178fc1223f4035e87441">>
		<<$fightAppDam['TargetType']>>_shield[<<fightAppDam['TargetNumber']>>] -= <<fightAppDam['Damage']>>
		<<if $fightAppDam['TargetName'] == 'you'>>
			""$fightAppDam['TargetName'] lose fightAppDam['Damage'] defense.""
		<<else>>
			""$fightAppDam['TargetName'] loses fightAppDam['Damage'] defense.""
		<</if>>
		<!-- !!otherwise remove shields to 0 and the remainder comes from health-->
	<<else>>
		<!-- FAILED TO CONVERT
			if <<$fightAppDam['TargetType']>>_shield[<<fightAppDam['TargetNumber']>>] > 0:
		-----
			<<if ERROR: FAILED TO CONVERT CONDITION: <<$fightAppDam['TargetType']>>_shield[<<fightAppDam['TargetNumber']>>] > 0>>

		-->
		<<warn "CONVERSION ERROR cf419d3003a0a909afde6f27767c794f">>
			<!-- FAILED TO CONVERT
				<<$fightAppDam['TargetType']>>_shield[<<fightAppDam['TargetNumber']>>] = 0
			-----
				<<setinit $fightAppDam['TargetType']_shield[$ERROR: FAILED TO CONVERT LITERAL: """<<fightAppDam['TargetNumber']>>"""] = 0>>

			-->
			<<warn "CONVERSION ERROR ef8075d2762c16b3cbf9c5902cf49561">>
			<<if $fightAppDam['TargetName'] == 'you'>>
				""$fightAppDam['TargetName'] lose fightAppDam['Shield'] defense.""
			<<else>>
				""$fightAppDam['TargetName'] losses fightAppDam['Shield'] defense.""
			<</if>>
		<</if>>
		<!-- FAILED TO CONVERT
			if <<$fightAppDam['TargetType']>>_health[<<fightAppDam['TargetNumber']>>] > <<fightAppDam['OverShieldDamage']>>:
		-----
			<<if ERROR: FAILED TO CONVERT CONDITION: <<$fightAppDam['TargetType']>>_health[<<fightAppDam['TargetNumber']>>] > <<fightAppDam['OverShieldDamage']>>>>

		-->
		<<warn "CONVERSION ERROR cb0b2337f3e573858f2ba567c2774bab">>
			<<$fightAppDam['TargetType']>>_health[<<fightAppDam['TargetNumber']>>] -= <<fightAppDam['OverShieldDamage']>>
		<<else>>
			<!-- FAILED TO CONVERT
				<<$fightAppDam['TargetType']>>_health[<<fightAppDam['TargetNumber']>>] = 0
			-----
				<<setinit $fightAppDam['TargetType']_health[$ERROR: FAILED TO CONVERT LITERAL: """<<fightAppDam['TargetNumber']>>"""] = 0>>

			-->
			<<warn "CONVERSION ERROR 262eca4981b387c7deeb72024e721f78">>
		<</if>>
		<<if $fightAppDam['TargetName'] == 'you'>>
			""$fightAppDam['TargetName'] lose fightAppDam['OverShieldDamage'] health.""
		<<else>>
			""$fightAppDam['TargetName'] loses fightAppDam['OverShieldDamage'] health.""
		<</if>>
	<</if>>
	<<set $fightAppDam to null>>
	<<set $fightAppDam to null>>
<</if>>
<<if $location_var[$here][0] == 'start'>>
	<<set $menu_off = 1>>
	<<set $inFight = 1>>
	
	<<if arrsize('pcs_health') > arrsize('opp_health')>>
		<<set $tableSize = arrsize('pcs_health')>>
	<<else>>
		<<set $tableSize = arrsize('opp_health')>>
	<</if>>
	<!-- FAILED TO CONVERT
		$HTMLText = '<table border=1>
	-----
		<<set $HTMLText = ERROR: FAILED TO CONVERT LITERAL: """'<table border=1>""">>

	-->
	<<warn "CONVERSION ERROR 3c46f1a9de187ada044da82af8e1d008">>
	<tr>
	<th align="left"><b><font size=18>Allies</font></b></td>
	<th align="center" valign="center" rowspan=<<tableSize*2+1>> ><b><font size=18>vs.</font></b></center></td>
	<th align="right"><b><font size=18>Opponents</font></b></td>
	<!-- FAILED TO CONVERT
		</tr>'
	-----
		ERROR: FAILED TO CONVERT LITERAL: """<""" / ERROR: FAILED TO CONVERT LITERAL: """tr>'"""

	-->
	<<warn "CONVERSION ERROR 1fd83a3e6ce5edd7d7a0d8bf05ea889b">>
	<<set $i = 0>>
	<<warn 'JUMP MARKER ENCOUNTERED: :FightPoster'>>
	<<if $i < $tableSize>>
		<<set $HTMLText += >>
		<tr>
		<td align="left"><img HEIGHT=300 src="<<$pcs_image[$i]>>"></left></td>
		<td align="right"><img HEIGHT=300 src="<<$opp_image[$i]>>"></right></td>
		</tr>
		<tr>
		<td align="left"><b><font size=10><<$pcs_name[$i]>></font></b></left></td>
		<td align="right"><b><font size=10><<$opp_name[$i]>></font></b></right></td>
		<!-- FAILED TO CONVERT
			</tr>'
		-----
			ERROR: FAILED TO CONVERT LITERAL: """<""" / ERROR: FAILED TO CONVERT LITERAL: """tr>'"""

		-->
		<<warn "CONVERSION ERROR 1fd83a3e6ce5edd7d7a0d8bf05ea889b">>
		<<set $i += 1>>
		<<warn 'JUMP COMMAND ENCOUNTERED: jump FightPoster'>>
	<</if>>
	<<set $HTMLText += '</table>'>>
	*pl setup.func('cleanHTML',$HTMLText)
	<<set $i = 0>>
	<<warn 'JUMP MARKER ENCOUNTERED: :PCSTimerInit'>>
	<<if $i < arrsize('pcs_health')>>
		<<setinit $pcs_timer[$i] = 60 - ($pc.skillLevel("reaction")[$i] / 2)>>
		<<set $i += 1>>
		<<warn 'JUMP COMMAND ENCOUNTERED: jump PCSTimerInit'>>
	<</if>>
	<<set $i = 0>>
	<<warn 'JUMP MARKER ENCOUNTERED: :OppTimerInit'>>
	<<if $i < arrsize('opp_health')>>
		<<setinit $opp_timer[$i] = 60 - ($opp_react[$i] / 2)>>
		<<set $i += 1>>
		<<warn 'JUMP COMMAND ENCOUNTERED: jump OppTimerInit'>>
	<</if>>
	<<act 'Fight!'>>
		<<gt 'fight' 'main'>>
	<</act>>
	<<set $HTMLText to null>>
	<<set $tableSize to null>>
	<<set $i to null>>
<</if>>
<<if $location_var[$here][0] == 'findActiveTimer'>>
	<!-- !! Find the participant with the lowest Timer-->
	<!-- !	These values are passed back via two global variables.-->
	<!-- !-->
	<!-- !	$fightTimType = 'player' or 'opponent' depending on which group has the lowest member-->
	<!-- !	fightTimNum = the array number of the lowest participant-->
	<<set $fightTimType = 'player'>>
	<<set $fightTimNum = 0>>
	<!-- !! set this to high so that everyone will be lower.-->
	<<set $fightTimLow = 99999>>
	<!-- !! Find lowest of pcs participants-->
	<<set $i = 0>>
	<<warn 'JUMP MARKER ENCOUNTERED: :LowTimerLoop1'>>
	<<if $i < arrsize('pcs_timer')>>
		<!-- !Skip round if char is stunned-->
		<<if getvar("$pcs_stun["+$i+"]") > 0>>
			<<setinit $pcs_stun[$i] -= 1>>
			<!-- !Skip anyone with no Health-->
		<<elseif getvar("$pc.pcs_health["+$i+"]") > 0>>
			<<if $pcs_timer[$i] < $fightTimLow>>
				<<set $fightTimLow = $pcs_timer[$i]>>
				<<set $fightTimNum = $i>>
			<</if>>
		<</if>>
		<<set $i += 1>>
		<<warn 'JUMP COMMAND ENCOUNTERED: jump LowTimerLoop1'>>
	<</if>>
	<!-- !!Find if any Opponents have lower than best PCS-->
	<<set $i = 0>>
	<<warn 'JUMP MARKER ENCOUNTERED: :LowTimerLoop2'>>
	<<if $i < arrsize('opp_timer')>>
		<!-- !Skip round if char is stunned-->
		<<if getvar("$opp_stun["+$i+"]") > 0>>
			<<setinit $opp_stun[$i] -= 1>>
			<!-- !Skip anyone with no Health-->
		<<elseif getvar("$opp_health["+$i+"]") > 0>>
			<<if $opp_timer[$i] < $fightTimLow>>
				<<set $fightTimLow = $opp_timer[$i]>>
				<<set $fightTimNum = $i>>
				<<set $fightTimType = 'opponent'>>
			<</if>>
		<</if>>
		<<set $i += 1>>
		<<warn 'JUMP COMMAND ENCOUNTERED: jump LowTimerLoop2'>>
	<</if>>
	<<set $i to null>>
<</if>>
<<if $location_var[$here][0] == 'main'>>
	<<gs 'fight' 'result_check'>>
	<<gs 'fight' 'findActiveTimer'>>
	<<gt 'fight' $fightTimType $fightTimNum>>
<</if>>
<<if $location_var[$here][0] == 'printStats'>>
	<!-- !{ Print the stats for a character
	$ARGS[1] = The Type of char ('opp','pcs')
	ARGS[2] = The member of the party
	} -->
	<<setinit $fightPStats['CharType'] = $location_var[$here][1]>>
	<<set $i = $ARGS[2]>>
	<<if $fightPStats['CharType'] == 'opp'>>
		<<setinit $fightPStats['Name'] = $opp_name[$i]>>
		<<setinit $fightPStats['Health'] = $opp_health[$i]>>
		<<setinit $fightPStats['Mana'] = $opp_mana[$i]>>
		<<setinit $fightPStats['Willpower'] = $opp_willpwr[$i]>>
		<<setinit $fightPStats['Shield'] = $opp_shield[$i]>>
		<<setinit $fightPStats['Fog'] = $opp_fog[$i]>>
		<<setinit $fightPStats['Clone'] = $opp_clone[$i]>>
		<<setinit $fightPStats['Stun'] = $opp_stun[$i]>>
		<<setinit $fightPStats['Timer'] = $opp_timer[$i]>>
		<<setinit $fightPStats['Image'] = $opp_image[$i]>>
	<<else>>
		<<setinit $fightPStats['Name'] = $pcs_name[$i]>>
		<<setinit $fightPStats['Health'] = $pc.pcs_health[$i]>>
		<<setinit $fightPStats['Mana'] = $pcs_mana[$i]>>
		<<setinit $fightPStats['Willpower'] = $pc.pcs_willpwr[$i]>>
		<<setinit $fightPStats['Shield'] = $pcs_shield[$i]>>
		<<setinit $fightPStats['Fog'] = $pcs_fog[$i]>>
		<<setinit $fightPStats['Clone'] = $pcs_clone[$i]>>
		<<setinit $fightPStats['Stun'] = $pcs_stun[$i]>>
		<<setinit $fightPStats['Timer'] = $pcs_timer[$i]>>
		<<setinit $fightPStats['Image'] = $pcs_image[$i]>>
	<</if>>
	<<set $fightStatRowText = >>
	<tr>
	<td rowspan=4 align=right valign=center>
	<img HEIGHT=70 src='<<$fightPStats['Image']>>'>
	<br> <b><<$fightPStats['Name']>></b>
	</td>
	<td align=right> Life </td>
	<td align=right> <b><font color = red><<fightPStats['Health']>></font></b> </td>
	<!-- FAILED TO CONVERT
		<td rowspan=4 align=left valign=center>"
	-----
		<<set ERROR: FAILED TO CONVERT LITERAL: """<td rowspan""" = ERROR: FAILED TO CONVERT LITERAL: """4 align=left valign=center>"""">>

	-->
	<<warn "CONVERSION ERROR 806808d0856b9f472d30f2236d45d1c9">>
	<<if getvar("$fightPStats['Shield']") > 0>>
		<<set $fightStatRowText += "<b><font color = purple>Protection fightPStats['Shield'] units</font></b><br>">>

	<</if>>
	<<if getvar("$fightPStats['Clone']") > 0>>
		<<set $fightStatRowText += "<b><font color = purple>Clones active fightPStats['Clone'] </font></b><br>">>

	<</if>>
	<<if getvar("$fightPStats['Fog']") > 0>>
		<<set $fightStatRowText += "<b><font color = purple>Obscuring Fog fightPStats['Fog'] units</font></b><br>">>

	<</if>>
	<<if getvar("$fightPStats['Stun']") > 0>>
		<<set $fightStatRowText += "<b><font color = purple>Stunned fightPStats['Stun'] rounds</font></b>">>

	<</if>>
	<<set $fightStatRowText += >>
	</td>
	</tr>
	<tr>
	<td align=right> Mana </td>
	<td align=right> <b><font color = blue><<fightPStats['Mana']>></font></b> </td>
	</tr>
	<tr>
	<td align=right> Willpower </td>
	<td align=right> <b><font color = green><<fightPStats['Willpower']>></font></b> </td>
	</tr>
	<tr>
	<td align=right> Initiative </td>
	<td align=right> <b><font color = orange><<fightPStats['Timer']>></font></b> </td>
	<!-- FAILED TO CONVERT
		</tr><tr><td colspan=4 bgcolor=grey></td></tr>"
	-----
		<<set ERROR: FAILED TO CONVERT LITERAL: """<""" / ERROR: FAILED TO CONVERT LITERAL: """tr><tr><td colspan""" = ERROR: FAILED TO CONVERT LITERAL: """4 bgcolor=grey><""" / ERROR: FAILED TO CONVERT LITERAL: """td><""" / ERROR: FAILED TO CONVERT LITERAL: """tr>"""">>

	-->
	<<warn "CONVERSION ERROR 89543fd0382987e51fafdfe93ea8bee8">>
	<<set $result = $fightStatRowText>>
	<<set $i to null>>
	<<set $fightPStats to null>>
	<<set $fightPStats to null>>
<</if>>
<<if $location_var[$here][0] == 'statDisplay'>>
	<<set $fightStatText = >>
	<table border=1><th colspan=4><b><font size=12>Opponents</font></b></th>
	<<set $j = 0>>
	<<warn 'JUMP MARKER ENCOUNTERED: :OppLoopRC1'>>
	<<if $j < arrsize('opp_health')>>
		<<set $fightStatText += setup.func('fight', 'printStats', 'opp', j)>>
		<<set $j += 1>>
		<<warn 'JUMP COMMAND ENCOUNTERED: jump OppLoopRC1'>>
	<</if>>
	<<set $fightStatText += "</table>">>
	*pl setup.func('cleanHTML',$fightStatText)
	<<set $fightStatText = >>
	<table border=1><th colspan=4><b><font size=12>Opponents</font></b></th>
	<<set $j = 0>>
	<<warn 'JUMP MARKER ENCOUNTERED: :PCSLoopRC1'>>
	<<if $j < arrsize('pcs_health')>>
		<<set $fightStatText += setup.func('fight', 'printStats', 'pcs', j)>>
		<<set $j += 1>>
		<<warn 'JUMP COMMAND ENCOUNTERED: jump PCSLoopRC1'>>
	<</if>>
	<<set $fightStatText += "</table>">>
	*pl setup.func('cleanHTML',$fightStatText)
<</if>>
<<if $location_var[$here][0] == 'result_check'>>
	<!-- !!cheat to auto-win fights check-->
	<<if getvar("$fight_cheat") == 1>>
		<<xgt 'ender' 'win'>>
		<<gt $location>>
		$exit
	<</if>>
	<!-- !!win/lose conditions-->
	<<if setup.func('fight', 'AvailableTargets', 'pcs') == 0>>
		<b><font color = red> You lost!</font></b>
		<<xgt 'ender' 'loss'>>
		<<gt $location>>
		$exit
	<<elseif setup.func('fight', 'AvailableTargets', 'opp') == 0>>
		<b><font color = green> You won!</font></b>
		<<xgt 'ender' 'win'>>
		<<gt $location>>
		$exit
	<<elseif $pc.pcs_willpwr <= 0>>
		<b><font color = red> You cannot summon the will to fight!</font></b>
		<<xgt 'ender' 'loss'>>
		<<gt $location>>
		$exit
	<</if>>
	<!-- !gt 'fight', 'main'-->
	<<set $i to null>>
<</if>>
<!-- !! Kick-->
<<setinit $AttackType[0] = 'Kick'>>
<<setinit $AttackSkill[0] = 'kick'>>
<<setinit $AttackMin[0] = 5>>
<<setinit $AttackMax[0] = 8>>
<<setinit $AttackTime[0] = 40>>
<!-- !! Hard Punch-->
<<setinit $AttackType[1] = 'Hard Punch'>>
<<setinit $AttackSkill[1] = 'punch'>>
<<setinit $AttackMin[1] = 4>>
<<setinit $AttackMax[1] = 6>>
<<setinit $AttackTime[1] = 30>>
<!-- !! Jab-->
<<setinit $AttackType[2] = 'Jab'>>
<<setinit $AttackSkill[2] = 'jab'>>
<<setinit $AttackMin[2] = 2>>
<<setinit $AttackMax[2] = 3>>
<<setinit $AttackTime[2] = 15>>
<!-- !!{Attack a target
$ARGS[0] = Attack Type
$ARGS[1] = Target Type
ARGS[2] = Which target
ARGS[3] = Which Attacker
} -->
<<if $location_var[$here][0] == 'Attack'>>
	<<set $fightAtk_Type = $location_var[$here][1]>>
	<<set $fightAtk_Type = arrpos('$AttackType',$fightAtk_Type)>>
	<<set $fightAtk_TargetType = $location_var[$here][2]>>
	<<set $fightAtk_TargetNumber = $ARGS[3]>>
	<<set $fightAtk_AttackerNumber = $ARGS[4]>>
	<<if $fightAtk_TargetType == 'opp' and getvar("$fightAtk_AttackerNumber") == 0>>
		<<set $fightAtk_AttackerType = 'pcs'>>
		<<setinit $fightAtk['DefenderName'] = $opp_name[$fightAtk_TargetNumber]>>
		<<setinit $fightAtk['AttackerName'] = 'You'>>
		<!-- !!Add Skill Exp-->
		<<set dynamic "$AttackSkill[$fightAtk_Type]_exp += rand(1 , 3)">>
	<<elseif $fightAtk_TargetType == 'opp'>>
		<<setinit $fightAtk['AttackerName'] = $pcs_name[$fightAtk_AttackerNumber]>>
		<<setinit $fightAtk['DefenderName'] = $opp_name[$fightAtk_TargetNumber]>>
		<<set $fightAtk_AttackerType = 'pcs'>>
	<<else>>
		<<set $fightAtk_AttackerType = 'opp'>>
		<<setinit $fightAtk['AttackerName'] = $opp_name[$fightAtk_AttackerNumber]>>
		<<setinit $fightAtk['DefenderName'] = $pcs_name[$fightAtk_TargetNumber]>>
	<</if>>
	<!-- FAILED TO CONVERT
		fightAtk['AttackerSkillValue'] = dyneval('result = <<$fightAtk_AttackerType>>_<<$AttackSkill[fightAtk_Type]>>[<<fightAtk_AttackerNumber>>]')
	-----
		<<setinit $fightAtk['AttackerSkillValue'] = dyneval('result = <<$fightAtk_AttackerType>>_<<$AttackSkill[$fightAtk_Type]>>[ERROR: FAILED TO CONVERT LITERAL: """<<fightAtk_AttackerNumber>>"""]')>>

	-->
	<<warn "CONVERSION ERROR a5ecb236e13909bc377f18d996fbad80">>
	<!-- FAILED TO CONVERT
		fightAtk['TargetReactValue'] = dyneval('result = iif(<<$fightAtk_TargetType>>_stun[<<fightAtk_TargetNumber>>]>0,0,<<$fightAtk_TargetType>>_react[<<fightAtk_TargetNumber>>])')
	-----
		<<setinit $fightAtk['TargetReactValue'] = dyneval('result = iif(<<$fightAtk_TargetType>>_stun[ERROR: FAILED TO CONVERT LITERAL: """<<fightAtk_TargetNumber>>"""]>0,0,<<$fightAtk_TargetType>>_react[ERROR: FAILED TO CONVERT LITERAL: """<<fightAtk_TargetNumber>>"""])')>>

	-->
	<<warn "CONVERSION ERROR eb3bb2d399049fd004be8731138969b2">>
	<!-- FAILED TO CONVERT
		fightAtk['TargetAgilValue'] = dyneval('result = iif(<<$fightAtk_TargetType>>_stun[<<fightAtk_TargetNumber>>]>0,0,<<$fightAtk_TargetType>>_agil[<<fightAtk_TargetNumber>>])')
	-----
		<<setinit $fightAtk['TargetAgilValue'] = dyneval('result = iif(<<$fightAtk_TargetType>>_stun[ERROR: FAILED TO CONVERT LITERAL: """<<fightAtk_TargetNumber>>"""]>0,0,<<$fightAtk_TargetType>>_agil[ERROR: FAILED TO CONVERT LITERAL: """<<fightAtk_TargetNumber>>"""])')>>

	-->
	<<warn "CONVERSION ERROR e0934895c9eebe6fa5e972822916bd4b">>
	<!-- FAILED TO CONVERT
		fightAtk['TargetHealthBefore'] = dyneval('result = <<$fightAtk_TargetType>>_health[<<fightAtk_TargetNumber>>]')
	-----
		<<setinit $fightAtk['TargetHealthBefore'] = dyneval('result = <<$fightAtk_TargetType>>_health[ERROR: FAILED TO CONVERT LITERAL: """<<fightAtk_TargetNumber>>"""]')>>

	-->
	<<warn "CONVERSION ERROR a5936a1a3d1d5f32138f95c8f8d4e7c9">>
	<<setinit $fightAtk['MinDamage'] = $AttackMin[$fightAtk_Type]>>
	<<setinit $fightAtk['MaxDamage'] = $AttackMax[$fightAtk_Type]>>
	<<if $fightAtk_TargetType == 'opp' and getvar("$fightAtk_AttackerNumber") == 0>>
		<p>You attempt to $fightAtk_Type $fightAtk["DefenderName"]!</p>
	<<else>>
		<p>$fightAtk["AttackerName"] attempts to $fightAtk_Type $fightAtk["DefenderName"]!</p>
	<</if>>
	<<if fightAtk['AttackerSkillValue'] + rand(0,40) > $fightAtk['TargetReactValue'] / 4 + 3 * $fightAtk['TargetAgilValue'] / 4>>
		<!-- !!Calculate Damage-->
		<!-- FAILED TO CONVERT
			dynamic "fightAtk['Damage'] = <<$fightAtk_AttackerType>>_stren[<<fightAtk_AttackerNumber>>] * rand(<<fightAtk['MinDamage']>>,<<fightAtk['MaxDamage']>>) / 3"
		-----
			<<set dynamic "fightAtk['Damage'] = $fightAtk_AttackerType_stren[ERROR: FAILED TO CONVERT LITERAL: """<<fightAtk_AttackerNumber>>"""] * rand(<<fightAtk['MinDamage']>>,<<fightAtk['MaxDamage']>>) / 3">>

		-->
		<<warn "CONVERSION ERROR cfefe9ab0122ffe561d12cad9d93895e">>
		<!-- !!Apply Damage-->
		<<gs 'fight' 'applyDamage' $fightAtk_TargetType $fightAtk_TargetNumber $fightAtk['Damage']>>
	<<elseif rand(0,3) != 0>>
		<!-- !!Always chance to hit if rand = 0-->
		<<if $fightAtk_TargetType == 'pcs' and getvar("$fightAtk_AttackerNumber") == 0>>
			You avoid the blow.
		<<else>>
			<p>$fightAtk["DefenderName"] avoids the blow.</p>
		<</if>>
	<<else>>
		<!-- !!Apply Damage-->
		<<gs 'fight' 'applyDamage' $fightAtk_TargetType $fightAtk_TargetNumber $fightAtk['Damage']>>
	<</if>>
	<!-- !! Flavor text for size of the hit.-->
	<!-- FAILED TO CONVERT
		fightAtk['TargetHealthLoss'] = fightAtk['TargetHealthBefore'] - dyneval('result = <<$fightAtk_TargetType>>_health[<<fightAtk_TargetNumber>>]')
	-----
		<<setinit $fightAtk['TargetHealthLoss'] = fightAtk['TargetHealthBefore'] - dyneval('result = <<$fightAtk_TargetType>>_health[ERROR: FAILED TO CONVERT LITERAL: """<<fightAtk_TargetNumber>>"""]')>>

	-->
	<<warn "CONVERSION ERROR 7b87100a6f5dfdc4b095f990afe10c50">>
	<!-- !! If blow does over half health in damage, causes stun-->
	<<if $fightAtk['TargetHealthLoss'] * 2 > $fightAtk['TargetHealthBefore']>>
		<<if $fightAtk_TargetType == 'pcs' and getvar("$fightAtk_TargetNumber") == 0>>
			It is a devastating blow. You are stunned.
		<<else>>
			<p>It is a devastating blow. $fightAtk["DefenderName"] is stunned.</p>
		<</if>>
		<<set '+$fightAtk_TargetType+'_stun['+fightAtk_TargetNumber+'] += 1>>
		<<set '+$fightAtk_TargetType+'_timer['+fightAtk_TargetNumber+'] += $AttackTime[$fightAtk_Type]>>
		<!-- !! Very hard hit-->
	<<elseif getvar("$fightAtk['TargetHealthLoss']") > 50>>
		<<if $fightAtk_TargetType == 'pcs' and getvar("$fightAtk_TargetNumber") == 0>>
			The hit is hard and you reel in pain.
		<<else>>
			<p>The hit is hard and $fightAtk["DefenderName"] reels in pain.</p>
		<</if>>
		<!-- !! Does physical damage, but not a lot-->
	<<elseif getvar("$fightAtk['TargetHealthLoss']") > 0>>
		It's a glancing blow, but still hurts.
		<!-- !! No physical damage was done.-->
	<<else>>
		Defenses were not pierced.
	<</if>>
	<!-- FAILED TO CONVERT
		dynamic "<<$fightAtk_AttackerType>>_timer[<<fightAtk_AttackerNumber>>] += AttackTime[<<fightAtk_Type>>]"
	-----
		<<set dynamic "$fightAtk_AttackerType_timer[ERROR: FAILED TO CONVERT LITERAL: """<<fightAtk_AttackerNumber>>"""] += AttackTime[ERROR: FAILED TO CONVERT LITERAL: """<<fightAtk_Type>>"""]">>

	-->
	<<warn "CONVERSION ERROR 397048aba0f92b4ba1176c0005fd4b75">>
	<<act 'Next'>>
		<<gt 'fight' 'main'>>
	<</act>>
	<!-- !! clear attack values to prevent figures bleeding through-->
	<<set $fightAtk to null>>
	<<set $fightAtk to null>>
	<<set $fightAtk_Type to null>>
	<<set $fightAtk_Type to null>>
	<<set $fightAtk_TargetType to null>>
	<<set $fightAtk_TargetType to null>>
	<<set $fightAtk_TargetNumber to null>>
	<<set $fightAtk_AttackerNumber to null>>
<</if>>
<!-- !! Make a list of targets that still have health-->
<!-- !  $ARGS[1] = Target Type ('pcs','opp')-->
<<if $location_var[$here][0] == 'AvailableTargets'>>
	<<set $fightAvailTarg to null>>
	<<set $i = 0>>
	<<warn 'JUMP MARKER ENCOUNTERED: :AvailTargetLoop'>>
	<<if $i < arrsize($ARGS[1]+'_health')>>
		<<if dyneval('$result =<<$ARGS[1]>>_health[<<i>>]') > 0>>
			<<setinitpush "$fightAvailTarg" $i>>
		<</if>>
		<<set $i += 1>>
		<<warn 'JUMP COMMAND ENCOUNTERED: jump AvailTargetLoop'>>
	<</if>>
	<<set $result = arrsize('fightAvailTarg')>>
	<<set $i to null>>
	$exit
<</if>>
<!-- !! Pick random target from list of targets.  Returns the Target, or -1 if no target.-->
<!-- !  $ARGS[1] = Target Type ('pcs','opp')-->
<<if $location_var[$here][0] == 'RandomTarget'>>
	<<if setup.func('fight', 'AvailableTargets', $ARGS[1]) > 0>>
		<<set $result = $fightAvailTarg[rand(0,arrsize('fightAvailTarg')) - 1]>>
	<<else>>
		<<set $result = -1>>
	<</if>>
	$exit
<</if>>
<!-- !! Find Action for an NPC fighter to take-->
<!-- !	$ARGS[1] = Attacker Type ('opp','pcs')-->
<!-- !	 ARGS[2] = Attacker party member number-->
<<if $location_var[$here][0] == 'fightAlgorithm'>>
	<<set $AttackerType = $location_var[$here][1]>>
	<<set $AttackerNumber = $ARGS[2]>>
	<<if $AttackerType == 'pcs'>>
		<<set $TargetType = 'opp'>>
	<<else>>
		<<set $TargetType = 'pcs'>>
	<</if>>
	<<set $TargetNumber = setup.func('fight', 'RandomTarget', $TargetType)>>
	<!-- !! Some Target still has some hitpoints-->
	<<if getvar("$TargetNumber") >= 0>>
		<!-- !!Fight Algorithm-->
		<<set $ActionMade = 0>>
		<!-- ! First try to cast spells-->
		<<if dyneval('result=<<$AttackerType>>_magik[<<AttackerNumber>>]') > 0>>
			<!-- FAILED TO CONVERT
				gs 'fight', 'buildCasterSpellList', $dyneval('$result=$<<$AttackerType>>_spells[<<AttackerNumber>>]')
			-----
				<<set gs 'fight' , 'buildCasterSpellList' , $dyneval('$result = $<<$AttackerType>>_spells[ERROR: FAILED TO CONVERT LITERAL: """<<AttackerNumber>>"""]')>>

			-->
			<<warn "CONVERSION ERROR 7b78b70ad6964cc508bd3b250973c7ea">>
			<!-- !Heal self if hurt badly-->
			<<if dyneval('$result =<<$AttackerType>>_health[<<AttackerNumber>>]') < 50>>
				<<set $ActionMade = setup.func('fight','spellListCheck', '$comHealSpells',$AttackerType,AttackerNumber,$AttackerType,AttackerNumber)>>
			<</if>>
			<!-- !Clone if none left-->
			<<if dyneval('$result =<<$AttackerType>>_clone[<<AttackerNumber>>]') = 0 and ActionMade = 0>>
				<<set $ActionMade = setup.func('fight','spellCheck', 'multiclone',$AttackerType,AttackerNumber,$AttackerType,AttackerNumber)>>
				<<if getvar("$ActionMade") == 0>>
					<<set $ActionMade = setup.func('fight','spellCheck', 'clone',$AttackerType,AttackerNumber,$AttackerType,AttackerNumber)>>
				<</if>>
			<</if>>
			<!-- !Shield if low shield-->
			<<if dyneval('$result =<<$AttackerType>>_shield[<<AttackerNumber>>]') = 0 and ActionMade = 0>>
				<<set $ActionMade = setup.func('fight','spellListCheck', '$comShldSpells',$AttackerType,AttackerNumber,$AttackerType,AttackerNumber)>>
			<</if>>
			<!-- !Fog if no Fog , Any fog on the field makes casting fog impossible-->
			<!-- !if opp_fog[ARGS[2]] = 0 and ActionMade = 0:-->
			<!-- !	ActionMade = setup.func('fight','spellCheck', 'fog','opp',ARGS[2],'opp',ARGS[2])-->
			<!-- !end-->
			<!-- !Buff if needed-->
			<!-- !  ToDo - How to determine if buff has already been applied-->
			<!-- !Attack Spell if Possible-->
			<<if getvar("$ActionMade") == 0>>
				<<set $ActionMade = setup.func('fight','spellListCheck', '$comAtkSpells',$TargetType,TargetNumber,$AttackerType,AttackerNumber)>>
			<</if>>
			<!-- !make sure we can continue the fight.-->
			<!-- !if ActionMode = 1:-->
			<<act 'Next'>>
				<<gt 'fight' 'main'>>
			<</act>>
			<!-- !end-->
		<</if>>
		<!-- !Physical attack if nothing else can be done.-->
		<<if getvar("$ActionMade") == 0>>
			<<if rand(0 , dyneval('result =<< $AttackerType>>
				<<gs 'fight' 'Attack' 'Kick' $TargetType $TargetNumber $AttackerNumber>>
			<<elseif rand(0 , dyneval('result =<< $AttackerType>>
				<<gs 'fight' 'Attack' 'Hard Punch' $TargetType $TargetNumber $AttackerNumber>>
			<<else>>
				<<gs 'fight' 'Attack' 'Jab' $TargetType $TargetNumber $AttackerNumber>>
			<</if>>
			<!-- !Spell was cast, so move timer.-->
		<<else>>
			<!-- FAILED TO CONVERT
				dynamic "<<$AttackerType>>_timer[<<AttackerNumber>>] += 50"
			-----
				<<set dynamic "$AttackerType_timer[ERROR: FAILED TO CONVERT LITERAL: """<<AttackerNumber>>"""] += 50">>

			-->
			<<warn "CONVERSION ERROR 83bd69235d25636eb8ae65bc0da64dfb">>
		<</if>>
		<!-- !!This should never happen-->
	<<else>>
		<<gt 'fight' 'main'>>
	<</if>>
	<<set $ActionMade to null>>
	<<set $TargetNumber to null>>
	<<set $TargetType to null>>
	<<set $AttackerType to null>>
	<<set $AttackerNumber to null>>
<</if>>
<<if $location_var[$here][0] == 'opponent'>>
	<<gs 'fight' 'statDisplay'>>
	<<gs 'fight' 'fightAlgorithm' 'opp' $ARGS[1]>>
<</if>>
<<if $location_var[$here][0] == 'player'>>
	<<gs 'fight' 'statDisplay'>>
	<!-- !! If this is the Player character-->
	<<if $location_var[$here][2] == 0>>
		<<if setup.startingCharacterTagsIncludes('magic')>>
			<<actCLA 'Cast a Spell'>>
				<<gs 'fight' 'spellcast'>>
			<</actCLA>>
		<</if>>
		<<if setup.func('fight', 'AvailableTargets', 'opp') > 0>>
			<<set $i = 0>>
			<<warn 'JUMP MARKER ENCOUNTERED: :loop000000'>>
			<<if $i < arrsize('fightAvailTarg')>>
				<<set $op_name_000000 = $opp_name[$fightAvailTarg[$i]]>>
				dynamic "
				<<actCLA 'Kick $op_name_000000'>>
					<!-- FAILED TO CONVERT
						gs 'fight', 'Attack', 'Kick', 'opp', <<fightAvailTarg[i]>>, 0
					-----
						<<gs 'fight' 'Attack' 'Kick' 'opp' ERROR: FAILED TO CONVERT LITERAL: """<<fightAvailTarg[$i]>>""" 0>>

					-->
					<<warn "CONVERSION ERROR c9e4b38c501171e1b136c86b49345920">>
				<</actCLA>>
				<<actCLA 'Punch $op_name_000000 hard'>>
					<!-- FAILED TO CONVERT
						gs 'fight', 'Attack', 'Hard Punch', 'opp', <<fightAvailTarg[i]>>, 0
					-----
						<<gs 'fight' 'Attack' 'Hard Punch' 'opp' ERROR: FAILED TO CONVERT LITERAL: """<<fightAvailTarg[$i]>>""" 0>>

					-->
					<<warn "CONVERSION ERROR e6235c1baf833ebbb8981b808d497fa9">>
				<</actCLA>>
				<<actCLA 'Jab $op_name_000000'>>
					<!-- FAILED TO CONVERT
						gs 'fight', 'Attack', 'Jab', 'opp', <<fightAvailTarg[i]>>, 0
					-----
						<<gs 'fight' 'Attack' 'Jab' 'opp' ERROR: FAILED TO CONVERT LITERAL: """<<fightAvailTarg[$i]>>""" 0>>

					-->
					<<warn "CONVERSION ERROR c8ec7362726f7575fcd1987886933d87">>
				<</actCLA>>
				<<set $op_name_000000 to null>>
				<<set $i += 1>>
				<<warn 'JUMP COMMAND ENCOUNTERED: jump loop000000'>>
			<</if>>
		<</if>>
		<<act 'Surrender'>>
			<<gt 'ender' 'surrender'>>
		<</act>>
		<!-- !! If this is a team member of the player-->
	<<else>>
		<<gs 'fight' 'fightAlgorithm' 'pcs' $ARGS[2]>>
	<</if>>
<</if>>
<!-- !! Builds an array spell list from a comma delimited spell name list-->
<!-- !	$ARGS[1] = comma delimited list of spell names-->
<<if $location_var[$here][0] == 'buildCasterSpellList'>>
	<<set $casterSpellList to null>>
	<<set $tmpStr = $trim($ARGS[1])>>
	<<warn 'JUMP MARKER ENCOUNTERED: :loop000001'>>
	<<set $i = INSTR($tmpStr,',')>>
	<<if getvar("$i") > 0>>
		<<setinitpush "$casterSpellList" $trim($mid($tmpStr,1,i-1))>>
		<<set $tmpStr = $trim($mid($tmpStr,i+1))>>
		<<warn 'JUMP COMMAND ENCOUNTERED: jump loop000001'>>
	<<else>>
		<<setinitpush "$casterSpellList" $trim($tmpStr)>>
	<</if>>
	<<set $i to null>>
	<<set $tmpStr to null>>
	$exit
<</if>>
<!-- !! Check if spell will be cast-->
<!-- !	$ARGS[1] = spell name-->
<!-- !	$ARGS[2] = Target Type ('opp','pcs')-->
<!-- !	 ARGS[3] = Target party member number-->
<!-- !	$ARGS[4] = Caster Type ('opp','pcs')-->
<!-- !	 ARGS[5] = Caster party member number-->
<<if $location_var[$here][0] == 'spellCheck'>>
	<<setinit $spellCheckVar['SpellName'] = $location_var[$here][1]>>
	<<setinit $spellCheckVar['TargetType'] = $location_var[$here][2]>>
	<<setinit $spellCheckVar['TargetNumber'] = $ARGS[3]>>
	<<setinit $spellCheckVar['CasterType'] = $location_var[$here][4]>>
	<<setinit $spellCheckVar['CasterNumber'] = $ARGS[5]>>
	<!-- FAILED TO CONVERT
		spellCheckVar['CasterMana'] = dyneval("result = <<$spellCheckVar['CasterType']>>_mana[<<spellCheckVar['CasterNumber']>>]")
	-----
		<<setinit $spellCheckVar['CasterMana'] = dyneval("result = <<$spellCheckVar['CasterType']>>_mana[ERROR: FAILED TO CONVERT LITERAL: """<<spellCheckVar['CasterNumber']>>"""]")>>

	-->
	<<warn "CONVERSION ERROR fe949732e4fe4e58038669f0acfc4418">>
	<<if ARRPOS('$casterSpellList',$spellCheckVar['SpellName']) >= 0 and $spellCheckVar['CasterMana'] >= $spellMana[$spellCheckVar['SpellName']]>>
		<<if $spellTarget[$spellCheckVar['SpellName']] == 'self'>>
			<<gs 'castSpellNPC' $spellCheckVar['SpellName'] $spellCheckVar['CasterType'] $spellCheckVar['CasterNumber'] $spellCheckVar['CasterType'] $spellCheckVar['CasterNumber']>>
		<<else>>
			<<gs 'castSpellNPC' $spellCheckVar['SpellName'] $spellCheckVar['TargetType'] $spellCheckVar['TargetNumber'] $spellCheckVar['CasterType'] $spellCheckVar['CasterNumber']>>
		<</if>>
		<<set $result = 1>>
	<<else>>
		<<set $result = 0>>
	<</if>>
	<<set $spellCheckVar to null>>
	<<set $spellCheckVar to null>>
	$exit
<</if>>
<!-- !! Check list of spells if they will be cast-->
<!-- !	$ARGS[1] = spell List array name-->
<!-- !	$ARGS[2] = Target Type ('opp','pcs')-->
<!-- !	 ARGS[3] = Target party member number-->
<!-- !	$ARGS[4] = Caster Type ('opp','pcs')-->
<!-- !	 ARGS[5] = Caster party member number-->
<<if $location_var[$here][0] == 'spellListCheck'>>
	<<set $i = 0>>
	<<set $ActionMade1 = 0>>
	<<warn 'JUMP MARKER ENCOUNTERED: :loop000002'>>
	<<if $i < arrsize($ARGS[1]) and getvar("$ActionMade1") == 0>>
		<!-- FAILED TO CONVERT
			ActionMade1 = setup.func('fight','spellCheck','<<$ARGS[1]>>[<<i>>]',$ARGS[2],ARGS[3],$ARGS[4],ARGS[5])
		-----
			<<set $ActionMade1 = setup.func('fight','spellCheck','<<$ARGS[1]>>[ERROR: FAILED TO CONVERT LITERAL: """<<i>>"""]',$ARGS[2],ARGS[3],$ARGS[4],ARGS[5])>>

		-->
		<<warn "CONVERSION ERROR 94ce77acb08e0ac18839ecffe71cce12">>
		<<set $i += 1>>
		<<warn 'JUMP COMMAND ENCOUNTERED: jump loop000002'>>
	<</if>>
	<<set $result = $ActionMade1>>
	<<set $ActionMade1 to null>>
	$exit
<</if>>
<<if $location_var[$here][0] == 'spellcast'>>
	 	<<act 'Next'>>
		<<gt 'fight' 'main'>>
	<</act>>
	<<set setup.func('spellBook' , 'targetable' , '$combatSpells' , 'gt 'fight' , 'main'' , 'pcs_timer[0] += 50')>>
<</if>>
<!-- !!--------------------------------------------------old shit---------------------------------------------------->
<<if $location_var[$here][0] == 'sta'>>
	<<set $menu_off = 1>>
	<<set $damTip = 0>>
	<<set $damTipM = 0>>
	<<set $damTipV = 0>>
	<<set $damTipMV = 0>>
	<<set $magweapbonus = 0>>
	<<set $magweapbonusV = 0>>
	<<set $bonusSh = 0>>
	<<set $bonusShV = 0>>
	<<set $eleSh = 0>>
	<<set $eleShV = 0>>
	<<set $poisonAV = 0>>
	<<set $hidanAtk = 0>>
	<b>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</b>
	<b><<$boydesc>></b> life <b><font color = red><<healthV>></font></b>, mana <b><font color = blue><<manaV>></font></b>, willpower <b><font color = green><<willpowerV>></font></b>
	<<if getvar("$defenceV") > 0>>
		<b><font color = red>Protection <<defenceV>> units</font></b>

	<</if>>
	<<if getvar("$defenceMV") > 0>>
		<b><font color = red>Mana protection <<defenceMV>> units</font></b>

	<</if>>
	<<if getvar("$defenceWV") > 0>>
		<b><font color = red>Will protection <<defenceWV>> units</font></b>

	<</if>>
	Your life <b><font color = red><<pcs_health>></font></b>, mana <b><font color = blue><<pcs_mana>></font></b>, willpower <b><font color = green><<pcs_willpwr>></font></b>
	<<if getvar("$defence") > 0>>
		<b><font color = green>Protection <<defence>> units</font></b>

	<</if>>
	<<if getvar("$defenceM") > 0>>
		<b><font color = green>Mana impact protection <<defenceM>> units</font></b>

	<</if>>
	<<if getvar("$defenceW") > 0>>
		<b><font color = green>Will impact protection <<defenceW>> units</font></b>

	<</if>>
	<<if getvar("$defenceAct") > 0>>
		<b><font color = green><<defenceAct>> Regeneration</font></b>

	<</if>>
	<<if getvar("$defenceActM") > 0>>
		<b><font color = green><<defenceActM>> Mana recovery protection</font></b>

	<</if>>
	<b>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</b>
	<<if getvar("$autocombat_cheat") == 0>>
		<<act 'Continue'>>
	<<gt 'fight' 'start'>>
<</act>>

	<</if>>
	<<if getvar("$autocombat_cheat") == 1>>
		<<gt 'fight' 'start'>>

	<</if>>
<</if>>
