Help - Search - Members - Calendar
Full Version: I want to pickpocket a npc & wait before I can again
RPG RPG Revolution Forums > Game Engines > RPG Maker XP Discussion
vvalkingman
Hello everyone laugh.gif

I'll get to the meat of it. Basically, I want the player to be able to "pickpocket" an npc and then have to wait 24 hrs/game time before they will be able to pickpocket them again. Now, I've worked out a ghetto way of doing this with the timer, self-switches, and a conditional branch at the npc level that checks if the timer has run out and turns off the self-switches accordingly. Which is all fine and dandy...but I don't want to see the timer and I want to be able to pickpocket more then one npc.

So I found a day and night system (http://forum.chaos-project.com/index.php?topic=710.0) blizzard's, and the reason I didn't just put this into script support is because i'm not too sure if it's possible to utilize his script this way, but here is what im thinking...
I get his script going, pickpocket an npc and instead of using the timer I reference his script's time and put it in a variable somehow. I then check if 60 minutes have past(which is how long 24 hrs would be in my game) and if so, then the self-switches will reset and we'll be able to pickpocket that npc again. Now, my question forum...in his code, how could I reference his time variable and put it as a variable? If i can do that I'm pretty sure I can figure out how to perform the checks against the variable.

What do you guys think? Is there an easier way to accomplish this or am I on the right track?
maximusmaxy
I had a look at the script and the variables your looking for are $game_system.ates.time.hour for the hour and $game_system.ates.time.min for the minute. After you do your pickpocket you could store these values in a variable and disable pickpocketing with a boolean. When the time comes around again you could then re-enable pickpocketing. I'll try write a script next time i'm on if you haven't worked it out by then.
vvalkingman
Ahhh $game_system, forgot that part.

Well here's what I was thinking:
I make pickpocketing a common event autorun after a switch is turned on. At the NPC level, after the x button is pressed(that's my pickpocket button) I do a self-switch to the next event where it'll "take a picture of the time variables" & turn on the pickpocket switch then self-switch to a third event where it'll run checks when you try to pickpocket again. The only issue I'm having is with multiple npcs. Basically, I can steal from one but I can't steal from the other until it resets lol. I'll work on it, if you can come up with a script that'd be sweet. Thanks again for all the help smile.gif
maximusmaxy
Yeah it would be very annoying to event your pickpocketing for each event. It would be a hell of allot easier with a script. If you could upload a demo of your game or just a section of it to see how your pickpocketing works i could see if i'm or someone else is able to script it.
vvalkingman
http://www.mediafire.com/?94aucl6scptcwck

edit: I tried to do what I said I was going to do in the previous post and got an error saying that it doesn't know what ates is...take a look at the npcs and see if you guys can help me figure out what im doing wrong here...thanks in advance!

edit: Ok so now I see that ssytem mispell lol...and realized that I'm looking for the EXACT moment when i stole from them minus a minute...hmmm how would you word that logic?

edit: Ok, I feel like I'm on the right track here....like i need one more variable maybe generated by a common event that checks if 24 hrs have passed? but i'm drawing a blank. http://www.mediafire.com/?x7c6nym7grislqk
maximusmaxy
I see can see what you want to happen, I'm going to tackle a script for this when i get back from work, I think it may work well as part of my tactical espionage engine that I'm working on biggrin.gif
vvalkingman
QUOTE (maximusmaxy @ Sep 7 2011, 08:43 PM) *
I see can see what you want to happen, I'm going to tackle a script for this when i get back from work, I think it may work well as part of my tactical espionage engine that I'm working on biggrin.gif


Sweet, I'm working up an algorithm right now...you see I got to thinking that maybe I could code up a table with the npc(event) and the time of the pickpocketing minus one minute(that way you can't just immediately pickpocket them) and run a check comparing the current time with the table and if the current time matches the time associated with the npc(event) then take them off all the list(making them pickpocketable again lol) seems alittle overly complicated and i'm sure i'm missing the easy way to do it somewhere lol but yea, i'll keep working on it and let yah know what i come up with. Thanks for wantin' to help me out. Let's race to see who comes up with a better/easier solution wink.gif
maximusmaxy
Just keeping you updated, i'm half done with the script. I still need to make the events update properly after the day is done(If you skip ahead of the time using the crystal it won't update), ill also do the directional thing so it only steals when they face backwards and i might mix up a thing or two. We shall see. Will do the other half tomorrow.Here is a demo and here is the script.

CODE
#===============================================================================
# Stealing System
# Author: Maximusmaxy
# Version: 0.5
# Thanks to:
# Vvalkingman - For requesting it
# Blizzard - For making the ATES
#===============================================================================
#
# NOTE: This script has been written to work with Advanced Time and Environment
# System (ATES) by Blizzard and will not work without it.
#
# Instructions:
# The items held by the event need to be initialised by using a script call,
# the easiest way to do this is place the call script in an autorun event.
# The call scripts are as follows:
#
# Steal.gold(EVENT,AMOUNT)
# Adds gold to the event
#
# Steal.item(EVENT,ID,AMOUNT)
# Adds items to the event
#
# Steal.weapon(EVENT,ID,AMOUNT)
# Adds weapons to the event
#
# Steal.armor(EVENT,ID,AMOUNT)
# Adds armor to the event
#
# EVENT is the event id on the current map
# ID is the id of the item/weapon/armor in the database
# AMOUNT is the amount of the gold/item/weapon/armor the event has
#
# To steal from an event use the call script type the following code:
# $game_map.events[EVENT].steal
# EVENT is the event id on the current map
#
#===============================================================================

class Steal
  #Set the steal item of the event to[type,id,amount]
  #type 0 = gold, 1 = item, 2 = weapon, 3 = armor
  #id = id in the database
  #amount = amount of that item stolen
  def self.gold(event,amount)
    $game_map.events[event].steal_item = [0,0,amount]
  end
  
  def self.item(event,id,amount)
    $game_map.events[event].steal_item = [1,id,amount]
  end
  
  def self.weapon(event,id,amount)
    $game_map.events[event].steal_item = [2,id,amount]
  end
    
  def self.armor(event,id,amount)
    $game_map.events[event].steal_item = [3,id,amount]
  end
end

class Game_Event < Game_Character
  attr_accessor :steal_item
  attr_accessor :stolen
  attr_accessor :stolen_time
  alias max_steal_initialize_later initialize
  def initialize( *args )
    max_steal_initialize_later( *args )
    #add the stealing variables to the event
    @steal_item = 0
    @stolen = false
    @stolen_time = 0
  end
  
  def steal
    #if the event has an item that isn't stolen
    if @steal_item != 0 && !@stolen
      #case for the type
      case @steal_item[0]
      when 0
        #add gold amount
        $game_party.gain_gold(@steal_item[2])
      when 1
        #add item id, amount
        $game_party.gain_item(@steal_item[1],@steal_item[2])
      when 2
        #add weapon id, amount
        $game_party.gain_weapon(@steal_item[1],@steal_item[2])
      when 3
        #add armor id, amount
        $game_party.gain_armor(@steal_item[1],@steal_item[2])
      end
      #activate the stolen variable
      @stolen = true
      #put the time at which the item was stolen into a variable
      @stolen_time = [$game_system.ates.time.min - 1, $game_system.ates.time.hour]
    end
  end
  
  def update
    if $game_system.ates.time.min == @stolen_time[0] &&
       $game_system.ates.time.hour == @stolen_time[1]
      @stolen = false
    end
  end
end
vvalkingman
Here's as far as I got:
http://www.mediafire.com/?7vldyld876d4b4d

Basically, I made a common event activated by a switch that checked the time and would turn the switch off once the time was met. The npc would not be able to be pickpocketed until the switch was turned off. This works for one npc only though...was starting to think I was going to have to set aside a section of switches for npcs to use or something lol let me update once I've checked yours out. Thanks again for your help!

edit: NICE! Works perfectly on event 006. I'll probably be making some modifications for myself if that's cool. For example, in my game when you pickpocket you only steal gold. Furthermore, pickpocket is a passive skill(you don't use it in combat) that levels up after usage. The money you get from pickpocketing is random but basically you go from a lower percentage of money to a higher one(ex. Pickpocket lvl 1 -> lvl 2 = 5 gold - 105 gold to 120 gold - 275 gold). Your script is amazing though, thanks again for all the help biggrin.gif

edit: Actually...it looks like you got about as far as I did lol is there a way to attach the time to the event? I think that if you steal from it and the event is event.stolen then when the time comes around and @stolen = false then it goes back to normal...kinda back to my table idea lol or do i have it all wrong? It's been a bit since I've actually touched some code so bare with me lol
vvalkingman
Ok, I see why I was confused. Your code works fine...but you forgot to account for the -1 smile.gif I caught this when I was doing events for the same thing earlier. Basically when you set the variable = ($game_system.ates.time.min - 1) what if the current minute is = to 0? then the variable will be -1 and no matter what the time is it won't ever be -1 haha so I added a check for the minutes and another one to make the hour workout too. Works great now biggrin.gif here's the updated:

CODE
#===============================================================================
# Stealing System
# Author: Maximusmaxy
# Version: 0.5a
# Thanks to:
# VValkingman - For requesting it & adding his two cents to the script
# Blizzard - For making the ATES
#===============================================================================
#
# NOTE: This script has been written to work with Advanced Time and Environment
# System (ATES) by Blizzard and will not work without it.
#
# Instructions:
# The items held by the event need to be initialised by using a script call,
# the easiest way to do this is place the call script in an autorun event.
# The call scripts are as follows:
#
# Steal.gold(EVENT,AMOUNT)
# Adds gold to the event
#
# Steal.item(EVENT,ID,AMOUNT)
# Adds items to the event
#
# Steal.weapon(EVENT,ID,AMOUNT)
# Adds weapons to the event
#
# Steal.armor(EVENT,ID,AMOUNT)
# Adds armor to the event
#
# EVENT is the event id on the current map
# ID is the id of the item/weapon/armor in the database
# AMOUNT is the amount of the gold/item/weapon/armor the event has
#
# To steal from an event use the call script type the following code:
# $game_map.events[EVENT].steal
# EVENT is the event id on the current map
#
#===============================================================================

class Steal
  #Set the steal item of the event to[type,id,amount]
  #type 0 = gold, 1 = item, 2 = weapon, 3 = armor
  #id = id in the database
  #amount = amount of that item stolen
  def self.gold(event,amount)
    $game_map.events[event].steal_item = [0,0,amount]
  end
  
  def self.item(event,id,amount)
    $game_map.events[event].steal_item = [1,id,amount]
  end
  
  def self.weapon(event,id,amount)
    $game_map.events[event].steal_item = [2,id,amount]
  end
    
  def self.armor(event,id,amount)
    $game_map.events[event].steal_item = [3,id,amount]
  end
end

class Game_Event < Game_Character
  attr_accessor :steal_item
  attr_accessor :stolen
  attr_accessor :stolen_time
  alias max_steal_initialize_later initialize
  def initialize( *args )
    max_steal_initialize_later( *args )
    #add the stealing variables to the event
    @steal_item = 0
    @stolen = false
    @stolen_time = 0
  end
  
  def steal
    #if the event has an item that isn't stolen
    if @steal_item != 0 && !@stolen
      #case for the type
      case @steal_item[0]
      when 0
        #add gold amount
        $game_party.gain_gold(@steal_item[2])
      when 1
        #add item id, amount
        $game_party.gain_item(@steal_item[1],@steal_item[2])
      when 2
        #add weapon id, amount
        $game_party.gain_weapon(@steal_item[1],@steal_item[2])
      when 3
        #add armor id, amount
        $game_party.gain_armor(@steal_item[1],@steal_item[2])
      end
      #activate the stolen variable
      @stolen = true
      #put the time at which the item was stolen into a variable
      @stolen_time = [$game_system.ates.time.min - 1, $game_system.ates.time.hour]
                        #VValkingman's check for negative numbers in the minute and hour;)  
                           if @stolen_time[0] < 0
                              @stolen_time[0] = 59
                              @stolen_time[1]-= 1
                              if @stolen_time[1] < 0
                                 @stolen_time[1] = 23
                              end
                            end
    end
  end
  
  def update
    if $game_system.ates.time.min == @stolen_time[0] &&
       $game_system.ates.time.hour == @stolen_time[1]
      @stolen = false
    end
  end
end
maximusmaxy
^ ^ nice catch there. Probably would have saved me ages if you didn't give me the heads up.
I have completed most of what i want to do with the script. I implemented the split talk/steal key, the events no longer need any call scripts in them at all, other than the script call to initialise the items. I fixed the problem of events not updating after a day had passed, and somehow created time travel huh.gif
There are 2 more things i'd like to implement before I'm satisfied. The levelling system, where the more you steal the higher your level is, and the more gold you can recieve from stealing. Also i would like to add automatic messages that appear so you don't have to use any switches at all. Unfortunately i'm not good at printing messages from scripts so if anyone could help me out there it would be really appreciated.

here is a demo, and here is the script:
CODE
#===============================================================================
# Stealing System
# Author: Maximusmaxy
# Version: 0.9
# Thanks to:
# VValkingman - For requesting it & adding his two cents to the script
# Blizzard - For making the ATES
#===============================================================================
# Version 0.5a 8/9/2011
# Version 0.9 9/9/2011
#===============================================================================
#
# NOTE: Some of the features have been written to work with Advanced Time and
# Environment System (ATES) by Blizzard and will not work without it.
#
# BIGGER NOTE: MUST be placed under ATES as it rewrites some of its methods.
#
# ATES can be found at the following link:
# http://forum.chaos-project.com/index.php?topic=710.0
#
#                                Instructions
# Stealing:
# To attempt to steal from an event use the input button specified in the config
# To steal from an event you must be facing it's back otherwise the event will
# notice you, or in other words it will activate it's fail self switch. If the
# steal is successful it will activate the events success self switch, and the
# item the event is holding will be added to your inventory. After the item is
# stolen and you try to steal from the event again, it will trigger it's
# unavailable self switch, unless the item has been refreshed.
#
# Items:
# The items held by the event need to be initialised by using a script call,
# the easiest way to do this is place the call script in an autorun event.
# The call scripts are as follows:
#
# Steal.gold(EVENT,AMOUNT)
# Adds gold to the event
#          or
# Steal.gold(EVENT,AMOUNT_MINIMUM,AMOUNT_MAXIMUM)
# Adds random gold to the event
#
# Steal.item(EVENT,ID,AMOUNT)
# Adds items to the event
#
# Steal.weapon(EVENT,ID,AMOUNT)
# Adds weapons to the event
#
# Steal.armor(EVENT,ID,AMOUNT)
# Adds armor to the event
#
# EVENT is the event id on the current map
# ID is the id of the item/weapon/armor in the database
# AMOUNT is the amount of the gold/item/weapon/armor the event has
# For gold a random number between AMOUNT_MINIMUM and AMOUNT_MAXIMUM is chosen
# if using the second script call.
#
# Item Refreshing:
# Using the timer from ATES you are able to refresh the items the event has
# every day. This feature can be enabled/disabled in the configuration. You can
# also manually refresh the item of the event using the call script.
#
# Steal.refresh(EVENT)
#
# EVENT is the event id on the current map
#
#===============================================================================

module Steal
  
#===============================================================================
# Begin Configuration
#===============================================================================

  #Input button to steal
  STEAL_KEY = Input::X          #Defaults as A key on the keyboard
  #Choose which switch you want to activate by stealing from the event.
  SUCCESS_SWITCH = 'B'
  FAIL_SWITCH = 'C'
  UNAVAILABLE_SWITCH = 'D'
  #choose whether or not you want to enable item refreshing after each day.
  #Requires ATES
  REFRESH_ENABLE = true

#===============================================================================
# End Configuration
#===============================================================================

  def self.do
    #direction of the player
    d = $game_player.direction
    #coords of the space in front of you
    x = $game_player.x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    y = $game_player.y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    #id of the event
    id = $game_map.check_event(x,y)
    #return if there is no event in that location
    return if id.instance_of?(Array)
    #if the event has no item cancel steal
    return if $game_map.events[id].steal_item == 0
    #If item is stolen or not refreshed
    if $game_map.events[id].stolen #Unavailable
      #don't turn toward the player
      $game_map.events[id].direction = $game_map.events[id].old_direction
      #activate the events self switch
      key = [$game_map.map_id,id,Steal::UNAVAILABLE_SWITCH]
      $game_self_switches[key] = true
      #refresh the map
      $game_map.need_refresh = true
    #If you are behind the event
    elsif d == $game_map.events[id].old_direction #Success
      #don't turn toward the player
      $game_map.events[id].direction = $game_map.events[id].old_direction
      #steal from that event
      $game_map.events[id].steal
      #activate the events self switch
      key = [$game_map.map_id,id,Steal::SUCCESS_SWITCH]
      $game_self_switches[key] = true
      #refresh the map
      $game_map.need_refresh = true
    else #Fail
      #turn toward player
      $game_map.events[id].turn_toward_player
      #activate the events self switch
      key = [$game_map.map_id,id,Steal::FAIL_SWITCH]
      $game_self_switches[key] = true
      #refresh the map
      $game_map.need_refresh = true
    end      
  end
  
  #Set the steal item of the event to [type,id,amount]
  #type 0 = gold, 1 = item, 2 = weapon, 3 = armor
  #id = id in the database
  #amount/min/max = amount of that item stolen
  def self.gold(event,amount_min,amount_max = -1)
    $game_map.events[event].steal_item = [0,amount_min,amount_max]
  end
  
  def self.item(event,id,amount)
    $game_map.events[event].steal_item = [1,id,amount]
  end
  
  def self.weapon(event,id,amount)
    $game_map.events[event].steal_item = [2,id,amount]
  end
    
  def self.armor(event,id,amount)
    $game_map.events[event].steal_item = [3,id,amount]
  end
  
  #refresh the events item
  def self.refresh(event)
    $game_map.events[event].stolen = false
  end
end

#===============================================================================
# Game_Event
#===============================================================================

class Game_Event < Game_Character
  attr_accessor :steal_item
  attr_accessor :stolen
  attr_accessor :stolen_time
  attr_accessor :direction
  attr_accessor :old_direction
  alias max_steal_initialize_later initialize
  alias max_steal_update_later update
  def initialize( *args )
    max_steal_initialize_later( *args )
    #add the stealing variables to the event
    @steal_item = 0
    @stolen = false
    @stolen_time = 0
    @old_direction = 2
  end
  
  def steal
    #if the event has an item that isn't stolen
    if @steal_item != 0 && !@stolen
      #case for the type
      case @steal_item[0]
      when 0
        #if no maximum specified
        if @steal_item[2] == -1
          #add gold amount
          $game_party.gain_gold(@steal_item[1])
        else
          #add gold random amount
          $game_party.gain_gold(@steal_item[1] + rand(@steal_item[2] - @steal_item[1]))
        end
      when 1
        #add item id, amount
        $game_party.gain_item(@steal_item[1],@steal_item[2])
      when 2
        #add weapon id, amount
        $game_party.gain_weapon(@steal_item[1],@steal_item[2])
      when 3
        #add armor id, amount
        $game_party.gain_armor(@steal_item[1],@steal_item[2])
      end
      #activate the stolen variable
      @stolen = true
      #put the time at which the item was stolen into a variable
      @stolen_time = [$game_system.ates.time.min - 1, $game_system.ates.time.hour]
      #VValkingman's check for negative numbers in the minute and hour;)  
      if @stolen_time[0] < 0
        @stolen_time[0] = 59
        @stolen_time[1] -= 1
        if @stolen_time[1] < 0
          @stolen_time[1] = 23
        end
      end
    end
  end
  
  def update
    #if ates is right version and refresh is enabled
    if $ates >= 0.4 && Steal::REFRESH_ENABLE
      #check if ates time is the stolen time and item is stolen
      if $game_system.ates.time.min == @stolen_time[0] &&
         $game_system.ates.time.hour == @stolen_time[1] && @stolen
        #reset stolen variables
        @stolen = false
        @stolen_time = 0
      end
    end
    #direction of the player
    d = $game_player.direction
    #coords of the space in front of you
    x = $game_player.x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    y = $game_player.y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    #if the event isn't in front of the player
    if $game_map.check_event(x,y) != $game_player.x || $game_map.check_event(x,y) != $game_player.y
      #update the old direction variable
      @old_direction = @direction
    end
    max_steal_update_later
  end
end

#===============================================================================
# Game_player
#===============================================================================

class Game_Player < Game_Character
  alias max_steal_update_later update
  def update
    max_steal_update_later
    #If not moving
    unless moving?
      #If Steal button was pressed
      if Input.trigger?(Steal::STEAL_KEY)
        #Steal from the event in front of you
        Steal.do
      end
    end
  end
end

#===============================================================================
# ATES Modification
#===============================================================================

#Modified to update the map every minute to create a realistic time advancement.
#Time now always progresses forward from script calls instead of back and forth.

module ATES
  def self.advance(m = 1, h = 0)
    #if ates doesn't exist or wrong version
    if $ates == nil || $ates < 0.4
      p 'needs ATES v0.4 or higher to work'
      return
    end
    return false if m < 0 || h < 0
    #create a variable
    hour = $game_system.ates.time.hour
    min = $game_system.ates.time.min
    #loop for the hours
    for i in 0..h
      #if not the last hour, use 60 minutes
      new_m = (i == h ? m : 60)
      #loop for the new minutes
      for j in 0..new_m
        #create a new variable for the loop
        new_hour = (hour + i) % 24
        new_min = min + j
        #increase hour and reset if min = 60
        new_hour += 1 if new_min > 59
        new_hour = 0 if new_hour == 24
        #modulus the minute
        new_min %= 60
        #update the actual hour/minute
        $game_system.ates.time.hour = new_hour
        $game_system.ates.time.min = new_min
        #refresh the map
        $game_map.update
      end
    end
    return true
  end
  
  def self.make_it_day
    #increase minutes to 60 (or 0)
    min = 60 - $game_system.ates.time.min
    #increase hour to night start and subtract from 24 if negative
    hour = DAY_START - $game_system.ates.time.hour - 1
    #subtract from 24 if negative
    hour += 24 if hour < 0
    #advance to night start
    ATES.advance(min,hour)
    return true
  end
  
  def self.make_it_night
    #increase minutes to 60 (or 0)
    min = 60 - $game_system.ates.time.min
    #increase hour to night start and subtract from 24 if negative
    hour = NIGHT_START - $game_system.ates.time.hour - 1
    #subtract from 24 if negative
    hour += 24 if hour < 0
    #advance to night start
    ATES.advance(min,hour)
    return true
  end
end
vvalkingman
QUOTE (maximusmaxy @ Sep 9 2011, 03:51 AM) *
There are 2 more things i'd like to implement before I'm satisfied. The levelling system, where the more you steal the higher your level is, and the more gold you can recieve from stealing. Also i would like to add automatic messages that appear so you don't have to use any switches at all. Unfortunately i'm not good at printing messages from scripts so if anyone could help me out there it would be really appreciated.

Well here is how you access the messaging system:

$game_temp.message_text = "Hey there, I am a message from the script!"

It's all in game_temp.

As for the leveling system, I've sort of worked it out in a common event already lol but I like where you are going with it so I'll slap it in the script during my lunch hour. When I write it, I'll have it so it's built into a script but give instructions for those who want to link the variable to the progression of a "pickpocketing skill" for a character. That way it doesn't have to be player 1(which it is in my game). I'll post a demo shortly after that smile.gif We make a good team there maximus wink.gif lol
maximusmaxy
Here's my last update for today, it now needs no self switches, no common events or anything, just the script call to initialise the items for the events(although Night Runner showed me a script today and i think i can implement a better solution to initialising the items). Although my messages don't really work yet, they only activate once and the next time they appear, they appear blank. If anyone could help me with that i will be completely satisfied with my script. If you post your method of leveling, i'll just add it to the options of my methods or whatever works out for you.
here is the demo and here is the script:

CODE
#===============================================================================
# Stealing System
# Author: Maximusmaxy
# Version: 0.9.5
# Thanks to:
# VValkingman - For requesting it & adding his two cents to the script
# Blizzard - For making the ATES
#===============================================================================
# Version 0.5a 8/9/2011
# Version 0.9 9/9/2011
# Version 0.9.5 10/9/2011
#===============================================================================
#
# NOTE: Some of the features have been written to work with Advanced Time and
# Environment System (ATES) by Blizzard and will not work without it.
#
# BIGGER NOTE: MUST be placed under ATES as it rewrites some of its methods.
#
# ATES can be found at the following link:
# http://forum.chaos-project.com/index.php?topic=710.0
#
#                                Instructions
# Stealing:
# To attempt to steal from an event use the input button specified in the config
# To steal from an event you must be facing it's back otherwise the event will
# notice you, or in other words it will activate it's fail message. If the
# steal is successful it will activate the events success message, and the
# item the event is holding will be added to your inventory. After the item is
# stolen and you try to steal from the event again, it will trigger it's
# unavailable message, unless the item has been refreshed.
#
# Items:
# The items held by the event need to be initialised by using a script call,
# the easiest way to do this is place the call script in an autorun event.
# The call scripts are as follows:
#
# Steal.gold(EVENT,AMOUNT)
# Adds gold to the event
#          or
# Steal.gold(EVENT,AMOUNT_MINIMUM,AMOUNT_MAXIMUM)
# Adds random gold to the event
#
# Steal.item(EVENT,ID,AMOUNT)
# Adds items to the event
#
# Steal.weapon(EVENT,ID,AMOUNT)
# Adds weapons to the event
#
# Steal.armor(EVENT,ID,AMOUNT)
# Adds armor to the event
#
# EVENT is the event id on the current map
# ID is the id of the item/weapon/armor in the database
# AMOUNT is the amount of the gold/item/weapon/armor the event has
# For gold a random number between AMOUNT_MINIMUM and AMOUNT_MAXIMUM is chosen
# if using the second script call.
#
# Item Refreshing:
# Using the timer from ATES you are able to refresh the items the event has
# every day. This feature can be enabled/disabled in the configuration. You can
# also manually refresh the item of the event using the call script.
#
# Steal.refresh(EVENT)
#
# EVENT is the event id on the current map
#
# Leveling:
# The higher your level in thievery, the more gold you recieve from stealing.
# Every time you steal from an event you gain an experience point towards your
# level. The Breaks in the levels can be set up in the config, every time your
# exp is equal to a value in the config, you will level up.
#
# There are two choices for the amount of gold recieved from leveling up.
#
# Addition: a set amount of gold is added per level.
# Eg. with addition of 100g.
# Lvl 1 = 50g, Lvl 2 = 50+100 = 150g, Lvl 3 = 50+200 = 250g ect.
#      
# Multiplication: gold recieved is multiplied by your level
# Eg. Lvl 1 = 50g, Lvl 2 = 50*2 = 100g, Lvl 3 = 50*3 = 150g ect.  
#
# If you don't want to use leveling and just gain flat rates, empty the
# level array.
#
#===============================================================================

module Steal
  
#===============================================================================
# Begin Configuration
#===============================================================================

  #Input button to steal
  STEAL_KEY = Input::X          #Defaults as A key on the keyboard
  #Choose what you want your stealing messages to say.
  SUCCESS_MESSAGE_BEGIN = "You Succesfully Steal:"
  SUCCESS_MESSAGE_END = "Score!"
  FAIL_MESSAGE = "I can't steal from here.\nThey will notice me."
  UNAVAILABLE_MESSAGE = "This person doesn't have an item\ni can steal."
  LVL_MESSAGE = "Congratulations!\nYour Thief skills are now level "
  #Set the breaks for levels here, if you don't want to use levels then leave
  STEAL_LEVEL = [5,10,20,35,50,75,100,130,165,200]    #the brackets empty eg.[]
  #Set the leveling type
  TYPE = 0              #Addition = 0, Multiplication = 1
  ADDITION = 100        #the amount for addition
  #choose whether or not you want to enable item refreshing after each day.
  #Requires ATES
  REFRESH_ENABLE = true

#===============================================================================
# End Configuration
#===============================================================================

  def self.do
    #direction of the player
    d = $game_player.direction
    #coords of the space in front of you
    x = $game_player.x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    y = $game_player.y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    #id of the event
    id = $game_map.check_event(x,y)
    #return if there is no event in that location
    return if id.instance_of?(Array)
    #if the event has no item cancel steal
    return if $game_map.events[id].steal_item == 0
    #If item is stolen or not refreshed
    if $game_map.events[id].stolen #Unavailable
      #don't turn toward the player
      $game_map.events[id].direction = $game_map.events[id].old_direction
      #show fail text
      $game_temp.message_text = UNAVAILABLE_MESSAGE
    elsif d == $game_map.events[id].old_direction #Success
      #don't turn toward the player
      $game_map.events[id].direction = $game_map.events[id].old_direction
      #steal from that event
      $game_map.events[id].steal
      #case for type
      case $game_map.events[id].steal_item[0]
      when 0 #Gold
        type = $data_system.words.gold.to_s
      when 1 #Item
        type = $data_items[$game_map.events[id].steal_item[1]].name
      when 2 #Weapon
        type = $data_weapons[$game_map.events[id].steal_item[1]].name
      when 3 #Armor
        type = $data_armors[$game_map.events[id].steal_item[1]].name
      end
      #plural check
      s = ($game_map.events[id].steal_item[2] == 1 ? "" : "s")
      s = "" if $game_map.events[id].steal_item[0] == 0
      #if type is gold and gold is random
      if $game_map.events[id].steal_item[0] == 1 &&
         $game_map.events[id].steal_item[2] == -1
        #amount is random
        amount = ($game_map.events[id].random_gold).to_s
      else
        #amount is normal
        amount = ($game_map.events[id].steal_item[1]).to_s
      end
      #show success text
      $game_temp.message_text = SUCCESS_MESSAGE_BEGIN + "\n" + amount + " " +
                                type + s + "\n" + SUCCESS_MESSAGE_END
      if $game_player.steal_leveled == true
        $game_temp.message_text = LVL_MESSAGE + $game_player.steal_level.to_s
      end
    else #Fail
      #turn toward player
      $game_map.events[id].turn_toward_player
      #show fail text
      $game_temp.message_text = FAIL_MESSAGE
    end      
  end

  #Set the steal item of the event to [type,id,amount]
  #type 0 = gold, 1 = item, 2 = weapon, 3 = armor
  #id = id in the database
  #amount/min/max = amount of that item stolen
  def self.gold(event,amount_min,amount_max = -1)
    $game_map.events[event].steal_item = [0,amount_min,amount_max]
  end
  
  def self.item(event,id,amount)
    $game_map.events[event].steal_item = [1,id,amount]
  end
  
  def self.weapon(event,id,amount)
    $game_map.events[event].steal_item = [2,id,amount]
  end
    
  def self.armor(event,id,amount)
    $game_map.events[event].steal_item = [3,id,amount]
  end
  
  #refresh the events item
  def self.refresh(event)
    $game_map.events[event].stolen = false
  end
end

#===============================================================================
# Game_Event
#===============================================================================

class Game_Event < Game_Character
  attr_accessor :steal_item
  attr_accessor :stolen
  attr_accessor :stolen_time
  attr_accessor :direction
  attr_accessor :old_direction
  attr_accessor :random_gold
  alias max_steal_initialize_later initialize
  alias max_steal_update_later update
  def initialize( *args )
    max_steal_initialize_later( *args )
    #add the stealing variables to the event
    @steal_item = 0
    @stolen = false
    @stolen_time = 0
    @old_direction = 2
    @random_gold = 0
  end
  
  def steal
    #if the event has an item that isn't stolen
    if @steal_item != 0 && !@stolen
      #case for the type
      case @steal_item[0]
      when 0
        #if no maximum specified, use minimum
        if @steal_item[2] == -1
          case Steal::TYPE
          when 0 #Addition
            $game_party.gain_gold(@steal_item[1] +
            (Steal::ADDITION * ($game_player.steal_level-1)))
          when 1 #Multiplication
            $game_party.gain_gold(@steal_item[1] * ($game_player.steal_level))
          end
        else
          #update random gold variable
          @random_gold = @steal_item[1] + rand(@steal_item[2] - @steal_item[1])
          case Steal::TYPE
          when 0 #Addition
            $game_party.gain_gold(@random_gold +
            (Steal::ADDITION * $game_player.steal_level-1))
          when 1 #Multiplication
            $game_party.gain_gold(@random_gold * $game_player.steal_level)
          end
        end
      when 1
        #add item id, amount
        $game_party.gain_item(@steal_item[1],@steal_item[2])
      when 2
        #add weapon id, amount
        $game_party.gain_weapon(@steal_item[1],@steal_item[2])
      when 3
        #add armor id, amount
        $game_party.gain_armor(@steal_item[1],@steal_item[2])
      end
      #activate the stolen variable
      @stolen = true
      #put the time at which the item was stolen into a variable
      @stolen_time = [$game_system.ates.time.min - 1, $game_system.ates.time.hour]
      #VValkingman's check for negative numbers in the minute and hour;)  
      if @stolen_time[0] < 0
        @stolen_time[0] = 59
        @stolen_time[1] -= 1
        if @stolen_time[1] < 0
          @stolen_time[1] = 23
        end
      end
      #increment amount of steals
      $game_player.steal_amount += 1
    end
  end
  
  def update
    #if ates is right version and refresh is enabled
    if $ates >= 0.4 && Steal::REFRESH_ENABLE
      #check if ates time is the stolen time and item is stolen
      if $game_system.ates.time.min == @stolen_time[0] &&
         $game_system.ates.time.hour == @stolen_time[1] && @stolen
        #reset stolen variables
        @stolen = false
        @stolen_time = 0
      end
    end
    #direction of the player
    d = $game_player.direction
    #coords of the space in front of you
    x = $game_player.x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    y = $game_player.y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    #if the event isn't in front of the player
    if $game_map.check_event(x,y) != $game_player.x || $game_map.check_event(x,y) != $game_player.y
      #update the old direction variable
      @old_direction = @direction
    end
    max_steal_update_later
  end
end

#===============================================================================
# Game_player
#===============================================================================

class Game_Player < Game_Character
  attr_accessor :steal_level
  attr_accessor :steal_amount
  attr_accessor :steal_leveled
  alias max_steal_initialize_later initialize
  alias max_steal_update_later update
  def initialize
    @steal_level = 1
    @steal_amount = 0
    @steal_leveled = false
    @steal_flag = 0
    max_steal_initialize_later
  end
  def update
    max_steal_update_later
    #if you level up, allow levelling
    if @steal_flag != @steal_amount
      @steal_leveled = false
    end
    #level up when level is equal to a value in STEAL_LEVEL
    if Steal::STEAL_LEVEL.include?(@steal_amount) && !@steal_leveled
      @steal_level += 1
      @steal_leveled = true
      @steal_flag = @steal_amount
    end  
    #If not moving
    unless moving?
      #If Steal button was pressed
      if Input.trigger?(Steal::STEAL_KEY)
        #Steal from the event in front of you
        Steal.do
      end
    end
  end
end

#===============================================================================
# ATES Modification
#===============================================================================

#Modified to update the map every minute to create a realistic time advancement.
#Time now always progresses forward from script calls instead of back and forth.

module ATES
  def self.advance(m = 1, h = 0)
    #if ates doesn't exist or wrong version
    if $ates == nil || $ates < 0.4
      p 'needs ATES v0.4 or higher to work'
      return
    end
    return false if m < 0 || h < 0
    #create a variable
    hour = $game_system.ates.time.hour
    min = $game_system.ates.time.min
    #loop for the hours
    for i in 0..h
      #if not the last hour, use 60 minutes
      new_m = (i == h ? m : 60)
      #loop for the new minutes
      for j in 0..new_m
        #create a new variable for the loop
        new_hour = (hour + i) % 24
        new_min = min + j
        #increase hour and reset if min = 60
        new_hour += 1 if new_min > 59
        new_hour = 0 if new_hour == 24
        #modulus the minute
        new_min %= 60
        #update the actual hour/minute
        $game_system.ates.time.hour = new_hour
        $game_system.ates.time.min = new_min
        #refresh the map
        $game_map.update
      end
    end
    return true
  end
  
  def self.make_it_day
    #increase minutes to 60 (or 0)
    min = 60 - $game_system.ates.time.min
    #increase hour to day start
    hour = DAY_START - $game_system.ates.time.hour - 1
    #subtract from 24 if negative
    hour += 24 if hour < 0
    #advance to night start
    ATES.advance(min,hour)
    return true
  end
  
  def self.make_it_night
    #increase minutes to 60 (or 0)
    min = 60 - $game_system.ates.time.min
    #increase hour to night start
    hour = NIGHT_START - $game_system.ates.time.hour - 1
    #subtract from 24 if negative
    hour += 24 if hour < 0
    #advance to night start
    ATES.advance(min,hour)
    return true
  end
end
vvalkingman
Well, looks like I was getting ahead of myself in scripting lol I tried to throw in alittle more control over a few aspects but I dont recall how to call the variables. Here's my version, doesn't let you steal...

http://www.mediafire.com/?cc2n996bsv1o6di

It would seem that the event bug that I thought would come up doesn't actually come up(where it locks the next maps' EV005 out from being stolen from if EV005 in this map has been stolen from) But yes, it only lets you do it once. Once per npc, even if you go to another map itll let you do those npcs too. But yea, only once. I think I'm going to leave scripting to the scripters lol if it's somethin obvious ill point it out but yea, my skills are rusty at best..thanks again max for all the help.
maximusmaxy
I looked over you code, you code like an eventer laugh.gif but yeah i implemented your code into mine so it will work exactly the way you want it to(except i condensed about a page of your code into like 3 lines).
Thanks for pointing out that the stolen item applies to the events of other maps though. I've been writing the script thinking that RGSS processes each individual event as separate objects, but when a map is created it overwrites all the event data with it's new data dry.gif . I'll be a bit busy for the next couple of days working on assignments and stuff but ill try to rewrite the code so that the script works across different maps.
Also i re-implemented all the old stuff(self switches activating) and all of your stuff(in game variables, custom leveling, and custom gold amounts) and added some new stuff(script calls for leveling).
I've barely done any bug testing on all the new methods so i'm not too sure if all of the stuff works. But here is what i got so far anyway.

CODE
#===============================================================================
# Stealing System
# Author: Maximusmaxy
# Version: 0.9.6
# Thanks to:
# VValkingman - For requesting it & adding his two cents to the script
# Blizzard - For making the ATES
#===============================================================================
# Version 0.5a 8/9/2011
# Version 0.9 9/9/2011
# Version 0.9.5 10/9/2011
# Version 0.9.6 11/9/2011
#===============================================================================
#
# NOTE: Some of the features have been written to work with Advanced Time and
# Environment System (ATES) by Blizzard and will not work without it.
#
# BIGGER NOTE: MUST be placed under ATES as it rewrites some of its methods.
#
# ATES can be found at the following link:
# http://forum.chaos-project.com/index.php?topic=710.0
#
#=============================Instructions======================================
#
# Stealing:
# To attempt to steal from an event use the input button specified in the config
#
# Messages:
# To steal from an event you must be facing it's back otherwise the event will
# notice you, or in other words it will activate it's fail message. If the
# steal is successful it will activate the events success message, and the
# item the event is holding will be added to your inventory. Back stealing can
# be turned off in the configuration, so you can steal from any direction.
# After the item is stolen and you try to steal from the event again, it will
# trigger it's unavailable message, unless the item has been refreshed.
# The default messages can be adjusted in the config.
#
# Self Switches:
# Instead of the default messages appearing you can use the self switches and
# use your own custom messages, or other actions. The self switches activated
# by different processes can be adjusted in the config.
#
# The defaults for both messages and self switches can be set up in the config
# below but can be changed by adding to the item initialisation script call:

