Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Closed TopicStart new topic
> Stealing System, Steal from events on the map.
maximusmaxy
post Sep 14 2011, 05:59 AM
Post #1


PZE whore
Group Icon

Group: Revolutionary
Posts: 131
Type: Scripter
RM Skill: Skilled




Stealing System

Version 1.1
Author: Maximusmaxy
Release Date: 14/9/11

Introduction
This script allows you to steal from events on the map. You can steal anything from gold to items, to weapons and armour. It utilises Blizzards advanced time and environment system (ATES) to refresh the items each day. It also features a levelling system to receive more gold/items per level.

Features
  • Steal gold/items/weapons/armour
  • Leveling system
  • Message system
  • All the features are highly configurable and easy to use

Instructions
All instructions are in the script and examples are in the demo.

Script
The main script and other required scripts can be found in the demo.
CODE
#===============================================================================
# Stealing System
# Author: Maximusmaxy
# Version: 1.1
# 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
# Version 1.1 18/9/2011
# -fixed bug causing items to not refresh from script calls
# -added script calls to enable/disable stealing
#===============================================================================
#
# 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
# You can enable and disable stealing with the following script calls
#
# Steal.enable
# for enabling
#
# Steal.disable
# for disabling
#
# 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,0,false,true) can be used for
# custom gold and self switches will be triggered instead of the messages.
#
# 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,level,MESSAGE,SWITCH)
# see Items for a description of the script calls.
#
# 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.
#
# 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. For
# key items that you only want to be stolen once, you can add a do not refresh
# flag to the event with the following script add on
#
# Steal.item(event,id,amount,level,message,switch,REFRESH)
# REFRESH can be true or false on whether or not you want the item to refresh
# each day. Defaults as true
#
# 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
#
# Event Levels:
# You can assign a level to the events and you will only be able to steal from
# the event if you have a higher level. Every event is initially assigned a
# level of 0, and will not change unless called for. You can assign a level to
# the event by adding onto the script call like so.
#
# $steal.item(event,id,amount,LEVEL)
# LEVEL is the level of the event
#
# 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
  
  #set to true if stealing is enabled initially, false for disabled initially
  STEAL_ENABLE = true
  
  #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 = ''
  LEVEL_MESSAGE1 = 'My steal level is too low.'
  LEVEL_MESSAGE2 = 'I should come back later when I'
  LEVEL_MESSAGE3 = 'have a higher level.'
  
  #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 = 'A'
  FAIL_SWITCH = 'B'
  UNAVAILABLE_SWITCH = 'C'
  LEVEL_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
    #inialize stolen variable if not already inialised
    $game_map.stolen[id] = 0 if $game_map.stolen[id] == nil
    #If item is stolen or not refreshed
    if $game_map.stolen[id] > 0 #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_party.steal_level < $game_map.events[id].steal_level #level too low
      #play cancel sound effect
      $game_system.se_play($data_system.cancel_se)
      #show level too low text if message is true
      self.steal_level(id) if $game_map.events[id].steal_message
      #activate switch if switch is true
      self.switch(id,LEVEL_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 message
    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
  
  def self.steal_level(id)
    #show the level too low message
    a = LEVEL_MESSAGE1
    b = LEVEL_MESSAGE2
    c = LEVEL_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,level = 0,
                message = MESSAGE,switch = SWITCH,refresh = true)
    $game_map.events[event].steal_item = [0,amount_min,amount_max]
    self.data(event,level,message,switch,refresh)
  end
  
  def self.item(event,id,amount,level = 0,
                message = MESSAGE,switch = SWITCH,refresh = true)
    $game_map.events[event].steal_item = [1,id,amount]
    self.data(event,level,message,switch,refresh)
  end
  
  def self.weapon(event,id,amount,level = 0,
                  message = MESSAGE,switch = SWITCH,refresh = true)
    $game_map.events[event].steal_item = [2,id,amount]
    self.data(event,level,message,switch,refresh)
  end
    
  def self.armor(event,id,amount,level = 0,
                 message = MESSAGE,switch = SWITCH,refresh = true)
    $game_map.events[event].steal_item = [3,id,amount]
    self.data(event,level,message,switch,refresh)
  end
  
  def self.nothing(event,message = MESSAGE,switch = SWITCH)
    $game_map.events[event].steal_item = [4,-1,-1]
    self.data(event,level,message,switch,refresh)
  end
  
  #load the data into the event
  def self.data(event,level,message,switch,refresh)
    $game_map.events[event].steal_level = level
    $game_map.events[event].steal_message = message
    $game_map.events[event].steal_switch = switch
    $game_map.events[event].steal_refresh = refresh
  end
  
  #enable stealing
  def self.enable
    $game_system.steal_enable = true
    #refresh the map
    $game_map.need_refresh = true
  end
  
  #disable stealing
  def self.disable
    $game_system.steal_enable = false
    #refresh the map
    $game_map.need_refresh = true
  end
  
  #refresh the events item
  def self.refresh(event)
    $game_map.stolen[event] = 0
  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
  attr_accessor :steal_level
  attr_accessor :steal_refresh
  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_level = 0
    @steal_message = Steal::MESSAGE
    @steal_switch = Steal::SWITCH
    @steal_refresh = true
  end
  
  def steal
    #if the event has an item that isn't stolen
    if @steal_item != 0 && $game_map.stolen[@id] == 0
      #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
      if @steal_refresh
        #activate the stolen variable if not nothing
        $game_map.stolen[@id] = 1 if @steal_item[0] != 4
      else
        #activate the unrefreshable stolen variable if not nothing
        $game_map.stolen[@id] = 2 if @steal_item[0] != 4
      end
      #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
    #fill in the in game variables if used
    $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.me_play($data_system.battle_end_me)
        #level up
        @steal_level += 1
        @steal_leveled = true
        @steal_flag = @steal_exp
      else
        #play normal sound effect
        $game_system.se_play($data_system.shop_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
    #update the in game variables if used
    $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
  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, stealing enabled and message isn't showing
      if Input.trigger?(Steal::STEAL_KEY) && $game_system.steal_enable &&
        !$game_temp.message_window_showing
        #Steal from the event in front of you
        Steal.do
      end
    end
  end
end

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

class Game_System
  attr_accessor :stolen_maps
  attr_accessor :steal_enable
  alias max_steal_initialize_later initialize
  alias max_steal_update_later update
  def initialize
    max_steal_initialize_later
    #variable for enabling/disabling stealing
    @steal_enable = Steal::STEAL_ENABLE
    #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
          #flag to reset the stolen variables
          $game_system.stolen_maps[i] = 2
        end
      end
    end
    max_steal_update_later
  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
    #0 = not stolen, 1 = stolen, 2 = stolen/unrefreshable
    @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_system.stolen_maps[@map_id] = 1
      for i in 0..$game_map.stolen.size
        #if refreshable/refresh the item
        $game_map.stolen[i] = 0 if $game_map.stolen[i] == 1
      end
    end
  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[@parameters[1]] = 1
    else
      #add the map to the stolen maps
      $game_system.stolen_maps[$game_variables[@parameters[1]]] = 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 = 5001
    #add to disposables
    @disposables << @window1
    #if steal is successful show the exp/level bar
    if @level && Steal::LEVELING
      @window2 = Window_Help.new
      #if leveling
      if $game_party.steal_leveled
        @window2.set_text("Level Up!    Steal Level: #{$game_party.steal_level}" +
        ' ' * 5 + 'Experience to next level: ' +
        ($game_party.steal_next == nil ? 'MAX' : "#{$game_party.steal_next}"), 0)
      else #if not leveling
        #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)
      end
      @window2.z = 5001
      #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

Compatibility
Incompatable with time/clock systems that are not ATES. Should be compatable with everything else.

Screenshot


DEMO
http://www.mediafire.com/?wmmu7kx92m8ou56

Installation
Paste the scripts somewhere above the main, in the order that they are in the demo

Thanks to
VValkingman - For requesting it, testing, debugging and adding his two cents to the script.
Blizzard - For the Advanced Time and Environment System (ATES)
Zeriab - For the dialogue system

This post has been edited by maximusmaxy: Sep 17 2011, 09:08 PM


__________________________
Check out the new PZE Forums! http://zeldaengine.net/index.php
Go to the top of the page
 
+Quote Post
   
vvalkingman
post Sep 14 2011, 10:41 AM
Post #2


The Traveling Bard ;)
Group Icon

