spellBook.qsrc 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. # spellBook
  2. ! Make a table of Spells to Cast from a given list. the list is in the form of the lists as done in the spellList file.
  3. !
  4. ! $ARGS[0] = Type of List: cast, learn, list
  5. ! This determines the info to be displayed as wel las the HTML formatting
  6. ! $ARGS[1] = the name of the array to use for the spell list.
  7. ! $ARGS[2] = (optional) return Action Code - a dynamic piece of code to run instead of generic return.
  8. ! $ARGS[3] = (optional) Additional code to put in spell link (all spells)
  9. !
  10. $spellBookVar['Type'] = $ARGS[0]
  11. $spellBookVar['Array'] = $ARGS[1]
  12. $spellBookVar['ActionCode'] = $ARGS[2]
  13. $spellBookVar['CodeAfterSpell'] = $ARGS[3]
  14. ! Make sure opptional variables have defaults
  15. if $spellBookVar['ActionCode'] = '':
  16. $spellBookVar['ActionCode'] = 'gt $loc, $loc_arg'
  17. end
  18. if $spellBookVar['CodeAfterSpell'] = '':
  19. $spellBookVar['CodeAfterSpell'] = 'gt $loc, $loc_arg'
  20. end
  21. ! lets the user back out if they don''t want ot cast.
  22. dynamic "act 'Never mind': <<$spellBookVar['ActionCode']>>"
  23. ! This just makes sure the current spellLists are loaded
  24. gs 'spellList'
  25. !-----------------------------------------------------------------------------------------------
  26. ! Choose the type of spell list to determine what info will be displayed and the HTML formatting
  27. ! 1) 'TableText' = The header for the table. The header row
  28. ! 2) 'RowCode' = The code used inside the loop to build the HTML text for that Row.
  29. !! 'learn' type is for displaying which seplls the user is currently learning.
  30. if $spellBookVar['Type'] = 'learn':
  31. $spellBookVar['TableText'] = "
  32. <center>
  33. <table CELLPADDING = '5'>
  34. <tr>
  35. <th align='left'>Spell</th>
  36. <th align='left'>Percent Learned</th>
  37. </tr>"
  38. $spellBookVar['RowCode'] = {
  39. if spellLearn[$ThisSpellName] > 0 and spellKnown[$ThisSpellName] ! 1:
  40. $result = "
  41. <tr>
  42. <td align='left'><<$spellName[$ThisSpellName]>></td>
  43. <td align='right'><<spellLearn[$ThisSpellName]>></td>
  44. </tr>"
  45. spellBookVar['Counter'] += 1
  46. else
  47. $result = ''
  48. end
  49. }
  50. !! 'list' type is list of castable spells. This makes a table of spells for the user to cast.
  51. elseif $spellBookVar['Type'] = 'cast':
  52. $spellBookVar['TableText'] = "
  53. <center>
  54. <table CELLPADDING = '5'>
  55. <tr>
  56. <th align='left'>Spell</th>
  57. <th align='left'>Mana</th>
  58. <th align='left'>Description</th>
  59. </tr>"
  60. $spellBookVar['RowCode'] = {
  61. if spellKnown[$ThisSpellName] = 1:
  62. if $spellOptDesc[$ThisSpellName] = '':
  63. ! If the spell has no Options, we jsut list it out for casting
  64. $tmpHTMLCode = "
  65. <tr>
  66. <td align='left'><a href=""EXEC: gs 'castSpell', '<<$ThisSpellName>>'& <<$spellBookVar['CodeAfterSpell']>>""><<$spellName[$ThisSpellName]>></a></td>
  67. <td align='right'><<spellMana[$ThisSpellName]>></td>
  68. <td align='left'><<$spellDesc[$ThisSpellName]>></td>
  69. </tr>"
  70. else
  71. ! If the spell does have options, we make a row for spell info, and loop through additional rows
  72. ! with options for the user to pick
  73. $tmpHTMLCode = "
  74. <tr>
  75. <td align='left'><<$spellName[$ThisSpellName]>></td>
  76. <td align='right'><<spellMana[$ThisSpellName]>></td>
  77. <td align='left'><<$spellDesc[$ThisSpellName]>></td>
  78. </tr>"
  79. n=0
  80. :RowCodeLoop98
  81. if n < arrsize('<<$spellOptDesc[$ThisSpellName]>>'):
  82. $spellBookVar['tmpVal'] = dyneval('$result = <<$spellOptVal[$ThisSpellName]>>[<<n>>]')
  83. $spellBookVar['tmpName']= dyneval('$result = <<$spellOptDesc[$ThisSpellName]>>[<<n>>]')
  84. $tmpHTMLCode += "
  85. <tr>
  86. <td align='left'></td>
  87. <td align='left'><a href=""EXEC: gs 'castSpell', '<<$ThisSpellName>>', '<<$spellBookVar['tmpVal']>>' & <<$spellBookVar['CodeAfterSpell']>>""><<$spellBookVar['tmpName']>></a></td>
  88. <td align='left'></td>
  89. </tr>"
  90. n += 1
  91. jump 'RowCodeLoop98'
  92. end
  93. end
  94. $result = $tmpHTMLCode
  95. spellBookVar['Counter'] += 1
  96. killvar '$tmpHTMLCode'
  97. killvar 'n'
  98. else
  99. $result = ''
  100. end
  101. }
  102. !! 'list' type is list of castable targetable spells. This makes a table of spells for the user to cast in combat.
  103. elseif $spellBookVar['Type'] = 'targetable':
  104. $spellBookVar['TableText'] = "
  105. <center>
  106. <table CELLPADDING = '5'>
  107. <tr>
  108. <th align='left'>Spell</th>
  109. <th align='left'>Mana</th>
  110. <th align='left'>Targets</th>
  111. <th align='left'>Description</th>
  112. </tr>"
  113. $spellBookVar['RowCode'] = {
  114. if spellKnown[$ThisSpellName] = 1:
  115. $tmpHTMLCode = "
  116. <tr>
  117. <td align='left'><<$spellName[$ThisSpellName]>></td>
  118. <td align='right'><<spellMana[$ThisSpellName]>></td>
  119. <td align='center'>"
  120. if $spellTarget[$ThisSpellName] = 'self':
  121. $tmpHTMLCode += "
  122. <a href=""EXEC: *clr & gs 'castSpell', '<<$ThisSpellName>>', 'pcs', 0, 0 & <<$spellBookVar['CodeAfterSpell']>>"">You</a>"
  123. elseif $spellTarget[$ThisSpellName] = 'team':
  124. n=0
  125. :RowCodeLoop96
  126. if n < arrsize('pcs_health'):
  127. $spellBookVar['tmpName']= dyneval('$result = $pcs_name[<<n>>]')
  128. $tmpHTMLCode += "
  129. <a href=""EXEC: *clr & gs 'castSpell', '<<$ThisSpellName>>', 'pcs', <<n>>, 0 & <<$spellBookVar['CodeAfterSpell']>>""><<$spellBookVar['tmpName']>></a>
  130. <br>"
  131. n += 1
  132. jump 'RowCodeLoop96'
  133. end
  134. else
  135. n=0
  136. :RowCodeLoop97
  137. if n < arrsize('opp_health'):
  138. $spellBookVar['tmpName']= dyneval('$result = $opp_name[<<n>>]')
  139. $tmpHTMLCode += "
  140. <a href=""EXEC: *clr & gs 'castSpell', '<<$ThisSpellName>>', 'opp', <<n>>, 0 & <<$spellBookVar['CodeAfterSpell']>>""><<$spellBookVar['tmpName']>></a>
  141. <br>"
  142. n += 1
  143. jump 'RowCodeLoop97'
  144. end
  145. end
  146. $tmpHTMLCode += " </td>
  147. <td align='left'><<$spellDesc[$ThisSpellName]>></td>
  148. </tr>"
  149. $result = $tmpHTMLCode
  150. spellBookVar['Counter'] += 1
  151. killvar '$tmpHTMLCode'
  152. killvar 'n'
  153. else
  154. $result = ''
  155. end
  156. }
  157. !! Default is a list of spells with descriptio nand mana cost listed.
  158. else
  159. $spellBookVar['TableText'] = "
  160. <center>
  161. <table CELLPADDING = '5'>
  162. <tr>
  163. <th align='left'>Spell</th>
  164. <th align='left'>Mana</th>
  165. <th align='left'>Description</th>
  166. </tr>"
  167. $spellBookVar['RowCode'] = {
  168. if spellKnown[$ThisSpellName] = 1:
  169. if $spellOptDesc[$ThisSpellName] = '':
  170. ! If the spell has no Options, we jsut list it out for casting
  171. $tmpHTMLCode = "
  172. <tr>
  173. <td align='left'><<$spellName[$ThisSpellName]>></td>
  174. <td align='right'><<spellMana[$ThisSpellName]>></td>
  175. <td align='left'><<$spellDesc[$ThisSpellName]>></td>
  176. </tr>"
  177. else
  178. ! If the spell does have options, we make a row for spell info, and loop through additional rows
  179. ! with options for the user to pick
  180. $tmpHTMLCode = "
  181. <tr>
  182. <td align='left'><<$spellName[$ThisSpellName]>></td>
  183. <td align='right'><<spellMana[$ThisSpellName]>></td>
  184. <td align='left'><<$spellDesc[$ThisSpellName]>></td>
  185. </tr>"
  186. n=0
  187. :RowCodeLoop99
  188. if n < arrsize('<<$spellOptDesc[$ThisSpellName]>>'):
  189. $spellBookVar['tmpVal'] = dyneval('$result = <<$spellOptVal[$ThisSpellName]>>[<<n>>]')
  190. $spellBookVar['tmpName']= dyneval('$result = <<$spellOptDesc[$ThisSpellName]>>[<<n>>]')
  191. $tmpHTMLCode += "
  192. <tr>
  193. <td align='left'></td>
  194. <td align='left'><<$spellBookVar['tmpName']>></td>
  195. <td align='left'></td>
  196. </tr>"
  197. n += 1
  198. jump 'RowCodeLoop99'
  199. end
  200. end
  201. $result = $tmpHTMLCode
  202. spellBookVar['Counter'] += 1
  203. killvar '$tmpHTMLCode'
  204. killvar 'n'
  205. else
  206. $result = ''
  207. end
  208. }
  209. end
  210. i = 0
  211. spellBookVar['ArraySize'] = dyneval("result = arrsize('<<$spellBookVar['Array']>>')")
  212. spellBookVar['Counter'] = 0
  213. :SpellListLoop
  214. $ThisSpellName = dyneval("$result = <<$spellBookVar['Array']>>[<<i>>]")
  215. if i < spellBookVar['ArraySize']:
  216. !$spellBookVar['RowCode']
  217. $spellBookVar['TableText'] += dyneval($spellBookVar['RowCode'])
  218. i += 1
  219. jump 'SpellListLoop'
  220. end
  221. $spellBookVar['TableText'] += "
  222. </table>
  223. </center>"
  224. if spellBookVar['Counter'] = 0:
  225. $spellBookVar['TableText'] = "<center>You have no spells in this list.</center>"
  226. end
  227. !*pl $spellBookVar['TableText']
  228. $result = func('cleanHTML',$spellBookVar['TableText'])
  229. killvar 'i'
  230. killvar '$ThisSpellName'
  231. killvar '$spellBookVar'
  232. killvar 'spellBookVar'
  233. --- spellBook ---------------------------------