Help

JS-AUTOMATIC-SPELL-SHAPING

For immortals

SyntaxRoom.at(84).shapeSpell("spellname"[,modifier][,'offensive'/'defensive');
   The above line within a javascript behavior will call an automatic spell
shaping function which will add randomly, based on level, various shaping
runes to the spell to be cast. The line can be placed inside a call to
self.cast or the result of the above call can be placed into a string variable.
A percentage chance will determine if the rune gets added - some shaping
runes which have prerequisites such as adjacency requiring area will add the
prerequisite runes if they are not already there.
 
   The function can also be used for casting spells via objects, in this
case the function will use the level of the bearer to determine which
shaping runes to use.
 
   When using this function, you can pass it either a base spell name or
rune makeup, do not pass it a spell alias (i.e.  the area version of a
spell) as this may mean some shaping runes get unnecessarily re-added to
the spell.  In addition, you can pass it a second parameter of any number
greater then zero or less then 5 (including decimals) to act as a modifier
to the inbuilt percentage chances of shaping the spells, eg passing a
modifier of two will mean there is a doubled chance of adding shaping,
passing a modifier of one half will mean there is a halved chance. If the
modifier is not present the percentages are not affected.
 
   The final argument you can pass the function is a string of either defensive
or offensive to control which set of shaping runes to use. Offensive is the
default if this parameter is not included. Note, this must be the third
argument in the function call so if you are using it, you must include a
modifier value beforehand.


Examples:
   self.cast(Room.at(84).shapeSpell("hellfire"),'args',self.fighting);
    - This will cast the spell 'hellfire' with unaffected base percentages
      at the entity which the mobile is currently fighting. It will use the
      default set of offensive shaping runes.
 
   self.cast(Room.at(84).shapeSpell("glacial strike",2),'args',vict);
    - This will cast the spell 'glacial strike' with a doubled chance of
      shaping at the entity represented by variable 'vict'. It will use the
      default set of offensive shaping runes.
 
   self.cast(Room.at(84).shapeSpell(myspell,0.5),'args',actor);
    - This will cast the spell represented by variable 'myspell' with a
      halved chance of applying shaping runes, at the actor of the event
      on which the behavior was triggered. 'myspell' must have been 
      predefined as the name or rune makeup of a spell. It will use the
      default set of offensive shaping runes.
 
   self.cast(Room.at(84).shapeSpell('sanctuary',0.5,'defensive'),'args',actor);
   - This will cast the sanctuary spell with a halved chance of applying
     any of the defensive set of shaping runes.


Offensive Runes used:
-Fiz (Area)
-Adj (Adjacency)
-Max (Maximise)
-Emj (Empower)
-Hei (Heighten)
-Qui (Quicken)
Defensive Runes used:
-Re (Group)
-Las (Lasting)
-Max (Maximise)
-Qui (Quicken)
-Emj (Empower)
-Hei (Heighten)

Recent updates:
- Improved robustness of the 'qui' rune addition to the code. It now uses an
  aura to spawn an event specific to the mobile or object casting the spells.
  There is still a remote possibility of interference but the probability is
  greatly reduced.
- Added support for calling from an object - will now use the bearers level
  to determine shaping if it has one. If there is no bearer or the caller is
  a room then the function will simply return the unaffected base spell rather
  then breaking as before.
- Added support for defensive spells. By passing 'defensive' as a third
  argument to the call it will use the defensive set of shaping runes rather
  then the standard offensive set.

Last edited by Engada in January 2007.