Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: Daniel Eakins on Mon 21/11/2011 22:29:30

Title: MODULE: Caterpillar v0.1 - Follow the player from behind
Post by: Daniel Eakins on Mon 21/11/2011 22:29:30
This module allows you to have characters follow the player character from behind, walking exactly in the player character's footsteps and changing rooms with them, forming a 'caterpillar' system. It is basically a smoother version of Bernie's FolEx old module (see http://www.adventuregamestudio.co.uk/yabb/index.php?topic=25121.0 ).

It was primarily designed for RPGs using keyboard controls (in particular, the KeyboardMovement module by Rui "Brisby" Pires & strazer). It currently does not work well with mouse controls because the KeyboardMovement is strictly 8-directional whereas mouse movement is, well, 360-directional.

Note that if your player character has MovementLinkedToAnimation = true, the characters who follow him must also have that parameter true and the same AnimationSpeed as him. If he has MovementLinkedToAnimation = false, the characters who follow him can have different AnimationSpeed values. In both cases, the characters's WalkSpeeds will be aligned with that of the player (including if you have implemented a custom "running" feature for your player's movement).

This is my first module ever, so sorry if there are bugs or if the code is awkward. Suggestions/comments are of course welcome.


Functions:

  Disable();
    Disables caterpillar movement.

  Enable();
    Enables caterpillar movement. By default, the module is automatically enabled at game start.

  Status();
    Returns whether caterpillar movement is currently enabled.

  Set(int spot, Character* name);
    Adds a character to the specified spot in the caterpillar (spot 0 is the first character that follows the player's character, spot 1 is the second, etc.). Note that adding a character makes them become non-solid.

    To remove a character from a spot, just set name to null. The character's original solid property will be restored.

  Get(int spot);
    Returns the ID number of the character in the specified spot.


Version history:

  v0.1 (November 21, 2011)  First release by Daniel Eakins


License:

  This module is released into the public domain.


Download (https://www.dropbox.com/s/lwdsl95xk5xkikk/Caterpillar010.zip?dl=1)
Title: Re: MODULE: Caterpillar v0.1 - Follow the player from behind
Post by: Perkele2012 on Fri 27/01/2012 04:04:32
This module sounds good! i know the post is a couple of months old, to bad it´s not avaible for download anymore. was looking forward to trying it out in my project..

cheers!
Title: Re: MODULE: Caterpillar v0.1 - Follow the player from behind
Post by: Icey on Fri 27/01/2012 06:44:03
Oh do reupload this please.
Title: Re: MODULE: Caterpillar v0.1 - Follow the player from behind
Post by: Deu2000 on Tue 21/02/2012 21:34:52
That module is very interesting. Bad that it isn't available  :'(.
Title: Re: MODULE: Caterpillar v0.1 - Follow the player from behind
Post by: Marion on Thu 18/10/2012 20:01:54
Hi ! I'm really interested, is the module available? Thank you !
Title: Re: MODULE: Caterpillar v0.1 - Follow the player from behind
Post by: Daniel Eakins on Tue 29/10/2013 23:17:26
Hello, sorry for replying so late (almost two years later!). I kind of left the forum at some point :sad:

The module has now been reuploaded.
Title: Re: MODULE: Caterpillar v0.1 - Follow the player from behind
Post by: Monsieur OUXX on Wed 03/09/2014 18:10:12
Sorry for digging up an old thread, but this module is rather useful, yet I found a bug.
This bug seems to have been introduced after an unfortunate last-minute modification.

Current code :
Code (ags) Select

static function Caterpillar::Set(int spot, Character* name) {

  // If 'name' is already at 'spot' or is the player, do nothing
  int n;
  while (n < NMAX) {
    if (name == follower[n] || name == player) {return;}
    n++;
  }
  // If 'name' is null, remove current character from 'spot'
  if (name == null) {
    ...
    follower[spot] = null;
  }
...


As you can see, the function is broken. The end-used is supposed to use "null" value for parameter "name" in order to remove that value from array "follower".
But before "if (name == null)" occurs, there is that loop which does "if (name == follower[n] ...) {return;}". If name==null, then name==follower[n] can be true! Therefore you never get to reach if (name == null)

Unless I'm overlooking something obvious, the correct code should be :
Code (ags) Select

static function Caterpillar::Set(int spot, Character* name) {

  // If 'name' is already at 'spot' or is the player, do nothing
  if (name != null) { // !!!!!!!!!!!!!!!!!!!
      int n;
      while (n < NMAX) {
        if (name == follower[n] || name == player) {return;}
        n++;
      }
  }                   //!!!!!!!!!!!!!!!!!!!!
  // If 'name' is null, remove current character from 'spot'
  if (name == null) {
    if (follower[spot] != null) { // !!!!!!!!!!!!!!!!
      follower[spot].StopMoving();
      follower[spot].Solid = originalsolid[spot];
    }                            //!!!!!!!!!!!!!!!!!!!
    follower[spot] = null;
  }...
Title: Re: MODULE: Caterpillar v0.1 - Follow the player from behind
Post by: Daniel Eakins on Sat 06/09/2014 17:24:16
Hey, what a coincidence, I was cleaning up my Dropbox folders just now and so I had to log in the forum to check some old links, after months of inactivity. I do not have AGS installed on this computer anymore so I can't check your edit Monsieur OUXX but I'm trusting your expertise :)
Title: Re: MODULE: Caterpillar v0.1 - Follow the player from behind
Post by: ollj on Fri 03/07/2015 11:24:54
this will go well with my "conga dance animations"
Title: Re: MODULE: Caterpillar v0.1 - Follow the player from behind
Post by: Daniel Eakins on Sat 16/12/2017 21:19:03
The broken link has been corrected (again).