Browse Source

Display Currently Active Spells in Stats Bar; Fix bug preventing multiple running spells; prevent Regeneration from running more than one at a time; make easy function to add spell into run list.

KeyMasterOfGozer 5 years ago
parent
commit
1f18c25e6e
4 changed files with 116 additions and 51 deletions
  1. 25 8
      locations/spell.qsrc
  2. 9 0
      locations/spellList.qsrc
  3. 67 43
      locations/spellTimer.qsrc
  4. 15 0
      locations/stat_display.qsrc

+ 25 - 8
locations/spell.qsrc

@@ -59,14 +59,22 @@ if $ARGS[0] = 'regenerate':
 		regenVal = 5 * SuccessValue
 		! Immediate health gain
 		pcs_health += regenVal
-		! Time when spell ends (totminut is right now, in minutes)
-		spellComplete = totminut + 120
-		! Code that is executed when spell completes
-		$spellCompExec = 'pcs_health += (5 * <<regenVal>>)'
-		! Code that is executed each minute the spell is running
-		$spellTickExec = 'pcs_health += <<regenVal>>'
-		! Name of spell for reportinig purposes
-		$spellTimeName = 'regenerate'
+		! If Regenerate is already running, we only extend.
+		regenArrIdx = arrpos('$spellTimeName','regenerate')
+		if regenArrIdx > -1:
+			! if it''s found, then update only
+			spellComplete[regenArrIdx] = totminut + 120
+			$spellCompExec[regenArrIdx] = 'pcs_health += (5 * <<regenVal>>)'
+			$spellTickExec[regenArrIdx] = 'pcs_health += <<regenVal>>'
+		else
+			! Add Timer:
+			!	spellName = 'regenerate'
+			!	duration  = 120
+			!	CompCode = 'pcs_health += (5 * <<regenVal>>)'
+			!	TickCode = 'pcs_health += <<regenVal>>'
+			gs 'spellTimer', 'add', 'regenerate', 120, 'pcs_health += (5 * <<regenVal>>)', 'pcs_health += <<regenVal>>'
+		end
+
 		'<b><font color = green>Your body surges with life. You feel better already.</font></b>'
 		killvar 'regenVal'
 	else
@@ -74,6 +82,15 @@ if $ARGS[0] = 'regenerate':
 	end
 end
 
+if $ARGS[0] = 'painblock':
+	if SuccessValue > 0:
+		pain['killer'] += 1
+		'<b><font color = green>Your pain recedes into a dull throb.</font></b>'
+	else
+		'<b>The spell fizzles.  Nothing seems to happen.</b>'
+	end
+end
+
 if $ARGS[0] = 'reset':
 	cla
 	!Create mist

+ 9 - 0
locations/spellList.qsrc

@@ -35,6 +35,12 @@ spellTime['regenerate'] = 1
 spellDiff['regenerate'] = 5
 $spellName['regenerate'] = "Regenerate"
 $spellDesc['regenerate'] = "Slowly regain health over time."
+!painblock
+spellMana['painblock'] = 1000
+spellTime['painblock'] = 1
+spellDiff['painblock'] = 8
+$spellName['painblock'] = "Pain Block"
+$spellDesc['painblock'] = "Block your pain for some time."
 !glamour
 spellMana['glamour'] = 500
 spellTime['glamour'] = 1
@@ -300,6 +306,7 @@ $combatSpells[34] = 'greatflood'
 ! List of Non-Combat Spells for use in Menu
 $nonComSpells[0] = 'heal'
 $nonComSpells[1] = 'regenerate'
+$nonComSpells[2] = 'painblock'
 
 
 ! Basic Spells
@@ -310,6 +317,8 @@ $basicSpells[3] = 'wind'
 $basicSpells[4] = 'multiclone'
 $basicSpells[5] = 'energo'
 $basicSpells[6] = 'haste'
+$basicSpells[7] = 'regenerate'
+$basicSpells[8] = 'painblock'
 
 
 ! Elemental Spell Groups

+ 67 - 43
locations/spellTimer.qsrc

@@ -12,56 +12,80 @@
 !	3) $spellTickExec - this holds some code to be executed every minute the spell is in effect
 !	4) $spellTimeName - hold the name of the spell being run
 !
-! Parameters:
+! If First Parameter is 'add', then we add an entry to the arrays
+!	In that case Expected Parameters are:
+!	$ARGS[1] = $spellTimeName - hold the name of the spell being run
+!	 ARGS[2] = Length of spell in minutes
+!	$ARGS[3] = $spellCompExec - this holds some code to run once the spell ends
+!	$ARGS[4] = $spellTickExec - this holds some code to be executed every minute the spell is in effect
+!
+! Else this will process the ticks with these Parameters:
 !	ARGS[0] = prevtotmin = Previous Total Minutes
 !	ARGS[1] = totminut = current Total Minutes since midnight Jan 1st 2016