# Steal.whatever(event,id,amount,MESSAGE,SWITCH)
# see Items for a description of the script call.
#
# Eg. Steal.gold(5,100,200,false,true) Will deactivate the message and only
# activate the events self switch. You can activate both at the same time
# if you wish.
#
# Items:
# The items held by the event need to be initialised by using a script call,
# the easiest way to do this is place the call script in an autorun event.
# The call scripts are as follows:
#
# Steal.gold(EVENT,AMOUNT)
# Adds gold to the event
#          or
# Steal.gold(EVENT,AMOUNT_MINIMUM,AMOUNT_MAXIMUM)
# Adds random gold to the event
#          or
# Steal.gold(EVENT)
# See custom gold stealing for deatails
#
# Steal.item(EVENT,ID,AMOUNT)
# Adds items to the event
#
# Steal.weapon(EVENT,ID,AMOUNT)
# Adds weapons to the event
#
# Steal.armor(EVENT,ID,AMOUNT)
# Adds armor to the event
#
# EVENT is the event id on the current map
# ID is the id of the item/weapon/armor in the database
# AMOUNT is the amount of the gold/item/weapon/armor the event has
# For gold a random number between AMOUNT_MINIMUM and AMOUNT_MAXIMUM is chosen
# if using the second script call.
#
# Item Refreshing:
# Using the timer from ATES you are able to refresh the items the event has
# every day. This feature can be enabled/disabled in the configuration. You can
# also manually refresh the item of the event using the call script.
#
# Steal.refresh(EVENT)
# EVENT is the event id on the current map
#
# Leveling:
# The higher your level in thievery, the more gold you recieve from stealing.
# Every time you steal from an event you gain an experience point towards your
# level. The Breaks in the levels can be set up in the config, every time your
# exp is equal to a value in the config, you will level up.
#
# You can also call leveling with the script calls
#
# Steal.experience(AMOUNT)
# adds the AMOUNT to the experience, cannot be negative.
#
# Steal.level(AMOUNT)
# adds the AMOUNT to the level, can be negative for deleveling.
#
# Steal.set_level(LEVEL)
# set level to chosen LEVEL
#
# There are three choices for the amount of gold recieved from leveling up.
#
# ADDITION: a set amount of gold is added per level.
# Eg. with addition of 100g.
# Lvl 1 = 50g, Lvl 2 = 50+100 = 150g, Lvl 3 = 50+200 = 250g ect.
#      
# MULTIPLICATION: gold recieved is multiplied by your level
# Eg. Lvl 1 = 50g, Lvl 2 = 50*2 = 100g, Lvl 3 = 50*3 = 150g ect.
#
# CUSTOM: A user selected amount is chosen to be recieved each level
# When using custom make your script call Steal.golf(EVENT)
# It disregards amounts when type is custom.
# Eg. Lvl 1 = 50g to 100g, Lvl 2 = 120g to 180g
#
# Leveling can be enabled/disabled in the config
#
# In-Game Variables:
# In the config you can choose whether you would like game variables to
# represent the stealing level and your current experience, and experience to
# the next level. These can then be used in messages/eventing ect.
# You can also also reference them for scripting using the following variables:
#
# $game_player.steal_level        for the level
# $game_player.steal_exp          for the experience
# $game_player.steal_next         for the experience to next level
#
# Don't adjust these values manually as the other variables will not scale
# accordingly. Use the script calls in Leveling.
#
#===============================================================================

module Steal
  
#===============================================================================
# Begin Configuration
#===============================================================================

  #Input button to steal
  STEAL_KEY = Input::X          #Defaults as A key on the keyboard
  #default congifuration for messages display/switch activation
  MESSAGE = true
  SWITCH = false
  #Set true to only be able to steal from the back, false for any direction
  BACK = true
  #Choose what you want your stealing messages to say.
  SUCCESS_MESSAGE_BEGIN = "You Succesfully Steal:"
  SUCCESS_MESSAGE_END = "Score!"
  FAIL_MESSAGE = "I can't steal from here.\nThey will notice me."
  UNAVAILABLE_MESSAGE = "This person doesn't have an item\ni can steal."
  LVL_MESSAGE = "Congratulations!\nYour Thief skill is now level "
  #Set the self switches you want to activate by stealing
  SUCCESS_SWITCH = 'B'
  FAIL_SWITCH = 'C'
  UNAVAILABE_SWITCH = 'D'
  #Set the breaks for levels here
  #Type 0 = set, Every time experience is equal to a level in the
  #STEAL_LEVEL you will level up eg. level 2 = 5exp , level 3 = 10exp
  #Type 1 = addition, Level breaks will be added consecutively
  #eg. level 2 = 5 exp , level 3 = 5+10 = 15exp, level 4 = 15+20 = 35exp
  LEVELING = true      #true if leveling is allowed, false if not
  BREAK_TYPE = 0
  STEAL_LEVEL = [0,5,10,20,35,50,75,100,140,200] #0 must be first value
  #Set the gold gain leveling type
  LEVEL_TYPE = 0        #Addition = 0, Multiplication = 1, Custom = 2
  ADDITION = 100        #the amount for addition
  #set the amount of gold recieved per level for custom leveling
  #The amount of levels must equal the amount of level breaks otherwise it
  #will not work.
  CUSTOM = [            #These amounts will only apply to custom leveling
           [50,105],    #level 1
           [125,255],   #level 2
           [283,334],   #level 3
           [350,465],   #level 4
           [550,664],   #level 5
           [680,763],   #level 6
           [794,875],   #level 7
           [896,954],   #level 8
           [990,1050],  #level 9
           [1070,1250]  #level 10
           ]
  #set whether or not you want the exp/level/next as a game variables and which
  LEVEL_USE = false
  EXP_USE = false
  NEXT_USE = false
  LEVEL_VARIABLE = 1
  EXP_VARIABLE = 2
  NEXT_VARIABLE = 3
  #choose whether or not you want to enable item refreshing after each day.
  #Requires ATES
  REFRESH_ENABLE = true

#===============================================================================
# End Configuration
#===============================================================================
  
  #Config error handling
  if LEVELING && LEVEL_TYPE == 2 && CUSTOM.size != STEAL_LEVEL.size
    raise 'The amount of levels must be equal in both CUSTOM and STEAL_LEVEL for custom gold gain'
  end
  if LEVELING && STEAL_LEVEL[0] != 0
    raise 'first variable in STEAL_LEVEL must be 0'
  end

  def self.do
    #return if there is no event in front of you
    return if $game_map.front == nil
    #id is the event in front of you
    id = $game_map.front
    #return if that event has no item
    return if $game_map.events[id].steal_item == 0
    #If item is stolen or not refreshed
    if $game_map.events[id].stolen #Unavailable
      #don't turn toward the player
      $game_map.events[id].direction = $game_map.events[id].old_direction
      #show fail text if message is true
      $game_temp.message_text = UNAVAILABLE_MESSAGE if $game_map.events[id].steal_message
      #activate switch if switch is true
      self.switch(id,UNAVAILABLE_SWITCH) if $game_map.events[id].steal_switch
    elsif $game_player.direction == $game_map.events[id].old_direction && BACK #Success
      #don't turn toward the player
      $game_map.events[id].direction = $game_map.events[id].old_direction
      #steal from that event
      $game_map.events[id].steal
      #print steal message if message is true
      self.steal_message(id) if $game_map.events[id].steal_message
      #activate switch if switch is true
      self.switch(id,SUCCESS_SWITCH) if $game_map.events[id].steal_switch
    elsif BACK == false #Success
      #don't turn toward the player
      $game_map.events[id].direction = $game_map.events[id].old_direction
      #steal from that event
      $game_map.events[id].steal
      #print steal message if message is true
      self.steal_message(id) if $game_map.events[id].steal_message
      #activate switch if switch is true
      self.switch(id,SUCCESS_SWITCH) if $game_map.events[id].steal_switch
    else #Fail
      #turn toward player
      $game_map.events[id].turn_toward_player
      #show fail text if message is true
      $game_temp.message_text = FAIL_MESSAGE if $game_map.events[id].steal_message
      #activate the switch if switch is true
      self.switch(id,FAIL_SWITCH) if $game_map.events[id].steal_switch
    end      
  end

  def self.switch(id,switch)
    key = [$game_map.map_id,id,switch]
    #activate the switch
    $game_self_switches[key] = true
    #refresh the map
    $game_map.need_refresh = true
  end
  
  def self.steal_message(id)
    #case for type
    case $game_map.events[id].steal_item[0]
    when 0 #Gold
      type = $data_system.words.gold.to_s
    when 1 #Item
      type = $data_items[$game_map.events[id].steal_item[1]].name
    when 2 #Weapon
      type = $data_weapons[$game_map.events[id].steal_item[1]].name
    when 3 #Armor
      type = $data_armors[$game_map.events[id].steal_item[1]].name
    end
    #plural check
    s = ($game_map.events[id].steal_item[2] == 1 ? "" : "s")
    s = "" if $game_map.events[id].steal_item[0] == 0
    #if type is gold
    if $game_map.events[id].steal_item[0] == 0
      #display gold amount
      amount = $game_map.events[id].gold.to_s
    else
      #display normal amount
      amount = $game_map.events[id].steal_item[2].to_s
    end
    #show success text
    $game_temp.message_text = SUCCESS_MESSAGE_BEGIN + "\n" + amount + " " +
                              type + s + "\n" + SUCCESS_MESSAGE_END
    #show leveled text if leveled and not initially
    if $game_player.steal_leveled == true && $game_player.steal_exp != 1
      $game_temp.message_text = LVL_MESSAGE + $game_player.steal_level.to_s
    end
  end
  #Set the steal item of the event to [type,id,amount]
  #type 0 = gold, 1 = item, 2 = weapon, 3 = armor
  #id = id in the database
  #amount/min/max = amount of that item stolen
  def self.gold(event,amount_min = -1,amount_max = -1,message = MESSAGE,switch = SWITCH)
    $game_map.events[event].steal_item = [0,amount_min,amount_max]
    $game_map.events[event].steal_message = message
    $game_map.events[event].steal_switch = switch
  end
  
  def self.item(event,id,amount,message = MESSAGE,switch = SWITCH)
    $game_map.events[event].steal_item = [1,id,amount]
    $game_map.events[event].steal_message = message
    $game_map.events[event].steal_switch = switch
  end
  
  def self.weapon(event,id,amount,message = MESSAGE,switch = SWITCH)
    $game_map.events[event].steal_item = [2,id,amount]
    $game_map.events[event].steal_message = message
    $game_map.events[event].steal_switch = switch
  end
    
  def self.armor(event,id,amount,message = MESSAGE,switch = SWITCH)
    $game_map.events[event].steal_item = [3,id,amount]
    $game_map.events[event].steal_message = message
    $game_map.events[event].steal_switch = switch
  end
  
  #refresh the events item
  def self.refresh(event)
    $game_map.events[event].stolen = false
  end
  
  def self.exp(exp)
    return if exp < 0
    for i in 0...exp
      $game_player.steal_exp += 1
      $game_player.update
    end
  end
    
  def self.level(level)
    #add the level
    $game_player.steal_level += level
    #if level is greater then the maximum level
    if $game_player.steal_level > (STEAL_LEVEL.size - 1)
      #set the level to maximum level
      $game_player.steal_level = (STEAL_LEVEL.size - 1)
    end
    #if level is less then minimum level
    if $game_player.steal_level < 1
      #set level to minimum level
      $game_player.steal_level = 1
    end
    #adjust other variables accordingly
    $game_player.steal_exp = STEAL_LEVEL[$game_player.steal_level - 1]
    $game_player.leveled = true
    $game_player.steal_flag = $game_player.steal_exp    
  end
  
  def self.set_level(level)
    #set the level
    $game_player.steal_level = level
    #if level is greater then the maximum level
    if $game_player.steal_level > (STEAL_LEVEL.size - 1)
      #set the level to maximum level
      $game_player.steal_level = (STEAL_LEVEL.size - 1)
    end
    #if level is less then minimum level
    if $game_player.steal_level < 1
      #set level to minimum level
      $game_player.steal_level = 1
    end
    #adjust other variables accordingly
    $game_player.steal_exp = STEAL_LEVEL[$game_player.steal_level - 1]
    $game_player.leveled = true
    $game_player.steal_flag = $game_player.steal_exp
  end
end

#===============================================================================
# Game_Event
#===============================================================================

class Game_Event < Game_Character
  attr_accessor :steal_item
  attr_accessor :stolen
  attr_accessor :stolen_time
  attr_accessor :direction
  attr_accessor :old_direction
  attr_accessor :gold
  attr_accessor :steal_message
  attr_accessor :steal_switch
  alias max_steal_initialize_later initialize
  alias max_steal_update_later update
  def initialize( *args )
    max_steal_initialize_later( *args )
    #add the stealing variables to the event
    @steal_item = 0
    @stolen = false
    @stolen_time = 0
    @old_direction = 2
    @gold = 0
    @steal_message = Steal::MESSAGE
    @steal_switch = Steal::SWITCH
  end
  
  def steal
    #if the event has an item that isn't stolen
    if @steal_item != 0 && !@stolen
      #case for the type
      case @steal_item[0]
      when 0 #gold
        #if no maximum specified
        if @steal_item[2] == -1 #normal gold
          @gold = @steal_item[1]
        #if no mimimum specified
        elsif @steal_item[1] == -1 #custom gold
          x = Steal::Custom[$game_player.steal_level][0]
          y = Steal::Custom[$game_player.steal_level][1]
          @gold = x + rand(y - x)          
        else #random gold
          @gold = @steal_item[1] + rand(@steal_item[2] - @steal_item[1])
        end
        case Steal::LEVEL_TYPE
        when 0 #Addition
          $game_party.gain_gold(@gold +
          (Steal::ADDITION * ($game_player.steal_level-1)))
        when 1 #Multiplication
          $game_party.gain_gold(@gold * $game_player.steal_level)
        when 2 #Custom
          $game_party.gain_gold(@gold)
        end
      when 1 #item
        #add item id, amount
        $game_party.gain_item(@steal_item[1],@steal_item[2])
      when 2 #weapon
        #add weapon id, amount
        $game_party.gain_weapon(@steal_item[1],@steal_item[2])
      when 3 #armor
        #add armor id, amount
        $game_party.gain_armor(@steal_item[1],@steal_item[2])
      end
      #activate the stolen variable
      @stolen = true
      #put the time at which the item was stolen into a variable
      @stolen_time = [$game_system.ates.time.min - 1, $game_system.ates.time.hour]
      #VValkingman's check for negative numbers in the minute and hour;)  
      if @stolen_time[0] < 0
        @stolen_time[0] = 59
        @stolen_time[1] -= 1
        if @stolen_time[1] < 0
          @stolen_time[1] = 23
        end
      end
      #increment amount of steals
      $game_player.steal_exp += 1
    end
  end
    
  def update
    #if ates is right version and refresh is enabled
    if $ates >= 0.4 && Steal::REFRESH_ENABLE
      #check if ates time is the stolen time and item is stolen
      if $game_system.ates.time.min == @stolen_time[0] &&
         $game_system.ates.time.hour == @stolen_time[1] && @stolen
        #reset stolen variables
        @stolen = false
        @stolen_time = 0
      end
    end
    #update the old direction variable
    @old_direction = @direction
    max_steal_update_later
  end
end

#===============================================================================
# Game_player
#===============================================================================

class Game_Player < Game_Character
  attr_accessor :steal_level
  attr_accessor :steal_exp
  attr_accessor :steal_leveled
  attr_accessor :steal_flag
  attr_accessor :steal_next
  alias max_steal_initialize_later initialize
  alias max_steal_update_later update
  def initialize
    @steal_level = 1
    @steal_exp = 0
    @steal_leveled = true
    @steal_flag = 0
    #if break type is addition
    if Steal::BREAK_TYPE == 1
      x = 0
      for i in 0...Steal::STEAL_LEVEL.size
        x += Steal::STEAL_LEVEL[i]
        @level_array[i] = x
      end
    else #if break type is set
      @level_array = Steal::STEAL_LEVEL
    end
    @steal_next = @level_array[@steal_level] - @steal_exp
    max_steal_initialize_later
  end
  
  def update
    max_steal_update_later
    #only level if allowed
    if Steal::LEVELING
      #if you recieve experience, allow leveling
      if @steal_flag != @steal_exp
        @steal_leveled = false
      end
      #level up when level is equal to a value in STEAL_LEVEL
      if @level_array.include?(@steal_exp) && !@steal_leveled
        @steal_level += 1
        @steal_leveled = true
        @steal_flag = @steal_exp
        #if at last level
        if @steal_level == (@level_array.size - 1)
          @steal_next = 0
        else
          @steal_next = @level_array[@steal_level] - @steal_exp
        end
      end
    end
    #If experience variable is used
    if Steal::EXP_USE
      #update the experience variable
      $game_variables[Steal::EXP_VARIABLE] = @steal_exp
    end
    #If level variable is used
    if Steal::LEVEL_USE
      #update the level variable
      $game_variables[Steal::LEVEL_VARIABLE] = @steal_level
    end
    #If level variable is used
    if Steal::NEXT_USE
      #update the exp to next level variable
      $game_variables[Steal::NEXT_VARIABLE] = @steal_next
    end
    #If not moving
    unless moving?
      #If Steal button was pressed
      if Input.trigger?(Steal::STEAL_KEY)
        #Steal from the event in front of you
        Steal.do
      end
    end
  end
end

#===============================================================================
# Game_Map
#===============================================================================

class Game_Map
  #return the event id of the event in front of you
  def front
    #direction of the player
    d = $game_player.direction
    #coords of the space in front of you
    x = $game_player.x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    y = $game_player.y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    #id of the event
    id = check_event(x,y)
    #return nil if there is no event there
    return nil if id.instance_of?(Array)
    #return the event id
    return id
  end
end

#===============================================================================
# ATES Modification
#===============================================================================

#Modified to update the map every minute to create a realistic time advancement.
#Time now always progresses forward from script calls instead of back and forth.

module ATES
  def self.advance(m = 1, h = 0)
    #if ates doesn't exist or wrong version
    if $ates == nil || $ates < 0.4
      raise 'you need ATES v0.4 or higher to use this method'
      return
    end
    return false if m < 0 || h < 0
    #create a variable
    hour = $game_system.ates.time.hour
    min = $game_system.ates.time.min
    #loop for the hours
    for i in 0..h
      #if not the last hour, use 60 minutes
      new_m = (i == h ? m : 60)
      #loop for the new minutes
      for j in 0..new_m
        #create a new variable for the loop
        new_hour = (hour + i) % 24
        new_min = min + j
        #increase hour and reset if min = 60
        new_hour += 1 if new_min > 59
        new_hour = 0 if new_hour == 24
        #modulus the minute
        new_min %= 60
        #update the actual hour/minute
        $game_system.ates.time.hour = new_hour
        $game_system.ates.time.min = new_min
        #refresh the map
        $game_map.update
      end
    end
    return true
  end
  
  def self.make_it_day
    #increase minutes to 60 (or 0)
    min = 60 - $game_system.ates.time.min
    #increase hour to day start
    hour = DAY_START - $game_system.ates.time.hour - 1
    #subtract from 24 if negative
    hour += 24 if hour < 0
    #advance to day start
    ATES.advance(min,hour)
    return true
  end
  
  def self.make_it_night
    #increase minutes to 60 (or 0)
    min = 60 - $game_system.ates.time.min
    #increase hour to night start
    hour = NIGHT_START - $game_system.ates.time.hour - 1
    #subtract from 24 if negative
    hour += 24 if hour < 0
    #advance to night start
    ATES.advance(min,hour)
    return true
  end
end
vvalkingman
Yea I knew there was probably an easier way to write it all out but its been awhile laugh.gif btw I just gave the code a run and it's giving me -1 gold every time even after I level up the pickpocketing. The configuration looks right...but I could be wrong lol Here's a demo of what I've got:

http://www.mediafire.com/?1m6jwgf691q18kf

Also, just a side note it's no big deal but is there a way for them not to turn around and respond when I steal from them? I press X, steal an amount of gold and they turn like "oh hey there" lol just curious smile.gif Thanks again for all your help, big guy!

edit: Just to clarify, LEVEL_TYPE is set to custom(2) and I'm calling an autorun steal.gold(5). I'll look through the code and see if I can find the reason.
maximusmaxy
Yeah those problem's where an easy fix, i posted the code without doing any bug testing at all, thats always a bad idea wink.gif I'm still working on being able to steal across different maps, so when i fix that i'll post the updated code.
vvalkingman
laugh.gif easy to fix eh? Not like I've been trying to figure it out since yesterday or anything...haha but yea its all good. Once you're finished I'm sure this script is going to be all the rage. Don't forget to post it in submissions after all this. Also be sure and look for your name in my game's credits under badass scripters wink.gif
maximusmaxy
Ok, ALMOST DONE, i have one final problem, and yes it is the stolen items not updating properly. I've half finished the problem(you can steal from events on other maps.) but when you change maps there stolen variable gets refreshed, I've tried a couple of things to fix the problem but none of them have worked. I still got a few things up my sleeve though so i will try them tomorrow. I fixed the message system though, by using a dialogue system though, i think it works pretty nicely.

EDIT:Last one was pretty buggy, fixed all the spelling errors i could find, the script calls now work, sound effects applied, made it more aesthetically pleasing.

here is the link
maximusmaxy
Ok i think i have everything figured out laugh.gif I got it almost perfect! except that the items refresh at midnight each night(actually 23:59) other than every 24 hours for each person, which is still pretty good. If i ever figure out how to do it the 24 hour way i'll put it in a future update. While playing around with it i got some more idea's i want to implement which i may work on later. This is probably the last update i'll post in this thread, I'll post future updates in the script submission thread so if a mod wants to lock this topic feel free to do so.

here is the link and here is the script.

CODE
#===============================================================================
# Stealing System
# Author: Maximusmaxy
# Version: 1.0
# Thanks to:
# VValkingman - For requesting it & adding his two cents to the script
# Blizzard - For the Advanced Time and Environment System (ATES)
# Zeriab - For the dialogue system
#===============================================================================
# Version 0.5a 8/9/2011
# Version 0.9 9/9/2011
# Version 0.9.5 10/9/2011
# Version 0.9.6 11/9/2011
# Version 0.9.8a 13/9/2011
# Version 1.0 14/9/2011
#===============================================================================
#
# NOTE: Some of the features have been written to work with Advanced Time and
# Environment System (ATES) by Blizzard and Dialogue System by Zeriab and will
# not work without them.
#
# BIGGER NOTE: MUST be placed under the required scripts as it rewrites some of
# there methods.
#
# ATES can be found at the following link:
# http://forum.chaos-project.com/index.php?topic=710.0
#
# Dialogue System can be found at the following link:
# http://forum.chaos-project.com/index.php/topic,64.0.html
#
#=============================Instructions======================================
#
# Stealing:
# To attempt to steal from an event use the input button specified in the config
#
# Messages:
# To steal from an event you must be facing it's back otherwise the event will
# notice you, or in other words it will activate it's fail message. If the
# steal is successful it will activate the events success message, and the
# item the event is holding will be added to your inventory. Back stealing can
# be turned off in the configuration, so you can steal from any direction.
# After the item is stolen and you try to steal from the event again, it will
# trigger it's unavailable message, unless the item has been refreshed.
# The default messages can be adjusted in the config.
#
# Self Switches:
# Instead of the default messages appearing you can use the self switches and
# use your own custom messages, or other actions. The self switches activated
# by different processes can be adjusted in the config.
#
# The defaults for both messages and self switches can be set up in the config
# below but can be changed by adding to the item initialisation script call:

# Steal.whatever(event,id,amount,MESSAGE,SWITCH)
# see Items for a description of the script call.
#
# Eg. Steal.gold(5,100,200,false,true) Will deactivate the message and only
# activate the events self switch. You can activate both at the same time
# if you wish but this is not recomended for 2 messages at the same time.
#
# Items:
# The items held by the event need to be initialised by using a script call,
# the easiest way to do this is place the call script in a parallel process.
# The call scripts are as follows:
#
# Steal.gold(EVENT,AMOUNT)
# Adds gold to the event
#          or
# Steal.gold(EVENT,AMOUNT_MINIMUM,AMOUNT_MAXIMUM)
# Adds random gold to the event
#          or
# Steal.gold(EVENT)
# See custom gold stealing for deatails
#
# Steal.item(EVENT,ID,AMOUNT)
# Adds items to the event
#
# Steal.weapon(EVENT,ID,AMOUNT)
# Adds weapons to the event
#
# Steal.armor(EVENT,ID,AMOUNT)
# Adds armor to the event
#
# Steal.nothing(EVENT,MESSAGE,SWITCH)
# Makes the event available to be triggered by stealing from it, useful for
# custom situations using self switches.
#
# EVENT is the event id on the current map
# ID is the id of the item/weapon/armor in the database
# AMOUNT is the amount of the gold/item/weapon/armor the event has
# For gold a random number between AMOUNT_MINIMUM and AMOUNT_MAXIMUM is chosen
# if using the second script call.
# MESSAGE and SWITCH can be added to any of the script calls to add there
# functionality to them eg. Steal.gold(5,-1,-1,false,true) can be used for
# custom gold and self switches will be triggered instead of the messages.
#
# Item Refreshing:
# Using the timer from ATES you are able to refresh the items the event has
# every day. This feature can be enabled/disabled in the configuration. You can
# also manually refresh the item of the event using the call script.
#
# Steal.refresh(EVENT)
# EVENT is the event id on the current map
#
# Leveling:
# The higher your level in thievery, the more gold you recieve from stealing.
# Every time you steal from an event you gain an experience point towards your
# level. The Breaks in the levels can be set up in the config, every time your
# exp is equal to a value in the config, you will level up.
#
# You can also call leveling with the script calls
#
# Steal.exp(AMOUNT)
# adds the AMOUNT to the experience, cannot be negative.
#
# Steal.level(AMOUNT)
# adds the AMOUNT to the level, can be negative for deleveling.
#
# Steal.set_level(LEVEL)
# set level to chosen LEVEL
#
# There are three choices for the amount of gold recieved from leveling up.
#
# ADDITION: a set amount of gold is added per level.
# Eg. with addition of 100g.
# Lvl 1 = 50g, Lvl 2 = 50+100 = 150g, Lvl 3 = 50+200 = 250g ect.
#
# MULTIPLICATION: gold recieved is multiplied by your level
# Eg. Lvl 1 = 50g, Lvl 2 = 50*2 = 100g, Lvl 3 = 50*3 = 150g ect.
#
# CUSTOM: A user selected amount is chosen to be recieved each level
# When using custom make your script call Steal.gold(EVENT)
# It disregards amounts when type is custom.
# Eg. Lvl 1 = 50g to 100g, Lvl 2 = 120g to 180g
#
# Leveling can be enabled/disabled in the config
#
# In-Game Variables:
# In the config you can choose whether you would like game variables to
# represent the stealing level and your current experience, and experience to
# the next level. These can then be used in messages/eventing ect.
# You can also also reference them for scripting using the following variables:
#
# $game_party.steal_level        for the level
# $game_party.steal_exp          for the experience
# $game_party.steal_next         for the experience to next level
#
# Don't adjust these values manually as the other variables will not scale
# accordingly. Use the script calls in Leveling.
#
# Compatabillity:
# This script would be incompatable with other time/clock based systems, and
# is only compatable with ATES. If the key for stealing conflicts with the
# key of another script just change it in the configuration. It may also
# conflict with scripts that deal heavily with events, such as an ABS.
#
#===============================================================================

