Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Akatosh on Sun 18/02/2007 15:18:26

Title: Trying to script a special kind of character... [SOLVED]
Post by: Akatosh on Sun 18/02/2007 15:18:26
This character is supposed to be always in the same room as cEgo and at the co-ordinates (160, 100). I've already tried letting him follow cEgo with DISTANCE and EAGERNESS = 1 and putting

cCracker.x=160; cCracker.y=100;

in repeatedly_execute. It worked quite well... except that cCracker only enters cEgo's room after about 5 seconds pass, which is 5 second too much for what I'm wanting to use this character.

Also, I tried to manipulate the cCracker.Room directly, but unfortunately, it's read-only... so that doesn't work.

If I can't have this character changing the room the second cEgo changes it, I could work around this with a command like character.SayAtBackground, which unfortunately doesn't exist.

And ideas what I should be doing?

/EDIT: No, I can't use any RawDraw functions.
Title: Re: Trying to script a special kind of character...
Post by: GarageGothic on Sun 18/02/2007 15:24:28
Try putting this in the global script:

function on_event (EventType event, int data) {
   if (event == eEventEnterRoomBeforeFadein) {
      cCracker.ChangeRoom(cEgo.Room, 160, 100); 
      }
   }
Title: Re: Trying to script a special kind of character...
Post by: Akatosh on Sun 18/02/2007 15:27:51
Works just perfectly. Many thanks.  :)
Title: Re: Trying to script a special kind of character...
Post by: Gilbert on Sun 18/02/2007 15:28:30
Insteading of making him "follow" Ego and repeatedly "fixing" his coordinates, instead you may just put him into the same room as Ego and that coordinates whenever the room is changed.
You may do it via on_event(), so something like below in global script:
function on_event(EventType event, int data){
Ã, if (event==eEventEnterRoomBeforeFadein) Ã, cCracker.ChangeRoom(data,160,100);
}


Edit: GG beats me to that, my code is similar, but instead of using cEgo.Room I used data in on_event() which is besically the same thing, unless cEgo is not always the player character.
Title: Re: Trying to script a special kind of character...
Post by: Ashen on Sun 18/02/2007 15:30:29
GG's way is probably best, and just forget about FollowCharacter (like Gilbot said, since you're 'fixing' cCracker's locaton in rep_ex anyway, you don't actually need it).
But for future reference:

Quote from: TheManual
game.following_room_timer
How long to wait before following char emerges in new room, default 150. (higher is longer)

Set it to 0, and the following char will appear at the same time as Ego.
Title: Re: Trying to script a special kind of character... [SOLVED]
Post by: Akatosh on Sun 18/02/2007 15:33:12
Hm... okay, I didn't remotly think of looking under game.variables for a FollowCharacter problem  :=

Again, thanks everyone... and I'll keep that in mind, Ashen.