-if ARGS[0] = 0:
-	BeforeTime = prevtotmin
-else
-	BeforeTime = ARGS[0]
-end
-if ARGS[1] = 0:
-	AfterTime = totminut
+
+if $ARGS[0] = 'add':
+	! Call this to instantiate a timed spell.
+	! Expected Args:
+	!	$ARGS[1] = $spellTimeName - hold the name of the spell being run
+	!	 ARGS[2] = Length of spell in minutes
+	!	$ARGS[3] = $spellCompExec - this holds some code to run once the spell ends
+	!	$ARGS[4] = $spellTickExec - this holds some code to be executed every minute the spell is in effect
+	*pl ""
+	spellCompSize = arrsize('spellComplete')
+	spellComplete[spellCompSize] = totminut + ARGS[2]
+	$spellTimeName[spellCompSize] = $ARGS[1]
+	$spellCompExec[spellCompSize] = $ARGS[3]
+	$spellTickExec[spellCompSize] = $ARGS[4]
+	killvar 'spellCompSize'
 else
-	AfterTime = ARGS[1]
-end
-i=0
-SpellEnds = 0
-:SpellTimerLoop
-if i < arrsize('spellComplete'):
-	NumTicks = AfterTime - BeforeTime
-	if spellComplete[i] <= AfterTime:
-		NumTicks -= AfterTime - spellComplete[i]
-		SpellEnds = 1
+	if ARGS[0] = 0:
+		BeforeTime = prevtotmin
 	else
-		SpellEnds = 0
+		BeforeTime = ARGS[0]
 	end
-	if NumTicks > 0:
-		j=0
-		:SpellTickLoop
-		if j < NumTicks and $spellTickExec[i] ! '':
-			dynamic $spellTickExec[i]
-			j += 1
-			jump 'SpellTickLoop'
-		end
+	if ARGS[1] = 0:
+		AfterTime = totminut
+	else
+		AfterTime = ARGS[1]
 	end
-	if SpellEnds = 1:
-		if $spellCompExec[i] ! '':
-			dynamic $spellCompExec[i]
+	i=0
+	SpellEnds = 0
+	:SpellTimerLoop
+	if i < arrsize('spellComplete'):
+		NumTicks = AfterTime - BeforeTime
+		if spellComplete[i] <= AfterTime:
+			NumTicks -= AfterTime - spellComplete[i]
+			SpellEnds = 1
+		else
+			SpellEnds = 0
+		end
+		if NumTicks > 0:
+			j=0
+			:SpellTickLoop
+			if j < NumTicks and $spellTickExec[i] ! '':
+				dynamic $spellTickExec[i]
+				j += 1
+				jump 'SpellTickLoop'
+			end
+		end
+		if SpellEnds = 1:
+			if $spellCompExec[i] ! '':
+				dynamic $spellCompExec[i]
+			end
+			killvar 'spellComplete', i
+			killvar '$spellTickExec', i
+			killvar '$spellCompExec', i
+			killvar '$spellTimeName', i
 		end
-		killvar 'spellComplete', i
-		killvar '$spellTickExec', i
-		killvar '$spellCompExec', i
-		killvar '$spellTimeName', i
+		i += 1
+		jump 'SpellTimerLoop'
 	end
-	i += 1
-	jump 'SpellTimerLoop'
-end
 
-killvar 'i'
-killvar 'j'
-killvar 'NumTicks'
-killvar 'SpellEnds'
-killvar 'BeforeTime'
-Killvar 'AfterTime'
+	killvar 'i'
+	killvar 'j'
+	killvar 'NumTicks'
+	killvar 'SpellEnds'
+	killvar 'BeforeTime'
+	Killvar 'AfterTime'
+end
 --- spellTimer ---------------------------------

+ 15 - 0
locations/stat_display.qsrc

@@ -1363,6 +1363,21 @@ end
 
 gs 'brother', 'brotherSexCount'
 
+!! List Current Active Spells
+if arrsize('spellComplete') > 0:
+	$tempSpellText="<br><b><font color='#FF99FF'>Active Spells</font></b>"
+	i=0
+	:ActiveSpellLoop
+	if i < arrsize('spellComplete'):
+		$tempSpellText += "<br><font color='#FF99FF'><<$spellName[$spellTimeName[i]]>></font>"
+		i += 1
+		jump 'ActiveSpellLoop'
+	end
+	$stat_msg += func('cleanHTML',$tempSpellText)
+	killvar '$tempSpellText'
+	killvar 'i'
+end
+
 
 !!zero checks marriage
 proverka1 = 0