module Steal
  
#===============================================================================
# Begin Configuration
#===============================================================================

  #Input button to steal
  STEAL_KEY = Input::X          #Defaults as A key on the keyboard
  
  #default congifuration for messages display/switch activation
  MESSAGE = true
  SWITCH = false
  
  #Set true to only be able to steal from the back, false for any direction
  BACK = true
  
  #Choose what you want your stealing messages to say. MESSAGE must be true for
  #them to activate, but this can also be changed in the script call.
  SUCCESS_MESSAGE1 = 'You Succesfully Steal:'
  SUCCESS_MESSAGE3 = 'Score!'
  FAIL_MESSAGE1 = 'I can''t steal from here.'
  FAIL_MESSAGE2 = 'They will notice me.'
  FAIL_MESSAGE3 = 'I should try again from behind.'
  UNAVAILABLE_MESSAGE1 = 'This person doesn''t have anything i can'
  UNAVAILABLE_MESSAGE2 = 'steal. I should try again later.'
  UNAVAILABLE_MESSAGE3 = ''
  
  #Set the self switches you want to activate by stealing. SWITCH must be true
  #for them to activate, but this can also be changed in the script call.
  SUCCESS_SWITCH = 'B'
  FAIL_SWITCH = 'C'
  UNAVAILABLE_SWITCH = 'D'
  
  #Set the breaks for levels here
  #Type 0 = set, Every time experience is equal to a level in the
  #STEAL_LEVEL you will level up eg. level 2 = 5exp , level 3 = 10exp
  #Type 1 = addition, Level breaks will be added consecutively
  #eg. level 2 = 5 exp , level 3 = 5+10 = 15exp, level 4 = 15+20 = 35exp
  LEVELING = true       #true if leveling is allowed, false if not
  BREAK_TYPE = 1        #Set = 0, Addition = 1
  STEAL_LEVEL = [0,5,10,20,35,50,75,100,140,200] #0 must be first value
  
  #Set the gold gain leveling type
  LEVEL_TYPE = 2        #Addition = 0, Multiplication = 1, Custom = 2
  ADDITION = 100        #the amount for addition
  
  #set the amount of gold recieved per level for custom leveling
  #The amount of levels must equal the amount of level breaks otherwise it
  #will not work.
  CUSTOM = [            #These amounts will only apply to custom leveling
           [50,105],    #level 1
           [125,255],   #level 2
           [283,334],   #level 3
           [350,465],   #level 4
           [550,664],   #level 5
           [680,763],   #level 6
           [794,875],   #level 7
           [896,954],   #level 8
           [990,1050],  #level 9
           [1070,1250]  #level 10
           ]
          
  #set whether or not you want the exp/level/next as in-game variables and which
  LEVEL_USE = true
  EXP_USE = true
  NEXT_USE = true
  LEVEL_VARIABLE = 1
  EXP_VARIABLE = 2
  NEXT_VARIABLE = 3
  
  #choose whether or not you want to enable item refreshing after each day.
  #Requires ATES
  REFRESH_ENABLE = true

#===============================================================================
# End Configuration
#===============================================================================
  
  #Config error handling
  if LEVELING && LEVEL_TYPE == 2 && CUSTOM.size != STEAL_LEVEL.size
    raise 'The amount of levels must be equal in both CUSTOM and STEAL_LEVEL for custom gold gain'
  end
  if LEVELING && STEAL_LEVEL[0] != 0
    raise 'first variable in STEAL_LEVEL must be 0'
  end

  def self.do
    #return if there is no event in front of you
    return if $game_map.front == nil
    #id is the event in front of you
    id = $game_map.front
    #return if that event has no item
    return if $game_map.events[id].steal_item == 0
    #don't turn toward the player
    $game_map.events[id].direction = $game_map.events[id].old_direction
    #If item is stolen or not refreshed
    if $game_map.stolen[id] #Unavailable
      #play cancel sound effect
      $game_system.se_play($data_system.cancel_se)
      #show fail text if message is true
      self.steal_unavailable(id) if $game_map.events[id].steal_message
      #activate switch if switch is true
      self.switch(id,UNAVAILABLE_SWITCH) if $game_map.events[id].steal_switch
    elsif ($game_player.direction == $game_map.events[id].old_direction &&
           BACK) || !BACK #Success
      #steal from that event
      $game_map.events[id].steal
      #update the variables
      $game_party.update
      #print steal message if message is true
      self.steal_success(id) if $game_map.events[id].steal_message
      #activate switch if switch is true
      self.switch(id,SUCCESS_SWITCH) if $game_map.events[id].steal_switch
    else#Fail
      #play cancel sound effect
      $game_system.se_play($data_system.cancel_se)
      #show fail text if message is true
      self.steal_fail(id) if $game_map.events[id].steal_message
      #activate the switch if switch is true
      self.switch(id,FAIL_SWITCH) if $game_map.events[id].steal_switch
    end      
  end

  def self.switch(id,switch)
    key = [$game_map.map_id,id,switch]
    #activate the switch
    $game_self_switches[key] = true
    #refresh the map
    $game_map.need_refresh = true
  end
  
  def self.steal_success(id)
    #case for type
    case $game_map.events[id].steal_item[0]
    when 0 #Gold
      type = $data_system.words.gold.to_s
    when 1 #Item
      type = $data_items[$game_map.events[id].steal_item[1]].name
    when 2 #Weapon
      type = $data_weapons[$game_map.events[id].steal_item[1]].name
    when 3 #Armor
      type = $data_armors[$game_map.events[id].steal_item[1]].name
    when 4 #Nothing
      type = ''
    end
    #plural check
    s = ($game_map.events[id].steal_item[2] == 1 ? "" : "s")
    s = "" if $game_map.events[id].steal_item[0] == 0 ||
              $game_map.events[id].steal_item[0] == 4
    #if type is gold
    if $game_map.events[id].steal_item[0] == 0
      #display gold amount
      amount = $game_map.events[id].gold.to_s
    elsif $game_map.events[id].steal_item[0] == 4
      #display nothing
      amount = 'Nothing!'
    else
      #display normal amount
      amount = $game_map.events[id].steal_item[2].to_s
    end
    #show success text
    a = SUCCESS_MESSAGE1
    b = amount + " " + type + s
    c = SUCCESS_MESSAGE3
    Dialog_Steal.show(a,b,c,true)
  end
  
  def self.steal_fail(id)
    #show the fail message
    a = FAIL_MESSAGE1
    b = FAIL_MESSAGE2
    c = FAIL_MESSAGE3
    Dialog_Steal.show(a,b,c,false)
  end
  
  def self.steal_unavailable(id)
    #show the unavailable message
    a = UNAVAILABLE_MESSAGE1
    b = UNAVAILABLE_MESSAGE2
    c = UNAVAILABLE_MESSAGE3
    Dialog_Steal.show(a,b,c,false)
  end
  
  #Set the steal item of the event to [type,id,amount]
  #type 0 = gold, 1 = item, 2 = weapon, 3 = armor
  #id = id in the database
  #amount/min/max = amount of that item stolen
  def self.gold(event,amount_min = -1,amount_max = -1,message = MESSAGE,switch = SWITCH)
    $game_map.events[event].steal_item = [0,amount_min,amount_max]
    $game_map.events[event].steal_message = message
    $game_map.events[event].steal_switch = switch
  end
  
  def self.item(event,id,amount,message = MESSAGE,switch = SWITCH)
    $game_map.events[event].steal_item = [1,id,amount]
    $game_map.events[event].steal_message = message
    $game_map.events[event].steal_switch = switch
  end
  
  def self.weapon(event,id,amount,message = MESSAGE,switch = SWITCH)
    $game_map.events[event].steal_item = [2,id,amount]
    $game_map.events[event].steal_message = message
    $game_map.events[event].steal_switch = switch
  end
    
  def self.armor(event,id,amount,message = MESSAGE,switch = SWITCH)
    $game_map.events[event].steal_item = [3,id,amount]
    $game_map.events[event].steal_message = message
    $game_map.events[event].steal_switch = switch
  end
  
  def self.nothing(event,message = MESSAGE,switch = SWITCH)
    $game_map.events[event].steal_item = [4,-1,-1]
    $game_map.events[event].steal_message = message
    $game_map.events[event].steal_switch = switch
  end    
  
  #refresh the events item
  def self.refresh(event)
    $game_map.stolen[event] = false
  end
  
  def self.exp(exp)
    return if exp < 0
    for i in 0...exp
      #increment the experience and update to check if leveling
      $game_party.steal_exp += 1
      #update the variables
      $game_party.update
    end
  end
    
  def self.level(level)
    #add the level
    $game_party.steal_level += level
    #if level is greater then the maximum level
    if $game_party.steal_level > (STEAL_LEVEL.size)
      #set the level to maximum level
      $game_party.steal_level = (STEAL_LEVEL.size)
    end
    #if level is less then minimum level
    if $game_party.steal_level < 1
      #set level to minimum level
      $game_party.steal_level = 1
    end
    #adjust other variables accordingly
    $game_party.steal_exp = $game_party.level_array[$game_party.steal_level - 1]
    $game_party.steal_leveled = true
    $game_party.steal_flag = $game_player.steal_exp
    #update the variables
    $game_party.update
  end
  
  def self.set_level(level)
    #set the level
    $game_party.steal_level = level
    #if level is greater then the maximum level
    if $game_party.steal_level > (STEAL_LEVEL.size)
      #set the level to maximum level
      $game_party.steal_level = (STEAL_LEVEL.size)
    end
    #if level is less then minimum level
    if $game_party.steal_level < 1
      #set level to minimum level
      $game_party.steal_level = 1
    end
    #adjust other variables accordingly
    $game_party.steal_exp = $game_party.level_array[$game_party.steal_level - 1]
    $game_party.steal_leveled = true
    $game_party.steal_flag = $game_party.steal_exp
    #update the variables
    $game_party.update
  end
