Parlu10

Veteran
Veteran
Joined
Jul 30, 2018
Messages
49
Reaction score
8
First Language
Italian
Primarily Uses
RMMV
Hi everyone,
I was trying to make a passive ability, also using Yanfly's Plugins, that would work like "Synchronize" in pokemon: whenever the user has a negative status, they transmit it to their enemies; in my case, I want them to transfer it to a random target.
However I don't really understand how it works, since I think a coding knowledge is required for this.
Thanks in advance for helping :)
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,703
Reaction score
2,804
First Language
English
Primarily Uses
RMMZ
Do you have the Buffs & States Core and Auto Passive States plugins?
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,827
Reaction score
14,980
First Language
English
Primarily Uses
RMMV

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

 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,703
Reaction score
2,804
First Language
English
Primarily Uses
RMMZ
Okay, give me a bit and I'll come up with a notetag that'll do this.
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
216
Reaction score
124
First Language
French
Primarily Uses
RMMV
First, we'll get a custom battle effect that records the state ID of every state the actor already has when entering a battle:
JavaScript:
<Custom Battle Effect>
user.pastStates = [];
for(i = 0; i < user.states().length; i++) {
    user.pastStates.push(user.states[i].id);
}
</Custom Battle Effect>
What we're going to do to make Synchronize work is that we'll record the states the wearer already has, and see in the wearer's current states which ones they didn't have before.
JavaScript:
<Custom React Effect>
newStates = [];
for(i = 0; i < user.states().length; i++) {
    newStates.push(user.states[i].id);
}
sync = [];
for(i = 0; i < newStates.length, i++) {
    if(!target.pastStates.includes(newStates[i])) {
        sync.push(target.newStates[i]);
    }
}
</Custom React Effect>
The sync variable contains every state ID of the states that weren't in the wearer's pastStates variable but were in newStates, which means they weren't there before the action that was just received.

Next, we'll throw these states at random opponents.
JavaScript:
if(target.isActor()) {
    opponents = $gameTroop;
} else {
    opponents = $gameParty;
}
for(i = 0; i < sync.length; i++) {
    syncTarget = opponents.randomTarget();
    syncTarget.addState(sync[i]);
}
Finally, we replace the past states array by the current one.
JavaScript:
user.pastStates= newStates;

Now all together:
JavaScript:
<Custom Battle Effect>
user.pastStates = [];
for(i = 0; i < user.states().length; i++) {
    user.pastStates.push(user.states[i].id);
}
</Custom Battle Effect>
<Custom React Effect>
newStates = [];
for(i = 0; i < user.states().length; i++) {
    newStates.push(user.states[i].id);
}
sync = [];
for(i = 0; i < newStates.length, i++) {
    if(!target.pastStates.includes(newStates[i])) {
        sync.push(target.newStates[i]);
    }
}
if(target.isActor()) {
    opponents = $gameTroop;
} else {
    opponents = $gameParty;
}
for(i = 0; i < sync.length; i++) {
    syncTarget = opponents.randomTarget();
    syncTarget.addState(sync[i]);
}
user.pastStates = newStates;
</Custom React Effect>
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,274
Reaction score
676
First Language
English
Primarily Uses
RMMV
The only trick with that is that it isn't limited solely to negative statuses, it will also distribute any buffs that the user gets during the battle.

The easiest way around that is probably to utilize a notetag: on every state that you want to be considered "negative" by this skill, give it the notetag <negative>

Then, modify the code by @CHKNRAVE to the following:

Code:
if(!target.pastStates.includes(newStates[i]) && $dataStates[newStates[i].id].meta.negative) {

I believe that should do what you want.
 

Parlu10

Veteran
Veteran
Joined
Jul 30, 2018
Messages
49
Reaction score
8
First Language
Italian
Primarily Uses
RMMV
First, we'll get a custom battle effect that records the state ID of every state the actor already has when entering a battle:
JavaScript:
<Custom Battle Effect>
user.pastStates = [];
for(i = 0; i < user.states().length; i++) {
    user.pastStates.push(user.states[i].id);
}
</Custom Battle Effect>
What we're going to do to make Synchronize work is that we'll record the states the wearer already has, and see in the wearer's current states which ones they didn't have before.
JavaScript:
<Custom React Effect>
newStates = [];
for(i = 0; i < user.states().length; i++) {
    newStates.push(user.states[i].id);
}
sync = [];
for(i = 0; i < newStates.length, i++) {
    if(!target.pastStates.includes(newStates[i])) {
        sync.push(target.newStates[i]);
    }
}
</Custom React Effect>
The sync variable contains every state ID of the states that weren't in the wearer's pastStates variable but were in newStates, which means they weren't there before the action that was just received.

Next, we'll throw these states at random opponents.
JavaScript:
if(target.isActor()) {
    opponents = $gameTroop;
} else {
    opponents = $gameParty;
}
for(i = 0; i < sync.length; i++) {
    syncTarget = opponents.randomTarget();
    syncTarget.addState(sync[i]);
}
Finally, we replace the past states array by the current one.
JavaScript:
user.pastStates= newStates;

Now all together:
JavaScript:
<Custom Battle Effect>
user.pastStates = [];
for(i = 0; i < user.states().length; i++) {
    user.pastStates.push(user.states[i].id);
}
</Custom Battle Effect>
<Custom React Effect>
newStates = [];
for(i = 0; i < user.states().length; i++) {
    newStates.push(user.states[i].id);
}
sync = [];
for(i = 0; i < newStates.length, i++) {
    if(!target.pastStates.includes(newStates[i])) {
        sync.push(target.newStates[i]);
    }
}
if(target.isActor()) {
    opponents = $gameTroop;
} else {
    opponents = $gameParty;
}
for(i = 0; i < sync.length; i++) {
    syncTarget = opponents.randomTarget();
    syncTarget.addState(sync[i]);
}
user.pastStates = newStates;
</Custom React Effect>
Thank you for your help, but it doesn't seem to work because the enemy is not affected by the new states; Also, the animation of the state doesn't play on the actor who is affected by that state.
 

Parlu10

Veteran
Veteran
Joined
Jul 30, 2018
Messages
49
Reaction score
8
First Language
Italian
Primarily Uses
RMMV
Okay, give me a bit and I'll come up with a notetag that'll do this.
Hi there! Sorry to bother you, but I wanted to ask you if you had come up with the notetag yet. Thanks in advance!
 

Latest Threads

Latest Posts

Latest Profile Posts

hmm in exploring MZ with FOSSIL... I see I'll probably need to stick with MV for now as none of the menu altering plugins I use work on MZ lol. and I don't have the money to dump into what I would need in some cases to update plugins to their MZ versions. Everytime I think of converting, 5 or more reasons popup on why I shouldn't.
Hmm... Game has 91 views, 25 downloads, 5 reviews and netted me 7 additional followers. Meanwhile the image I posted just yesterday on Imgur to showcase it has 45,197 views. Interesting, I think I have a new advertising idea. Also Twitter? The post got 16 retweets, 20 likes, and 1,683 views.... And a whole 3 hits to my game, completely valueless. I am glad I did this game jam, this information is quite valuable.
We're playing another Touch the Stars game jam entry, come join us! :D
Ok is telling someone that their drawing isnt good rude
I'm familiar with MZ thanks to jam now. I say it's a better working and looking MV. Lots of plugins too and FOSSIL helps alot. It's not bad.

Forum statistics

Threads
113,655
Messages
1,076,478
Members
147,677
Latest member
E0805
Top