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
7,737
Reaction score
5,497
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
94
Reaction score
11
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,788
Reaction score
2,232
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
94
Reaction score
11
First Language
English
Primarily Uses
RMMV
Thanks, I'll try that :)
 

Vis_Mage

Wisp Charmer
Veteran
Joined
Jul 28, 2013
Messages
775
Reaction score
278
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
7,737
Reaction score
5,497
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
775
Reaction score
278
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
13
Reaction score
7
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
7,737
Reaction score
5,497
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
7,180
Reaction score
10,575
First Language
Indonesian
Primarily Uses
N/A
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!
 

tsurugikage

Villager
Member
Joined
May 12, 2017
Messages
24
Reaction score
0
First Language
English
Primarily Uses
RMMV
I'm trying to do something similar to this using a number of "Math.randomInt(6)+a.level" a multiple number of times equal to the level of the caster, however all I could think of was adding "a.level*" to before it, and sadly, that just multiplies the integer by the level.

Any suggestions? I tried "if" commands, but I don't think I don't understand it fully.

My planned ideas were
a.level*Math.randomInt(6)+a.level
and
Math.randomInt(6)+a.level if (a.level>1) {+Math.randomInt(6)}; if (a.level>2) {+Math.randomInt(6)}; etc
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
6,028
Reaction score
6,042
First Language
English
Primarily Uses
RMMZ
I'm trying to do something similar to this using a number of "Math.randomInt(6)+a.level" a multiple number of times equal to the level of the caster, however all I could think of was adding "a.level*" to before it, and sadly, that just multiplies the integer by the level.

Any suggestions? I tried "if" commands, but I don't think I don't understand it fully.
So you want to reroll the "die" once for each level and use the combined total as the damage?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
6,028
Reaction score
6,042
First Language
English
Primarily Uses
RMMZ
Yes. Exactly. Up to a certain level anyways.
var damage = 0; for (var i = 0; i < Math.min(a.level, maximum level for effect); i++) { damage += Math.randomInt(6) + a.level; }; damage;
 

tsurugikage

Villager
Member
Joined
May 12, 2017
Messages
24
Reaction score
0
First Language
English
Primarily Uses
RMMV
var damage = 0; for (var i = 0; i < Math.min(a.level, maximum level for effect); i++) { damage += Math.randomInt(6) + a.level; }; damage;
Thank you. I am trying it out right now and so far it is working splendidly ^v^
 

Latest Threads

Latest Profile Posts

Brace yourself. We are approaching that time of the year again.
I once said, "I definitely want to be done with this project before my 40th birthday." At the time, I was about 50% done with the project.

With under 365 days to go now, I'm about ... 30% done.

What a sweet, innocent fool I was.
can anyone tell me how to edit my pfp it isn't obvious and I'm new here
Damn, took a chance on a paid MV plugin working with MZ (FOSSIL) but didn't work :p Been lucky up until now so I got cocky!
Going to be streaming more RM game dev in about 20 minutes or so...

Forum statistics

Threads
129,990
Messages
1,206,799
Members
171,228
Latest member
TsukiPTGamer69
Top