How to make the most of custom formulae. Part #1

is there a way to include a character's elemental affinity in a damage formula?

I want to make it so that a character's elemental damage is inversely related to their resistances.  so taking 80% ice damage would allow the user to do 120% fire damage, and 150% ice damage would cause 50% fire damage inflicted.

Is this something I can do with the formula box, or would I need a script for this?
Noticed there was a formula a while back that went something like custom_formula(a,b,false)

Out of curiosity how I would I set this up so that the formula would pull from a list of conditions like custom_formula(a,b,melee) and custom_formula(a,b,magic) with the third variable in the formula pointing to a specific condition within the formula.
you could do something like

Code:
def custom_formula(a,b,cond)  case cond.to_s  when "melee"    #do things  when "magic"    #do things  and so on  endend
you could do something like

def custom_formula(a,b,cond) case cond.to_s when "melee" #do things when "magic" #do things and so on endend
To use this formula, you need to write this in damage formula box

Code:
custom_formula(a,b,"melee")custom_formula(a,b,"magic")
Thanks for the heads up, been trying to consolidate my coding to make it easier to manage.
Though if they won't share anything, might be better to just separate them than use case blocks.
How to create a skill or spell that when used/ cast on the castsr, the caster will gain a chance on being hit to automatically cast spell/perform skill?

Eg. The caster has 20% chance on being hit (by normal attack or magic attack or both) to cast "Recovery" spell on him/herself.
You would add a state to the caster, then utilize a script like yanfly's lunatic states to make feedback effects for that state. 
You would add a state to the caster, then utilize a script like yanfly's lunatic states to make feedback effects for that state.
I have found the script you recommended. Could you suggest how to write string to make it work?

Something like?

<shock effect>

rand(100)<20 ? a.add_state(x) : nil

</shock effect>
No... you're gonna use the script on the state to make the caster use the spell when hit... You add the state to the caster via the damage formula via doing something like

a.add_state(STATE_ID);damage_formula

then using the lunatic states, you make him cast the recovery spell or maybe just heal himself right away 
No... you're gonna use the script on the state to make the caster use the spell when hit... You add the state to the caster via the damage formula via doing something like

a.add_state(STATE_ID);damage_formula

then using the lunatic states, you make him cast the recovery spell or maybe just heal himself right away
It seems not to be what I am asking (or I just misunderstand your point). Here is a brief situation;Supposedly, Eric learns a passive skill called "Anger Management" which will make him has 20% chance when being hit by any kind of damage from enemy to increase ATK by 30%.

Is your formula mentioned above is for enemy's attack to add state to Eric which forces him cast a spell?
Ahh... A passive skill, then you could be using a passive skill script which adds a state to the user and simply use the lunatic tags for the damage effect...

You won't want to do this via damage formula as that would mean making all skills check if the target has that skill, then do feedback damage to the user if that is true
Ahh... A passive skill, then you could be using a passive skill script which adds a state to the user and simply use the lunatic tags for the damage effect...

You won't want to do this via damage formula as that would mean making all skills check if the target has that skill, then do feedback damage to the user if that is true
Thanks for your reply. I'll try to work around with the script and see what I can do. Anyway, is there a way to adjust critical damage by using formula box? I have 2 points to adjust

1) I would like crit damage equals to attacker's atk (ignoring enemy's defense)

2) I'm thinking using variable to modify crit damage for each actor in game (which actually don't have many though).

Current I have basic attack skill damage (skill no.1 in data base)

def base_dmg(a,b )

something

something

# Just wonder how to add crit damage modify script here

end

Thanks for your help!
You need to edit the script part where critical damage is calculated to do that... Which AFAIK is inside the make_damage_value method, which means you will need a direct overwrite of that method coz an alias just won't do...
You need to edit the script part where critical damage is calculated to do that... Which AFAIK is inside the make_damage_value method, which means you will need a direct overwrite of that method coz an alias just won't do...
Ahh that's not what I can do really. I don't have much knowledge about scripting.

Thanks anyway for you reply!
Update: I found out how to write the formula myself. Just ignore it.



How make a damage formula which depends on state's duration (no. of turn remainning)?

For example, if there is a state applied on a target and has a full duration of 5 turns, will do extra damage by 50% to the target. 1 remainning turn per 10% extra damage something like that.

Thanks!

I am sorry if this was posted here before, but I have a question and I don't know if it could be resolved by formulae:

I want my healer to cast an attack that deals damage to all enemies and cures all allies (let's say for a 20% of their life total), is this possible to do?

Thanks in advance  😀
I might not have had enough caffeine, but I can't figure out what is wrong with this formula:

((a.level+a.atk)*5)/((b.level+b.def)+(b.agi/10))
@ Dalamar: By default Ace works with integers only, so all partial numbers are rounded down.


Example: If b.agi is 9, then b.agi/10 is 0.9 and that will be stored as 0 (dropping the .9) before continuing the calculation.


If the values from the target (b.level, b.def and b.agi) are high enough, the entire formula will always be zero due to rounding down after the division.


---------------


If that answer doesn't help you, you need to tell us what you expect to happen and what happens with that formula
With my formula I should be getting a value of 20 damage with no weapon equipped when the character attacks and 1 when the enemy attacks, all I am getting is no damage on both sides (using a level 5 character with atk=15, def=14, agi=13, the enemy atk=7, def=4, agi=10).

So ((5+15)*5)/((0+4)+(10/10) when the character attacks and ((0+7)*5)/((5+14)+(13/10) when the enemy attacks.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-the-most-of-custom-formulae-part-1.1143/