Korokage

Veteran
Veteran
Joined
Mar 1, 2015
Messages
58
Reaction score
9
First Language
English
Primarily Uses
Trying to help a buddy with his project, is there a way to get a skill to check if the target has a particular item? Looking to emulate a passive skill effect that alters how much damage the character takes.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
3,154
Reaction score
1,865
First Language
English
Primarily Uses
RMMV
Trying to help a buddy with his project, is there a way to get a skill to check if the target has a particular item? Looking to emulate a passive skill effect that alters how much damage the character takes.
Yes, but...do you mean the enemy is attacking, and you want to see if the target actor has equipped a certain weapon or armor? Or that the party possesses an item? (these are different terms in the database, and referenced differently in the code).

Also, there are free plugins to give passive states, why choose a workaround that emulates it instead of just actually having a passive skill?
 

Korokage

Veteran
Veteran
Joined
Mar 1, 2015
Messages
58
Reaction score
9
First Language
English
Primarily Uses
Yes, but...do you mean the enemy is attacking, and you want to see if the target actor has equipped a certain weapon or armor? Or that the party possesses an item? (these are different terms in the database, and referenced differently in the code).

Also, there are free plugins to give passive states, why choose a workaround that emulates it instead of just actually having a passive skill?
I don't think my buddy wants to add any more plugins to the project. In any case, it seems that I've misunderstood the problem he was having. I think I need to research a bit more so I can properly help him.
 

Maldra

Veteran
Veteran
Joined
May 31, 2017
Messages
90
Reaction score
10
First Language
English
Primarily Uses
RMMV
I have an ability that self inflicts damage to himself to inflict massage damage to an enemy:
a.gainHp(Math.round(-a.mhp*.2)); a.atk *24 - b.def

I was trying to do a similar ability except instead of a single target, allow it to attack all enemies. However, I only want to inflict damage to himself ONCE. With that formula as it currently stands, it inflicts damage to the user for EACH enemy. How can I make it so it only inflicts damage to the user once?
 

Frostorm

[]D[][]V[][]D
Veteran
Joined
Feb 22, 2016
Messages
2,370
Reaction score
1,985
First Language
English
Primarily Uses
RMMV
I have an ability that self inflicts damage to himself to inflict massage damage to an enemy:
a.gainHp(Math.round(-a.mhp*.2)); a.atk *24 - b.def

I was trying to do a similar ability except instead of a single target, allow it to attack all enemies. However, I only want to inflict damage to himself ONCE. With that formula as it currently stands, it inflicts damage to the user for EACH enemy. How can I make it so it only inflicts damage to the user once?
Instead of putting the a.gainHp(Math.round(-a.mhp*.2)); portion in the formula box, use a notetag like <Custom Execution> or <Pre-Damage Eval> and put it in there.
 

Maldra

Veteran
Veteran
Joined
May 31, 2017
Messages
90
Reaction score
10
First Language
English
Primarily Uses
RMMV
Thanks, I'll try that :)
 

Vis_Mage

Wisp Charmer
Veteran
Joined
Jul 28, 2013
Messages
760
Reaction score
258
First Language
English
Primarily Uses
RMMV
Probably a pretty simple issue I'm having, but could someone help me figure out what I have wrong with this damage formula? The skill is supposed to do an extra 10% damage x the value of a few variables added together.

Just to rule it out, the skill does do damage if it's just ((a.mat * (6 + a.luk)) / b.mdf). As it is now however, it deals 0 damage.

Code:
((a.mat * (6 + a.luk)) / b.mdf) * (1 + (0.1 * (v[289] + v[290] + v[291] + v[292] + v[293] + v[294] + v[295] + v[296] + v[298])))
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
3,154
Reaction score
1,865
First Language
English
Primarily Uses
RMMV
could someone help me figure out what I have wrong with this damage formula?
Holy parentheses, Batman.

Well, I don't see a mathematical error by looking at it. I suggest you double-check the values of all of those variables. If any of them have not been set during your current game, they'll be undefined, and any use of that in an equation will blank it out to NaN (which the damage function might error-check for and turn to 0).

This also means, as far as I know, that this will not work in a battle test since you won't have anything assigning values to the variables. You'll have to run an actual play test.

And then, of course, if any of them are sufficiently negative, it could make that entire side of the equation negative which would 0 out the damage.

So, yeah, troubleshoot the variables.
 

Vis_Mage

