easy way to determine if the player has reached walk goal

Started by Rocco, Sat 05/09/2009 20:53:57

Previous topic - Next topic

Rocco

i have several rooms and walkable areas (hope the limit for them increases soon) in one game-room,
so i need an easy way to find out, if the player has reached his walking goal, to perform several actions,
otherwise the actions must be canceled.

Codeexample:
Code: ags

function oMoneybox_AnyClick()
{

  player.Walk(875, 655, eBlock, eWalkableAreas);
  player.FaceDirection(eDirLeft);
  
  
  if(mouse.Mode == eModeInteract) 
  {
   ..........................
       
  }  
  else if(mouse.Mode == eModeLookat)
  {
   ............................       

  }
  else if(mouse.Mode == eModeUseinv)
  {
   .............................. 
   }  
  else
  player.Say("Das funktioniert leider nicht.");

}



NsMn

The easiest way would probably be to make a custom function which saves the x and y coordinate in global variables, and then check player.Moving, player.x and player.y in repeatedly_execute.

Rocco

must be easier, cause with this approach i need to save and check thousands of walkpoints  :-\

NsMn

I'm afraid I don't understand your problem right... the coordinates which the player is supposed to walk to are the only ones which are checked...


Rocco

thx, Khrismuc - It works fine for the main task, but i get a negative sideeffect,
the normal walkmode dont work anymore.
the player only moves when i click on an hotspot, and not when i click in walking mode on the floor (with walkable area)

thx NsMn - with your approach i have to call an additional function every time when a hotspot or object is clicked, i want to avoid that.

Khris

The module does claim a left click, but it calls ProcessClick(mouse.x, mouse.y, mouse.Mode); when there's nothing there.
Try setting "Automatically move the player in walk mode" to true.

Rocco

bigthanks, works perfect.  :)

a little dirty tweaking, cause the character dont stand always on the exact position

Code: ags

function repeatedly_execute() {
  if (!__arrived && (player.x == tgx || player.x == tgx+1 || player.x == tgx-1) && (player.y == tgy || player.y == tgy+1 || player.y == tgy-1)) {
    __arrived = true;





alsothanks NsMn  :)

SMF spam blocked by CleanTalk