end
  
#===============================================================================
# Game_Event
#===============================================================================

class Game_Event < Game_Character
  attr_accessor :steal_item
  attr_accessor :direction
  attr_accessor :old_direction
  attr_accessor :gold
  attr_accessor :steal_message
  attr_accessor :steal_switch
  alias max_steal_initialize_later initialize
  alias max_steal_update_later update
  def initialize( *args )
    max_steal_initialize_later( *args )
    #add the stealing variables to the event
    @steal_item = 0
    @old_direction = 2
    @gold = 0
    @steal_message = Steal::MESSAGE
    @steal_switch = Steal::SWITCH
  end
  
  def steal
    #if the event has an item that isn't stolen
    if @steal_item != 0 && !$game_map.stolen[id]
      #case for the type
      case @steal_item[0]
      when 0 #gold
        #if type is custom
        if Steal::LEVEL_TYPE == 2 #custom gold
          x = Steal::CUSTOM[$game_party.steal_level - 1][0]
          y = Steal::CUSTOM[$game_party.steal_level - 1][1]
          @gold = x + rand(y - x)
        #if no maximum specified
        elsif @steal_item[2] == -1 #normal gold
          @gold = @steal_item[1]
        else #random gold
          @gold = @steal_item[1] + rand(@steal_item[2] - @steal_item[1])
        end
        case Steal::LEVEL_TYPE
        when 0 #Addition
          $game_party.gain_gold(@gold +
          (Steal::ADDITION * ($game_player.steal_level-1)))
        when 1 #Multiplication
          $game_party.gain_gold(@gold * $game_player.steal_level)
        when 2 #Custom
          $game_party.gain_gold(@gold)
        end
      when 1 #item
        #add item id, amount
        $game_party.gain_item(@steal_item[1],@steal_item[2])
      when 2 #weapon
        #add weapon id, amount
        $game_party.gain_weapon(@steal_item[1],@steal_item[2])
      when 3 #armor
        #add armor id, amount
        $game_party.gain_armor(@steal_item[1],@steal_item[2])
      end
      #activate the stolen variable if not nothing
      $game_map.stolen[@id] = true if @steal_item[0] != 4
      #increment steal experience if not nothing
      $game_party.steal_exp += 1 if @steal_item[0] != 4
    end
  end
  
  def update
    max_steal_update_later
    #update the old direction variable
    @old_direction = @direction
  end
end

#===============================================================================
# Game_Party
#===============================================================================

class Game_Party
  attr_accessor :steal_level
  attr_accessor :steal_exp
  attr_accessor :steal_leveled
  attr_accessor :steal_flag
  attr_accessor :steal_next
  attr_reader   :level_array
  alias max_steal_initialize_later initialize
  def initialize
    @steal_level = 1
    @steal_exp = 0
    @steal_leveled = true
    @steal_flag = 0
    @level_array = []
    #if break type is addition
    if Steal::BREAK_TYPE == 1
      x = 0
      for i in 0...Steal::STEAL_LEVEL.size
        x += Steal::STEAL_LEVEL[i]
        @level_array[i] = x
      end
    else #if break type is set
      @level_array = Steal::STEAL_LEVEL
    end
    @steal_next = @level_array[@steal_level] - @steal_exp
    $game_variables[Steal::LEVEL_VARIABLE] = @steal_level if Steal::LEVEL_USE
    $game_variables[Steal::EXP_VARIABLE] = @steal_exp if Steal::EXP_USE
    $game_variables[Steal::NEXT_VARIABLE] = @steal_next if Steal::NEXT_USE
    max_steal_initialize_later
  end
  
  def update
    #only level if allowed
    if Steal::LEVELING
      #if you recieve experience, allow leveling
      if @steal_flag != @steal_exp
        @steal_leveled = false
      end
      #level up when level is equal to a value in STEAL_LEVEL
      if @level_array.include?(@steal_exp) && !@steal_leveled
        #play leveling sound effect
        $game_system.se_play($data_system.shop_se)
        #level up
        @steal_level += 1
        @steal_leveled = true
        @steal_flag = @steal_exp
      else
        #play normal sound effect
        $game_system.se_play($data_system.decision_se)
      end
      #if at last level
      if @steal_level == (@level_array.size)
        @steal_next = nil
      else #update the exp to next level variable
        @steal_next = (@level_array[@steal_level] - @steal_exp)
      end
    end
    #If experience variable is used
    if Steal::EXP_USE
      #update the experience variable
      $game_variables[Steal::EXP_VARIABLE] = @steal_exp
    end
    #If level variable is used
    if Steal::LEVEL_USE
      #update the level variable
      $game_variables[Steal::LEVEL_VARIABLE] = @steal_level
    end
    #If exp to next level variable is used
    if Steal::NEXT_USE
      #update the exp to next level variable
      $game_variables[Steal::NEXT_VARIABLE] = @steal_next
    end
  end
end

#===============================================================================
# Game_Player
#===============================================================================

class Game_Player < Game_Character
  alias max_steal_update_later update
  def update
    max_steal_update_later
    #If not moving
    unless moving?
      #If Steal button was pressed
      if Input.trigger?(Steal::STEAL_KEY)
        #Steal from the event in front of you
        Steal.do
      end
    end
  end
end

#===============================================================================
# Game_Map
#===============================================================================

class Game_Map
  attr_accessor :stolen
  attr_accessor :stolen_min
  attr_accessor :stolen_hour
  alias max_steal_initialize_later initialize
  alias max_steal_update_later update
  def initialize
    max_steal_initialize_later
    #create arrays for storing stolen data from events
    @stolen = []
  end
  
  #return the event id of the event in front of you
  def front
    #direction of the player
    d = $game_player.direction
    #coords of the space in front of you
    x = $game_player.x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    y = $game_player.y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    #id of the event
    id = check_event(x,y)
    #return nil if there is no event there
    return nil if id.instance_of?(Array)
    #return the event id
    return id
  end
  
  def update
    max_steal_update_later
    #if map needs reset
    if $game_system.stolen_maps[@map_id] == 2
      #reset stolen variables
      $game_map.stolen = [nil]
      $game_system.stolen_maps[@map_id] = 0
    end
  end
end

#===============================================================================
# Games_System
#===============================================================================

class Game_System
  attr_accessor :stolen_maps
  alias max_steal_initialize_later initialize
  alias max_steal_update_later update
  def initialize
    max_steal_initialize_later
    #0 = no reset, 1 = stolen from, 2 = need reset
    @stolen_maps = []
    @stolen_maps[1] = 1
  end
  
  def update
    #if ates is right version and refresh is enabled
    if $ates >= 0.4 && Steal::REFRESH_ENABLE
      for i in 0..$game_system.stolen_maps.size
        #check if ates time is midnight and a map is stolen from
        if $game_system.ates.time.hour == 23 &&
           $game_system.ates.time.min == 59 &&
           $game_system.stolen_maps[i] == 1
          #reset stolen variables
          $game_system.stolen_maps[i] = 2
        end
      end
    end
    max_steal_update_later
  end
end

#===============================================================================
# Interpreter
#===============================================================================

class Interpreter
  alias max_command_201_later command_201  
  def command_201
    max_command_201_later
    if @parameters[0] == 0
      #add the map to the stolen maps
      $game_system.stolen_maps[@map_id] = @parameters[1]
    else
      #add the map to the stolen maps
      $game_system.stolen_maps[@map_id] = $game_variables[@parameters[1]]
    end
  end
end

#===============================================================================
# Window_Stealing
#===============================================================================

#Main window for stealing
class Window_Stealing < Window_Base
  def initialize
    super(120, 300, 400, 128)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 200
  end
end

#===============================================================================
# Dialog_steal
# Uses the Dialog System as a framework of printing the stealing messages.
#===============================================================================

class Dialog_Steal < Dialog
  def initialize(text1,text2,text3,level = false)
    #lines of text
    @text1 = text1
    @text2 = text2
    @text3 = text3
    #level window?
    @level = level
  end
  
  def main_window
    #create array for storing disposable windows
    @disposables = []
    #main text window
    @window1 = Window_Stealing.new
    #draw the lines of text
    @window1.contents.draw_text(0,0,480,32,@text1)
    @window1.contents.draw_text(0,32,480,32,@text2)
    @window1.contents.draw_text(0,64,480,32,@text3)
    @window1.z = STARTING_Z_VALUE + 1
    #add to disposables
    @disposables << @window1
    #if steal is successful show the exp/level bar
    if @level && Steal::LEVELING
      @window2 = Window_Help.new
      #if level is at max print MAX as the next experience
      @window2.set_text("Steal Level: #{$game_party.steal_level}" +
      ' '*15 + 'Experience to next level: ' +
      ($game_party.steal_next == nil ? 'MAX' : "#{$game_party.steal_next}"), 0)
      @window2.z = STARTING_Z_VALUE + 1
      #add to disposables
      @disposables << @window2
    end
  end
  
  def main_dispose
    #dispose of all windows
    @disposables.each {|element| element.dispose}
  end
  
  def update
    #if pressing B/C/Steal key, exit the window
    if Input.trigger?(Input::B) || Input.trigger?(Input::C) ||
       Input.trigger?(Steal::STEAL_KEY)
      mark_to_close
    end
  end
end

#===============================================================================
# ATES Modification
# Modified to update the map every minute to create a realistic time advancement
# Time now always progresses forward from script calls instead of back and forth
#===============================================================================

module ATES
  def self.advance(m = 1, h = 0)
    #if ates doesn't exist or wrong version
    if $ates == nil || $ates < 0.4
      raise 'you need ATES v0.4 or higher to use this method'
    end
    return false if m < 0 || h < 0
    #create a variable
    hour = $game_system.ates.time.hour
    min = $game_system.ates.time.min
    #loop for the hours
    for i in 0..h
      #if not the last hour, use 60 minutes
      new_m = (i == h ? m : 60)
      #loop for the new minutes
      for j in 0..new_m
        #create a new variable for the loop
        new_hour = (hour + i) % 24
        new_min = min + j
        #increase hour and reset if min = 60
        new_hour += 1 if new_min > 59
        new_hour = 0 if new_hour == 24
        #modulus the minute
        new_min %= 60
        #update the actual hour/minute
        $game_system.ates.time.hour = new_hour
        $game_system.ates.time.min = new_min
        #update the map and system
        $game_map.update
        $game_system.update
      end
    end
    return true
  end
  
  def self.make_it_day
    #increase minutes to 60 (or 0)
    min = 60 - $game_system.ates.time.min
    #increase hour to day start
    hour = DAY_START - $game_system.ates.time.hour - 1
    #subtract from 24 if negative
    hour += 24 if hour < 0
    #advance to day start
    ATES.advance(min,hour)
    return true
  end
  
  def self.make_it_night
    #increase minutes to 60 (or 0)
    min = 60 - $game_system.ates.time.min
    #increase hour to night start
    hour = NIGHT_START - $game_system.ates.time.hour - 1
    #subtract from 24 if negative
    hour += 24 if hour < 0
    #advance to night start
    ATES.advance(min,hour)
    return true
  end
end


vvalkingman
Works great man, just want to say thank you again for all the help and I look forward to your next script smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.