Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- #-------------------------------------------------------------------------------
- - Hit Modifiers v1.0
- - Made by: Sixth
- #-------------------------------------------------------------------------------
- - Description:
- #-------------------------------------------------------------------------------
- This script will let you setup hit modifiers for all of your database objects.
- Basically, you can have different hit rates on different targets based on what
- "hit type" that target has.
- #-------------------------------------------------------------------------------
- - Note-Tags:
- #-------------------------------------------------------------------------------
- To setup a hit type for your actors and enemies, use this note-tag:
- <hit_type: type>
- Just replace the type after the : sign to whatever you want. That will be the
- hit type of the actor/enemy.
- Examples:
- <hit_type: short_range>
- <hit_type: flying>
- <hit_type: melee>
- #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- To setup hit modifiers for your actors, classes, enemies, equipment, states,
- skills and items, use this note-tag:
- <hit_mod: type, value>
- The type can be any type you used with the <hit_type: type> note-tag.
- Well, you can basically use anything for it, but the effect will only trigger
- if the user targets someone with the same type, so it would be useless if you
- have no actor/enemy tagged with the same type.
- The value must be a float number from 0.0 to infinity.
- 0.1 means 10%, 0.25 means 25%, 1.0 means 100%, and so on.
- These note-tags are additive, and can be gained from all the sources I listed
- above (actros, classes, equipment, etc).
- The skill and item note-tags will only be added if the used skill/item has
- the note-tag, while the rest of them will always be active, regardless of which
- skill/item is used.
- You can use multiple of these note-tags on the same object to setup values for
- multiple hit mods.
- Examples:
- <hit_mod: melee, 0.33>
- <hit_mod: long_range, -0.85>
- <hit_mod: mid_range, 0.55>
- #-------------------------------------------------------------------------------
- - Installation:
- #-------------------------------------------------------------------------------
- Place this script between Materials and Main.
- #-------------------------------------------------------------------------------
- =end
- # Settings:
- module HE_Mods
- # Default hit value for actors and enemies.
- # This values will only be used when attacking a target with the note-tag
- # <hit_type: x>. If the target is not tagged with that note-tag, the default
- # database values will be used (default hit rate calculation).
- # Also, the script will only redirect the hit calculation for physical
- # attacks, magical attacks will use the default database values only!
- DefHIT = 0.25 # 25% hit rate
- end
- # End of settings!
- #-------------------------------------------------------------------------------
- class RPG::BaseItem
- attr_accessor :hit_type, :hit_mod
- def hit_type
- init_hit_type if @hit_type.nil?
- return @hit_type
- end
- def init_hit_type
- @hit_type = @note =~ /<hit_type:\s*(.*)>/i ? $1 : ""
- end
- def hit_mod
- init_hit_mod if @hit_mod.nil?
- return @hit_mod
- end
- def init_hit_mod
- @hit_mod = {}
- cnote = @note.clone
- while cnote =~ /<hit_mod:(?:\s*)(.*)(?:\s*),(?:\s*)(.*)>/i
- @hit_mod[$1] = $2.to_f
- cnote.sub!(/<hit_mod:(?:\s*)(.*)(?:\s*),(?:\s*)(.*)>/i,"")
- end
- end
- end
- class Game_Battler < Game_BattlerBase
- def hit_mod(type)
- val = HE_Mods::DefHIT
- feature_objects.each do |ft|
- val += ft.hit_mod[type] || 0
- end
- return val
- end
- def item_hit(user, item)
- rate = item.success_rate * 0.01 # Get success rate
- if item.physical? # Physical attack: Multiply hit rate
- htp = self.is_a?(Game_Actor) ? actor.hit_type : enemy.hit_type
- if htp == ""
- mul = user.hit
- else
- mul = user.hit_mod(htp)
- mul += item.hit_mod[htp] || 0.0
- end
- rate *= mul
- end
- return rate # Return calculated hit rate
- end
- end
- # End of script!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement