After reading some tutorials, its time to practice, right? So i'm creating my first script, a pickpocketing system, but having some issues..
Here is the code:
CODE
### PickPocket by RamonBastos (first script) ###
module Vars #variables
attr_accessor :directionplayerfacing #The direction the player is looking to
attr_accessor :directionvictimfacing #Direction the Victim is looking to
attr_accessor :victimintel #Victim's Intel (The higher, the hardest to steal)
attr_accessor :randomconstant #just a random constant
attr_accessor :items_available_to_steal
attr_accessor :gold_available_to_steal
attr_accessor :chancetosteal #the equation
attr_accessor :pplevel #pickpocket skill level
attr_accessor :ppexp #pickpocket exp
end
#If you succeed to steal, this window will be shown
class Steal_Success < Window_Base
def initialize
super(220, 190, 128,150)
self.contents = Bitmap.new(width-32, height-32)
refresh
self.contents.font.name = "Arial"
self.contents.font.size = 24
end
def refresh
self.contents.clear
self.contents.draw_text(0, 0, 200, 32, "Stole "+@gold_available_to_steal.to_s+" gold") #this line is not working, it does not show the variable value.
self.contents.draw_text(0, 32, 300, 32, "Gained 1 XP")
end
end
#If you fail to steal, this window will be shown
class Steal_Fail < Window_Base
def initialize
super(220, 190, 200,80)
self.contents = Bitmap.new(width-32, height-32)
refresh
self.contents.font.name = "Arial"
self.contents.font.size = 24
end
def refresh
self.contents.clear
self.contents.draw_text(0, 0, 200, 32, "You failed to steal")
end
end
#if you lvl your pickpocket skill, this window will be shown
class PPlvlup < Window_Base
def initialize
super(220, 230, 200,80)
self.contents = Bitmap.new(width-32, height-32)
refresh
self.contents.font.name = "Arial"
self.contents.font.size = 24
end
def refresh
self.contents.clear
self.contents.draw_text(0, 0, 200, 32, "Your Pickpocket skill has increased")
end
end
class PickPocket #do i need to make it a sublcass of Game_party to add gold?
def initialize
@gold_available_to_steal = rand(500) #amount of gold the victim has
@victimintel=2 #victim's intel (the higher, the harder to steal)
@ppexp=0 #Starts with 0 exp
@pplevel=1 #Starts at lvl 1
@randomconstant=rand(101)
@chancetosteal = @pplevel - @victimintel + @randomconstant #equation
if @chancetosteal > 6 then #If the resulf of the equation above is higher than six, you stole the victim
@ppexp +=1 #add one point of PickPocketing Exp
if @ppexp == 10 then #Condition to lvl up
@ppexp = 0 #change exp back to 0
@pplevel += 1 #add one pickpocket lvl
@message=PPlvlup.new #Shows the window when you lvl up
end
@message=Steal_Success.new #Shows the window that tells your reward
else
@message=Steal_Fail.new #Shows the window that tells "You Failed"
end
end
end
To call this script im using an event in the map with the option to steal or not, if you choose yes, it calls PickPocket.new
I want to know:
how to make the fail or success windows to disappear after the player press the confirm button (its something about dispose, but idk how to use it) ,
how to show how much gold you stole .
how to increase gold ( wich superclass to use)
Also if there is any way to improve this script, because its my frist one ^^
Thanks
(if someone can add me at msn to answer some newbie questions, its ramonzinbastos@hotmail.com, i promise i wont bother u)
Wow, cool script man.
I'm not a scripter, so I can't help you too much.
BUT I can offer some suggestions, if I'm wrong, there's people that can help you on here.
I believe for the dispose thing it looks like this
@Steal_success.dispose
but like I said, I may be wrong.
I think the gold increase is done using Game_Party.
Dunno for the other thing :(
Don't worry though, there's MUCH more skilled scripters around here!
Thanks for the try dude, but it didnt work too..
What i had to do is use a Scene to call the window. Now its working, when i press Enter it disappear, but i dont know how to make the black background of the scene transparent
Well I'm fairly certain the snippit of code is:
or
As I got other windows to become transparent by placing this code in the script.
The problem is, I don't know where it would go for a Scene, since it isn't a window you're dealing with. I'm pretty sure it can be done somehow though.
just found out how to do it xD (a friend told me)
@spriteset = Spriteset_Map.new in the main method of the scene =)
i wonder why it is not lvling up the pickpocketing skill now...
### PickPocket by RamonBastos (first script) ###
module Vars #variables
attr_accessor :directionplayerfacing #The direction the player is looking to
attr_accessor :directionvictimfacing #Direction the Victim is looking to
attr_accessor :victimintel #Victim's Intel (The higher, the hardest to steal)
attr_accessor :randomconstant #just a random constant
attr_accessor :items_available_to_steal
attr_accessor :gold_available_to_steal
attr_accessor :chancetosteal #the equation
$pplevel=1 #pickpocket skill level
$ppexp=0 #pickpocket exp
$victiminfo=[] #0=Intel 1=AvailableGold
end
class PickPocket < Game_Party
def initialize
$victiminfo[1] #amount of gold the victim2 has
@randomconstant=rand(101)
@chancetosteal = $pplevel - $victiminfo[0] + @randomconstant #equation
if @chancetosteal > 6 then #If the resulf of the equation above is higher than six, you stole the victim
$ppexp +=1 #add one point of PickPocketing Exp
$game_party.gold += $victiminfo[1] #add gold
if $ppexp == 10 #Condition to lvl up
$pplevel += 1
$ppexp = 0
$scene= Scene_ShowLvlup_Window.new #Shows the window when you lvl up
end
$scene = Scene_ShowSuccess_Window.new #Shows the window that tells your reward
else
$scene=Scene_ShowFail_Window.new #Shows the window that tells "You Failed"
end
end
end
class Scene_ShowLvlup_Window
def main
@spriteset = Spriteset_Map.new #The background of scene is the map
@message1 = PPlvlup.new #call the success window
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@message1.dispose
@spriteset.dispose
end
def update
@message1.update
if Input.trigger?(Input::C) # If C button was pressed
$game_system.se_play($data_system.cancel_se) # Play cancel sound
$scene = Scene_Map.new # Switch to Menu screen
return
end
end
end
class Scene_ShowFail_Window
def main
@spriteset = Spriteset_Map.new #The background of scene is the map
@message1 = Steal_Fail.new #call the success window
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@message1.dispose
@spriteset.dispose
end
def update
@message1.update
if Input.trigger?(Input::C) # If C button was pressed
$game_system.se_play($data_system.cancel_se) # Play cancel sound
$scene = Scene_Map.new # Switch to Menu screen
return
end
end
end
class Scene_ShowSuccess_Window
def main
@spriteset = Spriteset_Map.new #The background of scene is the map
@message1 = Steal_Success.new #call the success window
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@message1.dispose
@spriteset.dispose
end
def update
@message1.update
if Input.trigger?(Input::C) # If C button was pressed
$game_system.se_play($data_system.cancel_se) # Play cancel sound
$scene = Scene_Map.new # Switch to Menu screen
return
end
end
end
#If you succeed to steal, this window will be shown
class Steal_Success < Window_Base
def initialize
super(220, 190, 150,130)
self.contents = Bitmap.new(width-32, height-32)
refresh
self.contents.font.name = "Arial"
self.contents.font.size = 24
end
def refresh
self.contents.clear
self.contents.draw_text(0, 0, 200, 32, "Stole " + $victiminfo[1].to_s + " gold") #this line is not working, it does not show the variable value.
self.contents.draw_text(0, 32, 300, 32, "Gained 1 XP")
end
end
#If you fail to steal, this window will be shown
class Steal_Fail < Window_Base
def initialize
super(220, 190, 200,80)
self.contents = Bitmap.new(width-32, height-32)
refresh
self.contents.font.name = "Arial"
self.contents.font.size = 24
end
def refresh
self.contents.clear
self.contents.draw_text(0, 0, 200, 32, "You failed to steal")
end
end
#if you lvl your pickpocket skill, this window will be shown
class PPlvlup < Window_Base
def initialize
super(220, 190, 200,80)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = "Arial"
self.contents.font.size = 24
refresh
end
def refresh
self.contents.clear
self.contents.draw_text(0, 0, 200, 32, "Your Pickpocket skill has increased")
end
end