Added decent spacing to all scripts thanks to Rubocop

This commit is contained in:
Maruno17
2021-12-18 15:25:40 +00:00
parent f7b76ae62e
commit d17fc40a47
207 changed files with 18577 additions and 18587 deletions

View File

@@ -90,39 +90,39 @@ class Game_Screen
# * Frame Update
#-----------------------------------------------------------------------------
def update
if @fadeout_duration && @fadeout_duration>=1
if @fadeout_duration && @fadeout_duration >= 1
d = @fadeout_duration
@brightness = (@brightness*(d-1))/d
@brightness = (@brightness * (d - 1)) / d
@fadeout_duration -= 1
end
if @fadein_duration && @fadein_duration>=1
if @fadein_duration && @fadein_duration >= 1
d = @fadein_duration
@brightness = (@brightness*(d-1)+255)/d
@brightness = (@brightness * (d - 1) + 255) / d
@fadein_duration -= 1
end
if @tone_duration>=1
if @tone_duration >= 1
d = @tone_duration
@tone.red = (@tone.red*(d-1)+@tone_target.red)/d
@tone.green = (@tone.green*(d-1)+@tone_target.green)/d
@tone.blue = (@tone.blue*(d-1)+@tone_target.blue)/d
@tone.gray = (@tone.gray*(d-1)+@tone_target.gray)/d
@tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
@tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
@tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
@tone_duration -= 1
end
if @flash_duration>=1
if @flash_duration >= 1
d = @flash_duration
@flash_color.alpha = @flash_color.alpha*(d-1)/d
@flash_color.alpha = @flash_color.alpha * (d - 1) / d
@flash_duration -= 1
end
if @shake_duration>=1 || @shake!=0
delta = (@shake_power*@shake_speed*@shake_direction)/10.0
if @shake_duration<=1 && @shake*(@shake+delta)<0
if @shake_duration >= 1 || @shake != 0
delta = (@shake_power * @shake_speed * @shake_direction) / 10.0
if @shake_duration <= 1 && @shake * (@shake + delta) < 0
@shake = 0
else
@shake += delta
end
@shake_direction = -1 if @shake>@shake_power*2
@shake_direction = 1 if @shake<-@shake_power*2
@shake_duration -= 1 if @shake_duration>=1
@shake_direction = -1 if @shake > @shake_power * 2
@shake_direction = 1 if @shake < -@shake_power * 2
@shake_duration -= 1 if @shake_duration >= 1
end
if $game_temp.in_battle
for i in 51..100
@@ -139,17 +139,17 @@ end
#===============================================================================
#
#===============================================================================
def pbToneChangeAll(tone,duration)
$game_screen.start_tone_change(tone,duration*Graphics.frame_rate/20)
def pbToneChangeAll(tone, duration)
$game_screen.start_tone_change(tone, duration * Graphics.frame_rate / 20)
for picture in $game_screen.pictures
picture.start_tone_change(tone,duration*Graphics.frame_rate/20) if picture
picture.start_tone_change(tone, duration * Graphics.frame_rate / 20) if picture
end
end
def pbShake(power,speed,frames)
$game_screen.start_shake(power,speed,frames*Graphics.frame_rate/20)
def pbShake(power, speed, frames)
$game_screen.start_shake(power, speed, frames * Graphics.frame_rate / 20)
end
def pbFlash(color,frames)
$game_screen.start_flash(color,frames*Graphics.frame_rate/20)
def pbFlash(color, frames)
$game_screen.start_flash(color, frames * Graphics.frame_rate / 20)
end

View File

@@ -16,7 +16,7 @@ class Game_SelfSwitches
# key : key
#-----------------------------------------------------------------------------
def [](key)
return (@data[key]==true) ? true : false
return (@data[key] == true) ? true : false
end
#-----------------------------------------------------------------------------
# * Set Self Switch

View File

@@ -44,28 +44,28 @@ class Game_System
def bgm_play(bgm)
old_pos = @bgm_position
@bgm_position = 0
bgm_play_internal(bgm,0)
bgm_play_internal(bgm, 0)
@bgm_position = old_pos
end
def bgm_play_internal2(name,volume,pitch,position) # :nodoc:
def bgm_play_internal2(name, volume, pitch, position) # :nodoc:
vol = volume
vol *= $PokemonSystem.bgmvolume/100.0
vol *= $PokemonSystem.bgmvolume / 100.0
vol = vol.to_i
begin
Audio.bgm_play(name,vol,pitch,position)
Audio.bgm_play(name, vol, pitch, position)
rescue ArgumentError
Audio.bgm_play(name,vol,pitch)
Audio.bgm_play(name, vol, pitch)
end
end
def bgm_play_internal(bgm,position) # :nodoc:
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 FileTest.audio_exist?("Audio/BGM/"+bgm.name)
bgm_play_internal2("Audio/BGM/"+bgm.name,
bgm.volume,bgm.pitch,@bgm_position) if !@defaultBGM
@playing_bgm = (bgm == nil) ? nil : bgm.clone
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
end
else
@bgm_position = position if !@bgm_paused
@@ -73,15 +73,15 @@ class Game_System
Audio.bgm_stop if !@defaultBGM
end
if @defaultBGM
bgm_play_internal2("Audio/BGM/"+@defaultBGM.name,
@defaultBGM.volume,@defaultBGM.pitch,@bgm_position)
bgm_play_internal2("Audio/BGM/" + @defaultBGM.name,
@defaultBGM.volume, @defaultBGM.pitch, @bgm_position)
end
Graphics.frame_reset
end
def bgm_pause(fadetime = 0.0) # :nodoc:
pos = Audio.bgm_pos rescue 0
self.bgm_fade(fadetime) if fadetime>0.0
self.bgm_fade(fadetime) if fadetime > 0.0
@bgm_position = pos
@bgm_paused = true
end
@@ -93,7 +93,7 @@ class Game_System
def bgm_resume(bgm) # :nodoc:
if @bgm_paused
self.bgm_play_internal(bgm,@bgm_position)
self.bgm_play_internal(bgm, @bgm_position)
@bgm_position = 0
@bgm_paused = false
end
@@ -108,7 +108,7 @@ class Game_System
def bgm_fade(time) # :nodoc:
@bgm_position = 0 if !@bgm_paused
@playing_bgm = nil
Audio.bgm_fade((time*1000).floor) if !@defaultBGM
Audio.bgm_fade((time * 1000).floor) if !@defaultBGM
end
def playing_bgm
@@ -130,9 +130,9 @@ class Game_System
return (@playing_bgm) ? @playing_bgm.clone : nil
end
def setDefaultBGM(bgm,volume = 80,pitch = 100)
bgm = RPG::AudioFile.new(bgm,volume,pitch) if bgm.is_a?(String)
if bgm!=nil && bgm.name!=""
def setDefaultBGM(bgm, volume = 80, pitch = 100)
bgm = RPG::AudioFile.new(bgm, volume, pitch) if bgm.is_a?(String)
if bgm != nil && bgm.name != ""
@defaultBGM = nil
self.bgm_play(bgm)
@defaultBGM = bgm.clone
@@ -146,12 +146,12 @@ class Game_System
def me_play(me)
me = RPG::AudioFile.new(me) if me.is_a?(String)
if me!=nil && me.name!=""
if FileTest.audio_exist?("Audio/ME/"+me.name)
if me != nil && me.name != ""
if FileTest.audio_exist?("Audio/ME/" + me.name)
vol = me.volume
vol *= $PokemonSystem.bgmvolume/100.0
vol *= $PokemonSystem.bgmvolume / 100.0
vol = vol.to_i
Audio.me_play("Audio/ME/"+me.name,vol,me.pitch)
Audio.me_play("Audio/ME/" + me.name, vol, me.pitch)
end
else
Audio.me_stop
@@ -162,13 +162,13 @@ class Game_System
################################################################################
def bgs_play(bgs)
@playing_bgs = (bgs==nil) ? nil : bgs.clone
if bgs!=nil && bgs.name!=""
if FileTest.audio_exist?("Audio/BGS/"+bgs.name)
@playing_bgs = (bgs == nil) ? nil : bgs.clone
if bgs != nil && bgs.name != ""
if FileTest.audio_exist?("Audio/BGS/" + bgs.name)
vol = bgs.volume
vol *= $PokemonSystem.sevolume/100.0
vol *= $PokemonSystem.sevolume / 100.0
vol = vol.to_i
Audio.bgs_play("Audio/BGS/"+bgs.name,vol,bgs.pitch)
Audio.bgs_play("Audio/BGS/" + bgs.name, vol, bgs.pitch)
end
else
@bgs_position = 0
@@ -179,7 +179,7 @@ class Game_System
end
def bgs_pause(fadetime = 0.0) # :nodoc:
if fadetime>0.0
if fadetime > 0.0
self.bgs_fade(fadetime)
else
self.bgs_stop
@@ -207,7 +207,7 @@ class Game_System
def bgs_fade(time)
@bgs_position = 0
@playing_bgs = nil
Audio.bgs_fade((time*1000).floor)
Audio.bgs_fade((time * 1000).floor)
end
def playing_bgs
@@ -230,11 +230,11 @@ class Game_System
def se_play(se)
se = RPG::AudioFile.new(se) if se.is_a?(String)
if se!=nil && se.name!="" && FileTest.audio_exist?("Audio/SE/"+se.name)
if se != nil && se.name != "" && FileTest.audio_exist?("Audio/SE/" + se.name)
vol = se.volume
vol *= $PokemonSystem.sevolume/100.0
vol *= $PokemonSystem.sevolume / 100.0
vol = vol.to_i
Audio.se_play("Audio/SE/"+se.name,vol,se.pitch)
Audio.se_play("Audio/SE/" + se.name, vol, se.pitch)
end
end
@@ -259,7 +259,7 @@ class Game_System
################################################################################
def windowskin_name
if @windowskin_name==nil
if @windowskin_name == nil
return $data_system.windowskin_name
else
return @windowskin_name
@@ -269,10 +269,10 @@ class Game_System
attr_writer :windowskin_name
def update
@timer -= 1 if @timer_working && @timer>0
if Input.trigger?(Input::SPECIAL) && pbCurrentEventCommentInput(1,"Cut Scene")
@timer -= 1 if @timer_working && @timer > 0
if Input.trigger?(Input::SPECIAL) && pbCurrentEventCommentInput(1, "Cut Scene")
event = @map_interpreter.get_self
@map_interpreter.pbSetSelfSwitch(event.id,"A",true)
@map_interpreter.pbSetSelfSwitch(event.id, "A", true)
@map_interpreter.command_end
event.start
end

View File

@@ -43,8 +43,8 @@ class Game_Map
end
def setup(map_id)
@map_id = map_id
@map = load_data(sprintf("Data/Map%03d.rxdata",map_id))
@map_id = map_id
@map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
tileset = $data_tilesets[@map.tileset_id]
updateTileset
@fog_ox = 0
@@ -57,10 +57,10 @@ class Game_Map
self.display_x = 0
self.display_y = 0
@need_refresh = false
Events.onMapCreate.trigger(self,map_id,@map,tileset)
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] = Game_Event.new(@map_id, @map.events[i], self)
end
@common_events = {}
for i in 1...$data_common_events.size
@@ -110,10 +110,10 @@ class Game_Map
#-----------------------------------------------------------------------------
def autoplayAsCue
if @map.autoplay_bgm
if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/"+ @map.bgm.name+ "_n")
pbCueBGM(@map.bgm.name+"_n",1.0,@map.bgm.volume,@map.bgm.pitch)
if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/" + @map.bgm.name + "_n")
pbCueBGM(@map.bgm.name + "_n", 1.0, @map.bgm.volume, @map.bgm.pitch)
else
pbCueBGM(@map.bgm,1.0)
pbCueBGM(@map.bgm, 1.0)
end
end
if @map.autoplay_bgs
@@ -126,8 +126,8 @@ class Game_Map
#-----------------------------------------------------------------------------
def autoplay
if @map.autoplay_bgm
if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/"+ @map.bgm.name+ "_n")
pbBGMPlay(@map.bgm.name+"_n",@map.bgm.volume,@map.bgm.pitch)
if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/" + @map.bgm.name + "_n")
pbBGMPlay(@map.bgm.name + "_n", @map.bgm.volume, @map.bgm.pitch)
else
pbBGMPlay(@map.bgm)
end
@@ -159,7 +159,7 @@ class Game_Map
return false if passage & 0x0f == 0x0f
return true if @priorities[event.tile_id] == 0
end
return playerPassable?(x, y, d, self_event) if self_event==$game_player
return playerPassable?(x, y, d, self_event) if self_event == $game_player
# All other events
newx = x
newy = y
@@ -270,7 +270,7 @@ class Game_Map
return true
end
def bush?(x,y)
def bush?(x, y)
for i in [2, 1, 0]
tile_id = data[x, y, i]
return false if GameData::TerrainTag.try_get(@terrain_tags[tile_id]).bridge &&
@@ -280,7 +280,7 @@ class Game_Map
return false
end
def deepBush?(x,y)
def deepBush?(x, y)
for i in [2, 1, 0]
tile_id = data[x, y, i]
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
@@ -290,7 +290,7 @@ class Game_Map
return false
end
def counter?(x,y)
def counter?(x, y)
for i in [2, 1, 0]
tile_id = data[x, y, i]
passage = @passages[tile_id]
@@ -299,7 +299,7 @@ class Game_Map
return false
end
def terrain_tag(x,y,countBridge = false)
def terrain_tag(x, y, countBridge = false)
if valid?(x, y)
for i in [2, 1, 0]
tile_id = data[x, y, i]
@@ -313,7 +313,7 @@ class Game_Map
end
# Unused.
def check_event(x,y)
def check_event(x, y)
for event in self.events.values
return event.id if event.at_coordinate?(x, y)
end
@@ -323,7 +323,7 @@ class Game_Map
return if @display_x == value
@display_x = value
if metadata&.snap_edges
max_x = (self.width - Graphics.width*1.0/TILE_WIDTH) * REAL_RES_X
max_x = (self.width - Graphics.width * 1.0 / TILE_WIDTH) * REAL_RES_X
@display_x = [0, [@display_x, max_x].min].max
end
$map_factory.setMapsInRange if $map_factory
@@ -333,7 +333,7 @@ class Game_Map
return if @display_y == value
@display_y = value
if metadata&.snap_edges
max_y = (self.height - Graphics.height*1.0/TILE_HEIGHT) * REAL_RES_Y
max_y = (self.height - Graphics.height * 1.0 / TILE_HEIGHT) * REAL_RES_Y
@display_y = [0, [@display_y, max_y].min].max
end
$map_factory.setMapsInRange if $map_factory
@@ -357,7 +357,7 @@ class Game_Map
def start_scroll(direction, distance, speed)
@scroll_direction = direction
if direction==2 || direction==8 # down or up
if direction == 2 || direction == 8 # down or up
@scroll_rest = distance * REAL_RES_Y
else
@scroll_rest = distance * REAL_RES_X
@@ -369,7 +369,7 @@ class Game_Map
return @scroll_rest > 0
end
def start_fog_tone_change(tone,duration)
def start_fog_tone_change(tone, duration)
@fog_tone_target = tone.clone
@fog_tone_duration = duration
if @fog_tone_duration == 0
@@ -377,10 +377,10 @@ class Game_Map
end
end
def start_fog_opacity_change(opacity,duration)
@fog_opacity_target = opacity*1.0
def start_fog_opacity_change(opacity, duration)
@fog_opacity_target = opacity * 1.0
@fog_opacity_duration = duration
if @fog_opacity_duration==0
if @fog_opacity_duration == 0
@fog_opacity = @fog_opacity_target
end
end
@@ -412,9 +412,9 @@ class Game_Map
$map_factory.setCurrentMap
end
# If scrolling
if @scroll_rest>0
distance = (1<<@scroll_speed)*40.0/Graphics.frame_rate
distance = @scroll_rest if distance>@scroll_rest
if @scroll_rest > 0
distance = (1 << @scroll_speed) * 40.0 / Graphics.frame_rate
distance = @scroll_rest if distance > @scroll_rest
case @scroll_direction
when 2 then scroll_down(distance)
when 4 then scroll_left(distance)
@@ -432,9 +432,9 @@ class Game_Map
common_event.update
end
# Update fog
@fog_ox -= @fog_sx/8.0
@fog_oy -= @fog_sy/8.0
if @fog_tone_duration>=1
@fog_ox -= @fog_sx / 8.0
@fog_oy -= @fog_sy / 8.0
if @fog_tone_duration >= 1
d = @fog_tone_duration
target = @fog_tone_target
@fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
@@ -454,8 +454,8 @@ end
#===============================================================================
#
#===============================================================================
def pbScrollMap(direction,distance,speed)
if speed==0
def pbScrollMap(direction, distance, speed)
if speed == 0
case direction
when 2 then $game_map.scroll_down(distance * Game_Map::REAL_RES_Y)
when 4 then $game_map.scroll_left(distance * Game_Map::REAL_RES_X)
@@ -471,7 +471,7 @@ def pbScrollMap(direction,distance,speed)
Input.update
break if !$game_map.scrolling?
pbUpdateSceneMap
break if $game_map.display_x==oldx && $game_map.display_y==oldy
break if $game_map.display_x == oldx && $game_map.display_y == oldy
oldx = $game_map.display_x
oldy = $game_map.display_y
end

