RMMV Damage Formula - ideas and help

a6p

Veteran
Veteran
Joined
Nov 1, 2015
Messages
30
Reaction score
8
First Language
English
Hey guys and gals,

My formula "v[3] * a.atk + a.atk * 4 - b.def * 2" is working perfectly with the exception being that it won't do damage on the first turn.

I can't figure out why. Can anyone help?

For the record, it's a charge up style attack that increases in strength each time a player uses a certain skill in the battle. Using the skill with this formula unleashes the damage and as a effect, triggers another common event that clears the charged up variable.

Thanks.
Hey guys I'm actually having the same problem here. Is there a bug in the system?

Additionally, common events used to increase the variable's value only seem to trigger every second time the skill is used.
 

lohenien

Veteran
Veteran
Joined
Mar 15, 2012
Messages
153
Reaction score
8
First Language
english
The issue here "v[3] * a.atk + a.atk * 4 - b.def * 2" maybe be that v[3] is 0 at some point so your attack value is 0 the first time you use it.
 

brendonx

Veteran
Veteran
Joined
Oct 30, 2015
Messages
85
Reaction score
5
First Language
English
Hey! Thanks for that.

But I thought that because it is "v[3] * a.atk + a.atk * 4" it should deal at least the "a.atk * 4" part because that would be calculated after the total of the "v[3] * a.atk" is calculated?
 

lohenien

Veteran
Veteran
Joined
Mar 15, 2012
Messages
153
Reaction score
8
First Language
english
Try it as (v[3] +1)*a.atk and see if it works
 

a6p

Veteran
Veteran
Joined
Nov 1, 2015
Messages
30
Reaction score
8
First Language
English
The issue here "v[3] * a.atk + a.atk * 4 - b.def * 2" maybe be that v[3] is 0 at some point so your attack value is 0 the first time you use it.
Yes, like Brendon's post above me, I also have arithmetic in my formula.

(a.atk*2 - b.def) * (($gameVariables.value(3)+1)^1.5) * (1+(a.level-b.level)/25)

I also have a common event that raises the variable by 1 for each use.

 

Try it as (v[3] +1)*a.atk and see if it works
That doesn't fix the problem.

Additionally, I have also used this formula during a test:

a.isStateAffected(13) ? v[3] *50: 10     with the common event that adds the 13th state.

It deals 10 damage on the first hit, 0 on the second, and 100 on the third.
 
Last edited by a moderator:

Liak

Veteran
Veteran
Joined
Mar 13, 2012
Messages
1,788
Reaction score
270
First Language
German
Primarily Uses
Wow, 17 pages already. :) Maybe we should start collecting the more widely applicable formulas in one place, so if someone needs an idea for a skill, he/she can go through the list and see if something looks interesting.
 

AMGLime

Veteran
Veteran
Joined
Dec 2, 2015
Messages
87
Reaction score
45
First Language
English
I took a quick glance through this thread, and I didn't see anything that works with the two skills I'm trying to build.

One skill does more damage the lower your health is, what I have right now is: 

a.mhp - a.hp / 2 + a.atk * 2

But it doesn't work, but what I want it to do is Subtract my current HP, from my Max HP. Cut it in half, and then add it to my normal attack x 2.

My other skill, I want to restore 50% of my Missing HP.

a.mhp - a.hp * 0.5 + 1

Is what I have, trying something different then the last one to see if it would work. I'm healing for 36, when I have 50 HP. When the most I should get is 25HP if I'm sitting at exactly 1 HP I believe. Does anyone know what I can do to make it work?
 

a6p

Veteran
Veteran
Joined
Nov 1, 2015
Messages
30
Reaction score
8
First Language
English
I took a quick glance through this thread, and I didn't see anything that works with the two skills I'm trying to build.

One skill does more damage the lower your health is, what I have right now is: 

a.mhp - a.hp / 2 + a.atk * 2

But it doesn't work, but what I want it to do is Subtract my current HP, from my Max HP. Cut it in half, and then add it to my normal attack x 2.

My other skill, I want to restore 50% of my Missing HP.

a.mhp - a.hp * 0.5 + 1

Is what I have, trying something different then the last one to see if it would work. I'm healing for 36, when I have 50 HP. When the most I should get is 25HP if I'm sitting at exactly 1 HP I believe. Does anyone know what I can do to make it work?
You simply have to add brackets. The system follows the BEDMAS order of calculating math. That means it'll calculate brackets and exponents first, then multiplications and divisions, then lastly it'll add and subtract.

