-
Rude
-
-
Вне сайта
-
Бывалый
-
- Сообщений: 56
- Спасибо получено: 91
-
-
|
Есть скрипт для изменения переключателя события через определенное время.
Немного его переписав сделал все тоже самое, но теперь указываются не секунды, а шаги. Инструкцию не переводил и не менял, но если написано про секунды - имеются в виду [теперь] шаги.
#------------------------------------------------------------------------------#
# Galv's Respawn Timer
#------------------------------------------------------------------------------#
# For: RPGMAKER VX ACE
# Version 1.1
#------------------------------------------------------------------------------#
# 2013-02-24 - Version 1.1 - added script call to purge specified timer
# 2013-02-23 - Version 1.0 - release
#-------------------------------------------------------------------------------
# This script allows you to set respawn timers for events and have them auto-
# matically change a switch or self switch when their timer expires.
#
# As the timer checks are made during the event movements, obviously these
# switches will not be changed until the player gets close enough. This was my
# idea at keeping any lag or checking billions of things at once down. Use the
# other script calls to force check if you require it to work differently.
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# SCRIPT CALL in EVENT script box
#-------------------------------------------------------------------------------
# set_spawn(map_id,event_id,time) # set which map, event and how many seconds
# # before respawn. Setting map or event id
# # to 0 will use current map and event the
# # script call was done in.
#-------------------------------------------------------------------------------
# EXAMPLES:
# set_spawn(1,2,20) # Event 2 on map 1 will respawn in 20 seconds from now
# set_spawn(0,0,200) # The event this call is in will respawn in 200 seconds
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# SCRIPT in a MOVE ROUTE script
#-------------------------------------------------------------------------------
# do_respawn?(switch,status) # This will check if the time is elapsed and
# # if so it will change a switch or self switch
# # to the status (true or false).
#-------------------------------------------------------------------------------
# EXAMPLES:
# do_respawn?("A",false) # Turns self switch A OFF if time elapses
# do_respawn?(1,true) # Turns switch 1 ON if time elapses
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# SCRIPT CALLS in EVENT script box
#-------------------------------------------------------------------------------
# purge_respawn_timers # Remove all activated timers
# purge_timer(map_id,event_id) # Remove specified active timer from list
#
# do_all_respawn(switch,status) # Checks all events with respawn timers and
# # changes all their switches to true or false
#
# do_map_respawn(map_id,switch,status) # Same as above but only for the map
# # you designate with map_id
#
# do_e_respawn(map_id,event_id,switch,status) # Same as above but check a
# # specific event on a map
#
# # These calls can be made anywhere to check and affect those events.
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# SCRIPT for CONTROL VARIABLES
#-------------------------------------------------------------------------------
# respawn_time(map_id,event_id) # Get amount of time left until respawn for
# # an event. Can use 0,0 to check the event
# # and map the control variable is used on.
#-------------------------------------------------------------------------------
class Game_Event < Game_Character
def do_respawn?(switch,status)
return if !$game_system.spawn_timer[[@map_id,@id]]
if $game_party.steps >= $game_system.spawn_timer[[@map_id,@id]]
if switch.is_a?(String)
$game_self_switches[[@map_id, @id, switch]] = status
elsif switch.is_a?(Numeric)
$game_switches[switch] = status
end
$game_system.spawn_timer.delete([@map_id,@id])
end
end
end
class Game_System
attr_accessor :spawn_timer
alias galv_spawn_timer_game_system_initialize initialize
def initialize
@spawn_timer = {}
galv_spawn_timer_game_system_initialize
end
end
class Game_Interpreter
def set_spawn(map_id,event_id,time)
event_id = @event_id if event_id == 0
map_id = $game_map.map_id if map_id == 0
$game_system.spawn_timer[[map_id,event_id]] = $game_party.steps + time
end
def do_all_respawn(switch,status)
# set ALL stored respawn events to do this if timers are up
$game_system.spawn_timer.each { |t|
if $game_party.steps >= t[1]
if switch.is_a?(String)
$game_self_switches[[t[0][0], t[0][1], switch]] = status
elsif switch.is_a?(Numeric)
$game_switches[switch] = status
end
$game_system.spawn_timer.delete(t[0])
end
}
end
def do_map_respawn(map_id,switch,status)
# check all stored respawn events for a MAP to change if timers are up
$game_system.spawn_timer.each { |t|
next if t[0][0] != map_id
if $game_party.steps >= t[1]
if switch.is_a?(String)
$game_self_switches[[t[0][0], t[0][1], switch]] = status
elsif switch.is_a?(Numeric)
$game_switches[switch] = status
end
$game_system.spawn_timer.delete(t[0])
end
}
end
def do_e_respawn(map_id,event_id,switch,status)
# check stored respawn event for a MAP to change if timer is up
$game_system.spawn_timer.each { |t|
next if t[0][0] != map_id
next if t[0][1] != event_id
if $game_party.steps >= t[1]
if switch.is_a?(String)
$game_self_switches[[t[0][0], t[0][1], switch]] = status
elsif switch.is_a?(Numeric)
$game_switches[switch] = status
end
$game_system.spawn_timer.delete(t[0])
end
}
end
def respawn_time(map_id,event_id)
# returns respawn time
event_id = @event_id if event_id == 0
map_id = $game_map.map_id if map_id == 0
if $game_system.spawn_timer[[map_id,event_id]].nil?
return 0
else
return $game_system.spawn_timer[[map_id,event_id]] - $game_party.steps
end
end
def purge_respawn_timers
$game_system.spawn_timer = {}
end
def purge_timer(map_id,event_id)
return if $game_system.spawn_timer[[map_id,event_id]].nil?
$game_system.spawn_timer.delete([map_id,event_id])
end
end
|