Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # * [ACE] Follower Arranger
- #===============================================================================
- # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
- # * Version: 1.0
- # * Updated: 11/02/2016
- # * Requires: --------
- #-------------------------------------------------------------------------------
- # * < Change Log >
- #-------------------------------------------------------------------------------
- # * Version 1.0 (11/02/2016)
- # - Initial release.
- #-------------------------------------------------------------------------------
- # * < Description >
- #-------------------------------------------------------------------------------
- # * This script will let you change how many followers are shown, which ones,
- # and in what order they appear on the map. These changes are purely for the
- # visuals of the map, the battle formation itself will NOT change!
- # * Various follower order sorting methods are possible to do too.
- # * You can change the follower settings anytime during the game also!
- #-------------------------------------------------------------------------------
- # * < Script Calls >
- #-------------------------------------------------------------------------------
- # * To hide, show, or toggle a follower, or to set a specific order for them,
- # you can use the following script call:
- #
- # set_follower_visibility(index,state,sort,reverse)
- #
- # The index is the party member's index. Note that from now on, the party
- # member indexes and follower indexes are NOT the same!
- # The index can be any number between 1 and the maximum size of your party
- # minus 1! So, if your party got 5 members, the index can be any integer
- # number between 1 and 4. These numbers represent the member's index in the
- # party (so NOT the index of a follower visible on the screen!).
- #
- # The state can be one of the following:
- # :show = Shows the selected party member's follower graphic on the map.
- # :hide = Hides the selected party member's follower graphic on the map.
- # :toggle = Toggles the selected party member's follower graphic on the map.
- # If the follower is shown, it will be hidden, and if it is hidden,
- # it will be shown.
- # :set = If this is used, the index argument (explained above) must be an
- # array instead of an integer number. That array must contain all
- # party member indexes you want to show on the map with a follower
- # graphic. If a party member's index is not in the array, it will be
- # hidden, and if it is in the array, it will be shown after the script
- # call, regardless of the current state of the follower graphic.
- # In short, this can set the shown members directly and with your
- # specific order.
- #
- # The sort argument is used if you want to sort your followers shown on the
- # map in a specific order. It is an optional argument!
- # The sort argument can be one of the following:
- # :sort = Sorts the follower graphics based on actor ID.
- # :reverse = Reverses the current order.
- # :level = Sorts the follower graphics based on their actor's level.
- # The lowest leveled will be the 1st follower, followed by higher
- # leveled actors.
- # It can also be set to an integer number between 0 and 7. In this case,
- # the follower graphics will be sorted based on their actor's specified param
- # values. The one with the lowest param value will be the 1st follower,
- # followed by the ones with higher params in order.
- # 0 = HP, 1 = MP, 2 = ATK, 3 = DEF, 4 = MAT, 5 = MDF, 6 = AGI, 7 = LUK
- #
- # The reverse argument is an optional one too. It will reverse the follower
- # graphics' order immediately after the change you made with the script call.
- # It happens after the sorting process (if you used a sort argument) or after
- # the change of visibility for the follower.
- # If you want to use this feature, just set it to true in your script calls,
- # if not, you can omit it entirely.
- #
- # NOTE:
- # If you enter a higher number than the number of party members in your party
- # minus one for the index argument, the script call will be diregarded, and
- # no changes will be made at all!
- #
- # Some examples are shown at the end of this section. I wanted to make an
- # example with real party setups, so that it is understood easier.
- #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # * To sort the order of follower graphics on the map based on different
- # factors, you can use the following script call:
- #
- # order_followers(type,reverse)
- #
- # The type can be one of the following:
- # :sort, :reverse, :level, and any integer number between 0 and 7 (params).
- # It works the same way as the optional sort argument in the previous script
- # call, so check the details there!
- #
- # The reverse argument is optional here as well.
- # If used, it will reverse the order of followers immediately after the
- # sorting. Set this to true if you want to use it, otherwise, you can omit it.
- #
- # Some examples are shown at the end of this section. I wanted to make an
- # example with real party setups, so that it is understood easier.
- #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # * You can also show, hide and toggle follower graphics based on their actor's
- # ID if you want. Use this script call for that:
- #
- # set_followers_by_actor(id,state,sort,reverse)
- #
- # So, instead of using party member indexes, you can use actor IDs directly
- # to, for example, hide the follower graphic of Ernest on the map, regardless
- # of Ernest's party member index.
- #
- # Every argument here is the same as in the first script call, but instead of
- # entering party member indexes, you enter actor IDs here for the 1st
- # argument.
- #
- # NOTE:
- # If the actor is not currently in the party, no change will be made!
- #
- # Some examples are shown at the end of this section. I wanted to make an
- # example with real party setups, so that it is understood easier.
- #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # * And finally, you can show, hide or toggle the visibility of all of the
- # follower graphics at once with the following script call:
- #
- # set_all_followers(state,type,sort,reverse)
- #
- # The state argument can be:
- # :show, :hide, :toggle
- # It works the same way as the other state arguments mentioned in other script
- # calls above.
- #
- # The type argument decides if you only want the script call to change your
- # battle members' follower graphics or your entire party (including non-battle
- # members). It can be:
- # :battle, :all
- # Should be obvious what they do.
- # You can omit this argument, in which case it will default to :battle.
- #
- # The sort and reverse arguments are optional as well, and they do the same
- # as in every other script call above.
- #
- # Some examples are shown at the end of this section. I wanted to make an
- # example with real party setups, so that it is understood easier.
- #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # * Let's see some examples with the following initial party:
- #
- # Member | Member | Actor | Member | Follower | In Battle | Follower |
- # Index | Name | ID | Level | Index | Party? | Visibility |
- # ---------------------------------------------------------------------------
- # 0 | Eric | 1 | 88 | 0 | Yes | Always shown!
- # ---------------------------------------------------------------------------
- # 1 | Natalie | 2 | 15 | 1 | Yes | Shown
- # ---------------------------------------------------------------------------
- # 2 | Terence | 3 | 34 | 2 | Yes | Shown
- # ---------------------------------------------------------------------------
- # 3 | Earnest | 4 | 96 | 3 | Yes | Shown
- # ---------------------------------------------------------------------------
- # 4 | Ryoma | 5 | 75 | - | No | Hidden
- # ---------------------------------------------------------------------------
- # 5 | Brenda | 6 | 12 | - | No | Hidden
- # ---------------------------------------------------------------------------
- #
- # This initial party is a completely normal party, can be done with the
- # default engine too. Note that hidden followers do not have a follower index!
- # But let's see what happens when you use some clever script calls!
- #
- # set_follower_visibility(2,:hide)
- # This would hide Terence's follower graphic.
- # After this script call, the following party members would be shown on the
- # map (in the order listed here):
- # Eric -> Natalie -> Earnest
- #
- # The table now looks like this:
- #
- # Member | Member | Actor | Member | Follower | In Battle | Follower |
- # Index | Name | ID | Level | Index | Party? | Visibility |
- # ---------------------------------------------------------------------------
- # 0 | Eric | 1 | 88 | 0 | Yes | Always shown!
- # ---------------------------------------------------------------------------
- # 1 | Natalie | 2 | 15 | 1 | Yes | Shown
- # ---------------------------------------------------------------------------
- # 2 | Terence | 3 | 34 | - | Yes | Hidden
- # ---------------------------------------------------------------------------
- # 3 | Earnest | 4 | 96 | 2 | Yes | Shown
- # ---------------------------------------------------------------------------
- # 4 | Ryoma | 5 | 75 | - | No | Hidden
- # ---------------------------------------------------------------------------
- # 5 | Brenda | 6 | 12 | - | No | Hidden
- # ---------------------------------------------------------------------------
- #
- # Let's use another script call!
- #
- # set_followers_by_actor(5,:toggle,:level)
- # This will show Ryoma's follower graphic, because he was hidden before,
- # regardless of his member index in the party, and regardless if he is in the
- # battle party or not.
- # Now, the shown followers are:
- # Eric -> Natalie -> Earnest -> Ryoma
- # But because we also added a sort argument (:level), the follower graphics
- # will be sorted by their actor's level, from the lowest to the highest.
- # This means, we will get this order:
- # Eric -> Natalie -> Ryoma -> Earnest
- #
- # The table now looks this way:
- #
- # Member | Member | Actor | Member | Follower | In Battle | Follower |
- # Index | Name | ID | Level | Index | Party? | Visibility |
- # ---------------------------------------------------------------------------
- # 0 | Eric | 1 | 88 | 0 | Yes | Always shown!
- # ---------------------------------------------------------------------------
- # 1 | Natalie | 2 | 15 | 1 | Yes | Shown
- # ---------------------------------------------------------------------------
- # 2 | Terence | 3 | 34 | - | Yes | Hidden
- # ---------------------------------------------------------------------------
- # 3 | Earnest | 4 | 96 | 3 | Yes | Shown
- # ---------------------------------------------------------------------------
- # 4 | Ryoma | 5 | 75 | 2 | No | Shown
- # ---------------------------------------------------------------------------
- # 5 | Brenda | 6 | 12 | - | No | Hidden
- # ---------------------------------------------------------------------------
- #
- # And now let's use yet another script call:
- #
- # set_all_followers(:toggle)
- # This will toggle the visibility of all of the battle members in the party.
- # That means, the follower graphics show will be these (in this order):
- # Eric -> Ryoma -> Terence
- # So, Natalie and Earnest were shown before the script call, that is why they
- # are hidden now, and Terence were hidden before, so he will be shown now.
- # Because Ryoma is not in the battle party, his follower visibility state will
- # remain whatever it was before, so he will still show up.
- # And because Ryoma was shown already before Terence appeared, Terence will be
- # put at the end of the follower graphics.
- #
- # The table now is:
- #
- # Member | Member | Actor | Member | Follower | In Battle | Follower |
- # Index | Name | ID | Level | Index | Party? | Visibility |
- # ---------------------------------------------------------------------------
- # 0 | Eric | 1 | 88 | 0 | Yes | Always shown!
- # ---------------------------------------------------------------------------
- # 1 | Natalie | 2 | 15 | - | Yes | Hidden
- # ---------------------------------------------------------------------------
- # 2 | Terence | 3 | 34 | 2 | Yes | Shown
- # ---------------------------------------------------------------------------
- # 3 | Earnest | 4 | 96 | - | Yes | Hidden
- # ---------------------------------------------------------------------------
- # 4 | Ryoma | 5 | 75 | 1 | No | Shown
- # ---------------------------------------------------------------------------
- # 5 | Brenda | 6 | 12 | - | No | Hidden
- # ---------------------------------------------------------------------------
- #
- # And a last script call!
- #
- # order_followers(:sort)
- # This will sort the follower graphics based on their actor's ID.
- # The followers now are (in this order):
- # Eric -> Terence -> Ryoma
- #
- # The table looks like thsi now:
- #
- # Member | Member | Actor | Member | Follower | In Battle | Follower |
- # Index | Name | ID | Level | Index | Party? | Visibility |
- # ---------------------------------------------------------------------------
- # 0 | Eric | 1 | 88 | 0 | Yes | Always shown!
- # ---------------------------------------------------------------------------
- # 1 | Natalie | 2 | 15 | - | Yes | Hidden
- # ---------------------------------------------------------------------------
- # 2 | Terence | 3 | 34 | 1 | Yes | Shown
- # ---------------------------------------------------------------------------
- # 3 | Earnest | 4 | 96 | - | Yes | Hidden
- # ---------------------------------------------------------------------------
- # 4 | Ryoma | 5 | 75 | 2 | No | Shown
- # ---------------------------------------------------------------------------
- # 5 | Brenda | 6 | 12 | - | No | Hidden
- # ---------------------------------------------------------------------------
- #
- # Alright, enough of the script calls, right?
- # Lets try something else...
- #
- # We will change the party formatiion in the menu.
- # Terence will be exchanged by Brenda, and Earnest will take Natalie's place.
- # The followers shown now are (in this order):
- # Eric -> Brenda -> Ryoma
- # You see, while follower graphic changes do NOT affect the party formation,
- # the opposite is NOT true. If you change the party formation in the menu,
- # that will be reflected in the shown follower graphics.
- # Neither Earnest or Natalie were shown as a follower before the change, so
- # exchanging their position won't change anything in the follower graphics.
- # But because Terence was shown, and because we exchanged him with Brenda,
- # Terence will exchange the follower visibility state with Brenda as well, so
- # Terence will be hidden, and Brenda will be shown.
- #
- # The table after the formation change:
- #
- # Member | Member | Actor | Member | Follower | In Battle | Follower |
- # Index | Name | ID | Level | Index | Party? | Visibility |
- # ---------------------------------------------------------------------------
- # 0 | Eric | 1 | 88 | 0 | Yes | Always shown!
- # ---------------------------------------------------------------------------
- # 1 | Earnest | 4 | 96 | - | Yes | Hidden
- # ---------------------------------------------------------------------------
- # 2 | Brenda | 6 | 12 | 1 | Yes | Shown
- # ---------------------------------------------------------------------------
- # 3 | Natalie | 2 | 15 | - | Yes | Hidden
- # ---------------------------------------------------------------------------
- # 4 | Ryoma | 5 | 75 | 2 | No | Shown
- # ---------------------------------------------------------------------------
- # 5 | Terence | 3 | 34 | - | No | Hidden
- # ---------------------------------------------------------------------------
- #
- # And this concludes the long series of examples, phew!
- #
- # Final note:
- # Every time you change follower graphics, the followers will be re-spawn at
- # the same position the player is. They will NOT stay at the same position
- # as the previous followers were before the change!
- #-------------------------------------------------------------------------------
- # * < Installation >
- #-------------------------------------------------------------------------------
- # * Place this script below Materials but above Main!
- #-------------------------------------------------------------------------------
- # * < Compatibility Info >
- #-------------------------------------------------------------------------------
- # * No known incompatibilities.
- #-------------------------------------------------------------------------------
- # * < Known Issues >
- #-------------------------------------------------------------------------------
- # * No known issues.
- #-------------------------------------------------------------------------------
- # * < Terms of Use >
- #-------------------------------------------------------------------------------
- # * Free to use for whatever purposes you want.
- # * Credit me (Sixth) in your game, pretty please! :P
- # * Posting modified versions of this script is allowed as long as you notice me
- # about it with a link to it!
- #===============================================================================
- $imported = {} if $imported.nil?
- $imported["SixthFollowerArranger"] = true
- #===============================================================================
- # Settings:
- #===============================================================================
- module FollowerArranger
- #-----------------------------------------------------------------------------
- # Initial Follower Settings
- #-----------------------------------------------------------------------------
- # Initial follower setting.
- # Shows 3 followers after the player.
- # The numbers in the array are the indexes of the party members.
- # 1 means the 2nd party member, 2 means the 3rd party member, and so on.
- # The 1st party member is always the player itself, and the visibility of
- # the player can NOT be modified by this script! You can do that easily with
- # the default event commands anyway.
- #
- # This also sets the initial order of appearance for the followers.
- # If you remove 1 from the array, for example, the second party member will
- # not show up as a follower, but the 3rd and 4th party member will.
- # Now, if you put the 1 at the end of the array, the 3 party members would
- # show up in the same order as in the array, so the 3rd party member would be
- # the 1st follower, the 4th member would be the 2nd follower and the
- # 2nd member would be the 3rd follower on the screen.
- #
- # Note that the order of followers is NOT related to the real party member
- # order! Every battle and menu related order stays unchanged, meaning these
- # changes to the followers only affect the visuals on the map scene!
- #-----------------------------------------------------------------------------
- Initial = [1,2,3] # Default: [1,2,3]
- end
- #===============================================================================
- # End of settings! Editing anything below may lead to... you know it, right? o.o
- #===============================================================================
- class Game_Interpreter
- def order_followers(type=:sort,reverse=false,upd=true)
- case type
- when Integer
- $game_system.visible_followers.sort_by! {|i| $game_party.members[i].param(type)}
- $game_player.followers.need_refresh = true if upd && !reverse
- when Array
- $game_system.visible_followers = type
- $game_player.followers.need_refresh = true if upd && !reverse
- when :sort
- $game_system.visible_followers.sort!
- $game_player.followers.need_refresh = true if upd && !reverse
- when :reverse
- $game_system.visible_followers.reverse!
- $game_player.followers.need_refresh = true if upd && !reverse
- when :level
- $game_system.visible_followers.sort_by! {|i| $game_party.members[i].level}
- $game_player.followers.need_refresh = true if upd && !reverse
- end
- $game_system.visible_followers.reverse! if reverse
- $game_player.followers.need_refresh = true if upd && reverse
- end
- def set_follower_visibility(index,state,sort=nil,reverse=false,upd=true)
- return if index > $game_party.all_members.size - 1
- case state
- when :show
- return if $game_system.visible_followers.include?(index)
- $game_system.visible_followers << index
- order_followers(sort,reverse,false) if sort
- $game_player.followers.need_refresh = true if upd
- when :hide
- $game_system.visible_followers.delete(index)
- order_followers(sort,reverse,false) if sort
- $game_player.followers.need_refresh = true if upd
- when :toggle
- if $game_system.visible_followers.include?(index)
- $game_system.visible_followers.delete(index)
- order_followers(sort,reverse,false) if sort
- $game_player.followers.need_refresh = true if upd
- else
- $game_system.visible_followers << index
- order_followers(sort,reverse,false) if sort
- $game_player.followers.need_refresh = true if upd
- end
- when :set
- $game_system.visible_followers = index
- $game_player.followers.need_refresh = true if upd
- end
- end
- def set_followers_by_actor(id,state,sort=nil,reverse=false)
- return if id == 0
- index = $game_actors[id].index
- return if index.nil? || index == 0
- set_follower_visibility(index,state,sort,reverse)
- end
- def set_all_followers(state,type=:battle,sort=nil,reverse=false)
- case type
- when :battle
- m = $game_party.max_battle_members
- when :all
- m = $game_party.all_members.size
- end
- (1...m).each do |i|
- set_follower_visibility(i,state,sort,reverse,false)
- end
- $game_player.followers.need_refresh = true
- end
- end
- class Game_System
- def visible_followers
- @visible_followers = FollowerArranger::Initial if @visible_followers.nil?
- return @visible_followers
- end
- end
- class Game_Player < Game_Character
- def reset_followers
- @followers = Game_Followers.new(self)
- @followers.each {|f| f.moveto(@x, @y); f.refresh; f.update}
- end
- end
- class Game_Follower < Game_Character
- def actor
- return nil if @member_index.nil?
- $game_party.all_members[@member_index]
- end
- end
- class Game_Followers
- attr_accessor :need_refresh
- def initialize(leader)
- @visible = $data_system.opt_followers
- @gathering = false
- @data = []
- first_f = $game_system.visible_followers[0]
- @data.push(Game_Follower.new(first_f, leader))
- $game_system.visible_followers.each_with_index do |index,i|
- next if i == 0
- @data.push(Game_Follower.new(index, @data[-1]))
- end
- end
- end
- class Spriteset_Map
- alias add_fref7632 update
- def update
- add_fref7632
- if $game_player.followers.need_refresh
- @character_sprites.each_with_index do |char,i|
- if char.character.is_a?(Game_Follower) || char.character.is_a?(Game_Player)
- @character_sprites[i].dispose
- @character_sprites[i] = nil
- end
- end
- @character_sprites.compact!
- $game_player.reset_followers
- $game_player.followers.reverse_each do |follower|
- @character_sprites.push(Sprite_Character.new(@viewport1, follower))
- end
- @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
- $game_player.followers.need_refresh = false
- end
- end
- end
- #==============================================================================
- # !!END OF SCRIPT - OHH, NOES!!
- #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement