Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #======================#
- # Z-Systems by: Zetu #
- #===========================#======================#===========================#
- # * * * Z05 Steal Command v1.03 * * * #
- #=#==========================================================================#=#
- # Add regular expression STEAL_SKILL to any skill to allow the player to #
- # steal from the target(s) of the skill. To add stealable items to an #
- # enemy, add as many regular expressions STEAL_OBJ to the enemy. #
- #--------------------------------------------------------------------------#
- # Requires CORE script.
- #==========================================================================#
- module Z05
- STEAL_SKILL = /<steal>/i
- STEAL_OBJ = /<steal[:]*\s*(WEAPON|ITEM|ARMOR|GOLD)\s*(\d+)>/i
- NO_STEALS = "%s has nothing to steal."
- STEAL_GOLD = "Stole %s gold from %s."
- STEAL_ITEM = "Stole %s from %s."
- STEAL_FAIL = "Couldn't steal anything!"
- def self.get_steal_ratio(user, target)
- base = 0.85 # Chance to steal if user.agi == target.agi
- # Do NOT set base to 1.0 or 0.0.
- return user.agi/(user.agi+(1/base -1)*target.agi)
- end
- #========#======================#====#================================#========#
- #--------# #----# DO NOT EDIT PAST THIS POINT!!! #--------#
- #--------# End of Customization #----# Editing will cause death by #--------#
- #--------# #----# brain asplosions. #--------#
- #========#======================#====#================================#========#
- end
- ($imported||={})[:z05]=true
- class RPG::UsableItem < RPG::BaseItem
- #--------------------------------------------------------------------------
- # * New method: steal?
- #--------------------------------------------------------------------------
- def steal?
- self.note.scan(Z05::STEAL_SKILL){return true}
- return false
- end
- end
- class Game_Enemy < Game_Battler
- attr_reader :last_stolen_item, :steal_data
- #--------------------------------------------------------------------------
- # * Alias method: initialize
- #--------------------------------------------------------------------------
- alias :z05_initialize :initialize
- def initialize(index, enemy_id)
- z05_initialize(index, enemy_id)
- create_steal_list
- end
- #--------------------------------------------------------------------------
- # * New method: create_steal_list
- #--------------------------------------------------------------------------
- def create_steal_list
- @steal_data = []
- self.enemy.note.scan(Z05::STEAL_OBJ){|type, id|
- case type
- when /item/i
- @steal_data.push($data_items[id.to_i])
- when /weapon/i
- @steal_data.push($data_weapons[id.to_i])
- when /armor/i
- @steal_data.push($data_armors[id.to_i])
- when /gold/i
- @steal_data.push(id.to_i)
- end}
- end
- #--------------------------------------------------------------------------
- # * Super method: item_apply
- #--------------------------------------------------------------------------
- def item_apply(user, item)
- super(user, item)
- @result.steal = nil
- steal_apply(user, item) if item.steal?
- end
- def steal_apply(user, item)
- ratio = Z05::get_steal_ratio(user, self)
- if @result.missed||@result.evaded
- @result.steal = :miss
- elsif rand < ratio
- @result.steal = add_item_steal_effect ? :success : :nosteal
- else
- @result.steal = :fail
- end
- end
- #--------------------------------------------------------------------------
- # * New method: add_item_steal_effect
- #--------------------------------------------------------------------------
- def add_item_steal_effect
- return false if @steal_data.size==0
- @stolenitem = @last_stolen_item = @steal_data.random!
- return false if @stolenitem.nil?
- if @stolenitem.is_a?(Integer)
- $game_party.gain_gold(@stolenitem)
- else
- $game_party.gain_item(@stolenitem, 1)
- end
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: reset_steal_item
- #--------------------------------------------------------------------------
- def reset_steal_item
- @last_stolen_item=nil
- @result.steal = nil
- end
- end
- class Game_ActionResult
- attr_accessor :steal
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement