Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: thom0512 on Mon 27/07/2009 01:36:46

Title: FOLLOW_EXACTLY-related question
Post by: thom0512 on Mon 27/07/2009 01:36:46
Hello everyone.  I have read through the manual and performed numerous forum searches but haven't found anything that has helped me.

I want a non-playable character to follow the playable character, but I want it done in a fashion so that the NPC will be "following the leader" and matching their every move, but doing so a moment or two later (so no waiting around, no moving to a random location close by the playable character, etc).  FOLLOW_EXACTLY has sent me in the right direction, but it's still not helping because no matter what value I input, overlapping of characters still occurs.  I hope this makes sense; any help would be greatly appreciated.
Title: Re: FOLLOW_EXACTLY-related question
Post by: Ethan D on Mon 27/07/2009 03:13:15
Have you tried the FollowCharacter function?
Title: Re: FOLLOW_EXACTLY-related question
Post by: monkey0506 on Mon 27/07/2009 03:33:07
Quote from: The manualThere is also another special use for this command. You can pass the special value FOLLOW_EXACTLY as the DIST parameter rather than passing a number. If you do this, then CHARID will always remain at exactly the same X and Y co-ordinates as CHARTOFOLLOW. This might be useful for effects such as a temporary halo over the character and so forth.

FOLLOW_EXACTLY is part of the Character.FollowCharacter function Float. The problem is that with FOLLOW_EXACTLY the two characters will share the same (X, Y) co-ordinates. Therefore the overlapping is intentional.

To make the character follow "a moment or two later" you need to set the DIST parameter to something OTHER than FOLLOW_EXACTLY, and use the EAGERNESS as well:

QuoteDIST sets how far away from CHARTOFOLLOW that CHARID will stand. If DIST is 1, they will try to stand very close; if DIST is for example 20, they will stand about 20 pixels away.

EAGERNESS sets on average how long the character will stand around before checking if he needs to move again. Setting this to 0 means that he will always be on the move until he reaches CHARTOFOLLOW; setting this to 99 means that he will pause and think for a while on route. Values in between specify different lengths of idle time

Edit: I corrected the parameters. I was a bit tired when I posted last night. FOLLOW_EXACTLY applies to the DIST parameter.
Title: Re: FOLLOW_EXACTLY-related question
Post by: Khristian Cammilleri on Tue 28/07/2009 16:19:27
You Should Use FollowCharacter

Character.FollowCharacter(Character* chartofollow, optional int dist,
                          optional int eagerness)


Pass CHARTOFOLLOW as null to stop the character following

DIST sets how far away from CHARTOFOLLOW that CHARID will stand. If DIST is 1, they will try to stand very close; if DIST is for example 20, they will stand about 20 pixels away.

EAGERNESS sets on average how long the character will stand around before checking if he needs to move again. Setting this to 0 means that he will always be on the move until he reaches CHARTOFOLLOW; setting this to 99 means that he will pause and think for a while on route. Values in between specify different lengths of idle time.


The FollowExactly Command Is useless if  you want to make a character to follow your player ::)
Title: Re: FOLLOW_EXACTLY-related question
Post by: monkey0506 on Wed 29/07/2009 05:07:20
FOLLOW_EXACLY is not useless, it does exactly what the manual says. The two characters will have exactly the same (X, Y) co-ordinates. This can be useful if it's what you want. What's useless is saying a valid function is useless just because of user error and/or failure to read (or at least understand) the manual which documents proper usage.
Title: Re: FOLLOW character problem
Post by: dbuske on Fri 19/11/2010 15:21:29
I add the following script to the room script and I get an error message.
cMuffy.FollowCharacter(cDanny);
It says unexpected error with cMuffy.
Muffy is a dog who I want to follow Danny most of the time except when I script to make her save the day.
Title: Re: FOLLOW_EXACTLY-related question
Post by: Matti on Fri 19/11/2010 15:44:31
Yeah, so what does the code look like and what does the error message exactly say? It seems you didn't put the command inside any function (like the rep-exec.).

Also, don't dig up old threads that have nothing to do with your question.
Title: Re: FOLLOW_EXACTLY-related question
Post by: dbuske on Fri 19/11/2010 16:01:52
The command was exactly as I wrote it. 
Here is the error message:

Message                                                          room  room1.asc                                      line 2

Failed to save room1.crm; details below
Error (line 2): parse error; unexpected 'cMuffy'

I don't know what your guess said.  I am new to scripting.
Title: Re: FOLLOW_EXACTLY-related question
Post by: Matti on Fri 19/11/2010 16:07:00
Quote from: dbuske on Fri 19/11/2010 16:01:52
I don't know what your guess said.  I am new to scripting.

