Browse Source

Combat Magic restored for PC. Spells working for NPCs, but no spells in Fight AI. That is next step

KeyMasterOfGozer 4 years ago
parent
commit
85c11b503e
5 changed files with 79 additions and 11 deletions
  1. 6 2
      locations/castSpell.qsrc
  2. 5 1
      locations/castSpellNPC.qsrc
  3. 7 4
      locations/fight.qsrc
  4. 3 2
      locations/spell.qsrc
  5. 58 2
      locations/spellBook.qsrc

+ 6 - 2
locations/castSpell.qsrc

@@ -18,8 +18,12 @@ $SpellArgs = ""
 i=1
 :ArgLoop
 if i < arrsize('$ARGS'):
+	if $ARGS[i] = '':
+		$SpellArgs += ", <<ARGS[i]>>"
+	else
+		$SpellArgs += ", '<<$ARGS[i]>>'"
+	end
 	i += 1
-	$SpellArgs = $SpellArgs + ", '<<$ARGS[i - 1]>>'"
 	jump 'ArgLoop'
 end
 killvar 'i'
@@ -67,10 +71,10 @@ if spellKnown[$SpellID] = 1:
 		minut += spellTime[$SpellID]
 
 		gs 'stat'
-
 		$SpellExec = "gs 'spell', '<<$SpellID>>', '<<spellSuccess>>'<<$SpellArgs>>"
 
 		dynamic $SpellExec
+
 	else
 		*pl "You realize you don''t have enough mana for this spell."
 	end

+ 5 - 1
locations/castSpellNPC.qsrc

@@ -20,8 +20,12 @@ $SpellArgs = ""
 i=5
 :ArgLoopNPC
 if i < arrsize('$ARGS'):
+	if $ARGS[i] = '':
+		$SpellArgs += ", <<ARGS[i]>>"
+	else
+		$SpellArgs += ", '<<$ARGS[i]>>'"
+	end
 	i += 1
-	$SpellArgs = $SpellArgs + ", '<<$ARGS[i - 1]>>'"
 	jump 'ArgLoopNPC'
 end
 killvar 'i'

+ 7 - 4
locations/fight.qsrc

@@ -493,7 +493,7 @@ if $ARGS[0] = 'player':
 	else
 		TargetNumber = 2
 	end
-		
+
 	if pcs_magik > 0:
 		act 'Cast a Spell': gs 'fight', 'spellcast'
 	end
@@ -540,6 +540,12 @@ if $ARGS[0] = 'player':
 end
 
 
+if $ARGS[0] = 'spellcast':
+	cls
+	cla
+	func('spellBook', 'targetable', '$combatSpells', 'gt ''fight'', ''main''', 'gt ''fight'', ''main''')
+end
+
 if $ARGS[0] = 'opp_spellcast':
 end
 
@@ -553,9 +559,6 @@ end
 
 
 
-
-
-
 !!--------------------------------------------------old shit--------------------------------------------------
 
 

+ 3 - 2
locations/spell.qsrc

@@ -18,12 +18,12 @@ SuccessValue = $ARGS[1]
 
 ! ARGS for Combat Spells if Applicable
 $TargetType = $ARGS[2]
-if $spellTarget[$ARGS[0]] = 'self':
+if $spellTarget[$ARGS[2]] = 'self':
 	! Self target spell, Caster and target are the same
 	$CasterType = $TargetType
 	TargetNumber = ARGS[3]
 	CasterNumber = ARGS[3]
-elseif $spellTarget[$ARGS[0]] = 'team':
+elseif $spellTarget[$ARGS[2]] = 'team':
 	! Team target spell targets person on the same team
 	$CasterType = $TargetType
 	TargetNumber = ARGS[3]
@@ -405,6 +405,7 @@ if $ARGS[0] = 'weapon':
 		'<b>The spell fizzles.  Nothing seems to happen.</b>'
 	end
 	!xgt'atak','player'}
+	"weapon"
 end
 
 if $ARGS[0] = 'wind':

+ 58 - 2
locations/spellBook.qsrc

@@ -22,7 +22,7 @@ if $spellBookVar['CodeAfterSpell'] = '':
 end
 
 ! lets the user back out if they don''t want ot cast.
-act 'Never mind':dynamic $spellBookVar['ActionCode']
+dynamic "act 'Never mind': <<$spellBookVar['ActionCode']>>"
 
 ! This just makes sure the current spellLists are loaded
 gs 'spellList'
@@ -98,6 +98,62 @@ elseif $spellBookVar['Type'] = 'cast':
 				end
 
 			end
+			$result = $tmpHTMLCode
+			spellBookVar['Counter'] += 1
+			killvar '$tmpHTMLCode'
+			killvar 'n'
+		else
+			$result = ''
+		end
+	}
+!! 'list' type is list of castable targetable spells.  This makes a table of spells for the user to cast in combat.
+elseif $spellBookVar['Type'] = 'targetable':
+	$spellBookVar['TableText'] = "
+	<center>
+		<table CELLPADDING = '5'>
+			<tr>
+				<th align='left'>Spell</th>
+				<th align='left'>Mana</th>
+				<th align='left'>Targets</th>
+				<th align='left'>Description</th>
+			</tr>"
+	$spellBookVar['RowCode'] = {
+		if spellKnown[$ThisSpellName] = 1:
+			$tmpHTMLCode = " 
+			<tr>
+				<td align='left'><<$spellName[$ThisSpellName]>></td>
+				<td align='right'><<spellMana[$ThisSpellName]>></td>
+				<td align='center'>"
+			if $spellTarget[$ThisSpellName] = 'self':
+				$tmpHTMLCode += " 
+				<a href=""EXEC: gs 'castSpell', '<<$ThisSpellName>>', 'pcs', 0, 0 & <<$spellBookVar['CodeAfterSpell']>>"">You</a>"
+			elseif $spellTarget[$ThisSpellName] = 'team':
+				n=0
+				:RowCodeLoop96
+				if n < arrsize('pcs_health'):
+					$spellBookVar['tmpName']= dyneval('$result = $pcs_name[<<n>>]')
+					$tmpHTMLCode += " 
+					<a href=""EXEC: gs 'castSpell', '<<$ThisSpellName>>', 'pcs', <<n>>, 0 & <<$spellBookVar['CodeAfterSpell']>>""><<$spellBookVar['tmpName']>></a>
+					<br>"
+					n += 1
+					jump 'RowCodeLoop96'
+				end
+			else
+				n=0
+				:RowCodeLoop97
+				if n < arrsize('opp_health'):
+					$spellBookVar['tmpName']= dyneval('$result = $opp_name[<<n>>]')
+					$tmpHTMLCode += " 
+					<a href=""EXEC: gs 'castSpell', '<<$ThisSpellName>>', 'opp', <<n>>, 0 & <<$spellBookVar['CodeAfterSpell']>>""><<$spellBookVar['tmpName']>></a>
+					<br>"
+					n += 1
+					jump 'RowCodeLoop97'
+				end
+			end
+			$tmpHTMLCode += " </td>
+				<td align='left'><<$spellDesc[$ThisSpellName]>></td>
+			</tr>"
+
 			$result = $tmpHTMLCode
 			spellBookVar['Counter'] += 1
 			killvar '$tmpHTMLCode'
@@ -180,7 +236,7 @@ $spellBookVar['TableText'] += "
 if spellBookVar['Counter'] = 0:
 	$spellBookVar['TableText'] = "<center>You have no spells in this list.</center>"
 end
-
+!*pl $spellBookVar['TableText']
 $result = func('cleanHTML',$spellBookVar['TableText'])
 
 killvar 'i'