#================================================= =============================
# Skill Steal
#by Atoa
#================================================= =============================
#
# go to the skills extensions and add the extension "STEAL" to it
#
# to add items to the enemies, go to the module Atoa and look for
# Enemy_Steal[ID] = {"ITEM" => RATE}
#
# ID = enemy ID
# ITEM = Item type and ID
# it always must be an string, with an letter and a number, like this "xY"
# where "x" is the item type, and Y the item ID.
# x must be "a" for armors, "w" for weapons, "i" for itens, "g" for gold
# RATA = % de of getting the item, an value from 1 to 100, can be one case decimals
# e.g.: 5.4 = 5,4% rate
#
# EG.: Enemy_Steal[15] = {"w6" => 22.5, "g900" => 12}
# That means that Enemy ID 15 (Enemy_Drops[15])
# has 22,5% of giving the weapon ID 6 ("w6" => 22.5)
# and 12% of giving 900 golds ("g900" => 12)
#
# Remember that you can olny steal one "item" per attempt
#
#================================================= =============================
module Atoa
Enemy_Steal = [] # dont mess with this line
# You can steal the same enemy more than one time?
Multi_Steal = false
# If false, the each enemy can be stolen only once per battle, even if they
# they have more items (like the olds FFs)
# Base Rate
Steal_Rate = 50
# Note: even if it is 100%, that don't means you aways will get an item, since
# it's needed to check each item rate.
# Message if target dont have items
No_Item = "Nothing to stel"
# Message if steal attempt fails
Steal_Fail = "Steal attepmt failed"
# Successe of item steal. {item} represents the item name
# Must aways be added to teh get item messagem, or the name won't be shwon
Steal_Item = "Stole {item}"
# E.g.:
# "Stole {item}" - Stole Potion
# "{item} get" - Potion get
# Successe of gold steal. {gold} represents the amount gained
# Must aways be added to teh get money messagem, or the value won't be shwon
# {unit} is the game currency, it's opitional.
Steal_Gold = "Stole {gold}{unit}"
# E.g:
# "Stole {gold}{unit}" - Stole 500G
# "Stole {gold} coins" - "Stole 500 coins"
# Add the list of items to steal
Enemy_Steal[1] = {"g100" => 50, "w1" => 50, "a1" => 15}
Enemy_Steal[2] = {"i3" => 22.5, "w2" => 5}
# You can add as many you want
end
#================================================= =============================
# RPG::Skill
#================================================= =============================
class RPG::Skill
alias atoa_steal_extension extension
def extension
case @id
when 84 # i'm using skill "Throw Weapon" as an example
return ["STEAL"]
# Add here the IDs of the skills with the stal extension
end
atoa_steal_extension
end
end
#================================================= =============================
# Game_Enemy
#================================================= =============================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
include Atoa
#--------------------------------------------------------------------------
attr_accessor :steal_items
attr_accessor :steal_flag
attr_accessor :stole_item
attr_accessor :steal_attempt
#--------------------------------------------------------------------------
alias initialize_atoa_steal_enemy initialize
#--------------------------------------------------------------------------
def initialize(troop_id, member_index)
initialize_atoa_steal_enemy(troop_id, member_index)
@steal_items = Enemy_Steal[@enemy_id].to_a
@stole_item = nil
@steal_flag = false
@steal_attempt = 0
end
end
#================================================= =============================
# Game_Battler
#================================================= =============================
class Game_Battler
#--------------------------------------------------------------------------
include Atoa
#--------------------------------------------------------------------------
def stole_item_set(user)
@steal_flag = true
steal_success = rand(100) < (Steal_Rate + self.steal_attempt) * user.agi / self.agi
self.steal_attempt += 1
return false unless steal_success
return nil if self.steal_items == nil or self.steal_items == []
item_stole = []
self.steal_items.each do |item, steal_rate|
item = item.split('')
if item[0] == "i"
item = item.join
item.slice!("i")
item_stole.push($data_items[item.to_i]) if rand(1000) < (steal_rate * 10).to_i
elsif item[0] == "a"
item = item.join
item.slice!("a")
item_stole.push($data_armors[item.to_i]) if rand(1000) < (steal_rate * 10).to_i
elsif item[0] == "w"
item = item.join
item.slice!("w")
item_stole.push($data_weapons[item.to_i]) if rand(1000) < (steal_rate * 10).to_i
elsif item[0] == "g"
item = item.join
item.slice!("g")
item_stole.push(item.to_i) if rand(1000) < (steal_rate * 10).to_i
end
end
return false if item_stole == []
self.steal_attempt = 0
stole_item_index = rand(item_stole.size)
item_to_steal = [item_stole[stole_item_index]]
self.steal_items.delete_at(stole_item_index) if Multi_Steal
self.steal_items = [] unless Multi_Steal
return item_to_steal
end
end
#================================================= =============================
# Scene_Battle
#================================================= =============================
class Scene_Battle
#--------------------------------------------------------------------------
include Atoa
#--------------------------------------------------------------------------
def pop_steal_help(obj)
@help_window.set_text(obj, 1)
count = 0
loop do
update_basic
count += 1
break @help_window.visible = false if (Input.trigger?(Input::C) and count > 30) or count == 80
end
end
#--------------------------------------------------------------------------
alias atoa_steal_action_end action_end
def action_end
if @active_battler.action.kind == 1
obj = $data_skills[@active_battler.action.skill_id]
if obj.extension.include?("STEAL")
@targets.each do |battler|
stole_item = battler.stole_item_set(@active_battler) and battler.is_a?(Game_Enemy)
if battler.is_a?(Game_Enemy) && battler.steal_flag
item_stole = stole_item[0] unless stole_item == false or stole_item == nil
item_stole = nil if stole_item == nil
item_stole = false if stole_item == false or battler.missed or battler.evaded
case item_stole
when nil
text = No_Item
when false
text = Steal_Fail
when Numeric
$game_party.gain_gold(item_stole)
text = Steal_Gold.dup
text.gsub!(/{gold}/i) {"#{item_stole}"}
text.gsub!(/{unit}/i) {"#{$data_system.terms.gold}"}
else
$game_party.gain_item(item_stole, 1)
text = Steal_Item.dup
text.gsub!(/{item}/i) {"#{item_stole.name}"}
end
pop_steal_help(text)
battler.steal_flag = false
wait(3)
end
end
end
end
atoa_steal_action_end
end
end