Scripting Problem: How to make Character following character before Roomchange

Started by kampfkaese, Fri 25/07/2014 21:08:09

Previous topic - Next topic

kampfkaese

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

Khris

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. ;)

kampfkaese

Thanks as far! I did it with normal Kater.walk() command! Works fine..
Thank you

kampfkaese

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*");
}



Cassiebsg

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.
There are those who believe that life here began out there...

kampfkaese

No thats another Problem. I want that the player walks in front of the cat when the User klicks on "Talk to cat"

Slasher

If ever you need to stop a character following you need to use:

Code: ags
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.

Khris

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);

SMF spam blocked by CleanTalk