Wisp Charmer
Veteran
Joined
Jul 28, 2013
Messages
760
Reaction score
258
First Language
English
Primarily Uses
RMMV
Holy parentheses, Batman.
Haha, yeah, I probably don't need quite that many, just making sure everything is calculated in the order that I'd like it to.

And yep, the variables were the culprit. Not all of the ones I was checking had a value set to them, and I assumed it would just count it as 0, instead of erroring out the entire formula. Setting them all to 0 at the start of the game fixes that. Thank you! :)
 

Clairenova

Villager
Member
Joined
Jul 28, 2021
Messages
8
Reaction score
3
First Language
English
Primarily Uses
RMMV
Hey there! Happy holidays everyone! I wish everyone the best of times and lots of success!!! <3

Anyways, hope Ive got the right thread for this, it seems like my problem could be solved using damage formulas exclusively, so I figured Id start here first. The project Im working on is gonna be having MP also be a Morale system on top of Mana, and I wanna make sure Crits are impactful and demoralize the enemy. So I was hoping to grab a formula to make sure a skill deals MP damage when you land a Critical and ONLY when you land a Critical, on top of just dealing the regular HP damage the attack should logically do with whatever formula I plug in for that. I'm not the best with more complex, conditional coding when it comes to these formulas so I definitely could use some help with this.

I think the current formula I was using in testing was b.gainMp(-X); (a.atk * 4 - b.def * 2) and it was definitely dealing the MP damage on top of HP, but obviously there's more I need add to make the b.gainMp(-X) part only happen conditionally on a Critical Hit. Can that can be done just adding if/and statements into the MP Damage part of the formula?? If so what would that take?? Or am I just way off the mark for making this actually work and rigging something up with the functionality from plugins like Yanfly's Auto Passive States and/or Buff & States Core to add a global passive state with a custom establish effect would be closer to the solution???

Any help in the right direction would go a long way, thanks all :)
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
3,154
Reaction score
1,865
First Language
English
Primarily Uses
RMMV
I was hoping to grab a formula to make sure a skill deals MP damage when you land a Critical and ONLY when you land a Critical
Try:
if (b.result().critical) b.gainMp(-X); a.atk * 4 - b.def * 2
 

TheOnlyLlama

Villager
Member
Joined
Oct 16, 2018
Messages
12
Reaction score
36
First Language
Polish
Primarily Uses
RMMV
Late Merry Christmas and soon Happy New Year!

So a few days ago I resumed work on my game. I wanted to create a skill that deals some damage and inflicts stun state. But if the target is already affected by stun, it's affected by stagger instead. I'm not that good when it comes to more complex damage formulas and I came up with that:

if (b.isStateAffected(12)) {b.remove_state(12); b.add_state(11); a.atk} else {b.add_state(12); a.atk}

As for this moment, it deals no damage and no state is applied whatsoever. Any help or directing me towards the right path will be extremely appreciated.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,619
Reaction score
8,598
First Language
Indonesian
Primarily Uses
RMVXA
add_state and remove_state syntax is for RGSS. For MV onward, it is addState and removeState

So the correct one would be
JavaScript:
if (b.isStateAffected(12)) {b.removeState(12); b.addState(11)} else {b.addState(12)}; a.atk
 

TheOnlyLlama

Villager
Member
Joined
Oct 16, 2018
Messages
12
Reaction score
36
First Language
Polish
Primarily Uses
RMMV
add_state and remove_state syntax is for RGSS. For MV onward, it is addState and removeState

So the correct one would be
JavaScript:
if (b.isStateAffected(12)) {b.removeState(12); b.addState(11)} else {b.addState(12)}; a.atk
OMG! Thank you so much! It works perfectly!
 

Latest Threads

Latest Posts

Latest Profile Posts

Fun fact. Today it's exactly 2600 days since I met my now gf for the first time. Sometimes being a programmer can be really useful. O:)
Is RPG Maker VX (rgss2) still relevant? xD
ZyCHqk2.png

Something about top-downs.
I have never felt so attacked by a tree before :LZSlol: it took 10++ hours to make but at least it looks pretty LOL

Untitled-1.png
now seems like the worst time for me to need a better computer with how much stuff is costing. that and I don't thing there's much else I can do to make MV run any better with what I have.

Forum statistics

Threads
118,455
Messages
1,116,110
Members
155,440
Latest member
yamamushi
Top