mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-07-23 08:07:02 +00:00
Update 6.8
This commit is contained in:
@@ -25,7 +25,6 @@ class Game_Temp
|
||||
attr_accessor :fadestate # for sprite hashes
|
||||
attr_accessor :background_bitmap
|
||||
attr_accessor :mart_prices
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# * Object Initialization
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#TODO: Do not autoformat this file
|
||||
|
||||
#==============================================================================
|
||||
# ** Game_System
|
||||
#------------------------------------------------------------------------------
|
||||
@@ -20,7 +22,7 @@ class Game_System
|
||||
attr_accessor :autoscroll_x_speed
|
||||
attr_accessor :autoscroll_y_speed
|
||||
attr_accessor :bgm_position
|
||||
|
||||
attr_reader :defaultBGM
|
||||
def initialize
|
||||
@map_interpreter = Interpreter.new(0, true)
|
||||
@battle_interpreter = Interpreter.new(0, false)
|
||||
@@ -42,10 +44,13 @@ class Game_System
|
||||
################################################################################
|
||||
|
||||
def bgm_play(bgm)
|
||||
begin
|
||||
old_pos = @bgm_position
|
||||
@bgm_position = 0
|
||||
bgm_play_internal(bgm,0)
|
||||
@bgm_position = old_pos
|
||||
rescue
|
||||
end
|
||||
end
|
||||
|
||||
def bgm_play_internal2(name,volume,pitch,position) # :nodoc:
|
||||
@@ -62,7 +67,7 @@ class Game_System
|
||||
def bgm_play_internal(bgm,position) # :nodoc:
|
||||
@bgm_position = position if !@bgm_paused
|
||||
@playing_bgm = (bgm==nil) ? nil : bgm.clone
|
||||
if bgm!=nil && bgm.name!=""
|
||||
if (bgm!=nil && bgm.name!="")
|
||||
if FileTest.audio_exist?("Audio/BGM/"+bgm.name)
|
||||
bgm_play_internal2("Audio/BGM/"+bgm.name,
|
||||
bgm.volume,bgm.pitch,@bgm_position) if !@defaultBGM
|
||||
@@ -122,6 +127,7 @@ class Game_System
|
||||
|
||||
# Plays the currently memorized background music
|
||||
def bgm_restore
|
||||
echoln @memorized_bgm
|
||||
bgm_play(@memorized_bgm)
|
||||
end
|
||||
|
||||
@@ -131,7 +137,9 @@ class Game_System
|
||||
end
|
||||
|
||||
def setDefaultBGM(bgm,volume=80,pitch=100)
|
||||
bgm = RPG::AudioFile.new(bgm,volume,pitch) if bgm.is_a?(String)
|
||||
|
||||
#@defaultBGM = bgm.clone
|
||||
bgm = RPG::AudioFile.new(bgm) if bgm.is_a?(String)
|
||||
if bgm!=nil && bgm.name!=""
|
||||
@defaultBGM = nil
|
||||
self.bgm_play(bgm)
|
||||
|
||||
@@ -38,6 +38,9 @@ class Game_Map
|
||||
attr_accessor :need_refresh # refresh request flag
|
||||
attr_accessor :scroll_direction
|
||||
|
||||
attr_accessor :fog2_name
|
||||
attr_accessor :fog2_opacity
|
||||
|
||||
TILE_WIDTH = 32
|
||||
TILE_HEIGHT = 32
|
||||
X_SUBPIXELS = 4
|
||||
@@ -64,6 +67,7 @@ class Game_Map
|
||||
@fog2_sx = 0
|
||||
@fog2_sy = 0
|
||||
@fog2_opacity = 0
|
||||
@fog2_name = ""
|
||||
|
||||
@fog_tone = Tone.new(0, 0, 0, 0)
|
||||
@fog_tone_target = Tone.new(0, 0, 0, 0)
|
||||
@@ -76,7 +80,7 @@ class Game_Map
|
||||
Events.onMapCreate.trigger(self, map_id, @map, tileset)
|
||||
@events = {}
|
||||
for i in @map.events.keys
|
||||
@events[i] = Game_Event.new(@map_id, @map.events[i], self)
|
||||
@events[i] = create_new_game_event(@map.events[i])
|
||||
end
|
||||
@common_events = {}
|
||||
for i in 1...$data_common_events.size
|
||||
@@ -87,6 +91,10 @@ class Game_Map
|
||||
@scroll_speed = 4
|
||||
end
|
||||
|
||||
def create_new_game_event(event)
|
||||
return Game_Event.new(@map_id, event, self)
|
||||
end
|
||||
|
||||
def updateTileset
|
||||
tileset = $data_tilesets[@map.tileset_id]
|
||||
@tileset_name = tileset.tileset_name
|
||||
@@ -126,7 +134,7 @@ class Game_Map
|
||||
return @map.data;
|
||||
end
|
||||
|
||||
def tileset_id;
|
||||
def tileset_id
|
||||
return @map.tileset_id;
|
||||
end
|
||||
|
||||
@@ -153,21 +161,26 @@ class Game_Map
|
||||
end
|
||||
end
|
||||
|
||||
def setFog2(filename,sx=0,sy=0,opacity=32)
|
||||
def bgm
|
||||
return @map.bgm
|
||||
end
|
||||
|
||||
def setFog2(filename,sx=0,sy=0,opacity=32,zoom=nil)
|
||||
@fog2_name = filename
|
||||
@fog2_sx=sx
|
||||
@fog2_sy=-sy
|
||||
@fog2_opacity = opacity
|
||||
$scene.spriteset.setFog2(filename)
|
||||
@fog_zoom = zoom if zoom
|
||||
$scene.spriteset.setFog2(filename) if $scene.is_a?(Scene_Map)
|
||||
end
|
||||
|
||||
def eraseFog2()
|
||||
@fog2_sx=0
|
||||
@fog2_sy=-0
|
||||
@fog2_sx = 0
|
||||
@fog2_sy = -0
|
||||
@fog2_opacity = 0
|
||||
$scene.spriteset.disposeFog2()
|
||||
end
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# * Plays background music
|
||||
# Plays music called "[normal BGM]_n" if it's night time and it exists
|
||||
@@ -237,6 +250,16 @@ class Game_Map
|
||||
for i in [2, 1, 0]
|
||||
tile_id = data[x, y, i]
|
||||
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
|
||||
|
||||
# BRIDGE LOGIC FOR NPCs
|
||||
# If we are on a bridge, ignore non-bridge tiles (like water underneath)
|
||||
if terrain.bridge && $PokemonGlobal.bridge > 0
|
||||
passage = @passages[tile_id]
|
||||
return (passage & bit == 0 && passage & 0x0f != 0x0f)
|
||||
end
|
||||
next if terrain.bridge && $PokemonGlobal.bridge == 0
|
||||
|
||||
|
||||
# If already on water, only allow movement to another water tile
|
||||
if self_event != nil && terrain.can_surf_freely
|
||||
for j in [2, 1, 0]
|
||||
@@ -262,6 +285,8 @@ class Game_Map
|
||||
break if facing_terrain.id != :None && !facing_terrain.ignore_passability
|
||||
end
|
||||
end
|
||||
return true if terrain.acroBike && $PokemonGlobal.bicycle
|
||||
|
||||
# Regular passability checks
|
||||
if !terrain || !terrain.ignore_passability
|
||||
passage = @passages[tile_id]
|
||||
@@ -276,15 +301,55 @@ class Game_Map
|
||||
bit = (1 << (d / 2 - 1)) & 0x0f
|
||||
for i in [2, 1, 0]
|
||||
tile_id = data[x, y, i]
|
||||
next unless tile_id
|
||||
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
|
||||
passage = @passages[tile_id]
|
||||
if terrain
|
||||
# Ignore bridge tiles if not on a bridge
|
||||
next if terrain.bridge && $PokemonGlobal.bridge == 0
|
||||
# Make water tiles passable if player is surfing
|
||||
return true if $PokemonGlobal.surfing && terrain.can_surf && !terrain.waterfall
|
||||
return true if ($PokemonGlobal.surfing || $PokemonGlobal.boat) && terrain.can_surf && !terrain.waterfall
|
||||
# Prevent cycling in really tall grass/on ice
|
||||
return false if $PokemonGlobal.bicycle && terrain.must_walk
|
||||
# return false if $PokemonGlobal.bicycle && terrain.must_walk
|
||||
# Depend on passability of bridge tile if on bridge
|
||||
if terrain.bridge && $PokemonGlobal.bridge > 0
|
||||
return (passage & bit == 0 && passage & 0x0f != 0x0f)
|
||||
end
|
||||
end
|
||||
# Regular passability checks
|
||||
if !terrain || !terrain.ignore_passability
|
||||
return false if passage & bit != 0 || passage & 0x0f == 0x0f
|
||||
return true if @priorities[tile_id] == 0
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
# Just a copy of playerPassable? without the ledges
|
||||
def OWPokemonPassable?(x, y, d, self_event = nil)
|
||||
return false if x== $game_player.x && y == $game_player.y
|
||||
return false if $game_map.event_at_position(x, y)
|
||||
bit = (1 << (d / 2 - 1)) & 0x0f
|
||||
for i in [2, 1, 0]
|
||||
tile_id = data[x, y, i]
|
||||
next unless tile_id
|
||||
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
|
||||
passage = @passages[tile_id]
|
||||
if terrain
|
||||
return false if terrain.ledge
|
||||
return false if terrain.acroBike
|
||||
# Ignore bridge tiles if not on a bridge
|
||||
next if terrain.bridge && $PokemonGlobal.bridge == 0
|
||||
# Make water tiles passable if player is surfing
|
||||
if terrain.can_surf && !terrain.waterfall
|
||||
if ($PokemonGlobal.surfing || $PokemonGlobal.boat)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
# Prevent cycling in really tall grass/on ice
|
||||
# return false if $PokemonGlobal.bicycle && terrain.must_walk
|
||||
# Depend on passability of bridge tile if on bridge
|
||||
if terrain.bridge && $PokemonGlobal.bridge > 0
|
||||
return (passage & bit == 0 && passage & 0x0f != 0x0f)
|
||||
@@ -375,6 +440,7 @@ class Game_Map
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
def get_event_at_position(x, y, excluding_IDs = [])
|
||||
for event in self.events.values
|
||||
next if excluding_IDs.include?(event.id)
|
||||
@@ -383,6 +449,14 @@ class Game_Map
|
||||
return nil
|
||||
end
|
||||
|
||||
def get_events_with_name(name)
|
||||
events_with_name = []
|
||||
for event in self.events.values
|
||||
events_with_name << event if event.name.downcase == name.downcase
|
||||
end
|
||||
return events_with_name
|
||||
end
|
||||
|
||||
def display_x=(value)
|
||||
return if @display_x == value
|
||||
@display_x = value
|
||||
|
||||
@@ -13,7 +13,7 @@ class Game_Character
|
||||
attr_accessor :character_name
|
||||
attr_accessor :character_hue
|
||||
attr_reader :opacity
|
||||
attr_reader :blend_type
|
||||
attr_accessor :blend_type
|
||||
attr_accessor :direction
|
||||
attr_accessor :pattern
|
||||
attr_accessor :pattern_surf
|
||||
@@ -25,10 +25,15 @@ class Game_Character
|
||||
attr_reader :move_speed
|
||||
attr_accessor :walk_anime
|
||||
attr_writer :bob_height
|
||||
attr_accessor :under_everything #under even grass
|
||||
attr_accessor :under_player #always under the player, but over grass, etc.
|
||||
attr_accessor :under_everything # under even grass
|
||||
attr_accessor :under_player # always under the player, but over grass, etc.
|
||||
attr_accessor :direction_fix
|
||||
attr_accessor :always_on_top
|
||||
attr_accessor :forced_bush_depth
|
||||
attr_reader :move_route
|
||||
attr_accessor :shadow_offset
|
||||
attr_accessor :animation_speed
|
||||
attr_accessor :step_anime
|
||||
|
||||
def initialize(map = nil)
|
||||
@map = map
|
||||
@@ -79,9 +84,12 @@ class Game_Character
|
||||
@moved_this_frame = false
|
||||
@locked = false
|
||||
@prelock_direction = 0
|
||||
@under_everything=false
|
||||
@under_everything = false
|
||||
@under_player = false
|
||||
@forced_z=nil
|
||||
@forced_z = nil
|
||||
@forced_bush_depth = nil
|
||||
@shadow_offset =0
|
||||
@animation_speed = nil #override if the animation speed needs to be different from move speed
|
||||
end
|
||||
|
||||
def at_coordinate?(check_x, check_y)
|
||||
@@ -106,6 +114,15 @@ class Game_Character
|
||||
@opacity = opacity
|
||||
end
|
||||
|
||||
def set_animation_speed(speed)
|
||||
#echoln "animation_speed = #{speed}"
|
||||
@animation_speed = speed
|
||||
end
|
||||
|
||||
def reset_animation_speed(speed)
|
||||
@animation_speed = nil
|
||||
end
|
||||
|
||||
def move_speed=(val)
|
||||
return if val == @move_speed
|
||||
@move_speed = val
|
||||
@@ -213,6 +230,10 @@ class Game_Character
|
||||
end
|
||||
|
||||
def calculate_bush_depth
|
||||
if @forced_bush_depth
|
||||
@bush_depth = @forced_bush_depth
|
||||
return
|
||||
end
|
||||
if @tile_id > 0 || @always_on_top || jumping?
|
||||
@bush_depth = 0
|
||||
else
|
||||
@@ -240,6 +261,26 @@ class Game_Character
|
||||
return $game_map.terrain_tag(facing[1], facing[2])
|
||||
end
|
||||
|
||||
#like pbFacingTerrainTag, but doesn't care about passability
|
||||
def getTerrainTagDirectlyInFront()
|
||||
x = $game_player.x
|
||||
y= $game_player.y
|
||||
|
||||
case @direction
|
||||
when DIRECTION_UP
|
||||
y= $game_player.y-1
|
||||
when DIRECTION_DOWN
|
||||
y= $game_player.y+1
|
||||
when DIRECTION_LEFT
|
||||
x= $game_player.x-1
|
||||
when DIRECTION_RIGHT
|
||||
x= $game_player.x+1
|
||||
end
|
||||
return $game_map.terrain_tag(x, y)
|
||||
end
|
||||
def getTerrainTag()
|
||||
return $game_map.terrain_tag($game_player.x, $game_player.y)
|
||||
end
|
||||
|
||||
def passable?(x, y, d, strict = false)
|
||||
return false if self == $game_player && $game_switches[SWITCH_LOCK_PLAYER_MOVEMENT]
|
||||
@@ -247,7 +288,7 @@ class Game_Character
|
||||
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
|
||||
return false unless self.map.valid?(new_x, new_y)
|
||||
if self.character_name == "SHARPEDO" || self.character_name == "nightmare"
|
||||
return false if pbFacingTerrainTag().id==:SharpedoObstacle
|
||||
return false if pbFacingTerrainTag().id == :SharpedoObstacle
|
||||
end
|
||||
return true if @through
|
||||
|
||||
@@ -346,13 +387,14 @@ class Game_Character
|
||||
return 0 if @under_player
|
||||
return 999 if @always_on_top
|
||||
return @forced_z if @forced_z
|
||||
return 999 if @on_bridge && $PokemonGlobal.bridge <= 0
|
||||
z = screen_y_ground
|
||||
if @tile_id > 0
|
||||
begin
|
||||
return z + self.map.priorities[@tile_id] * 32
|
||||
rescue
|
||||
return 0
|
||||
#raise "Event's graphic is an out-of-range tile (event #{@id}, map #{self.map.map_id})"
|
||||
# raise "Event's graphic is an out-of-range tile (event #{@id}, map #{self.map.map_id})"
|
||||
end
|
||||
end
|
||||
# Add z if height exceeds 32
|
||||
@@ -361,10 +403,14 @@ class Game_Character
|
||||
|
||||
def opposite_direction
|
||||
case @direction
|
||||
when DIRECTION_LEFT; return DIRECTION_RIGHT
|
||||
when DIRECTION_RIGHT; return DIRECTION_LEFT
|
||||
when DIRECTION_UP; return DIRECTION_DOWN
|
||||
when DIRECTION_DOWN; return DIRECTION_UP
|
||||
when DIRECTION_LEFT;
|
||||
return DIRECTION_RIGHT
|
||||
when DIRECTION_RIGHT;
|
||||
return DIRECTION_LEFT
|
||||
when DIRECTION_UP;
|
||||
return DIRECTION_DOWN
|
||||
when DIRECTION_DOWN;
|
||||
return DIRECTION_UP
|
||||
else
|
||||
return DIRECTION_ALL
|
||||
end
|
||||
@@ -389,7 +435,6 @@ class Game_Character
|
||||
end
|
||||
|
||||
def force_move_route(move_route)
|
||||
#echoln screen_z() if self == $game_player
|
||||
if @original_move_route == nil
|
||||
@original_move_route = @move_route
|
||||
@original_move_route_index = @move_route_index
|
||||
@@ -458,6 +503,28 @@ class Game_Character
|
||||
end
|
||||
end
|
||||
|
||||
def move_type_away_from_player
|
||||
# Calculate distance from player
|
||||
sx = @x + @width / 2.0 - ($game_player.x + $game_player.width / 2.0)
|
||||
sy = @y - @height / 2.0 - ($game_player.y - $game_player.height / 2.0)
|
||||
|
||||
# If far from player, just move randomly
|
||||
if sx.abs + sy.abs >= 20
|
||||
move_random
|
||||
return
|
||||
end
|
||||
# Randomized movement behavior
|
||||
case rand(6)
|
||||
when 0..3
|
||||
move_away_from_player # move in the opposite direction
|
||||
when 4
|
||||
move_random # occasional random step
|
||||
when 5
|
||||
move_forward # maybe just move forward
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def move_type_custom
|
||||
return if jumping? || moving?
|
||||
while @move_route_index < @move_route.list.size
|
||||
@@ -602,6 +669,14 @@ class Game_Character
|
||||
pbSEPlay(command.parameters[0])
|
||||
when 45 then
|
||||
eval(command.parameters[0])
|
||||
when PBMoveRoute::PlayAnimation then
|
||||
playAnimation(command.parameters[0],@x,@y)
|
||||
when PBMoveRoute::FlyForward then
|
||||
fly_forward
|
||||
when PBMoveRoute::SetFloatingOn then
|
||||
@floating = true
|
||||
when PBMoveRoute::SetFloatingOff then
|
||||
@floating = false
|
||||
end
|
||||
@move_route_index += 1
|
||||
end
|
||||
@@ -886,6 +961,15 @@ class Game_Character
|
||||
end
|
||||
end
|
||||
|
||||
def fly_forward
|
||||
case @direction
|
||||
when DIRECTION_LEFT, DIRECTION_UP then
|
||||
move_upper_left
|
||||
when DIRECTION_RIGHT, DIRECTION_DOWN then
|
||||
move_upper_right
|
||||
end
|
||||
end
|
||||
|
||||
def move_forward
|
||||
case @direction
|
||||
when 2 then
|
||||
@@ -915,19 +999,19 @@ class Game_Character
|
||||
@direction_fix = last_direction_fix
|
||||
end
|
||||
|
||||
def jump_forward
|
||||
def jump_forward(distance = 1)
|
||||
case $game_player.direction
|
||||
when DIRECTION_DOWN
|
||||
x_direction = 0
|
||||
y_direction = 1
|
||||
y_direction = distance
|
||||
when DIRECTION_UP
|
||||
x_direction = 0
|
||||
y_direction = -1
|
||||
y_direction = 0 - distance
|
||||
when DIRECTION_LEFT
|
||||
x_direction = -1
|
||||
x_direction = 0 - distance
|
||||
y_direction = 0
|
||||
when DIRECTION_RIGHT
|
||||
x_direction = 1
|
||||
x_direction = distance
|
||||
y_direction = 0
|
||||
else
|
||||
x_direction = 0
|
||||
@@ -937,6 +1021,7 @@ class Game_Character
|
||||
end
|
||||
|
||||
def jump(x_plus, y_plus)
|
||||
@jump_in_place = (x_plus == 0 && y_plus == 0)
|
||||
if x_plus != 0 || y_plus != 0
|
||||
if x_plus.abs > y_plus.abs
|
||||
(x_plus < 0) ? turn_left : turn_right
|
||||
@@ -963,18 +1048,24 @@ class Game_Character
|
||||
if self.is_a?(Game_Player)
|
||||
$PokemonTemp.dependentEvents.pbMoveDependentEvents
|
||||
end
|
||||
triggerLeaveTile
|
||||
if x_plus != 0 || y_plus != 0
|
||||
triggerLeaveTile
|
||||
end
|
||||
end
|
||||
|
||||
def jumpForward
|
||||
case self.direction
|
||||
when 2 then
|
||||
jumpTowards(self.direction)
|
||||
end
|
||||
|
||||
def jumpTowards(direction)
|
||||
case direction
|
||||
when DIRECTION_DOWN then
|
||||
jump(0, 1) # down
|
||||
when 4 then
|
||||
when DIRECTION_LEFT then
|
||||
jump(-1, 0) # left
|
||||
when 6 then
|
||||
when DIRECTION_RIGHT then
|
||||
jump(1, 0) # right
|
||||
when 8 then
|
||||
when DIRECTION_UP then
|
||||
jump(0, -1) # up
|
||||
end
|
||||
end
|
||||
@@ -1131,12 +1222,14 @@ class Game_Character
|
||||
# 6 => @stop_count > 0 # 0 seconds
|
||||
if @stop_count >= self.move_frequency_real
|
||||
case @move_type
|
||||
when 1 then
|
||||
when MOVE_TYPE_RANDOM then
|
||||
move_type_random
|
||||
when 2 then
|
||||
when MOVE_TYPE_TOWARDS_PLAYER then
|
||||
move_type_toward_player
|
||||
when 3 then
|
||||
when MOVE_TYPE_CUSTOM then
|
||||
move_type_custom
|
||||
when MOVE_TYPE_AWAY_PLAYER then
|
||||
move_type_away_from_player
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1167,7 +1260,10 @@ class Game_Character
|
||||
end
|
||||
# End of a step, so perform events that happen at this time
|
||||
if !jumping? && !moving?
|
||||
Events.onStepTakenFieldMovement.trigger(self, self)
|
||||
unless @jump_in_place
|
||||
Events.onStepTakenFieldMovement.trigger(self, self)
|
||||
end
|
||||
@jump_in_place = false
|
||||
calculate_bush_depth
|
||||
@stopped_this_frame = true
|
||||
elsif !@moved_last_frame || @stopped_last_frame # Started a new step
|
||||
@@ -1205,11 +1301,30 @@ class Game_Character
|
||||
# it takes to move half a tile (or a whole tile if cycling). We assume the
|
||||
# game uses square tiles.
|
||||
real_speed = (jumping?) ? jump_speed_real : move_speed_real
|
||||
frames_per_pattern = Game_Map::REAL_RES_X / (real_speed * 2.0)
|
||||
frames_per_pattern *= 2 if move_speed >= 5 # Cycling speed or faster
|
||||
if @animation_speed
|
||||
base = Game_Map::REAL_RES_X / 2.0
|
||||
frames_per_pattern = base / @animation_speed
|
||||
else
|
||||
frames_per_pattern = Game_Map::REAL_RES_X / (real_speed * 2.0)
|
||||
frames_per_pattern *= 2 if move_speed >= 5 # Cycling speed or faster
|
||||
end
|
||||
return if @anime_count < frames_per_pattern
|
||||
# Advance to the next animation frame
|
||||
@pattern = (@pattern + 1) % 4
|
||||
@anime_count -= frames_per_pattern
|
||||
end
|
||||
|
||||
# def distance_from_player
|
||||
# dx = (@x - $game_player.x).abs
|
||||
# dy = (@y - $game_player.y).abs
|
||||
# return (dx + dy)-1 #-1 because not counting the event's or the player"s current tile
|
||||
# end
|
||||
def distance_from_player
|
||||
return Float::INFINITY if self.map_id != $game_map.map_id
|
||||
dx = (@x - $game_player.x).abs
|
||||
dy = (@y - $game_player.y).abs
|
||||
return (dx + dy) - 1
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -7,7 +7,9 @@ class Game_Event < Game_Character
|
||||
attr_reader :character_name
|
||||
attr_accessor :need_refresh
|
||||
attr_accessor :opacity
|
||||
attr_accessor :through
|
||||
attr_reader :page
|
||||
attr_reader :on_bridge
|
||||
attr_accessor :refresh_hue
|
||||
|
||||
def initialize(map_id, event, map=nil)
|
||||
super(map)
|
||||
@@ -20,20 +22,34 @@ class Game_Event < Game_Character
|
||||
@width = $~[1].to_i
|
||||
@height = $~[2].to_i
|
||||
end
|
||||
if @event.name[/bush_depth\((\d+)\)/i]
|
||||
@forced_bush_depth = $~[1].to_i
|
||||
end
|
||||
|
||||
@erased = false
|
||||
@starting = false
|
||||
@need_refresh = false
|
||||
@route_erased = false
|
||||
@through = true
|
||||
@to_update = true
|
||||
@need_refresh = true
|
||||
@refresh_hue = true
|
||||
@tempSwitches = {}
|
||||
if @event.name[/forced_z\s*=\s*(-?\d+)/i]
|
||||
@forced_z = $1.to_i
|
||||
end
|
||||
if @event.name.include?("on_bridge")
|
||||
@on_bridge = true
|
||||
end
|
||||
moveto(@event.x, @event.y) if map
|
||||
refresh
|
||||
end
|
||||
|
||||
def through
|
||||
return true if @on_bridge && $PokemonGlobal.bridge <= 0
|
||||
return @through
|
||||
end
|
||||
|
||||
def id; return @event.id; end
|
||||
def name; return @event.name; end
|
||||
|
||||
@@ -85,6 +101,7 @@ class Game_Event < Game_Character
|
||||
switchname = $data_system.switches[id]
|
||||
return false if !switchname
|
||||
if switchname[/^s\:/]
|
||||
#echoln caller
|
||||
return eval($~.post_match)
|
||||
else
|
||||
return $game_switches[id]
|
||||
@@ -185,6 +202,10 @@ class Game_Event < Game_Character
|
||||
end
|
||||
end
|
||||
|
||||
def get_page(page_index)
|
||||
return @event.pages[page_index]
|
||||
end
|
||||
|
||||
def refresh
|
||||
new_page = nil
|
||||
unless @erased
|
||||
@@ -217,7 +238,7 @@ class Game_Event < Game_Character
|
||||
end
|
||||
@tile_id = @page.graphic.tile_id
|
||||
@character_name = @page.graphic.character_name
|
||||
@character_hue = @page.graphic.character_hue
|
||||
@character_hue = @page.graphic.character_hue if @refresh_hue
|
||||
if @original_direction != @page.graphic.direction
|
||||
@direction = @page.graphic.direction
|
||||
@original_direction = @direction
|
||||
@@ -288,5 +309,10 @@ class Game_Event < Game_Character
|
||||
return !@erased && @page != nil
|
||||
end
|
||||
|
||||
def visible?
|
||||
return false unless @page && @page.graphic
|
||||
return @page.graphic.character_name != "" && active?
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -32,19 +32,31 @@ class Game_Player < Game_Character
|
||||
end
|
||||
|
||||
def bump_into_object
|
||||
return if @bump_se && @bump_se>0
|
||||
if $game_switches[SWITCH_TIME_TRIAL]
|
||||
$game_temp.time_trial_bumps ||= 0
|
||||
$game_temp.time_trial_bumps += 1 unless @bump_se && @bump_se > 0
|
||||
end
|
||||
return if @bump_se && @bump_se > 0
|
||||
pbSEPlay("Player bump")
|
||||
@bump_se = Graphics.frame_rate/2
|
||||
@bump_se = Graphics.frame_rate / 2
|
||||
end
|
||||
|
||||
def move_generic(dir, turn_enabled = true)
|
||||
turn_generic(dir, true) if turn_enabled
|
||||
if !$PokemonTemp.encounterTriggered
|
||||
return if hopOffFence
|
||||
unless $PokemonGlobal.acroBike
|
||||
if $PokemonGlobal.bike_trick && $game_player.pbFacingTerrainTag.acroBike
|
||||
bikeOnFence
|
||||
pbWait(4)
|
||||
end
|
||||
end
|
||||
if can_move_in_direction?(dir)
|
||||
x_offset = (dir == 4) ? -1 : (dir == 6) ? 1 : 0
|
||||
y_offset = (dir == 8) ? -1 : (dir == 2) ? 1 : 0
|
||||
return if pbLedge(x_offset, y_offset)
|
||||
return if pbEndSurf(x_offset, y_offset)
|
||||
return if sitOnChair
|
||||
turn_generic(dir, true)
|
||||
if !$PokemonTemp.encounterTriggered
|
||||
@x += x_offset
|
||||
@@ -364,7 +376,7 @@ class Game_Player < Game_Character
|
||||
end
|
||||
|
||||
def update_event_triggering
|
||||
return if moving?
|
||||
return if moving? || jumping?
|
||||
# Try triggering events upon walking into them/in front of them
|
||||
if @moved_this_frame
|
||||
$PokemonTemp.dependentEvents.pbTurnDependentEvents
|
||||
@@ -419,6 +431,7 @@ def pbCancelVehicles(destination=nil)
|
||||
$PokemonGlobal.surfing = false
|
||||
$PokemonGlobal.diving = false
|
||||
$PokemonGlobal.bicycle = false if !destination || !pbCanUseBike?(destination)
|
||||
$PokemonGlobal.acroBike = false
|
||||
pbUpdateVehicle
|
||||
end
|
||||
|
||||
@@ -432,6 +445,7 @@ end
|
||||
|
||||
def pbMountBike
|
||||
return if $PokemonGlobal.bicycle
|
||||
pbSEPlay("bike")
|
||||
$PokemonGlobal.bicycle = true
|
||||
pbUpdateVehicle
|
||||
bike_bgm = GameData::Metadata.get.bicycle_BGM
|
||||
@@ -440,8 +454,11 @@ def pbMountBike
|
||||
end
|
||||
|
||||
def pbDismountBike
|
||||
return if $game_map.terrain_tag($game_player.x, $game_player.y).acroBike
|
||||
return if !$PokemonGlobal.bicycle
|
||||
$PokemonGlobal.bicycle = false
|
||||
$PokemonGlobal.acroBike = false
|
||||
$game_player.bike_hops = false
|
||||
pbUpdateVehicle
|
||||
$game_map.autoplayAsCue
|
||||
end
|
||||
|
||||
@@ -35,10 +35,10 @@ class Game_Player < Game_Character
|
||||
|
||||
#Override the player's graphics
|
||||
# Path from Graphics/Characters/player/
|
||||
def setPlayerGraphicsOverride(path)
|
||||
@defaultCharacterName=path
|
||||
|
||||
def setPlayerGraphicsOverride(filename)
|
||||
@defaultCharacterName="overrides/#{filename}"
|
||||
end
|
||||
|
||||
def removeGraphicsOverride
|
||||
@defaultCharacterName = ""
|
||||
end
|
||||
@@ -70,20 +70,100 @@ class Game_Player < Game_Character
|
||||
|
||||
def update_command
|
||||
self.move_speed = 0.5 if $game_switches[SWITCH_SUPER_SLOW_SPEED]
|
||||
|
||||
if $game_player.pbTerrainTag.ice
|
||||
self.move_speed = 4 # Sliding on ice
|
||||
elsif !moving? && !@move_route_forcing && $PokemonGlobal
|
||||
reset_bike_speed
|
||||
self.move_speed = 4
|
||||
elsif !@move_route_forcing && $PokemonGlobal
|
||||
if $PokemonGlobal.bicycle
|
||||
self.move_speed = $game_switches[SWITCH_RACE_BIKE] && !Input.press?(Input::ACTION) ? 5.5 : 5 # Cycling
|
||||
self.move_speed = current_bicycle_speed
|
||||
elsif pbCanRun? || $PokemonGlobal.surfing
|
||||
self.move_speed = 4 # Running, surfing
|
||||
reset_bike_speed
|
||||
self.move_speed = 4
|
||||
else
|
||||
self.move_speed = 3 # Walking, diving
|
||||
reset_bike_speed
|
||||
self.move_speed = 3
|
||||
end
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
def current_bicycle_speed
|
||||
if $game_player.pbTerrainTag.must_walk
|
||||
reset_bike_speed
|
||||
return 3
|
||||
end
|
||||
|
||||
if $game_switches[SWITCH_RACE_BIKE]
|
||||
reset_bike_speed
|
||||
return Input.press?(Input::ACTION) ? 5 : 5.6
|
||||
end
|
||||
|
||||
if Settings::KANTO
|
||||
reset_bike_speed
|
||||
return 5
|
||||
end
|
||||
|
||||
# Settings::HOENN — accelerating bike
|
||||
mach_max_speed = 5.333
|
||||
mach_starting_speed = 4.2
|
||||
mach_acceleration = 0.05
|
||||
acro_speed = 5.0
|
||||
|
||||
if Input.press?(Input::ACTION)
|
||||
bikeOnFence unless $PokemonGlobal.bike_trick
|
||||
@bike_speed = acro_speed
|
||||
@bike_idle_frames = 0
|
||||
check_bunny_hops
|
||||
$PokemonGlobal.bike_trick = true
|
||||
elsif moving?
|
||||
@bike_speed = [(@bike_speed || mach_starting_speed) + mach_acceleration, mach_max_speed].min
|
||||
@bike_idle_frames = 0
|
||||
stop_bunny_hops
|
||||
else
|
||||
@bike_idle_frames = (@bike_idle_frames || 0) + 1
|
||||
@bike_speed = mach_starting_speed if @bike_idle_frames > 3
|
||||
$PokemonGlobal.bike_trick = false
|
||||
stop_bunny_hops
|
||||
end
|
||||
@bike_speed = acro_speed if $game_player.floating
|
||||
@bike_was_moving = moving?
|
||||
return @bike_speed || mach_starting_speed
|
||||
end
|
||||
|
||||
def check_bunny_hops
|
||||
@bike_hops_timer = 0 unless @bike_hops_timer
|
||||
if @bike_hops_unlocked
|
||||
if Input.press?(Input::ACTION)
|
||||
$game_player.bike_hops = true
|
||||
else
|
||||
@bike_hops_unlocked = false
|
||||
$game_player.bike_hops = false
|
||||
end
|
||||
else
|
||||
if moving?
|
||||
@bike_hops_timer = 0
|
||||
$game_player.bike_hops = false
|
||||
else
|
||||
@bike_hops_timer += 1
|
||||
if @bike_hops_timer >= 16
|
||||
@bike_hops_unlocked = true
|
||||
$game_player.bike_hops = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def stop_bunny_hops
|
||||
@bike_hops_timer = 0
|
||||
@bike_hops_unlocked = false
|
||||
$game_player.bike_hops = false
|
||||
end
|
||||
def reset_bike_speed
|
||||
@bike_speed = nil
|
||||
end
|
||||
|
||||
def update_pattern
|
||||
if $PokemonGlobal.surfing || $PokemonGlobal.diving
|
||||
p = ((Graphics.frame_count%60)*@@bobFrameSpeed).floor
|
||||
|
||||
@@ -381,6 +381,14 @@ class DependentEvents
|
||||
end
|
||||
end
|
||||
|
||||
def turn(direction)
|
||||
events=$PokemonGlobal.dependentEvents
|
||||
for i in 0...events.length
|
||||
event=@realEvents[i]
|
||||
event.direction=direction
|
||||
end
|
||||
end
|
||||
|
||||
def eachEvent
|
||||
events=$PokemonGlobal.dependentEvents
|
||||
for i in 0...events.length
|
||||
|
||||
Reference in New Issue
Block a user