Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Steal Command script?

Okay...I need the steal command script

Detailed Description:
I need it to work with the VX battle sideview system,if you have played Final Fantasy you'll understand what I mean,you just basically go upto your enemy and steal something,can someone help me with this?
 
Try being a little more specific than this. When do you get the command? Is it a skill, an action, or something else? How does it work? How are the chances of success determined? How many items can you steal? Please describe the system in detail, because not everyone has played final fantasy, and you can't get the mechanics out of a youtube video. Also, the more specific you are, (and the nicer you are), the more likely it is that someone will fill your request.
 

Atoa

Member

Code:
#================================================= =============================

# 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

It's an skill, not an command.
 
@Glitchfinder:
Well I figured atleast alot of people have played some of the Final Fantasy games,so next time I'll ask for something,I'll make it more specific and thank you for the tips.

@Atoa:
Thank you for the script,I really appreciate it.

@Dargor:
Same to you although as you're still working on it.

I'll give credit...

Edit:
I'm not much about errors but the script by Atoa,It keeps getting an error message what's basically this:
Screenshoterror.png
 

Atoa

Member

lol '-'
Line 2 is this: # Skill Steal
So it's impossible to have errors, unless you copied it wrong.
Re copy the script, remeber you have to turn off the line numbers in the post.
 

Atoa

Member

@obsorber
the script just add the "steal" effect to an skill.
And don't mess with the skill anim.

So the problem is with the skill movement config, not with the steal script.
 
Nice simple add-on I must say :)

One thing,
I have Multi_Steal = false, so all attempts after the 1st say "Nothing to Steal".
However, I'm hoping to have the Steal command disabled after one attempt, so it can't even be selected.
Though I'm figuring this would have to be done with a whole diff script. Am I right/wrong?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top