Group: Revolutionary
Posts: 210
Type: Developer
RM Skill: Intermediate




Good stuff maximus! Your link for the demo is broken though...


__________________________

Thank you X-M-O for my sexy new banner! ;)

Project I'm currently racking my brain on:
"Modern Witch" Project(tentative name): 5% done
Goshiki: The Five Paths: 40% done

Projects on the backburner:
The Great Thief of Mango City: 5% done
Knights of the Black Gate: 10% done
The Venting: 74% done
Go to the top of the page
 
+Quote Post
   
maximusmaxy
post Sep 14 2011, 11:17 AM
Post #3


PZE whore
Group Icon

Group: Revolutionary
Posts: 131
Type: Scripter
RM Skill: Skilled




Should be fixed now.


__________________________
Check out the new PZE Forums! http://zeldaengine.net/index.php
Go to the top of the page
 
+Quote Post
   
ruiran1
post Mar 21 2012, 11:09 AM
Post #4


Level 1
Group Icon

Group: Member
Posts: 8
Type: Mapper
RM Skill: Skilled




Its not so usefull, i dotn know many games that should work with that not many people have nigth day scripts, and the demo doesnt give anny ideas;
Anny ways good script works perfectly


__________________________
keep low.
Move fast.
Kill first.
Die last.
One shot.
One kill.
No luck.
Pure skill.

one bright morning
late in the night
2 dead boys went out to fight
back to back they faced each other
they pulled out there swords and shot eachother
and if you dont belive my lie is true
ask the blind man he saw it 2



Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 25th May 2013 - 03:46 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker