mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Remove Scripts folder to convert to submodule
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
class Sprite_Picture
|
||||
def initialize(viewport, picture)
|
||||
@viewport = viewport
|
||||
@picture = picture
|
||||
@sprite = nil
|
||||
update
|
||||
end
|
||||
|
||||
def dispose
|
||||
@sprite.dispose if @sprite
|
||||
end
|
||||
|
||||
def update
|
||||
@sprite.update if @sprite
|
||||
# If picture file name is different from current one
|
||||
if @picture_name != @picture.name
|
||||
# Remember file name to instance variables
|
||||
@picture_name = @picture.name
|
||||
# If file name is not empty
|
||||
if @picture_name != ""
|
||||
# Get picture graphic
|
||||
@sprite=IconSprite.new(0,0,@viewport) if !@sprite
|
||||
@sprite.setBitmap("Graphics/Pictures/"+@picture_name)
|
||||
end
|
||||
end
|
||||
# If file name is empty
|
||||
if @picture_name == ""
|
||||
# Set sprite to invisible
|
||||
if @sprite
|
||||
@sprite.dispose if @sprite
|
||||
@sprite=nil
|
||||
end
|
||||
return
|
||||
end
|
||||
# Set sprite to visible
|
||||
@sprite.visible = true
|
||||
# Set transfer starting point
|
||||
if @picture.origin == 0
|
||||
@sprite.ox = 0
|
||||
@sprite.oy = 0
|
||||
else
|
||||
@sprite.ox = @sprite.bitmap.width / 2
|
||||
@sprite.oy = @sprite.bitmap.height / 2
|
||||
end
|
||||
# Set sprite coordinates
|
||||
@sprite.x = @picture.x
|
||||
@sprite.y = @picture.y
|
||||
@sprite.z = @picture.number
|
||||
# Set zoom rate, opacity level, and blend method
|
||||
@sprite.zoom_x = @picture.zoom_x / 100.0
|
||||
@sprite.zoom_y = @picture.zoom_y / 100.0
|
||||
@sprite.opacity = @picture.opacity
|
||||
@sprite.blend_type = @picture.blend_type
|
||||
# Set rotation angle and color tone
|
||||
@sprite.angle = @picture.angle
|
||||
@sprite.tone = @picture.tone
|
||||
end
|
||||
end
|
||||
@@ -1,45 +0,0 @@
|
||||
class Sprite_Timer
|
||||
def initialize(viewport=nil)
|
||||
@viewport=viewport
|
||||
@timer=nil
|
||||
@total_sec=nil
|
||||
@disposed=false
|
||||
end
|
||||
|
||||
def dispose
|
||||
@timer.dispose if @timer
|
||||
@timer=nil
|
||||
@disposed=true
|
||||
end
|
||||
|
||||
def disposed?
|
||||
@disposed
|
||||
end
|
||||
|
||||
def update
|
||||
return if disposed?
|
||||
if $game_system.timer_working
|
||||
@timer.visible = true if @timer
|
||||
if !@timer
|
||||
@timer=Window_AdvancedTextPokemon.newWithSize("",Graphics.width-120,0,120,64)
|
||||
@timer.width=@timer.borderX+96
|
||||
@timer.x=Graphics.width-@timer.width
|
||||
@timer.viewport=@viewport
|
||||
@timer.z=99998
|
||||
end
|
||||
curtime=$game_system.timer / Graphics.frame_rate
|
||||
curtime=0 if curtime<0
|
||||
if curtime != @total_sec
|
||||
# Calculate total number of seconds
|
||||
@total_sec = curtime
|
||||
# Make a string for displaying the timer
|
||||
min = @total_sec / 60
|
||||
sec = @total_sec % 60
|
||||
@timer.text = _ISPRINTF("<ac>{1:02d}:{2:02d}", min, sec)
|
||||
end
|
||||
@timer.update
|
||||
else
|
||||
@timer.visible=false if @timer
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,264 +0,0 @@
|
||||
class BushBitmap
|
||||
def initialize(bitmap, isTile, depth)
|
||||
@bitmaps = []
|
||||
@bitmap = bitmap
|
||||
@isTile = isTile
|
||||
@isBitmap = @bitmap.is_a?(Bitmap)
|
||||
@depth = depth
|
||||
@manual_refresh = false
|
||||
end
|
||||
|
||||
def dispose
|
||||
@bitmaps.each { |b| b.dispose if b }
|
||||
end
|
||||
|
||||
def bitmap
|
||||
thisBitmap = (@isBitmap) ? @bitmap : @bitmap.bitmap
|
||||
current = (@isBitmap) ? 0 : @bitmap.currentIndex
|
||||
if !@bitmaps[current]
|
||||
if @isTile
|
||||
@bitmaps[current] = pbBushDepthTile(thisBitmap, @depth)
|
||||
else
|
||||
@bitmaps[current] = pbBushDepthBitmap(thisBitmap, @depth)
|
||||
end
|
||||
end
|
||||
return @bitmaps[current]
|
||||
end
|
||||
|
||||
def pbBushDepthBitmap(bitmap, depth)
|
||||
ret = Bitmap.new(bitmap.width, bitmap.height)
|
||||
charheight = ret.height / 4
|
||||
cy = charheight - depth - 2
|
||||
for i in 0...4
|
||||
y = i * charheight
|
||||
if cy >= 0
|
||||
ret.blt(0, y, bitmap, Rect.new(0, y, ret.width, cy))
|
||||
ret.blt(0, y + cy, bitmap, Rect.new(0, y + cy, ret.width, 2), 170)
|
||||
end
|
||||
ret.blt(0, y + cy + 2, bitmap, Rect.new(0, y + cy + 2, ret.width, 2), 85) if cy + 2 >= 0
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbBushDepthTile(bitmap, depth)
|
||||
ret = Bitmap.new(bitmap.width, bitmap.height)
|
||||
charheight = ret.height
|
||||
cy = charheight - depth - 2
|
||||
y = charheight
|
||||
if cy >= 0
|
||||
ret.blt(0, y, bitmap, Rect.new(0, y, ret.width, cy))
|
||||
ret.blt(0, y + cy, bitmap, Rect.new(0, y + cy, ret.width, 2), 170)
|
||||
end
|
||||
ret.blt(0, y + cy + 2, bitmap, Rect.new(0, y + cy + 2, ret.width, 2), 85) if cy + 2 >= 0
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
def event_is_trainer(event)
|
||||
return $game_map.events[event.id] && event.name[/trainer\((\d+)\)/i]
|
||||
end
|
||||
|
||||
class Sprite_Character < RPG::Sprite
|
||||
attr_accessor :character
|
||||
attr_accessor :pending_bitmap
|
||||
attr_accessor :bitmap_override
|
||||
attr_accessor :charbitmap
|
||||
|
||||
def initialize(viewport, character = nil)
|
||||
super(viewport)
|
||||
@character = character
|
||||
if darknessEffectOnCurrentMap()
|
||||
if @character.is_a?(Game_Event)
|
||||
$game_map.events[@character.id].erase if event_is_trainer(@character)
|
||||
end
|
||||
end
|
||||
|
||||
@oldbushdepth = 0
|
||||
@spriteoffset = false
|
||||
if !character || character == $game_player || (character.name[/reflection/i] rescue false)
|
||||
@reflection = Sprite_Reflection.new(self, character, viewport)
|
||||
end
|
||||
@surfbase = Sprite_SurfBase.new(self, character, viewport) if character == $game_player
|
||||
checkModifySpriteGraphics(@character) if @character
|
||||
update
|
||||
end
|
||||
|
||||
def checkModifySpriteGraphics(character)
|
||||
return if character == $game_player || !character.name
|
||||
if TYPE_EXPERTS_APPEARANCES.keys.include?(character.name.to_sym)
|
||||
typeExpert = character.name.to_sym
|
||||
setSpriteToAppearance(TYPE_EXPERTS_APPEARANCES[typeExpert])
|
||||
end
|
||||
end
|
||||
|
||||
def setSpriteToAppearance(trainerAppearance)
|
||||
#return if !@charbitmap || !@charbitmap.bitmap
|
||||
begin
|
||||
new_bitmap = AnimatedBitmap.new(getBaseOverworldSpriteFilename()) #@charbitmap
|
||||
new_bitmap.bitmap = generateNPCClothedBitmapStatic(trainerAppearance)
|
||||
@bitmap_override = new_bitmap
|
||||
updateBitmap
|
||||
rescue
|
||||
end
|
||||
end
|
||||
|
||||
def clearBitmapOverride()
|
||||
@bitmap_override = nil
|
||||
updateBitmap
|
||||
end
|
||||
|
||||
def setSurfingPokemon(pokemonSpecies)
|
||||
@surfingPokemon = pokemonSpecies
|
||||
@surfbase.setPokemon(pokemonSpecies) if @surfbase
|
||||
end
|
||||
|
||||
def groundY
|
||||
return @character.screen_y_ground
|
||||
end
|
||||
|
||||
def visible=(value)
|
||||
super(value)
|
||||
@reflection.visible = value if @reflection
|
||||
end
|
||||
|
||||
def dispose
|
||||
@bushbitmap.dispose if @bushbitmap
|
||||
@bushbitmap = nil
|
||||
@charbitmap.dispose if @charbitmap
|
||||
@charbitmap = nil
|
||||
@reflection.dispose if @reflection
|
||||
@reflection = nil
|
||||
@surfbase.dispose if @surfbase
|
||||
@surfbase = nil
|
||||
super
|
||||
end
|
||||
|
||||
def updateBitmap
|
||||
@manual_refresh = true
|
||||
end
|
||||
|
||||
def pbLoadOutfitBitmap(outfitFileName)
|
||||
# Construct the file path for the outfit bitmap based on the given value
|
||||
#outfitFileName = sprintf("Graphics/Outfits/%s", value)
|
||||
|
||||
# Attempt to load the outfit bitmap
|
||||
begin
|
||||
outfitBitmap = RPG::Cache.load_bitmap("", outfitFileName)
|
||||
return outfitBitmap
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def generateClothedBitmap()
|
||||
return
|
||||
end
|
||||
|
||||
def applyDayNightTone()
|
||||
if @character.is_a?(Game_Event) && @character.name[/regulartone/i]
|
||||
self.tone.set(0, 0, 0, 0)
|
||||
else
|
||||
pbDayNightTint(self)
|
||||
end
|
||||
end
|
||||
|
||||
def updateCharacterBitmap
|
||||
AnimatedBitmap.new('Graphics/Characters/' + @character_name, @character_hue)
|
||||
end
|
||||
|
||||
def should_update?
|
||||
return @tile_id != @character.tile_id ||
|
||||
@character_name != @character.character_name ||
|
||||
@character_hue != @character.character_hue ||
|
||||
@oldbushdepth != @character.bush_depth ||
|
||||
@manual_refresh
|
||||
end
|
||||
|
||||
def refreshOutfit()
|
||||
self.pending_bitmap = getClothedPlayerSprite(true)
|
||||
end
|
||||
|
||||
def update
|
||||
if self.pending_bitmap
|
||||
self.bitmap = self.pending_bitmap
|
||||
self.pending_bitmap = nil
|
||||
end
|
||||
return if @character.is_a?(Game_Event) && !@character.should_update?
|
||||
super
|
||||
if should_update?
|
||||
@manual_refresh = false
|
||||
@tile_id = @character.tile_id
|
||||
@character_name = @character.character_name
|
||||
@character_hue = @character.character_hue
|
||||
@oldbushdepth = @character.bush_depth
|
||||
if @tile_id >= 384
|
||||
@charbitmap.dispose if @charbitmap
|
||||
@charbitmap = pbGetTileBitmap(@character.map.tileset_name, @tile_id,
|
||||
@character_hue, @character.width, @character.height)
|
||||
@charbitmapAnimated = false
|
||||
@bushbitmap.dispose if @bushbitmap
|
||||
@bushbitmap = nil
|
||||
@spriteoffset = false
|
||||
@cw = Game_Map::TILE_WIDTH * @character.width
|
||||
@ch = Game_Map::TILE_HEIGHT * @character.height
|
||||
self.src_rect.set(0, 0, @cw, @ch)
|
||||
self.ox = @cw / 2
|
||||
self.oy = @ch
|
||||
@character.sprite_size = [@cw, @ch]
|
||||
else
|
||||
@charbitmap.dispose if @charbitmap
|
||||
|
||||
@charbitmap = updateCharacterBitmap()
|
||||
@charbitmap = @bitmap_override.clone if @bitmap_override
|
||||
|
||||
RPG::Cache.retain('Graphics/Characters/', @character_name, @character_hue) if @charbitmapAnimated = true
|
||||
@bushbitmap.dispose if @bushbitmap
|
||||
@bushbitmap = nil
|
||||
#@spriteoffset = @character_name[/offset/i]
|
||||
@spriteoffset = @character_name[/fish/i] || @character_name[/dive/i] || @character_name[/surf/i]
|
||||
@cw = @charbitmap.width / 4
|
||||
@ch = @charbitmap.height / 4
|
||||
self.ox = @cw / 2
|
||||
@character.sprite_size = [@cw, @ch]
|
||||
end
|
||||
end
|
||||
@charbitmap.update if @charbitmapAnimated
|
||||
bushdepth = @character.bush_depth
|
||||
if bushdepth == 0
|
||||
if @character == $game_player
|
||||
self.bitmap = getClothedPlayerSprite() #generateClothedBitmap()
|
||||
else
|
||||
self.bitmap = (@charbitmapAnimated) ? @charbitmap.bitmap : @charbitmap
|
||||
end
|
||||
else
|
||||
@bushbitmap = BushBitmap.new(@charbitmap, (@tile_id >= 384), bushdepth) if !@bushbitmap
|
||||
self.bitmap = @bushbitmap.bitmap
|
||||
end
|
||||
self.visible = !@character.transparent
|
||||
if @tile_id == 0
|
||||
sx = @character.pattern * @cw
|
||||
sy = ((@character.direction - 2) / 2) * @ch
|
||||
self.src_rect.set(sx, sy, @cw, @ch)
|
||||
self.oy = (@spriteoffset rescue false) ? @ch - 16 : @ch
|
||||
self.oy -= @character.bob_height
|
||||
end
|
||||
if self.visible
|
||||
applyDayNightTone()
|
||||
end
|
||||
self.x = @character.screen_x
|
||||
self.y = @character.screen_y
|
||||
self.z = @character.screen_z(@ch)
|
||||
# self.zoom_x = Game_Map::TILE_WIDTH / 32.0
|
||||
# self.zoom_y = Game_Map::TILE_HEIGHT / 32.0
|
||||
self.opacity = @character.opacity
|
||||
self.blend_type = @character.blend_type
|
||||
# self.bush_depth = @character.bush_depth
|
||||
if @character.animation_id != 0
|
||||
animation = $data_animations[@character.animation_id]
|
||||
animation(animation, true)
|
||||
@character.animation_id = 0
|
||||
end
|
||||
@reflection.update if @reflection
|
||||
@surfbase.update if @surfbase
|
||||
end
|
||||
end
|
||||
@@ -1,87 +0,0 @@
|
||||
class Sprite_Reflection
|
||||
attr_reader :visible
|
||||
attr_accessor :event
|
||||
|
||||
def initialize(sprite,event,viewport=nil)
|
||||
@rsprite = sprite
|
||||
@sprite = nil
|
||||
@event = event
|
||||
@height = 0
|
||||
@fixedheight = false
|
||||
if @event && @event!=$game_player
|
||||
if @event.name[/reflection\((\d+)\)/i]
|
||||
@height = $~[1].to_i || 0
|
||||
@fixedheight = true
|
||||
end
|
||||
end
|
||||
@viewport = viewport
|
||||
@disposed = false
|
||||
update
|
||||
end
|
||||
|
||||
def dispose
|
||||
if !@disposed
|
||||
@sprite.dispose if @sprite
|
||||
@sprite = nil
|
||||
@disposed = true
|
||||
end
|
||||
end
|
||||
|
||||
def disposed?
|
||||
@disposed
|
||||
end
|
||||
|
||||
def visible=(value)
|
||||
@visible = value
|
||||
@sprite.visible = value if @sprite && !@sprite.disposed?
|
||||
end
|
||||
|
||||
def update
|
||||
return
|
||||
# return if disposed?
|
||||
# shouldShow = @rsprite.visible
|
||||
# if !shouldShow
|
||||
# # Just-in-time disposal of sprite
|
||||
# if @sprite
|
||||
# @sprite.dispose
|
||||
# @sprite = nil
|
||||
# end
|
||||
# return
|
||||
# end
|
||||
# # Just-in-time creation of sprite
|
||||
# @sprite = Sprite.new(@viewport) if !@sprite
|
||||
# if @sprite
|
||||
# x = @rsprite.x-@rsprite.ox
|
||||
# y = @rsprite.y-@rsprite.oy
|
||||
# y -= 32 if @rsprite.character.character_name[/offset/i]
|
||||
# @height = $PokemonGlobal.bridge if !@fixedheight
|
||||
# y += @height*16
|
||||
# width = @rsprite.src_rect.width
|
||||
# height = @rsprite.src_rect.height
|
||||
# @sprite.x = x+width/2
|
||||
# @sprite.y = y+height+height/2
|
||||
# @sprite.ox = width/2
|
||||
# @sprite.oy = height/2-2 # Hard-coded 2 pixel shift up
|
||||
# @sprite.oy -= @rsprite.character.bob_height*2
|
||||
# @sprite.z = -50 # Still water is -100, map is 0 and above
|
||||
# @sprite.zoom_x = @rsprite.zoom_x
|
||||
# @sprite.zoom_y = @rsprite.zoom_y
|
||||
# frame = (Graphics.frame_count%40)/10
|
||||
# @sprite.zoom_x *= [1.0, 0.95, 1.0, 1.05][frame]
|
||||
# @sprite.angle = 180.0
|
||||
# @sprite.mirror = true
|
||||
# @sprite.bitmap = @rsprite.bitmap
|
||||
# @sprite.tone = @rsprite.tone
|
||||
# if @height>0
|
||||
# @sprite.color = Color.new(48,96,160,255) # Dark still water
|
||||
# @sprite.opacity = @rsprite.opacity
|
||||
# @sprite.visible = !Settings::TIME_SHADING # Can't time-tone a colored sprite
|
||||
# else
|
||||
# @sprite.color = Color.new(224,224,224,96)
|
||||
# @sprite.opacity = @rsprite.opacity*3/4
|
||||
# @sprite.visible = true
|
||||
# end
|
||||
# @sprite.src_rect = @rsprite.src_rect
|
||||
# end
|
||||
end
|
||||
end
|
||||
@@ -1,150 +0,0 @@
|
||||
class Sprite_SurfBase
|
||||
attr_reader :visible
|
||||
attr_accessor :event
|
||||
|
||||
def initialize(sprite, event, viewport = nil)
|
||||
@rsprite = sprite
|
||||
@sprite = nil
|
||||
@event = event
|
||||
@viewport = viewport
|
||||
@disposed = false
|
||||
#@surfbitmap = AnimatedBitmap.new("Graphics/Characters/base_surf")
|
||||
@surfbitmap = update_surf_bitmap(:SURF)
|
||||
@divebitmap = update_surf_bitmap(:DIVE)
|
||||
# RPG::Cache.retain("Graphics/Characters/base_surf")
|
||||
# RPG::Cache.retain("Graphics/Characters/base_dive")
|
||||
@cws = @surfbitmap.width / 4
|
||||
@chs = @surfbitmap.height / 4
|
||||
@cwd = @divebitmap.width / 4
|
||||
@chd = @divebitmap.height / 4
|
||||
update
|
||||
end
|
||||
|
||||
def dispose
|
||||
return if @disposed
|
||||
@sprite.dispose if @sprite
|
||||
@sprite = nil
|
||||
@surfbitmap.dispose
|
||||
@divebitmap.dispose
|
||||
@disposed = true
|
||||
end
|
||||
|
||||
def disposed?
|
||||
@disposed
|
||||
end
|
||||
|
||||
def visible=(value)
|
||||
@visible = value
|
||||
@sprite.visible = value if @sprite && !@sprite.disposed?
|
||||
end
|
||||
|
||||
def update_surf_bitmap(type)
|
||||
species = $Trainer.surfing_pokemon
|
||||
path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_board" if type == :SURF
|
||||
#path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_scuba" if type == :DIVE
|
||||
path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_Head" if type == :DIVE
|
||||
if species
|
||||
shape = species.shape
|
||||
basePath = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER
|
||||
action = "divemon" if type == :DIVE
|
||||
action = "surfmon" if type == :SURF
|
||||
path = "#{basePath}#{action}_#{shape.to_s}"
|
||||
end
|
||||
return AnimatedBitmap.new(path)
|
||||
end
|
||||
|
||||
|
||||
# case species.shape
|
||||
# when :Head
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_Head" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_Head" if type == :SURF
|
||||
# when :Serpentine
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_HeadBase" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_HeadBase" if type == :SURF
|
||||
# when :Finned
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_HeadBase" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_HeadBase" if type == :SURF
|
||||
# when :HeadArms
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_HeadBase" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_HeadBase" if type == :SURF
|
||||
# when :HeadBase
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_HeadBase" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_HeadBase" if type == :SURF
|
||||
# when :BipedalTail
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_HeadBase" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_HeadBase" if type == :SURF
|
||||
# when :HeadLegs
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_HeadBase" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_HeadBase" if type == :SURF
|
||||
# when :Quadruped
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_HeadBase" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_HeadBase" if type == :SURF
|
||||
# when :Winged
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_HeadBase" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_HeadBase" if type == :SURF
|
||||
# when :Multiped
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_HeadBase" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_HeadBase" if type == :SURF
|
||||
# when :MultiBody
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_HeadBase" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_HeadBase" if type == :SURF
|
||||
# when :Bipedal
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_HeadBase" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_HeadBase" if type == :SURF
|
||||
# when :MultiWinged
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_HeadBase" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_HeadBase" if type == :SURF
|
||||
# when :Insectoid
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_HeadBase" if type == :DIVE
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_HeadBase" if type == :SURF
|
||||
# else
|
||||
# path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_01"
|
||||
# end
|
||||
|
||||
|
||||
def update
|
||||
return if disposed?
|
||||
if !$PokemonGlobal.surfing && !$PokemonGlobal.diving
|
||||
# Just-in-time disposal of sprite
|
||||
if @sprite
|
||||
@sprite.dispose
|
||||
@sprite = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
# Just-in-time creation of sprite
|
||||
@sprite = Sprite.new(@viewport) if !@sprite
|
||||
if @sprite
|
||||
if $PokemonGlobal.surfing
|
||||
@surfbitmap = update_surf_bitmap(:SURF)
|
||||
@sprite.bitmap = @surfbitmap.bitmap
|
||||
cw = @cws
|
||||
ch = @chs
|
||||
elsif $PokemonGlobal.diving
|
||||
@divebitmap = update_surf_bitmap(:DIVE)
|
||||
@sprite.bitmap = @divebitmap.bitmap
|
||||
cw = @cwd
|
||||
ch = @chd
|
||||
end
|
||||
sx = @event.pattern_surf * cw
|
||||
sy = ((@event.direction - 2) / 2) * ch
|
||||
@sprite.src_rect.set(sx, sy, cw, ch)
|
||||
if $PokemonTemp.surfJump
|
||||
@sprite.x = ($PokemonTemp.surfJump[0] * Game_Map::REAL_RES_X - @event.map.display_x + 3) / 4 + (Game_Map::TILE_WIDTH / 2)
|
||||
@sprite.y = ($PokemonTemp.surfJump[1] * Game_Map::REAL_RES_Y - @event.map.display_y + 3) / 4 + (Game_Map::TILE_HEIGHT / 2) + 16
|
||||
else
|
||||
@sprite.x = @rsprite.x
|
||||
@sprite.y = @rsprite.y
|
||||
end
|
||||
@sprite.ox = cw / 2
|
||||
@sprite.oy = ch - 16 # Assume base needs offsetting
|
||||
@sprite.oy -= @event.bob_height
|
||||
@sprite.z = @event.screen_z(ch) - 1
|
||||
@sprite.zoom_x = @rsprite.zoom_x
|
||||
@sprite.zoom_y = @rsprite.zoom_y
|
||||
@sprite.tone = @rsprite.tone
|
||||
@sprite.color = @rsprite.color
|
||||
@sprite.opacity = @rsprite.opacity
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,30 +0,0 @@
|
||||
class Spriteset_Global
|
||||
attr_reader :playersprite
|
||||
@@viewport2 = Viewport.new(0, 0, Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT)
|
||||
@@viewport2.z = 200
|
||||
|
||||
def initialize
|
||||
@playersprite = Sprite_Player.new(Spriteset_Map.viewport, $game_player)
|
||||
@picture_sprites = []
|
||||
for i in 1..100
|
||||
@picture_sprites.push(Sprite_Picture.new(@@viewport2, $game_screen.pictures[i]))
|
||||
end
|
||||
@timer_sprite = Sprite_Timer.new
|
||||
update
|
||||
end
|
||||
|
||||
def dispose
|
||||
@playersprite.dispose
|
||||
@picture_sprites.each { |sprite| sprite.dispose }
|
||||
@timer_sprite.dispose
|
||||
@playersprite = nil
|
||||
@picture_sprites.clear
|
||||
@timer_sprite = nil
|
||||
end
|
||||
|
||||
def update
|
||||
@playersprite.update
|
||||
@picture_sprites.each { |sprite| sprite.update }
|
||||
@timer_sprite.update
|
||||
end
|
||||
end
|
||||
@@ -1,168 +0,0 @@
|
||||
# Unused
|
||||
class ClippableSprite < Sprite_Character
|
||||
def initialize(viewport,event,tilemap)
|
||||
@tilemap = tilemap
|
||||
@_src_rect = Rect.new(0,0,0,0)
|
||||
super(viewport,event)
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
@_src_rect = self.src_rect
|
||||
tmright = @tilemap.map_data.xsize*Game_Map::TILE_WIDTH-@tilemap.ox
|
||||
echoln("x=#{self.x},ox=#{self.ox},tmright=#{tmright},tmox=#{@tilemap.ox}")
|
||||
if @tilemap.ox-self.ox<-self.x
|
||||
# clipped on left
|
||||
diff = -self.x-@tilemap.ox+self.ox
|
||||
self.src_rect = Rect.new(@_src_rect.x+diff,@_src_rect.y,
|
||||
@_src_rect.width-diff,@_src_rect.height)
|
||||
echoln("clipped out left: #{diff} #{@tilemap.ox-self.ox} #{self.x}")
|
||||
elsif tmright-self.ox<self.x
|
||||
# clipped on right
|
||||
diff = self.x-tmright+self.ox
|
||||
self.src_rect = Rect.new(@_src_rect.x,@_src_rect.y,
|
||||
@_src_rect.width-diff,@_src_rect.height)
|
||||
echoln("clipped out right: #{diff} #{tmright+self.ox} #{self.x}")
|
||||
else
|
||||
echoln("-not- clipped out left: #{diff} #{@tilemap.ox-self.ox} #{self.x}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Spriteset_Map
|
||||
attr_reader :map
|
||||
@@viewport0 = Viewport.new(0, 0, Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT) # Panorama
|
||||
@@viewport0.z = -100
|
||||
@@viewport1 = Viewport.new(0, 0, Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT) # Map, events, player, fog
|
||||
@@viewport1.z = 0
|
||||
@@viewport3 = Viewport.new(0, 0, Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT) # Flashing
|
||||
@@viewport3.z = 500
|
||||
|
||||
def Spriteset_Map.viewport # For access by Spriteset_Global
|
||||
return @@viewport1
|
||||
end
|
||||
|
||||
def initialize(map=nil)
|
||||
@map = (map) ? map : $game_map
|
||||
$scene.map_renderer.add_tileset(@map.tileset_name)
|
||||
@map.autotile_names.each do |filename|
|
||||
$scene.map_renderer.add_autotile(filename)
|
||||
$scene.map_renderer.add_extra_autotiles(@map.tileset_id)
|
||||
end
|
||||
|
||||
@panorama = AnimatedPlane.new(@@viewport0)
|
||||
@fog = AnimatedPlane.new(@@viewport1)
|
||||
@fog.z = 3000
|
||||
@fog2=nil
|
||||
@character_sprites = []
|
||||
for i in @map.events.keys.sort
|
||||
sprite = Sprite_Character.new(@@viewport1,@map.events[i])
|
||||
@character_sprites.push(sprite)
|
||||
end
|
||||
@weather = RPG::Weather.new(@@viewport1)
|
||||
pbOnSpritesetCreate(self,@@viewport1)
|
||||
update
|
||||
end
|
||||
|
||||
def setFog2(filename="010-Water04")
|
||||
disposeFog2()
|
||||
@fog2 = AnimatedPlane.new(@@viewport1)
|
||||
@fog2.z = 3001
|
||||
@fog2.setFog(filename)
|
||||
end
|
||||
|
||||
def disposeFog2()
|
||||
@fog2.dispose if @fog2
|
||||
@fog2 =nil
|
||||
end
|
||||
|
||||
def dispose
|
||||
if $scene.is_a?(Scene_Map)
|
||||
$scene.map_renderer.remove_tileset(@map.tileset_name)
|
||||
@map.autotile_names.each do |filename|
|
||||
$scene.map_renderer.remove_autotile(filename)
|
||||
$scene.map_renderer.remove_extra_autotiles(@map.tileset_id)
|
||||
end
|
||||
end
|
||||
@panorama.dispose
|
||||
@fog.dispose
|
||||
@fog2.dispose if @fog2
|
||||
for sprite in @character_sprites
|
||||
sprite.dispose
|
||||
end
|
||||
@weather.dispose
|
||||
@panorama = nil
|
||||
@fog = nil
|
||||
@character_sprites.clear
|
||||
@weather = nil
|
||||
end
|
||||
|
||||
def getAnimations
|
||||
return @usersprites
|
||||
end
|
||||
|
||||
def restoreAnimations(anims)
|
||||
@usersprites = anims
|
||||
end
|
||||
|
||||
def update
|
||||
if @panorama_name!=@map.panorama_name || @panorama_hue!=@map.panorama_hue
|
||||
@panorama_name = @map.panorama_name
|
||||
@panorama_hue = @map.panorama_hue
|
||||
@panorama.setPanorama(nil) if @panorama.bitmap!=nil
|
||||
@panorama.setPanorama(@panorama_name,@panorama_hue) if @panorama_name!=""
|
||||
Graphics.frame_reset
|
||||
end
|
||||
if @fog_name!=@map.fog_name || @fog_hue!=@map.fog_hue
|
||||
@fog_name = @map.fog_name
|
||||
@fog_hue = @map.fog_hue
|
||||
@fog.setFog(nil) if @fog.bitmap!=nil
|
||||
@fog.setFog(@fog_name,@fog_hue) if @fog_name!=""
|
||||
Graphics.frame_reset
|
||||
end
|
||||
tmox = (@map.display_x/Game_Map::X_SUBPIXELS).round
|
||||
tmoy = (@map.display_y/Game_Map::Y_SUBPIXELS).round
|
||||
@@viewport1.rect.set(0,0,Graphics.width,Graphics.height)
|
||||
@@viewport1.ox = 0
|
||||
@@viewport1.oy = 0
|
||||
@@viewport1.ox += $game_screen.shake
|
||||
@panorama.ox = tmox/2
|
||||
@panorama.oy = tmoy/2
|
||||
@fog.ox = tmox+@map.fog_ox
|
||||
@fog.oy = tmoy+@map.fog_oy
|
||||
@fog.zoom_x = @map.fog_zoom/100.0
|
||||
@fog.zoom_y = @map.fog_zoom/100.0
|
||||
@fog.opacity = @map.fog_opacity
|
||||
@fog.blend_type = @map.fog_blend_type
|
||||
@fog.tone = @map.fog_tone
|
||||
|
||||
@fog2.ox = tmox+@map.fog2_ox if @fog2
|
||||
@fog2.oy = tmoy+@map.fog2_oy if @fog2
|
||||
@fog2.zoom_x = @map.fog_zoom/100.0 if @fog2
|
||||
@fog2.zoom_y = @map.fog_zoom/100.0 if @fog2
|
||||
@fog2.opacity = @map.fog2_opacity if @fog2
|
||||
|
||||
|
||||
@panorama.update
|
||||
@fog.update
|
||||
@fog2.update if @fog2
|
||||
|
||||
for sprite in @character_sprites
|
||||
sprite.update
|
||||
end
|
||||
if self.map!=$game_map
|
||||
@weather.fade_in(:None, 0, 20)
|
||||
else
|
||||
@weather.fade_in($game_screen.weather_type, $game_screen.weather_max, $game_screen.weather_duration)
|
||||
end
|
||||
@weather.ox = tmox
|
||||
@weather.oy = tmoy
|
||||
@weather.update
|
||||
@@viewport1.tone = $game_screen.tone
|
||||
@@viewport3.color = $game_screen.flash_color
|
||||
@@viewport1.update
|
||||
@@viewport3.update
|
||||
end
|
||||
end
|
||||
@@ -1,84 +0,0 @@
|
||||
=begin
|
||||
A sprite whose sole purpose is to display an animation. This sprite
|
||||
can be displayed anywhere on the map and is disposed
|
||||
automatically when its animation is finished.
|
||||
Used for grass rustling and so forth.
|
||||
=end
|
||||
class AnimationSprite < RPG::Sprite
|
||||
def initialize(animID,map,tileX,tileY,viewport=nil,tinting=false,height=3)
|
||||
super(viewport)
|
||||
@tileX = tileX
|
||||
@tileY = tileY
|
||||
self.bitmap = Bitmap.new(1, 1)
|
||||
self.bitmap.clear
|
||||
@map = map
|
||||
setCoords
|
||||
pbDayNightTint(self) if tinting
|
||||
self.animation($data_animations[animID],true,height)
|
||||
end
|
||||
|
||||
def setCoords
|
||||
self.x = ((@tileX * Game_Map::REAL_RES_X - @map.display_x) / Game_Map::X_SUBPIXELS).ceil
|
||||
self.x += Game_Map::TILE_WIDTH / 2
|
||||
self.y = ((@tileY * Game_Map::REAL_RES_Y - @map.display_y) / Game_Map::Y_SUBPIXELS).ceil
|
||||
self.y += Game_Map::TILE_HEIGHT
|
||||
end
|
||||
|
||||
def dispose
|
||||
self.bitmap.dispose
|
||||
super
|
||||
end
|
||||
|
||||
def update
|
||||
if !self.disposed?
|
||||
setCoords
|
||||
super
|
||||
self.dispose if !self.effect?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Spriteset_Map
|
||||
alias _animationSprite_initialize initialize unless method_defined?(:_animationSprite_initialize)
|
||||
alias _animationSprite_update update unless method_defined?(:_animationSprite_update)
|
||||
alias _animationSprite_dispose dispose unless method_defined?(:_animationSprite_dispose)
|
||||
|
||||
def initialize(map=nil)
|
||||
@usersprites=[]
|
||||
_animationSprite_initialize(map)
|
||||
end
|
||||
|
||||
def addUserAnimation(animID,x,y,tinting=false,height=3)
|
||||
sprite=AnimationSprite.new(animID,$game_map,x,y,@@viewport1,tinting,height)
|
||||
addUserSprite(sprite)
|
||||
return sprite
|
||||
end
|
||||
|
||||
def addUserSprite(sprite)
|
||||
for i in 0...@usersprites.length
|
||||
if @usersprites[i]==nil || @usersprites[i].disposed?
|
||||
@usersprites[i]=sprite
|
||||
return
|
||||
end
|
||||
end
|
||||
@usersprites.push(sprite)
|
||||
end
|
||||
|
||||
def dispose
|
||||
_animationSprite_dispose
|
||||
for i in 0...@usersprites.length
|
||||
@usersprites[i].dispose
|
||||
end
|
||||
@usersprites.clear
|
||||
end
|
||||
|
||||
def update
|
||||
@@viewport3.tone.set(0,0,0,0)
|
||||
_animationSprite_update
|
||||
for i in 0...@usersprites.length
|
||||
@usersprites[i].update if !@usersprites[i].disposed?
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,253 +0,0 @@
|
||||
#===============================================================================
|
||||
# Sprite_Shadow (Sprite_Ombre )
|
||||
# Based on Genzai Kawakami's shadows, dynamisme & features by Rataime, extra
|
||||
# features Boushy
|
||||
# Modified by Peter O. to be compatible with Pokémon Essentials
|
||||
#===============================================================================
|
||||
class Sprite_Shadow < RPG::Sprite
|
||||
attr_accessor :character
|
||||
|
||||
def initialize(viewport, character = nil, params = [])
|
||||
super(viewport)
|
||||
@source = params[0]
|
||||
@anglemin = (params.size > 1) ? params[1] : 0
|
||||
@anglemax = (params.size > 2) ? params[2] : 0
|
||||
@self_opacity = (params.size > 4) ? params[4] : 100
|
||||
@distancemax = (params.size > 3) ? params[3] : 350
|
||||
@character = character
|
||||
update
|
||||
end
|
||||
|
||||
def dispose
|
||||
@chbitmap&.dispose
|
||||
super
|
||||
end
|
||||
|
||||
def update
|
||||
if !in_range?(@character, @source, @distancemax)
|
||||
self.opacity = 0
|
||||
return
|
||||
end
|
||||
super
|
||||
if @tile_id != @character.tile_id ||
|
||||
@character_name != @character.character_name ||
|
||||
@character_hue != @character.character_hue
|
||||
@tile_id = @character.tile_id
|
||||
@character_name = @character.character_name
|
||||
@character_hue = @character.character_hue
|
||||
@chbitmap&.dispose
|
||||
if @tile_id >= 384
|
||||
@chbitmap = pbGetTileBitmap(@character.map.tileset_name,
|
||||
@tile_id, @character.character_hue)
|
||||
self.src_rect.set(0, 0, 32, 32)
|
||||
@ch = 32
|
||||
@cw = 32
|
||||
self.ox = 16
|
||||
self.oy = 32
|
||||
else
|
||||
@chbitmap = AnimatedBitmap.new('Graphics/Characters/' + @character.character_name,
|
||||
@character.character_hue)
|
||||
@cw = @chbitmap.width / 4
|
||||
@ch = @chbitmap.height / 4
|
||||
self.ox = @cw / 2
|
||||
self.oy = @ch
|
||||
end
|
||||
end
|
||||
if @chbitmap.is_a?(AnimatedBitmap)
|
||||
@chbitmap.update
|
||||
self.bitmap = @chbitmap.bitmap
|
||||
else
|
||||
self.bitmap = @chbitmap
|
||||
end
|
||||
self.visible = !@character.transparent
|
||||
if @tile_id == 0
|
||||
sx = @character.pattern * @cw
|
||||
sy = (@character.direction - 2) / 2 * @ch
|
||||
if self.angle > 90 || angle < -90
|
||||
case @character.direction
|
||||
when 2 then sy = @ch * 3
|
||||
when 4 then sy = @ch * 2
|
||||
when 6 then sy = @ch
|
||||
when 8 then sy = 0
|
||||
end
|
||||
end
|
||||
self.src_rect.set(sx, sy, @cw, @ch)
|
||||
end
|
||||
self.x = ScreenPosHelper.pbScreenX(@character)
|
||||
self.y = ScreenPosHelper.pbScreenY(@character) - 5
|
||||
self.z = ScreenPosHelper.pbScreenZ(@character, @ch) - 1
|
||||
self.zoom_x = ScreenPosHelper.pbScreenZoomX(@character)
|
||||
self.zoom_y = ScreenPosHelper.pbScreenZoomY(@character)
|
||||
self.blend_type = @character.blend_type
|
||||
self.bush_depth = @character.bush_depth
|
||||
if @character.animation_id != 0
|
||||
animation = $data_animations[@character.animation_id]
|
||||
animation(animation, true)
|
||||
@character.animation_id = 0
|
||||
end
|
||||
@deltax = ScreenPosHelper.pbScreenX(@source) - self.x
|
||||
@deltay = ScreenPosHelper.pbScreenY(@source) - self.y
|
||||
self.color = Color.new(0, 0, 0)
|
||||
@distance = ((@deltax**2) + (@deltay**2))
|
||||
self.opacity = @self_opacity * 13_000 / ((@distance * 370 / @distancemax) + 6000)
|
||||
self.angle = 57.3 * Math.atan2(@deltax, @deltay)
|
||||
@angle_trigo = self.angle + 90
|
||||
@angle_trigo += 360 if @angle_trigo < 0
|
||||
if @anglemin != 0 || @anglemax != 0
|
||||
if (@angle_trigo < @anglemin || @angle_trigo > @anglemax) && @anglemin < @anglemax
|
||||
self.opacity = 0
|
||||
return
|
||||
end
|
||||
if @angle_trigo < @anglemin && @angle_trigo > @anglemax && @anglemin > @anglemax
|
||||
self.opacity = 0
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def in_range?(element, object, range) # From Near's Anti Lag Script, edited
|
||||
elemScreenX = ScreenPosHelper.pbScreenX(element)
|
||||
elemScreenY = ScreenPosHelper.pbScreenY(element)
|
||||
objScreenX = ScreenPosHelper.pbScreenX(object)
|
||||
objScreenY = ScreenPosHelper.pbScreenY(object)
|
||||
x = (elemScreenX - objScreenX) * (elemScreenX - objScreenX)
|
||||
y = (elemScreenY - objScreenY) * (elemScreenY - objScreenY)
|
||||
r = x + y
|
||||
return r <= range * range
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===================================================
|
||||
# ? CLASS Sprite_Character edit
|
||||
#===================================================
|
||||
class Sprite_Character < RPG::Sprite
|
||||
alias shadow_initialize initialize unless method_defined?(:shadow_initialize)
|
||||
|
||||
def initialize(viewport, character = nil)
|
||||
@ombrelist = []
|
||||
@character = character
|
||||
shadow_initialize(viewport, @character)
|
||||
end
|
||||
|
||||
def setShadows(map, shadows)
|
||||
if character.is_a?(Game_Event) && shadows.length > 0
|
||||
params = XPML_read(map, "Shadow", @character, 4)
|
||||
if params != nil
|
||||
shadows.each do |shadow|
|
||||
@ombrelist.push(Sprite_Shadow.new(viewport, @character, shadows))
|
||||
end
|
||||
end
|
||||
end
|
||||
if character.is_a?(Game_Player) && shadows.length > 0
|
||||
shadows.each do |shadow|
|
||||
@ombrelist.push(Sprite_Shadow.new(viewport, $game_player, shadow))
|
||||
end
|
||||
end
|
||||
update
|
||||
end
|
||||
|
||||
def clearShadows
|
||||
@ombrelist.each { |s| s&.dispose }
|
||||
@ombrelist.clear
|
||||
end
|
||||
|
||||
alias shadow_update update unless method_defined?(:shadow_update)
|
||||
|
||||
def update
|
||||
shadow_update
|
||||
@ombrelist.each { |ombre| ombre.update }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===================================================
|
||||
# ? CLASS Game_Event edit
|
||||
#===================================================
|
||||
class Game_Event
|
||||
attr_accessor :id
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===================================================
|
||||
# ? CLASS Spriteset_Map edit
|
||||
#===================================================
|
||||
class Spriteset_Map
|
||||
attr_accessor :shadows
|
||||
|
||||
alias shadow_initialize initialize unless method_defined?(:shadow_initialize)
|
||||
|
||||
def initialize(map = nil)
|
||||
@shadows = []
|
||||
warn = false
|
||||
map = $game_map if !map
|
||||
map.events.keys.sort.each do |k|
|
||||
ev = map.events[k]
|
||||
warn = true if ev.list != nil && ev.list.length > 0 && ev.list[0].code == 108 &&
|
||||
(ev.list[0].parameters == ["s"] || ev.list[0].parameters == ["o"])
|
||||
params = XPML_read(map, "Shadow Source", ev, 4)
|
||||
@shadows.push([ev] + params) if params != nil
|
||||
end
|
||||
if warn == true
|
||||
p "Warning : At least one event on this map uses the obsolete way to add shadows"
|
||||
end
|
||||
shadow_initialize(map)
|
||||
@character_sprites.each do |sprite|
|
||||
sprite.setShadows(map, @shadows)
|
||||
end
|
||||
$scene.spritesetGlobal.playersprite.setShadows(map, @shadows)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===================================================
|
||||
# ? XPML Definition, by Rataime, using ideas from Near Fantastica
|
||||
#
|
||||
# Returns nil if the markup wasn't present at all,
|
||||
# returns [] if there wasn't any parameters, else
|
||||
# returns a parameters list with "int" converted as int
|
||||
# eg :
|
||||
# begin first
|
||||
# begin second
|
||||
# param1 1
|
||||
# param2 two
|
||||
# begin third
|
||||
# anything 3
|
||||
#
|
||||
# p XPML_read("first", event_id) -> []
|
||||
# p XPML_read("second", event_id) -> [1, "two"]
|
||||
# p XPML_read("third", event_id) -> [3]
|
||||
# p XPML_read("forth", event_id) -> nil
|
||||
#===================================================
|
||||
def XPML_read(map, markup, event, max_param_number = 0)
|
||||
parameter_list = nil
|
||||
return nil if !event || event.list.nil?
|
||||
event.list.size.times do |i|
|
||||
if event.list[i].code == 108 &&
|
||||
event.list[i].parameters[0].downcase == "begin " + markup.downcase
|
||||
parameter_list = [] if parameter_list.nil?
|
||||
((i + 1)...event.list.size).each do |j|
|
||||
if event.list[j].code == 108
|
||||
parts = event.list[j].parameters[0].split
|
||||
if parts.size != 1 && parts[0].downcase != "begin"
|
||||
if parts[1].to_i != 0 || parts[1] == "0"
|
||||
parameter_list.push(parts[1].to_i)
|
||||
else
|
||||
parameter_list.push(parts[1])
|
||||
end
|
||||
else
|
||||
return parameter_list
|
||||
end
|
||||
else
|
||||
return parameter_list
|
||||
end
|
||||
return parameter_list if max_param_number != 0 && j == i + max_param_number
|
||||
end
|
||||
end
|
||||
end
|
||||
return parameter_list
|
||||
end
|
||||
@@ -1,586 +0,0 @@
|
||||
# Particle Engine, Peter O., 2007-11-03
|
||||
# Based on version 2 by Near Fantastica, 04.01.06
|
||||
# In turn based on the Particle Engine designed by PinkMan
|
||||
class Particle_Engine
|
||||
def initialize(viewport = nil, map = nil)
|
||||
@map = (map) ? map : $game_map
|
||||
@viewport = viewport
|
||||
@effect = []
|
||||
@disposed = false
|
||||
@firsttime = true
|
||||
@effects = {
|
||||
# PinkMan's Effects
|
||||
"fire" => Particle_Engine::Fire,
|
||||
"smoke" => Particle_Engine::Smoke,
|
||||
"teleport" => Particle_Engine::Teleport,
|
||||
"spirit" => Particle_Engine::Spirit,
|
||||
"explosion" => Particle_Engine::Explosion,
|
||||
"aura" => Particle_Engine::Aura,
|
||||
# BlueScope's Effects
|
||||
"soot" => Particle_Engine::Soot,
|
||||
"sootsmoke" => Particle_Engine::SootSmoke,
|
||||
"rocket" => Particle_Engine::Rocket,
|
||||
"fixteleport" => Particle_Engine::FixedTeleport,
|
||||
"smokescreen" => Particle_Engine::Smokescreen,
|
||||
"flare" => Particle_Engine::Flare,
|
||||
"splash" => Particle_Engine::Splash,
|
||||
# By Peter O.
|
||||
"starteleport" => Particle_Engine::StarTeleport
|
||||
}
|
||||
end
|
||||
|
||||
def dispose
|
||||
return if disposed?
|
||||
@effect.each do |particle|
|
||||
next if particle.nil?
|
||||
particle.dispose
|
||||
end
|
||||
@effect.clear
|
||||
@map = nil
|
||||
@disposed = true
|
||||
end
|
||||
|
||||
def disposed?
|
||||
return @disposed
|
||||
end
|
||||
|
||||
def add_effect(event)
|
||||
@effect[event.id] = pbParticleEffect(event)
|
||||
end
|
||||
|
||||
def remove_effect(event)
|
||||
return if @effect[event.id].nil?
|
||||
@effect[event.id].dispose
|
||||
@effect.delete_at(event.id)
|
||||
end
|
||||
|
||||
def realloc_effect(event, particle)
|
||||
type = pbEventCommentInput(event, 1, "Particle Engine Type")
|
||||
if type.nil?
|
||||
particle&.dispose
|
||||
return nil
|
||||
end
|
||||
type = type[0].downcase
|
||||
cls = @effects[type]
|
||||
if cls.nil?
|
||||
particle&.dispose
|
||||
return nil
|
||||
end
|
||||
if !particle || !particle.is_a?(cls)
|
||||
particle&.dispose
|
||||
particle = cls.new(event, @viewport)
|
||||
end
|
||||
return particle
|
||||
end
|
||||
|
||||
def pbParticleEffect(event)
|
||||
return realloc_effect(event, nil)
|
||||
end
|
||||
|
||||
def update
|
||||
if @firsttime
|
||||
@firsttime = false
|
||||
@map.events.values.each do |event|
|
||||
remove_effect(event)
|
||||
add_effect(event)
|
||||
end
|
||||
end
|
||||
@effect.each_with_index do |particle, i|
|
||||
next if particle.nil?
|
||||
if particle.event.pe_refresh
|
||||
event = particle.event
|
||||
event.pe_refresh = false
|
||||
particle = realloc_effect(event, particle)
|
||||
@effect[i] = particle
|
||||
end
|
||||
particle&.update
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class ParticleEffect
|
||||
attr_accessor :x, :y, :z
|
||||
|
||||
def initialize
|
||||
@x = 0
|
||||
@y = 0
|
||||
@z = 0
|
||||
end
|
||||
|
||||
def update; end
|
||||
def dispose; end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class ParticleSprite
|
||||
attr_accessor :x, :y, :z, :ox, :oy, :opacity, :blend_type
|
||||
attr_reader :bitmap
|
||||
|
||||
def initialize(viewport)
|
||||
@viewport = viewport
|
||||
@sprite = nil
|
||||
@x = 0
|
||||
@y = 0
|
||||
@z = 0
|
||||
@ox = 0
|
||||
@oy = 0
|
||||
@opacity = 255
|
||||
@bitmap = nil
|
||||
@blend_type = 0
|
||||
@minleft = 0
|
||||
@mintop = 0
|
||||
end
|
||||
|
||||
def dispose
|
||||
@sprite&.dispose
|
||||
end
|
||||
|
||||
def bitmap=(value)
|
||||
@bitmap = value
|
||||
if value
|
||||
@minleft = -value.width
|
||||
@mintop = -value.height
|
||||
else
|
||||
@minleft = 0
|
||||
@mintop = 0
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
w = Graphics.width
|
||||
h = Graphics.height
|
||||
if !@sprite && @x >= @minleft && @y >= @mintop && @x < w && @y < h
|
||||
@sprite = Sprite.new(@viewport)
|
||||
elsif @sprite && (@x < @minleft || @y < @mintop || @x >= w || @y >= h)
|
||||
@sprite.dispose
|
||||
@sprite = nil
|
||||
end
|
||||
if @sprite
|
||||
@sprite.x = @x if @sprite.x != @x
|
||||
@sprite.x -= @ox
|
||||
@sprite.y = @y if @sprite.y != @y
|
||||
@sprite.y -= @oy
|
||||
@sprite.z = @z if @sprite.z != @z
|
||||
@sprite.opacity = @opacity if @sprite.opacity != @opacity
|
||||
@sprite.blend_type = @blend_type if @sprite.blend_type != @blend_type
|
||||
@sprite.bitmap = @bitmap if @sprite.bitmap != @bitmap
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class ParticleEffect_Event < ParticleEffect
|
||||
attr_accessor :event
|
||||
|
||||
def initialize(event, viewport = nil)
|
||||
@event = event
|
||||
@viewport = viewport
|
||||
@particles = []
|
||||
@bitmaps = {}
|
||||
end
|
||||
|
||||
def setParameters(params)
|
||||
@randomhue, @leftright, @fade,
|
||||
@maxparticless, @hue, @slowdown,
|
||||
@ytop, @ybottom, @xleft, @xright,
|
||||
@xgravity, @ygravity, @xoffset, @yoffset,
|
||||
@opacityvar, @originalopacity = params
|
||||
end
|
||||
|
||||
def loadBitmap(filename, hue)
|
||||
key = [filename, hue]
|
||||
bitmap = @bitmaps[key]
|
||||
if !bitmap || bitmap.disposed?
|
||||
bitmap = AnimatedBitmap.new("Graphics/Fogs/" + filename, hue).deanimate
|
||||
@bitmaps[key] = bitmap
|
||||
end
|
||||
return bitmap
|
||||
end
|
||||
|
||||
def initParticles(filename, opacity, zOffset = 0, blendtype = 1)
|
||||
@particles = []
|
||||
@particlex = []
|
||||
@particley = []
|
||||
@opacity = []
|
||||
@startingx = self.x + @xoffset
|
||||
@startingy = self.y + @yoffset
|
||||
@screen_x = self.x
|
||||
@screen_y = self.y
|
||||
@real_x = @event.real_x
|
||||
@real_y = @event.real_y
|
||||
@filename = filename
|
||||
@zoffset = zOffset
|
||||
@bmwidth = 32
|
||||
@bmheight = 32
|
||||
@maxparticless.times do |i|
|
||||
@particlex[i] = -@xoffset
|
||||
@particley[i] = -@yoffset
|
||||
@particles[i] = ParticleSprite.new(@viewport)
|
||||
@particles[i].bitmap = loadBitmap(filename, @hue) if filename
|
||||
if i == 0 && @particles[i].bitmap
|
||||
@bmwidth = @particles[i].bitmap.width
|
||||
@bmheight = @particles[i].bitmap.height
|
||||
end
|
||||
@particles[i].blend_type = blendtype
|
||||
@particles[i].y = @startingy
|
||||
@particles[i].x = @startingx
|
||||
@particles[i].z = self.z + zOffset
|
||||
@opacity[i] = rand(opacity / 4)
|
||||
@particles[i].opacity = @opacity[i]
|
||||
@particles[i].update
|
||||
end
|
||||
end
|
||||
|
||||
def x; return ScreenPosHelper.pbScreenX(@event); end
|
||||
def y; return ScreenPosHelper.pbScreenY(@event); end
|
||||
def z; return ScreenPosHelper.pbScreenZ(@event); end
|
||||
|
||||
def update
|
||||
if @viewport &&
|
||||
(@viewport.rect.x >= Graphics.width ||
|
||||
@viewport.rect.y >= Graphics.height)
|
||||
return
|
||||
end
|
||||
selfX = self.x
|
||||
selfY = self.y
|
||||
selfZ = self.z
|
||||
newRealX = @event.real_x
|
||||
newRealY = @event.real_y
|
||||
@startingx = selfX + @xoffset
|
||||
@startingy = selfY + @yoffset
|
||||
@__offsetx = (@real_x == newRealX) ? 0 : selfX - @screen_x
|
||||
@__offsety = (@real_y == newRealY) ? 0 : selfY - @screen_y
|
||||
@screen_x = selfX
|
||||
@screen_y = selfY
|
||||
@real_x = newRealX
|
||||
@real_y = newRealY
|
||||
if @opacityvar > 0 && @viewport
|
||||
opac = 255.0 / @opacityvar
|
||||
minX = (opac * (-@xgravity.to_f / @slowdown).floor) + @startingx
|
||||
maxX = (opac * (@xgravity.to_f / @slowdown).floor) + @startingx
|
||||
minY = (opac * (-@ygravity.to_f / @slowdown).floor) + @startingy
|
||||
maxY = @startingy
|
||||
minX -= @bmwidth
|
||||
minY -= @bmheight
|
||||
maxX += @bmwidth
|
||||
maxY += @bmheight
|
||||
if maxX < 0 || maxY < 0 || minX >= Graphics.width || minY >= Graphics.height
|
||||
# echo "skipped"
|
||||
return
|
||||
end
|
||||
end
|
||||
particleZ = selfZ + @zoffset
|
||||
@maxparticless.times do |i|
|
||||
@particles[i].z = particleZ
|
||||
if @particles[i].y <= @ytop
|
||||
@particles[i].y = @startingy + @yoffset
|
||||
@particles[i].x = @startingx + @xoffset
|
||||
@particlex[i] = 0.0
|
||||
@particley[i] = 0.0
|
||||
end
|
||||
if @particles[i].x <= @xleft
|
||||
@particles[i].y = @startingy + @yoffset
|
||||
@particles[i].x = @startingx + @xoffset
|
||||
@particlex[i] = 0.0
|
||||
@particley[i] = 0.0
|
||||
end
|
||||
if @particles[i].y >= @ybottom
|
||||
@particles[i].y = @startingy + @yoffset
|
||||
@particles[i].x = @startingx + @xoffset
|
||||
@particlex[i] = 0.0
|
||||
@particley[i] = 0.0
|
||||
end
|
||||
if @particles[i].x >= @xright
|
||||
@particles[i].y = @startingy + @yoffset
|
||||
@particles[i].x = @startingx + @xoffset
|
||||
@particlex[i] = 0.0
|
||||
@particley[i] = 0.0
|
||||
end
|
||||
if @fade == 0
|
||||
if @opacity[i] <= 0
|
||||
@opacity[i] = @originalopacity
|
||||
@particles[i].y = @startingy + @yoffset
|
||||
@particles[i].x = @startingx + @xoffset
|
||||
@particlex[i] = 0.0
|
||||
@particley[i] = 0.0
|
||||
end
|
||||
elsif @opacity[i] <= 0
|
||||
@opacity[i] = 250
|
||||
@particles[i].y = @startingy + @yoffset
|
||||
@particles[i].x = @startingx + @xoffset
|
||||
@particlex[i] = 0.0
|
||||
@particley[i] = 0.0
|
||||
end
|
||||
calcParticlePos(i)
|
||||
if @randomhue == 1
|
||||
@hue += 0.5
|
||||
@hue = 0 if @hue >= 360
|
||||
@particles[i].bitmap = loadBitmap(@filename, @hue) if @filename
|
||||
end
|
||||
@opacity[i] = @opacity[i] - rand(@opacityvar)
|
||||
@particles[i].opacity = @opacity[i]
|
||||
@particles[i].update
|
||||
end
|
||||
end
|
||||
|
||||
def calcParticlePos(i)
|
||||
@leftright = rand(2)
|
||||
if @leftright == 1
|
||||
xo = -@xgravity.to_f / @slowdown
|
||||
else
|
||||
xo = @xgravity.to_f / @slowdown
|
||||
end
|
||||
yo = -@ygravity.to_f / @slowdown
|
||||
@particlex[i] += xo
|
||||
@particley[i] += yo
|
||||
@particlex[i] -= @__offsetx
|
||||
@particley[i] -= @__offsety
|
||||
@particlex[i] = @particlex[i].floor
|
||||
@particley[i] = @particley[i].floor
|
||||
@particles[i].x = @particlex[i] + @startingx + @xoffset
|
||||
@particles[i].y = @particley[i] + @startingy + @yoffset
|
||||
end
|
||||
|
||||
def dispose
|
||||
@particles.each do |particle|
|
||||
particle.dispose
|
||||
end
|
||||
@bitmaps.values.each do |bitmap|
|
||||
bitmap.dispose
|
||||
end
|
||||
@particles.clear
|
||||
@bitmaps.clear
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Fire < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0, 0, 1, 20, 40, 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0])
|
||||
initParticles("particle", 250)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Smoke < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0, 0, 0, 80, 20, 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80])
|
||||
initParticles("smoke", 250)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Teleport < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([1, 1, 1, 10, rand(360), 1, -64,
|
||||
Graphics.height, -64, Graphics.width, 0, 3, -8, -15, 20, 0])
|
||||
initParticles("wideportal", 250)
|
||||
@maxparticless.times do |i|
|
||||
@particles[i].ox = 16
|
||||
@particles[i].oy = 16
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Spirit < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([1, 0, 1, 20, rand(360), 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0])
|
||||
initParticles("particle", 250)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Explosion < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0, 0, 1, 20, 0, 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0])
|
||||
initParticles("explosion", 250)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Aura < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0, 0, 1, 20, 0, 1, -64,
|
||||
Graphics.height, -64, Graphics.width, 2, 2, -5, -13, 30, 0])
|
||||
initParticles("particle", 250)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Soot < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0, 0, 0, 20, 0, 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80])
|
||||
initParticles("smoke", 100, 0, 2)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::SootSmoke < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0, 0, 0, 30, 0, 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80])
|
||||
initParticles("smoke", 100, 0)
|
||||
@maxparticless.times do |i|
|
||||
@particles[i].blend_type = rand(6) < 3 ? 1 : 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Rocket < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0, 0, 0, 60, 0, 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0, -5, -15, 5, 80])
|
||||
initParticles("smoke", 100, -1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::FixedTeleport < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([1, 0, 1, 10, rand(360), 1,
|
||||
-Graphics.height, Graphics.height, 0, Graphics.width, 0, 3, -8, -15, 20, 0])
|
||||
initParticles("wideportal", 250)
|
||||
@maxparticless.times do |i|
|
||||
@particles[i].ox = 16
|
||||
@particles[i].oy = 16
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
# By Peter O.
|
||||
class Particle_Engine::StarTeleport < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0, 0, 1, 10, 0, 1,
|
||||
-Graphics.height, Graphics.height, 0, Graphics.width, 0, 3, -8, -15, 10, 0])
|
||||
initParticles("star", 250)
|
||||
@maxparticless.times do |i|
|
||||
@particles[i].ox = 48
|
||||
@particles[i].oy = 48
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Smokescreen < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0, 0, 0, 250, 0, 0.2, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.8, 0.8, -5, -15, 5, 80])
|
||||
initParticles(nil, 100)
|
||||
@maxparticless.times do |i|
|
||||
rnd = rand(3)
|
||||
@opacity[i] = (rnd == 0) ? 1 : 100
|
||||
filename = (rnd == 0) ? "explosionsmoke" : "smoke"
|
||||
@particles[i].bitmap = loadBitmap(filename, @hue)
|
||||
end
|
||||
end
|
||||
|
||||
def calcParticlePos(i)
|
||||
if @randomhue == 1
|
||||
filename = (rand(3) == 0) ? "explosionsmoke" : "smoke"
|
||||
@particles[i].bitmap = loadBitmap(filename, @hue)
|
||||
end
|
||||
multiple = 1.7
|
||||
xgrav = @xgravity * multiple / @slowdown
|
||||
xgrav = -xgrav if rand(2) == 1
|
||||
ygrav = @ygravity * multiple / @slowdown
|
||||
ygrav = -ygrav if rand(2) == 1
|
||||
@particlex[i] += xgrav
|
||||
@particley[i] += ygrav
|
||||
@particlex[i] -= @__offsetx
|
||||
@particley[i] -= @__offsety
|
||||
@particlex[i] = @particlex[i].floor
|
||||
@particley[i] = @particley[i].floor
|
||||
@particles[i].x = @particlex[i] + @startingx + @xoffset
|
||||
@particles[i].y = @particley[i] + @startingy + @yoffset
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Flare < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0, 0, 1, 30, 10, 1, -64,
|
||||
Graphics.height, -64, Graphics.width, 2, 2, -5, -12, 30, 0])
|
||||
initParticles("particle", 255)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Splash < ParticleEffect_Event
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0, 0, 1, 30, 255, 1, -64,
|
||||
Graphics.height, -64, Graphics.width, 4, 2, -5, -12, 30, 0])
|
||||
initParticles("smoke", 50)
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
@maxparticless.times do |i|
|
||||
@particles[i].opacity = 50
|
||||
@particles[i].update
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Game_Event < Game_Character
|
||||
attr_accessor :pe_refresh
|
||||
|
||||
alias nf_particles_game_map_initialize initialize unless method_defined?(:nf_particles_game_map_initialize)
|
||||
|
||||
def initialize(map_id, event, map = nil)
|
||||
@pe_refresh = false
|
||||
begin
|
||||
nf_particles_game_map_initialize(map_id, event, map)
|
||||
rescue ArgumentError
|
||||
nf_particles_game_map_initialize(map_id, event)
|
||||
end
|
||||
end
|
||||
|
||||
alias nf_particles_game_map_refresh refresh unless method_defined?(:nf_particles_game_map_refresh)
|
||||
|
||||
def refresh
|
||||
nf_particles_game_map_refresh
|
||||
@pe_refresh = true
|
||||
end
|
||||
end
|
||||
@@ -1,519 +0,0 @@
|
||||
class PictureOrigin
|
||||
TopLeft = 0
|
||||
Center = 1
|
||||
TopRight = 2
|
||||
BottomLeft = 3
|
||||
LowerLeft = 3
|
||||
BottomRight = 4
|
||||
LowerRight = 4
|
||||
Top = 5
|
||||
Bottom = 6
|
||||
Left = 7
|
||||
Right = 8
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Processes
|
||||
XY = 0
|
||||
DeltaXY = 1
|
||||
Z = 2
|
||||
Curve = 3
|
||||
Zoom = 4
|
||||
Angle = 5
|
||||
Tone = 6
|
||||
Color = 7
|
||||
Hue = 8
|
||||
Opacity = 9
|
||||
Visible = 10
|
||||
BlendType = 11
|
||||
SE = 12
|
||||
Name = 13
|
||||
Origin = 14
|
||||
Src = 15
|
||||
SrcSize = 16
|
||||
CropBottom = 17
|
||||
end
|
||||
|
||||
|
||||
|
||||
def getCubicPoint2(src,t)
|
||||
x0 = src[0]; y0 = src[1]
|
||||
cx0 = src[2]; cy0 = src[3]
|
||||
cx1 = src[4]; cy1 = src[5]
|
||||
x1 = src[6]; y1 = src[7]
|
||||
|
||||
x1 = cx1+(x1-cx1)*t
|
||||
x0 = x0+(cx0-x0)*t
|
||||
cx0 = cx0+(cx1-cx0)*t
|
||||
cx1 = cx0+(x1-cx0)*t
|
||||
cx0 = x0+(cx0-x0)*t
|
||||
cx = cx0+(cx1-cx0)*t
|
||||
# a = x1 - 3 * cx1 + 3 * cx0 - x0
|
||||
# b = 3 * (cx1 - 2 * cx0 + x0)
|
||||
# c = 3 * (cx0 - x0)
|
||||
# d = x0
|
||||
# cx = a*t*t*t + b*t*t + c*t + d
|
||||
y1 = cy1+(y1-cy1)*t
|
||||
y0 = y0+(cy0-y0)*t
|
||||
cy0 = cy0+(cy1-cy0)*t
|
||||
cy1 = cy0+(y1-cy0)*t
|
||||
cy0 = y0+(cy0-y0)*t
|
||||
cy = cy0+(cy1-cy0)*t
|
||||
# a = y1 - 3 * cy1 + 3 * cy0 - y0
|
||||
# b = 3 * (cy1 - 2 * cy0 + y0)
|
||||
# c = 3 * (cy0 - y0)
|
||||
# d = y0
|
||||
# cy = a*t*t*t + b*t*t + c*t + d
|
||||
return [cx,cy]
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# PictureEx
|
||||
#===============================================================================
|
||||
class PictureEx
|
||||
attr_accessor :x # x-coordinate
|
||||
attr_accessor :y # y-coordinate
|
||||
attr_accessor :z # z value
|
||||
attr_accessor :zoom_x # x directional zoom rate
|
||||
attr_accessor :zoom_y # y directional zoom rate
|
||||
attr_accessor :angle # rotation angle
|
||||
attr_accessor :tone # tone
|
||||
attr_accessor :color # color
|
||||
attr_accessor :hue # filename hue
|
||||
attr_accessor :opacity # opacity level
|
||||
attr_accessor :visible # visibility boolean
|
||||
attr_accessor :blend_type # blend method
|
||||
attr_accessor :name # file name
|
||||
attr_accessor :origin # starting point
|
||||
attr_reader :src_rect # source rect
|
||||
attr_reader :cropBottom # crops sprite to above this y-coordinate
|
||||
attr_reader :frameUpdates # Array of processes updated in a frame
|
||||
|
||||
def initialize(z)
|
||||
# process: [type, delay, total_duration, frame_counter, cb, etc.]
|
||||
@processes = []
|
||||
@x = 0.0
|
||||
@y = 0.0
|
||||
@z = z
|
||||
@zoom_x = 100.0
|
||||
@zoom_y = 100.0
|
||||
@angle = 0
|
||||
@rotate_speed = 0
|
||||
@tone = Tone.new(0, 0, 0, 0)
|
||||
@tone_duration = 0
|
||||
@color = Color.new(0, 0, 0, 0)
|
||||
@hue = 0
|
||||
@opacity = 255.0
|
||||
@visible = true
|
||||
@blend_type = 0
|
||||
@name = ""
|
||||
@origin = PictureOrigin::TopLeft
|
||||
@src_rect = Rect.new(0,0,-1,-1)
|
||||
@cropBottom = -1
|
||||
@frameUpdates = []
|
||||
end
|
||||
|
||||
def callback(cb)
|
||||
if cb.is_a?(Proc); cb.call(self)
|
||||
elsif cb.is_a?(Array); cb[0].method(cb[1]).call(self)
|
||||
elsif cb.is_a?(Method); cb.call(self)
|
||||
end
|
||||
end
|
||||
|
||||
def setCallback(delay, cb=nil)
|
||||
delay = ensureDelayAndDuration(delay)
|
||||
@processes.push([nil,delay,0,0,cb])
|
||||
end
|
||||
|
||||
def running?
|
||||
return @processes.length>0
|
||||
end
|
||||
|
||||
def totalDuration
|
||||
ret = 0
|
||||
for process in @processes
|
||||
dur = process[1]+process[2]
|
||||
ret = dur if dur>ret
|
||||
end
|
||||
ret *= 20.0/Graphics.frame_rate
|
||||
return ret.to_i
|
||||
end
|
||||
|
||||
def ensureDelayAndDuration(delay, duration=nil)
|
||||
delay = self.totalDuration if delay<0
|
||||
delay *= Graphics.frame_rate/20.0
|
||||
if !duration.nil?
|
||||
duration *= Graphics.frame_rate/20.0
|
||||
return delay.to_i, duration.to_i
|
||||
end
|
||||
return delay.to_i
|
||||
end
|
||||
|
||||
def ensureDelay(delay)
|
||||
return ensureDelayAndDuration(delay)
|
||||
end
|
||||
|
||||
# speed is the angle to change by in 1/20 of a second. @rotate_speed is the
|
||||
# angle to change by per frame.
|
||||
# NOTE: This is not compatible with manually changing the angle at a certain
|
||||
# point. If you make a sprite auto-rotate, you should not try to alter
|
||||
# the angle another way too.
|
||||
def rotate(speed)
|
||||
@rotate_speed = speed*20.0/Graphics.frame_rate
|
||||
while @rotate_speed<0; @rotate_speed += 360; end
|
||||
@rotate_speed %= 360
|
||||
end
|
||||
|
||||
def erase
|
||||
self.name = ""
|
||||
end
|
||||
|
||||
def clearProcesses
|
||||
@processes = []
|
||||
end
|
||||
|
||||
def adjustPosition(xOffset, yOffset)
|
||||
for process in @processes
|
||||
next if process[0]!=Processes::XY
|
||||
process[5] += xOffset
|
||||
process[6] += yOffset
|
||||
process[7] += xOffset
|
||||
process[8] += yOffset
|
||||
end
|
||||
end
|
||||
|
||||
def move(delay, duration, origin, x, y, zoom_x=100.0, zoom_y=100.0, opacity=255)
|
||||
setOrigin(delay,duration,origin)
|
||||
moveXY(delay,duration,x,y)
|
||||
moveZoomXY(delay,duration,zoom_x,zoom_y)
|
||||
moveOpacity(delay,duration,opacity)
|
||||
end
|
||||
|
||||
def moveXY(delay, duration, x, y, cb=nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::XY,delay,duration,0,cb,@x,@y,x,y])
|
||||
end
|
||||
|
||||
def setXY(delay, x, y, cb=nil)
|
||||
moveXY(delay,0,x,y,cb)
|
||||
end
|
||||
|
||||
def moveCurve(delay, duration, x1, y1, x2, y2, x3, y3, cb=nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::Curve,delay,duration,0,cb,[@x,@y,x1,y1,x2,y2,x3,y3]])
|
||||
end
|
||||
|
||||
def moveDelta(delay, duration, x, y, cb=nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::DeltaXY,delay,duration,0,cb,@x,@y,x,y])
|
||||
end
|
||||
|
||||
def setDelta(delay, x, y, cb=nil)
|
||||
moveDelta(delay,0,x,y,cb)
|
||||
end
|
||||
|
||||
def moveZ(delay, duration, z, cb=nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::Z,delay,duration,0,cb,@z,z])
|
||||
end
|
||||
|
||||
def setZ(delay, z, cb=nil)
|
||||
moveZ(delay,0,z,cb)
|
||||
end
|
||||
|
||||
def moveZoomXY(delay, duration, zoom_x, zoom_y, cb=nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::Zoom,delay,duration,0,cb,@zoom_x,@zoom_y,zoom_x,zoom_y])
|
||||
end
|
||||
|
||||
def setZoomXY(delay, zoom_x, zoom_y, cb=nil)
|
||||
moveZoomXY(delay,0,zoom_x,zoom_y,cb)
|
||||
end
|
||||
|
||||
def moveZoom(delay, duration, zoom, cb=nil)
|
||||
moveZoomXY(delay,duration,zoom,zoom,cb)
|
||||
end
|
||||
|
||||
def setZoom(delay, zoom, cb=nil)
|
||||
moveZoomXY(delay,0,zoom,zoom,cb)
|
||||
end
|
||||
|
||||
def moveAngle(delay, duration, angle, cb=nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::Angle,delay,duration,0,cb,@angle,angle])
|
||||
end
|
||||
|
||||
def setAngle(delay, angle, cb=nil)
|
||||
moveAngle(delay,0,angle,cb)
|
||||
end
|
||||
|
||||
def moveTone(delay, duration, tone, cb=nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
target = (tone) ? tone.clone : Tone.new(0,0,0,0)
|
||||
@processes.push([Processes::Tone,delay,duration,0,cb,@tone.clone,target])
|
||||
end
|
||||
|
||||
def setTone(delay, tone, cb=nil)
|
||||
moveTone(delay,0,tone,cb)
|
||||
end
|
||||
|
||||
def moveColor(delay, duration, color, cb=nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
target = (color) ? color.clone : Color.new(0,0,0,0)
|
||||
@processes.push([Processes::Color,delay,duration,0,cb,@color.clone,target])
|
||||
end
|
||||
|
||||
def setColor(delay, color, cb=nil)
|
||||
moveColor(delay,0,color,cb)
|
||||
end
|
||||
|
||||
# Hue changes don't actually work.
|
||||
def moveHue(delay, duration, hue, cb=nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::Hue,delay,duration,0,cb,@hue,hue])
|
||||
end
|
||||
|
||||
# Hue changes don't actually work.
|
||||
def setHue(delay, hue, cb=nil)
|
||||
moveHue(delay,0,hue,cb)
|
||||
end
|
||||
|
||||
def moveOpacity(delay, duration, opacity, cb=nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::Opacity,delay,duration,0,cb,@opacity,opacity])
|
||||
end
|
||||
|
||||
def setOpacity(delay, opacity, cb=nil)
|
||||
moveOpacity(delay,0,opacity,cb)
|
||||
end
|
||||
|
||||
def setVisible(delay, visible, cb=nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::Visible,delay,0,0,cb,visible])
|
||||
end
|
||||
|
||||
# Only values of 0 (normal), 1 (additive) and 2 (subtractive) are allowed.
|
||||
def setBlendType(delay, blend, cb=nil)
|
||||
delay = ensureDelayAndDuration(delay)
|
||||
@processes.push([Processes::BlendType,delay,0,0,cb,blend])
|
||||
end
|
||||
|
||||
def setSE(delay, seFile, volume=nil, pitch=nil, cb=nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::SE,delay,0,0,cb,seFile,volume,pitch])
|
||||
end
|
||||
|
||||
def setName(delay, name, cb=nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::Name,delay,0,0,cb,name])
|
||||
end
|
||||
|
||||
def setOrigin(delay, origin, cb=nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::Origin,delay,0,0,cb,origin])
|
||||
end
|
||||
|
||||
def setSrc(delay, srcX, srcY, cb=nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::Src,delay,0,0,cb,srcX,srcY])
|
||||
end
|
||||
|
||||
def setSrcSize(delay, srcWidth, srcHeight, cb=nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::SrcSize,delay,0,0,cb,srcWidth,srcHeight])
|
||||
end
|
||||
|
||||
# Used to cut Pokémon sprites off when they faint and sink into the ground.
|
||||
def setCropBottom(delay, y, cb=nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::CropBottom,delay,0,0,cb,y])
|
||||
end
|
||||
|
||||
def update
|
||||
procEnded = false
|
||||
@frameUpdates.clear
|
||||
for i in 0...@processes.length
|
||||
process = @processes[i]
|
||||
# Decrease delay of processes that are scheduled to start later
|
||||
if process[1]>=0
|
||||
# Set initial values if the process will start this frame
|
||||
if process[1]==0
|
||||
case process[0]
|
||||
when Processes::XY
|
||||
process[5] = @x
|
||||
process[6] = @y
|
||||
when Processes::DeltaXY
|
||||
process[5] = @x
|
||||
process[6] = @y
|
||||
process[7] += @x
|
||||
process[8] += @y
|
||||
when Processes::Curve
|
||||
process[5][0] = @x
|
||||
process[5][1] = @y
|
||||
when Processes::Z
|
||||
process[5] = @z
|
||||
when Processes::Zoom
|
||||
process[5] = @zoom_x
|
||||
process[6] = @zoom_y
|
||||
when Processes::Angle
|
||||
process[5] = @angle
|
||||
when Processes::Tone
|
||||
process[5] = @tone.clone
|
||||
when Processes::Color
|
||||
process[5] = @color.clone
|
||||
when Processes::Hue
|
||||
process[5] = @hue
|
||||
when Processes::Opacity
|
||||
process[5] = @opacity
|
||||
end
|
||||
end
|
||||
# Decrease delay counter
|
||||
process[1] -= 1
|
||||
# Process hasn't started yet, skip to the next one
|
||||
next if process[1]>=0
|
||||
end
|
||||
# Update process
|
||||
@frameUpdates.push(process[0]) if !@frameUpdates.include?(process[0])
|
||||
fra = (process[2]==0) ? 1 : process[3] # Frame counter
|
||||
dur = (process[2]==0) ? 1 : process[2] # Total duration of process
|
||||
case process[0]
|
||||
when Processes::XY, Processes::DeltaXY
|
||||
@x = process[5] + fra * (process[7] - process[5]) / dur
|
||||
@y = process[6] + fra * (process[8] - process[6]) / dur
|
||||
when Processes::Curve
|
||||
@x, @y = getCubicPoint2(process[5],fra.to_f/dur)
|
||||
when Processes::Z
|
||||
@z = process[5] + fra * (process[6] - process[5]) / dur
|
||||
when Processes::Zoom
|
||||
@zoom_x = process[5] + fra * (process[7] - process[5]) / dur
|
||||
@zoom_y = process[6] + fra * (process[8] - process[6]) / dur
|
||||
when Processes::Angle
|
||||
@angle = process[5] + fra * (process[6] - process[5]) / dur
|
||||
when Processes::Tone
|
||||
@tone.red = process[5].red + fra * (process[6].red - process[5].red) / dur
|
||||
@tone.green = process[5].green + fra * (process[6].green - process[5].green) / dur
|
||||
@tone.blue = process[5].blue + fra * (process[6].blue - process[5].blue) / dur
|
||||
@tone.gray = process[5].gray + fra * (process[6].gray - process[5].gray) / dur
|
||||
when Processes::Color
|
||||
@color.red = process[5].red + fra * (process[6].red - process[5].red) / dur
|
||||
@color.green = process[5].green + fra * (process[6].green - process[5].green) / dur
|
||||
@color.blue = process[5].blue + fra * (process[6].blue - process[5].blue) / dur
|
||||
@color.alpha = process[5].alpha + fra * (process[6].alpha - process[5].alpha) / dur
|
||||
when Processes::Hue
|
||||
@hue = (process[6] - process[5]).to_f / dur
|
||||
when Processes::Opacity
|
||||
@opacity = process[5] + fra * (process[6] - process[5]) / dur
|
||||
when Processes::Visible
|
||||
@visible = process[5]
|
||||
when Processes::BlendType
|
||||
@blend_type = process[5]
|
||||
when Processes::SE
|
||||
pbSEPlay(process[5],process[6],process[7])
|
||||
when Processes::Name
|
||||
@name = process[5]
|
||||
when Processes::Origin
|
||||
@origin = process[5]
|
||||
when Processes::Src
|
||||
@src_rect.x = process[5]
|
||||
@src_rect.y = process[6]
|
||||
when Processes::SrcSize
|
||||
@src_rect.width = process[5]
|
||||
@src_rect.height = process[6]
|
||||
when Processes::CropBottom
|
||||
@cropBottom = process[5]
|
||||
end
|
||||
# Increase frame counter
|
||||
process[3] += 1
|
||||
if process[3]>process[2]
|
||||
# Process has ended, erase it
|
||||
callback(process[4]) if process[4]
|
||||
@processes[i] = nil
|
||||
procEnded = true
|
||||
end
|
||||
end
|
||||
# Clear out empty spaces in @processes array caused by finished processes
|
||||
@processes.compact! if procEnded
|
||||
# Add the constant rotation speed
|
||||
if @rotate_speed != 0
|
||||
@frameUpdates.push(Processes::Angle) if !@frameUpdates.include?(Processes::Angle)
|
||||
@angle += @rotate_speed
|
||||
while @angle<0; @angle += 360; end
|
||||
@angle %= 360
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def setPictureSprite(sprite, picture, iconSprite=false)
|
||||
return if picture.frameUpdates.length==0
|
||||
for i in 0...picture.frameUpdates.length
|
||||
case picture.frameUpdates[i]
|
||||
when Processes::XY, Processes::DeltaXY
|
||||
sprite.x = picture.x.round
|
||||
sprite.y = picture.y.round
|
||||
when Processes::Z
|
||||
sprite.z = picture.z
|
||||
when Processes::Zoom
|
||||
sprite.zoom_x = picture.zoom_x / 100.0
|
||||
sprite.zoom_y = picture.zoom_y / 100.0
|
||||
when Processes::Angle
|
||||
sprite.angle = picture.angle
|
||||
when Processes::Tone
|
||||
sprite.tone = picture.tone
|
||||
when Processes::Color
|
||||
sprite.color = picture.color
|
||||
when Processes::Hue
|
||||
# This doesn't do anything.
|
||||
when Processes::BlendType
|
||||
sprite.blend_type = picture.blend_type
|
||||
when Processes::Opacity
|
||||
sprite.opacity = picture.opacity
|
||||
when Processes::Visible
|
||||
sprite.visible = picture.visible
|
||||
when Processes::Name
|
||||
sprite.name = picture.name if iconSprite && sprite.name != picture.name
|
||||
when Processes::Origin
|
||||
case picture.origin
|
||||
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
|
||||
sprite.ox = 0
|
||||
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
|
||||
sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width/2 : 0
|
||||
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
|
||||
sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width : 0
|
||||
end
|
||||
case picture.origin
|
||||
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
|
||||
sprite.oy = 0
|
||||
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
|
||||
sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height/2 : 0
|
||||
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
|
||||
sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height : 0
|
||||
end
|
||||
when Processes::Src
|
||||
next unless iconSprite && sprite.src_rect
|
||||
sprite.src_rect.x = picture.src_rect.x
|
||||
sprite.src_rect.y = picture.src_rect.y
|
||||
when Processes::SrcSize
|
||||
next unless iconSprite && sprite.src_rect
|
||||
sprite.src_rect.width = picture.src_rect.width
|
||||
sprite.src_rect.height = picture.src_rect.height
|
||||
end
|
||||
end
|
||||
if iconSprite && sprite.src_rect && picture.cropBottom>=0
|
||||
spriteBottom = sprite.y-sprite.oy+sprite.src_rect.height
|
||||
if spriteBottom>picture.cropBottom
|
||||
sprite.src_rect.height = [picture.cropBottom-sprite.y+sprite.oy,0].max
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def setPictureIconSprite(sprite, picture)
|
||||
setPictureSprite(sprite,picture,true)
|
||||
end
|
||||
@@ -1,172 +0,0 @@
|
||||
class Interpolator
|
||||
ZOOM_X = 1
|
||||
ZOOM_Y = 2
|
||||
X = 3
|
||||
Y = 4
|
||||
OPACITY = 5
|
||||
COLOR = 6
|
||||
WAIT = 7
|
||||
|
||||
def initialize
|
||||
@tweening = false
|
||||
@tweensteps = []
|
||||
@sprite = nil
|
||||
@frames = 0
|
||||
@step = 0
|
||||
end
|
||||
|
||||
def tweening?
|
||||
return @tweening
|
||||
end
|
||||
|
||||
def tween(sprite,items,frames)
|
||||
@tweensteps = []
|
||||
if sprite && !sprite.disposed? && frames>0
|
||||
@frames = frames
|
||||
@step = 0
|
||||
@sprite = sprite
|
||||
for item in items
|
||||
case item[0]
|
||||
when ZOOM_X
|
||||
@tweensteps[item[0]] = [sprite.zoom_x,item[1]-sprite.zoom_x]
|
||||
when ZOOM_Y
|
||||
@tweensteps[item[0]] = [sprite.zoom_y,item[1]-sprite.zoom_y]
|
||||
when X
|
||||
@tweensteps[item[0]] = [sprite.x,item[1]-sprite.x]
|
||||
when Y
|
||||
@tweensteps[item[0]] = [sprite.y,item[1]-sprite.y]
|
||||
when OPACITY
|
||||
@tweensteps[item[0]] = [sprite.opacity,item[1]-sprite.opacity]
|
||||
when COLOR
|
||||
@tweensteps[item[0]] = [sprite.color.clone,Color.new(
|
||||
item[1].red-sprite.color.red,
|
||||
item[1].green-sprite.color.green,
|
||||
item[1].blue-sprite.color.blue,
|
||||
item[1].alpha-sprite.color.alpha
|
||||
)]
|
||||
end
|
||||
end
|
||||
@tweening = true
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @tweening
|
||||
t = (@step*1.0)/@frames
|
||||
for i in 0...@tweensteps.length
|
||||
item = @tweensteps[i]
|
||||
next if !item
|
||||
case i
|
||||
when ZOOM_X
|
||||
@sprite.zoom_x = item[0]+item[1]*t
|
||||
when ZOOM_Y
|
||||
@sprite.zoom_y = item[0]+item[1]*t
|
||||
when X
|
||||
@sprite.x = item[0]+item[1]*t
|
||||
when Y
|
||||
@sprite.y = item[0]+item[1]*t
|
||||
when OPACITY
|
||||
@sprite.opacity = item[0]+item[1]*t
|
||||
when COLOR
|
||||
@sprite.color = Color.new(
|
||||
item[0].red+item[1].red*t,
|
||||
item[0].green+item[1].green*t,
|
||||
item[0].blue+item[1].blue*t,
|
||||
item[0].alpha+item[1].alpha*t
|
||||
)
|
||||
end
|
||||
end
|
||||
@step += 1
|
||||
if @step==@frames
|
||||
@step = 0
|
||||
@frames = 0
|
||||
@tweening = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class RectInterpolator
|
||||
def initialize(oldrect,newrect,frames)
|
||||
restart(oldrect,newrect,frames)
|
||||
end
|
||||
|
||||
def restart(oldrect,newrect,frames)
|
||||
@oldrect = oldrect
|
||||
@newrect = newrect
|
||||
@frames = [frames,1].max
|
||||
@curframe = 0
|
||||
@rect = oldrect.clone
|
||||
end
|
||||
|
||||
def set(rect)
|
||||
rect.set(@rect.x,@rect.y,@rect.width,@rect.height)
|
||||
end
|
||||
|
||||
def done?
|
||||
@curframe>@frames
|
||||
end
|
||||
|
||||
def update
|
||||
return if done?
|
||||
t = (@curframe*1.0/@frames)
|
||||
x1 = @oldrect.x
|
||||
x2 = @newrect.x
|
||||
x = x1+t*(x2-x1)
|
||||
y1 = @oldrect.y
|
||||
y2 = @newrect.y
|
||||
y = y1+t*(y2-y1)
|
||||
rx1 = @oldrect.x+@oldrect.width
|
||||
rx2 = @newrect.x+@newrect.width
|
||||
rx = rx1+t*(rx2-rx1)
|
||||
ry1 = @oldrect.y+@oldrect.height
|
||||
ry2 = @newrect.y+@newrect.height
|
||||
ry = ry1+t*(ry2-ry1)
|
||||
minx = x<rx ? x : rx
|
||||
maxx = x>rx ? x : rx
|
||||
miny = y<ry ? y : ry
|
||||
maxy = y>ry ? y : ry
|
||||
@rect.set(minx,miny,maxx-minx,maxy-miny)
|
||||
@curframe += 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class PointInterpolator
|
||||
attr_reader :x
|
||||
attr_reader :y
|
||||
|
||||
def initialize(oldx,oldy,newx,newy,frames)
|
||||
restart(oldx,oldy,newx,newy,frames)
|
||||
end
|
||||
|
||||
def restart(oldx,oldy,newx,newy,frames)
|
||||
@oldx = oldx
|
||||
@oldy = oldy
|
||||
@newx = newx
|
||||
@newy = newy
|
||||
@frames = frames
|
||||
@curframe = 0
|
||||
@x = oldx
|
||||
@y = oldy
|
||||
end
|
||||
|
||||
def done?
|
||||
@curframe>@frames
|
||||
end
|
||||
|
||||
def update
|
||||
return if done?
|
||||
t = (@curframe*1.0/@frames)
|
||||
rx1 = @oldx
|
||||
rx2 = @newx
|
||||
@x = rx1+t*(rx2-rx1)
|
||||
ry1 = @oldy
|
||||
ry2 = @newy
|
||||
@y = ry1+t*(ry2-ry1)
|
||||
@curframe += 1
|
||||
end
|
||||
end
|
||||
@@ -1,43 +0,0 @@
|
||||
module ScreenPosHelper
|
||||
def self.pbScreenZoomX(ch)
|
||||
return Game_Map::TILE_WIDTH/32.0
|
||||
end
|
||||
|
||||
def self.pbScreenZoomY(ch)
|
||||
return Game_Map::TILE_HEIGHT/32.0
|
||||
end
|
||||
|
||||
def self.pbScreenX(ch)
|
||||
return ch.screen_x
|
||||
end
|
||||
|
||||
def self.pbScreenY(ch)
|
||||
return ch.screen_y
|
||||
end
|
||||
|
||||
@heightcache={}
|
||||
|
||||
def self.bmHeight(bm)
|
||||
h=@heightcache[bm]
|
||||
if !h
|
||||
bmap=AnimatedBitmap.new("Graphics/Characters/"+bm,0)
|
||||
h=bmap.height
|
||||
@heightcache[bm]=h
|
||||
bmap.dispose
|
||||
end
|
||||
return h
|
||||
end
|
||||
|
||||
def self.pbScreenZ(ch,height=nil)
|
||||
if height==nil
|
||||
height=0
|
||||
if ch.tile_id > 0
|
||||
height=32
|
||||
elsif ch.character_name!=""
|
||||
height=bmHeight(ch.character_name)/4
|
||||
end
|
||||
end
|
||||
ret=ch.screen_z(height)
|
||||
return ret
|
||||
end
|
||||
end
|
||||
@@ -1,35 +0,0 @@
|
||||
|
||||
#[FRAME1 [x,y]],[FRAME2 [x,y], etc.]
|
||||
#
|
||||
# exact number of pixels that the sprite needs to be moved for each frame
|
||||
# add 2 pixels on even frames
|
||||
module Outfit_Offsets
|
||||
BASE_OFFSET = [[0, 0], [0, 0], [0, 0], [0, 0]]
|
||||
|
||||
|
||||
RUN_OFFSETS_DOWN = [[0, 2], [0, 6], [0, 2], [0, 6]]
|
||||
RUN_OFFSETS_LEFT = [[-2, -2], [-2, -2], [-2, -2], [-2, -2]]
|
||||
RUN_OFFSETS_RIGHT = [[2, -2], [2, -2], [2, -2], [2, -2]]
|
||||
RUN_OFFSETS_UP = [[0, -2], [0, -2], [0, -2], [0, -2]]
|
||||
|
||||
SURF_OFFSETS_DOWN = [[0, -6], [0, -4], [0, -6], [0, -4]]
|
||||
SURF_OFFSETS_LEFT = [[-2, -10], [-2, -8], [-2, -10], [-2, -8]]
|
||||
SURF_OFFSETS_RIGHT = [[4, -10], [4, -8], [4, -10], [4, -8]]
|
||||
#SURF_OFFSETS_UP = [[0, -6], [0, -4], [0, -6], [0, -4]]
|
||||
SURF_OFFSETS_UP = [[0, -10], [0, -8], [0, -10], [0, -8]]
|
||||
|
||||
DIVE_OFFSETS_DOWN = [[0, -6], [0, -4], [0, -6], [0, -4]]
|
||||
DIVE_OFFSETS_LEFT = [[6, -8], [6, -6], [6, -8], [6, -6]]
|
||||
DIVE_OFFSETS_RIGHT = [[-6, -8], [-6, -6], [-6, -8], [-6, -6]]
|
||||
DIVE_OFFSETS_UP = [[0, -2], [0, 0], [0, -2], [0, 0]]
|
||||
|
||||
BIKE_OFFSETS_DOWN = [[0, -2], [2, 0], [0, -2], [-2, 0]]
|
||||
BIKE_OFFSETS_LEFT = [[-4, -4], [-2, -2], [-4, -4], [-6, -2]]
|
||||
BIKE_OFFSETS_RIGHT = [[4, -4], [2, -2], [4, -4], [6, -2]]
|
||||
BIKE_OFFSETS_UP = [[0, -2], [-2, 0], [0, -2], [2, 0]]
|
||||
|
||||
FISH_OFFSETS_DOWN = [[0, -6], [0, -2], [0, -8], [2, -6]]
|
||||
FISH_OFFSETS_LEFT = [[0, -8], [-6, -6], [0, -8], [2, -8]]
|
||||
FISH_OFFSETS_RIGHT = [[0, -8], [6, -6], [0, -8], [-2, -8]]
|
||||
FISH_OFFSETS_UP = [[0, -6], [0, -6], [0, -6], [2, -4]]
|
||||
end
|
||||
@@ -1,170 +0,0 @@
|
||||
class Sprite_Wearable < RPG::Sprite
|
||||
attr_accessor :filename
|
||||
attr_accessor :action
|
||||
attr_accessor :sprite
|
||||
|
||||
def initialize(player_sprite, filename, action, viewport, relative_z=0)
|
||||
@player_sprite = player_sprite
|
||||
@viewport = viewport
|
||||
@sprite = Sprite.new(@viewport)
|
||||
@wearableBitmap = AnimatedBitmap.new(filename) if pbResolveBitmap(filename)
|
||||
@filename = filename
|
||||
@sprite.bitmap = @wearableBitmap.bitmap if @wearableBitmap
|
||||
@action = action
|
||||
@color = 0
|
||||
@frameWidth = 80 #@sprite.width
|
||||
@frameHeight = 80 #@sprite.height / 4
|
||||
@sprite.z = 0
|
||||
@relative_z=relative_z #relative to player
|
||||
echoln(_INTL("init had at z = {1}, player sprite at {2}",@sprite.z,@player_sprite.z))
|
||||
|
||||
#Unused position offset
|
||||
# @x_pos_base_offset = 0
|
||||
# @y_pos_base_offset = 0
|
||||
end
|
||||
|
||||
def apply_sprite_offset(offsets_array, current_frame)
|
||||
@sprite.x += offsets_array[current_frame][0]
|
||||
@sprite.y += offsets_array[current_frame][1]
|
||||
end
|
||||
|
||||
def adjustPositionForScreenScrolling
|
||||
return if !$game_map.scrolling? && !@was_just_scrolling
|
||||
if $game_map.scrolling?
|
||||
@was_just_scrolling=true
|
||||
else
|
||||
@was_just_scrolling=false
|
||||
end
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
case $game_map.scroll_direction
|
||||
when DIRECTION_RIGHT
|
||||
offset_x=-8
|
||||
when DIRECTION_LEFT
|
||||
offset_x=8
|
||||
when DIRECTION_UP
|
||||
offset_y=8
|
||||
@sprite.z+=50 #weird layering glitch for some reason otherwise. It's reset to the correct value in the next animation frame
|
||||
when DIRECTION_DOWN
|
||||
offset_y=-8
|
||||
end
|
||||
@sprite.x+=offset_x
|
||||
@sprite.y+=offset_y
|
||||
end
|
||||
|
||||
|
||||
def set_sprite_position(action, direction, current_frame)
|
||||
@sprite.x = @player_sprite.x - @player_sprite.ox
|
||||
@sprite.y = @player_sprite.y - @player_sprite.oy
|
||||
case action
|
||||
when "run"
|
||||
if direction == DIRECTION_DOWN
|
||||
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_DOWN, current_frame)
|
||||
elsif direction == DIRECTION_LEFT
|
||||
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_LEFT, current_frame)
|
||||
elsif direction == DIRECTION_RIGHT
|
||||
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_RIGHT, current_frame)
|
||||
elsif direction == DIRECTION_UP
|
||||
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_UP, current_frame)
|
||||
end
|
||||
when "surf"
|
||||
if direction == DIRECTION_DOWN
|
||||
apply_sprite_offset(Outfit_Offsets::SURF_OFFSETS_DOWN,current_frame)
|
||||
elsif direction == DIRECTION_LEFT
|
||||
apply_sprite_offset( Outfit_Offsets::SURF_OFFSETS_LEFT,current_frame)
|
||||
elsif direction == DIRECTION_RIGHT
|
||||
apply_sprite_offset( Outfit_Offsets::SURF_OFFSETS_RIGHT,current_frame)
|
||||
elsif direction == DIRECTION_UP
|
||||
apply_sprite_offset( Outfit_Offsets::SURF_OFFSETS_UP,current_frame)
|
||||
end
|
||||
when "dive"
|
||||
if direction == DIRECTION_DOWN
|
||||
apply_sprite_offset(Outfit_Offsets::DIVE_OFFSETS_DOWN,current_frame)
|
||||
elsif direction == DIRECTION_LEFT
|
||||
apply_sprite_offset( Outfit_Offsets::DIVE_OFFSETS_LEFT,current_frame)
|
||||
elsif direction == DIRECTION_RIGHT
|
||||
apply_sprite_offset( Outfit_Offsets::DIVE_OFFSETS_RIGHT,current_frame)
|
||||
elsif direction == DIRECTION_UP
|
||||
apply_sprite_offset( Outfit_Offsets::DIVE_OFFSETS_UP,current_frame)
|
||||
end
|
||||
when "bike"
|
||||
if direction == DIRECTION_DOWN
|
||||
apply_sprite_offset(Outfit_Offsets::BIKE_OFFSETS_DOWN,current_frame)
|
||||
elsif direction == DIRECTION_LEFT
|
||||
apply_sprite_offset( Outfit_Offsets::BIKE_OFFSETS_LEFT,current_frame)
|
||||
elsif direction == DIRECTION_RIGHT
|
||||
apply_sprite_offset( Outfit_Offsets::BIKE_OFFSETS_RIGHT,current_frame)
|
||||
elsif direction == DIRECTION_UP
|
||||
apply_sprite_offset( Outfit_Offsets::BIKE_OFFSETS_UP,current_frame)
|
||||
end
|
||||
when "fish"
|
||||
if direction == DIRECTION_DOWN
|
||||
apply_sprite_offset(Outfit_Offsets::FISH_OFFSETS_DOWN,current_frame)
|
||||
elsif direction == DIRECTION_LEFT
|
||||
apply_sprite_offset( Outfit_Offsets::FISH_OFFSETS_LEFT,current_frame)
|
||||
elsif direction == DIRECTION_RIGHT
|
||||
apply_sprite_offset( Outfit_Offsets::FISH_OFFSETS_RIGHT,current_frame)
|
||||
elsif direction == DIRECTION_UP
|
||||
apply_sprite_offset( Outfit_Offsets::FISH_OFFSETS_UP,current_frame)
|
||||
end
|
||||
else
|
||||
@sprite.x = @player_sprite.x - @player_sprite.ox
|
||||
@sprite.y = @player_sprite.y - @player_sprite.oy
|
||||
end
|
||||
adjustPositionForScreenScrolling()
|
||||
|
||||
@sprite.y -= 2 if current_frame % 2 == 1
|
||||
end
|
||||
|
||||
|
||||
def animate(action, frame=nil)
|
||||
@action = action
|
||||
current_frame = @player_sprite.character.pattern if !frame
|
||||
direction = @player_sprite.character.direction
|
||||
crop_spritesheet(direction)
|
||||
adjust_layer()
|
||||
set_sprite_position(@action, direction, current_frame)
|
||||
end
|
||||
|
||||
def update(action, filename,color)
|
||||
@sprite.opacity = @player_sprite.opacity if @wearableBitmap
|
||||
if filename != @filename || color != @color
|
||||
if pbResolveBitmap(filename)
|
||||
#echoln pbResolveBitmap(filename)
|
||||
@wearableBitmap = AnimatedBitmap.new(filename,color)
|
||||
@sprite.bitmap = @wearableBitmap.bitmap
|
||||
else
|
||||
@wearableBitmap = nil
|
||||
@sprite.bitmap = nil
|
||||
end
|
||||
@color =color
|
||||
@filename = filename
|
||||
end
|
||||
animate(action)
|
||||
end
|
||||
|
||||
def adjust_layer()
|
||||
if @sprite.z != @player_sprite.z+@relative_z
|
||||
@sprite.z = @player_sprite.z+@relative_z
|
||||
end
|
||||
end
|
||||
|
||||
def crop_spritesheet(direction)
|
||||
sprite_x = 0
|
||||
sprite_y = ((direction - 2) / 2) * @frameHeight
|
||||
@sprite.src_rect.set(sprite_x, sprite_y, @frameWidth, @frameHeight)
|
||||
end
|
||||
|
||||
def dispose
|
||||
return if @disposed
|
||||
@sprite.dispose if @sprite
|
||||
@sprite = nil
|
||||
@disposed = true
|
||||
end
|
||||
|
||||
def disposed?
|
||||
@disposed
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -1,85 +0,0 @@
|
||||
class Sprite_Hair < Sprite_Wearable
|
||||
def initialize(player_sprite, filename, action, viewport)
|
||||
super
|
||||
@relative_z = 1
|
||||
|
||||
#@sprite.z = @player_sprite.z + 1
|
||||
end
|
||||
|
||||
def animate(action, frame = nil)
|
||||
@action = action
|
||||
current_frame = @player_sprite.character.pattern if !frame
|
||||
direction = @player_sprite.character.direction
|
||||
crop_spritesheet(direction, current_frame, action)
|
||||
adjust_layer()
|
||||
set_sprite_position(@action, direction, current_frame)
|
||||
end
|
||||
|
||||
def crop_spritesheet(direction, current_frame, action)
|
||||
sprite_x = ((current_frame)) * @frameWidth
|
||||
# Don't animate surf
|
||||
sprite_x = 0 if action == "surf"
|
||||
|
||||
sprite_y = ((direction - 2) / 2) * @frameHeight
|
||||
@sprite.src_rect.set(sprite_x, sprite_y, @frameWidth, @frameHeight)
|
||||
end
|
||||
|
||||
def set_sprite_position(action, direction, current_frame)
|
||||
@sprite.x = @player_sprite.x - @player_sprite.ox
|
||||
@sprite.y = @player_sprite.y - @player_sprite.oy
|
||||
case action
|
||||
when "run"
|
||||
if direction == DIRECTION_DOWN
|
||||
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_DOWN, current_frame)
|
||||
elsif direction == DIRECTION_LEFT
|
||||
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_LEFT, current_frame)
|
||||
elsif direction == DIRECTION_RIGHT
|
||||
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_RIGHT, current_frame)
|
||||
elsif direction == DIRECTION_UP
|
||||
apply_sprite_offset(Outfit_Offsets::RUN_OFFSETS_UP, current_frame)
|
||||
end
|
||||
when "surf"
|
||||
if direction == DIRECTION_DOWN # Always animate as if on the first frame
|
||||
apply_sprite_offset(Outfit_Offsets::SURF_OFFSETS_DOWN, 0)
|
||||
elsif direction == DIRECTION_LEFT
|
||||
apply_sprite_offset(Outfit_Offsets::SURF_OFFSETS_LEFT, 0)
|
||||
elsif direction == DIRECTION_RIGHT
|
||||
apply_sprite_offset(Outfit_Offsets::SURF_OFFSETS_RIGHT, 0)
|
||||
elsif direction == DIRECTION_UP
|
||||
apply_sprite_offset(Outfit_Offsets::SURF_OFFSETS_UP, 0)
|
||||
end
|
||||
when "dive"
|
||||
if direction == DIRECTION_DOWN
|
||||
apply_sprite_offset(Outfit_Offsets::DIVE_OFFSETS_DOWN, current_frame)
|
||||
elsif direction == DIRECTION_LEFT
|
||||
apply_sprite_offset(Outfit_Offsets::DIVE_OFFSETS_LEFT, current_frame)
|
||||
elsif direction == DIRECTION_RIGHT
|
||||
apply_sprite_offset(Outfit_Offsets::DIVE_OFFSETS_RIGHT, current_frame)
|
||||
elsif direction == DIRECTION_UP
|
||||
apply_sprite_offset(Outfit_Offsets::DIVE_OFFSETS_UP, current_frame)
|
||||
end
|
||||
when "bike"
|
||||
if direction == DIRECTION_DOWN
|
||||
apply_sprite_offset(Outfit_Offsets::BIKE_OFFSETS_DOWN, current_frame)
|
||||
elsif direction == DIRECTION_LEFT
|
||||
apply_sprite_offset(Outfit_Offsets::BIKE_OFFSETS_LEFT, current_frame)
|
||||
elsif direction == DIRECTION_RIGHT
|
||||
apply_sprite_offset(Outfit_Offsets::BIKE_OFFSETS_RIGHT, current_frame)
|
||||
elsif direction == DIRECTION_UP
|
||||
apply_sprite_offset(Outfit_Offsets::BIKE_OFFSETS_UP, current_frame)
|
||||
end
|
||||
when "fish"
|
||||
if direction == DIRECTION_DOWN
|
||||
apply_sprite_offset(Outfit_Offsets::FISH_OFFSETS_DOWN, current_frame)
|
||||
elsif direction == DIRECTION_LEFT
|
||||
apply_sprite_offset(Outfit_Offsets::FISH_OFFSETS_LEFT, current_frame)
|
||||
elsif direction == DIRECTION_RIGHT
|
||||
apply_sprite_offset(Outfit_Offsets::FISH_OFFSETS_RIGHT, current_frame)
|
||||
elsif direction == DIRECTION_UP
|
||||
apply_sprite_offset(Outfit_Offsets::FISH_OFFSETS_UP, current_frame)
|
||||
end
|
||||
end
|
||||
adjustPositionForScreenScrolling()
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,8 +0,0 @@
|
||||
class Sprite_Hat < Sprite_Wearable
|
||||
def initialize(player_sprite, filename, action, viewport, relative_z=2)
|
||||
super
|
||||
@relative_z = relative_z
|
||||
#@sprite.z = @player_sprite.z + 2
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,116 +0,0 @@
|
||||
class Sprite_Player < Sprite_Character
|
||||
def initialize(viewport, character = nil)
|
||||
super
|
||||
@viewport = viewport
|
||||
@outfit_bitmap = nil
|
||||
# @hat_bitmap = nil
|
||||
# @hat2_bitmap = nil
|
||||
|
||||
hatFilename = ""
|
||||
hairFilename = ""
|
||||
@hat = Sprite_Hat.new(self, hatFilename, @character_name, @viewport,3)
|
||||
@hat2 = Sprite_Hat.new(self, hatFilename, @character_name, @viewport,2)
|
||||
@hair = Sprite_Hair.new(self, hairFilename, @character_name, @viewport)
|
||||
|
||||
@previous_skinTone = 0
|
||||
|
||||
@current_bitmap = nil
|
||||
@previous_action =nil
|
||||
echoln "init playa"
|
||||
getClothedPlayerSprite(true)
|
||||
end
|
||||
|
||||
|
||||
def updateCharacterBitmap
|
||||
skinTone = $Trainer.skin_tone ? $Trainer.skin_tone : 0
|
||||
baseBitmapFilename = getBaseOverworldSpriteFilename(@character_name, skinTone)
|
||||
if !pbResolveBitmap(baseBitmapFilename)
|
||||
baseBitmapFilename = Settings::PLAYER_GRAPHICS_FOLDER + @character_name
|
||||
end
|
||||
AnimatedBitmap.new(baseBitmapFilename, @character_hue)
|
||||
end
|
||||
|
||||
def applyDayNightTone
|
||||
super
|
||||
pbDayNightTint(@hat.sprite) if @hat && @hat.sprite.bitmap
|
||||
pbDayNightTint(@hat2.sprite) if @hat2 && @hat2.sprite.bitmap
|
||||
pbDayNightTint(@hair.sprite) if @hair && @hair.sprite.bitmap
|
||||
end
|
||||
|
||||
def opacity=(value)
|
||||
super
|
||||
@hat.sprite.opacity= value if @hat && @hat.sprite.bitmap
|
||||
@hat2.sprite.opacity= value if @hat2 && @hat2.sprite.bitmap
|
||||
@hair.sprite.opacity= value if @hair && @hair.sprite.bitmap
|
||||
end
|
||||
|
||||
def getClothedPlayerSprite(forceUpdate=false)
|
||||
if @previous_action != @character_name || forceUpdate
|
||||
@current_bitmap = generateClothedBitmap
|
||||
end
|
||||
@previous_action = @character_name
|
||||
@hair.animate(@character_name) if @hair
|
||||
@hat.animate(@character_name) if @hat
|
||||
@hat2.animate(@character_name) if @hat2
|
||||
return @current_bitmap
|
||||
end
|
||||
|
||||
|
||||
def generateClothedBitmap()
|
||||
@charbitmap.bitmap.clone #nekkid sprite
|
||||
baseBitmap = @charbitmap.bitmap.clone #nekkid sprite
|
||||
|
||||
outfitFilename = getOverworldOutfitFilename($Trainer.clothes, @character_name) #
|
||||
outfitFilename = getOverworldOutfitFilename(Settings::PLAYER_TEMP_OUTFIT_FALLBACK) if !pbResolveBitmap(outfitFilename)
|
||||
hairFilename = getOverworldHairFilename($Trainer.hair)
|
||||
hatFilename = getOverworldHatFilename($Trainer.hat)
|
||||
hat2Filename = getOverworldHatFilename($Trainer.hat2)
|
||||
|
||||
hair_color_shift = $Trainer.hair_color
|
||||
hat_color_shift = $Trainer.hat_color
|
||||
hat2_color_shift = $Trainer.hat2_color
|
||||
|
||||
clothes_color_shift = $Trainer.clothes_color
|
||||
|
||||
hair_color_shift = 0 if !hair_color_shift
|
||||
hat_color_shift = 0 if !hat_color_shift
|
||||
hat2_color_shift = 0 if !hat2_color_shift
|
||||
|
||||
clothes_color_shift = 0 if !clothes_color_shift
|
||||
@hair.update(@character_name, hairFilename, hair_color_shift) if @hair
|
||||
@hat.update(@character_name, hatFilename, hat_color_shift) if @hat
|
||||
@hat2.update(@character_name, hat2Filename, hat2_color_shift) if @hat2
|
||||
|
||||
if !pbResolveBitmap(outfitFilename)
|
||||
raise "No temp clothes graphics available"
|
||||
end
|
||||
|
||||
outfitBitmap = AnimatedBitmap.new(outfitFilename, clothes_color_shift) if pbResolveBitmap(outfitFilename)
|
||||
baseBitmap.blt(0, 0, outfitBitmap.bitmap, outfitBitmap.bitmap.rect) if outfitBitmap
|
||||
@previous_action = @character_name
|
||||
return baseBitmap
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
def update
|
||||
super
|
||||
end
|
||||
|
||||
def dispose
|
||||
super
|
||||
@hat.dispose if @hat
|
||||
@hat2.dispose if @hat2
|
||||
@hair.dispose if @hair
|
||||
end
|
||||
|
||||
def pbLoadOutfitBitmap(outfitFileName)
|
||||
begin
|
||||
outfitBitmap = RPG::Cache.load_bitmap("", outfitFileName)
|
||||
return outfitBitmap
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user