Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Item Hit Ratio, Add a hit ratio attribute to a consumable item
BigEd781
post Dec 7 2008, 07:36 PM
Post #1


No method: 'stupid_title' found for `nil:NilClass'
Group Icon

Group: Revolutionary
Posts: 1,829
Type: Scripter
RM Skill: Undisclosed




Item Hit Ratio Addition
By BigEd781


I did this as a request, so I thought i would share. This script allows you to give consumable items like potions and scrolls a hit ratio attribute. For example, you could create an item that revives a character, but is only effective 50% of the time.

Configuration / Use

To give an item a hit ratio, you will add a line to the "Notes" field of that item. It should look like this:

CODE
[hit ratio]50


Spaces and case are ignored. The "[hit ratio]" tag tells the script that this item has a specified hit ratio value, and "50" is the value. A value of 50 would mean that the item is successful 50% of the time. 25 would mean it was successful 25% of the time, 100 would mean 100% (which is the default) and so on. Here is an image:



Script
CODE
module RPG
  
  class Item
    
    def get_consumable_hit_ratio
      ratio = 100
      self.note.each { |line|
        line.downcase!        
        line.gsub!(' ', '')          
        ratio = line.gsub("[hitratio]", '') if line.include?("[hitratio]") }              
      return ratio.to_i
    end
    
  end
  
end

class Game_Battler
  
  #--------------------------------------------------------------------------
  # * Apply Item Effects
  #     user : Item user
  #     item : item
  #--------------------------------------------------------------------------
  alias :eds_old_pre_hit_ratio_item_effect :item_effect
  def item_effect(user, item)  
    if item_effective?(user, item) && item.is_a?(RPG::Item)
      clear_action_results
      ratio = item.get_consumable_hit_ratio    
      if rand(100) >= ratio
        @missed = true
        return
      end
    end
    eds_old_pre_hit_ratio_item_effect(user, item)
  end
  
end


Compatibility / Issues
Should be fine as far as compatibility is concerned, let me know of any bugs.


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
lahandi
post Dec 10 2008, 11:26 PM
Post #2


Level 8
Group Icon

Group: Revolutionary
Posts: 111
Type: Artist
RM Skill: Skilled





Not sure to applied the hit ratio on medical items, but it will be very usefull for throwable items. Nice script Ed!

PS : I just think about, maybe you could create somekind script for throwable items. I mean, only certain characters that could access/use that item on battle. Something like Shadow (FF6) and Amarant (FF9) throw skill. Just an idea... hehe...



__________________________
Go to the top of the page
 
+Quote Post
   
originalwij
post Dec 11 2008, 02:05 PM
Post #3


... 42 ...
Group Icon

Group: Revolutionary
Posts: 214
Type: Scripter
RM Skill: Masterful




Great little scriptlet!! Definately going to use this ... keep up the good work!


__________________________




Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 25th May 2013 - 09:52 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker