Yanfly Target Furthest Right

Status
Not open for further replies.

Seacliff

RPG Maker Mastermind
Veteran
Joined
Nov 8, 2012
Messages
2,982
Reaction score
1,129
First Language
Yes
Primarily Uses
RM2k
I thought this would be easy by checking the code to see how the Battle Engine code handles 'this.furthestRight' (this.maxItems() - 1;) but apparently not.

Is it possible to create a skill that only targets the enemy on the far right side of the screen? Alternatively, attacking only the living enemy with the highest (or lowest) troop ID also works.
 

Doktor_Q

I'm not a real doktor, but I am a real Q
Veteran
Joined
Aug 1, 2016
Messages
874
Reaction score
562
First Language
English
Primarily Uses
RMMV
If you use Yanfly Selection Control, something like this should work:

<Custom Select Condition>
var unit = target.friendsUnit().aliveMembers();
if (unit.indexOf(target) == unit.length - 1) {
condition = true;
} else {
condition = false;
}
</Custom Select Condition>

Custom select conditions provide you with a "target" object, and you have to say whether said target is valid or invalid.
target.friendsUnit() gives you the troop for enemies and the party for actors, so this should work for either team.
.aliveMembers() gives us a list of only the surviving visible members, and then we store that in "unit" because it's a mouthful otherwise.

So now that we have a list of available targets, we use unit.indexOf(target) to see what position target is at- 0 is the furthest left, so the furthest right is list length - 1 (unit.length - 1).

I haven't tested it myself, so there's a chance something's missing, but it should be pretty close.
 

Seacliff

RPG Maker Mastermind
Veteran
Joined
Nov 8, 2012
Messages
2,982
Reaction score
1,129
First Language
Yes
Primarily Uses
RM2k
Thanks, this works as intended!
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,842
Reaction score
5,225
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
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.

Forum statistics

Threads
105,868
Messages
1,017,093
Members
137,587
Latest member
Usagiis
Top