View File

@@ -77,22 +77,22 @@ class Interpreter
# y : y coordinate to scroll to and center on
# speed : (optional) scroll speed (from 1-6, default being 4)
#-----------------------------------------------------------------------------
def autoscroll(x,y,speed = SCROLL_SPEED_DEFAULT)
def autoscroll(x, y, speed = SCROLL_SPEED_DEFAULT)
if $game_map.scrolling?
return false
elsif !$game_map.valid?(x,y)
elsif !$game_map.valid?(x, y)
print 'Map Autoscroll: given x,y is invalid'
return command_skip
elsif !(1..6).include?(speed)
print 'Map Autoscroll: invalid speed (1-6 only)'
return command_skip
end
center_x = (Graphics.width/2 - Game_Map::TILE_WIDTH/2) * 4 # X coordinate in the center of the screen
center_y = (Graphics.height/2 - Game_Map::TILE_HEIGHT/2) * 4 # Y coordinate in the center of the screen
max_x = ($game_map.width - Graphics.width*1.0/Game_Map::TILE_WIDTH) * 4 * Game_Map::TILE_WIDTH
max_y = ($game_map.height - Graphics.height*1.0/Game_Map::TILE_HEIGHT) * 4 * Game_Map::TILE_HEIGHT
count_x = ($game_map.display_x - [0,[x*Game_Map::REAL_RES_X-center_x,max_x].min].max)/Game_Map::REAL_RES_X
count_y = ($game_map.display_y - [0,[y*Game_Map::REAL_RES_Y-center_y,max_y].min].max)/Game_Map::REAL_RES_Y
center_x = (Graphics.width / 2 - Game_Map::TILE_WIDTH / 2) * 4 # X coordinate in the center of the screen
center_y = (Graphics.height / 2 - Game_Map::TILE_HEIGHT / 2) * 4 # Y coordinate in the center of the screen
max_x = ($game_map.width - Graphics.width * 1.0 / Game_Map::TILE_WIDTH) * 4 * Game_Map::TILE_WIDTH
max_y = ($game_map.height - Graphics.height * 1.0 / Game_Map::TILE_HEIGHT) * 4 * Game_Map::TILE_HEIGHT
count_x = ($game_map.display_x - [0, [x * Game_Map::REAL_RES_X - center_x, max_x].min].max) / Game_Map::REAL_RES_X
count_y = ($game_map.display_y - [0, [y * Game_Map::REAL_RES_Y - center_y, max_y].min].max) / Game_Map::REAL_RES_Y
if !@diag
@diag = true
dir = nil
@@ -109,7 +109,7 @@ class Interpreter
dir = 3
end
end
count = [count_x.abs,count_y.abs].min
count = [count_x.abs, count_y.abs].min
else
@diag = false
dir = nil
@@ -139,7 +139,7 @@ class Interpreter
# speed : (optional) scroll speed (from 1-6, default being 4)
#-----------------------------------------------------------------------------
def autoscroll_player(speed = SCROLL_SPEED_DEFAULT)
autoscroll($game_player.x,$game_player.y,speed)
autoscroll($game_player.x, $game_player.y, speed)
end
end
@@ -148,20 +148,20 @@ end
class Game_Map
def scroll_downright(distance)
@display_x = [@display_x + distance,
(self.width - Graphics.width*1.0/TILE_WIDTH) * REAL_RES_X].min
(self.width - Graphics.width * 1.0 / TILE_WIDTH) * REAL_RES_X].min
@display_y = [@display_y + distance,
(self.height - Graphics.height*1.0/TILE_HEIGHT) * REAL_RES_Y].min
(self.height - Graphics.height * 1.0 / TILE_HEIGHT) * REAL_RES_Y].min
end
def scroll_downleft(distance)
@display_x = [@display_x - distance, 0].max
@display_y = [@display_y + distance,
(self.height - Graphics.height*1.0/TILE_HEIGHT) * REAL_RES_Y].min
(self.height - Graphics.height * 1.0 / TILE_HEIGHT) * REAL_RES_Y].min
end
def scroll_upright(distance)
@display_x = [@display_x + distance,
(self.width - Graphics.width*1.0/TILE_WIDTH) * REAL_RES_X].min
(self.width - Graphics.width * 1.0 / TILE_WIDTH) * REAL_RES_X].min
@display_y = [@display_y - distance, 0].max
end
@@ -174,8 +174,8 @@ class Game_Map
# If scrolling
if @scroll_rest > 0
# Change from scroll speed to distance in map coordinates
distance = (1<<@scroll_speed)*40/Graphics.frame_rate
distance = @scroll_rest if distance>@scroll_rest
distance = (1 << @scroll_speed) * 40 / Graphics.frame_rate
distance = @scroll_rest if distance > @scroll_rest
# Execute scrolling
case @scroll_direction
when 1 then scroll_downleft(distance)

View File

@@ -19,7 +19,7 @@ class PokemonMapFactory
@maps[0] = Game_Map.new
@mapIndex = 0
oldID = ($game_map) ? $game_map.map_id : 0
setMapChanging(id,@maps[0]) if oldID!=0 && oldID!=@maps[0].map_id
setMapChanging(id, @maps[0]) if oldID != 0 && oldID != @maps[0].map_id
$game_map = @maps[0]
@maps[0].setup(id)
setMapsInRange
@@ -27,9 +27,9 @@ class PokemonMapFactory
end
def map
@mapIndex = 0 if !@mapIndex || @mapIndex<0
@mapIndex = 0 if !@mapIndex || @mapIndex < 0
return @maps[@mapIndex] if @maps[@mapIndex]
raise "No maps in save file... (mapIndex=#{@mapIndex})" if @maps.length==0
raise "No maps in save file... (mapIndex=#{@mapIndex})" if @maps.length == 0
if @maps[0]
echoln "Using next map, may be incorrect (mapIndex=#{@mapIndex}, length=#{@maps.length})"
return @maps[0]
@@ -39,21 +39,21 @@ class PokemonMapFactory
def hasMap?(id)
for map in @maps
return true if map.map_id==id
return true if map.map_id == id
end
return false
end
def getMapIndex(id)
for i in 0...@maps.length
return i if @maps[i].map_id==id
return i if @maps[i].map_id == id
end
return -1
end
def getMap(id,add = true)
def getMap(id, add = true)
for map in @maps
return map if map.map_id==id
return map if map.map_id == id
end
map = Game_Map.new
map.setup(id)
@@ -62,10 +62,10 @@ class PokemonMapFactory
end
def getMapNoAdd(id)
return getMap(id,false)
return getMap(id, false)
end
def getNewMap(playerX,playerY)
def getNewMap(playerX, playerY)
id = $game_map.map_id
conns = MapFactoryHelper.getMapConnections
if conns[id]
@@ -96,16 +96,16 @@ class PokemonMapFactory
# their transfer to that map.
def setCurrentMap
return if $game_player.moving?
return if $game_map.valid?($game_player.x,$game_player.y)
newmap = getNewMap($game_player.x,$game_player.y)
return if $game_map.valid?($game_player.x, $game_player.y)
newmap = getNewMap($game_player.x, $game_player.y)
return if !newmap
oldmap=$game_map.map_id
if oldmap!=0 && oldmap!=newmap[0].map_id
setMapChanging(newmap[0].map_id,newmap[0])
oldmap = $game_map.map_id
if oldmap != 0 && oldmap != newmap[0].map_id
setMapChanging(newmap[0].map_id, newmap[0])
end
$game_map = newmap[0]
@mapIndex = getMapIndex($game_map.map_id)
$game_player.moveto(newmap[1],newmap[2])
$game_player.moveto(newmap[1], newmap[2])
$game_map.update
pbAutoplayOnTransition
$game_map.refresh
@@ -144,17 +144,17 @@ class PokemonMapFactory
@fixup = false
end
def setMapChanging(newID,newMap)
Events.onMapChanging.trigger(self,newID,newMap)
def setMapChanging(newID, newMap)
Events.onMapChanging.trigger(self, newID, newMap)
end
def setMapChanged(prevMap)
Events.onMapChange.trigger(self,prevMap)
Events.onMapChange.trigger(self, prevMap)
@mapChanged = true
end
def setSceneStarted(scene)
Events.onMapSceneChange.trigger(self,scene,@mapChanged)
Events.onMapSceneChange.trigger(self, scene, @mapChanged)
@mapChanged = false
end
@@ -194,42 +194,42 @@ class PokemonMapFactory
end
# Only used by dependent events
def isPassableStrict?(mapID,x,y,thisEvent = nil)
def isPassableStrict?(mapID, x, y, thisEvent = nil)
thisEvent = $game_player if !thisEvent
map = getMapNoAdd(mapID)
return false if !map
return false if !map.valid?(x,y)
return false if !map.valid?(x, y)
return true if thisEvent.through
if thisEvent==$game_player
if thisEvent == $game_player
if !($DEBUG && Input.press?(Input::CTRL))
return false if !map.passableStrict?(x,y,0,thisEvent)
return false if !map.passableStrict?(x, y, 0, thisEvent)
end
else
return false if !map.passableStrict?(x,y,0,thisEvent)
return false if !map.passableStrict?(x, y, 0, thisEvent)
end
for event in map.events.values
next if event == thisEvent || !event.at_coordinate?(x, y)
return false if !event.through && event.character_name!=""
return false if !event.through && event.character_name != ""
end
return true
end
def getTerrainTag(mapid,x,y,countBridge = false)
def getTerrainTag(mapid, x, y, countBridge = false)
map = getMapNoAdd(mapid)
return map.terrain_tag(x,y,countBridge)
return map.terrain_tag(x, y, countBridge)
end
# NOTE: Assumes the event is 1x1 tile in size. Only returns one terrain tag.
def getFacingTerrainTag(dir = nil,event = nil)
tile = getFacingTile(dir,event)
def getFacingTerrainTag(dir = nil, event = nil)
tile = getFacingTile(dir, event)
return GameData::TerrainTag.get(:None) if !tile
return getTerrainTag(tile[0],tile[1],tile[2])
return getTerrainTag(tile[0], tile[1], tile[2])
end
def getTerrainTagFromCoords(mapid,x,y,countBridge = false)
tile = getRealTilePos(mapid,x,y)
def getTerrainTagFromCoords(mapid, x, y, countBridge = false)
tile = getRealTilePos(mapid, x, y)
return GameData::TerrainTag.get(:None) if !tile
return getTerrainTag(tile[0],tile[1],tile[2])
return getTerrainTag(tile[0], tile[1], tile[2])
end
def areConnected?(mapID1, mapID2)
@@ -268,38 +268,38 @@ class PokemonMapFactory
# Gets the distance from this event to another event. Example: If this event's
# coordinates are (2,5) and the other event's coordinates are (5,1), returns
# the array (3,-4), because (5-2=3) and (1-5=-4).
def getThisAndOtherEventRelativePos(thisEvent,otherEvent)
return [0,0] if !thisEvent || !otherEvent
def getThisAndOtherEventRelativePos(thisEvent, otherEvent)
return [0, 0] if !thisEvent || !otherEvent
return getRelativePos(
thisEvent.map.map_id,thisEvent.x,thisEvent.y,
otherEvent.map.map_id,otherEvent.x,otherEvent.y)
thisEvent.map.map_id, thisEvent.x, thisEvent.y,
otherEvent.map.map_id, otherEvent.x, otherEvent.y)
end
def getThisAndOtherPosRelativePos(thisEvent,otherMapID,otherX,otherY)
return [0,0] if !thisEvent
def getThisAndOtherPosRelativePos(thisEvent, otherMapID, otherX, otherY)
return [0, 0] if !thisEvent
return getRelativePos(
thisEvent.map.map_id,thisEvent.x,thisEvent.y,otherMapID,otherX,otherY)
thisEvent.map.map_id, thisEvent.x, thisEvent.y, otherMapID, otherX, otherY)
end
# Unused
def getOffsetEventPos(event,xOffset,yOffset)
def getOffsetEventPos(event, xOffset, yOffset)
event = $game_player if !event
return nil if !event
return getRealTilePos(event.map.map_id,event.x+xOffset,event.y+yOffset)
return getRealTilePos(event.map.map_id, event.x + xOffset, event.y + yOffset)
end
# NOTE: Assumes the event is 1x1 tile in size. Only returns one tile.
def getFacingTile(direction = nil,event = nil,steps = 1)
event = $game_player if event==nil
return [0,0,0] if !event
def getFacingTile(direction = nil, event = nil, steps = 1)
event = $game_player if event == nil
return [0, 0, 0] if !event
x = event.x
y = event.y
id = event.map.map_id
direction = event.direction if direction==nil
return getFacingTileFromPos(id,x,y,direction,steps)
direction = event.direction if direction == nil
return getFacingTileFromPos(id, x, y, direction, steps)
end
def getFacingTileFromPos(mapID,x,y,direction = 0,steps = 1)
def getFacingTileFromPos(mapID, x, y, direction = 0, steps = 1)
id = mapID
case direction
when 1
@@ -323,9 +323,9 @@ class PokemonMapFactory
x += steps
y -= steps
else
return [id,x,y]
return [id, x, y]
end
return getRealTilePos(mapID,x,y)
return getRealTilePos(mapID, x, y)
end
def getRealTilePos(mapID, x, y)
@@ -354,7 +354,7 @@ class PokemonMapFactory
return nil
end
def getFacingCoords(x,y,direction = 0,steps = 1)
def getFacingCoords(x, y, direction = 0, steps = 1)
case direction
when 1
x -= steps
@@ -377,7 +377,7 @@ class PokemonMapFactory
x += steps
y -= steps
end
return [x,y]
return [x, y]
end
def updateMaps(scene)
@@ -464,9 +464,9 @@ module MapFactoryHelper
if !@@MapDims[id]
begin
map = load_data(sprintf("Data/Map%03d.rxdata", id))
@@MapDims[id] = [map.width,map.height]
@@MapDims[id] = [map.width, map.height]
rescue
@@MapDims[id] = [0,0]
@@MapDims[id] = [0, 0]
end
end
# Return map in cache
@@ -475,11 +475,11 @@ module MapFactoryHelper
# Returns the X or Y coordinate of an edge on the map with id.
# Considers the special strings "N","W","E","S"
def self.getMapEdge(id,edge)
return 0 if edge=="N" || edge=="W"
def self.getMapEdge(id, edge)
return 0 if edge == "N" || edge == "W"
dims = getMapDims(id) # Get dimensions
return dims[0] if edge=="E"
return dims[1] if edge=="S"
return dims[0] if edge == "E"
return dims[1] if edge == "S"
return dims[0] # real dimension (use width)
end
@@ -494,7 +494,7 @@ module MapFactoryHelper
return true
end
def self.mapInRangeById?(id,dispx,dispy)
def self.mapInRangeById?(id, dispx, dispy)
range = 6 # Number of tiles
dims = MapFactoryHelper.getMapDims(id)
return false if dispx >= (dims[0] + range) * Game_Map::REAL_RES_X

