Interrupting movement with regions

Started by pmprog, Tue 19/10/2004 21:30:23

Previous topic - Next topic

pmprog

Okay, maybe I'm loosing it (some might argue I never had it) but-

Player A needs to cross region B to get to object C
If the player uses the "Interact" cursor on C, I need to get him to stop at B until (s)he does something. My code in the region

Code: ags

  // script for region2: Player walks onto region
  if( GetGlobalInt(0) == 0 )
  {
    StopMoving(MARTY);
    
    DisplaySpeech(MARTY, "Not Yet!");
    
    MoveCharacterBlocking(MARTY, 180, 160, 0); // Move player back
  }


However, this only activates after the player has reached object C. How can I prevent this from happening?

I tried RemoveWalkableArea to prevent the player getting close, but the player can still interact with the object from the other side of the room.

Any ideas on how to solve this?

Ashen

You could do away with region B, and work it into the "Interact with object C" command.
Code: ags

if (GetGlobalInt (0) == 0) { // thing hasn't been done
  MoveCharacterBlocking (MARTY, x, y, 0); // move towards object, but don't get there
  DisplaySpeech (MARTY, "Not Yet.");
  MoveCharacterBlocking (MARTY, 180, 160, 0);
}
else { // thing has been done
  //whatever
}
I know what you're thinking ... Don't think that.

Goot

#2
or

MoveCharacter(GetPlayerCharacter(),object x, object y);
while((character[GetPlayerCharacter].walking)&&(GetRegionAt             (character[GetPlayerCharacter()].x,character[GetPlayerCharacter()].y)==region#)){
Wait(1);
}
if(character[GetPlayerCharacter()].x</> a value ){//check if player is //near object
runscript for interacting with object
}
else{
display ("You can't get there yet.");
}


Disable the region to let them go to the object

pmprog

Cool. Thanks!

Ashen, code works a charm.

Goot, the code doesn't work. He walks right through. However, that was easy to fix, just needed an extra line added

Code: ags

if(character[GetPlayerCharacter()].x</> a value ){//check if player is //near object
runscript for interacting with object
}
else{
display ("You can't get there yet.");
StopMoving(GetPlayerCharacter()); // Prevent Moving
}

SMF spam blocked by CleanTalk