This script allows you to add “feature conditions” to any objects that hold features. These conditions are used to control whether the features from an object are applied to your actor or not.
For example, suppose you have shield equips that have special elemental immunities when the “guard” state is applied. You can add these features to the shield and then use feature conditions to indicate that the “guard” state must be applied before the features are transferred.
Feature conditions can be applied at the object level, which means all conditions must be met for any features to be applied.
Feature conditions can also be applied at the feature level, which provides finer control over when specific features can be applied.
Script: download here
Place this script below Materials and above Main
To add feature conditions, use the notetag for any objects with features, such as Actors, Classes, Weapons, Armors, Enemies, or States. If you are using
the Feature Manager, then it will be applied to skills and items as well.
Object-level feature conditions
For object-level conditions, use the note-tag of the form
<feature condition> FORMULA </feature condition>
For any valid ruby formula that returns true or false. Three variables are available for your convenience:
a - subject the feature applies to s - game switches v - game variables
By “subject” I refer to “actor” or “enemy”. For example, a state can be applied to both actors or enemies, so if the enemy has the state, then that enemy is
the subject. If the actor has the state, then that actor is the subject. Be careful when writing your formulas.
Applying conditions to individual features is the same as object-level
conditions, except in the note-tag you specify which feature it applies to
<feature condition: x> FORMULA </feature condition> <feature condition: x, y, ... > FORMULA </feature condition>
Where x and y are the ID’s of the features. The ID of the feature is based on
its position in the list, so the feature at the top of the list has ID 1, the
next one has ID 2, and so on.
You can specify multiple ID’s by separating them with commas.
Important Note on Formulas
Features are accessed during actor initialization. This means that if your condition references an actor, it will be thrown into a recursive loop and your game will crash.
Here are some quick examples of some conditions you might have
- Feature 2 and 3 are applied only if the party has more than 5000 gold
<feature condition: 2,3 > $game_party.gold > 5000 </feature condition>
- Features of the object are only applied if state 23 is applied
<feature condition> a.state?(23) </feature condition>