View File

@@ -96,7 +96,7 @@ class Game_Character
end
def move_speed=(val)
return if val==@move_speed
return if val == @move_speed
@move_speed = val
# @move_speed_real is the number of quarter-pixels to move each frame. There
# are 128 quarter-pixels per tile. By default, it is calculated from
@@ -107,7 +107,7 @@ class Game_Character
# 4 => 25.6 # 5 frames per tile - running speed (2x walking speed)
# 5 => 32 # 4 frames per tile - cycling speed (1.25x running speed)
# 6 => 64 # 2 frames per tile
self.move_speed_real = (val == 6) ? 64 : (val == 5) ? 32 : (2 ** (val + 1)) * 0.8
self.move_speed_real = (val == 6) ? 64 : (val == 5) ? 32 : (2**(val + 1)) * 0.8
end
def move_speed_real
@@ -120,7 +120,7 @@ class Game_Character
end
def jump_speed_real
self.jump_speed_real = (2 ** (3 + 1)) * 0.8 if !@jump_speed_real # 3 is walking speed
self.jump_speed_real = (2**(3 + 1)) * 0.8 if !@jump_speed_real # 3 is walking speed
return @jump_speed_real
end
@@ -129,7 +129,7 @@ class Game_Character
end
def move_frequency=(val)
return if val==@move_frequency
return if val == @move_frequency
@move_frequency = val
# @move_frequency_real is the number of frames to wait between each action
# in a move route (not forced). Specifically, this is the number of frames
@@ -381,8 +381,8 @@ class Game_Character
def triggerLeaveTile
if @oldX && @oldY && @oldMap &&
(@oldX!=self.x || @oldY!=self.y || @oldMap!=self.map.map_id)
Events.onLeaveTile.trigger(self,self,@oldMap,@oldX,@oldY)
(@oldX != self.x || @oldY != self.y || @oldMap != self.map.map_id)
Events.onLeaveTile.trigger(self, self, @oldMap, @oldX, @oldY)
end
@oldX = self.x
@oldY = self.y
@@ -629,23 +629,23 @@ class Game_Character
end
end
def move_random_range(xrange = -1,yrange = -1)
def move_random_range(xrange = -1, yrange = -1)
dirs = [] # 0=down, 1=left, 2=right, 3=up
if xrange<0
if xrange < 0
dirs.push(1)
dirs.push(2)
elsif xrange>0
elsif xrange > 0
dirs.push(1) if @x > @original_x - xrange
dirs.push(2) if @x < @original_x + xrange
end
if yrange<0
if yrange < 0
dirs.push(0)
dirs.push(3)
elsif yrange>0
elsif yrange > 0
dirs.push(0) if @y < @original_y + yrange
dirs.push(3) if @y > @original_y - yrange
end
return if dirs.length==0
return if dirs.length == 0
case dirs[rand(dirs.length)]
when 0 then move_down(false)
when 1 then move_left(false)
@@ -655,11 +655,11 @@ class Game_Character
end
def move_random_UD(range = -1)
move_random_range(0,range)
move_random_range(0, range)
end
def move_random_LR(range = -1)
move_random_range(range,0)
move_random_range(range, 0)
end
def move_toward_player
@@ -755,19 +755,19 @@ class Game_Character
def jumpForward
case self.direction
when 2 then jump(0,1) # down
when 4 then jump(-1,0) # left
when 6 then jump(1,0) # right
when 8 then jump(0,-1) # up
when 2 then jump(0, 1) # down
when 4 then jump(-1, 0) # left
when 6 then jump(1, 0) # right
when 8 then jump(0, -1) # up
end
end
def jumpBackward
case self.direction
when 2 then jump(0,-1) # down
when 4 then jump(1,0) # left
when 6 then jump(-1,0) # right
when 8 then jump(0,1) # up
when 2 then jump(0, -1) # down
when 4 then jump(1, 0) # left
when 6 then jump(-1, 0) # right
when 8 then jump(0, 1) # up
end
end

View File

@@ -54,7 +54,7 @@ class Game_Event < Game_Character
end
def tsOn?(c)
return @tempSwitches && @tempSwitches[c]==true
return @tempSwitches && @tempSwitches[c] == true
end
def tsOff?(c)
@@ -62,17 +62,17 @@ class Game_Event < Game_Character
end
def setTempSwitchOn(c)
@tempSwitches[c]=true
@tempSwitches[c] = true
refresh
end
def setTempSwitchOff(c)
@tempSwitches[c]=false
@tempSwitches[c] = false
refresh
end
def isOff?(c)
return !$game_self_switches[[@map_id,@event.id,c]]
return !$game_self_switches[[@map_id, @event.id, c]]
end
def switchIsOn?(id)
@@ -87,31 +87,31 @@ class Game_Event < Game_Character
def variable
return nil if !$PokemonGlobal.eventvars
return $PokemonGlobal.eventvars[[@map_id,@event.id]]
return $PokemonGlobal.eventvars[[@map_id, @event.id]]
end
def setVariable(variable)
$PokemonGlobal.eventvars[[@map_id,@event.id]]=variable
$PokemonGlobal.eventvars[[@map_id, @event.id]] = variable
end
def varAsInt
return 0 if !$PokemonGlobal.eventvars
return $PokemonGlobal.eventvars[[@map_id,@event.id]].to_i
return $PokemonGlobal.eventvars[[@map_id, @event.id]].to_i
end
def expired?(secs = 86400)
ontime=self.variable
time=pbGetTimeNow
return ontime && (time.to_i>ontime+secs)
ontime = self.variable
time = pbGetTimeNow
return ontime && (time.to_i > ontime + secs)
end
def expiredDays?(days = 1)
ontime=self.variable.to_i
ontime = self.variable.to_i
return false if !ontime
now=pbGetTimeNow
elapsed=(now.to_i-ontime)/86400
elapsed+=1 if (now.to_i-ontime)%86400>(now.hour*3600+now.min*60+now.sec)
return elapsed>=days
now = pbGetTimeNow
elapsed = (now.to_i - ontime) / 86400
elapsed += 1 if (now.to_i - ontime) % 86400 > (now.hour * 3600 + now.min * 60 + now.sec)
return elapsed >= days
end
def cooledDown?(seconds)
@@ -143,7 +143,7 @@ class Game_Event < Game_Character
return if $game_system.map_interpreter.running? || @starting
if @event.name[/trainer\((\d+)\)/i]
distance = $~[1].to_i
if @trigger==2 && pbEventCanReachPlayer?(self,$game_player,distance)
if @trigger == 2 && pbEventCanReachPlayer?(self, $game_player, distance)
start if !jumping? && !over_trigger?
end
end
@@ -248,8 +248,8 @@ class Game_Event < Game_Character
return true if @move_route_forcing
return true if @event.name[/update/i]
range = 2 # Number of tiles
return false if self.screen_x - @sprite_size[0]/2 > Graphics.width + range * Game_Map::TILE_WIDTH
return false if self.screen_x + @sprite_size[0]/2 < -range * Game_Map::TILE_WIDTH
return false if self.screen_x - @sprite_size[0] / 2 > Graphics.width + range * Game_Map::TILE_WIDTH
return false if self.screen_x + @sprite_size[0] / 2 < -range * Game_Map::TILE_WIDTH
return false if self.screen_y_ground - @sprite_size[1] > Graphics.height + range * Game_Map::TILE_HEIGHT
return false if self.screen_y_ground < -range * Game_Map::TILE_HEIGHT
return true

