Problem with walk-to points + Global Pause

Started by alkis21, Thu 21/06/2007 22:19:42

Previous topic - Next topic

alkis21

My 'Exit' system works this way:

Say there's an open door in the room. I draw a region around the door to make sure that the Walk cursor will change to an Exit icon, and a hotspot around the same area. I then add a walk-to point to the hotspot to make sure that my character will always walk to the hotspot (and the region) and exit the room when you click on the hotspot.

My problem is that I don't want my character to walk to the hotspot when you click on it with a different cursor (use, talk or inventory). No matter how I try to adjust the code, adding player.StopMoving() or other functions I can think of the player always moves to hotspots that have a walk-to point when you click on them. How can I stop this from happening?

My second question is, is there any way to pause a dialog by pressing a key?

Khris

#1
Simply don't use walk-to points.
In the door hotspot's "any click on" interaction, use something like this:
Code: ags
  if (mouse.Mode==eModeWalk) {
  player.Walk(x, y, eBlock);
  player.ChangeRoom(...);
}


You could even automate the whole process by using Custom properties; for every exit hotspot, enter the walk-to coords (x default: -1) and the ChangeRoom's three parameters, then in on_mouse_click/eMouseLeft:

Code: ags
  Hotspot*h=Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  if (mouse.Mode==eModeWalkto && h!=hotspot[0] && h.GetProperty("x")!=-1) { 
    player.Walk(h.GetProperty("x"), h.GetProperty("y"), eBlock);
    player.ChangeRoom(h.GetProperty("r"), h.GetProperty("rx"), h.GetProperty("ry"));
    return;
  }
  ProcessClick(...);


Small edit in code.

Ashen

'Any click' interactions aren't triggered by eModeWalkto, AFAIK, unless you've checked the 'Don't automatically move character' option. That means you'll have to add a line to on_mouse_click to handle eModeWalkto, but coupled with not using Walk-to points for exit hotspots it's still probably the easiest way.
I know what you're thinking ... Don't think that.

alkis21

#3
Thanks for the answers guys.

Quote from: Ashen on Fri 22/06/2007 00:15:42
'Any click' interactions aren't triggered by eModeWalkto, AFAIK, unless you've checked the 'Don't automatically move character' option.

My thought exactly... I had tried it.
So if I understand correctly, there is absolutely no way of preventing the character from moving to a hotspot that has a walk-to point?

QuoteThat means you'll have to add a line to on_mouse_click to handle eModeWalkto, but coupled with not using Walk-to points for exit hotspots it's still probably the easiest way.

And what would that line be?  ???

Khris, doesn't your 2nd code need FaceLocation parameters as well? And what is the ProcessClick(...) function about?

Do you by any chance have anything to suggest regarding my second question in the 1st post?

Khris

ProcessClick() is the default line for a left mouse click.

Quote from: alkis21 on Fri 22/06/2007 07:12:43So if I understand correctly, there is absolutely no way of preventing the character from moving to a hotspot that has a walk-to point?
That's right. Using Hotspot.RunInteraction instead of ProcessClick doesn't make a difference, the player will still walk to the walk-to pint first.

FaceLocation should go into the new room's "player enters screen (before fadein)".

Pausing dialogs:
I've tried it using this:
Code: ags
function key_down;

function repeatedly_execute_always() {
  if (IsKeyPressed(32)) key_down=1;
  if (!IsKeyPressed(32) && key_down) {
    key_down=0;
    if (IsGamePaused()) {
      UnPauseGame();
      gPause.Visible=false;
    }
    else {
      PauseGame();
      gPause.Visible=true;
    }
  }
}


It sort of works. You can't pause the game while the dialog GUI is displayed, though.
In my example, the space bar is used to pause the game. After I've used
Code: ags
  game.skip_speech_specific_key='.';
in game_start, pressing space didn't skip speech any longer before pausing.

alkis21

#5
That looks correct... I'll try it when I go home. I wonder if it will pause voices in mid sentence?

Quotethe player will still walk to the walk-to pint first.

Who can blame him? If there were pints of beer near me, I'd walk to them too. :)

What about the line in on_mouse_click  Ashen mentioned?

Khris

The second code snippet in my first reply is meant to go into on_mouse_click, so another line in there won't be necessary, unless I'm missing something.

alkis21

In your 'Pause' code, shouldn't "function key_down;" be int or bool instead of function?

Khris

Heh, right, although it doesn't make a difference. function is essentially the same as int.

alkis21

The "walk to hotspot" script works perfectly.
I used the Properties idea of your script, without the player.ChangeRoom function though. I prefer to stick to Regions for that, as sometimes I have more conditions in Regions.

Your Pause script pauses the game, but not the voices I'm afraid. :( I guess there is no way of doing that?

SMF spam blocked by CleanTalk