Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # // Event Amplifier
- # // Regular Expressions (In Event Comment)
- # <bool: *> : Adds a script condition to event page.
- # <x/y += *> : Offsets X/Y coordinate of event.
- # // Added Features
- # self_var : Variable Local to Event (Like Self Switch)
- module Z21
- module REGEXP
- BOOL = /<(?:bool|condition)[ :]*(.*)>/i
- OFFSET = /<([xy])[ :]*(.*)>/i
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement