Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Date Created : 01/28/2011
- # Date Modified: 02/07/2011
- module IEX
- module SIREN
- RECTSIZE = 64
- TILESET_FRAMESIZE = RECTSIZE
- TILESET_COLUMNS = 8
- RANGE_TYPE_NUM = 2
- COLORSET = {
- # ID=> Color.new(red, grn, blu),
- 0 => Color.new( 0, 0, 255), # Blue
- 1 => Color.new(255, 0, 0), # Red
- 2 => Color.new( 0, 255, 0), # Green
- 3 => Color.new( 0, 128, 255), # Tealish - Allies
- 4 => Color.new(128, 0, 198), # Purple - Enemies
- 5 => Color.new(255, 255, 0), # Yellow
- 6 => Color.new(128, 128, 128), # Grey - Aoe
- } # Do Not Remove
- COLORASSIGN = {
- :move => 0,
- :skill => 2,
- :attack => 5,
- :aoe => 6,
- } # Do Not Remove
- SIREN_ICONS = {
- # Game
- :move => 2,
- :terrain => 2,
- :defense => 2,
- :offense => 2,
- # Editor
- :pencil => 5184,
- :eraser => 5186,
- :fill => 5185,
- :eyedrop => 5187,
- :save => 5188,
- :chngts => 5178,
- :vewpass => 5180,
- :startpnt=> 5191,
- } # Do Not Remove
- PARTY_START_POINTS = 3
- TROOP_START_POINTS = 3
- PERMOVE_FRMS = 15
- STAT_AFFECTS = ['atk', 'def', 'spi', 'agi', 'dex', 'res']
- end
- end
- module IEX
- module SIREN
- module EDITOR
- SIREN_MAPNAME= "SirenBattlemap"
- CURSOR_FRMRTE= 5
- PLACE_SOUND = RPG::SE.new("SIREN-PlacementSound", 100, 100)
- FLOOD_SOUND = RPG::SE.new("021-Dive01", 90, 100)
- REMOVE_SOUND = RPG::SE.new("Booby Trap_hit", 90, 100)
- CHANGE_SOUND = RPG::SE.new("016-Jump02", 70, 100)
- SAMPLE_SOUND = RPG::SE.new("SIREN-RemoveSound", 100, 100)
- NOMOVE_SOUND = RPG::SE.new("bump", 100, 100)
- #"385992_dumbstep"
- EDITOR_BGM = RPG::BGM.new("Templar", 70, 100)
- EDITOR_BUTTON_ASSIGN = {
- :accept => Input::C,
- :pencil => Input::LETTERS['P'],
- :eraser => Input::LETTERS['O'],
- :eyedrop => Input::LETTERS['I'],
- :fill => Input::LETTERS['G'],
- :save => Input::LETTERS['M'],
- }
- module_function
- def save_sirenmap(mapdata, id)
- name = sprintf("#{SIREN_MAPNAME}%04d.rvdata", id)
- save_data(mapdata, name)
- return name
- end
- end
- end
- end
- module IEX
- module SIREN
- module BATTLEMAP
- # Passage
- # 0 - Unpassable
- # 1 - Passable
- # 2 - Damaged and Passable
- # 7 - Only Down
- # 8 - Only Left
- # 9 - Only Right
- # 10- Only Up
- # 11- Vertical Only
- # 12- Horizontal Only
- TILECHIP_SETTINGS = { }
- TILECHIP_SETTINGS["INDOOR"] = { }
- TILECHIP_SETTINGS["INDOOR"][:tileset] = "IndoorBattleBackset"
- TILECHIP_SETTINGS["INDOOR"][:passage] = [
- # 1, 2, 3, 4, 5, 6, 7, 8
- 0, 1, 1, 2, 2, 0, 0, 0,
- 0, 1, 1, 2, 2, 0, 0, 0,
- 1, 0,11,12, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- ]
- # Effects
- # "" - No Effect
- # 1 - Defense +5%
- # 2 - Defense +10%
- # 3 - Defense -5%
- # 4 - Defense -10%
- # 5 - Offense +5%
- # 6 - Offense +10%
- # 7 - Offense -5%
- # 8 - Offense -10%
- # 9 - MP-Regen
- # 10- HP-Regen
- # 11- Party Start Point
- # 12- Troop Start Point
- TILECHIP_SETTINGS["INDOOR"][:effects] = [
- # 1, 2, 3, 4, 5, 6, 7, 8
- [""], [""], [""], ["DEF-10%"], ["DEF-5%"], [""], [""], [""],
- [""], [""], [""], [""], [""], [""], [""], [""],
- [""], [""], [""], [""], [""], [""], [""], [""],
- ["PSP"],["TSP"], ["MPREG+5%"],["HPREG+5%"], ["DEF+10%"], ["DEF+5%"], ["DEF+10%"], ["DEF+5%"],
- [""], [""], [""], [""], [""], [""], [""], [""],
- ]
- module_function
- def create_siren_pos(coord, offset, type=nil)
- offset = offset.to_i
- offset += 8 if type == :ytype
- return coord * IEX::SIREN::RECTSIZE + offset
- end
- def siren_fullrange
- result = []
- for x in 0...$game_battlemap.data.xsize
- for y in 0...$game_battlemap.data.ysize
- result.push([x, y]) unless result.include?([x, y])
- end
- end
- return result
- end
- def siren_truerange(x, y, oldranges)
- result = []
- for rng in oldranges
- result << [rng[0]+x, rng[1]+y]
- end
- return result
- end
- end
- end
- end
- class Game_BattleMap
- def terrain_effects(x, y)
- data = tile_effects(x, y)
- result = {}
- for ef in data
- case ef
- when /(HP|MP)REG([\+\-](?:\d+))([%%])/i
- case $1.to_s.upcase
- when "HP"
- result["HPREGEN"] = $2.to_i
- when "MP"
- result["MPREGEN"] = $2.to_i
- end
- when /(\w+)([\+\-](?:\d+))([%%])/i
- result[$1.to_s.upcase] = [0, 0] if result[$1.to_s.upcase].nil?
- result[$1.to_s.upcase][0] = $2.to_i
- when /(\w+)([\+\-](?:\d+))/i
- result[$1.to_s.upcase] = [0, 0] if result[$1.to_s.upcase].nil?
- result[$1.to_s.upcase][1] = $2.to_i
- end
- end
- return result
- end
- end
- class Game_Battler
- def apply_terrain_changes(val, stat)
- result = val
- return result unless $game_temp.in_battle
- effects = $game_battlemap.terrain_effect_at(siren_x, siren_y) #terrain_effects(siren_x, siren_y)
- stas = stat.to_s.upcase
- unless effects[stas].nil?
- result += effects[stas][1].to_i
- result += IEX::IMath.cal_percent(effects[stas][0].to_i, result)
- end
- return result
- end
- end
- class Window_BattleStatus < Window_Selectable
- #~ def prevent_left_right?
- #~ return true
- #~ end
- end
- class ActorCommand_Help < Window_Base
- end
- #===============================================================================
- # Window_ActorCommand
- #===============================================================================
- class Window_ActorCommand < Window_Selectable #Window_Command
- include ICY_Window_MiniCommand
- attr_accessor :actor
- #--------------------------------------------------------------------------
- # alias method: initialize
- #--------------------------------------------------------------------------
- alias iex_sr0_initialize initialize unless $@
- def initialize
- @disable_empty_commands = YEM::BATTLE_ENGINE::DISABLE_EMPTY_COMMANDS
- iex_sr0_initialize
- end
- #--------------------------------------------------------------------------
- # new method: item
- #--------------------------------------------------------------------------
- def item; return @data[self.index]; end
- #--------------------------------------------------------------------------
- # new method: skill
- #--------------------------------------------------------------------------
- def skill; return $data_skills[@skills[item]]; end
- def display_mode ; return 1 end
- #--------------------------------------------------------------------------
- # overwrite method: setup
- #--------------------------------------------------------------------------
- def setup(actor)
- @last_setup = :standard
- @column_max = 1
- @column_max = 3 if display_mode == 1
- @actor = actor
- @data = []; @commands = []; @skills = {}
- data_set = actor.class.id
- data_set = 0 if !YEM::BATTLE_ENGINE::CLASS_COMMANDS.include?(actor.class.id)
- #---
- for item in YEM::BATTLE_ENGINE::CLASS_COMMANDS[data_set]
- case item
- when :attack; @commands.push(actor.attack_vocab)
- when :skill; @commands.push(actor.skill_vocab)
- when :guard; @commands.push(actor.guard_vocab)
- when :item; @commands.push(Vocab.item)
- when :equip; @commands.push(YEM::BATTLE_ENGINE::EQUIP_VOCAB)
- when :escape
- next unless $game_troop.can_escape
- @commands.push(Vocab.escape)
- else
- valid = false
- if YEM::BATTLE_ENGINE::SKILL_COMMANDS.include?(item)
- @skills[item] = YEM::BATTLE_ENGINE::SKILL_COMMANDS[item][0]
- @commands.push(YEM::BATTLE_ENGINE::SKILL_COMMANDS[item][1])
- valid = true
- end
- next unless valid
- end
- @data.push(item)
- end
- #---
- @commands.push("Move")
- @data.push(:move)
- @commands = @data
- @item_max = @commands.size
- refresh
- self.index = 0
- end
- def update_command_text ; end
- #--------------------------------------------------------------------------
- # new method: update
- #--------------------------------------------------------------------------
- def update
- return unless $scene.is_a?(Scene_Battle)
- super unless Input.trigger?(Input::L) or Input.trigger?(Input::R)
- if @last_index != self.index
- update_command_text if display_mode == 1
- end
- return unless @actor == $scene.status_window.actor
- refresh if @actor != nil and @actor.update_commands
- end
- #--------------------------------------------------------------------------
- # new method: refresh
- #--------------------------------------------------------------------------
- alias iex_sr0_refresh refresh unless $@
- def refresh
- @actor.update_commands = false if @actor != nil
- iex_sr0_refresh
- end
- #--------------------------------------------------------------------------#
- # * new method :get_icon
- #--------------------------------------------------------------------------#
- def get_icon(obj) ; return iex_get_icon(obj) end
- #--------------------------------------------------------------------------#
- # * new method :get_vocab
- #--------------------------------------------------------------------------#
- def get_vocab(obj); return iex_get_vocab(obj) end
- #--------------------------------------------------------------------------#
- # * new method :lastindex_command
- #--------------------------------------------------------------------------#
- def lastindex_command ; return :nil end
- #--------------------------------------------------------------------------#
- # * new method :set_lastcommand
- #--------------------------------------------------------------------------#
- def set_lastcommand ; end #@actor.last_command = command unless @actor.nil? end
- def iex_get_icon(command)
- case command
- # Default Commands
- when :attack
- unless @actor.weapons[0].nil?
- return @actor.weapons[0].icon_index
- else
- return 2
- end
- when :skill
- return 132
- when :guard
- return 53
- when :item
- return 144
- when :equip
- return 32
- when :escape
- return 48
- # Special Commands
- when :link
- return $data_skills[5].icon_index
- when :sup
- return $data_skills[7].icon_index
- when :move
- return 5177
- else
- return 0
- end
- end
- def iex_get_vocab(command)
- case command
- when :attack; return @actor.nil? ? Vocab.attack : @actor.attack_vocab
- when :skill; return @actor.nil? ? Vocab.skill : @actor.skill_vocab
- when :guard; return @actor.nil? ? Vocab.guard : @actor.guard_vocab
- when :item; return Vocab.item
- when :equip; return YEM::BATTLE_ENGINE::EQUIP_VOCAB
- when :escape; return Vocab.escape
- else
- if YEM::BATTLE_ENGINE::SKILL_COMMANDS.include?(command)
- return YEM::BATTLE_ENGINE::SKILL_COMMANDS[item][1]
- end
- end
- end
- #--------------------------------------------------------------------------
- # new method: enabled?
- #--------------------------------------------------------------------------
- def enabled?(obj = nil)
- return false unless @actor.actor?
- if @actor.auto_battle
- return true if obj == :equip and @actor.equip_cooldown.to_i <= 0
- return true if obj == :escape and $game_troop.can_escape
- return false
- end
- return false unless @actor.inputable?
- return false if obj == nil
- return false if obj == :equip and @actor.equip_cooldown.to_i > 0
- if @disable_empty_commands
- return false if obj == :skill and @actor.skills.size <= 0
- return false if obj == :item and $game_party.battle_item_size <= 0
- end
- if @skills.include?(obj)
- skill = $data_skills[@skills[obj]]
- return @actor.skill_can_use?(skill)
- end
- return true
- end unless method_defined? :enabled?
- #--------------------------------------------------------------------------
- # new method: enabled?
- #--------------------------------------------------------------------------
- alias iex_sirenset_wac_enabled? enabled? unless $@
- def enabled?(obj = nil)
- if obj == :move && !@actor.nil?
- return false unless @actor.siren_canmove?
- end
- iex_sirenset_wac_enabled?(obj)
- end
- end
- module IEX
- module SIREN
- module_function
- def get_atk_direction(hx, hy, tx, ty)
- if tx > hx && ty == hy
- return 6
- elsif tx < hx && ty == hy
- return 4
- elsif tx == hx && ty > hy
- return 2
- elsif tx == hx && ty < hy
- return 8
- end
- return 0
- end
- # 0 - Diamond < >
- # 1 - Linear +
- # 2 - X x
- # 3 - Breath <
- # 4 - SnowFlake *
- # 5 - Block [ ]
- # 6 - Directional Line ->
- def create_range_data(rng, minrng=0, type=0, direction=2)
- result = []
- case type
- when 0 # Normal - Diamond <>
- for x in 0..rng
- for y in 0..rng
- next if x+y > rng
- next if x+y < minrng
- result << [ x, y] unless result.include?([ x, y])
- result << [-x, y] unless result.include?([-x, y])
- result << [ x, -y] unless result.include?([ x, -y])
- result << [-x, -y] unless result.include?([-x, -y])
- end
- end
- when 1 # Linear +
- for x in 0..rng
- for y in 0..rng
- next if x+y > rng
- next if x+y < minrng
- result << [ x, 0] unless result.include?([ x, 0])
- result << [-x, 0] unless result.include?([-x, 0])
- result << [ 0, -y] unless result.include?([ 0, -y])
- result << [ 0, y] unless result.include?([ 0, y])
- end
- end
- when 2 # X - x
- for x in 0..rng
- for y in 0..rng
- next if x+y > rng
- next if x+y < minrng
- result << [ x, x] unless result.include?([ x, x])
- result << [-x, -x] unless result.include?([-x, -x])
- result << [-y, y] unless result.include?([-y, y])
- result << [ y, -y] unless result.include?([ y, -y])
- end
- end
- when 3 # Breath <
- for x in 0..rng
- for y in 0..rng
- next if x+y > rng
- next if x+y < minrng
- case direction
- when 2
- result << [ x, y] unless result.include?([ x, y])
- result << [-x, y] unless result.include?([-x, y])
- when 4
- result << [-x, y] unless result.include?([-x, y])
- result << [-x, -y] unless result.include?([-x, -y])
- when 6
- result << [ x, y] unless result.include?([ x, y])
- result << [ x, -y] unless result.include?([ x, -y])
- when 8
- result << [ x, -y] unless result.include?([ x, -y])
- result << [-x, -y] unless result.include?([-x, -y])
- end
- end
- end
- when 4 # Snow Flake *
- for x in 0..rng
- next if x < minrng
- result << [ 0, x] unless result.include?([ 0, x])
- result << [ x, 0] unless result.include?([ x, 0])
- result << [ 0, -x] unless result.include?([ 0, -x])
- result << [-x, 0] unless result.include?([-x, 0])
- result << [ x, x] unless result.include?([ x, x])
- result << [-x, x] unless result.include?([-x, x])
- result << [ x, -x] unless result.include?([ x, -x])
- result << [-x, -x] unless result.include?([-x, -x])
- end
- when 5 # Block []
- for x in 0..rng
- for y in 0..rng
- next if x+y < minrng
- result << [ x, y] unless result.include?([ x, y])
- result << [-x, y] unless result.include?([-x, y])
- result << [ x, -y] unless result.include?([ x, -y])
- result << [-x, -y] unless result.include?([-x, -y])
- end
- end
- when 6 # Directional Line <-
- for x in 0..rng
- for y in 0..rng
- next if x+y > rng
- next if x+y < minrng
- case direction
- when 2
- result << [ 0, y] unless result.include?([ 0, y])
- when 4
- result << [-x, 0] unless result.include?([-x, 0])
- when 6
- result << [ x, 0] unless result.include?([ x, 0])
- when 8
- result << [ 0, -y] unless result.include?([ 0, -y])
- end
- end
- end
- end
- return result
- end
- end
- end
- module IEX
- module REGEX
- module BASEITEM
- RANGE = /<RANGE:[ ](\d+)[ ]*,[ ]*(\d+)[ ]*,[ ]*(\d+)>/i
- AOE = /<AOE:[ ](\d+)[ ]*,[ ]*(\d+)[ ]*,[ ]*(\d+)>/i
- end
- module ITEM
- end
- module WEAPON
- end
- module ARMOR
- end
- module SKILL
- end
- module STATE
- end
- module ENEMY
- ATTACK_RANGE = /<(?:ATK|ATTACK)(?:RANGE|_RANGE| RANGE):[ ](\d+)[ ]*,[ ]*(\d+)[ ]*,[ ]*(\d+)>/i
- ATTACK_AOE = /<(?:ATK|ATTACK)(?:AOE|_AOE| AOE):[ ](\d+)[ ]*,[ ]*(\d+)[ ]*,[ ]*(\d+)>/i
- MOVE_RANGE = /<(?:MV|MOVE)(?:RANGE|_RANGE| RANGE):[ ](\d+)[ ]*,[ ]*(\d+)[ ]*,[ ]*(\d+)>/i
- end
- end
- end
- class RPG::BaseItem
- attr_accessor :range
- attr_accessor :aoe
- def iex_siren_bsi_cache
- # Range Types
- # 0 - Diamond < >
- # 1 - Linear +
- # 2 - X x
- # 3 - Breath <
- # 4 - SnowFlake *
- # 5 - Block [ ]
- # [rng, minrng, type]
- @range = [1, 0, 0 ]
- @aoe = [0, 0, 0 ]
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when IEX::REGEX::BASEITEM::RANGE
- @range = [$1.to_i, $2.to_i, $3.to_i]
- when IEX::REGEX::BASEITEM::AOE
- @aoe = [$1.to_i, $2.to_i, $3.to_i]
- end
- }
- end
- end
- class RPG::Item
- def iex_siren_ite_cache
- #~ self.note.split(/[\r\n]+/).each { |line|
- #~ case line
- #~ when
- #~ end
- #~ }
- end
- end
- class RPG::Weapon
- def iex_siren_wep_cache
- #~ self.note.split(/[\r\n]+/).each { |line|
- #~ case line
- #~ when
- #~ end
- #~ }
- end
- end
- class RPG::Armor
- def iex_siren_arm_cache
- #~ self.note.split(/[\r\n]+/).each { |line|
- #~ case line
- #~ when
- #~ end
- #~ }
- end
- end
- class RPG::Skill
- def iex_siren_ski_cache
- #~ self.note.split(/[\r\n]+/).each { |line|
- #~ case line
- #~ when
- #~ end
- #~ }
- end
- end
- class RPG::State
- def iex_siren_ste_cache
- #~ self.note.split(/[\r\n]+/).each { |line|
- #~ case line
- #~ when
- #~ end
- #~ }
- end
- end
- class RPG::Enemy
- attr_accessor :attackrange
- attr_accessor :attackaoe
- attr_accessor :moverange
- def iex_siren_eny_cache
- @attackrange = [1, 0, 0]
- @attackaoe = [0, 0, 0]
- @moverange = [3, 0, 0]
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when IEX::REGEX::ENEMY::ATTACK_RANGE
- @attackrange = [$1.to_i, $2.to_i, $3.to_i]
- when IEX::REGEX::ENEMY::ATTACK_AOE
- @attackaoe = [$1.to_i, $2.to_i, $3.to_i]
- when IEX::REGEX::ENEMY::MOVE_RANGE
- @moverange = [$1.to_i, $2.to_i, $3.to_i]
- end
- }
- end
- end
- class SirenMap
- attr_accessor :id
- attr_accessor :name
- attr_accessor :data
- attr_accessor :tileset
- attr_accessor :tilechip
- attr_accessor :start_points
- def initialize
- @name = ""
- @id = 0
- @data = Table.new(1, 1, 2)
- @tileset = ""
- @tilechip = ""
- @start_points = {}
- @start_points[:troop] = {}
- @start_points[:party] = {}
- end
- class StartPoint
- attr_accessor :x
- attr_accessor :y
- def initialize(x, y)
- @x = x
- @y = y
- end
- end
- end
- class Game_BattleMap
- include IEX::SIREN
- include IEX::SIREN::EDITOR
- include IEX::SIREN::BATTLEMAP
- def initialize
- @map_data = Table.new(1, 1, 2)
- @map = SirenMap.new
- end
- def setup(map_id)
- if map_id.nil?
- w = Graphics.width / RECTSIZE
- h = Graphics.height / RECTSIZE
- @map = SirenMap.new
- @map.data = Table.new(w, h, 2)
- for x in 0...@map.data.xsize
- for y in 0...@map.data.ysize
- @map.data[x, y, 0] = 0
- end
- end
- else
- load = load_data(sprintf("#{SIREN_MAPNAME}%04d.rvdata", map_id))
- if load.is_a?(Table)
- @map = SirenMap.new
- @map.data = load
- else
- @map = load
- end
- end
- @terrain_effect_table = IEX::ITable.new(@map.data.xsize, @map.data.ysize, 1, {})
- for x in 0...@map.data.xsize
- for y in 0...@map.data.ysize
- @terrain_effect_table[x, y, 0] = terrain_effects(x, y)
- end
- end
- end
- def change_tile(x, y, z, newtileid)
- @map.data[x, y, z] = newtileid
- @terrain_effect_table[x, y, z] = terrain_effects(x, y)
- end
- def terrain_effect_at(x, y)
- return @terrain_effect_table[x, y, 0]
- end
- def get_start_points(party, index)
- return @map.start_points[party.siren_group][index]
- end
- def map ; return @map end
- def current_tilechip
- return @map.tilechip
- end
- def data
- return @map.data
- end
- def passable?(x, y, obj = nil)
- data = TILECHIP_SETTINGS[current_tilechip][:passage]
- tid = @map.data[x, y, 0].to_i
- case data[tid]
- when 0 ; return false
- when 1 ; return true
- when 2 ; return true
- when 11
- return true if obj.nil?
- return true if y != obj.y and x == obj.x
- when 12
- return true if obj.nil?
- return true if y == obj.y and x != obj.x
- end
- return false
- end
- def tile_effects(x, y)
- return [] if TILECHIP_SETTINGS[current_tilechip].nil?
- data = TILECHIP_SETTINGS[current_tilechip][:effects]
- tid = @map.data[x, y, 0].to_i
- return data[tid]
- end
- def get_battlers_xy(x, y)
- result = []
- for bat in $game_troop.members + $game_party.members
- result << bat if bat.siren_xy?(x, y)
- end
- return result
- end
- end
- class Game_Battler
- def siren_canmove?
- return @move_pnt > 0
- end
- def set_siren_xy(nx, ny)
- @siren_x = nx
- @siren_y = ny
- end
- def siren_x ; return @siren_x end
- def siren_y ; return @siren_y end
- def siren_x=(val) ; @siren_x = val end
- def siren_y=(val) ; @siren_y = val end
- def siren_xy?(sx, sy) ; return (@siren_x == sx && @siren_y == sy) end
- def siren_origin_x
- mx = @siren_x.to_i
- hx = IEX::SIREN::RECTSIZE/2
- x = IEX::SIREN::BATTLEMAP.create_siren_pos(mx, hx)
- return x
- end
- def siren_origin_y
- my = @siren_y.to_i
- hy = IEX::SIREN::RECTSIZE/2
- y = IEX::SIREN::BATTLEMAP.create_siren_pos(my, hy, :ytype)
- return y
- end
- def attack_range
- return [1, 0, 0]
- end
- def attack_aoe
- return [0, 0, 0]
- end
- def move_range
- return @move_pnt
- end
- def skill_range(skill)
- return skill.range
- end
- def skill_aoe(skill)
- return skill.aoe
- end
- IEX::SIREN::STAT_AFFECTS.each { |meth|
- meth = meth.to_s.downcase
- mStr = %Q(
- alias iex_sirencore_gmb_#{meth} #{meth} unless $@
- def #{meth}
- stat = iex_sirencore_gmb_#{meth}
- stat = apply_terrain_changes(stat, '#{meth}')
- return Integer(stat)
- end
- )
- module_eval(mStr)
- }
- end
- class Game_Enemy < Game_Battler
- def attack_range
- return enemy.attackrange
- end
- def attack_aoe
- return enemy.attackaoe
- end
- def skill_range(skill)
- return skill.range
- end
- def skill_aoe(skill)
- return skill.aoe
- end
- def origin_x
- return siren_origin_x
- end
- def origin_y
- return siren_origin_y
- end
- end
- class Game_Actor < Game_Battler
- def attack_range
- return weapons[0].range
- end
- def attack_aoe
- return weapons[0].aoe
- end
- def skill_range(skill)
- return skill.range
- end
- def skill_aoe(skill)
- return skill.aoe
- end
- def origin_x
- return siren_origin_x
- end
- def origin_y
- return siren_origin_y
- end
- end
- class Game_Troop < Game_Unit
- def home_y
- hx = IEX::SIREN::RECTSIZE/2 ; hy = IEX::SIREN::RECTSIZE/2
- gw = Graphics.width ; gh = Graphics.height
- result = gh / IEX::SIREN::RECTSIZE
- result -= members.size
- result = result.abs
- result /= 2
- return result
- end
- def home_x ; return 1 end
- def siren_group ; return :troop end
- end
- class Game_Party < Game_Unit
- def home_y
- hx = IEX::SIREN::RECTSIZE/2 ; hy = IEX::SIREN::RECTSIZE/2
- gw = Graphics.width ; gh = Graphics.height
- result = gh / IEX::SIREN::RECTSIZE
- result -= members.size
- result = result.abs
- result /= 2
- return result
- end
- def home_x ; return 8 end
- def siren_group ; return :party end
- end
- class Siren_CursorRect < Rect
- include IEX::SIREN
- include IEX::SIREN::EDITOR
- attr_accessor :rngdata
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @rngdata = []
- @rngcursor_rect = self
- end
- def update
- update_cursor
- end
- def update_cursor
- cx = @rngcursor_rect.x
- cy = @rngcursor_rect.y
- if Input.repeat?(Input::RIGHT)
- if @rngdata.include?([cx+1, cy])
- Sound.play_cursor
- @rngcursor_rect.x = cx + 1
- else
- NOMOVE_SOUND.play
- end
- elsif Input.repeat?(Input::LEFT)
- if @rngdata.include?([cx-1, cy])
- Sound.play_cursor
- @rngcursor_rect.x = cx - 1
- else
- NOMOVE_SOUND.play
- end
- elsif Input.repeat?(Input::UP)
- if @rngdata.include?([cx, cy-1])
- Sound.play_cursor
- @rngcursor_rect.y = cy - 1
- else
- NOMOVE_SOUND.play
- end
- elsif Input.repeat?(Input::DOWN)
- if @rngdata.include?([cx, cy+1])
- Sound.play_cursor
- @rngcursor_rect.y = cy + 1
- else
- NOMOVE_SOUND.play
- end
- end
- end
- end
- class Spriteset_BattleMap < Sprite
- include IEX::SIREN
- attr_accessor :forced_update
- def initialize(map, viewport=nil)
- super(viewport)
- self.x = 0 ; self.y = 0
- self.bitmap = Bitmap.new(Graphics.width, Graphics.height)
- @forced_update = false
- @battlemap = map
- @tileset = []
- @tileset[0] = Cache.picture(@battlemap.map.tileset)
- @tilechip = @battlemap.map.tilechip
- @do_tile_update = false
- for x in 0...@battlemap.data.xsize
- for y in 0...@battlemap.data.ysize
- place_tile(@tileset[0], x, y, @battlemap.data[x, y, 0])
- end
- end
- @stored_data = @battlemap.data.dup
- end
- def place_tile(tileset, x, y, tindex, clear = false)
- tfs = TILESET_FRAMESIZE ; tc = TILESET_COLUMNS
- tindex = tindex.to_i
- rect = Rect.new(x*tfs, y*tfs, tfs, tfs)
- brect= Rect.new(tindex % tc * tfs, tindex / tc * tfs, tfs, tfs)
- self.bitmap.clear_rect(rect) if clear
- self.bitmap.blt(rect.x, rect.y, tileset, brect)
- end
- def update
- super
- if @tilechip != @battlemap.map.tilechip
- self.bitmap.clear
- @stored_data = Table.new(@battlemap.data.xsize, @battlemap.data.ysize, @battlemap.data.zsize)
- @tileset[0] = Cache.picture(@battlemap.map.tileset)
- @tilechip = @battlemap.map.tilechip
- end
- tile_change = false
- if @do_tile_update
- for x in 0...@battlemap.data.xsize
- for y in 0...@battlemap.data.ysize
- next if @stored_data[x, y, 0] == @battlemap.data[x, y, 0] and !@forced_update
- place_tile(@tileset[0], x, y, @battlemap.data[x, y, 0], true)
- tile_change = true
- end
- end
- end
- Graphics.frame_reset if tile_change
- @stored_data = @battlemap.data.clone
- @forced_update = false
- end
- end
- class Siren_BattleCursor < Sprite_Base
- include IEX::SIREN
- attr_accessor :intern_rect
- def initialize(viewport, color=nil)
- super(viewport)
- color = Color.new(128, 20, 20) if color.nil?
- x = RECTSIZE / 8 ; y = RECTSIZE / 8
- w = RECTSIZE - x ; h = RECTSIZE - y
- x /= 2 ; y /= 2
- pre_rect = Rect.new(0, 0, RECTSIZE, RECTSIZE)
- self.bitmap = Bitmap.new(RECTSIZE, RECTSIZE)
- self.bitmap.fill_rect(pre_rect, color)
- crect = pre_rect.dup
- crect.x = x ; crect.y = y ; crect.width = w ; crect.height = h
- self.bitmap.clear_rect(crect)
- self.z = 6
- self.blend_type = 1
- @intern_rect = Rect.new(0, 0, 0, 0)
- end
- def update
- super
- update_move_to
- end
- #--------------------------------------------------------------------------
- # new method: create_move_to
- #--------------------------------------------------------------------------
- def create_move_to(destination_x, destination_y, total_frames = 60)
- den = [total_frames, 1].max
- if destination_x != nil
- @move_to_x = Integer(destination_x)
- @move_rate_x = [RECTSIZE.abs/den, 2].max
- end
- if destination_y != nil
- @move_to_y = Integer(destination_y)
- @move_rate_y = [RECTSIZE.abs/den, 2].max
- end
- return if @character_sprite == nil
- end
- #--------------------------------------------------------------------------
- # new method: update_move_to
- #--------------------------------------------------------------------------
- def update_move_to
- if @move_to_x != nil
- value = [(self.x - @move_to_x).abs, @move_rate_x].min
- self.x += (@move_to_x > self.x) ? value : -value
- @move_to_x = nil if self.x == @move_to_x
- end
- if @move_to_y != nil
- value = [(self.y - @move_to_y).abs, @move_rate_y].min
- self.y += (@move_to_y > self.y) ? value : -value
- @move_to_y = nil if self.y == @move_to_y
- end
- end
- end
- class Siren_PositionSprite < Sprite
- def initialize(viewport)
- super(viewport)
- @old_pos = []
- self.bitmap = Bitmap.new(320, 96)
- self.bitmap.font.size = 36
- update_pos(0, 0)
- end
- def update_pos(newx, newy)
- if @old_pos[0] != newx || @old_pos[1] != newy
- self.bitmap.clear
- self.bitmap.draw_text(0, 0, 300, 56, "#{newx},#{newy}", 2)
- @old_pos = [newx, newy]
- end
- end
- end
- class Siren_TileWindow < Window_Base
- include IEX::SIREN
- def initialize(tileset, width, height)
- super(0, 0, width, height)
- @tileindex = 0
- @tileset = tileset
- refresh
- end
- def tileindex_limit
- bitmap = Cache.picture(@tileset)
- result = bitmap.rect.height / TILESET_FRAMESIZE
- result *= TILESET_COLUMNS
- return result
- end
- def current_tileindex ; return @tileindex end
- def current_tileset ; return @tileset end
- def update_tilset(new_tileset)
- if @tileset != new_tileset
- change_tileset(new_tileset)
- end
- end
- def change_tileset(new_tileset)
- @tileset = new_tileset
- refresh
- end
- def update_tileindex(new_tileindex)
- if @tileindex != new_tileindex
- @tileindex = new_tileindex
- refresh
- end
- end
- def refresh
- @item_max = (self.width-32) / TILESET_FRAMESIZE
- targ_index = @tileindex - (@item_max/2)
- for i in 0...@item_max
- draw_tile(i, 0, targ_index+i, targ_index+i == @tileindex ? 255 : 128)
- end
- end
- def draw_tile(x, y, index, opac=255)
- bitmap = Cache.picture(@tileset)
- tfs = TILESET_FRAMESIZE ; tc = TILESET_COLUMNS
- tindex = index
- rect = Rect.new(x*tfs, y*tfs, tfs, tfs)
- brect= Rect.new(tindex % tc * tfs, tindex / tc * tfs, tfs, tfs)
- self.contents.clear_rect(rect)
- self.contents.blt(rect.x, rect.y, bitmap, brect, opac)
- end
- end
- class Siren_IconWindow < Window_Base
- def change_icon(new_icon)
- @old_icon = 0 if @old_icon.nil?
- if @old_icon != new_icon.to_i
- self.contents.clear
- draw_icon(new_icon.to_i, 0, 0)
- @old_icon = new_icon.to_i
- end
- end
- def update_icon(new_icon)
- change_icon(new_icon)
- end
- end
- class Siren_Window_Terrain < Window_Base
- def initialize(x, y)
- super(x, y, 128, 56)
- end
- def update_tileid(x, y)
- $game_battlemap.data[x, y, 0]
- end
- end
- class Scene_BattleMap_Editor < Scene_Base
- include IEX::SIREN
- include IEX::SIREN::EDITOR
- include IEX::SIREN::BATTLEMAP
- def initialize
- RPG::BGM.fade(1000)
- super
- @tilechip = TILECHIP_SETTINGS.keys[0]
- $game_battlemap.setup(nil)
- $game_battlemap.map.tilechip = @tilechip
- $game_battlemap.map.tileset = TILECHIP_SETTINGS[@tilechip][:tileset]
- @windows = {}
- @viewport1 = Viewport.new(0, 0, Graphics.width, Graphics.height)
- @viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
- @viewport2.z = 50
- @spriteset = Spriteset_BattleMap.new($game_battlemap, @viewport1)
- @spriteset.forced_update = true
- @spriteset.z = 3
- @spriteset.visible = true
- @tileindex = 0
- @rngdata = []
- @rngdata = siren_fullrange
- create_cursor
- @posprite = Siren_PositionSprite.new(@viewport2)
- @posprite.x = Graphics.width - @posprite.bitmap.width
- @posprite.y = Graphics.height - @posprite.bitmap.height
- @indexsprite = Siren_PositionSprite.new(@viewport2)
- @indexsprite.x = Graphics.width - @posprite.bitmap.width
- @indexsprite.y = Graphics.height - @posprite.bitmap.height
- @indexsprite.y -= 64
- @rngcursor_rect.rngdata = @rngdata
- @mapcount = Dir.glob("#{SIREN_MAPNAME}*.rvdata").size + 1
- @start_points = {}
- @start_points[:troop] = {}
- @start_points[:party] = {}
- for i in 0...PARTY_START_POINTS
- @start_points[:party][i] = Siren_BattleCursor.new(@viewport1, COLORSET[3])
- @start_points[:party][i].z = 10
- @start_points[:party][i].visible = false
- @start_points[:party][i].bitmap.font.size = RECTSIZE - (RECTSIZE/8)
- @start_points[:party][i].bitmap.draw_text(0, 0, RECTSIZE, RECTSIZE, i, 1)
- end
- for i in 0...TROOP_START_POINTS
- @start_points[:troop][i] = Siren_BattleCursor.new(@viewport1, COLORSET[4])
- @start_points[:troop][i].z = 10
- @start_points[:troop][i].visible = false
- @start_points[:troop][i].bitmap.font.size = RECTSIZE - (RECTSIZE/8)
- @start_points[:troop][i].bitmap.draw_text(0, 0, RECTSIZE, RECTSIZE, i, 1)
- end
- end
- def start
- super
- @windows["Tile"] = Siren_TileWindow.new($game_battlemap.map.tileset,
- RECTSIZE*5+32, RECTSIZE+32)
- #@windows["Tile"].opacity = 128
- @windows["Tile"].x = 10
- @windows["Tile"].y = Graphics.height - @windows["Tile"].height - 10
- @windows["Save"] = Window_Base.new(0, 0, 360, 56)
- @windows["Save"].x = (Graphics.width - @windows["Save"].width) / 2
- @windows["Save"].y = (Graphics.height - @windows["Save"].height) / 2
- @windows["Save"].openness = 0
- @windows["Tool"] = Siren_IconWindow.new(0, 0, 56, 56)
- @windows["Tool"].x = Graphics.width - @windows["Tool"].width
- commands = ["Return", "Leave Map Editor", "Setup Start points", "LoadMap"]
- @windows["Command"] = Window_Command.new(172, commands)
- @windows["Command"].x = (Graphics.width - @windows["Command"].width) / 2
- @windows["Command"].y = (Graphics.height - @windows["Command"].height) / 2
- @windows["Command"].active = false
- @windows["Command"].openness = 0
- @current_tool = :pencil
- EDITOR_BGM.play
- end
- def terminate
- super
- @viewport1.dispose unless @viewport1.nil?
- @viewport2.dispose unless @viewport2.nil?
- @spriteset.dispose unless @spriteset.nil?
- @posprite.dispose unless @posprite.nil?
- @indexsprite.dispose unless @indexsprite.nil?
- @range_cursor.dispose unless @range_cursor.nil?
- for win in @windows.values
- next if win.nil?
- win.dispose
- end
- @windows.clear
- end
- def return_scene
- $game_map.autoplay
- $scene = Scene_Map.new
- GC.start
- end
- def create_cursor
- @rngcursor_rect = Siren_CursorRect.new(0, 0, 0, 0)
- @range_cursor = Siren_BattleCursor.new(@viewport1)
- @range_cursor.visible = true
- end
- def update_basic
- Graphics.update
- Input.update
- @viewport1.update
- @viewport2.update
- end
- def update
- super
- @viewport1.update
- @viewport2.update
- update_user_input
- update_cursor
- @range_cursor.update
- for win in @windows.values
- next if win.nil?
- win.update if win.active
- end
- @windows["Tile"].update_tilset($game_battlemap.map.tileset)
- @windows["Tile"].update_tileindex(@tileindex)
- @windows["Tool"].update_icon(SIREN_ICONS[@current_tool])
- update_range_cursor(@rngcursor_rect.x, @rngcursor_rect.y)
- @posprite.update_pos(@rngcursor_rect.x, @rngcursor_rect.y)
- ati = $game_battlemap.data[@rngcursor_rect.x, @rngcursor_rect.y, 0]
- @indexsprite.update_pos(ati, @mapcount)
- @spriteset.update
- end
- def update_user_input
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @windows["Command"].open
- closing = false
- loop do
- update_basic
- @windows["Command"].update
- if @windows["Command"].openness == 255
- @windows["Command"].active = true
- if Input.trigger?(Input::C)
- case @windows["Command"].index.to_i
- when 0
- Sound.play_decision
- closing = true
- @windows["Command"].close
- when 1
- Sound.play_decision
- return_scene
- break
- when 2
- Sound.play_decision
- closing = true
- @windows["Command"].close
- @windows["Command"].openness = 0
- @windows["Command"].active = false
- update_set_start_points
- end
- elsif Input.trigger?(Input::B)
- Sound.play_cancel
- closing = true
- @windows["Command"].close
- end
- end
- break if closing && @windows["Command"].openness == 0
- end
- @windows["Command"].active = false
- elsif Input.trigger?(Input::C)
- tool_action(@current_tool)
- elsif Input.trigger?(Input::X)
- tool_action(:eraser)
- elsif Input.trigger?(Input::Y)
- tool_action(:eyedrop)
- elsif Input.trigger?(Input::Z)
- tool_action(:fill)
- elsif Input.repeat?(Input::L)
- CHANGE_SOUND.play
- @tileindex = (@tileindex-1) % @windows["Tile"].tileindex_limit
- elsif Input.repeat?(Input::R)
- CHANGE_SOUND.play
- @tileindex = (@tileindex+1) % @windows["Tile"].tileindex_limit
- elsif Input.trigger?(EDITOR_BUTTON_ASSIGN[:save])
- Sound.play_save
- name = save_sirenmap($game_battlemap.map, @mapcount)
- @windows["Save"].contents.clear
- @windows["Save"].contents.draw_text(0, 0, 320, 24, "Save Complete", 1)
- @windows["Save"].open
- @windows["Save"].openness = 1
- clos = false
- loop do
- update_basic
- @windows["Save"].update
- if Input.trigger?(Input::C)
- clos = true
- @windows["Save"].close
- end
- break if @windows["Save"].openness == 0
- end
- @mapcount += 1
- elsif Input.trigger?(EDITOR_BUTTON_ASSIGN[:pencil])
- CHANGE_SOUND.play ; @current_tool = :pencil
- elsif Input.trigger?(EDITOR_BUTTON_ASSIGN[:eraser])
- CHANGE_SOUND.play ; @current_tool = :eraser
- elsif Input.trigger?(EDITOR_BUTTON_ASSIGN[:eyedrop])
- CHANGE_SOUND.play ; @current_tool = :eyedrop
- elsif Input.trigger?(EDITOR_BUTTON_ASSIGN[:fill])
- CHANGE_SOUND.play ; @current_tool = :fill
- elsif Input.trigger?(Input::LETTERS['H'])
- @windows["Tile"].active = true
- if @windows["Tile"].openness == 255
- @windows["Tile"].close
- else
- @windows["Tile"].open
- end
- end
- end
- def tool_action(tool)
- case tool
- when :pencil
- PLACE_SOUND.play
- $game_battlemap.data[@rngcursor_rect.x, @rngcursor_rect.y, 0] = @windows["Tile"].current_tileindex.to_i
- when :eraser
- REMOVE_SOUND.play
- $game_battlemap.data[@rngcursor_rect.x, @rngcursor_rect.y, 0] = 0
- when :eyedrop
- SAMPLE_SOUND.play
- @tileindex = $game_battlemap.data[@rngcursor_rect.x, @rngcursor_rect.y, 0]
- when :fill
- FLOOD_SOUND.play
- current = $game_battlemap.data[@rngcursor_rect.x, @rngcursor_rect.y, 0]
- for x in 0...$game_battlemap.data.xsize
- for y in 0...$game_battlemap.data.ysize
- next unless $game_battlemap.data[x, y, 0] == current
- $game_battlemap.data[x, y, 0] = @windows["Tile"].current_tileindex.to_i
- end
- end
- end
- end
- def set_start_points
- for i in 0...PARTY_START_POINTS
- rect = @start_points[:party][i].intern_rect
- $game_battlemap.map.start_points[:party][i] = SirenMap::StartPoint.new(rect.x, rect.y)
- end
- for i in 0...TROOP_START_POINTS
- rect = @start_points[:troop][i].intern_rect
- $game_battlemap.map.start_points[:troop][i] = SirenMap::StartPoint.new(rect.x, rect.y)
- end
- end
- def update_set_start_points
- @active_point = nil
- for i in 0...PARTY_START_POINTS
- @active_point = @start_points[:party][i]
- update_active_point
- end
- for i in 0...TROOP_START_POINTS
- @active_point = @start_points[:troop][i]
- update_active_point
- end
- set_start_points
- end
- def update_active_point
- @rngcursor_rect.x = 0
- @rngcursor_rect.y = 0
- @active_point.visible = true
- loop do
- @rngcursor_rect.update_cursor
- update_spec_cursor(@active_point, @rngcursor_rect.x, @rngcursor_rect.y)
- @active_point.intern_rect.x = @rngcursor_rect.x
- @active_point.intern_rect.y = @rngcursor_rect.y
- #@active_point.update
- for spr in @start_points[:party].values + @start_points[:troop].values
- spr.update
- end
- update_basic
- break if Input.trigger?(Input::C)
- end
- end
- def update_cursor ; @rngcursor_rect.update_cursor end
- def update_range_cursor(px, py, rng=[])
- update_spec_cursor(@range_cursor, px, py, rng)
- end
- def update_spec_cursor(cursor, px, py, rng=[])
- if rng.empty?
- sx = px ; sy = py
- else
- sx = rng[0]+px ; sy = rng[1]+py
- end
- sx *= RECTSIZE ; sy *= RECTSIZE
- cursor.create_move_to(sx, sy, CURSOR_FRMRTE)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment