if character is on x, y ?

Started by YotamElal, Mon 28/02/2005 14:22:59

Previous topic - Next topic

YotamElal

is there a script

if (character is on screen co-ordinates x,y){

Rui 'Trovatore' Pires

You mean like "character[EGO].x"? (rt[f]m)
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

strazer

Character.x and .y are room coordinates, not screen coordinates.
To check if a character is at a certain position on the screen, do:

Code: ags

  if ((character[CHARID].x - GetViewportX() == THEXCOORD) && (character[CHARID].x - GetViewportY() == THEYCOORD) {
    // do stuff
  }


If you're referring to his position in the room, remove GetViewportX/Y.

YotamElal

I tried to use character[EGO].x 
& character[EGO].y
but it didn't work.

I have a character walking around from spot to spot in the repeated actions of the room.
I want the character to say a word each time a path is finished.
Here is my code:
PlZHlP

  if (character[FRA].walking == 0) {
   MoveCharacter (FRA, 163, 210);
   MoveCharacterPath (FRA, 229, 219);
   MoveCharacterPath (FRA, 167, 234);
   MoveCharacterPath (FRA, 167, 216);
   MoveCharacterPath (FRA, 121, 207);
   MoveCharacterPath (FRA, 121, 236);
  }

I tried to add....

if (character[FRA].x==229){
if (character[FRA].y==219){
DisplaySpeech(...)}
}
if (character[FRA].x==167){
if (character[FRA].y==234){
DisplaySpeech(...)}
}

but it didn't work.. :o(

DoorKnobHandle

It would be alot easier to use this then:

Code: ags

if (character[FRA].walking == 0)
{
   MoveCharacter (FRA, 163, 210);
   DisplaySpeech (...);
   MoveCharacterPath (FRA, 229, 219);
   DisplaySpeech (...);
   MoveCharacterPath (FRA, 167, 234);
   DisplaySpeech (...);
   MoveCharacterPath (FRA, 167, 216);
   DisplaySpeech (...);
   MoveCharacterPath (FRA, 121, 207);
   DisplaySpeech (...);
   MoveCharacterPath (FRA, 121, 236);
   DisplaySpeech (...);
}

YotamElal

i tried that before...

all the speehes are displayed before the first path and then they arn't displayed at all!!!???!?

strazer

#6
mamarulez:
The MoveCharacterPath commands buffer the walking commands, they are not blocking, therefore your suggestion won't work.

YotamElal:
Each time the character finishes a path, he is still considered moving.
When a character is moving, for performance reasons the pathfinder can give slightly inaccurate results for the character's coordinates, so it may not be possible to do it your way.

Try this:

Code: ags

function room_a() {
  // script for room: Repeatedly execute

  if (character[FRA].walking == 0) {

    if (character[FRA].x == 163 && character[FRA].y == 210) {
      DisplaySpeech(FRA, "Finished 1st path.");
      MoveCharacter(FRA, 229, 219);
    }
    else if (character[FRA].x == 229 && character[FRA].y == 219) {
      DisplaySpeech(FRA, "Finished 2nd path.");
      MoveCharacter(FRA, 167, 234);
    }
    else if (character[FRA].x == 167 && character[FRA].y == 234) {
      DisplaySpeech(FRA, "Finished 3rd path.");
      MoveCharacter(FRA, 167, 216);
    }
    else if (character[FRA].x == 167 && character[FRA].y == 216) {
      DisplaySpeech(FRA, "Finished 4th path.");
      MoveCharacter(FRA, 121, 207);
    }
    else if (character[FRA].x == 121 && character[FRA].y == 207) {
      DisplaySpeech(FRA, "Finished 5th path.");
      MoveCharacter(FRA, 121, 236);
    }
    else {
      DisplaySpeech(FRA, "Finished last path / Starting.");
      MoveCharacter(FRA, 163, 210);
    }

  }

}


Edit: Fixed DisplaySpeech command.

YotamElal


SMF spam blocked by CleanTalk