Scripting for Feats

Feat Code

There are five pieces of code you can write. All of these are optional. Except for the last one (Other) you cannot declare any subroutines.

The Cr object holds all the creature's information and is always accessible from any of the feat's subroutines. See the Creature object for more information. To edit a creature's attacks see the Attack object .

If you will need the character's race, check the "Return Race in cRace" box. The object cRace holds the race, but cRace may not be valid. Do not access cRace if it is not valid (check using func.ValidRa(cRace))! See the Race object specification for available members in cRace.

Getting a Feat

Enter the code to run when the character gets the feat for the first time. Usually, this code gives bonuses to various stats. If the "Level-Dependant Effect" box is checked then this code will be executed each time the PC gains a level. Do not check the box if the feat will give cumulative bonuses (for example, toughness would give 3 hp at each level if "Level-Dependant Effect" were checked). Also, do not use check this box if the feat asks something of the user (for example Weapon Focus requires the user to select what weapon).

If for some reason the feat's effects cannot be applied (for example, the user did not select a weapon when asked to apply Weapon Focus), you must set FeatGet = False which indicates that the feat will not be selected after all. FeatGet is set to True by default.

If the "Can Take Feat Multiple Time" box is checked then the user can press "Take Again" to apply the effects again (for example, for a new weapon).

Removing a Feat

Code to remove the bonuses obtained when the "Getting a Feat" code was executed. It's unusual for a PC to remove a feat, but it can happen if the user selected the wrong feat. Make sure all effects are removed. Use the race to get some default values if needed.

If for some reason the feat's effects cannot be removed (for example, the user did not select a weapon when asked to apply Weapon Focus), you must set FeatRemove = False which indicates that the feat will stay selected after all. FeatRemove is set to True by default.

Using a Feat

This code is executed when the user presses the 'Use Feat' button from the feats tab. This can be used to make a reflex save with a special bonus and report the result, for example. User input can be useful in these cases.

Stop Using Feat

This code is executed when the user presses the 'Stop Using Feat' button from the feats tab. This could be necessary if 'Use Feat' gives only a temporary bonus.

Resting

The 'Rest' code is run whenever the user selects one of the Rest menu options (see Main Window Menus ). All calls to this code have one parameter set, Hours, an integer. Hours is set to 8 or 24 hours when called from the Rest menu, but is set to 0 when called manually, using the Rest button from the Feats Frame . When Hours is 0, you can have the script output to the combat log or use dialogs. Otherwise, it is not recommended to do so.

Other Subroutines

You can enter subroutines or functions that will be used by any of the three other functions. You must declare full subroutines, for example:

Sub MySubroutine(Argument1, Argument 2)

(... enter some code...)

End Sub

Function MyFunction (Argument1, Argument 2)

(... enter some code...)

'Return a value like this

MyFunction = 12

End Function

Special

First, you must choose what the special code will do by selecting an option in "Use of Special Subroutine". Set Nothing if no special code will be used. Since your Special subroutine will be called often, keep it as short as possible to avoid slowing the program. Also, never ask for any user input in a Special subroutine for Attack Bonus or Condition Effects calculation.

Attack Bonus Calculation:

The code is called whenever the attack/damage bonuses are calculated for any weapon the character has. The object cAtt is the attack in question. Make sure you only modify values that are re-calculated each time. For example:

cAtt. WeaponDamageBonus = cAtt. WeaponDamageBonus + 1

will cause the weapon's damage bonus to grow uncontrollably, because WeaponDamageBonus is a persistent value for the attack.

Condition Effects Calculation:

This code is called right after all the effects from all conditions and magic items are totaled up. You can add to or change any bonus that comes from a condition. Only change variables that are recalculated in this step. This code is executed before the bonuses are applied throughout (for example, before calculating the total AC).

Set the variable FeatSpecial to a string describing the effect of the condition. This gives feedback to the user in windows like the Detailed AC Bonuses.

Metamagic Feats:

This code is called when casting a spell, before calculating DC or decrementing from the spell slots available. Usually metamagic feats apply to only one or a few spells. The following public variables are set and can be modified by the code:

SpellName, SpellNum (# in cr.SpellList), SpellLevel (for the appropriate class), SpellSlotUsed (same as Spell Level but usually increased), ClassAbbrev (that casts this spell, like 'Wiz'), ClassLevel (effective casting level; only for ClassAbbrev), DCBonus, FeatDescription (string added in the combat log to indicate the feat's effect).

Forced is true if the feat must be applied no matter what; usually used when an item reproduces a spell effect that is metamagicked. For example, a potion could be Aid with the feat Spell Focus applied; in this case Forced is true and the script doesn't check if the item is of the correct school.

The following aren't used yet but are reserved for future versions: DurationMult (multiply duration by this), RangeMult (multiplier for the range), EffectMult (multiplier of variable numeric effects), Maximized (set to true if all variable values are maximized).

NoteStr, OtherStr, OtherInt1, OtherInt2

Metapsionic Feats:

The code for metapsionic feats is identical to that of metamagic feats, with 4 extra variables:

OrigPP is the original number of power points for this power. FinalPP is the number of PP after applying this feat. AugmentPP is the number of PP applied to augmenting the power's effect (only used by the Augment Power "feat"). FocusUsed is the number of psionic focuses expended by the feat (usually PC's only have 1 psionic focus).

Additionally, the SpellSlotUsed variable will be ignored for metapsionics.





Documentation for DM Genie and Player Genie, page Script_Feat. Copyright © Mad Scientist Studios, 2006.
Help Contents   |   DM Genie home page
Click here if you cannot see the table of contents on the left