12 de setembro de 2012 15:43:29 ART
1º Instale o Script SDK
2º Crie um novo atributo no sistema, com o nome de Steal, na linha 20.
3º Crie uma nova classe no editor de RGSS e Cole o script abaixo:
Citação:
#=============================================================================
# ■ Steal Effect
#=============================================================================
# Trickster
# Version 3 Final
# 20.12.05
#=============================================================================
# fixes in this version
# cleaned code
# SDK compliant
# changed a few things
# you may now use states/elements in the skill
# corrected a mistake in the damage formula (a simple sign mistake)
# corrected another mistake in the damage formula (in the exp damage it used the skills INT-F)
#
# the skill effects
# accurary influences the chance of success
# the agi(33%), dex(20%), and int(50%)
#
# magic defense (theft defense) is steal defensiveness
# the dexerity and intelligence of the battler
# and the agility and intelligence of the enemy influences chance
#
# effect rating determines the item you get or the gold you get
# variance tells variance, unless you are using INT-F = 2 then It determines
# the type of item: 1 for weapon 2 for armor 3 for item
# the evasion then determines the number you get the power determines the id
#
# Third argument INT-F
# INT-F = 1 steals gold according to skill power
# INT-F = 2 steals an item the item id is the power (don't use with enemies)
# INT-F = 3 steals gold according to the enemies drop gold
# INT-F = 4 steals an item the item is the enemies drop item
# INT-F = 5 steals a skill(random)
# INT-F = 6 steals the enemies highest rated skill (don't use with enemies)
# INT-F = 7 steals exp enemies exp
# INT-F = 8 steals exp skill power
#=============================================================================
#--------------------------------------------------------------------------
# * Begin SDK Log
#--------------------------------------------------------------------------
SDK.log("Steal", "Trickster", 3, "20.12.05")
#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.state("Steal") == true
#===================================================
# ▼ CLASS Game_Enemy Begins
#===================================================
class Game_Enemy
attr_accessor :second_item_ids #the enemies second stealable item
attr_accessor :rare_item_ids #the enemies rare item
alias trickster_enemy_initialize initialize
def initialize(troop_id, member_index)
trickster_enemy_initialize(troop_id, member_index)
@second_item_ids = get_item_ids
@rare_item_ids = get_rare_ids
end
def get_item_ids
if self.is_a?(Game_Enemy)
case self.id
when 1
return [1,1,33] #[item_id, item_type, chance]
when 2
return [2,1,30]
when 3
return [3,3,10]
end
end
end
def get_rare_ids
if self.is_a?(Game_Enemy)
case self.id
when 1
return [3,1,33] #[item_id, item_type, chance]
when 3
return [4,3,10]
else
return
end
end
end
end
#===================================================
# ▲ CLASS Game_Enemy Ends
#===================================================
#===================================================
# ▼ CLASS Game_Actor Begins
#===================================================
class Game_Actor
attr_accessor :skills_lost #skill ids that were stolen
attr_accessor :skills_gained #skill ids that were gained
alias trickster_actor_initialize initialize
def initialize(actor_id)
@skills_lost = []
@skills_gained = []
trickster_actor_initialize(actor_id)
end
end
#===================================================
# ▲ CLASS Game_Actor Ends
#===================================================
#===================================================
# ▼ CLASS Game_Battler Begins
#===================================================
class Game_Battler
DEXERITY_INFLUENCE = 100
INTELLIGENCE_INFLUENCE = 100
AGILITY_INFLUENCE = 67
SKILL_DEFENSE_INT = 100
SKILL_DEFENSE_DEX = 200
SKILL_DEFENSE_AGI = 133
FAILED_MESSAGE = 'Failed'
NO_SKILLS_MESSAGE = 'No Skills'
STEAL_GOLD_SKILL_POWER = 1
STEAL_ITEM_DEFINED_SKILL = 2
STEAL_GOLD_ENEMY_GOLD = 3
STEAL_ITEM_ENEMY_ITEM = 4
STEAL_SKILL = 5
STEAL_OVERUSED_SKILL = 6
STEAL_EXP_ENEMY_EXP = 7
STEAL_EXP_DEFINED_SKILL = 8
MAX_RATING = 10
STEALING_ELEMENT_ID = 20
#--------------------------------------------------------------------------
attr_accessor :stolen_gold #true if stolen gold from enemy
attr_accessor :stolen_item #true if stolen item from enemy
attr_accessor :stolen_skill #true if stolen skill from enemy
attr_accessor :stolen_exp #true if stolen exp from enemy
attr_accessor :stolen_rare #true if stolen rare item from enemy
attr_accessor :gold_holding #= gold stolen if enemy stole from player
attr_accessor :item_holding #= item id if enemy stole item from player
attr_accessor :unstealable #items that aren't able to be stolen
#---------------------------------------------------------------------------
alias trickster_steal_initialize initialize
def initialize
trickster_steal_initialize
@stolen_gold = false
@stolen_item = false
@stolen_skill = false
@stolen_exp = false
@stolen_rare = false
@gold_holding = 0
@item_holding = []
item_ids = []
weapon_ids = []
armor_ids = []
@unstealable = [item_ids,weapon_ids,armor_ids]
end
#--------------------------------------------------------------------------
def steal_effect(attacker, skill, steal)
#reset flags
self.damage = 0
self.critical = false
#call get_chance to get hit result
hit_result = get_chance(attacker, skill)
if hit_result == true
#Determine what are we stealing
case steal
when STEAL_GOLD_SKILL_POWER
unless self.stolen_gold
self.stolen_gold = true
power = skill.power
power += attacker.dex * skill.dex_f / DEXERITY_INFLUENCE
power += attacker.int / self.int * INTELLIGENCE_INFLUENCE
power += attacker.agi * skill.agi_f / AGILITY_INFLUENCE
if power > 0
power -= self.int * skill.mdef_f / SKILL_DEFENSE_INT
power -= self.dex * skill.mdef_f / SKILL_DEFENSE_DEX
power -= self.agi * skill.mdef_f / SKILL_DEFENSE_AGI
power = [power, 0].max
end
self.damage = power * elements_correct(skill.element_set)
self.damage /= 100
if skill.variance > 0 and self.damage.abs > 0
amp = [self.damage.abs * skill.variance / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
if self.gold_holding != 0
self.damage = self.gold_holding
self.gold_holding = 0
end
if self.is_a?(Game_Actor)
$game_party.lose_gold(self.damage)
attacker.gold_holding += self.damage
else
$game_party.gain_gold(self.damage)
end
attacker.stolen_gold = false
self.damage = self.damage.to_s + ' ' + $data_system.words.gold
states_plus(skill.plus_state_set)
states_minus(skill.minus_state_set)
else
self.damage = FAILED_MESSAGE
end
when STEAL_ITEM_DEFINED_SKILL
if attacker.is_a?(Game_Actor)
unless self.stolen_item
self.stolen_item = true
number = skill.eva_f.to_s
case skill.variance
when 1
$game_party.gain_weapon(skill.power, skill.eva_f)
self.damage = number + ' ' +$data_weapons[skill.power].name
when 2
$game_party.gain_armor(skill.power, skill.eva_f)
self.damage = number + ' ' +$data_armors[skill.power].name
when 3
$game_party.gain_item(skill.power, skill.eva_f)
self.damage = number + ' ' +$data_items[skill.power].name
end
attacker.stolen_item = false
states_plus(skill.plus_state_set)
states_minus(skill.minus_state_set)
else
self.damage = FAILED_MESSAGE
end
end
when STEAL_GOLD_ENEMY_GOLD
unless self.stolen_gold
self.stolen_gold = true
self.is_a?(Game_Enemy) ? power = self.gold : power = skill.power
power += attacker.dex * skill.dex_f / DEXERITY_INFLUENCE
power += attacker.int / self.int * INTELLIGENCE_INFLUENCE
power += attacker.agi * skill.agi_f / AGILITY_INFLUENCE
if power > 0
power -= self.int * skill.mdef_f / SKILL_DEFENSE_INT
power -= self.dex * skill.mdef_f / SKILL_DEFENSE_DEX
power -= self.agi * skill.mdef_f / SKILL_DEFENSE_AGI
power = [power, 0].max
end
self.damage = power * elements_correct(skill.element_set)
self.damage /= 100
if skill.variance > 0 and self.damage.abs > 0
amp = [self.damage.abs * skill.variance / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
if self.gold_holding != 0
self.damage = self.gold_holding
self.gold_holding = 0
end
if self.is_a?(Game_Actor)
$game_party.lose_gold(self.damage)
attacker.gold_holding += self.damage
else
$game_party.gain_gold(self.damage)
end
attacker.stolen_gold = false
self.damage = self.damage.to_s + ' ' + $data_system.words.gold
states_plus(skill.plus_state_set)
states_minus(skill.minus_state_set)
else
self.damage = FAILED_MESSAGE
end
when STEAL_ITEM_ENEMY_ITEM #steal item
unless self.stolen_item
self.stolen_item = true
if self.is_a?(Game_Enemy)
number = skill.eva_f.to_s
#Determine what type of item is stolen
if self.rare_item_ids != nil and self.rare_item_ids[2] > rand(100)
rare_id = self.rare_item_ids
case rare_id[1]
when 1
$game_party.gain_item(rare_id[0],skill.eva_f)
self.damage = number + ' ' +$data_items[rare_id[0]].name
when 2
$game_party.gain_weapon(rare_id[0],skill.eva_f)
self.damage = number + ' ' +$data_weapons[rare_id[0]].name
when 3
$game_party.gain_armor(rare_id[0],skill.eva_f)
self.damage = number + ' ' +$data_armors[rare_id[0]].name
end
elsif self.second_item_ids != nil and
self.second_item_ids[2] > rand(100)
sec_id = self.second_item_ids
case sec_id[1]
when 1
$game_party.gain_item(sec_id[0],skill.eva_f)
self.damage = number + ' ' +$data_items[sec_id[0]].name
when 2
$game_party.gain_weapon(sec_id[0],skill.eva_f)
self.damage = number + ' ' +$data_weapons[sec_id[0]].name
when 3
$game_party.gain_armor(sec_id[0],skill.eva_f)
self.damage = number + ' ' +$data_armors[sec_id[0]].name
end
elsif steal_normal_chance
if self.weapon_id != 0
$game_party.gain_weapon(self.weapon_id, skill.eva_f)
self.damage = number + ' ' +$data_weapons[self.weapon_id].name
elsif self.armor_id != 0
$game_party.gain_armor(self.armor_id, skill.eva_f)
self.damage = number + ' ' +$data_armors[self.armor_id].name
elsif self.item_id != 0
$game_party.gain_item(self.item_id, skill.eva_f)
self.damage = number + ' ' +$data_items[self.item_id].name
end
elsif self.item_holding != []
item = self.item_holding
case item[1]
when 1
$game_party.gain_item(item[0],1)
self.damage = number + ' ' +$data_items[item[0]].name
when 2
$game_party.gain_weapon(item[0],skill.eva_f)
self.damage = number + ' ' +$data_weapons[item[0]].name
when 3
$game_party.gain_armor(item[0],skill.eva_f)
self.damage = number + ' ' +$data_armors[item[0]].name
end
self.item_holding = []
else
self.damage = FAILED_MESSAGE
return
end
states_plus(skill.plus_state_set)
states_minus(skill.minus_state_set)
else
#enemy attempt to steal item
#determine item type
what_to_steal = rand(3)
data = []
#run through all avialable items
case what_to_steal
when 1
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
data.push($data_items)
end
end
when 2
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
data.push($data_weapons)
end
end
when 3
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
data.push($data_armors)
end
end
end
if data.size == 0
self.damage = FAILED_MESSAGE
return
end
#get a random item from list
stolen_id = rand(data.size - 1)
flag = false
#if the item is unstealable it fails
for i in 0...@unstealable[what_to_steal].size
if @unstealable[what_to_steal] = data[stolen_id].id
flag = true
end
end
#check if the item is equippable and if it is currently equipped
if what_to_steal > 1
for actor in $game_party.actors
if what_to_steal == 2
if actor.weapon_id == data[stolen_id].id
flag = true
end
else
if (actor.armor1_id == data[stolen_id].id or
actor.armor2_id == data[stolen_id].id or
actor.armor3_id == data[stolen_id].id or
actor.armor4_id == data[stolen_id].id)
flag = true
end
end
end
end
#if the item was equipped steal fails
if data.size == 1 and flag
self.damage = FAILED_MESSAGE
return
end
#checking again
terminate = 0
while flag
terminate += 1
stolen_id = rand(data.size - 1)
flag = false
for i in 0...@unstealable[what_to_steal].size
if @unstealable[what_to_steal] = data[stolen_id].id
flag = true
end
end
if what_to_steal > 1
for actor in $game_party.actors
if what_to_steal == 2
if actor.weapon_id == data[stolen_id].id
flag = true
end
else
if (actor.armor1_id == data[stolen_id].id or
actor.armor2_id == data[stolen_id].id or
actor.armor3_id == data[stolen_id].id or
actor.armor4_id == data[stolen_id].id)
flag = true
end
end
end
end
if terminate == 10 * data.size
self.damage = FAILED_MESSAGE
return
end
end
#steal the item
item_id = data[stolen_id].id
case what_to_steal
when 1
$game_party.lose_item(item_id,1)
self.damage = $data_items[item_id].name + ' Stolen'
when 2
$game_party.lose_weapon(item_id,1)
self.damage = $data_weapons[item_id.id].name + ' Stolen'
when 3
$game_party.lose_armor(item_id,1)
self.damage = $data_armors[item_id].name + ' Stolen'
end
attacker.item_holding = [item_id, what_to_steal]
attacker.stolen_item = false
states_plus(skill.plus_state_set)
states_minus(skill.minus_state_set)
end
else
self.damage = FAILED_MESSAGE
end
when STEAL_SKILL
if self.is_a?(Game_Enemy)
unless self.stolen_skill
data = []
#run through the enemy actions
for actions in self.actions
data.push(actions.skill_id)
end
if data.size == 0
self.damage = NO_SKILLS_MESSAGE
return
end
#pick a random skill
random = rand(data.size)
#check if attacker already knows the skill or if already stolen
if not attacker.skills.include?(data[random])
if not attacker.skills_gained.include?(data[random])
attacker.skills_gained += [data[random]]
end
end
attacker.learn_skill(data[random])
index = nil
for i in 0...self.actions.size
if self.actions.skill_id == data[random]
index = i
end
end
#delete the skill from the enemy
self.actions.delete_at(index)
#give states before action remake
states_plus(skill.plus_state_set)
states_minus(skill.minus_state_set)
for enemy in $game_troop.enemies
if enemy.id == self.id
enemy.stolen_skill = true
#remake enemy action so that they don't use the skill stolen
enemy.make_action
end
end
self.damage = $data_skills[data[random]].name + ' Stolen'
else
self.damage = FAILED_MESSAGE
end
else
unless self.stolen_skill or self.skills.size == 0
random = rand(self.skills.size)
stolen = $data_skills[self.skills[random]]
#to prevent the chance of an enemy using a skill that won't work
if stolen.element_set.include?(STEALING_ELEMENT_ID)
if (stolen.int_f == STEAL_ITEM_DEFINED_SKILL or
stolen.int_f == STEAL_OVERUSED_SKILL)
self.damage = FAILED_MESSAGE
return
end
end
action = attacker.actions[0].dup
size = attacker.actions.size
attacker.actions.push(action)
attacker.actions.skill_id = self.skills[random]
#set the skill to a random rating
attacker.actions.rating = 1 + rand(MAX_RATING)
self.stolen_skill = true
self.damage = $data_skills[self.skills[random]].name + ' Stolen'
self.skills_lost += [self.skills[random]]
self.forget_skill(self.skills[random])
states_plus(skill.plus_state_set)
states_minus(skill.minus_state_set)
else
self.damage = FAILED_MESSAGE
end
end
when STEAL_OVERUSED_SKILL
if self.is_a?(Game_Enemy)
unless self.stolen_skill
data = []
for actions in self.actions
data.push(actions) if actions.skill_id != nil
end
if data.size == 0
self.damage = NO_SKILLS_MESSAGE
return
end
#sort the data by rating
data.sort! {|a,b| b.rating - a.rating }
if not attacker.skills.include?(data[0].skill_id)
if not attacker.skills_gained.include?(data[0].skill_id)
attacker.skills_gained += [data[0].skill_id]
end
end
attacker.learn_skill(data[0].skill_id)
#find the index
for i in 0...self.actions.size
if self.actions.skill_id == data[0].skill_id
index = i
end
end
self.actions.delete_at(index)
states_plus(skill.plus_state_set)
states_minus(skill.minus_state_set)
for enemy in $game_troop.enemies
if enemy.id == self.id
enemy.stolen_skill = true
enemy.make_action
end
end
self.damage = $data_skills[data[0].skill_id].name + ' Stolen'
else
self.damage = FAILED_MESSAGE
end
else
self.damage = FAILED_MESSAGE
end
when STEAL_EXP_ENEMY_EXP
unless self.stolen_exp
self.stolen_exp = true
self.is_a?(Game_Enemy) ? power = self.exp : power = skill.power
power += attacker.dex * skill.dex_f / DEXERITY_INFLUENCE
power += attacker.int / self.int * INTELLIGENCE_INFLUENCE
power += attacker.agi * skill.agi_f / AGILITY_INFLUENCE
if power > 0
power -= self.int * skill.mdef_f / SKILL_DEFENSE_INT
power -= self.dex * skill.mdef_f / SKILL_DEFENSE_DEX
power -= self.agi * skill.mdef_f / SKILL_DEFENSE_AGI
power = [power, 0].max
end
self.damage = power * elements_correct(skill.element_set)
self.damage /= 100
if skill.variance > 0 and self.damage.abs > 0
amp = [self.damage.abs * skill.variance / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
if self.is_a?(Game_Actor)
self.exp -= self.damage
else
attacker.exp += self.damage
end
attacker.stolen_exp = false
self.damage = self.damage.to_s + ' Exp'
states_plus(skill.plus_state_set)
states_minus(skill.minus_state_set)
else
self.damage = FAILED_MESSAGE
end
when STEAL_EXP_DEFINED_SKILL
unless self.stolen_exp
self.stolen_exp = true
power = skill.power
power += attacker.dex * skill.dex_f / DEXERITY_INFLUENCE
power += attacker.int / self.int * INTELLIGENCE_INFLUENCE
power += attacker.agi * skill.agi_f / AGILITY_INFLUENCE
if power > 0
power -= self.int * skill.mdef_f / SKILL_DEFENSE_INT
power -= self.dex * skill.mdef_f / SKILL_DEFENSE_DEX
power -= self.agi * skill.mdef_f / SKILL_DEFENSE_AGI
power = [power, 0].max
end
self.damage = power * elements_correct(skill.element_set)
self.damage /= 100
if skill.variance > 0 and self.damage.abs > 0
amp = [self.damage.abs * skill.variance / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
if self.is_a?(Game_Actor)
self.exp -= self.damage
else
attacker.exp += self.damage
end
attacker.stolen_exp = false
self.damage = self.damage.to_s + ' Exp'
states_plus(skill.plus_state_set)
states_minus(skill.minus_state_set)
else
self.damage = FAILED_MESSAGE
end
end
else
self.damage = FAILED_MESSAGE
end
return true
end
#--------------------------------------------------------------------------
def get_chance(attacker, skill)
int_inf = self.int / attacker.int
base_inf = self.agi / attacker.dex
hit_inf = (100 - skill.hit)
chance = rand(100) > (base_inf * int_inf * hit_inf)
return chance
end
#--------------------------------------------------------------------------
def steal_normal_chance
self.rare_item_ids == nil ? rare = 0 : rare = self.rare_item_ids[2]
self.second_item_ids == nil ? sec = 0 : sec = self.second_item_ids[2]
return (100 - (rare+sec) > rand(100))
end
end
#===================================================
# ▲ CLASS Game_Battler Ends
#===================================================
#===================================================
# ▼ CLASS Scene_Battle Begins
#===================================================
class Scene_Battle
STEALING_ELEMENT_ID = 21
alias trickster_main main
def main
for actor in $game_party.actors
actor.stolen_gold = false
actor.stolen_item = false
actor.stolen_skill = false
actor.stolen_exp = false
end
trickster_main
end
#--------------------------------------------------------------------------
def make_skill_action_result
@skill = $data_skills[@active_battler.current_action.skill_id]
unless @active_battler.current_action.forcing
unless @active_battler.skill_can_use?(@skill.id)
$game_temp.forcing_battler = nil
@phase4_step = 1
return
end
end
@active_battler.sp -= @skill.sp_cost
@status_window.refresh
@help_window.set_text(@skill.name, 1)
@animation1_id = @skill.animation1_id
@animation2_id = @skill.animation2_id
@common_event_id = @skill.common_event_id
set_target_battlers(@skill.scope)
if @skill.element_set.include?(STEALING_ELEMENT_ID)
for target in @target_battlers
target.steal_effect(@active_battler, @skill, @skill.int_f)
end
else
for target in @target_battlers
target.skill_effect(@active_battler, @skill)
end
end
end
#--------------------------------------------------------------------------
alias trickster_battle_end battle_end
def battle_end(result)
#learn and forget stolen/gained skills
for actor in $game_party.actors
if actor.skills_gained.size > 0
for skill in actor.skills_gained
actor.forget_skill(skill)
end
end
if actor.skills_lost.size > 0
for skill in actor.skills_lost
actor.learn_skill(skill)
end
end
end
trickster_battle_end(result)
end
end
#===================================================
# ▲ CLASS Scene_Battle Ends
#===================================================
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end