I would like to be able to specify that an enemy should always select either actor 2 or actor 3 to attack, assuming that actor is alive.
Can this be done with a script call? A cunning addition to all the enemy's damage formulas? Maybe a genius level bit of eventing on the troop page? Or something else maybe?
Give the enemy a unique attack skill and use Target Core:
Code:
<Custom Target Eval>
var actor = $gameActors.actor(actor id);
if ($gameParty.battleMembers().contains(actor) && !actor.isDead()) {
targets.push($gameActors.actor(actor id));
} else {
for (var i = 0; i < foes.aliveMembers().length; ++i) {
var member = foes.aliveMembers()[i];
targets.push(member);
}
}
</Custom Target Eval>
@Trihan I'm sorry to say that I don't entirely follow this.
First off - is that Javascript or Ruby? It's just that I would expect it to be game_party etc., not gameParty, but perhaps that's my mistake.
Next, I can see that if I input 2 for the first (actor id) then all would proceed as planned. But if it's actor 3 who is in the party instead, then he won't be targeted.
For background Actors 2 and 3 are different instances of the same character, so it can only ever be one or the other, not both.
Finally, I don't understand what you mean by "use Target Core". Is that what I would put in the damage formula box?
<Custom Target Eval>
var actor = $gameActors.actor(actor id);
if ($gameParty.battleMembers().contains(actor) && !actor.isDead()) {
targets.push($gameActors.actor(actor id));
} else {
for (var i = 0; i < foes.aliveMembers().length; ++i) {
var member = foes.aliveMembers()[i];
targets.push(member);
}
}
</Custom Target Eval>
The TRG suggestion would only work if the enemy troop consists of only one enemy. However, if there is more than one, then every enemy would target that particular actor, which is not what I want.
I can't read the code right now but you could do something like this:
Set the enemy you want to only target 2 actors (let's call it A) to only have skills that trigger a switch and store a value (id of the skill you really want to be used) in a variable (let's call it $game_variables[m]). Generate a random integer and get an actor id from that:
Code:
number = rand(2)
case number
when 0
$game_variables[n] = actor1_id
when 1
$game_variables[n] = actor2_id
end
Change n with the id of the variable you want to store the actor id into and change actor1_id and actor2_id with the id of the two prefered targets.
After doing this you should check if the selected actor is in the active party AND if he is alive. You can do it using event commands if I am not wrong. Just check if the actor is a party member, if the generated id matches actor's id and if actor's hp are greater than 0. If that's false for both actors then just s your variable n to be -1 (which means random target).
Have a troop event running at the end of turn and check if A is alive and if the switch you decided to trigger is on. If that's true than use the event to force an action on A. Skill id will be the one you stored in $game_variables[m] and target id will be the one in $game_variables[n]. if you want to do it via script call then use this line:
NOTE: you can force A to act in the same event you used to pick a target but if I am not wrong there are few bugs that could occur (like being unable to actually pass the correct target). If you really cannot have the enemy cting at the end of turn (which prevents those bugs to happen) try to add that line to the skill event and see what happens. I do not recommand doing it anyway.
EDIT: I am sorry, I know this was a HUGE wall of text. I used to put horizontal rules to separate things but aparently the bb code for them doesn't work with the new forum apparence. I guess I have to fin another way. (Feel free to suggest one)
There are some ways to manipulate targets. I'm sure there are some good scripts for this out there, but of course I can't recall one out of my head, so I'd leave it to you to search for one if you need it.
Apart from that, you could use this to manipulate the target of an enemies next action, similar to what Heirukichi already suggested. This code can be executed before the enemy makes their turn (e.g. during a troop event at the start of the turn):
Code:
enemy = $game_troop.enemies[ INDEX ]
if enemy && enemy.current_action
enemy.current_action.target_index = INDEX
end
Replace the INDEX in line 1 with the index of the respective enemy (starting with 0), and in line 3 with the index of your preferred target (also starting with 0). Note that these represent the positions of the battlers within their units, not their database IDs. You can use variables here as well of course.
The downside of this one is that it will behave like the actor target selection. If the original target is dead once the enemy makes their turn, they will target the first party member instead of a random one. Also if you use the "Action Times+" feature for your enemy, this will only affect their first action in a turn.
To make the second enemy use their actions on either actor #2 or #3 for example, you could also use this code, which already filters out dead and out-of-party actors:
Code:
enemy = $game_troop.enemies[1] #<- Second enemy (Index = 1)
if enemy && enemy.current_action
# Find all preferred actors (out of actor 2 and 3) that are in the party and alive:
targets = [2, 3].map { |i| $game_actors[i] }.select { |a| a.index && a.alive? }
# Select the party position of a random preferred actor if there is any:
enemy.current_action.target_index = targets.sample.index unless targets.empty?
end
@Kes
For Ace, there is a way to control the targeting completely with a script that I had asked Enelvon to write a long time ago, but it will require specific coding knowledge.
Here is the link, but if you need help on how to use it this will get technical (and I don't have time for that at the moment) https://forums.rpgmakerweb.com/index.php?threads/target-manager-v1-0-initial-release.30722/
I never used it because MV was advertised before I could start game development, and I decided to switch to that before starting, so I'm a bit rusty on it myself. But it was one of three parts (the other two being default troop events and default enemy attack patterns) that could be combined for a relatively good AI if you were willing to put in the work on its events and codes.
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.