Project1
标题:
战斗时发生错误
[打印本页]
作者:
garyfrank
时间:
2012-12-16 13:50
标题:
战斗时发生错误
长按C键盘,就会出现 脚本的'XAS- Battler‘ 的166行发生了NoMethodError.
undefined method 'pages' for nil:NilClass
此外攻击时的动画都没有了。
我是直接使用范本,将他的地图删除,在他的范本基础下建立地图的。
#===============================================================================
#===============================================================================
# BATTLER
#===============================================================================
#===============================================================================
#===============================================================================
# SENSOR
#===============================================================================
module XRXS_EnemySensor
#--------------------------------------------------------------------------
# Update Sensor
#--------------------------------------------------------------------------
def update_sensor
if self.battler != nil and self.battler.is_a?(Game_Enemy)
enemy_sensor = XAS_BA_ENEMY::ENEMY_SENSOR[self.battler.id]
end
if enemy_sensor != nil
@sensor_range = enemy_sensor
else
@sensor_range = $game_variables[XAS_BA_ENEMY::DEFAULT_ENEMY_SENSOR_VARIABLE_ID]
end
if self.battler != nil and (self.knockbacking? or
self.battler.xas_states_stop == true or
self.battler.xas_states_sleep == true or
self.battler.hp == 0 or
self.throw_on == true)
@sensor_range = -1
end
distance = ($game_player.x - self.x).abs + ($game_player.y - self.y).abs
enable = (distance <= @sensor_range)
key = [$game_map.map_id, self.id, XAS_BA::SENSOR_SELF_SWITCH]
last_enable = $game_self_switches[key]
last_enable = false if last_enable == nil
if enable != last_enable
$game_self_switches[key] = enable
$game_map.need_refresh = true
end
end
end
#===============================================================================
# Game_Event
#===============================================================================
class Game_Event < Game_Character
include XRXS_EnemySensor
end
#===============================================================================
# Game_Player
#===============================================================================
class Game_Player < Game_Character
include XRXS_BattlerAttachment
#--------------------------------------------------------------------------
# Battler
#--------------------------------------------------------------------------
def battler
return $game_party.actors[0]
end
#--------------------------------------------------------------------------
# Defeat Process
#--------------------------------------------------------------------------
def defeat_process
super
if XAS_BA::AUTOGAMEOVER == true
$scene = Scene_Gameover.new rescue nil if self.collapse_done
else
$game_switches[XAS_BA::GAMEOVER_SWITCH_ID] = true
$game_map.refresh
end
end
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
alias xrxs64c_update update
def update
xrxs64c_update
self.battler.remove_states_auto if self.battler != nil
if self.collapse_done
self.collapse_done = false
@xrxs64c_defeat_done = false
end
end
end
#===============================================================================
# Game Event
#===============================================================================
class Game_Event < Game_Character
include XRXS_BattlerAttachment
#--------------------------------------------------------------------------
# Battler
#--------------------------------------------------------------------------
def battler
return @battler
end
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
alias xrxs64c_refresh refresh
def refresh
xrxs64c_refresh
self.battler_recheck
end
#--------------------------------------------------------------------------
# Battler Recheck
#--------------------------------------------------------------------------
def battler_recheck
return if [url=home.php?mod=space&uid=133701]@battler[/url] != nil
if @page == nil
return
end
@enemy_id = 0
for page in @event.pages.reverse
condition = page.condition
if condition.variable_valid and
condition.variable_id == XAS_BA::ENEMY_ID_VARIABLE_ID and
(!condition.switch1_valid or $game_switches[condition.switch1_id]) and
(!condition.switch2_valid or $game_switches[condition.switch2_id])
@enemy_id = condition.variable_value
break
end
end
if @enemy_id == 0
return
end
troop_id = -1
member_index = -1
for troop in $data_troops
next if troop == nil
for enemy in troop.members
if enemy.enemy_id == @enemy_id
troop_id = $data_troops.index(troop)
member_index = troop.members.index(enemy)
break
end
end
end
if troop_id != -1 and member_index != -1
@battler = Game_Enemy.new(troop_id, member_index)
end
end
#--------------------------------------------------------------------------
# Enemy Id
#--------------------------------------------------------------------------
def enemy_id
self.battler
return @enemy_id
end
#--------------------------------------------------------------------------
# Treasure Dispose
#--------------------------------------------------------------------------
def treasure_dispose
if self.battler == nil and self.is_a?(Game_Event)
for pg in @event.pages
if pg.condition.variable_id == 10000 and
pg.condition.variable_value > 0
pg.condition.variable_value -= 1
if pg.condition.variable_value < 100
self.zoom_x -= 0.01 if self.zoom_x > 0.01
end
elsif pg.condition.variable_id == 10000 and
pg.condition.variable_value == 0
$game_map.remove_token(self)
end
end
end
end
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
alias xrxs64c_update update
def update
if @collapse_wait_count.to_i > 0
@collapse_wait_count -= 1
if @collapse_wait_count == 0
@collapse_wait_count = nil
$game_map.remove_token(self)
end
return
end
treasure_dispose
update_sensor
xrxs64c_update
if self.battler != nil
self.battler.remove_states_auto
end
if self.collapse_duration.to_i > 0
@through = true
end
if self.collapse_done
[url=home.php?mod=space&uid=316553]@opacity[/url] = 0
@collapse_wait_count = 32
return
end
end
#--------------------------------------------------------------------------
# Hit Reaction ON
#--------------------------------------------------------------------------
def hit_reaction_on
self.hit_reaction = true
end
#--------------------------------------------------------------------------
# Hit Reaction Off
#--------------------------------------------------------------------------
def hit_reaction_off
self.hit_reaction = false
end
#--------------------------------------------------------------------------
# Hp Hit Reaction
#--------------------------------------------------------------------------
def hp_hit_reaction(on)
lowhp = self.battler.maxhp * XAS_BA_ENEMY::LOWHP / 100
if self.battler.hp > lowhp
self.hit_reaction = on
else
if on == true
self.hit_reaction = false
else
self.hit_reaction = true
end
end
end
#--------------------------------------------------------------------------
# Hero Level Hit Reaction
#--------------------------------------------------------------------------
def hero_level_hit_reaction(level,on)
actor = $game_party.actors[0]
if actor.level >= level
self.hit_reaction = on
else
if on == true
self.hit_reaction = false
else
self.hit_reaction = true
end
end
end
#--------------------------------------------------------------------------
# Shield Enable!
#--------------------------------------------------------------------------
def shield_enable!
@shield_disable = nil
end
#--------------------------------------------------------------------------
# Shield Disable!
#--------------------------------------------------------------------------
def shield_disable!
@shield_disable = true
end
#--------------------------------------------------------------------------
# LowHP Shield
#--------------------------------------------------------------------------
def lowhp_shield(on)
lowhp = self.battler.maxhp * XAS_BA_ENEMY::LOWHP / 100
if on == true
@shield_disable = true
elsif on == false
@shield_disable = nil
end
end
#--------------------------------------------------------------------------
# Hero HP Shield
#--------------------------------------------------------------------------
def hp_shield(on)
lowhp = self.battler.maxhp * XAS_BA_ENEMY::LOWHP / 100
if self.battler.hp > lowhp
if on == true
@shield_disable = nil
else
@shield_disable = true
end
else
if on == true
@shield_disable = true
else
@shield_disable = nil
end
end
end
#--------------------------------------------------------------------------
# Hero Level Shield
#--------------------------------------------------------------------------
def hero_level_shield(level,on)
actor = $game_party.actors[0]
if actor.level >= level
if on == true
@shield_disable = nil
else
@shield_disable = true
end
else
if on == true
@shield_disable = true
else
@shield_disable = nil
end
end
end
#--------------------------------------------------------------------------
# Shield Directions
#--------------------------------------------------------------------------
def shield_directions
set = @shield_disable ? [] : XAS_BA_ENEMY::SHILED_DIRECTIONS[self.enemy_id]
set = [] if set == nil
return set
end
#--------------------------------------------------------------------------
# Shield Actions
#--------------------------------------------------------------------------
def shield_actions
set = XAS_BA_ENEMY::SHILED_ACTIONS[self.enemy_id]
set = [] if set == nil
return set
end
#--------------------------------------------------------------------------
# Knock Back Disable
#--------------------------------------------------------------------------
def knock_back_disable
return XAS_BA_ENEMY::KNOCK_BACK_DISABLES.include?(self.enemy_id)
end
#--------------------------------------------------------------------------
# Body Size
#--------------------------------------------------------------------------
def body_size
return XAS_BA_ENEMY::BODY_SQUARE[self.enemy_id].to_i
end
#--------------------------------------------------------------------------
# Defeat Process
#--------------------------------------------------------------------------
def defeat_process
super
enemy_defeat_process(self.battler)
enemy_defeat_animation = XAS_BA_ENEMY::DEF_ANI[enemy_id]
if XAS_BA_ENEMY::DEF_ANI[enemy_id] != nil and not
terrain_tag == XAS::FALL_TERRAIN
self.animation_id = enemy_defeat_animation
end
end
end
#===============================================================================
# Game Event
#===============================================================================
class Game_Event < Game_Character
attr_reader :collision_attack
#--------------------------------------------------------------------------
# Img Act Exist?
#--------------------------------------------------------------------------
def img_act_exist?
RPG::Cache.character(@page.graphic.character_name + "_Act" , @page.graphic.character_hue) rescue return false
end
#--------------------------------------------------------------------------
# Attack ON
#--------------------------------------------------------------------------
def attack_on
if self.battler.is_a?(Game_Enemy) and
(self.battler.states.include?(XAS::MUTE_ID) or
self.battler.states.include?(XAS::SEALATTACK_ID))
@collision_attack = false
self.battler.damage = XAS::SEALED_TEXT
self.battler.damage_pop = true
return false
end
@collision_attack = true
self.animation_id = self.battler.animation1_id
if img_act_exist?
@character_name = @page.graphic.character_name + "_Act"
end
end
#--------------------------------------------------------------------------
# Attack Off
#--------------------------------------------------------------------------
def attack_off
@collision_attack = false
@character_name = @page.graphic.character_name
end
end
#===============================================================================
# Game_Player
#===============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# Check Event Trigger Touch
#--------------------------------------------------------------------------
alias xrxs64c_check_event_trigger_touch check_event_trigger_touch
def check_event_trigger_touch(x, y)
xrxs64c_check_event_trigger_touch(x, y)
if $game_system.map_interpreter.running?
return
end
for event in $game_map.events.values
next unless event.collision_attack
unless [1,2].include?(event.trigger)
if event.battler != nil and event.x == x and event.y == y
$game_player.attack_effect(event)
end
end
end
end
end
#===============================================================================
# Game_Event
#===============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# Check Event Trigger Touch
#--------------------------------------------------------------------------
alias xrxs64c_check_event_trigger_touch check_event_trigger_touch
def check_event_trigger_touch(x, y)
xrxs64c_check_event_trigger_touch(x, y)
if $game_system.map_interpreter.running?
return
end
return unless self.collision_attack
if self.battler != nil and x == $game_player.x and y == $game_player.y
$game_player.attack_effect(self)
end
end
end
#===============================================================================
# XAS_BA_BATTLEEVENT_NONPREEMPT
#===============================================================================
module XAS_BA_BATTLEEVENT_NONPREEMPT
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
def update
return if self.battler != nil and $game_system.map_interpreter.running?
super
end
end
#===============================================================================
# Game_Event
#===============================================================================
class Game_Event < Game_Character
include XAS_BA_BATTLEEVENT_NONPREEMPT
end
#===============================================================================
# Sprite_Character
#===============================================================================
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
alias xrxs64c_update update
def update
if @battler == nil
@battler = @character.battler
end
xrxs64c_update
if @battler == nil or @_collapse_duration > 0 or
@character.collapse_done
return
end
if @battler.hiblink_duration.is_a?(Numeric)
if XAS_BA::BLINK_ON == true
@character.opacity = (@character.opacity + 70) % 190 + 40
end
if XAS_ABS_SETUP::BATTLER_SHAKE_EFFECT == true and @character.knockbacking?
self.x = @character.screen_x + rand(5)
end
@battler.hiblink_duration -= 1
if @battler.hiblink_duration <= 0
@battler.hiblink_duration = nil
@character.opacity = 255
end
end
end
end
#===============================================================================
# Game_Character
#===============================================================================
class Game_Character
#--------------------------------------------------------------------------
# Blow
#--------------------------------------------------------------------------
def blow(d, power = 1)
@knock_back_prespeed = @move_speed if @knock_back_prespeed == nil
if self.knock_back_disable and (self.battler.xas_states_sleep == true or
self.battler.xas_states_stop == true)
@move_speed = XAS_BA::KNOCK_BACK_SPEED
end
return if self.knock_back_disable
power.times do
if passable?(self.x, self.y, d)
@x += ([3,6,9].include?(d) ? 1 : [1,4,7].include?(d) ? -1 : 0)
@y += ([1,2,3].include?(d) ? 1 : [7,8,9].include?(d) ? -1 : 0)
end
end
if self.battler.is_a?(Game_Enemy)
enemy_knock_duration = XAS_BA_ENEMY::INVICIBLE_DURATION_ENEMY[enemy_id]
if enemy_knock_duration != nil
@knock_back_duration = enemy_knock_duration
else
@knock_back_duration = XAS_BA_ENEMY::DEFAULT_INVICIBLE_DURATION_ENEMY
end
else
@knock_back_duration = XAS_BA::KNOCK_BACK_DURATION_HERO
end
@move_speed = XAS_BA::KNOCK_BACK_SPEED
end
#--------------------------------------------------------------------------
# Hit Image Check
#--------------------------------------------------------------------------
def hit_image_check
if self.battler.is_a?(Game_Enemy)
@collision_attack = false
if img_hit_enemy_exist? and not
self.battler.xas_states_stop == true
@character_name = @page.graphic.character_name + "_Hit"
end
else
if img_hit_actor_exist?(@actor) and not
self.battler.xas_states_stop == true
@character_name = @actor.character_name + "_Hit"
end
end
end
#--------------------------------------------------------------------------
# Fall Effect Update
#--------------------------------------------------------------------------
def fall_effect_update
unless moving? or jumping? or
self.is_a?(Game_Player)
if terrain_tag == XAS::FALL_TERRAIN and
@through == false
if @erased == false
self.animation_id = XAS::FALL_ANIMATION_ID
self.erase
end
end
end
if terrain_tag == XAS::SLIP_TERRAIN and @through == false
jump(0,0) unless jumping?
@y += 1
end
end
#--------------------------------------------------------------------------
# knockbacking?
#--------------------------------------------------------------------------
def knockbacking?
return @knock_back_duration != nil
end
#--------------------------------------------------------------------------
# Collapsing?
#--------------------------------------------------------------------------
def collapsing?
return self.collapse_duration.to_i > 0
end
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
alias xrxs64c_nb_update update
def update
@stop_count = -1 if self.knockbacking? or self.dead?
xrxs64c_nb_update
throw_update
fall_effect_update
if self.knockbacking?
hit_image_check
@pattern = 0
unless self.battler.xas_states_stop == true or
self.battler.xas_states_sleep == true or
self.dead?
@knock_back_duration -= 1
end
if @knock_back_duration <= 0
unless self.erased == true
if self.battler.is_a?(Game_Enemy)
@character_name = @page.graphic.character_name
else
@character_name = @actor.character_name
end
end
@knock_back_duration = nil
@move_speed = @knock_back_prespeed
@knock_back_prespeed = nil
end
return
end
end
end
#===============================================================================
# XAS_DamageStop
#===============================================================================
module XAS_DamageStop
#--------------------------------------------------------------------------
# Actiong?
#--------------------------------------------------------------------------
def acting?
return (super or self.knockbacking? or self.collapsing?)
end
end
#===============================================================================
# Game_Player
#===============================================================================
class Game_Player < Game_Character
include XAS_DamageStop
end
#===============================================================================
# Game_Event
#===============================================================================
class Game_Event < Game_Character
include XAS_DamageStop
end
#===============================================================================
# module RPG
#===============================================================================
module RPG
class Sprite < ::Sprite
#--------------------------------------------------------------------------
# Dispose Animation
#--------------------------------------------------------------------------
def dispose_animation
if @_animation_sprites != nil
sprite = @_animation_sprites[0]
if sprite != nil
@@_reference_count[sprite.bitmap] -= 1
end
for sprite in @_animation_sprites
sprite.dispose
end
@_animation_sprites = nil
@_animation = nil
end
end
end
end
#===============================================================================
# Game_Map
#===============================================================================
class Game_Map
#--------------------------------------------------------------------------
# Starting?
#--------------------------------------------------------------------------
def starting?
if $game_system.map_interpreter.running?
return true
end
for event in $game_map.events.values
return true if event.starting
end
return false
end
end
#===============================================================================
# class Interpreter
#===============================================================================
module XAS_ACTION
#--------------------------------------------------------------------------
# Xas Z Shoot Bullet
#--------------------------------------------------------------------------
alias xas_z_shoot_bullet shoot_bullet
def shoot_bullet(action_id)
bullet_token = xas_z_shoot_bullet(action_id)
return bullet_token
end
end
#===============================================================================
# Sprite_Battler Fix
#===============================================================================
class Sprite_Battler < RPG::Sprite
alias xas_damage_update update
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
def update
super
if @battler_visible
if @battler.damage_pop
damage(@battler.damage, @battler.critical,@battler.state,@battler.item)
@battler.damage = nil
@battler.critical = false
@battler.damage_pop = false
end
end
xas_damage_update
end
end
复制代码
作者:
garyfrank
时间:
2012-12-16 14:38
使用3.82版本 同樣方法則顯示
GAME MAP 的305 行發生了NOMETHODERROR UNDEFINED METHOD > FOR NIL:NILCLASS
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles the map. It includes scrolling and passable determining
# functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :tileset_name # tileset file name
attr_accessor :autotile_names # autotile file name
attr_accessor :panorama_name # panorama file name
attr_accessor :panorama_hue # panorama hue
attr_accessor :fog_name # fog file name
attr_accessor :fog_hue # fog hue
attr_accessor :fog_opacity # fog opacity level
attr_accessor :fog_blend_type # fog blending method
attr_accessor :fog_zoom # fog zoom rate
attr_accessor :fog_sx # fog sx
attr_accessor :fog_sy # fog sy
attr_accessor :battleback_name # battleback file name
attr_accessor :display_x # display x-coordinate * 128
attr_accessor :display_y # display y-coordinate * 128
attr_accessor :need_refresh # refresh request flag
attr_reader :passages # passage table
attr_reader :priorities # prioroty table
attr_reader :terrain_tags # terrain tag table
attr_reader :events # events
attr_reader :fog_ox # fog x-coordinate starting point
attr_reader :fog_oy # fog y-coordinate starting point
attr_reader :fog_tone # fog color tone
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@map_id = 0
@display_x = 0
@display_y = 0
end
#--------------------------------------------------------------------------
# * Setup
# map_id : map ID
#--------------------------------------------------------------------------
def setup(map_id)
# Put map ID in @map_id memory
@map_id = map_id
# Load map from file and set @map
@map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
# set tile set information in opening instance variables
tileset = $data_tilesets[@map.tileset_id]
@tileset_name = tileset.tileset_name
@autotile_names = tileset.autotile_names
@panorama_name = tileset.panorama_name
@panorama_hue = tileset.panorama_hue
@fog_name = tileset.fog_name
@fog_hue = tileset.fog_hue
@fog_opacity = tileset.fog_opacity
@fog_blend_type = tileset.fog_blend_type
@fog_zoom = tileset.fog_zoom
@fog_sx = tileset.fog_sx
@fog_sy = tileset.fog_sy
@battleback_name = tileset.battleback_name
@passages = tileset.passages
@priorities = tileset.priorities
@terrain_tags = tileset.terrain_tags
# Initialize displayed coordinates
@display_x = 0
@display_y = 0
# Clear refresh request flag
@need_refresh = false
# Set map event data
@events = {}
for i in @map.events.keys
@events[i] = Game_Event.new(@map_id, @map.events[i])
end
# Set common event data
@common_events = {}
for i in 1...$data_common_events.size
@common_events[i] = Game_CommonEvent.new(i)
end
# Initialize all fog information
@fog_ox = 0
@fog_oy = 0
@fog_tone = Tone.new(0, 0, 0, 0)
@fog_tone_target = Tone.new(0, 0, 0, 0)
@fog_tone_duration = 0
@fog_opacity_duration = 0
@fog_opacity_target = 0
# Initialize scroll information
@scroll_direction = 2
@scroll_rest = 0
@scroll_speed = 4
end
#--------------------------------------------------------------------------
# * Get Map ID
#--------------------------------------------------------------------------
def map_id
return @map_id
end
#--------------------------------------------------------------------------
# * Get Width
#--------------------------------------------------------------------------
def width
return @map.width
end
#--------------------------------------------------------------------------
# * Get Height
#--------------------------------------------------------------------------
def height
return @map.height
end
#--------------------------------------------------------------------------
# * Get Encounter List
#--------------------------------------------------------------------------
def encounter_list
return @map.encounter_list
end
#--------------------------------------------------------------------------
# * Get Encounter Steps
#--------------------------------------------------------------------------
def encounter_step
return @map.encounter_step
end
#--------------------------------------------------------------------------
# * Get Map Data
#--------------------------------------------------------------------------
def data
return @map.data
end
#--------------------------------------------------------------------------
# * Automatically Change Background Music and Backround Sound
#--------------------------------------------------------------------------
def autoplay
if @map.autoplay_bgm
$game_system.bgm_play(@map.bgm)
end
if @map.autoplay_bgs
$game_system.bgs_play(@map.bgs)
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# If map ID is effective
if @map_id > 0
# Refresh all map events
for event in @events.values
event.refresh
end
# Refresh all common events
for common_event in @common_events.values
common_event.refresh
end
end
# Clear refresh request flag
@need_refresh = false
end
#--------------------------------------------------------------------------
# * Scroll Down
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_down(distance)
@display_y = [@display_y + distance, (self.height - 15) * 128].min
end
#--------------------------------------------------------------------------
# * Scroll Left
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_left(distance)
@display_x = [@display_x - distance, 0].max
end
#--------------------------------------------------------------------------
# * Scroll Right
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_right(distance)
@display_x = [@display_x + distance, (self.width - 20) * 128].min
end
#--------------------------------------------------------------------------
# * Scroll Up
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_up(distance)
@display_y = [@display_y - distance, 0].max
end
#--------------------------------------------------------------------------
# * Determine Valid Coordinates
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
def valid?(x, y)
return (x >= 0 and x < width and y >= 0 and y < height)
end
#--------------------------------------------------------------------------
# * Determine if Passable
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8,10)
# * 0,10 = determine if all directions are impassable
# self_event : Self (If event is determined passable)
#--------------------------------------------------------------------------
def passable?(x, y, d, self_event = nil)
# If coordinates given are outside of the map
unless valid?(x, y)
# impassable
return false
end
# Change direction (0,2,4,6,8,10) to obstacle bit (0,1,2,4,8,0)
bit = (1 << (d / 2 - 1)) & 0x0f
# Loop in all events
for event in events.values
# If tiles other than self are consistent with coordinates
if event.tile_id >= 0 and event != self_event and
event.x == x and event.y == y and not event.through
# If obstacle bit is set
if @passages[event.tile_id] & bit != 0
# impassable
return false
# If obstacle bit is set in all directions
elsif @passages[event.tile_id] & 0x0f == 0x0f
# impassable
return false
# If priorities other than that are 0
elsif @priorities[event.tile_id] == 0
# passable
return true
end
end
end
# Loop searches in order from top of layer
for i in [2, 1, 0]
# Get tile ID
tile_id = data[x, y, i]
# Tile ID acquistion failure
if tile_id == nil
# impassable
return false
# If obstacle bit is set
elsif @passages[tile_id] & bit != 0
# impassable
return false
# If obstacle bit is set in all directions
elsif @passages[tile_id] & 0x0f == 0x0f
# impassable
return false
# If priorities other than that are 0
elsif @priorities[tile_id] == 0
# passable
return true
end
end
# passable
return true
end
#--------------------------------------------------------------------------
# * Determine Thicket
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
def bush?(x, y)
if @map_id != 0
for i in [2, 1, 0]
tile_id = data[x, y, i]
if tile_id == nil
return false
elsif @passages[tile_id] & 0x40 == 0x40
return true
end
end
end
return false
end
#--------------------------------------------------------------------------
# * Determine Counter
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
def counter?(x, y)
if @map_id != 0
for i in [2, 1, 0]
tile_id = data[x, y, i]
if tile_id == nil
return false
elsif @passages[tile_id] & 0x80 == 0x80
return true
end
end
end
return false
end
#--------------------------------------------------------------------------
# * Get Terrain Tag
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
def terrain_tag(x, y)
if @map_id != 0
for i in [2, 1, 0]
tile_id = data[x, y, i]
if tile_id == nil
return 0
elsif @terrain_tags[tile_id] > 0
return @terrain_tags[tile_id]
end
end
end
return 0
end
#--------------------------------------------------------------------------
# * Get Designated Position Event ID
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
def check_event(x, y)
for event in $game_map.events.values
if event.x == x and event.y == y
return event.id
end
end
end
#--------------------------------------------------------------------------
# * Start Scroll
# direction : scroll direction
# distance : scroll distance
# speed : scroll speed
#--------------------------------------------------------------------------
def start_scroll(direction, distance, speed)
@scroll_direction = direction
@scroll_rest = distance * 128
@scroll_speed = speed
end
#--------------------------------------------------------------------------
# * Determine if Scrolling
#--------------------------------------------------------------------------
def scrolling?
return @scroll_rest > 0
end
#--------------------------------------------------------------------------
# * Start Changing Fog Color Tone
# tone : color tone
# duration : time
#--------------------------------------------------------------------------
def start_fog_tone_change(tone, duration)
@fog_tone_target = tone.clone
@fog_tone_duration = duration
if @fog_tone_duration == 0
@fog_tone = @fog_tone_target.clone
end
end
#--------------------------------------------------------------------------
# * Start Changing Fog Opacity Level
# opacity : opacity level
# duration : time
#--------------------------------------------------------------------------
def start_fog_opacity_change(opacity, duration)
@fog_opacity_target = opacity * 1.0
@fog_opacity_duration = duration
if @fog_opacity_duration == 0
@fog_opacity = @fog_opacity_target
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Refresh map if necessary
if $game_map.need_refresh
refresh
end
# If scrolling
if @scroll_rest > 0
# Change from scroll speed to distance in map coordinates
distance = 2 ** @scroll_speed
# Execute scrolling
case @scroll_direction
when 2 # Down
scroll_down(distance)
when 4 # Left
scroll_left(distance)
when 6 # Right
scroll_right(distance)
when 8 # Up
scroll_up(distance)
end
# Subtract distance scrolled
@scroll_rest -= distance
end
# Update map event
for event in @events.values
event.update
end
# Update common event
for common_event in @common_events.values
common_event.update
end
# Manage fog scrolling
@fog_ox -= @fog_sx / 8.0
@fog_oy -= @fog_sy / 8.0
# Manage change in fog color tone
if @fog_tone_duration >= 1
d = @fog_tone_duration
target = @fog_tone_target
@fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
@fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
@fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
@fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
@fog_tone_duration -= 1
end
# Manage change in fog opacity level
if @fog_opacity_duration >= 1
d = @fog_opacity_duration
@fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
@fog_opacity_duration -= 1
end
end
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1