Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # GTBS Placement Window v2.5.2
- #
- # This Script was made for GTBS 2.4. It is a plug-n-play
- # Paste this anywhere below [GTBS] Window_Base
- # Feel free to use/edit
- # Credits would be nice, but you do not need to.
- #
- # Edit the values in module Quasi to your liking.
- # Don't edit anything else unless you know what you are doing.
- #
- # To use a picture instead of windowskin for the Place Window
- # Make a file in Graphics/Pictures/GTBS/ named "TBS_Place"
- #
- # Uses battlers instead of characters.
- # Uses Animated battlers settings if sprite name has the _ANIM suffix
- # Animated battlers might be buggy, didn't test all the different types
- # only tested Minkoff and GTBS
- # Not sure how Minkoff mini battle actually works, so it may be scripted incorrect
- #
- # Animated Character referenced off Galv
- #
- # By Quasi (http://quasixi.wordpress.com/)
- # 1/31/14
- #
- # Edited:
- # Fixed a small buy with L,R
- # 2/7/14
- #
- # Added hide for background picture
- # Didn't notice I forgot it
- # 2/8/14
- #===============================================================================
- module Quasi
- PLACEOFFSET_Y = 70
- PLACEWIN_X = 0
- PLACEWIN_Y = Graphics.height - 170
- PLACEWIN_Z = 2
- PLACEWIN_HEIGHT = 100
- PLACEWIN_WIDTH = Graphics.width
- PLACEWIN_COL = 5 #Max Number of actors to display
- WINPLACE_SPACING = 40 #Spacing Between Actors
- # Set this to true if you want to use minkoff battlers ( needs to end in _MINI )
- # Keep this as false if your not using it or it'll cut the chara incorrect.
- PLACEMINKOFF = false
- # Set the pose you want to use
- # Only works for animated battlers!
- # If you don't know what poses they're are look at [GTBS] Animation Config
- # line 113, for minkoff line 175
- PLACEPOSE = 2
- end
- #===============================================================================
- # Changes to [GTBS] Scene_Battle
- # Adds window + hides
- #===============================================================================
- class Scene_Battle_TBS
- Win_Place = 'place'
- alias quasi_create_windows create_windows
- def create_windows
- quasi_create_windows
- create_place_window
- end
- def create_place_window
- @windows[Win_Place] = Windows_Place_GTBS.new
- end
- def finish_prep
- @windows[Win_Help].hide
- @windows[Win_Place].hide
- if @ATB_Active
- setup_start_atb
- else
- choose_team_start
- end
- end
- #===============================================================================
- # Changes to [GTBS] Place_Actors
- # Updates Place Window
- # Flipped R and L
- #===============================================================================
- alias quasi_start_actor_place start_actor_place
- alias quasi_place_update place_update
- def set_place_finish?
- @windows[Win_Confirm].ask(Command_Confirm::Place)
- @windows[Win_Place].visible = false
- end
- def start_actor_place
- quasi_start_actor_place
- @windows[Win_Place].visible = true
- @windows[Win_Place].update($game_party.all_members[@index], @index)
- end
- #--------------------------------------------------------------------------
- # * Place Init - This method is the "initial" update to be processed during the
- # character placement phase
- # L and R, switched to go correctly with window
- # A (SHIFT) added to remove a battler
- #--------------------------------------------------------------------------
- def place_init
- actor = $game_party.all_members[@index]
- if Input.trigger?(Input::B)
- if tactics_actors.size == 0#Cannot exit setup if no actors placed
- Sound.play_buzzer
- else
- Sound.play_cancel
- set_place_finish?
- end
- elsif Input.trigger?(Input::A)
- if @cursor.in_range?
- if @temp_placed = occupied_by? #if occupied
- @temp_placed.hide
- @temp_placed.tbs_battler = false
- @temp_placed.clear_tbs_pos
- dispose_character(@temp_placed)
- clear_r_sprites
- @temp_placed = nil
- Sound.play_decision
- end
- end
- elsif Input.trigger?(Input::C)
- #valid in range?
- if @cursor.in_range?
- if temp_placed = occupied_by? #if occupied
- @cursor.target_positions = [@cursor.pos]
- @cursor.target_area[0] = 1
- @temp_placed = temp_placed
- Sound.play_decision
- else
- if actor.hidden?
- if actor.death_state?
- Sound.play_buzzer
- return
- else
- Sound.play_decision
- actor.gtbs_entrance(@cursor.x, @cursor.y)
- create_character(@spriteset.viewport1, actor)
- next_actor_to_place
- @cursor.moveto_next
- if tactics_actors.size == $game_party.placable?
- set_place_finish?
- end
- end
- #not allowed to place an actor that was forced by a map place
- elsif !@place_loc.include?(actor.pos)
- Sound.play_buzzer
- return
- else #if actor already placed, move to location
- Sound.play_decision
- actor.moveto(@cursor.x, @cursor.y)
- actor.update
- end
- end
- else #valid not in range
- Sound.play_buzzer
- end
- #next actor
- elsif Input.trigger?(Input::R)
- Sound.play_cursor
- next_actor_to_place
- #previous actor
- elsif Input.trigger?(Input::L)
- Sound.play_cursor
- previous_actor_to_place
- end
- end
- def place_update
- quasi_place_update
- @windows[Win_Help].visible = true if @windows[Win_Help].visible != true
- @windows[Win_Place].visible = true if @windows[Win_Confirm].visible == false
- @windows[Win_Place].update($game_party.all_members[@index], @index)
- end
- end
- #===============================================================================
- # Windows_Place_GTBS
- # By Quasi
- #===============================================================================
- class Windows_Place_GTBS < TBS_Window_Base
- #----------------------------------------------------------------------------
- # * Object Intialization
- # actor = Game_Actor/Game_Enemy/nil
- #----------------------------------------------------------------------------
- def initialize(actor = nil)
- super(Quasi::PLACEWIN_X, Quasi::PLACEWIN_Y, Quasi::PLACEWIN_WIDTH, Quasi::PLACEWIN_HEIGHT)
- @actor = nil
- @index = 0
- @animtime = 0
- @step = -1
- @afix = 1
- @key = ""
- @col = Quasi::PLACEWIN_COL
- @y = Quasi::PLACEOFFSET_Y
- @tsteps = 2
- self.z = Quasi::PLACEWIN_Z
- create_back
- create_contents
- refresh
- end
- def create_back
- if FileTest.exist?('Graphics/Pictures/GTBS/Window_Place.png')
- @back = Sprite.new
- @back.bitmap = Cache.picture('GTBS/Window_Place.png')
- @back.z = 0
- self.opacity = 0
- else
- self.opacity = GTBS::CONTROL_OPACITY
- end
- end
- #----------------------------------------------------------------------------
- # Update Method
- #----------------------------------------------------------------------------
- def update(actor = nil, index = nil)
- super()
- if @actor != actor
- @actor = actor
- refresh
- end
- if @index != index
- @index = index
- refresh
- end
- return unless self.visible
- @animtime += 1
- if @animtime == 10
- @animtime = 0
- @step += 1
- if @step >= @tsteps
- @step = -1
- end
- refresh
- end
- end
- #----------------------------------------------------------------------------
- # Refresh Method
- #----------------------------------------------------------------------------
- def refresh
- if @actor == nil
- hide
- return
- end
- draw_actor_info
- self.visible = true
- end
- def draw_character(character_name, character_index, battler_hue, x, y, enabled = true)
- return unless character_name
- anim = character_name.include?(GTBS::DETERMINE_ANIM_KEY)
- suffix = ""
- if Quasi::PLACEMINKOFF == true
- if File.exist?('Graphics/Battlers/'+character_name+'_MINI.png')
- suffix = "_MINI"
- end
- end
- bitmap = Cache.battler(character_name+suffix, battler_hue)
- n = character_index
- step = 0
- step = @step if enabled
- if anim and !Quasi::PLACEMINKOFF
- cf = GTBS::DEFAULT_POSE_FRAMES
- cs = GTBS::DEFAULT_POSE_STANCES
- cp = (Quasi::PLACEPOSE - 1) * 4
- cw = bitmap.width / cf
- ch = bitmap.height / (cs * 4)
- cx = (cp%4*cf+1+step)*cw
- cy = (cp/4*4)*ch
- ts = cf - 1
- elsif anim and Quasi::PLACEMINKOFF
- cf = GTBS::MINKOFF_HOLDER_POSE_FRAMES
- cs = GTBS::MINKOFF_HOLDER_POSE_STANCES
- cp = (Quasi::PLACEPOSE - 1)
- cw = bitmap.width / cf
- ch = bitmap.height / cs
- cx = (1+step)*cw
- cy = cp*ch
- ts = cf - 1
- else
- 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
- cx = (n%4*3+1+step)*cw
- cy = (n/4*4)*ch
- ts = 2
- end
- if enabled == true
- @tsteps = ts
- end
- ocx = cw/2
- src_rect = Rect.new(cx, cy, cw, ch)
- ret_rect = Rect.new(x - ocx, y - ch, cw, ch)
- contents.stretch_blt(ret_rect, bitmap, src_rect)
- end
- def draw_actor_info
- clear_info
- draw_text(0, 50, 180, line_height, " < Prev")
- draw_text(Graphics.width - 100, 50, 180, line_height, "Next > ")
- party_members = $game_party.all_members
- if @col > party_members.size
- @col = party_members.size
- end
- @odd = (@col + 1) % 2
- @ofix = (@col / 2) - @odd
- @afix = party_members.size - (@col - @ofix)
- @fix = @col
- @fix %= 2
- @pindex = @index + @afix
- for i in 0...@col
- @pindex += 1
- @pindex %= party_members.size
- @a = party_members[@pindex]
- spacing = i * Quasi::WINPLACE_SPACING
- x = ( Graphics.width / 2 ) - (((@col - @fix) * 40) / 2)
- x -= 16
- if @index != @pindex
- @ani = false
- else
- @ani = true
- end
- if @a != nil
- draw_character(@a.character_name, @a.character_index, @a.battler_hue,x + spacing + 2, @y, @ani)
- end
- end
- end
- def clear_info
- self.contents.clear
- contents.clear
- end
- #-----------------------------------------------------------
- # This change checks for a background image and if exist set its visiblity
- #-----------------------------------------------------------
- def visible=(bool)
- if @back
- @back.visible = bool
- end
- super(bool)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment