- Joined
- Oct 31, 2018
- Messages
- 29
- Reaction score
- 3
- First Language
- Spanish & EN
- Primarily Uses
- RMMZ
My goal with Java script, in which I'm not very proficient, is to create a skill that hits a foe(100%) and those around it to take reduced damage(50%). I am using RPG maker MZ and I also have a number of plugins(battle core). However, I have been unsuccessful in creating that skill exactly how I want it.
Reference : Here
I've presumed to use a skill called "Chain Lighting" which fits the desired effect.
References for the code on using splice...
Reference
gyazo.com
However, the result... that I get. When I target a foe, and I execute the skill it hits the target twice and then it does the desired effect. I don't want it to hit the same target twice, only once.
What I'm I doing wrong?
Reference : Here
I've presumed to use a skill called "Chain Lighting" which fits the desired effect.
References for the code on using splice...
Reference
JavaScript:
<JS Targets>
const foes = this.subject().opponentsUnit();
const target = foes.members()[this._targetIndex];
targets.push(target);
let members = foes.aliveMembers();
members.splice(members.indexOf(target), 1);
let extraTargets = 2;
while (extraTargets--) {
const member = members[Math.randomInt(members.length)];
if (member) {
targets.push(member);
members.splice(members.indexOf(member), 1);
}
}
</JS Targets>

Gyazo Screen Video
What I'm I doing wrong?