Damage Formula Problem

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?
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.
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.
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
Seems that did the trick, thanks a bunch!

Original thread: https://forums.rpgmakerweb.com/threads/damage-formula-problem.161427/