Easier walking

Started by Ethan D, Fri 17/07/2009 16:15:04

Previous topic - Next topic

Ethan D

Im trying to figure out how to make it so that when the play clicks on a walkable area with the interact, look at, or talk to interaction the player will walk there, this is so it will be easier for the player to move around and they wont have to change their icons as often.

Snake

You can open up the Any Click script and move the character to the mouse coords.
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

GuyAwesome

Walkable Areas don't have interactions, do they? Or am I misunderstand what you mean by 'the Any Click script'?

I think you'll need to alter the on_mouse_click function to act as if eModeWalkto was used in that case. For example

Code: ags

  if (button == eMouseLeft) {
    if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) ProcessClick(mouse.x,mouse.y,eModeWalkto);
    else ProcessClick(mouse.x, mouse.y, mouse.Mode);
  }


Should treat all mouse clicks not on an Object, Character, Hotspot or GUI as eModeWalkto clicks. You might want to add an extra check in there that the click was on a Walkable area (&& GetWalkableAreaAt(mouse.x,mouse.y) != 0), otherwise the character will try to get as close to the click as possible which could be more annoying than having to change modes - or even dangerous, depending on your game.

Another option is to have right-click act as a 'default' interaction (Walk-to if clicked on nothing, Talk-to Characters, Look-at Objects, Use Hotspots, etc).

Ethan D

I tried the code and it worked great but im not quite understanding what you mean by that it could be dangerous considering that it essentially just applies walkto to the other interactions right?

GuyAwesome

I was thinking 'dangerous to the player character' dangerous, rather than 'could introduce bugs' dangerous. Should've explained it better.
For example, if your game had interactions triggered by the PC walking over a region then having them start walking when the player didn't mean for them to would be frustrating to say the least - and if that accidental movement could cause the PC's death, would probably count as a good reason to stop playing the game and never go back. Provided the player knows that any click on an area they could reasonably walk to will make them walk there - or if your game doesn't have any @!*king annoying boobytraps in the first place :) - it's not really a problem.

Ethan D

Ok, I understand what you mean.  It shouldnt be a problem at all then.

Snake

Guy, I should have been more specific but I was in a hurry ;)

Float On, you can make a hotspot covering your walkable area. Then in the Any Click script move the character to where the mouse was clicked.
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

GuyAwesome

#7
Ah, OK. Happens to the best of us  ;)
For that matter, you could use hotspot[0]'s interactions - it covers every part of the screen not filled with another Hotspot, so you don't need to 'waste' one just for this. You'd still need to include the Walkable Area check, but otherwise that way would work fine. The one downside being, you'd have to add the interaction to every room...

EDIT:
Actually, could you use unhandled_event, in the Global Script, for this? You'd need to do a Hotspot.GetAtScreenXY check, but that's not too bad. I still prefer my way, though.

SMF spam blocked by CleanTalk