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>
Hey there, I’m looking to activate features based on the condition that the actor has a certain weapon, or armor TYPE equipped (i.e. a lance, a sword, heavy armor, etc.). Earlier in the thread, the same question was asked and answered, but the code provided causes a SystemStack error. ( a.equip_wtype_ok?(WTYPE_ID) )
That seems like a method that is simply looking to see if the actor CAN equip a certain type of weapon, not if they actually ARE equipped with a weapon of that type, based on the description of the method in Game_BattlerBase. What would be the proper syntax to look for a specific gear type (weapon or armor) and check is item(s) of those types are actually equipped on the actor?
i am a noob at ruby so this may be a silly question but how can i use in game variable as the condtion?
i tried calling it v.V == 1, but it didn’t work out
nevermind i found the answer in a guide for another of your programms
Hi Hime. I know your script evals the conditions for the features. I created a simple snippet to check if someone is in the battle party (and also alive). Obviously I had to create a snippet for that (it just wouldn’t fit the notebox). The check itself works fine, I put it under Game_Interpreter. But when the game runs, I get a NoMethod error. If I don’t add the feature condition and call it from the script call, the script does run. I know it’s because the snippet I made is out of scope, that’s why the NoMethod error, but how can I fix it?
Sorry for the extra long post, I don’t even know if that’s the right place for it.
You should be able to put it in the note-box, even if you put it on multiple lines.
Formulas are executed in the context of the feature, which is kind of useless.
For your purposes, you may consider putting it inside Game_Battler and then calling it via
Now you can define the method for both Game_Actor and Game_Enemy and you suddenly have a feature condition that works for both actors and enemies.
First, thanks for the quick reply!
I tried putting it in Game_Battler (or even Game_Actor) and I got a Stack level too deep error.
What is the method you have written? Consider posting it on the issue tracker since it’s easier to look at code there
I have put in… (without the spaces after <)
< feature condition: 1>
< /feature condition>
< feature condition: 1,2>
< /feature condition>
< feature condition: 1,2,3>
< /feature condition>
but it doesnt work as I think it ought to. Instead, as soon as you get 1 mana, you get all features. I want to make it so that the more mana (1,2,3 etc) you currently have, the more features you get. Any help?
Checking for equality is ==, not =. See if using == solves the problem.
Negative, Ghost Rider.
It is weird too, when I reverse it (mp==3,==2,==1) it results in something else. I think, I will make permstates, each seperate with its own Feature Condition. Clean fix without causing too much issue, lol. Thanks for the response.
Question: how do i get a specific feature to show up if the actor/class has a certain ‘weapon type’ equipped? I don’t mean specific weapons, i mean like swords, axes, guns, bows, staves, etc.
Look up the ID of the weapon type in your Terms database and then plug that into this formula:
Sorry about bothering you yet again, but i have a question. How should i make switch conditions? Thanks!
Nevermind, i think i got it.
<feature condition: x>
You can also use the short-hand
Which refers to switch 1.
awesome script! Makes a lot of duplicating redundant and as such is always welcome!
A little contradiction to your writeup, what I found in my project: When tagging multiple features in the way you described (feature condition: x, y, z, …), in my case with a state, it doesn't work and always applies the latest set of features on the state.
lHowever, when I tag the features alone feature per feature (feature condition: x, then another tag with feature condition: y, etc) it works just fine.
Of course, could be a minor compatibility issue since I didn't test it on an empty project, but I just thought I'd mention it. Thanks for the sweet script in any case!
Oops, you're right, I wrote it down because I was going to implement it, but I guess I only implemented it in my thoughts.
I've updated it so that it actually parses multiple ID's.
That's very nice of you! =)
This is a pretty sick function actually. The amount of possibility this brings to the game is immense. I will begin testing it shortly. Thanks!