PickPocket script
Hi everyone, I thought about a mechanics I added some time ago to my game, a pickpocketing system, it was really ugly, lots of lines of setup for each event, so I decided to turn it into a script,I changed this
http://s22.postimg.org/ycym1y4wh/Before.jpg
into this:
http://s2.postimg.org/x5h6qpne1/After.jpg
I am pretty satisfied with the result, so I thought I'd share this
Description:
You simply have to put one line of script call in an event box (e.g Eaty_Steal(['g',0],32,100,@event_id,10,"How dare you!") ), and when the player will interact with that npc while pressing a default key
SHIFT), he'll try to steal what you set within the script call, if the player gets caught you can decide what the consequences will be.
The chances of success are determined by this formula (rand(attention_level) - $game_party.leader.agi ), which you can freely change (in that case also adjust the conditions check accordingly (value<0, value<a/2, value>=a/2)).
Here's the script:
Spoiler Code:
#=============================================================================#
#
#EatYourBeetS stealing script
#
# In any event put this in the first line:
# Eaty_Steal(['g',0],32,100,@event_id,10,"How dare you!")
#
# ['g', = item type: 'g'=gold, 'i'=item, 'a'=armor, 'w'=weapon
# 0], = item ID, not checked when you choose 'g'
#32 , = quantity of item or gold that will be stolen
#100, = attention level, used to determine the chances of stealing or
# getting caught, check the formula in Dinamic setup
#@event_id, used for the self switch, just pass it as @event_id
#10 , = ID of the switch to activate when caught, 0 if you don't need it
# (I use one switch per city)
#"How dare you!" = optional, determines what will the npc say if you
#) get caught, you can change the default below
#
#
#*Free to use anywhere
#*Credits: EatYourBeetS
#*If you find bugs or have an idea about how to improve this,
#please let me know!
#
#=============================================================================#
class Game_Interpreter
#--------------------------------------------------------------------------
# * Steal from NPCs
#--------------------------------------------------------------------------
def Eaty_Steal(i=['g',0],q=1,a=50,event_id,switch,line)
#=============================================================================
# Custom conditions
#
#Add other conditions here if you want, e.g, if you want to steal only when
#an item is equipped add:
#return unless $game_party.members_equip_include?($data_armors)
return unless Input.press?(:SHIFT) #Steal Button(to press with Z/space/enter)
return if $game_switches==true && switch!=0
#=============================================================================
if $game_self_switches[[$game_map.map_id,event_id,'D']]==false #SW check
#Dinamic setup
line.is_a?(String) ? line : (line=nil; line="Thief!") #-> default line
data_id = i #Don't change
#-----
a = rand(a) + a/5 #Stealing Formula
value = a - $game_party.leader.agi #Stealing Formula
#-----
#============================================================================
# Stealing successful
#=========================================================================
if value < 0
$game_message.background = 1
$game_message.add("\nYou stole something!")
$game_self_switches[] = true#SW ON
#$game_variables -= 3 #this is my 'karma' variable,
# if you have something similar just change the id
q_s=q.to_s+" " if q!=1
q_s="" if q==1
RPG::SE.new("Chime2", 100, 120).play#Success Sound
#----------------------------------------------------------------------
if i != 'g'
if i == 'w'
icon = $data_weapons.icon_index
name = $data_weapons.name
$game_party.gain_item($data_weapons, q)
elsif i == 'a'
icon = $data_armors.icon_index
name = $data_armors.name
$game_party.gain_item($data_armors, q)
elsif i == 'i'
icon = $data_items.icon_index
name = $data_items.name
$game_party.gain_item($data_items, q)
end
$game_message.background = 1
$game_message.add("#{q_s}#{name} \\i[#{icon}] Obtained!")
else
#----------------------------------------------------------------------
$game_party.gain_gold(q)
$game_message.background = 1
$game_message.add("#{q}\\i Obtained!")#361 is my gold icon index
end
#==========================================================================
# Stealing failed
#========================================================================
elsifvalue >= 0 && value < (a/2)
$game_message.background = 1
$game_message.add("\nStealing failed!")
elsifvalue >= a/2
$game_message.add("#{line}")
RPG::SE.new("Reflection", 100, 120).play #Failure Sound
$game_switches=true if switch != 0
end
#----------------------------------------------------------------------
else #If Self Switch is on
$game_message.background = 1
$game_message.add("\nYou already stole something")
end # Self switch check end
#----------------------------------------------------------------------
command_115 #Exit event processing
end # Method end
#==============================================================================
end # Game_Interpreter class end
#==============================================================================
This is my first script, please let me know about any improvement I can make, or any bugs or mistakes.
本贴来自国际rpgmaker官方论坛作者:EatYourBeetS处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/pickpocket-script.38805/
页:
[1]