For anyone who wants this to no longer place followers directly on the player after battles, and instead place the follower behind the trainer.
Or, if the spot behind the trainer is full, check the other directions around the player. If somehow ALL of those are full, then resign to place the follower on the player.
I didn't like the look of followers colliding with the player after every battle, so here's a fix for others who also dislike that.
Go to the script additions folder, under refresh.rb
Starting on line 156, here's the new code to paste in.
#-------------------------------------------------------------------------------
# Queue a Following Pokemon refresh after the end of a battle, put it behind the player, unless that's full, then take the next open spot - Thane S
#-------------------------------------------------------------------------------
module BattleCreationHelperMethods
class << self
alias __followingpkmn__after_battle after_battle unless method_defined?(:__followingpkmn__after_battle)
end
def self.after_battle(*args)
__followingpkmn__after_battle(*args) #default after-battle logic
if FollowingPkmn.can_check? && FollowingPkmn.get_event #only do this if you had followers out
event = FollowingPkmn.get_event
player = $game_player
map = $game_map
directions = case player.direction
when 2 then [[0, -1], [-1, 0], [1, 0], [0, 1]] #when facing down, put follower above
when 4 then [[1, 0], [0, -1], [0, 1], [-1, 0]] #when facing left, put to the right
when 6 then [[-1, 0], [0, -1], [0, 1], [1, 0]] #when facing right, put to left
when 8 then [[0, 1], [-1, 0], [1, 0], [0, -1]] #when facing up, but below
end
placed = false #verify we actually placed the follower, just in case
directions.each do |dx, dy|
x = player.x + dx
y = player.y + dy
if map.valid?(x, y) && #tile is on map
map.passable?(x, y, 10) && #you can walk on tile
!map.events.values.any? { |e| e.x == x && e.y == y && !e.through } #no trainers or anything on the tile
event.moveto(x, y) #then we place the follower on that spot
placed = true
break
end
end
event.moveto(player.x, player.y) unless placed #do the original logic of dumping the follower on the player if there's nothing open
end
FollowingPkmn.refresh(false)
$PokemonGlobal.call_refresh = true
end
end