|
@@ -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 ---------------------------------
|