Jump to content
Shad3

Enemy AI : Targeting Priority Manipulator

Recommended Posts

Enemy AI : Targeting Priority Manipulator

By Shad3Light

 

TargetingPriority.png

 
The default VX Ace's enemy targeting behavior just pick a random target for any actions.
This script adds some AI targeting priority. With this script, the enemies become able to pick a target based on the action specific priority.

Download the script here, or grab it from my blog here.
 

Installation
Put this script below â–¼ Materials and above â–¼ Main Process.

Usage
The copy of the following instruction is included within the script.


In an enemy notebox, you can add some tags.

<target [action_id] [shortcut]>

where [action_id] corresponds to the enemy's action list, and [shortcut] corresponds to one of the implemented targeting priority method.

Example:

<target 1 high_hp>

This will make the enemy target the battlers with the highest HP value when using action number 1 (by default Attack).
 

<target 2 low_hp_rate>

This will make the enemy target the battler with the lowest HP percentage when using action number 2. If the action no. 2 is set to Heal, the enemy will proceed to heal its ally with the lowest percentage of health.

Available targeting shortcut is as follows:

low_hp
high_hp
low_hp_rate
high_hp_rate
low_mp
high_mp
low_mp_rate
high_mp_rate
low_tp
high_tp
low_tp_rate
high_tp_rate
self
not_self

 
If you want to make your own targeting condition, use

<target eval [action_id]>
[eval]
</target eval>

where [eval] is a ruby expression that takes returns -1, 0, or 1.
In the eval, a and b denotes the battlers that would be sorted.

For example, to make the enemy prioritize Eric when doing its ultimate skill, the tag will be

<target eval 8>
if a.name == "Eric"
-1
elsif b.name == "Eric"
1
else
a.hp <=> b.hp
end
</target eval>

Do note that target selection is done at the start of the turn, like actors. The enemy will not suddenly change target mid-turn, for example if its target had already healed.
Also, TGR have no effect on acquiring target with this script.



Patches
This script should work with most battle systems.
For users of Schala Battle System, there is a patch here.

Credits
Give credits to Shad3Light (me).
For use in commercial project, I expect to at least be contacted first.

Edited by Shad3

Share this post


Link to post
Share on other sites

Well, this script and the snippet I posted before is different in inner working but yeah, decided to make a whole script as the default targeting behavior is just randomness.

Share this post


Link to post
Share on other sites

Would it be possible with this script to allow enemies to target actors with states, only when the actor doesn't already have the state applied?

Share this post


Link to post
Share on other sites

Would it be possible with this script to allow enemies to target actors with states, only when the actor doesn't already have the state applied?

<target eval 3>
if !a.state?(18)
-1
elsif !b.state?(18)
1
else
rand(3) - 1
end
</target eval>

This will prioritize any target without the state id 18.

 

Though, if you want to make the enemy only consider using the skill only when there's opponent without said state, you'd want another script, either Hime's Enemy Action Conditions or my own (uncommented, beware) script. In case of my script:

<condition eval 3>
p.any? { |a| !a.state?(18) }
</condition eval>

For Hime's script, the code is basically the same.

 

 

As analogues to the player, Action condition script is like considering which skill to use, and my targeting script is like picking the target for said skill.

Edited by Shad3

Share this post


Link to post
Share on other sites

And another better one!!! YAAAY!  And another better one, is that even a correct sentence? LoL... anyway :wub:

 

Your like my target man for the week Shad :D

 

Much Kudos to ya ;)

Share this post


Link to post
Share on other sites

I hope posting a month later isn't considered necroposting. :/

 

How would I make an enemy prioritize using a certain skill on a character with a certain state over using said skill to a character without the state?

 

 

Would it be possible with this script to allow enemies to target actors with states, only when the actor doesn't already have the state applied?

<target eval 3>
if !a.state?(18)
-1
elsif !b.state?(18)
1
else
rand(3) - 1
end
</target eval>

This will prioritize any target without the state id 18.

 

Would I use this, only slightly altered?

Share this post


Link to post
Share on other sites

Is tgr totally disabled when this script is active or only when I configure the enemies' actions? If it is completely disabled, can I set attacking priority based on party lineup (position 1, 2, 3, 4 and so on)? If so, what would it look like?

 

Thanks!

Share this post


Link to post
Share on other sites

I think it's incompatibility, I finally got DoubleX's to work, sort of, when placed in a certain spot on my script list. I just need something that can check if states are already applied, and then sort by parameters for targeting. I'm assuming through the custom eval, this is possible with this script?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted