Schwipsy

Villager
Member
Joined
Jan 4, 2021
Messages
15
Reaction score
2
First Language
Spanish
Primarily Uses
RMMV
I'm trying to use YEPSkillCore to make the player take damage and drain the MP if it misses the attack. This is the code I tried using (but is not working)
What am I doing wrong?


JavaScript:
<Post-Damage Eval>
var result = target.result();
if (result.missed || result.evaded){
<HP Cost: 5%>
<MP Cost: 10%>
} else {
<HP Cost: 0%>
<MP Cost: 0%>
}
</Post-Damage Eval>
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
938
Reaction score
585
First Language
English
Primarily Uses
RMMV
Your trigger is probably correct but what you're doing when that trigger is checked doesn't work.

Those tags inside the <> brackets are not javascript, so the engine will have no idea what to do with them. You need to manually remove hp/mp from the battler if the action misses/is evaded.

user.gainHp(-Math.round(user.mhp * 0.05))
user.gainMp(-Math.round(user.mmp * 0.10))

You could even show a damage popup too:
user.startDamagePopup()
 

Schwipsy

Villager
Member
Joined
Jan 4, 2021
Messages
15
Reaction score
2
First Language
Spanish
Primarily Uses
RMMV
Your trigger is probably correct but what you're doing when that trigger is checked doesn't work.

Those tags inside the <> brackets are not javascript, so the engine will have no idea what to do with them. You need to manually remove hp/mp from the battler if the action misses/is evaded.

user.gainHp(-Math.round(user.mhp * 0.05))
user.gainMp(-Math.round(user.mmp * 0.10))

You could even show a damage popup too:
user.startDamagePopup()

Thanks! I'll try that. Where should I add the user.startDamagePopup() thing? Tbh I started using this software like 2 days ago, so I'm trying to learn this software.

Where is the documentation for this stuff? I thought it might be the "hp cost" thingy but couldnt find anything online since I was probabbly googling it wrong.

Edit: Btw do you know if there's a way to make it so, the higher the MP, the less chance of missing you have? I'm trying to make a skill with a high miss chance of 20% and I would like it to lower itself the higher the mp.

edi2: Maybe a way to reset MP back to 0 after each combat ends or starts?
 
Last edited:

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
938
Reaction score
585
First Language
English
Primarily Uses
RMMV
Thanks! I'll try that. Where should I add the user.startDamagePopup() thing? Tbh I started using this software like 2 days ago, so I'm trying to learn this software.
Put it right below the other two functions I gave you starting with user.
Where is the documentation for this stuff? I thought it might be the "hp cost" thingy but couldnt find anything online since I was probabbly googling it wrong.
Honestly, I'm not even sure anymore. Most of this stuff I ended up getting from messing around in the console, or looking at other peoples code.
Edit: Btw do you know if there's a way to make it so, the higher the MP, the less chance of missing you have? I'm trying to make a skill with a high miss chance of 20% and I would like it to lower itself the higher the mp.
You'd need a plugin for that, but I'm not sure one exists that allows this to work this way. Skill success rate is flat, so you'd need something to set a custom success rate based on conditions.

edi2: Maybe a way to reset MP back to 0 after each combat ends or starts?
StateCore has the ability to have a state cause an effect on combat end, or combat start
Code:
<Custom Victory Effect>
user.gainMp(-user.mmp)
</Custom Victory Effect>
Code:
<Custom Battle Effect>
user.gainMp(-user.mmp)
</Custom Battle Effect>
You can use that together with the Auto Passive states plugin to make it always on the actors so it always resets MP on victory/battle start.
 

Schwipsy

Villager
Member
Joined
Jan 4, 2021
Messages
15
Reaction score
2
First Language
Spanish
Primarily Uses
RMMV
Put it right below the other two functions I gave you starting with user.

Honestly, I'm not even sure anymore. Most of this stuff I ended up getting from messing around in the console, or looking at other peoples code.

You'd need a plugin for that, but I'm not sure one exists that allows this to work this way. Skill success rate is flat, so you'd need something to set a custom success rate based on conditions.


StateCore has the ability to have a state cause an effect on combat end, or combat start
Code:
<Custom Victory Effect>
user.gainMp(-user.mmp)
</Custom Victory Effect>
Code:
<Custom Battle Effect>
user.gainMp(-user.mmp)
</Custom Battle Effect>
You can use that together with the Auto Passive states plugin to make it always on the actors so it always resets MP on victory/battle start.


Man you're such a bro. By documentation I mean, i didnt even know that the command "user.gainMP" existed. Or that there's a console. Where can I find that stuff?


Again, thanks a lot! You just kinda did the base combat of the project lmao
 
Last edited:

Schwipsy

Villager
Member
Joined
Jan 4, 2021
Messages
15
Reaction score
2
First Language
Spanish
Primarily Uses
RMMV
Put it right below the other two functions I gave you starting with user.

Honestly, I'm not even sure anymore. Most of this stuff I ended up getting from messing around in the console, or looking at other peoples code.

You'd need a plugin for that, but I'm not sure one exists that allows this to work this way. Skill success rate is flat, so you'd need something to set a custom success rate based on conditions.


StateCore has the ability to have a state cause an effect on combat end, or combat start
Code:
<Custom Victory Effect>
user.gainMp(-user.mmp)
</Custom Victory Effect>
Code:
<Custom Battle Effect>
user.gainMp(-user.mmp)
</Custom Battle Effect>
You can use that together with the Auto Passive states plugin to make it always on the actors so it always resets MP on victory/battle start.

Mate, I just tried it out and it doesnt seem to be working at all.

Edit: I thought SkillCore was not working but <hp cost= SOMETHING> works. I'm adding this stuff on the note box of the skill. Am I doing it wrong?
 
Last edited:

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
938
Reaction score
585
First Language
English
Primarily Uses
RMMV
The victory and battle start tags need to be on a state, not the skill. To make this work, create a state with no expiration, and use the YEP_AutoPassiveStates plugin to make it so that the actor (or all actors) have the state active on them at all times. Either do this by putting it in the plugin parameters, or by tagging the actor or class with <passive state: x> in their note box.
 

Schwipsy

Villager
Member
Joined
Jan 4, 2021
Messages
15
Reaction score
2
First Language
Spanish
Primarily Uses
RMMV
The victory and battle start tags need to be on a state, not the skill. To make this work, create a state with no expiration, and use the YEP_AutoPassiveStates plugin to make it so that the actor (or all actors) have the state active on them at all times. Either do this by putting it in the plugin parameters, or by tagging the actor or class with <passive state: x> in their note box.

I didn't try that yet. I added this code into the note of the skill yet it didnt work.
Code:
<Post-Damage Eval>
var result = target.result();
if (result.missed || result.evaded){
user.gainHp(-Math.round(user.mhp * 0.05))
user.gainMp(-Math.round(user.mmp * 0.10)) 
} else {
user.gainMp(Math.round(user.mmp * 0.10)) 
}
</Post-Damage Eval>

Is there a syntax error or something? Thanks
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
938
Reaction score
585
First Language
English
Primarily Uses
RMMV
I don't see anything in there that shouldn't work.

Try putting in some console.log() commands and see what the output is?
Code:
<Post-Damage Eval>
var result = target.result();
console.log(result.missed, result.evaded)
if (result.missed || result.evaded){
user.gainHp(-Math.round(user.mhp * 0.05))
user.gainMp(-Math.round(user.mmp * 0.10))
} else {
user.gainMp(Math.round(user.mmp * 0.10))
}
</Post-Damage Eval>
The only suspicious line to me is defining the result as the target result, when generally, the action result works fine. With that console.log line in there, it should output something to the console, if it's undefined or false, even when the attacker has missed, the target result has probably already been cleared.
I think this.result().missed or this.result().evaded will work instead, but I'm not in a position to check that right now.
 

Schwipsy

Villager
Member
Joined
Jan 4, 2021
Messages
15
Reaction score
2
First Language
Spanish
Primarily Uses
RMMV
I don't see anything in there that shouldn't work.

Try putting in some console.log() commands and see what the output is?
Code:
<Post-Damage Eval>
var result = target.result();
console.log(result.missed, result.evaded)
if (result.missed || result.evaded){
user.gainHp(-Math.round(user.mhp * 0.05))
user.gainMp(-Math.round(user.mmp * 0.10))
} else {
user.gainMp(Math.round(user.mmp * 0.10))
}
</Post-Damage Eval>
The only suspicious line to me is defining the result as the target result, when generally, the action result works fine. With that console.log line in there, it should output something to the console, if it's undefined or false, even when the attacker has missed, the target result has probably already been cleared.
I think this.result().missed or this.result().evaded will work instead, but I'm not in a position to check that right now.

Ok, I just checked the code. If I change it to this.result()missed & this.result().evaded it says "this.result is not a function".
I tried the code you posted and in the console I dont get anything unless i dont actually miss, which gets me a "false false". If I do miss, nothing happens nor appears in the console.
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
938
Reaction score
585
First Language
English
Primarily Uses
RMMV
If you don't miss, it showing false false is what it should do, and in that case it should give back the MP. Since you're not calling a damage popup after, it won't pop any kind of indicator that it happened, though, you'd have to watch the user's MP and see the change yourself.
adding a user.startDamagePopup() will make it so that it shows the mpgain.

Code:
<Post-Damage Eval>
var result = target.result();
console.log(result.missed, result.evaded)
if (result.missed || result.evaded){
user.gainHp(-Math.round(user.mhp * 0.05))
user.gainMp(-Math.round(user.mmp * 0.10))
user.startDamagePopup()
} else {
user.gainMp(Math.round(user.mmp * 0.10))
user.startDamagePopup()
}
</Post-Damage Eval>
I'm honestly not sure why it doesn't show anything at all in the console when a miss....

Wait now I got it. The post-damage eval only happens if the skill being used hits. Since this is a miss, it never does damage, so this eval never happens.

Change it to <after eval> instead. That will go no matter what the result of the skill was.
 

Schwipsy

Villager
Member
Joined
Jan 4, 2021
Messages
15
Reaction score
2
First Language
Spanish
Primarily Uses
RMMV
Dude, that was IT. I changed it to "after eval" and everything worked. Also, the battle states thingy, worked. You're awesome man.
 

Latest Threads

Latest Profile Posts

I'm working on a modding system of my game and I screw the game up, so hard that I have to access my backup in my hard drive ;-;
Stop shutting the damn power down! Why always like this
Working on a slightly experimental horror game. It will be finished in approximately 88888888888 years.
Y'all will enjoy it though, I put lots of effort into making it stand out.

It's called Red Light and it's inspired by another obscure RPG Maker horror game, but I don't want to give too much away just yet.
Ohh man, Weapon animations plugin feels so mandatory. Seeing that same image regardless of the icon of the weapon....ugh :p
Ok so......Maaaaybe I've taken a ''little'' bit of inspiration from FF9 when it comes to battle hud xD

ff9.PNG

Just maybe....

Forum statistics

Threads
112,357
Messages
1,067,718
Members
146,004
Latest member
Faxify
Top