I'm not really sure how to do this. You can't access the action id of the current action in Game_Battler (where the final calculated damage is dealt) so I tried to do this in Game_Action.
The idea is simple: Some skills are non-lethal or have a chance to not be.
For example, let's say that you have the move Bash. It has a great chance of knockdown, but deals nonlethal damage.
When nonlethal damage is dealt to an enemy and the damage exceeds their current HP, they fall Unconscious. Using Stabilize on an ally will make them Prone, and using Stabilize once more brings them back to normal.
They say a good strategy is to incapacitate an enemy instead of killing them, so their allies will be distracted tending to them.
In the early part of Game_Action, I put this this snippet:
attr_reader :lethalAt the bottom of Game_Action, I add this part:
#------------------------------------------------------------------------- # Lethality #------------------------------------------------------------------------- #my edit -- lethality def lethal if item.is_a?(RPG::Skill) @lethal = false # All moves are lethal unless otherwise specified case item.id when 300 #Non-lethal Skill# @lethal = true end end endFinally, I make this adjustment to execute_damage(user)
def execute_damage(user) on_damage(@result.hp_damage) if @result.hp_damage > 0 #my edit -- lethality in regards to final damage proceedure #-- if $Game_Action.lethal != true && @result.hp_damage >= self.hp self.hp -= (@result.hp_damage - 1) self.add_state(200) #become unconsious else self.hp -= @result.hp_damage end #--however, when attacking an enemy, I get the error
Script 'Game_Battler' line 408: NoMethodError occurred.undefined method 'lethal' for nil:NilClassI feel like I'm missing some simple things in all of this to make it work. Any help?
I think you might need to check action_result instead. Or, find the object that is of Game_action type in order for that to work (which, action_result might be, I can't recall right now).
It's late in my time zone though so I'll have to fire up RPGMaker tomorrow after work and look at this more, unless someone else manages to solve it first.
Action_Result deals with the value of the HP damage dealt. I want to keep the actual value of the HP damage the same, so the player knows how much damage they dealt, and also for means of TP Charge (which is based on damage dealt) and some ailments, which, per scripting, are also based on damage dealt. I just want to affect how much HP is subtracted after the final damage is calculated, based on the current action in play.
I also tried intitializing 'lethal' in Game_Battler as well and having the condition be @lethal != true instead of $Game_Action.lethal != true, but doing so ends up making it so that skills are always lethal.
You could try something like this..
class Game_Battler alias :mdvforshitvaluedeki :make_damage_value def make_damage_value(user, item) @user_using_item = user # Not used, just shown to point it out.. @item_being_used = item mdvforshitvaluedeki(user, item) end alias :aplgrdshitvaluedeki :apply_guard def apply_guard(value) old_val = aplgrdshitvaluedeki(value) if old_val >= self.hp && [300].include?(@item_being_used.id) add_state(200) old_val -= 1 end old_val end endSlightly different approach, but similar end result. 🙂
I think I would want to copy the hp damage part onto execute_damage(user) and not make_damage_value. Either way.
But then yeah, Yato, how would I reference whether the action is an item or a skill using the process you gave me, and condition the action id in an array like I can with 'case -- when a,b,c,d,e
Since there will be both items and skills that deal non-lethal damage, and there will be a lot of them, arrays would be the most fast and efficient
Hm, I'd have to see how efficient that is, working with apply_guard.
Dekita, assuming you meant to put that process right under the normal apply_guard in Game_Battler,
using a skill results in the error
Script 'Game_Battler' line 412: NoMethodError occurred.undefined method 'damage' for nil:NilClassreferring to 'item.damage.to_hp?'
Strange, you should never be able to use a nil item...
Just put a check for 'return unless item' in the method. 🙂
edit: before the item.damage is checked.
Before the item damage is checked?
So, this is my layout:
def apply_guard(damage) damage / (damage > 0 && guard? ? 2 * grd : 1) end #my edit############################################### class RPG::Skill < RPG::UsableItem def nonlethal? return [300].include?(id) endendclass RPG::Item < RPG::UsableItem def nonlethal? return [34, 35].include?(id) endend alias :aplgrdshitvaluedeki :apply_guard def apply_guard(value) old_val = aplgrdshitvaluedeki(value) if is_lethal_attack?(old_val) add_state(200) old_val -= 1 end old_val end def is_lethal_attack?(value) item = @item_being_used return false unless item return false unless item.damage.to_hp? return false unless value >= self.hp return item.nonlethal? end################################################I used skill 300 and it killed the slime. I scratch my head at that one.
Oh my thats messy...
Ok, the method should be placed within a class, more specifically, the class I linked above. It shuld* resemble something like this...
class RPG::Skill < RPG::UsableItem def nonlethal? return [300].include?(id) endendclass RPG::Item < RPG::UsableItem def nonlethal? return [34, 35].include?(id) endendclass Game_Battler alias :mdvforshitvaluedeki :make_damage_value def make_damage_value(user, item) @user_using_item = user # Not used, just shown to point it out.. @item_being_used = item mdvforshitvaluedeki(user, item) end alias :aplgrdshitvaluedeki :apply_guard def apply_guard(value) old_val = aplgrdshitvaluedeki(value) if is_lethal_attack?(old_val) add_state(200) old_val = hp-1 end old_val end def is_lethal_attack?(value) item = @item_being_used return false unless item return false unless item.damage.to_hp? return false unless value >= self.hp return item.nonlethal? end endIts likely the reason the slime died is due to the fact that you had the methods placed so strangely..
However, it could have been because the old value was only being reduced by one, rather than setting the battlers hp to 1. The above code should fix this. 🙂
Edit:
This code should be placed in its own script page under materials and above main. Also below any custom battle systems you are using (maybe other scripts that overwrite make damage value)
Thanks for setting that up. Very helpful. Yeah, I realized I was subtracting damage wrong as well. Only thing is, the method you're using reduces the final damage instead of the HP subtracted (which I mentioned was my end goal).
So if a target's remaining HP is 5 and they took 1000 non-lethal damage from a move that deals Bleed based on damage dealt (using a script),
the damage calculated would be reduced to 4 so they wouldn't gain any TP from being attacked and they wouldn't begin bleeding.
Is there a way to relocate this process over to execute_damage or so?
I also tried
(Game_Action)
def checklethality(user) if item.is_a?(RPG::Skill) $game_switches[1] = false #nonlethal by default case item.id when 300 #Nonlethal $game_switches[1] = true #switch "Damage is Nonlethal" is turned on end end (Game_Battler)
def execute_damage(user) on_damage(@result.hp_damage) if @result.hp_damage > 0 user.checklethality if $game_switches[1] == true and @result.hp_damage >= self.hp self.hp -= (@result.hp_damage - 1) else self.hp -= @result.hp_damage end self.mp -= @result.mp_damage user.hp += @result.hp_drain user.mp += @result.mp_drain endbut could not find the right way to access my process in Game_Battler of checking which determines if the skill is nonlethal or not
~~~
Wait, duhhh, I found the solution-- the skill damage formula.
Here's an example for a non-lethal skill damage formula
value = 500; if rand(1000) > value then $game_switches[1] = true end; a.atk*4 - b.def*2Then your execute_damage will want to look like this
def execute_damage(user) on_damage(@result.hp_damage) if @result.hp_damage > 0 if $game_switches[1] && @result.hp_damage >= self.hp self.hp -= (self.hp - 1) self.add_state(300) else self.hp -= @result.hp_damage end self.mp -= @result.mp_damage user.hp += @result.hp_drain user.mp += @result.mp_drain $game_switches[1] = false end'Value' can be anything, and lethality can be at any percentage, and can also be influenced by stats.
For my example, this skill has a 50% chance to deal non-lethal damage.