Walk to interaction fix

Started by Elliott Hird, Wed 19/10/2005 11:58:28

Previous topic - Next topic

Elliott Hird

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.

strazer

What are you talking about exactly? What fix?
Yes, please describe your problem further and post the code you're trying to use.

Elliott Hird

#2
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:
Code: ags

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.

Ashen

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?
I know what you're thinking ... Don't think that.

Elliott Hird

#4
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.

SSH

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);
}
12

Elliott Hird

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.

SSH

#7

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?
12

Elliott Hird


SSH

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
12

Elliott Hird

That's nothing to do with this. This allows me to set an interaction for Walk to on hotspots, instead of using reigons.

SSH

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...
12

Sam.

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?
Bye bye thankyou I love you.

Elliott Hird

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.

SSH

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?  :=
12

Elliott Hird

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.

SMF spam blocked by CleanTalk