ramonbastos
Member
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:
[rgss]### 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 < Game_Party
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
$game_party.gold += @gold_available_to_steal #add gold
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
[/rgss]
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 .
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)
Here is the code:
[rgss]### 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 < Game_Party
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
$game_party.gold += @gold_available_to_steal #add gold
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
[/rgss]
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 .
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)