:: castSpell
<<set $here = 'castSpell'>>
<<set $ARGS = $location_var[$here]>>
<!-- ! Used to cast a spell.-->
<!-- !-->
<!-- ! ARGS[0] is the spell being cast-->
<!-- !	Valid Spells are listed below-->
<!-- !		teleport-->
<!-- ! ARGS[1-n] are any parameters that need to be passed to the Spell-->
<!-- !-->
<!-- !	Example:-->
<!-- !		gs 'castSpell', 'teleport', 'CentralPark'-->
<<gs 'spellList'>>
<<set $spellSuccess = 0>>
<<set $SpellID = $location_var[$here][0]>>
<<set $SpellArgs = "">>
<<set $i = 1>>
<<warn 'JUMP MARKER ENCOUNTERED: :ArgLoop'>>
<<if $i < arrsize('$ARGS')>>
	<<if $location_var[$here][$i] == ''>>
		<<set $SpellArgs += ", ARGS[$i]">>
	<<else>>
		<<set $SpellArgs += ", '$ARGS[$i]'">>
	<</if>>
	<<set $i += 1>>
	<<warn 'JUMP COMMAND ENCOUNTERED: jump ArgLoop'>>
<</if>>
<<set $i to null>>
<<if getvar("$spellKnown["+$SpellID+"]") == 1>>
	<!-- !Make a Skill Check to see if the Spell succeeds-->
	<<set $spellRoll = pcs_splcstng - spellDiff[$SpellID] - ($pc.horny / 5) + rand(1,100)>>
	<<if getvar("$spellRoll") > 50>>
		<!-- !Critical Success-->
		<<set $spellSuccess = 2>>
		<<run $pc.skillExperienceGain('splcstng',rand(1,spellDiff[$SpellID])` + `rand(0,5))>>
	<<elseif getvar("$spellRoll") > 10>>
		<!-- !Success-->
		<<set $spellSuccess = 1>>
		<<run $pc.skillExperienceGain('splcstng',rand(1,spellDiff[$SpellID]))>>
	<<elseif getvar("$spellRoll") > -20>>
		<!-- !Failure-->
		<<set $spellSuccess = 0>>
		<<run $pc.skillExperienceGain('splcstng',`rand(1,spellDiff[$SpellID])` / 2)>>
	<<else>>
		<!-- !Critical Failure-->
		<<set $spellSuccess = -1>>
		<<run $pc.skillExperienceGain('splcstng',`rand(1,spellDiff[$SpellID])` / 2)>>
	<</if>>
	<<set $spellRoll to null>>
	<!-- !Incur the costs of casting the spell-->
	<<if getvar("$spellSuccess") == 2>>
		<<set $manaCost = $spellMana[$SpellID] / 2>>
	<<elseif getvar("$spellSuccess") == -1>>
		<<set $manaCost = $spellMana[$SpellID] * 2>>
	<<else>>
		<<set $manaCost = $spellMana[$SpellID]>>
	<</if>>
	<<if $pcs_mana >= $manaCost>>
		<<set $pcs_mana -= $manaCost>>
		<!-- !pcs_willpwr -= spellWill[$SpellID]-->
		<<set $arouseVal = $manaCost / 50>>
		<<arouse 'voyeur' $arouseVal >>
		<<set $time.minutes -= $arouseVal>>
		<<set $arouseVal to null>>
		<<set $manaCost to null>>
		<<set $time.minutes += $spellTime[$SpellID]>>
		<<set $SpellExec = "gs 'spell', '$SpellID', 'spellSuccess'$SpellArgs">>
		<<SpellExec>>
	<<else>>
		 * pl "You realize you don't have enough mana for this spell."
	<</if>>
<</if>>
<<set $SpellID to null>>
<<set $SpellArgs to null>>
<<set $SpellExec to null>>
<<set $spellSuccess to null>>
<<set $arouseVal to null>>
<<set $manaCost to null>>
