Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- class Game_Vehicle < Game_Character
- #----------------------------------------------------------------------------
- # ============================== CONFIGURATION ==============================
- MAX_PLAYER_TO_SHOW_IN_VEHICLE = 2 # máximos minichars dibujados de tu party
- MINI_PLAYER_IN_BOAT = true # Muestra minichars sobre botes
- MINI_PLAYER_IN_AIRSHIP = true # Muestra minichars en aviones
- MINI_PLAYER_IN_SHIP = true # Muestra minichars en barcos
- MOVEMENT_IN_BOAT = true # Anima minichars en botes
- MOVEMENT_IN_SHIP = true # Anima minichars en barcos
- MOVEMENT_IN_AIRSHIP = true # Anima minichars en Aviones
- # Animaciones para los diferentes vehículos
- BOAT_MINICHARS_ANIMATION = [0,1,1,0,0,0,-1,-1,-1,0,0,0,1]
- SHIP_MINICHARS_ANIMATION = [0,1,1,0,0,0,-1,-1,-1,0,0,0,1]
- AIRSHIP_MINICHARS_ANIMATION = [0,1,1,0,0,0,-1,-1,-1,0,0,0,1]
- # ============================ END CONFIGURATION ============================
- #----------------------------------------------------------------------------
- alias refresh_newold refresh unless $@
- #----------------------------------------------------------------------------
- def refresh
- refresh_newold
- unless @driving
- dispose_mini_actors
- end
- end
- #----------------------------------------------------------------------------
- alias get_off_newold get_off unless $@
- #----------------------------------------------------------------------------
- def get_off
- dispose_mini_actors
- get_off_newold
- end
- #----------------------------------------------------------------------------
- alias get_on_newold get_on unless $@
- #----------------------------------------------------------------------------
- def get_on
- get_on_newold
- if @type == :airship
- @initial_up = [32,30,28,26,24,22,20,18,16,14,12,10,8,4,2]
- end
- if @movement_mini_actors.nil?
- if @type == :boat
- @movement_mini_actors = [0,BOAT_MINICHARS_ANIMATION]
- elsif @type == :airship
- @movement_mini_actors = [0,AIRSHIP_MINICHARS_ANIMATION]
- else
- @movement_mini_actors = [0,SHIP_MINICHARS_ANIMATION]
- end
- end
- @movement_mini_actors[0] = 0
- end
- #----------------------------------------------------------------------------
- def dispose_mini_actors
- unless @mini_actors.nil?
- @mini_actors.each {|sprite| sprite.bitmap.dispose; sprite.dispose}
- @mini_actors = nil
- end
- end
- #----------------------------------------------------------------------------
- alias new_update_newold update unless $@
- #----------------------------------------------------------------------------
- def update
- new_update_newold
- if @driving and ((@type == :boat and MINI_PLAYER_IN_BOAT) or
- (@type == :airship and MINI_PLAYER_IN_AIRSHIP) or
- (@type == :ship and MINI_PLAYER_IN_SHIP))
- refresh_players_in_vehicle
- end
- end
- #----------------------------------------------------------------------------
- def refresh_players_in_vehicle
- return unless SceneManager.scene.is_a?(Scene_Map)
- dispose_mini_actors
- actors = []
- x = y = 0
- mod = 20/MAX_PLAYER_TO_SHOW_IN_VEHICLE
- if @type == :boat
- modX = modY = 0
- elsif @type == :airship
- modX = 0; modY = -42
- else
- modX = 0; modY = 6
- end
- if not @initial_up.nil? and Graphics.frame_count % 2 != 0
- modY += @initial_up.shift
- @initial_up = nil if @initial_up.size == 0
- elsif not @initial_up.nil?
- modY += @initial_up[0]
- end
- for i in 0...MAX_PLAYER_TO_SHOW_IN_VEHICLE
- actor = $game_party.members[i]
- next if actor.nil?
- s = Sprite.new(Viewport.new)
- s.x = (@real_x-$game_map.display_x)*32 + x + modX
- s.y = (@real_y-$game_map.display_y)*32 + y + modY
- s.bush_depth = 2; s.bush_opacity = 160
- case @direction
- when 2; y -= mod;
- if @type == :boat or @type == :airship
- s.ox = -8; s.oy = -5;
- else
- s.ox = -8; s.oy = 0;
- end
- when 4; s.ox = -4; s.oy = 0; x += mod;
- when 6; s.ox = -12; s.oy = 0; x -= mod;
- when 8; y += mod;
- if @type == :boat or @type == :airship
- s.ox = -8; s.oy = 3;
- else
- s.ox = -8; s.oy = 10;
- end
- end
- if [2,8].include?(@direction)
- s.y += @movement_mini_actors[1][@movement_mini_actors[0]]
- else
- s.x += @movement_mini_actors[1][@movement_mini_actors[0]]
- end
- s.z = 1000
- s.bitmap = get_actor_bitmap(actor)
- actors << s
- end
- if actors.size > 0
- @mini_actors = actors
- end
- if (Graphics.frame_count % 3 == 0 and @type == :boat and MOVEMENT_IN_BOAT) or
- (Graphics.frame_count % 12 == 0 and @type == :ship and MOVEMENT_IN_SHIP) or
- (Graphics.frame_count % 8 == 0 and @type == :airship and MOVEMENT_IN_AIRSHIP)
- @movement_mini_actors[0] += 1
- @movement_mini_actors[0] = 1 if @movement_mini_actors[0] >=
- @movement_mini_actors[1].size
- end
- end
- #----------------------------------------------------------------------------
- def get_actor_bitmap(actor)
- character_name = actor.character_name
- index = actor.character_index
- bitmap = Cache.character(character_name)
- sign = character_name[/^[\!\$]./]
- if sign && sign.include?('$')
- cw = bitmap.width / 3
- ch = bitmap.height / 4
- else
- cw = bitmap.width / 12
- ch = bitmap.height / 8
- end
- dest = Bitmap.new(16,16)
- pattern = 1#actor.pattern < 3 ? actor.pattern : 1
- sx = (index % 4 * 3 + pattern) * cw
- sy = (index / 4 * 4 + (@direction - 2) / 2) * ch
- dest.stretch_blt(dest.rect,bitmap,Rect.new(sx, sy, cw, ch))
- dest
- end
- #----------------------------------------------------------------------------
- end
- #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement