Increase Variable by random amount when using Attack skills[Semi-Solved]

Status
Not open for further replies.

SmashArtist

Lazy Artist
Veteran
Joined
May 31, 2016
Messages
853
Reaction score
1,520
First Language
English
Primarily Uses
RMMV
Hello!
I'm mainly an artist and not a programmer, so I got stumped when trying to use a script call in my attack skill's damage formula and it didn't work.

Basically, I want most skills to increase a variable based on which actor is using that skill by a random amount (1-3 currently).
I've been using iterations of this code in the attack skill's damage formula:
JavaScript:
a.atk - b.def; if (a.actorId() == 1)  {var oldValue = $gameVariable.Value(42); $gameVariables.setValue(42,oldValue+Math.randomInt(3)+1);} else {var oldValue = $gameVariable.Value(62); $gameVariables.setValue(62,oldValue+Math.randomInt(3)+1);}
However, it doesn't increment the specified variables at all. I've tested this code outside of battle and it works fine, so I'm not sure what I'm doing wrong.
Any help would be appreciated! :kaoswt2:

Edit:
I also previously had it at:
JavaScript:
a.atk - b.def; if (a.actorId() == 1)  {$gameVariables.setValue(42,$gameVariable.Value(42)+Math.randomInt(3)+1);} else { $gameVariables.setValue(62,$gameVariable.Value(62)+Math.randomInt(3)+1);}
It didn't work that way either.

Edit 2:
So I didn't figure out how to make the code work, so I used a work-around.
I made separate "attack" skills for each actor that call common events that add to the variable when used.
I changed the actor's attacks by using YEP_WeaponUnleash, which allows you to replace attack and guard skills with other skills.
 
Last edited:

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
478
Reaction score
210
First Language
English
Primarily Uses
RMMV
You've misspelled some of the commands ($gameVariables is plural!) and used the wrong case (it's value and setValue - one has an uppercase V, the other is lowercase). I can't see any other errors.

I will also note that this skill will always deal 0 damage if used by an enemy, because you're calling actorId() which doesn't exist if a is an enemy. If you need it to work for enemies, there is a workaround.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,001
Reaction score
4,743
First Language
Dutch
Primarily Uses
RMXP

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.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

ESAMarathon on Twitch, now streaming "Eat Girl". Yep, that's the title of a game... Apparently it's a Pacman knockoff.... Which is of course the only logical conclusion one would get from a name like "Eat Girl". :kaopride: I can't believe anybody would think anything else! :kaoback:
Super stoked i just finished my first town in my project, by finished i mean i can always add more decorative aesthetics and the NPCs don't talk yet but the mapping is complete and all the important chess pieces are present!
My brain: Hey, I have an idea how to make the transition to the main story quest in The Wastes more natural!
Me: Good!
My brain: You need to remake the hotel you start out in, it's not realistic enough.
Me: Ok... This was unexpected, but I can do it.
My brain: Now make each hotel floor 5 times as large to match the main part. Oh, you also need to make a bunch of new npcs to fill in the space on these maps.
Me: Crap.
Should be able to release Haxe MV/MZ next weekend.
It look that somehow MZ tracks are messed up (for example battle4 is obviously a theme, castle2 is a ship, ship1 is a scene and so on..). Maybe they just named them after with some ambiguity.

Forum statistics

Threads
100,618
Messages
977,838
Members
132,228
Latest member
zhengdddddd
Top