Author Topic: One mouse mode interaction walking problem!  (Read 141 times)

One mouse mode interaction walking problem!
« on: 13 Feb 2018, 14:12 »
Hi guys, hope you can help me out!

I'm making a quick game for a friend, using an adaptation of the sierra template that comes with AGS 3.4 and wanted to really strip out all the interactions and have one mouse click handle everything. Initially I simply disabled everything except the walk function and thought I'd put all the interactions with hotspots, objects and characters into anyclick script and use conditionals to check if an item is being used and so on.

I then discovered that the walk mode doesn't appear to use the anyclick script and is its own entity, so ended up keeping interact, so I now have two mouse modes which I can swap between using a right click.

However, I wanted to have the inventory open with a right click and had really got myself set on just having one interaction mode, so I attempted to have the interact function also walk the character. I put a command in game_start forcing the cursor to interact mode (essentially disabling the walk mode) and tried this in the global script:

Code: Adventure Game Studio
  2. function on_mouse_click(MouseButton button) {
  3.   // called when a mouse button is clicked. button is either LEFT or RIGHT
  4.   if (IsGamePaused() == 1) {
  5.     // Game is paused, so do nothing (ie. don't allow mouse click)
  6.   }
  7.   else if (button == eMouseLeft) {
  8.     Room.ProcessClick(mouse.x, mouse.y, mouse.Mode);
  9.     player.Walk(mouse.x,mouse.y, eNoBlock, eWalkableAreas);
  11.   }

Initially it seemed fine - the cursor still interacts with my hotspots, and the character seemed to walk around, like I intended. However, something a little odd happens - the character walks fine in one direction, follows my clicks to the pixel, but if I turn the other direction, the character refuses to walk. He just takes a couple of half steps and won't go any further. He even walks in the opposite direction from my click! I've checked my walkable areas and they're all fine, tried starting him in a different room, and even returned the script to its previous state and the problem disappeared. One thing I noticed is that this only seems to happen in scrolling rooms. Is there something obvious I'm missing? Let me know if you have any ideas! Thanks guys.
« Last Edit: 13 Feb 2018, 14:15 by Duckbutcher »


    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: One mouse mode interaction walking problem!
« Reply #1 on: 13 Feb 2018, 14:20 »
You're passing screen coordinates into a function that expects room coordinates.

I'd also modify the code slightly:
Code: Adventure Game Studio
  1.   else if (button == eMouseLeft) {
  2.     if (GetLocationType(mouse.x, mouse.y) == eLocationNothing)
  3.       player.Walk(mouse.x + GetViewportX(), mouse.y + GetViewportY()); // eNoBlock, eWalkableAreas are the default values
  4.     else Room.ProcessClick(mouse.x, mouse.y, mouse.Mode);
  5.   }
« Last Edit: 13 Feb 2018, 14:22 by Khris »

Re: One mouse mode interaction walking problem!
« Reply #2 on: 13 Feb 2018, 14:32 »
Thanks a bunch, it's working great now. Cheers!