Specify if I want no-null-damage

I know, there are several no null damage scripts that make the minimum damage that can be dealt 1. I'm using one right now (Specifically Kread-EX's) because I want all standardly offensive attacks to deal at least one damage no matter what. One party member has very weak physical offense (a mage of course) so that's why this is even a concern. But I'm wondering if a no null damage script could be made where I can put a note tag in a skill's box that indicates I want it to ignore the no null damage script and deal null damage anyway. (I'm using the Yanfly Battle Engine and I have it where the null damage popup is just blank so it doesn't show up.)


I need this namely for skills with special effects that use the damage formula box with "HP Damage" for their effect, but aren't actually supposed to deal damage. Because of the no null damage script, these attacks (one of which is a skill using this formula as an example, but there are several others in my game with this issue.) are dealing 1 damage even though they're not supposed to cause damage in the first place.
It might be best to remove the script and simply add a [+1] at the end of the damage formula for all the skills that need to do at least one damage. While removing it for skills that can or need to do 0 damage.
@Tatsude K. Hitori I made the damage formula for the normal attack "a.atk * 4 - b.def * 2 + 1" to try that out and it's doing null. Am I doing order of operations wrong, or is it because of variance? Note I'm very non-mathematically-inclined.
a - b + 1 with a default null-damage of 0 is gonna be zero if b >= a + 1.  What was actually recommended is just to put your damage formula in an array.max, such as [damage, 1].max which will return whichever is the larger value.


Keep in mind that this is still effected by variance, but that shouldn't be a problem as variance less than +/-50% should round to 1.
@harosata I'm sorry, but what is an array.max?
An array is [whatever, is, in, here].  An array has a max method which picks out the highest number in that array.  For example, [1,5,3,-2].max would return 5 because it is the highest number in that array.  You have already been provided with a workable example in the form of [damage, 1].max, which would return either the damage or 1 (if the damage calculates as 0 or lower).  Ideally, you would replace damage with your damage formula.


It is also possible to name an array like you would name a switch or variable, so if you decided that this_array = [damage, 1], then you can also find the max number by using this_array.max.


---


But seriously, just put [yourdamageformula, 1].max in your skill's formula box.
That won't work.


The damage formula is only a part of the damage calculation, not it's end result.


Physical/magical and elemental resistances will still be counted, and those can still negate even that 1 point of damage.


Than there is the Guard flag, which will further lower the final damage if the target "guards" (got the Guard flag from any source).


You won't be able to do what you want in the damage formula, that's for sure.


You will need to modify the damage calculations in the code itself to set the final damage to the minimum value you want when the conditions are met for it (such as when a specific skill is not used, in your case).


If you link me that minimum damage script you use, I will add that condition for you in it.
@Sixth 

Code:
class RPG::UsableItem::Damage
  alias_method(:krx_one_ruid_eval, :eval)
  def eval(a, b, v)
	damage = krx_one_ruid_eval(a, b, v)
	damage = 1 if damage == 0 && sign == 1
	damage
  end
end
That script got the same issues I mentioned above, it modifies the damage formula only, not the final damage.


You can still get 0 damage even if you use that, unless you don't use any of the things I mentioned.


Here is one that actually works in all situations:

Spoiler
class RPG::BaseItem

attr_accessor :no_min_dmg

def no_min_dmg
init_no_min_dmg if @no_min_dmg.nil?
return @no_min_dmg
end

def init_no_min_dmg
@no_min_dmg = @note =~ /<no min dmg>/i ? true : false
end

end

class Game_ActionResult

alias add_min_dmg6681 make_damage
def make_damage(value, item)
if value == 0 && !item.no_min_dmg
value = item.damage.recover? ? -1 : 1
end
add_min_dmg6681(value, item)
end

end



This one will modify the real final damage, so it will bypass all those resistance modifiers at the end.


You can use the <no min dmg> note-tag to exclude an item/skill from this calculation.


I haven't really tested this, but it should work.


You can also remove that script from KreadEX, you don't need that anymore.
@Sixth I got an error when I tested using a regular attack on an enemy with very high defense (therefore would have been null.)


tumblr_ok2i9gsFcU1rb9glpo1_500.png



I also tried using a skill I put the <no min dmg> note tag on against an enemy with high defense and therefore would have been null and the same error happened. If it helps, this error only seems to happen when the damage would be null.
Ahh, yeah, I forgot that the recover? method is for the damage of the item, not the item itself. >.>


Fixed it in the above snippet, it should work now.
Thank you very much, you're a lifesaver!

Original thread: https://forums.rpgmakerweb.com/threads/specify-if-i-want-no-null-damage.73847/