Enemy Action Conditions
This script allows you to define multiple custom action conditions on top of the conditions provided by the database.
The database does not allow you to set multiple conditions for a single action. This script addresses this issue by allowing you to create multiple conditions.
In order to provide flexible conditions for game developers, custom action conditions are provided as formulas, allowing you to condition your actions on anything you can imagine.
Download
Script: download here
Installation
In the script editor, place this script below Materials and above Main
Usage
When setting up the enemy in the database, you can set up the actions that the
enemy can use. Each action has an ID: the first action on the list is ID 1,
the second action on the list is ID 2.
To add an action condition to a particular action, use the note-tag
<action condition: ID> FORMULA </action condition>
Where the ID is the action ID, and the FORMULA is any valid formula that
returns true or false. All conditions must be met in order for the action to
be usable.
The following formula variables are available:
a - the enemy p - game party t - game troop s - game switches v - game variables
Hey, I’m trying to check if an enemy is at level 6.
Example 1: a.level >= 4
Example 2: a.level == 6
I use enemy levels and parameter table. Both scripts from this website.
It only works at level 1, even though it’s at level 6.
Odd that it works at level 1. Have you tried this in a new project and see if it could be a script conflict?
I figured it out. When I open up a new project, I added ‘parameter table’ first, then ‘enemy action condition’. Lastly, I added enemy levels. And now it works.
That means there could be incompatible scripts in the other project. I’ll disable those until I find anything incompatible.
And thanks!
Turns out this script isn’t compatible with victor engine. Could you edit this script to make it compatible? If not, let me know and I’ll post this to rpgmakerweb.com.
Excuse me, how to make a skill usable by enemy only when any one of them is hurt?
I tried this one, but fail.
!(t.hp_rate * 100) == 100
</action condition>
That’s because t is the troop itself, not an enemy.
Assuming there are two enemies, and you want a skill to be usable when one of them is hurt, you can say
t.members.any?{|mem| mem.hp_rate < 1}
However if they restore their HP, then the condition is false again.
Would this work on party members as well? Or at least a way to edit it to make it work? I’d like some party members to have skills that are only usable if a variable is at a certain value or a switch is on. Is that possible?
Try Custom Use Conditions
hi
I know this is late but I was wondering if it’s possible to make the enemy use a skill on an ally enemy when a certain state is applied to their ally. I’m basically trying to get my enemies to have a chance to revive each other.
It would be possible to check if “any” allies have a particular state, but it wouldn’t be possible to check if a specific ally had that state. The script only specifies whether the action can be used, and not whether the action can be used on a specific target (as the script does not handle any target related properties).
I’m not sure if you would be able to accomplish what you want with this script on its own.
Oh bummer, thanks for the reply though.
Heya.
I’m having some trouble with this script and I’d like some advice. If my actor is using attack A, then they’re in state A. When this happens, I want my enemy to attack them over all else. However, if my other actor uses attack B, then they’re in state B. Is there a way to have my enemy attack the actor in state B over the actor in state A?
This script is mainly focused on whether an enemy is able to use a skill.
Have you considered having state B simply increase the TGR parameter that makes it a more likely target?
I didn’t consider that, actually! Thank ya, I was able to work it out.
Skill chain?
Hello.
This is a minor question/comment.
I’m trying to put cumulative conditions on the same skill.
In concrete… my acrobat have two skills raising either evade or magic evade.
I use the conditions so it wont use any of these skills if either state is up.
I first tried to have both in one condition…
!a.state? (242)
!a.state? (243)
But then the acrobat was using the skills if any of the two wasn’t up.
Now i use two conditions for the same skill :
!a.state? (242)
!a.state? (243)
And it works as intended, so it’s not a blocking issue.
Yet i Wonder if there isn’t a simpler/smouther way to write it down.
If not I hope it’ll help people trying to do the same.
A single formula is used for a condition. If you want to specify that either condition can be met in order for the condition to be met, use the OR operator
Yes it works like that too. Thanks.
Can I make a skill sequence?
Hi I’m using the game variable but it seems to be not correct.
v[2] == 1
It tells that if variable no.2 is 1 then use action 1. Is this correct?
Oh it’s ok now. The problem is I forgot to save the game file after I inserted the script. The script is great and thanks a lot!
Do you know of any way to get an enemy to use a skill only on characters without a specific state?
For example I’m using
!p.members.any? {|mem| mem.state?(5) }
to get an enemy to confuse party members that don’t have the status effect. But the enemy still just seems to target randomly anyway.
Unfortunately due to the way actions are processed by default, it chooses which skill to use before it chooses which battler to target.
The check only occurs during the skill selection step. This is why there is no variable for the target.
Hello.
I have some questions for i have no knowledge of formula.
I’d like to have an enemy using a skill when one member of the party have a specific state.
I tried with “p.state? (3)” but it doesn’t works, perhaps because “p” means the party and not one character.
I also Wonder how to reverse this condition.
For exemple, i’d like the enemy to cast a skill when it doesn’t have a specific state.
In the same way, is there a way to have an enemy use a skill when no one in the party have a specific state?
Alternatively, if you know a good place to learn about formula… i could learn to fish.
I had a look at “How to make the most of custom formulae. Part #1” but it seems focused on damage formula.
Thanks in advance.
Yes,
p
refers to the party object. If you want to make it so that a skill is used when any member of the party has state 3, you can sayWhich simply asks whether any member has state 3.
For the reverse, you just need to stick a
!
in front to negate itWhich means if someone has the state, then it won’t be used.
If you can do damage formulas then you could do any other formula. The principles are the same. For learning, I’m not sure what would be the best approach because you can basically do anything. That topic is likely a good place to start since it focuses on specific applications.
Can I make enemies use magic and special attacks in a specific order with this script?
Not directly, but if you can enforce some sort of order by using conditions (such as variable value) and then having each skill change the variable value, you can then force the enemy to use certain skills in that order based on the variable. Or you can use states. It’s up to you to think about the logic.
Ok i just tested and it works fine. Thanks!
I’ll have a closer look at the guide.
I am terribly sorry.
Another question or two.
if i write “!a.state? (X)” it will use the skill only if it doesn’t have the state? (for self casting buffs)
Also, i couldn’t find how to use a switch as a condition. “$game_switches[x] ?” doesn’t seems to work.
Hopefully it should be the last time i bug you (with this script).
Yes. Does it do that?
Example
1 – it works all right.
2 – I don’t manage to make it work.
Actually i don’t know how to make sure the condition is registered. I tried two things :
if s[1]
1
else
0
end
or
if s[1]
true
else
false
end
None worked.
At worst i can replace the switch with a state marker inflicted on the whole troup.
Out of curiosity i also tried …
!t.members.all? {|mem| mem.state?(177)}
Hoping the skill wont be used if the whole troup have a specific state, but it doesn’t work…
Guess it’s not that simple ;p
Try just writing
I can’t reply to the last message so i reply here.
s[1] works and !s[1] works too.
Thanks a lot.
I had all four battle members inflicted with a state, and had set the enemy to not select the action unless at least one member wasn't inflicted with the state, and the enemy still randomly selects to use that action.
"condition eval 2"
p.any? { |a| !a.state?(33) }
"/condition eval"
Replaced the code in quotes so it wouldn't parse weird here.
Do I have the note tag wrong? Should it be b.state?(33)?
condition eval?
Aha! I see the error. I had pasted the condition tag from a post on the RMN thread which was incorrect. I'll test it ASAP.
Just to clarify. Is the use 'rating' selection in the tool set still the primary factor in chances of one ability used over another? Assuming they are available.
Yes (they should).