castSpellNPC.qsrc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # castSpellNPC
  2. ! Used for NPCs to cast a spell.
  3. !
  4. ! $ARGS[0] is the spell being cast
  5. ! $ARGS[1] = Target Type ('opp','pcs')
  6. ! ARGS[2] = Target party member number
  7. ! $ARGS[3] = Caster Type ('opp','pcs')
  8. ! ARGS[4] = Caster party member number
  9. ! ARGS[5-n] are any parameters that need to be passed to the Spell
  10. !
  11. ! Example:
  12. ! gs 'castSpell', 'teleport', 'CentralPark'
  13. gs 'spellList'
  14. spellSuccess = 1
  15. $SpellID = $ARGS[0]
  16. $SpellArgs = ""
  17. i=5
  18. :ArgLoopNPC
  19. if i < arrsize('$ARGS'):
  20. if $ARGS[i] = '':
  21. $SpellArgs += ", <<ARGS[i]>>"
  22. else
  23. $SpellArgs += ", '<<$ARGS[i]>>'"
  24. end
  25. i += 1
  26. jump 'ArgLoopNPC'
  27. end
  28. killvar 'i'
  29. manaCost = spellMana[$SpellID]
  30. casterMana = dyneval('result=<<$ARGS[3]>>_mana[<<ARGS[4]>>]')
  31. if casterMana >= manaCost:
  32. dynamic '<<$ARGS[3]>>_mana[<<ARGS[4]>>] -= <<manaCost>>'
  33. $SpellExec = "gs 'spell', '<<$SpellID>>', '<<spellSuccess>>', '<<$ARGS[1]>>', <<ARGS[2]>>, <<ARGS[4]>><<$SpellArgs>>"
  34. dynamic $SpellExec
  35. else
  36. 'Not enough mana to cast the spell.'
  37. end
  38. killvar '$SpellID'
  39. killvar '$SpellExec'
  40. killvar 'spellSuccess'
  41. killvar 'manaCost'
  42. killvar 'casterMana'
  43. --- castSpellNPC ---------------------------------