How do I use a character ID as a skill parameter?

level100gastly

Villager
Member
Joined
Mar 4, 2018
Messages
14
Reaction score
5
First Language
Portuguese
Primarily Uses
RMMV
Since Archeia said there's no such thing as a stupid question, I'm here asking for guidance about the aforemented problem. The idea was to check whether or not the target of a skill was a girl or not (since I trying to implement a revival skill that's supposed to heal their HP more). Since I know the ID's from the girl characters the party can have, my issue comes mostly from inexperience with JavaScript, so any help would be greatly appreciated.

I assume the syntax would be something like:
if (actorID = a || b || c) { (Char is a girl)
skill heals 30% of max hp
} else {
skill heals 10% of max hp
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,886
Reaction score
982
First Language
English
Primarily Uses
RMMV
First off, you're going to either have to use a plugin or take some extra steps - by default, the only way you can get event or script commands attached to a skill is by having it call a common event, and a common event doesn't have any way to know who you just used a skill on.

I'll show you how to do it in the vanilla engine with no plugins, but the downside to this method is that calling the common event happens after the skill is performed, so it will look different from your other skills.

1 - Make a new state that doesn't do anything

2 - In your skill, on the right-hand side, you see Effects. Add one that adds that new empty state. Then add one that calls a common event.

3 - In the common event, go to the third tab, bottom right, and click Script. Inside the script box:
Code:
var heal=0;
for (var i=0; i<$gameParty.aliveMembers().length; i++)
{
    if (!$gameParty.aliveMembers()[i].isStateAffected(state_id))
        continue;

    switch ($gameParty.aliveMembers()[i].actorId())
    {
        case xx:
        case yy:
        case zz:
            heal=$gameParty.aliveMembers()[i].mhp*.3;
        default:
            heal=$gameParty.aliveMembers()[i].mhp*.1;
    }
    $gameParty.aliveMembers()[i].removeState(state_id);
    $gameParty.aliveMembers()[i].gainHp(heal);    
}
Where:
state_id is the ID of the empty state you've been using, and
xx, yy, zz, as many cases as you want, are the actor IDs of your female actors.

It is possible that someone more JavaScript-savvy might know a method to condense that into something you can fit into the damage formula of your healing skill, in which case you wouldn't need the state and event...but that's what I can do for you :stickytongue:

The other method to be able to do all this at the correct time during a skill would be to use Yanfly's Action Sequences, but that's more complicated because you would have to learn how to program every aspect of the skill via the action sequence (the actor movements, animations, etc.).
 

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
2,016
Reaction score
581
First Language
English
Primarily Uses
N/A
Make the skill have it's own element. Give all the girl charecters an effectivness to that element above 100% (like with elemental weaknesses) and boom! the skill automaticly checks if the target is a girl. no plugin required
 

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,504
Reaction score
729
First Language
indonesian
Since Archeia said there's no such thing as a stupid question, I'm here asking for guidance about the aforemented problem. The idea was to check whether or not the target of a skill was a girl or not (since I trying to implement a revival skill that's supposed to heal their HP more). Since I know the ID's from the girl characters the party can have, my issue comes mostly from inexperience with JavaScript, so any help would be greatly appreciated.

I assume the syntax would be something like:
if (actorID = a || b || c) { (Char is a girl)
skill heals 30% of max hp
} else {
skill heals 10% of max hp
i think you can use damage formula box...
first set the skill to hp heal
then try using this in damage formula box:
Code:
[1,3,7].includes(b.actorId()) ? b.mhp * 0.3 : b.mhp * 0.1;

change 1, 3 ,7 to any female character actor id you have in database...
all entry separated by coma... in above example: actor 1, actor 3, and actor 7 will get 30% mhp heal.

hope this help...
 

level100gastly

Villager
Member
Joined
Mar 4, 2018
Messages
14
Reaction score
5
First Language
Portuguese
Primarily Uses
RMMV
@ATT_Turan Unfortunely the code wouldn't work (my guess is that it wouldn't fit into the script box, and putting it into two separate scripts so it would chain didn't work either), but thanks anyway for taking your time!

@Oddball Man, I would never have thought of that! It didn't make into the skill because it inspired me to make a different one.

@estriole This is more on par with what I tried (which includes all of the posted ideas). What was lacking was the proper syntax (it still looks a bit weird to me) and now it works perfectly. Many thanks!
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,886
Reaction score
982
First Language
English
Primarily Uses
RMMV
@ATT_Turan Unfortunely the code wouldn't work (my guess is that it wouldn't fit into the script box, and putting it into two separate scripts so it would chain didn't work either), but thanks anyway for taking your time!
It looks like you found a solution, but...you simply make it smaller until it fits into the script box. Neither new lines nor spaces after one matter for code. And I believe the script box isn't limited horizontally, so you could just delete carriage returns and extra spaces until the whole thing fit onto one huge line if you wanted to.
 

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,504
Reaction score
729
First Language
indonesian
@ATT_Turan Unfortunely the code wouldn't work (my guess is that it wouldn't fit into the script box, and putting it into two separate scripts so it would chain didn't work either), but thanks anyway for taking your time!

@Oddball Man, I would never have thought of that! It didn't make into the skill because it inspired me to make a different one.

@estriole This is more on par with what I tried (which includes all of the posted ideas). What was lacking was the proper syntax (it still looks a bit weird to me) and now it works perfectly. Many thanks!
glad it work out for you... for the syntax look a bit weird... it's a variation of IF in shortened form... it's useful to use in oneliner code which fits the formula box perfectly...

if you're interested of how it works...
basically it will be in this format
Code:
[condition]  ?  [if true] : [if false]
so in above example for the [condition] we use:
Code:
[1,3,7].includes(b.actorId())
[1,3,7] => an array of number where we specify all the id that will be compared to target actor id
includes => for checking the former array contain a certain element or not
b.actorId() => b in damage formula means the target... and .actorId() is a method in Game Actor to grab it's actor id

then after that we fill the value that will be used if the condition is true or false AFTER ? sign and separated by :

hope this help.
 

level100gastly

Villager
Member
Joined
Mar 4, 2018
Messages
14
Reaction score
5
First Language
Portuguese
Primarily Uses
RMMV
glad it work out for you... for the syntax look a bit weird... it's a variation of IF in shortened form... it's useful to use in oneliner code which fits the formula box perfectly...

if you're interested of how it works...
basically it will be in this format
Code:
[condition]  ?  [if true] : [if false]
so in above example for the [condition] we use:
Code:
[1,3,7].includes(b.actorId())
[1,3,7] => an array of number where we specify all the id that will be compared to target actor id
includes => for checking the former array contain a certain element or not
b.actorId() => b in damage formula means the target... and .actorId() is a method in Game Actor to grab it's actor id

then after that we fill the value that will be used if the condition is true or false AFTER ? sign and separated by :

hope this help.
I'm familiar with ternary operators, not so much with the parameters. Thanks for the explanation.
 

Latest Threads

Latest Posts

Latest Profile Posts

Day 2 of my redesign journey, as a follow up from the previous post :kaothx:
pXiRJSm.jpg

This is Cedric's son, Apollo!
New pet peeve: Telling tech support personnel what something is doing, only for them to tell me (in excessively condescending tones) what it should be doing. Yes, I know what it should be doing, and if it was doing that, I wouldn’t be talking to you and your attitude problem about it right now, would I? >.<
uglywolf wrote on Khulse's profile.
Hello.
The rules I makes pun about on your last thread is about "Verify Files" before anything else, if the stuff comes from STEAM. Which means, if it could be fixed with just that, there is no need to redownload the whole stuff.
But glad the reinstall worked, hope you enjoy it and your days too.
uh oh, I just tapped into a fresh, deep vein of nightmare fuel right here guys:

Forum statistics

Threads
115,432
Messages
1,089,801
Members
150,188
Latest member
FRANEKWIEM
Top