Cubicle

Villager
Member
Joined
Dec 12, 2019
Messages
7
Reaction score
0
First Language
Dutch
Primarily Uses
RMMV
Hey RPG makers, thanks for reading this thread!
I'm still quite new to RPGMaker and have been experimenting with using Javascript in combination with Yanfly plugins to create various skill effects, to various levels of succes haha. (RPG Maker MV)
Right now Im trying to create a skill called gut punch that does the following:

Target an enemy,
Deal X damage to that enemy
if the enemy is poisoned: poison all other enemies.

The idea is that the target vomits over the other enemies spreading his disease to them.
I've tried to write something that I thought would maybe work:

1594992460844.png

I'm quite certain that all the functions I'm using are correct except for the one I try to change the target with:
target = $gameTroop.aliveMembers();

I know how I would be able to apply poison to the main target, but I don't know how to switch targets at some point in the skill phases to then apply poison to the new targets (being all enemies).

If someone could help me out, that would mean the world to me :).
Thanks in advance,
Cubicle
 

Attachments

  • Annotation 2020-07-17 153124.png
    Annotation 2020-07-17 153124.png
    128.6 KB · Views: 2

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,359
Reaction score
2,479
First Language
English
Primarily Uses
RMMZ
Code:
<Post-Damage Eval>
if (target.isStateAffected(11)) {
  $gameTroop.aliveMembers().forEach(member => { member.addState(11); });
}
</Post-Damage Eval>
 

Cubicle

Villager
Member
Joined
Dec 12, 2019
Messages
7
Reaction score
0
First Language
Dutch
Primarily Uses
RMMV
Thank you so much man!
It worked, I tried to figure out the syntax and I think I understand :).
the forEach function is something in Javascript and everything else is defined by RPG Maker MV right?
The only thing I'm unsure about is the term 'member,' do you use that term because gameTroop.aliveMembers consists of 'members' or is that also a general term of javascript?
Thanks a lot either way! :)

Code:
<Post-Damage Eval>
if (target.isStateAffected(11)) {
  $gameTroop.aliveMembers().forEach(member => { member.addState(11); });
}
</Post-Damage Eval>
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,359
Reaction score
2,479
First Language
English
Primarily Uses
RMMZ
You're absolutely correct; forEach is a native function in JavaScript that you can use on any array.

The reason I used "member" was just for a meaningful variable name inside the function block. I could have called it almost literally anything; it's just a way to refer to the current array element inside the function.

Heck, if you wanted you could have done $gameTroop.aliveMembers().forEach(bananasarekindacool => { bananasarekindacool.addState(11); });
 

Latest Threads

Latest Posts

Latest Profile Posts

Sometimes you Just need to realise someone is beyond help... Still hard to walk away tho :(
100 Horror/Tragedy Sample Maps, Penguin Mech Sprite, & TileD Templates | RPG Maker News #70

Continuing working on abs. So far I have done the workout twice. I am excited to see the results after a couple of weeks. How is everyone doing? :)
MZ: oh boy imma work today
Me, excited: Really?
MZ, doesn't do what I tell It too
Me: I Thought-
MZ: I am Working!
Oof, this "side project" of mine is starting to get as complex as a VS plugin, at least as far as plugin parameters are concerned. I think I now understand why a plugin like this doesn't already exist(that I know of). Learning a lot while trying to make it work though!

Forum statistics

Threads
112,213
Messages
1,066,594
Members
145,817
Latest member
scorlight
Top