Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: newwaveburritos on Thu 22/07/2021 19:11:04

Title: Disabling "walk to" clicks but not "interact" clicks [SOLVED]
Post by: newwaveburritos on Thu 22/07/2021 19:11:04
I've been screwing around with this for a few hours now and I'm close to a solution but I haven't quite nailed it yet.  I have a bar in the game where the character will sit and while the character is seated I want the player to be able to click on any hotspot in the room but I do not want the player to be able to walk anywhere and right now any click around that does not fire a hotspot will take the player back to the first frame of the sitting at the bar view and try to walk there.  I'm using the BASS template.  I know that this has something to do with putting a ClaimEvent() somewhere but I can't seem to put it in the right spot.  All I really want to do is not have the player try to walk anywhere until they stand up. but I think I might be calling things in the wrong spot.

Code (ags) Select
function on_mouse_click(MouseButton button) {
  if (!SittingAtBar) return; // -> exit function here
  if (mouse.Mode == eModeWalkto) {
    ClaimEvent(); // prevent standard click handling, nothing further will happen
}


This just makes it so no click works and you can't actually click on anything.  SetGameOption(OPT_NOWALKMODE, 0)
  Mouse.DisableMode(eModeWalkto) aren't working for me either, probably because I need to use them in conjunction with the ClaimEvent()?  It's the click processing done by the scripts further down the chain that I think are giving me problems.

I was using a workaround by making a GUI that was really just intercepting all the clicks and just put buttons over where the other characters were sitting but that wasn't ideal because I realized I would need to make a separate GUI for each permutation of characters at the bar and also this got rid of the Action Bar which was a bit weird so I decided to actually solve the problem instead of using GUI buttons to workaround everything.  Thanks again, everybody!
Title: Re: Disabling "walk to" clicks but not "interact" clicks
Post by: Cassiebsg on Thu 22/07/2021 20:25:24
Yes, you can claim the event and just do not process the walk click.
I would probably just go on to Gloabal script, locate the on_mouse_click function, and for the walkto code, just add a
Code (ags) Select

if (SittingAtBar) return;  //do noting, or break to end the function...
else processclick...


But claiming the event would probably be more elegant... 
Title: Re: Disabling "walk to" clicks but not "interact" clicks [SOLVED]
Post by: newwaveburritos on Fri 23/07/2021 04:25:45
This works perfectly and doesn't complicate anything.  Thanks so much!

...now I guess I should go disassemble that weird GUI...   :-[
Title: Re: Disabling "walk to" clicks but not "interact" clicks [SOLVED]
Post by: Khris on Fri 23/07/2021 08:06:19
Doing this in the global script instead doesn't make much sense to me.

The BASS template uses a two button interface, which basically means you don't check for eModeWalkto but a left click on an empty spot.
So you would need something like:

Code (ags) Select
function on_mouse_click(MouseButton button) {
  if (!SittingAtBar) return;
  if (button == eMouseLeft && GetLocationType(mouse.x, mouse.y) == eLocationNothing) ClaimEvent();
}
Title: Re: Disabling "walk to" clicks but not "interact" clicks [SOLVED]
Post by: newwaveburritos on Fri 23/07/2021 16:11:36
This also works. 

Quoteyou don't check for eModeWalkto but a left click on an empty spot.

This is what I missing and couldn't wrap my brain around.  Thanks for the help.