View File

@@ -17,9 +17,9 @@ class Game_Player < Game_Character
def initialize(*arg)
super(*arg)
@lastdir=0
@lastdirframe=0
@bump_se=0
@lastdir = 0
@lastdirframe = 0
@bump_se = 0
end
def map
@@ -103,9 +103,9 @@ class Game_Player < Game_Character
end
def bump_into_object
return if @bump_se && @bump_se>0
return if @bump_se && @bump_se > 0
pbSEPlay("Player bump")
@bump_se = Graphics.frame_rate/4
@bump_se = Graphics.frame_rate / 4
end
def move_generic(dir, turn_enabled = true)
@@ -179,7 +179,7 @@ class Game_Player < Game_Character
triggerLeaveTile
end
def pbTriggeredTrainerEvents(triggers,checkIfRunning = true)
def pbTriggeredTrainerEvents(triggers, checkIfRunning = true)
result = []
# If event is running
return result if checkIfRunning && $game_system.map_interpreter.running?
@@ -188,7 +188,7 @@ class Game_Player < Game_Character
next if !event.name[/trainer\((\d+)\)/i]
distance = $~[1].to_i
# If event coordinates and triggers are consistent
if pbEventCanReachPlayer?(event,self,distance) && triggers.include?(event.trigger)
if pbEventCanReachPlayer?(event, self, distance) && triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
result.push(event) if !event.jumping? && !event.over_trigger?
end
@@ -196,7 +196,7 @@ class Game_Player < Game_Character
return result
end
def pbTriggeredCounterEvents(triggers,checkIfRunning = true)
def pbTriggeredCounterEvents(triggers, checkIfRunning = true)
result = []
# If event is running
return result if checkIfRunning && $game_system.map_interpreter.running?
@@ -205,7 +205,7 @@ class Game_Player < Game_Character
next if !event.name[/counter\((\d+)\)/i]
distance = $~[1].to_i
# If event coordinates and triggers are consistent
if pbEventFacesPlayer?(event,self,distance) && triggers.include?(event.trigger)
if pbEventFacesPlayer?(event, self, distance) && triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
result.push(event) if !event.jumping? && !event.over_trigger?
end
@@ -218,7 +218,7 @@ class Game_Player < Game_Character
def pbCheckEventTriggerFromDistance(triggers)
ret = pbTriggeredTrainerEvents(triggers)
ret.concat(pbTriggeredCounterEvents(triggers))
return false if ret.length==0
return false if ret.length == 0
for event in ret
event.start
end
@@ -401,10 +401,10 @@ class Game_Player < Game_Character
next if !event.at_coordinate?(@x + x_offset, @y + y_offset)
if event.name[/trainer\((\d+)\)/i]
distance = $~[1].to_i
next if !pbEventCanReachPlayer?(event,self,distance)
next if !pbEventCanReachPlayer?(event, self, distance)
elsif event.name[/counter\((\d+)\)/i]
distance = $~[1].to_i
next if !pbEventFacesPlayer?(event,self,distance)
next if !pbEventFacesPlayer?(event, self, distance)
end
# If starting determinant is front event (other than jumping)
next if event.jumping? || event.over_trigger?
@@ -429,12 +429,12 @@ class Game_Player < Game_Character
end
$game_temp.followers.update
# Count down the time between allowed bump sounds
@bump_se -= 1 if @bump_se && @bump_se>0
@bump_se -= 1 if @bump_se && @bump_se > 0
# Finish up dismounting from surfing
if $game_temp.ending_surf && !moving?
pbCancelVehicles
$game_temp.surf_base_coords = nil
$game_temp.ending_surf = false
$game_temp.ending_surf = false
end
update_event_triggering
end
@@ -538,7 +538,7 @@ class Game_Player < Game_Character
$game_temp.followers.turn_followers
result = pbCheckEventTriggerFromDistance([2])
# Event determinant is via touch of same position event
result |= check_event_trigger_here([1,2])
result |= check_event_trigger_here([1, 2])
# No events triggered, try other event triggers upon finishing a step
pbOnStepTaken(result)
end
@@ -546,7 +546,7 @@ class Game_Player < Game_Character
if Input.trigger?(Input::USE) && !$game_temp.in_mini_update
# Same position and front event determinant
check_event_trigger_here([0])
check_event_trigger_there([0,2])
check_event_trigger_there([0, 2])
end
end
end
@@ -566,8 +566,8 @@ def pbGetPlayerCharset(charset, trainer = nil, force = false)
end
$game_player.charsetData = [trainer.character_ID, charset, outfit] if $game_player
ret = charset
if pbResolveBitmap("Graphics/Characters/"+ret+"_"+outfit.to_s)
ret = ret+"_"+outfit.to_s
if pbResolveBitmap("Graphics/Characters/" + ret + "_" + outfit.to_s)
ret = ret + "_" + outfit.to_s
end
return ret
end

View File

@@ -161,7 +161,7 @@ class Game_Follower < Game_Event
def location_passable?(x, y, direction)
this_map = self.map
return false if !this_map || !this_map.valid?(x,y)
return false if !this_map || !this_map.valid?(x, y)
return true if @through
passed_tile_checks = false
bit = (1 << (direction / 2 - 1)) & 0x0f