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
4,500
Reaction score
2,855
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,737
Reaction score
2,296
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
773
Reaction score
276
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
4,500
Reaction score
2,855
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
773
Reaction score
276
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
11
Reaction score
6
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
4,500
Reaction score
2,855
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,814
Reaction score
9,142
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!
 

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
4,977
Reaction score
4,587
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
4,977
Reaction score
4,587
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 Posts

Latest Profile Posts

Couldn't sleep at all so I started working on the topmost deck. I've had to make several deviations from the Imperator/Berengaria's deck-plans to accommodate MV's movement, but 100% accuracy was never my intention.
Still no name for the poor ship...:kaodes:
Screenshot-2022-06-25-053308.png
ScreenShot_6_24_2022_9_20_7.png
Here's Mike when you get a preemptive strike in battle. There's another one for when an enemy sneaks up on you too.
Suddenly, games mean nothing. The money spent was worth it to bring souls towards the light of life. May God bless my path forever. I pray that all are shaken for truth and poured out flat on the table of true understanding, knowledge, and wisdom. Bless you.
Finally I bought OMORI...cant wait to get traumatised!!!
Finished making this pretty ambitious forest map. Was wondering what y'all think of it! :kaopride:
1656136876015.png

Forum statistics

Threads
123,022
Messages
1,153,464
Members
161,365
Latest member
sieuthitien
Top