Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #======================#
- # Z-Systems by: Zetu #
- #===========================#======================#===========================#
- # * * * Z 21 :: Eventeer v1.01 * * * #
- #=#==========================================================================#=#
- # Version 1.01 #
- # Scripted Event Conditions #
- # * (In Event Comment) Place <bool: *> to add a scripted condition to #
- # event page. #
- # Sprite Offset #
- # * (In Event Comment) Place <x/y += *> to add/subtract displayed x/y #
- # coordinate of page's sprite. #
- # Event Area Expander #
- # * (In Area Name) Place <event ext: *> to cause event id *'s event #
- # trigger (player touch and action button) to be in area, instead of #
- # the event's x/y coordinate. #
- # Self Variable #
- # * Now events can have self variables (not just switches). Use #
- # self_var in script call (or (EVENT).self_var) to access an event's #
- # self variable. #
- #==========================================================================#
- module Z21
- module REGEXP
- BOOL = /<(?:bool|condition)[ :]*(.*)>/i
- OFFSET = /<(x|y)[: ]*(.*)>/i
- AREAEVENT = /<event *ext[: ]*(.*)>/
- end
- end
- class Game_Event
- alias z21conditions_met? conditions_met? unless $@
- def conditions_met?(page)
- return false unless z21regexp_conditions_met?(page)
- return z21conditions_met?(page)
- end
- def z21regexp_conditions_met?(page)
- for line in page.list
- next unless line.code == 108
- line.parameters[0].scan(Z21::REGEXP::BOOL){|condition|
- return false unless eval(condition[0])
- }
- end
- return true
- end
- end
- class Game_Interpreter
- def event
- return $game_map.events[@event_id]
- end
- def self_var
- return event.self_var
- end
- end
- class Game_Event
- def self_var
- return $self_var[@event.id, @map.map_id]
- end
- def self_var=(new_value)
- $self_var[@event.id, @map.map_id] = new_value
- end
- end
- class Game_SelfVariables
- def initialize
- @data = {}
- end
- def [](key)
- return @data[key].nil? ? 0 : @data[key]
- end
- def []=(key, value)
- @data[key] = value
- end
- end
- class Scene_Title < Scene_Base
- alias z21create_game_objects create_game_objects unless $@
- def create_game_objects
- z21create_game_objects
- $self_var = Game_SelfVariables.new
- end
- end
- class Scene_File < Scene_Base
- alias z21write_save_data write_save_data unless $@
- def write_save_data(file)
- z21write_save_data(file)
- Marshal.dump($game_player, file)
- end
- alias z21read_save_data read_save_data
- def read_save_data(file)
- z21read_save_data(file)
- $self_var = Marshal.load(file)
- end
- end
- class Game_Character
- alias z21screen_x screen_x unless $@
- def screen_x
- return z21screen_x + z21_offset_x
- end
- alias z21screen_y screen_y unless $@
- def screen_y
- return z21screen_y + z21_offset_y
- end
- def z21_offset_x
- return 0 unless self.is_a?(Game_Event)
- return z21_offset[0]
- end
- def z21_offset_y
- return 0 unless self.is_a?(Game_Event)
- return z21_offset[1]
- end
- def z21_offset
- param = [0, 0]
- return param if @page.nil?
- for line in @page.list
- next unless line.code == 108
- line.parameters[0].scan(Z21::REGEXP::OFFSET){|matches|
- for match in matches
- case $1.upcase
- when "X"
- param[0] += $2.to_i
- when "Y"
- param[1] += $2.to_i
- end
- end
- }
- end
- return param
- end
- end
- class Game_Player < Game_Character
- alias z21check_event_trigger_touch check_event_trigger_touch unless $@
- def check_event_trigger_touch(x, y)
- if area_bind.size != 0
- return false if $game_map.interpreter.running?
- for id in area_bind
- event = $game_map.events[id]
- next if event.nil?
- event.start
- end
- else
- return z21check_event_trigger_touch(x, y)
- end
- end
- alias z21check_event_trigger_here check_event_trigger_here unless $@
- def check_event_trigger_here(triggers)
- if area_bind.size != 0
- return false if $game_map.interpreter.running?
- result = false
- for id in area_bind
- event = $game_map.events[id]
- next if event.nil?
- next unless triggers.include?(event.trigger)
- next if event.priority_type == 1
- event.start
- result = true if event.starting
- end
- return result
- else
- return z21check_event_trigger_here(triggers)
- end
- end
- def area_control?(test_id)
- area.name.scan(Z21::REGEXP::AREAEVENT){
- id = $1.to_s
- }
- return id == test_id
- end
- def area_bind
- for area in $data_areas.values
- id = area_event_id(area)
- if in_area?(area) and id != 0
- return id
- end
- end
- end
- def area_event_id(area)
- result = []
- for area in $data_areas.values
- area.name.scan(Z21::REGEXP::AREAEVENT){
- result.push($1.to_i)
- }
- end
- return result
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement