characters again [SOLVED]

Started by , Thu 07/04/2005 04:24:10

Previous topic - Next topic

waffle

is it possible to do something if the players WALKED into or on each other?

Scummbuddy

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
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

waffle

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?

Khris

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

waffle

ooohhh. okay. in the NewRoomEx is the Ex part for the number of that room that I want them to go in?

Scummbuddy

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.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

waffle

does that go in the global script? if so, where?

NiksterG

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.
Check out my games! (Not all made with AGS)

TerranRich

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.
Status: Trying to come up with some ideas...

waffle

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?

Huw Dawson

You CAN put co-ordinates there. The PC's just invisible.  :)
Post created from the twisted mind of Huw Dawson.
Not suitible for under-3's due to small parts.
Contents may vary.

waffle

everytime i try it (in global or room script) it always says "unidentified if" or something like that. help?

Khris

The full text of the error message would be helpful.
And post the bit of code the message is referring to.

waffle

 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.

Khris

Now we're talking ;)

use this:

if (AreCharactersColliding(BRANDON,ONE)==1)
Ã,  { NewRoomEx(5, 160, 120); }

waffle


TerranRich

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++. :)
Status: Trying to come up with some ideas...

SMF spam blocked by CleanTalk