Author Topic: MODULE: Caterpillar v0.1 - Follow the player from behind  (Read 4002 times)

Daniel Eakins

  • Time Traveller
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
« Last Edit: 16 Dec 2017, 21:18 by Daniel Eakins »
We all have our time machines, don't we?

Perkele2012

    • I can help with making music
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: MODULE: Caterpillar v0.1 - Follow the player from behind
« Reply #1 on: 27 Jan 2012, 04:04 »

Jonathan Wedge

  • It's the time of ICEY!!!
Re: MODULE: Caterpillar v0.1 - Follow the player from behind
« Reply #2 on: 27 Jan 2012, 06:44 »
Oh do reupload this please.

Deu2000

  • The only vaccum cleaner that supports TCP/IP
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
    • I can help with web design
    •  
Re: MODULE: Caterpillar v0.1 - Follow the player from behind
« Reply #3 on: 21 Feb 2012, 21:34 »
That module is very interesting. Bad that it isn't available  :'(.


Re: MODULE: Caterpillar v0.1 - Follow the player from behind
« Reply #4 on: 18 Oct 2012, 20:01 »
Hi ! I'm really interested, is the module available? Thank you !

Daniel Eakins

  • Time Traveller
Re: MODULE: Caterpillar v0.1 - Follow the player from behind
« Reply #5 on: 29 Oct 2013, 23:17 »
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.
We all have our time machines, don't we?

Monsieur OUXX

  • Cavefish
  • Mittens Vassal
  • Mittens Half Initiate
    • I can help with proof reading
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: MODULE: Caterpillar v0.1 - Follow the player from behind
« Reply #6 on: 03 Sep 2014, 18:10 »
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: Adventure Game Studio
  1. static function Caterpillar::Set(int spot, Character* name) {
  2.  
  3.   // If 'name' is already at 'spot' or is the player, do nothing
  4.   int n;
  5.   while (n < NMAX) {
  6.     if (name == follower[n] || name == player) {return;}
  7.     n++;
  8.   }
  9.   // If 'name' is null, remove current character from 'spot'
  10.   if (name == null) {
  11.     ...
  12.     follower[spot] = null;
  13.   }
  14. ...
  15.  

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: Adventure Game Studio
  1. static function Caterpillar::Set(int spot, Character* name) {
  2.  
  3.   // If 'name' is already at 'spot' or is the player, do nothing
  4.   if (name != null) { // !!!!!!!!!!!!!!!!!!!
  5.       int n;
  6.       while (n < NMAX) {
  7.         if (name == follower[n] || name == player) {return;}
  8.         n++;
  9.       }
  10.   }                   //!!!!!!!!!!!!!!!!!!!!
  11.   // If 'name' is null, remove current character from 'spot'
  12.   if (name == null) {
  13.     if (follower[spot] != null) { // !!!!!!!!!!!!!!!!
  14.       follower[spot].StopMoving();
  15.       follower[spot].Solid = originalsolid[spot];
  16.     }                            //!!!!!!!!!!!!!!!!!!!
  17.     follower[spot] = null;
  18.   }...
  19.  
« Last Edit: 03 Sep 2014, 18:59 by Monsieur OUXX »
 

Daniel Eakins

  • Time Traveller
Re: MODULE: Caterpillar v0.1 - Follow the player from behind
« Reply #7 on: 06 Sep 2014, 17:24 »
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 :)
We all have our time machines, don't we?

Re: MODULE: Caterpillar v0.1 - Follow the player from behind
« Reply #8 on: 03 Jul 2015, 11:24 »
this will go well with my "conga dance animations"

Daniel Eakins

  • Time Traveller
Re: MODULE: Caterpillar v0.1 - Follow the player from behind
« Reply #9 on: 16 Dec 2017, 21:19 »
The broken link has been corrected (again).
We all have our time machines, don't we?