Change Action Target to opposite unit?

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
How can I change an action's target to the opposite side?

I have a state that can change the current action's target to a different one (It would randomly select a correct index. So if the player selected the enemy with index 1, it can randomly target the enemy with index 3).

My challenge is trying to include allies to that random targeting. I know how to get their indexes, but it's the same values (0 to X) as the enemy's values. So even if I get 2, it would always refer to the enemy's battler with index 2 and not the ally's battler with index 2.

Can the .isForOpponent() property be modified to change target to your ally unit? Not sure how to tell it to NOT target the opponent.

EDIT:

Part of my code includes:
Code:
        // Randomly attack (via Confusion Skill) one of the valid ally options
        if (poolA.length > 0) {
          var redirect = poolA[Math.floor(Math.random()* poolA.length)]
          action.setTarget(redirect);
          action.setSkill(confuseSkill);
          console.log("[Debug] Attack 1A: "+redirect);
        }
At the moment I'm just changing the skill when it has to target one of the unit's allies. This skill's scope is set to "1 Ally". However, it still targets the opponent AND it crashes with an "Undefined is not a function". The confusion skill being called is practically empty. No states or common events involved. No action sequences either.
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

"You can thank my later", "But you haven't done anything", "Well, that's why ..."
Are we allowed to post about non-RPG Maker games?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

Forum statistics

Threads
105,884
Messages
1,017,238
Members
137,608
Latest member
Arm9
Top