Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=============================================================================
- # Change the Leader in Map - By Ramiro
- #=============================================================================
- #
- # Instructions:
- # To know who is the leader call this: $game_party.leader
- #
- # Change PARTY_CHANGE_ACTIVE to the switch id than turns ON/OFF the party switcher
- #=============================================================================
- module Party_Change
- PARTY_CHANGE_ACTIVE = 1
- end
- class Game_Player < Game_Character
- attr_reader :selected_index
- alias ch_initialize initialize
- def intialize
- @selected_index = 0
- ch_initialize
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- if $game_party.members.size == 0
- @character_name = ""
- @character_index = 0
- else
- @selected_index = 0 unless @selected_index
- actor = $game_party.members[@selected_index] # Get front actor
- @character_name = actor.character_name
- @character_index = actor.character_index
- end
- end
- def shift_left
- @selected_index -= 1
- @selected_index %= $game_party.members.size
- refresh
- end
- def shift_right
- @selected_index += 1
- @selected_index %= $game_party.members.size
- refresh
- end
- def reset_characters
- @selected_index = 0
- refresh
- end
- end
- class Game_Party < Game_Unit
- alias game_party_remove_actor remove_actor
- def remove_actor(id)
- game_party_remove_actor(id)
- $game_player.reset_characters
- end
- def leader
- return members[$game_player.selected_index]
- end
- end
- class Scene_Map < Scene_Base
- include Party_Change
- alias scene_map_start start
- alias scene_map_terminate terminate
- alias scene_map_update update
- def start
- scene_map_start
- @party_window = Window_HeroActive.new
- @party_window.visible = $game_switches[PARTY_CHANGE_ACTIVE]
- end
- def terminate
- scene_map_terminate
- @party_window.dispose
- end
- def update
- scene_map_update
- @party_window.update
- @party_window.visible = $game_switches[PARTY_CHANGE_ACTIVE]
- return if !$game_switches[PARTY_CHANGE_ACTIVE]
- if Input.trigger?(Input::L)
- @party_window.change_index(-1)
- $game_player.shift_left
- elsif Input.trigger?(Input::R)
- @party_window.change_index(1)
- $game_player.shift_right
- end
- end
- end
- class Window_HeroActive
- def initialize
- @index = $game_player.selected_index
- @viewport = Viewport.new(0,0,108,36)
- @viewport.z = 9999
- @hud = Sprite.new(@viewport)
- @hud.bitmap = Cache.picture("character change.png")
- @hud.z = 9999
- @ox = (@index - 1) * 36 - 2
- refresh
- end
- def update
- if @ox > (@index - 1) * 36 - 2
- @ox -= 2
- elsif @ox < (@index - 1) * 36 - 2
- @ox += 2
- end
- @plane.ox = @ox
- end
- def refresh
- create_battler_frame
- end
- def dispose
- @viewport.dispose
- if @plane
- @plane.bitmap.dispose
- @plane.dispose
- end
- @hud.bitmap.dispose
- @hud.dispose
- end
- def create_battler_frame
- if @plane
- @plane.bitmap.dispose
- @plane.dispose
- end
- @plane = Plane.new(@viewport)
- @plane.bitmap = Bitmap.new(36 * $game_party.members.size,36)
- draw_heros_on_bitmap(@plane.bitmap)
- @plane.ox = @ox
- end
- def draw_heros_on_bitmap(bitmap)
- for i in 0..$game_party.members.size
- next if !$game_party.members[i]
- actor = $game_party.members[i]
- character_name = actor.character_name
- bmp =Cache.character(character_name)
- sign = character_name[/^[\!\$]./]
- if sign != nil and sign.include?('$')
- cw = bmp.width / 3
- ch = bmp.height / 4
- else
- cw = bmp.width / 12
- ch = bmp.height / 8
- end
- x = i * 36
- y = 2
- n = actor.character_index
- src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
- bitmap.blt(x, y, bmp, src_rect)
- end
- end
- def visible=(value)
- @plane.visible = value
- @hud.visible = value
- end
- def change_index(value)
- @index += value
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement