RMMV Target Core / Chain Lightning (tips & tricks) (Resolved)

Status
Not open for further replies.

Jay19

Veteran
Veteran
Joined
Dec 27, 2018
Messages
72
Reaction score
26
First Language
Français
Primarily Uses
N/A
Hello,
I've been stuck for hours on a formula embedded in a script using a plugin from Yanfly
I'm not familiar with scripts and I'm having a hard time configuring it the way I want, even if I think I'm close.
This is a tips & tricks (Chain Lightning), used so that an attack on a single target can reverberate on another target with reduced damage.
Here I want to use it for an equivalent in care.
My problem: the reverb should only hit one of my 4 heroes, but I'm using another plugin that allows me to summon creatures. Those creatures are therefore "friendly targets" but I don't want to include them.

The part of the formula that interests me seems to be this:

var members = allies.aliveMembers();

I would like to be able to specify that the allies who can be targeted are the members of groups 1, 2, 3 and 4.
Is it possible ?
Thanks to those who will help me.

(Translation made via google, please ask me to rephrase if necessary).
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,807
Reaction score
2,867
First Language
EN
Primarily Uses
RMMZ
:kaohi: Here's a link to the Tips & Tricks article, for ease of reference:

I've moved this thread to JavaScript/Plugin Support. Thank you.

(You originally posted this in Plugin Releases, which is for sharing plugins you have created.)

Edit: maybe try this?

var members = allies.aliveMembers().slice(0, 4);
I.e. only look at the first 4 alive members. Technical details here:
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,965
Reaction score
3,155
First Language
English
Primarily Uses
RMMV
caethyril's suggestion will probably take care of you - if that doesn't work, you should say which plugin you're using for summoning more actors and link to it.
 

Jay19

Veteran
Veteran
Joined
Dec 27, 2018
Messages
72
Reaction score
26
First Language
Français
Primarily Uses
N/A
Merci beaucoup. Je regarde ça chaque fois que j'ai un moment, je suis au travail en ce moment.
Désolé d'avoir posté au mauvais endroit.
 

Jay19

Veteran
Veteran
Joined
Dec 27, 2018
Messages
72
Reaction score
26
First Language
Français
Primarily Uses
N/A
I just tried your formula. She could have been very good, but unfortunately there is a problem. If one of my 4 characters is knocked out, then the next summon in order is included in the formula allies.aliveMembers().slice(0, 4)
Is there another solution than the term "slice"? I'm thinking something like "actorID" for example.
I think we are close to the solution.


Edit : The full formula is:

<Custom Target Eval>
// Adds the selected target to the target list.
targets.push(target);
// Grab the group of alive foes as candidates.
var members = allies.aliveMembers();
// Remove the target from the group of candidates.
members.splice(members.indexOf(target), 1);
// This is the number of extra targets to select with Chain Lightning.
var extraTargets = 2;
// Loop the extra targets.
while (extraTargets--) {
// Grab a random Allies from the alive foes.
var member = members[Math.floor(Math.random() * members.length)];
// Check to see if the member exists.
if (member) {
// Add the member to the group of targets.
targets.push(member);
// Remove the member as a viable candidate.
members.splice(members.indexOf(member), 1);
}
}
</Custom Target Eval>
 
Last edited:

Anastasius

Veteran
Veteran
Joined
Feb 7, 2022
Messages
51
Reaction score
37
First Language
English
Primarily Uses
RMMV
I just tried your formula. She could have been very good, but unfortunately there is a problem. If one of my 4 characters is knocked out, then the next summon in order is included in the formula allies.aliveMembers().slice(0, 4)
Is there another solution than the term "slice"? I'm thinking something like "actorID" for example.
I think we are close to the solution.


Edit : The full formula is:

<Custom Target Eval>
// Adds the selected target to the target list.
targets.push(target);
// Grab the group of alive foes as candidates.
var members = allies.aliveMembers();
// Remove the target from the group of candidates.
members.splice(members.indexOf(target), 1);
// This is the number of extra targets to select with Chain Lightning.
var extraTargets = 2;
// Loop the extra targets.
while (extraTargets--) {
// Grab a random Allies from the alive foes.
var member = members[Math.floor(Math.random() * members.length)];
// Check to see if the member exists.
if (member) {
// Add the member to the group of targets.
targets.push(member);
// Remove the member as a viable candidate.
members.splice(members.indexOf(member), 1);
}
}
</Custom Target Eval>
Hello. I haven't tested this but you can try the following:
JavaScript:
var members = allies.aliveMembers().filter(m => m.actorId() <= 4);
i.e. only look at the alive party members whose actor IDs are 4 or less.
EDIT:
  • The code will FAIL if you use this skill on enemies. You need to modify the filter() method conditions for that.
  • That's a strange skill you're creating since Chain Lightning is normally meant for enemies rather than allies: you're using allies rather than foes. But this is your thread and you can create whatever skill you like. :kaohi:
 
Last edited:

Jay19

Veteran
Veteran
Joined
Dec 27, 2018
Messages
72
Reaction score
26
First Language
Français
Primarily Uses
N/A
Thank you for your reply. This matches the idea I had, but unfortunately it doesn't work (syntax error).
In my opinion, the solution should not be very different from what you propose to me.
I also thought we could go through a status effect that would now only be on my heroes, but I don't know if that makes it any easier.

(Translation made via google, please ask me to rephrase if necessary).


Edit :
The solution was found in private message by Anastasius.
If anyone is interested, the correct code was:
var members = allies.aliveMembers().filter(function(m) {return m.actorId() <= 4});
Topic can be closed, thanks again Anastasius, and thanks to those who tried to help me.
 
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,807
Reaction score
2,867
First Language
EN
Primarily Uses
RMMZ
Anastasius's original response used ES6 syntax, which is supported in the latest versions of RMMV. Since you needed the ES5 code, I guess you're using an older version. If that's not deliberate, you may want to consider updating:

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.

Latest Threads

Latest Posts

Latest Profile Posts

uOy9Wjc.png

Something something.
Dev be like: "I'll make the character goes amnesia so I could explain the world and the lore better and immersive to the players"
Whoever decided that the 5th area of Xenoblade 3 had to be THAT big and be explored in the manner it does needs to be shot. My OCD cannot leave a tiny shard of the map hidden and those controls can go right on and f*** themselves. -.-

/rant off
Raggon wrote on NoPatience's profile.
:kaohi:

Forum statistics

Threads
124,435
Messages
1,163,622
Members
163,247
Latest member
renice
Top