Making miss deal (a little) damage

Hello! While playtesting my game I noticed my attacks missed a lot of times, even with just 5% chance to miss,

I think a streak of bad luck, which is strangely likely to happen, would probably anger the player.

I'd like to have every missing attack deal a certain amount of damage for example rand(a.atk), while still having the miss icon pop-up, I don't need such amount to be different from skill to skill.

I imagined I could accomplish this by changing something in the Game_battler script, around line 500:

Spoiler
#-------------------------------------------------------------------------- # * Apply Effect of Skill/Item #-------------------------------------------------------------------------- def item_apply(user, item) @result.clear @result.used = item_test(user, item) @result.missed = (@result.used && rand >= item_hit(user, item)) @result.evaded = ([email protected] && rand < item_eva(user, item)) if @result.hit? unless item.damage.none? @result.critical = (rand < item_cri(user, item)) make_damage_value(user, item) execute_damage(user) end item.effects.each {|effect| item_effect_apply(user, item, effect) } item_user_effect(user, item) end end 
but I'm not quite sure, I'm also not too sure about how to check the a.atk outside of the skill damage formula, can you help me?  🙂
I think this would work. What I did was I copy/pasted the main code to add in an elsif it was a miss (this way an evade still does 0). This will have it do half damage on a miss, change the 0.5 to whatever percent you wish.

I'd recommend posting this as a code snippet in materials above main, and as part of the Game Battler Class.

Edit: Crazy program thinks tab = enter. Grrr. Anyways, I think this code is final now.

Code:
def item_apply(user, item)   @result.clear   @result.used = item_test(user, item)   @result.missed = (@result.used && rand >= item_hit(user, item))   @result.evaded = ([email protected] && rand < item_eva(user, item))   if @result.hit?      unless item.damage.none?        @result.critical = (rand < item_cri(user, item))        make_damage_value(user, item)        execute_damage(user)      end      item.effects.each {|effect| item_effect_apply(user, item, effect) }      item_user_effect(user, item)   elsif @result.miss?      unless item.damage.none?        make_damage_value(user, item) * 0.5        execute_damage(user)      end      item.effects.each {|effect| item_effect_apply(user, item, effect) }      item_user_effect(user, item)   end #End of if/else if codeend #End of item_apply
You would have to change the miss message though, because it isn't exactly a miss anymore, It's a reverse critical. It could be something like

(user's name) knicked the enemy

or

An poorly aimed blow!

or

(User's name) nearly missed

Blind could also cause this reverse critical to be a true miss. How would you do that?
@bgillisp thank you really much for your answer, I tried it, but sadly I ran into two errors,

1) it doesn't recognize @result.miss?, tried changing it to @result.missed? and to @result.missed, only the third one didn't send an error

2) the other error is probably *0.5 , it tells me undefined method ' * ' for nil:NilClass ...

Edit: ok now it works perfectly I removed *0.5 from Item apply and put it here(Line 348 of Game_Battler):

Re-edit: it works better the way bgillisp suggested in the post below

@Oddball you can change this line in the Vocab script  

Code:
EnemyNoHit      = "Missed! %s took no damage!"
@bgillisp thank you really much for your answer, I tried it, but sadly I ran into two errors,

1) it doesn't recognize @result.miss?, tried changing it to @result.missed? and to @result.missed, only the third one didn't send an error

2) the other error is probably *0.5 , it tells me undefined method ' * ' for nil:NilClass ...
That's what happens when I'm not on RPGMaker. It looks like it is @result.missed from what I can see.

For the second, I forgot that it stores the values in @result.hp. Delete the * 0.5, and try this in the line below it.

@result.hp_damage *= 0.5

That should work as far as I can tell.

Edit: I should add to make sure to put that line between the make_item_damage and the execute_damage line.

Edit2: Maybe I should post this as a script snippet somewhere, once the bugs are worked out (if any still remain)? There seems to be some demand for a script like this from what I can tell.
Yes it works perfectly now, I only had to add .to_i to result.hp_damage because otherwise it deals damage in floating point, thank you!
Yes it works perfectly now, I only had to add .to_i to result.hp_damage because otherwise it deals damage in floating point, thank you!
What,  you don't want your characters having 592.562 HP? 😛

Original thread: https://forums.rpgmakerweb.com/threads/making-miss-deal-a-little-damage.38290/