I am having some trouble with enemies not using spells or skill correctly. I have an enemy that can use cure on an ally, but I don't want then to use cure unless the ally has specific status effects on them such as poison, burn, or paralysis. How would I go at doing this with or without a script. If I use a script what would I use? Thanks for the help.
Smarter Enemy AI
RGSS3 Script RequestsHey there! Incase I'm not mistaken, wouldn't you need to use a Condition Branch for said Cure skill? (I sort of know the basics of the battle system format, but not entirely).
In my mind, I'm thinking something along the lines of:
======
If: (enemy ally) has: Status (whatever status that is)
-Cast cure on (enemy ally).
else:
(Execute some other action besides cure here)
=======
As for checking multiple statuses, I could see you using a nested If-if-if-if-Else statement.
=======
If: enemy ally has (poison)
-cure ally
-exit event processing
If: enemy ally has (burn)
-cure ally
-exit event processing
If: enemy ally has (paralysis)
-cure ally
-exit event processing
(Execute some other action besides cure here)
=======
Just some food for thought!
In my mind, I'm thinking something along the lines of:
======
If: (enemy ally) has: Status (whatever status that is)
-Cast cure on (enemy ally).
else:
(Execute some other action besides cure here)
=======
As for checking multiple statuses, I could see you using a nested If-if-if-if-Else statement.
=======
If: enemy ally has (poison)
-cure ally
-exit event processing
If: enemy ally has (burn)
-cure ally
-exit event processing
If: enemy ally has (paralysis)
-cure ally
-exit event processing
(Execute some other action besides cure here)
=======
Just some food for thought!
You can try to search for "Enemy Battle AI - RPGVXACE" on Google.
I don't remember the names, but there were at least 2 scripts for this on Ace
I don't remember the names, but there were at least 2 scripts for this on Ace
I want something like this, but I don't want to do condition and force the enemy to use it. I want them to use it randomly only if the ally has the status. Plus, I would have to do that for every battle troop.
I tried those but they didn't work how I thought it would.
Scope Conditions
This script allows you to specify a scope condition for your items and skills.A scope condition is a formula that is used to determine whether a skillor item has an effect on a target or not. If
himeworks.com
There is an easy solution for this (I think).
Within the conditional branches in the same examples I provided above, instead of casting a cure ally every single time, why not try creating a Random-Action Variable?
Like:
=======
If: enemy ally has (poison)
{
Declare Random-Action Variable 001: 1-3:
{If Variable 001 = 1:
-cure ally (1)
-exit event processing
}
{If Variable 001 = 2:
-cure ally (2)
-exit event processing
}
{If Variable 001 = 3:
-(some other action)
-exit event processing
}
}
etc...
(Execute some other action besides cure here)
================
In an instance with randomness, Variables are you best friends. As far as I'm aware, using variables, and manipulating them in nested If-statements sounds like the best option that's non-plugin, and non-script.
There is basically no way around that.
AI programming is one of the most complex parts around, and it is only possible by applying specific knowledge on the options of an enemies behaviour.
And that means any different behaviour needs a different programming, resulting in different troops requiring different events.
There are a number of scripts that can help or provide shortcuts, but no one can create miracles here.
AI programming will always require specific work for specific units.
rpgmaker.net
I am curious on if the target states means they have to have all those applied or just one of them. I don't want the healer to waste mp for the skill if it doesn't need to.
That script looks good except it gave me an error when the slime was trying to use a cure spell when all enemies were cured already.
This fixes that, but I still had the slimes using the skill on the wrong battler
*not to used with yanfly battle engine
This fixes that, but I still had the slimes using the skill on the wrong battler
*not to used with yanfly battle engine
Ruby:
class Scene_Battle < Scene_Base
def use_item
item = @subject.current_action.item
@log_window.display_use_item(@subject, item)
@subject.use_item(item)
refresh_status
if [email protected]_action.make_targets.nil?
targets = @subject.current_action.make_targets.compact
show_animation(targets, item.animation_id)
targets.each {|target| item.repeats.times { invoke_item(target, item) } }
end
end
end
Does it only use the skill when the ally has all or just one status on it? I don't know if I have the database info setup right. BTW, the code now makes it to where the animations act out twice instead of one time when i use anything.
Do you have other code somewhere that changes use item?
This is just a copy of the default with the one if statement.
I haven't tried inflicting multiple states, just poison.
Idk, but you could look just in case.
right, you have yanfly battle engine which overwrites the use_item and has a rescue. So you don't need the code I posted.
Ok. Good to know. What do we do about the cure though? Do I have the notetag setup right for the healer slime? Or am I missing something?
Adding in yanfly target manager and setting the skill to this note tag
<targets: 1 random allies>
<ai_conditions>
target_states: 2, 7
only_if_target
</ai_conditions>
and the enemy without any note tags
I've seen it 80% accurate.
It will still select an enemy that is not poisoned. but most of the time it selects the correct one.
I'm honestly not sure how to make it 100% accurate.
<targets: 1 random allies>
<ai_conditions>
target_states: 2, 7
only_if_target
</ai_conditions>
and the enemy without any note tags
I've seen it 80% accurate.
It will still select an enemy that is not poisoned. but most of the time it selects the correct one.
I'm honestly not sure how to make it 100% accurate.
I tried it and it works somewhat well. If you find a way to make it better, please let me know. BTW, how do I get it to where they don't use it if no one has to be cured? Is that even possible?
I think I finally got it.
Total 180 of what I did previously.
Remove yanfly target manager.
Remove the tags on the skill and set them up on the enemy.
<ai_conditions: 2> use_id
only_if_target
target_states: 2, 7
</ai_conditions>
<ai_conditions: 2> use_id
only_if_target
target_states: 2
</ai_conditions>
<ai_conditions: 2> use_id
only_if_target
target_states: 7
</ai_conditions>
Try that.
Total 180 of what I did previously.
Remove yanfly target manager.
Remove the tags on the skill and set them up on the enemy.
<ai_conditions: 2> use_id
only_if_target
target_states: 2, 7
</ai_conditions>
<ai_conditions: 2> use_id
only_if_target
target_states: 2
</ai_conditions>
<ai_conditions: 2> use_id
only_if_target
target_states: 7
</ai_conditions>
Try that.
I had it on 2 and 2 was heal. lol. Changed it to three and it worked.
BTW when I setup the heal I have it as this setup, but it still casts heal when they are full health:
It is the condition 2.
I don't know why, but it works better if it is set to this
<ai_conditions: 2>
only_if_target
target_hpgt: 65
</ai_conditions>
still not 100%, but without getting very involved in the script I don't know how to make it better. Someone else with more coding knowledge can maybe take a look. it seems to be acting in reverse for the hplt and hpgt options.
*scratch that, I think I got it. I reversed the directional compare and it looks like it works good now.
Line 757 and 761, swap the < > symbols. hpgt <= , hplt >=
<ai_conditions: 2>
only_if_target
target_hpgt: 65
</ai_conditions>
still not 100%, but without getting very involved in the script I don't know how to make it better. Someone else with more coding knowledge can maybe take a look. it seems to be acting in reverse for the hplt and hpgt options.
*scratch that, I think I got it. I reversed the directional compare and it looks like it works good now.
Line 757 and 761, swap the < > symbols. hpgt <= , hplt >=
Moved to: RGSS3 Script Requests
Original thread: https://forums.rpgmakerweb.com/threads/smarter-enemy-ai.141169/