Lokos

Villager
Member
Joined
Apr 27, 2023
Messages
7
Reaction score
0
First Language
English
Primarily Uses
RMMV
I'm testing out a rather simple damage formula for my attacks:

[a.atk * 4 - b.def * 2, 1].max

I want the move always do at least one damage, however despite using this formula, my weakest party members will still do "Null" damage.
Now, the attack I'm using is an element resisted by the test enemies (half damage) but that should theoretically not matter with this formula, right? It should still be minimum 1 damage?

Anyone know what the problem is? Could the Yanfly Battle Engine be messing with something?
 

Roninator2

Gamer
Regular
Joined
May 22, 2016
Messages
5,224
Reaction score
1,557
First Language
English
Primarily Uses
RMVXA
First VX Ace
Ruby:
  def make_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = apply_critical(value) if @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
  end
There are several steps that is processed to get the final result.
The damage formula is the first.

A script written by Sixth can overwrite this.
When the damage value is actually determined it is sent to Game_ActionResult as seen in the last line above.
That then determines what type of damage, HP, MP, HP Drain etc.
Sixth's script (there are others as well) modify this so that if the result is 0 or below then make it 1. So I would say you just need to add in that script to your project.

Second MV
No idea, your profile says you use MV so hopefully you were looking for a VX Ace answer. But the MV result should be similar to VX Ace.
 

Lokos

Villager
Member
Joined
Apr 27, 2023
Messages
7
Reaction score
0
First Language
English
Primarily Uses
RMMV
First VX Ace
Ruby:
  def make_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = apply_critical(value) if @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
  end
There are several steps that is processed to get the final result.
The damage formula is the first.

A script written by Sixth can overwrite this.
When the damage value is actually determined it is sent to Game_ActionResult as seen in the last line above.
That then determines what type of damage, HP, MP, HP Drain etc.
Sixth's script (there are others as well) modify this so that if the result is 0 or below then make it 1. So I would say you just need to add in that script to your project.

Second MV
No idea, your profile says you use MV so hopefully you were looking for a VX Ace answer. But the MV result should be similar to VX Ace.
I managed to find Sixth's script, and it seems to mostly do the job, so thanks for that!

One thing I noticed though is that it will also turn damage to 1 if the enemy is immune to the element, which is the one scenario where I'd probably like it to actually nullify damage.

I guess the easiest way to explain it is using an example like Pokémon, where minimum damage is always 1 unless the opponent is completely immune to the elemental type.
 

Roninator2

Gamer
Regular
Joined
May 22, 2016
Messages
5,224
Reaction score
1,557
First Language
English
Primarily Uses
RMVXA
One thing I noticed though is that it will also turn damage to 1 if the enemy is immune to the element, which is the one scenario where I'd probably like it to actually nullify damage.
We can try to work around that.
Try adding this in
Ruby:
#==============================================================================
# ** Game_ActionResult
#==============================================================================

class Game_ActionResult
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(battler)
    @battler = battler
    @immune = false
    clear
  end
  #--------------------------------------------------------------------------
  # * Set immune status
  #--------------------------------------------------------------------------
  def immune(value)
    @immune = value
  end
end

#==============================================================================
# ** Game_Battler
#==============================================================================

class Game_Battler < Game_BattlerBase
  alias r2_damage_immune_damage_element   make_damage_value
  def make_damage_value(user, item)
    below_zero = false
    value = item.damage.eval(user, self, $game_variables)
    below_zero = true if value <= 0
    value = 10 if below_zero
    value *= item_element_rate(user, item)
    @result.immune(true) if value <= 0
    r2_damage_immune_damage_element(user, item)
    @result.immune(false)
  end
end

Then in Sixth's script change one line
if value == 0 && !item.no_min_dmg && !@immune
 

Lokos

Villager
Member
Joined
Apr 27, 2023
Messages
7
Reaction score
0
First Language
English
Primarily Uses
RMMV
Seems that did the trick, thanks a bunch!
 

Latest Threads

Latest Posts

Latest Profile Posts

So the concept for my Game Jam project is way more than I can complete before the deadline. But I think I found a way to get the core done and make the incomplete parts either not really noticeable or make them a part of the story for now. That sneaky, dastardly Krampus! Then I can complete the rest. Did I mention that this is fun?
I've been working on a game called "Eternal Sunset". Is there anywhere here i can "show it off" maybe? Wondering what others think.
What do you do when there are lots of offers online but you don't have even a slight chance of ever playing those myriads of games?
Ugh, mispelled my username.

Forum statistics

Threads
136,539
Messages
1,267,317
Members
180,207
Latest member
Setsuisnotavailable
Top