Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Elliott Hird on Wed 19/10/2005 11:58:28

Title: Walk to interaction fix
Post by: Elliott Hird on Wed 19/10/2005 11:58:28
Well, the fix needs fixing. It should work, but it doesn't. I've got a cursormode 8 non-standard and if it's walk to it's meant to walk to, then run the cursormode 8. Walk to is cursormode 0. Any ideas? I'll post the code or the compiled game if needed.
Title: Re: Walk to interaction fix
Post by: strazer on Wed 19/10/2005 16:09:42
What are you talking about exactly? What fix?
Yes, please describe your problem further and post the code you're trying to use.
Title: Re: Walk to interaction fix
Post by: Elliott Hird on Wed 19/10/2005 16:40:25
Not a fix, i'm attempting a workaround to walk-to interactions on hotspots with no reigons. what it is:
cursors
0 walk to
1 look at... (etc)
8 go to
9 nothing

here's on mouse click:

function on_mouse_click(MouseButton button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  // store mouse position in an int
  clickedy = mouse.y;
  clickedx = mouse.x;
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) {
    ProcessClick(clickedy, clickedx, mouse.Mode );
    if (mouse.Mode == eModeWalkto) {
      ProcessClick(clickedy, clickedx, eModeGoto);
    }
  }
  else {   // right-click, so cycle cursor
    mouse.SelectNextMode();
  }
}

Pretty self explanitory, what really happens is no interactions run (even with look, interact, etc!), and all walk to does is walks there and doesn't run the interactions.
Title: Re: Walk to interaction fix
Post by: Ashen on Wed 19/10/2005 16:58:10
What do you mean by "hotspots with no regions", and why do you need to work round them?

Anyway: for one thing (and this might just be here, if it's not a direct copy of the script), you're put clickedx and clickedy the wrong way round in the ProcessClick commands. AFAIK, that would cause a problem, as it'd be running (for example) ProcessClick(50, 160, mouse.Mode)[/i], when you clicked (160, 50) - i.e. not triggering the interaction of whatever you clicked on. If the hotspot has a walk-to point set, that may explain why you're still walking there, even though nothing else happens.

Could you post an example of the interactions (all modes) you've got for one hotspot?
Title: Re: Walk to interaction fix
Post by: Elliott Hird on Wed 19/10/2005 17:02:18
It works now, swapping x and y, but because I've made the walk non-blocking (of course) it runs the command first, THEN walks there. How could I work around this while still having it non-blocking? When they arrive there, I THEN want it to run the interaction.
Title: Re: Walk to interaction fix
Post by: SSH on Wed 19/10/2005 17:20:55
This should probably be in Beginners' Tech, but anyway.

What you need to do is :

in on_mouse_click:

store the value of player.ActiveInventory
store the value of mouse.Mode
store the x and y, as you do
set a flag variable to 1
make the guy walk to the right place

in repeatedly_execute:

if (player.moving==0 && flag==1) {
  flag=0; Processclick(stored x, stored y, stored mode);
}
Title: Re: Walk to interaction fix
Post by: Elliott Hird on Wed 19/10/2005 17:31:06
Hmm, mode doesn't need to be stored and the inv doesn't need to, but I was trying to avoid using rep_ex, but meh. Ok.
Anyway, got it working.
Title: Re: Walk to interaction fix
Post by: SSH on Wed 19/10/2005 17:47:19

What's wrong with rep_ex?

What if the player changes the inventory item and/or the cursor mode before the onscreen char reaches the walkto point?
Title: Re: Walk to interaction fix
Post by: Elliott Hird on Wed 19/10/2005 18:54:18
What would it change?
Title: Re: Walk to interaction fix
Post by: SSH on Thu 20/10/2005 07:47:49
Well, if a player clicked with the "look" mode on something, then while the char was walking to the object, changed mode to "interact", they might reasonably expect that the action performed on the object was "look" and NOT "interact". To do this, you must save the cursor mode.

Ditto, active inventory
Title: Re: Walk to interaction fix
Post by: Elliott Hird on Thu 20/10/2005 10:57:12
That's nothing to do with this. This allows me to set an interaction for Walk to on hotspots, instead of using reigons.
Title: Re: Walk to interaction fix
Post by: SSH on Thu 20/10/2005 13:21:02
You said:

Quote from: Elliott Hird on Wed 19/10/2005 17:02:18
It works now, swapping x and y, but because I've made the walk non-blocking (of course) it runs the command first, THEN walks there. How could I work around this while still having it non-blocking? When they arrive there, I THEN want it to run the interaction.

Therefore, I assumed that you wnted it to run the CORRECT interaction on completing the walking...
Title: Re: Walk to interaction fix
Post by: Sam. on Thu 20/10/2005 21:00:27
But as far as I was concerned, regions were used to REPLACE walk to interactions on hotspots, just seems a bit.. backward.

Walk to was never complicated though, isn't there an option on the interactions editor?
Title: Re: Walk to interaction fix
Post by: Elliott Hird on Thu 20/10/2005 21:12:37
sigh. Interactions is easier, cause of the fact that it only happens if you click Walk to ON the hotspot, not if you happen to cross the reigon. Plus it's easier in the editor.
Title: Re: Walk to interaction fix
Post by: SSH on Fri 21/10/2005 09:42:39
I think there's been some confusion between "Walk to" and "Player walks on to" here. But even after knowing that, I'm still confused: Elliott, can you re-explain your current problem, please... or is it fixed by now?  :=
Title: Re: Walk to interaction fix
Post by: Elliott Hird on Fri 21/10/2005 10:45:31
It's fixed. My code works, and if I make an interaction in the editor for my "Go to" mode, the player walks there non-blocking and then it performs the action. Yes, player stands on wouldn't work with floating hotspots, with this I could click a pixel under it and it wouldn't trigger it.