Where exactly did you put that line? Make sure it's within the room load or the rep-exe or any other function. You know, within { and }.
Title: Re: FOLLOW_EXACTLY-related question
Post by: dbuske on Fri 19/11/2010 16:09:07
I put it in the room script of room1 called forest walk.
Title: Re: FOLLOW_EXACTLY-related question
Post by: Sslaxx on Fri 19/11/2010 16:12:10
Quote from: dbuske on Fri 19/11/2010 16:09:07
I put it in the room script of room1 called forest walk.
Copy and paste the script here, please.
Title: Re: FOLLOW_EXACTLY-related question
Post by: Matti on Fri 19/11/2010 16:16:29
Within the room script it has to be within a function.

If it looks like this


// room script

cMuffy.FollowCharacter(cDanny);


.. you get an error message (and should definitely do the tutorial).

If it looks like this it should work (well, not really since the command would be called every game cycle and thus never start - but you shouldn't get any error):


// room script

function room_RepExec(){

cMuffy.FollowCharacter(cDanny);

}


Yeah, what Sslaxx said, show us the script.
Title: Re: FOLLOW_EXACTLY-related question
Post by: dbuske on Fri 19/11/2010 16:19:45
Heres the script:

cMuffy.FollowCharacter(cDanny);
Title: Re: FOLLOW_EXACTLY-related question
Post by: Sslaxx on Fri 19/11/2010 16:24:01
Quote from: dbuske on Fri 19/11/2010 16:19:45
Heres the script:

cMuffy.FollowCharacter(cDanny);

Are you saying that this is all the code you have done in this room? I mean the script for the entire room.
Title: Re: FOLLOW_EXACTLY-related question
Post by: dbuske on Fri 19/11/2010 16:26:39
Looks like a couple of guys fooling the new guy
Title: Re: FOLLOW_EXACTLY-related question
Post by: Sslaxx on Fri 19/11/2010 16:31:55
Quote from: dbuske on Fri 19/11/2010 16:26:39
Looks like a couple of guys fooling the new guy
Can the attitude, mate. Nobody's trying to fool you. Follow Matti's advice, take a look at the tutorial.
Title: Re: FOLLOW_EXACTLY-related question
Post by: dbuske on Fri 19/11/2010 16:34:13
I will go elsewhere.  I don't need to be made fun of.
Title: Re: FOLLOW_EXACTLY-related question
Post by: Matti on Fri 19/11/2010 16:39:56
Nobody is making fun of you (yet), but if your room script really just contains that single line, then you should do the tutorial.

And pay close attention to the events pane:

(http://img528.imageshack.us/img528/6959/thingies.png)
Title: Re: FOLLOW_EXACTLY-related question
Post by: Khris on Fri 19/11/2010 17:08:59
dbuske:
You have already acquired a record here of doing stuff that's frowned upon; within not ten posts you have asked several extremely basic questions that clearly show you didn't bother to read the tutorial that comes with AGS (which in turn means you didn't read or follow the rules of this forum), you also didn't go back to these topics, not even to mark them as solved, and you announced a game more than prematurely, again violating the forum rules in the process.
These forums are paid for by the guy who created the free engine you're using, and we help you here for free in our spare time. Keep that in mind in the future, if you please.

Regardless, what people posted here was in no way meant to make a fool out of you. For one thing, not all of us realized immediately that the one line was all you had in your room script, secondly you kind of stubbornly posted what you did several times without addressing anything that e.g. Matti replied.

These forums are extremely friendly and helpful towards newbies in general and I'd really be careful not to waste that right at the beginning.


With that out of the way, open the first room where Muffy is supposed to follow Danny, click the lightning bolt icon as shown in Matti's picture, then click on the line marked blue and finally on the ellipses button.
AGS creates a function called something like room1_AfterFadein(). Put the command inside the curly brackets that mark the beginning and end of the function body.

Next time you test run the game, as soon as you enter that room and the background has faded in, AGS calls that function and all the commands inside are executed, i.e. the one you just added.
Title: Re: FOLLOW_EXACTLY-related question
Post by: dbuske on Sun 28/11/2010 16:41:58
Thanks for the help Matti.
I am slowly figuring out the scripting.  Pointing me to the event button really helped.  Being new to all this, I just didn't understand even how to start doing scripting.
I am making good progress now.  I even got my dog character to follow the main playing character automatically.
Now I need to learn how to do the dialogs, music and sound.
If I want to ask for help for making all the dog character views (drawing them, front, back, sides), which forum do I do that.  Meaning getting someone to point me to maybe an already done dog character.
Title: Re: FOLLOW_EXACTLY-related question
Post by: Khris on Sun 28/11/2010 17:05:03
If you need help about drawing something, take a look at the Tutorials and the Technical art questions sticky threads in the Critics Lounge.

If you're looking for resources, there's a Contribution sticky thread in the Critics lounge where you can find free characters and other things.

If you have produced something and put some effort into it, looking for critics and suggestions, post what you drew in the Critics Lounge.

Here's a link to some other valuable information:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=14373.0