The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: hiromu656 on February 07, 2011, 04:36:04 AM

Title: Item Hit Ratio
Post by: hiromu656 on February 07, 2011, 04:36:04 AM
Simply, I'd like to see a way of having Items have a chance of failure. Letting me affect the hit ratio like done with spells. I don't plan to implement it to all of my items, just to the reviving scroll in my game (Antenecros).
Title: Re: Item Hit Ratio
Post by: pacdiggity on February 07, 2011, 06:46:47 AM
That seems quite bastardly to do to your players. Anyway, I'm quite positive that MA will post here and tell you that he's already made a script with 17 more features that does exactly that. The question is when.
Title: Re: Item Hit Ratio
Post by: TDS on February 07, 2011, 07:10:30 AM
This should do it.


#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass of the Game_Actor
# and Game_Enemy classes.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias tds_item_hit_rate_game_battler_calc_hit                      calc_hit 
  #--------------------------------------------------------------------------
  # * Calculation of Final Hit Ratio
  #     user : Attacker, or user of skill or item
  #     obj  : Skill or item (for normal attacks, this is nil)
  #--------------------------------------------------------------------------
  def calc_hit(user, obj = nil)
    # If Object is an Item
    if obj.is_a?(RPG::Item)     
      # Return Object Hit Ratio
      return obj.hit_ratio
    end   
    # Run Original Method   
    tds_item_hit_rate_game_battler_calc_hit(user, obj = nil)
  end 
end

#============================================================================
# ** RPG::Item
#----------------------------------------------------------------------------
# This module handles item information.
#============================================================================ 
module RPG
  class Item < UsableItem
  #--------------------------------------------------------------------------
  # * Get Item Hit Ratio
  #--------------------------------------------------------------------------
  def hit_ratio
    # Check for Hit Ratio
    self.note[/HIT_RATE: ([-0-9]+)/i]
    # Return hit ratio
    return $1 == nil ? 100 : $1.to_i
    end
  end
end


To use it simply add this into the item note box:


HIT_RATE: #


# = The Hit rate you want for the item.

The script will assume 100% hit rate if this is not in the note box.

Let me know if this works out for you and if you need anything added to it.

Have a nice day.


Quote from: Welfare-Daddy Pacman on February 07, 2011, 06:46:47 AM
That seems quite bastardly to do to your players. Anyway, I'm quite positive that MA will post here and tell you that he's already made a script with 17 more features that does exactly that. The question is when.


How exactly does this help the person asking for help?

Title: Re: Item Hit Ratio
Post by: pacdiggity on February 07, 2011, 07:24:29 AM
Did you whip that up in that window of time?
God you're amazing.
As for my post, it was reassuring positivity.
I just like talking to people ;9
Title: Re: Item Hit Ratio
Post by: hiromu656 on February 07, 2011, 01:11:49 PM
Wow, TDS, it worked perfectly, thanks for the swiftness. And to Pacman, in my game's Lore you could call it, the spell, Raise Dead is sort of a sin, using an item called Antenecros is the alternative to it but has a chance of failure, but Raise Dead has no chance of failure but is hard on the cleric to cast, for instance when a cleric casts Raise Dead they would suffer "Weakened Soul" a state that damages Spirit until cured or it passes.
Title: Re: Item Hit Ratio
Post by: pacdiggity on February 08, 2011, 09:39:54 AM
Fair enough. That's actually an incredibly good explanation. I think I read that somewhere in GoV anyway. Would be quite silly if your skills didn't make sense in your lore.