Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Thu 07/04/2005 04:24:10

Title: characters again [SOLVED]
Post by: on Thu 07/04/2005 04:24:10
is it possible to do something if the players WALKED into or on each other?
Title: Re: characters again
Post by: Scummbuddy on Thu 07/04/2005 04:49:15
you mean like...
----------------------
AreCharactersColliding
AreCharactersColliding (CHARID1, CHARID2)

Checks if character CHARID1 is touching CHARID2. This function just checks the base line of both characters, so that if one is standing a fair distance behind the other, it will not be marked as colliding. Returns 1 if the characters feet are touching, 0 otherwise.
Example:

if (AreCharactersColliding(EGO,MAN)==1)
   { colliding code here }

will execute the colliding code only if the characters EGO and MAN are colliding.
See Also: AreCharObjColliding, AreObjectsColliding, AreThingsOverlapping
Title: Re: characters again
Post by: on Fri 08/04/2005 02:06:15
yeah, something like that. i just wanted to have it so that the player character goes to a different room when 2 characters collide or touch.
and whats the colliding code?
Title: Re: characters again
Post by: Khris on Fri 08/04/2005 08:58:36
colliding code is the code that's executed if (AreCharactersColliding(EGO,MAN)==1)
You want to make the player character go to a different room, so:

if (AreCharactersColliding(EGO,MAN)==1)
  { NewRoomEx(room, x, y); }
Title: Re: characters again
Post by: on Fri 08/04/2005 15:03:38
ooohhh. okay. in the NewRoomEx is the Ex part for the number of that room that I want them to go in?
Title: Re: characters again
Post by: Scummbuddy on Fri 08/04/2005 15:37:59
why dont you check it out in the manual... just like youre supposed to do before posting. also searching the forums is the second step.

if you help yourself, you will be much more satisfied with your game.
Title: Re: characters again
Post by: on Fri 08/04/2005 22:25:07
does that go in the global script? if so, where?
Title: Re: characters again
Post by: NiksterG on Sat 09/04/2005 01:52:15
If you want to have it happen in every room, yes, then it would go under the global script. (under repeatedly_execute, I believe). However, if you want to have it happen only in one room, then it goes in that room's script under repeatedly_execute.
Title: Re: characters again
Post by: TerranRich on Sat 09/04/2005 03:12:07
The most commonly asked scripting question is "Where does it go?" And that's a question that only YOU can answer. Think about it for a minute. When do you want the code to run? Wouldn't it work the best when it's running all the time to check constantly to see if two characters are colliding? Thus, there is the repeatedly_execute function. Look it up in the manual. It's a great thing.
Title: Re: characters again
Post by: on Sat 09/04/2005 15:50:07
okay, now im stuck. i know where to put it now, but when i tested the game, it said that there was an error in the script. it was where the (room,x.y.) thing goes. i can't put any x and y coordinents in there because the room is a "hide player character" room. help?
Title: Re: characters again
Post by: Huw Dawson on Sat 09/04/2005 16:03:18
You CAN put co-ordinates there. The PC's just invisible.  :)
Title: Re: characters again
Post by: on Sat 09/04/2005 16:30:28
everytime i try it (in global or room script) it always says "unidentified if" or something like that. help?
Title: Re: characters again
Post by: Khris on Sat 09/04/2005 18:29:11
The full text of the error message would be helpful.
And post the bit of code the message is referring to.
Title: Re: characters again
Post by: on Sat 09/04/2005 19:03:30
 if (AreCharactersColliding(BRANDON,ONE)==1)
  { NewRoomEx(room5, x160, y120); }

Then when I test the game, it says:

There was an error compiling your script. The problem was:
In: 'Room script' Error (line 6): unidentified symbol 'y120'
Do you want to fix the script now? (Your room has not been saved)

This happens when I put that script thingie in repeatedly execute in that particuler room.
Title: Re: characters again
Post by: Khris on Sat 09/04/2005 19:36:30
Now we're talking ;)

use this:

if (AreCharactersColliding(BRANDON,ONE)==1)
Ã,  { NewRoomEx(5, 160, 120); }
Title: Re: characters again
Post by: on Sat 09/04/2005 19:51:03
it works! thanx man
Title: Re: characters again
Post by: TerranRich on Sat 09/04/2005 22:10:07
Yeah, that's one of the most basic rules of scripting. x160 doesn't mean anything to the engine. When you pass numbers, however, it knows what to do with the numbers you give to the function. Now it knows to place the character at 160 by 120 on the room "grid". x160 and y120 would be interpreted as variable names at the very least...I think.

Perhaps someone should make out an Intro to Programming generic fundamentals tutorial. That would help beginners of scripting greatly. AGS's scripting assumes you know the basics of programming fundamentals and at least maybe the syntax and formatting of C or C++. :)