Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: kampfkaese on Fri 25/07/2014 21:08:09

Title: Scripting Problem: How to make Character following character before Roomchange
Post by: kampfkaese on Fri 25/07/2014 21:08:09
Hello!

I'm a total Newbie to the Scripting Language used in AGS ans i wanted to realise a Cat following the Character when he leaves the room.

My first Try:

Quote
function room_LeaveLeft()
{
  while(Kater.x!=cEgo.x)
  {
  Kater.FollowCharacter(cEgo);
  }
 
   
cEgo.ChangeRoom(2, 490, 395);
}

I must say a have really no Idea how to make it right and where to search in the Syntax Library, could somebody translate it into the right language? :D
Title: Re: Scripting Problem: How to make Character following character before Roomchange
Post by: Khris on Fri 25/07/2014 21:24:20
The manual doesn't state this specifically, but if you make one character follow another, they will automatically follow them into other rooms.
Just remove the while loop, you don't need it. And even if you did need it, calling FollowCharacter 40 times per second would have no effect. ;)
Title: Re: Scripting Problem: How to make Character following character before Roomchange
Post by: kampfkaese on Fri 25/07/2014 22:39:31
Thanks as far! I did it with normal Kater.walk() command! Works fine..
Thank you
Title: Re: Scripting Problem: How to make Character following character before Roomchange
Post by: kampfkaese on Sat 26/07/2014 13:27:43
Another Problem:

How can i make my Character moving to another? i Tried this with "character.x" but it wont work..

Quote

function Kater_Talk()
{
cEgo.Walk(Kater.x,  Kater.y);
cEgo.Say("... Naaa mein kleiner?");
cEgo.Say("...");
Kater.Say("*Miau*");
}


Title: Re: Scripting Problem: How to make Character following character before Roomchange
Post by: Cassiebsg on Sat 26/07/2014 15:59:16
I might be off, but if you still have the cat following the player, then every time the player moves, so will the cat and you never get to the cat's xy. Meaning that you need to tell the cat to stop following and then start following again after the talk.
Also try putting a wait() command between the walk and the say command, or the lines will happens before your character reaches the cat.

PS - You might also need another xy since the player can't exist in the exact same xy as the cat.
Title: Re: Scripting Problem: How to make Character following character before Roomchange
Post by: kampfkaese on Sat 26/07/2014 16:50:33
No thats another Problem. I want that the player walks in front of the cat when the User klicks on "Talk to cat"
Title: Re: Scripting Problem: How to make Character following character before Roomchange
Post by: Slasher on Sat 26/07/2014 18:08:49
If ever you need to stop a character following you need to use:

Code (ags) Select
Kater.FollowCharacter=null; // stops Kater following anyone.
cEgo.Walk(Kater.x,  Kater.y +20, eBlock,eWalkableAreas); // will make the character walk before anything and he will walk to just below and in front of the cat. Adjust Kater. y + [n] to position. Also, check out baselines.
Title: Re: Scripting Problem: How to make Character following character before Roomchange
Post by: Khris on Sun 27/07/2014 15:23:14
The Walk command is called only once, with the parameters being the values of Kater.x/y at that point in time, it doesn't cause the player to in turn follow Kater, should he move elsewhere before the player has reached her destination.
Still, you probably should look into the parameters of FollowCharacter (eagerness and distance) so you don't have to turn off following if the player approaches the cat.
Use what slasher suggested and offset the y position a bit, then use player.FaceLocation(). If Kater does move in between, turn off following by using Kater.FollowCharacter(null);