For the damage formula try this:

(a.mhp - a.hp) / 2 + a.atk * 2

For your healing ability:

(a.mhp - a.hp) * 0.5 + 1
 

AMGLime

Veteran
Veteran
Joined
Dec 2, 2015
Messages
87
Reaction score
45
First Language
English
Thanks a lot a6p. It seems to be in working order now, I didn't even think of adding brackets lol.
 

duskaco

Villager
Member
Joined
Dec 14, 2015
Messages
18
Reaction score
0
First Language
English
I couldn't find anything similar anywhere (not that i have searched for long, but i need to go off soon), and I'm stuck with a problem.

I want to make a skill that deals HP damage, and drains back mp. (Both are constants. In the actual scenario, Drain MP Lv1 Deals 30 damage, while recover's the user's mana by 3. Actually draining the enemy's mana is optional) But none of my trial scripts are working. (Not that I have much experience in anything but the basics)

Another thing I noticed is that Hp drain drains 100% of the dealt damage as hp. Is it possible to change it to a portion of the dealt damage? (Deals 30k damage, regains 300 hp)

(Please show me what exactly I should type in the formula box, as I might not understand it if abstract terms are used. I'm sorry for the inconvenience.)

(Plugins used: Some Yanfly plugins including core engine, battle engine core, skill core and quite a bit of sub plugins)
 

luigiman2201

Villager
Member
Joined
Oct 30, 2015
Messages
16
Reaction score
2
First Language
English
I couldn't find anything similar anywhere (not that i have searched for long, but i need to go off soon), and I'm stuck with a problem.

I want to make a skill that deals HP damage, and drains back mp. (Both are constants. In the actual scenario, Drain MP Lv1 Deals 30 damage, while recover's the user's mana by 3. Actually draining the enemy's mana is optional) But none of my trial scripts are working. (Not that I have much experience in anything but the basics)

Another thing I noticed is that Hp drain drains 100% of the dealt damage as hp. Is it possible to change it to a portion of the dealt damage? (Deals 30k damage, regains 300 hp)

(Please show me what exactly I should type in the formula box, as I might not understand it if abstract terms are used. I'm sorry for the inconvenience.)

(Plugins used: Some Yanfly plugins including core engine, battle engine core, skill core and quite a bit of sub plugins)
You can use a.gainMp(x) in your formula, with x being the amount of MP/Mana you regain.

If you want it to drain MP/Mana from the enemy, use b.gainMp(x) (b refers to the target), with x being the amount of MP you want them to lose (use a negative value).

For the Drain MP Lv1 example you've given your formula would be this (let's say the damage formula is the standard a.atk * 4 - b.def * 2 and 10% of the damage is drained through MP):

a.gainMp((a.atk * 4 - b.def * 2) * 0,1);b.gainMp(-((a.atk * 4 - b.def * 2) * 0,1));a.atk * 4 - b.def * 2If your atk = 15 and the enemy's defense = 5

a.gainMp((15 * 4 - 5 * 2) * 0,1);b.gainMp(-((15 * 4 - 5 * 2) * 0,1));15 * 4 - 5 * 2
Code:
a.gainMp((60 - 10) * 0,1);b.gainMp(-((60 - 10) * 0,1));60 - 10
Code:
a.gainMp(5);b.gainMp(-5);50
In other words, you deal 50 damage, the user gains 5 MP, the enemy loses 5 MP

Let me know if there's still anything you don't understand and i'll try to explain.
 

a6p

Veteran
Veteran
Joined
Nov 1, 2015
Messages
30
Reaction score
8
First Language
English
You can use a.gainMp(x) in your formula, with x being the amount of MP/Mana you regain.

If you want it to drain MP/Mana from the enemy, use b.gainMp(x) (b refers to the target), with x being the amount of MP you want them to lose (use a negative value).

For the Drain MP Lv1 example you've given your formula would be this (let's say the damage formula is the standard a.atk * 4 - b.def * 2 and 10% of the damage is drained through MP):

a.gainMp((a.atk * 4 - b.def * 2) * 0,1);b.gainMp(-((a.atk * 4 - b.def * 2) * 0,1));a.atk * 4 - b.def * 2If your atk = 15 and the enemy's defense = 5

a.gainMp((15 * 4 - 5 * 2) * 0,1);b.gainMp(-((15 * 4 - 5 * 2) * 0,1));15 * 4 - 5 * 2
Code:
a.gainMp((60 - 10) * 0,1);b.gainMp(-((60 - 10) * 0,1));60 - 10
Code:
a.gainMp(5);b.gainMp(-5);50
In other words, you deal 50 damage, the user gains 5 MP, the enemy loses 5 MP

Let me know if there's still anything you don't understand and i'll try to explain.
This is pretty good and all, but the formula doesn't account for whether the skill deals more MP damage than the target already has. It could very well deal 10 MP damage to an enemy with only 8 MP, but still return 10 MP to the user.

Try this formula instead, it's pretty much the same as Luigi's but with the Math command added:

a.gainMp(Math.min(b.mp, (a.atk * 4 - b.def * 2) * 0.1));b.gainMp(Math.max(-b.mp, -((a.atk * 4 - b.def * 2) * 0.1)));a.atk * 4 - b.def * 2The Math.min() command returns the lowest of the two numbers (separated by commas). This allows you to gain either the amount of MP the target currently has, or the 10% of the damage dealt, so you're not absorbing more MP than the target already has.

The Math.max() command returns the highest of the two numbers (which is important because you're dealing with negative integers).

Also remember that battle formula commands are case sensitive!
 

a6p

Veteran
Veteran
Joined
Nov 1, 2015
Messages
30
Reaction score
8
First Language
English
Hey guys and gals,

My formula "v[3] * a.atk + a.atk * 4 - b.def * 2" is working perfectly with the exception being that it won't do damage on the first turn.

I can't figure out why. Can anyone help?

For the record, it's a charge up style attack that increases in strength each time a player uses a certain skill in the battle. Using the skill with this formula unleashes the damage and as a effect, triggers another common event that clears the charged up variable.

Thanks.
If you haven't found a way to fix this yet, try using

$gameVariables.value(1) * a.atk + a.atk * 4 - b.def * 2I find that using v[x] in formulas is kinda buggy. It isn't recognized as a number in the battle formula on the first time it's used, among other things.

$gameVariables.value(x) doesn't seem to have this issue for some reason.

I don't know if this'll work for you, since the problem with my formula was actually a syntax error.
 
Last edited by a moderator:

brendonx

Veteran
Veteran
Joined
Oct 30, 2015
Messages
85
Reaction score
5
First Language
English
Thanks a lot A6P! I'll try this as soon as I get home!
 

duskaco

Villager
Member
Joined
Dec 14, 2015
Messages
18
Reaction score
0
First Language
English
This is pretty good and all, but the formula doesn't account for whether the skill deals more MP damage than the target already has. It could very well deal 10 MP damage to an enemy with only 8 MP, but still return 10 MP to the user.

Try this formula instead, it's pretty much the same as Luigi's but with the Math command added:

a.gainMp(Math.min(b.mp, (a.atk * 4 - b.def * 2) * 0.1));b.gainMp(Math.max(-b.mp, -((a.atk * 4 - b.def * 2) * 0.1)));a.atk * 4 - b.def * 2The Math.min() command returns the lowest of the two numbers (separated by commas). This allows you to gain either the amount of MP the target currently has, or the 10% of the damage dealt, so you're not absorbing more MP than the target already has.

The Math.max() command returns the highest of the two numbers (which is important because you're dealing with negative integers).

Also remember that battle formula commands are case sensitive!
You can use a.gainMp(x) in your formula, with x being the amount of MP/Mana you regain.

If you want it to drain MP/Mana from the enemy, use b.gainMp(x) (b refers to the target), with x being the amount of MP you want them to lose (use a negative value).

For the Drain MP Lv1 example you've given your formula would be this (let's say the damage formula is the standard a.atk * 4 - b.def * 2 and 10% of the damage is drained through MP):

a.gainMp((a.atk * 4 - b.def * 2) * 0,1);b.gainMp(-((a.atk * 4 - b.def * 2) * 0,1));a.atk * 4 - b.def * 2If your atk = 15 and the enemy's defense = 5

a.gainMp((15 * 4 - 5 * 2) * 0,1);b.gainMp(-((15 * 4 - 5 * 2) * 0,1));15 * 4 - 5 * 2
Code:
a.gainMp((60 - 10) * 0,1);b.gainMp(-((60 - 10) * 0,1));60 - 10
Code:
a.gainMp(5);b.gainMp(-5);50
In other words, you deal 50 damage, the user gains 5 MP, the enemy loses 5 MP

Let me know if there's still anything you don't understand and i'll try to explain.
Thanks for the help! It's working perfectly now.

And thanks for the clear explanation. It was really helpful for understanding the code.
 

duskaco

Villager
Member
Joined
Dec 14, 2015
Messages
18
Reaction score
0
First Language
English
This is the same question as the one in this http://forums.rpgmakerweb.com/index.php?/topic/53431-inflicting-a-trait-if-another-trait-exists/

So it might be answered there, but I'm told to ask the question here... so, here goes.

I wish to make a state that activates when the state is reapplied to the same target.

For example,

[stagger] causes an enemy to lose 20% of his attack and magic attack, and is removed after an action.

But, if another [stagger] effect is applied onto the same enemy while the previous stagger exists, [stagger] will be removed, and changed into [Knockdown], where the enemy cannot do anything for the turn.

Take for example I have a skill called Stone. When it hits an enemy, it will inflict [stagger] for one turn.

Then I use a skill called Power Strike, that can also inflict [stagger]. The enemy's [stagger] is removed and changed into [Knockdown].

The same results should be achievable with 2 Stones, or 2 Power Strikes, or similar skills.

Is it possible to achieve this without scripts or plugins?

If not, what plugins do I need to use to do this?

Do I need to make a script?
 

a6p

Veteran
Veteran
Joined
Nov 1, 2015
Messages
30
Reaction score
8
First Language
English
This is the same question as the one in this http://forums.rpgmakerweb.com/index.php?/topic/53431-inflicting-a-trait-if-another-trait-exists/

So it might be answered there, but I'm told to ask the question here... so, here goes.

I wish to make a state that activates when the state is reapplied to the same target.

For example,

[stagger] causes an enemy to lose 20% of his attack and magic attack, and is removed after an action.

But, if another [stagger] effect is applied onto the same enemy while the previous stagger exists, [stagger] will be removed, and changed into [Knockdown], where the enemy cannot do anything for the turn.

Take for example I have a skill called Stone. When it hits an enemy, it will inflict [stagger] for one turn.

Then I use a skill called Power Strike, that can also inflict [stagger]. The enemy's [stagger] is removed and changed into [Knockdown].

The same results should be achievable with 2 Stones, or 2 Power Strikes, or similar skills.

Is it possible to achieve this without scripts or plugins?

If not, what plugins do I need to use to do this?

Do I need to make a script?
You can do this with a "states stack" script. I know they exist but I'm not up for finding one.

Alternatively, this particular effect can be done in the formula.

Let x = stagger's state id, let y = knockdown's state id

b.isStateAffected(x) ? b.addState(y): b.addState(x); input damage formula hereThis formula checks if stagger is applied to the target. If the target doesn't have stagger, stagger is added to the target and damage is dealt based on the formula. If the target is staggered, knockdown is applied instead and damage is dealt based on the formula.

Not that this is relevant, but you can also use stats to set up more creative conditions, for example:

a.hp < 100 ? b.addState(1)(a.atk - b.luk) = 0 ? 9999: 0I don't know if there's a code for removing states. You might just have to edit the Knockdown state to remove Stagger in the state editor. 
 
Last edited by a moderator:

duskaco

Villager
Member
Joined
Dec 14, 2015
Messages
18
Reaction score
0
First Language
English
I see. Thanks for the clear explanation! I think I would go to search for a state stacking plugin though, since it might be a hassle (significantly more than a mere hassle) to enter this line in every skill with the same effect.
 

emelian65

Veteran
Veteran
Joined
Sep 13, 2015
Messages
190
Reaction score
50
First Language
Spanish
Primarily Uses
Hello everyone I have read most of this pages(I admit that I skip some) and I found myself with a problem.

b.isStateAffected(16) ? b.addState(1): 30 + a.mat * 4 - b.mdf * 2;

This is supposed to inflcit Death if an enemy is suffering of a specific State a two-turn-kill strategy that some enemies will use, I have tried it in a completely clean project, the results is that the target is revived automatically after he is killed(even the message of Has been revived appears) in the case of enemies, however if the allies are affected the test crashes and this appears.

TypeError

Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': float parameter 3 is non-finite.

This also appears in a new project, soo can someone tell me what am I doing wrong?

This is the New Project

TypeError: Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': float parameter 3 is non-finite.

    at TypeError (native)

    at Bitmap.gradientFillRect (file:///C:/Users/Administrador/Documents/Games/Test%20Zero/js/rpg_core.js:781:24)

    at Window_BattleStatus.Window_Base.drawGauge (file:///C:/Users/Administrador/Documents/Games/Test%20Zero/js/rpg_windows.js:469:19)

    at Window_BattleStatus.Window_Base.drawActorHp (file:///C:/Users/Administrador/Documents/Games/Test%20Zero/js/rpg_windows.js:555:10)

    at Window_BattleStatus.drawGaugeAreaWithTp (file:///C:/Users/Administrador/Documents/Games/Test%20Zero/js/rpg_windows.js:5518:10)

    at Window_BattleStatus.drawGaugeArea (file:///C:/Users/Administrador/Documents/Games/Test%20Zero/js/rpg_windows.js:5511:14)

    at Window_BattleStatus.drawItem (file:///C:/Users/Administrador/Documents/Games/Test%20Zero/js/rpg_windows.js:5484:10)

    at Window_BattleStatus.Window_Selectable.drawAllItems (file:///C:/Users/Administrador/Documents/Games/Test%20Zero/js/rpg_windows.js:1250:18)

    at Window_BattleStatus.refresh (file:///C:/Users/Administrador/Documents/Games/Test%20Zero/js/rpg_windows.js:5478:10)

    at Function.BattleManager.refreshStatus (file:///C:/Users/Administrador/Documents/Games/Test%20Zero/js/rpg_managers.js:2046:24)

 

This is the project with the plug-ins am I doing something wrong?

 

TypeError: Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': float parameter 3 is non-finite.

    at TypeError (native)

    at Bitmap.gradientFillRect (file:///C:/Users/Administrador/Documents/Games/DEX%20-%20Demonic%20Extension%20Program/js/rpg_core.js:781:24)

    at Window_BattleStatus.Window_Base.drawGauge (file:///C:/Users/Administrador/Documents/Games/DEX%20-%20Demonic%20Extension%20Program/js/plugins/YEP_CoreEngine.js:1238:19)

    at Window_BattleStatus.Window_Base.drawActorHp (file:///C:/Users/Administrador/Documents/Games/DEX%20-%20Demonic%20Extension%20Program/js/rpg_windows.js:555:10)

    at Window_BattleStatus.Window_Base.drawActorHp (file:///C:/Users/Administrador/Documents/Games/DEX%20-%20Demonic%20Extension%20Program/js/plugins/YEP_SkillCore.js:1029:44)

    at Window_BattleStatus.drawGaugeArea (file:///C:/Users/Administrador/Documents/Games/DEX%20-%20Demonic%20Extension%20Program/js/plugins/YEP_BattleStatusWindow.js:458:10)

    at Window_BattleStatus.drawItem (file:///C:/Users/Administrador/Documents/Games/DEX%20-%20Demonic%20Extension%20Program/js/plugins/YEP_BattleStatusWindow.js:428:10)

    at Window_BattleStatus.processStatusRefresh (file:///C:/Users/Administrador/Documents/Games/DEX%20-%20Demonic%20Extension%20Program/js/plugins/YEP_BattleEngineCore.js:4267:10)

    at Window_BattleStatus.updateStatusRequests (file:///C:/Users/Administrador/Documents/Games/DEX%20-%20Demonic%20Extension%20Program/js/plugins/YEP_BattleEngineCore.js:4258:50)

    at Scene_Battle.updateStatusWindowRequests (file:///C:/Users/Administrador/Documents/Games/DEX%20-%20Demonic%20Extension%20Program/js/plugins/YEP_BattleEngineCore.js:3633:24)

 

Sorry if this was not the place to ask but I'm really hitting myself with this.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Posts

Latest Profile Posts

Frostorm wrote on Featherbrain's profile.
Hey, so what species are your raptors? Any of these?
... so here's my main characters running around inside "Headspace", a place people use as a safe place away from anxious/panic related thinking.
Stream will be live shortly! I will be doing some music tonight! Feel free to drop by!
Made transition effects for going inside or outside using zoom, pixi filter, and a shutter effect
I have gathered enough feedback from a few selected people. But it is still available if you want to sign up https://forums.rpgmakerweb.com/index.php?threads/looking-for-testers-a-closed-tech-demo.130774/

Forum statistics

Threads
105,992
Messages
1,018,195
Members
137,773
Latest member
Kirakirna
Top