I want to create new types of damages...such as power critical or breaking critical...
however why does it not pass the damage?
Here's my code:
def breaking_hit(damage) damage + NewDamage:😀AMAGES[rand(DAMAGES.size)] end alias power_hit_new make_damage_value def make_damage_value(user, item) power_hit_new (user, item) value = breaking_hit(value) end an error that says
undefined method + for Nil:NilClass appears. What is supposed to be the problem? I based it from the other ones like apply_critical but it doesn't seem to work. any ideas?
Do the followings and report me the result:
Try both of these:
first:
def breaking_hit(damage) NewDamage:😀AMAGES[rand(DAMAGES.size)]endsecond:
def breaking_hit(damage) damageendTell me what happens.
If there's no error, say so, if there's error specify the error by posting the what kind of error, and if line is specified, post the line.
It seems to be working, there's no error going up and the thing I want shows up.
So when you separate the operands, no error occurred, but when you try to add them together, the error occurred?
It seems the error occurs when I place them in one method, so to speak. Another error occurs is that its repeated throughout the entire battle.
Here's my point:
class Game_Battler < Game_BattlerBase attr_accessor 😛ower_critical_strike def check_if_power_critical power_critical = PCritical:😛OWER_CHANCE[rand(PCritical:😛OWER_CHANCE.size)] if power_critical >= 70 @power_critical_strike = true p "Breaking Hit" end end def apply_pcritical(damage) PCritical:😛OWER[rand(PCritical:😛OWER.size)] end def apply_pcritical(damage) damage end alias make_damage_pcritical make_damage_value def make_damage_value(user, item) make_damage_pcritical(user, item) #Call Original Method value = apply_pcritical(value) if @power_critical_strike end alias item_apply_p_critical item_apply_p_critical def item_apply(user, item) item_apply_p_critical(user, item) check_if_power_critical end endIt does check if there's a power critical or not in the actor and enemy's damage, however, I wonder why it goes automatically or what I meant is that when my actor gets a power critical, automatically the enemies gets power critical too, and that being said also everytime. It does not go to the checking method and re-randomize the value of chance.
In ruby, the one lower overrides the one higher.
If you put both at the same time
def apply_pcritical(damage) PCritical:😛OWER[rand(PCritical:😛OWER.size)]end def apply_pcritical(damage) damageend the lower will override the above, changing the return value to damage. What I asked you is to run the script 2 times, each with different return variable, not mixed them up.
Try reading the variable value
def check_if_power_critical power_critical = PCritical:😛OWER_CHANCE[rand(PCritical:😛OWER_CHANCE.size)] p "pcritical = ", power_critical, "pchance = ", PCritical:😛OWER_CHANCE, "pchanceSize = ", PCritical:😛OWER_CHANCE.size if power_critical >= 70 @power_critical_strike = true p "Breaking Hit" endendDoes it give what you expect?
Yes it does, thank you very much 🙂
I'll keep that in mind! 🙂