bisudo

Villager
Member
Joined
Oct 15, 2022
Messages
6
Reaction score
1
First Language
Portuguese
Primarily Uses
RMMV
I'm making an accessory inspired by the pokémon's air balloon, it gives immunity to an element until the user suffers an attack from another type of element. I did this by creating a state with a trait that gives immunity to the psychic type, and giving that passive state to the aluminum hat. I found a code and tried to adapt it to my purpose, but I don't know java and the effect isn't removed when damaged. If anyone can help, I'd be grateful!

That's the code I found and put on the state notetag:

Code:
<Custom Apply Effect>
var atkcount = 1; //This is the attack counter. Change it to fit your purpose
target._attackCount = atkcount;
target.setStateCounter(44, target._attackCount); //Set a counter to your state. Change X to your state ID
</Custom Apply Effect>

<Custom React Effect>
//Check if actor takes dmg
if (value > 0 && !this.isHpRecover()){
//Decrease the attack counter by 1
target._attackCount -= 1;
//Set a counter to your state. Change X to your state ID
target.setStateCounter(44, target._attackCount);
//Check if attack counter reaches 0
if (target._attackCount <=0){
//Remove the state. Change X to your state ID
target.removeState(44);}}
</Custom React Effect>

<Custom Remove Effect>
user._attackCount = undefined;
</Custom Remove Effect>

Here is the link to the trend I got the link from:
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,810
Reaction score
6,626
First Language
English
Primarily Uses
RMMV
I found a code and tried to adapt it to my purpose, but I don't know java and the effect isn't removed when damaged.
RPG Maker uses JavaScript, not Java. They're two different languages.

Your problem is that you're talking about a passive state and using code for regular states. You can't use removeState() on a passive state, you have to use the notetags from the plugin instructions to determine whether the passive state is turned on or off.

So there are a few different ways you could do this, but the method I'll give you here uses two states. One is a passive state on the accessory. That state has no Traits, no icon, nothing.

Give it this notetag:
Code:
<Custom Battle Effect>
user.addState(44);
</Custom Battle Effect>

I assume 44 is your air balloon state because that's what you have in the code you posted.

Now, in the notes of 44, get rid of all of the garbage that doesn't have anything to do with your skill and just put this:
Code:
<Custom Respond Effect>
//Check if actor takes dmg
if (value > 0 && !this.isHpRecover())
    target.removeState(44);
</Custom Respond Effect>

That should be all you need. If the state is giving State Resist to a certain element and you want it to go away after it actually takes damage, and the state ID is 44, this will do that.
 

bisudo

Villager
Member
Joined
Oct 15, 2022
Messages
6
Reaction score
1
First Language
Portuguese
Primarily Uses
RMMV
That should be all you need. If the state is giving State Resist to a certain element and you want it to go away after it actually takes damage, and the state ID is 44, this will do that.
Yup, it works indeed, thank you so much. I never really had time for RPG maker till the last couple weeks, but since then I've already seen you in so many threads and solving so much of my problems lol. Keep the good work and saving peoples games! :D
 

Latest Threads

Latest Posts

Latest Profile Posts

ialfabeiufbgaeyiufgouigfeuagfiebauofvuafuvaufvuiavetgfvgfeiuyfvafuaguydg.
Happy Pride Month! I actually have a game character named Lazura Landerson who is a lesbian, and she's a Cosmic Magi who works on a starship. She's dating another Cosmic Magi named Ciara Kendren, and the two plan to marry someday. As for me, I'm straight... but you're free to choose who you want to be.
Had a dream about ending the project. I think I need a bit of a break, or to keep dev stuff lighter. And not take it super seriously. Don't think its normal to have nightmares over game stuff.
I don't wanna go to work. I want to go back to bed.
A Littlefish classic. I forgot to eat dinner and now I'm wondering how to turn the entire contents of my fridge into an abominable yet strangely satisfying breakfast.

Forum statistics

Threads
131,591
Messages
1,221,354
Members
173,298
Latest member
max80000
Top