Followers' Movement

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,442
Reaction score
679
First Language
Polish
Primarily Uses
Other
Hello everybody!

I'd like to ask when the followers move?

In game, they move along with Player, but I want to deconstruct that, because I have 2 players and I need to bind the second follower to second player.

I tried many things, but with no use, so I replaced the default chase method with two new, that are forced manually in update method:

#==============================================================================# ** Game_Follower#------------------------------------------------------------------------------# This class handles followers. A follower is an allied character, other than# the front character, displayed in the party. It is referenced within the# Game_Followers class.#==============================================================================class Game_Follower < Game_Character #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(member_index, preceding_character) super() @member_index = member_index #@preceding_character = preceding_character @transparent = $data_system.opt_transparent @through = true end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh @character_name = visible? ? actor.character_name : "" @character_index = visible? ? actor.character_index : 0 end #-------------------------------------------------------------------------- # * Get Corresponding Actor #-------------------------------------------------------------------------- def actor $game_party.battle_members[@member_index] end #-------------------------------------------------------------------------- # * Determine Visibility #-------------------------------------------------------------------------- def visible? actor && $game_player.followers.visible end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update case @member_index when 2 @move_speed = $game_player.real_move_speed @transparent = $game_player.transparent @walk_anime = $game_player.walk_anime @step_anime = $game_player.step_anime @direction_fix = $game_player.direction_fix @opacity = $game_player.opacity @blend_type = $game_player.blend_type when 3 @move_speed = $game_player2.real_move_speed @transparent = $game_player2.transparent @walk_anime = $game_player2.walk_anime @step_anime = $game_player2.step_anime @direction_fix = $game_player2.direction_fix @opacity = $game_player2.opacity @blend_type = $game_player2.blend_type end super #HERE their movement is forced when there's a correct distance. chase_player_1 if distance_x_from($game_player.x) == 2 || distance_x_from($game_player.x) == -2 || distance_y_from($game_player.y) == 2 || distance_y_from($game_player.y) == -2 chase_player_2 if distance_x_from($game_player2.x) == 2 || distance_x_from($game_player2.x) == -2 || distance_y_from($game_player2.y) == 2 || distance_y_from($game_player2.y) == -2 end #-------------------------------------------------------------------------- # * Pursue Preceding Character #-------------------------------------------------------------------------- def chase_preceding_character end def chase_player_1 if @member_index == 2 unless moving? #~ sx = distance_x_from(@preceding_character.x)#~ sy = distance_y_from(@preceding_character.y)#~ case @member_index#~ when 2#~ sx = distance_x_from($game_player.x)#~ sy = distance_y_from($game_player.y)#~ when 3#~ sx = distance_x_from($game_player2.x)#~ sy = distance_y_from($game_player2.y)#~ end sx = distance_x_from($game_player.x) sy = distance_y_from($game_player.y) if sx != 0 && sy != 0 move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2) elsif sx != 0 move_straight(sx > 0 ? 4 : 6) elsif sy != 0 move_straight(sy > 0 ? 8 : 2) end end end end def chase_player_2 if @member_index == 3 unless moving? #~ sx = distance_x_from(@preceding_character.x)#~ sy = distance_y_from(@preceding_character.y) sx = distance_x_from($game_player2.x) sy = distance_y_from($game_player2.y) if sx != 0 && sy != 0 move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2) elsif sx != 0 move_straight(sx > 0 ? 4 : 6) elsif sy != 0 move_straight(sy > 0 ? 8 : 2) end end end end #-------------------------------------------------------------------------- # * Determine if at Same Position as Preceding Character #-------------------------------------------------------------------------- def gather? case @member_index when 2 !moving? && pos?($game_player.x, $game_player.y) when 3 !moving? && pos?($game_player2.x, $game_player2.y) end endend
And it works:

But their AI is kinda, well not perfect. I mean it's okay, I can program their movement properly, because the current one is just for testing, but I'd like to ask if this workaround is okay or if there's a better way to do this.

I really can't get where followers' movement is forced by default.

Any suggestions? Thank you in advance.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Potato The game! Few concepts for characters to my game.
Well, well, well, well....Lemme get a look at this fanart.
The Google Play rating for one of my games finally rose above 4.0 after getting review-bombed from a $0 sale. Now the game's sales are doing much better when discounted, so that's nice.
I'm getting close to releasing a demo. Working on formatting my Games in Development post.
I always see a few people asking for C# in next engine and I always thought: Do I not know enough about that language to tell it will affect extensibility and customizability to the negative? Watching a video from SumRndmDde today I feel confirmed.

Forum statistics

Threads
98,223
Messages
950,501
Members
129,522
Latest member
Rasenringu
Top