GotThere problem, still works?

Started by Chomba, Sat 04/03/2023 22:13:03

Previous topic - Next topic

Chomba

Hello people,

today I bring you something from the past (2008), but I was looking for a way to be able to interrupt the walk eblock for when you are going to do some interaction/look at specific coordinates and cancel the action if you want to. I found that the solution would be Khris's GotThere module... although it's been around for a while.

Anyway, I downloaded it, imported the script and tried to use it according to Khris' instructions in this forum topic. But I get an error.

The instructions:


The error:


(you can download the module from here):

https://www.adventuregamestudio.co.uk/forums/beginners-technical-questions/eblock-enoblock-and-looking-at-an-object/msg477380/#msg477380

Also keep in mind that I'm using AGS 3.6 - BASS template, and this is from.... I don't know which version, but I don't think that's the problem.
Any ideas? Can this be solved or is it because the script is obsolete by now?

eri0o

Looking at the module code "GotThere" just means you have to code your check for whatever means that character is there.

Example

Code: ags
// module header

import bool IsInPosition(this Character*, int x, int y, int pad = 2);

Code: ags
// module script

bool IsInPosition(this Character*, int x, int y, int pad)
{
  return (this.x > x - pad) && (this.x < x + pad) && (this.y > y - pad) && (this.y < y + pad);
}

and then use this to check if the character is in position.

Khris

I rewrote the module to make it easier to use; since I kept updating the Google Drive file which to my knowledge retains the share link, you've probably ended up with the latest version but outdated instructions.

Here's the latest thread:
https://www.adventuregamestudio.co.uk/forums/beginners-technical-questions/graphicalfunctional-questions-for-cmi-style-guiinventorymenus/msg636639852/#msg636639852

In short you need:
Code: ags
  if (WalkFace(123, 45, eDirectionLeft)) {
    // what happens when the player reachers those coordinates goes in here
  }

eri0o: the module doesn't just check for a character's position, it also runs the interaction as soon as they arrive at the target coordinates.

Chomba

Thanks for the answers,
I downloaded the version you posted now and use the code as in the example, but it still doesn't work.



The character walks to the position, but does not execute the command.
I also tried the "look" function, only here it didn't even walk to the coordinates. If I clicked to look with the character standing still, it would directly say its phrase, but if I made the character walk (to any side) and clicked to look while doing it, it would walk to the coordinates of the code, but it wouldn't execute the final action either. Very strange...

Could it be that there are incompatibilities of the code with AGS version 3.6 directly? Am I doing something wrong? I'm testing all this in the BASS template demo game.

Khris

Yeah, I did the same test and noticed that the BASS template uses the walk-to cursor for everything for some reason. The mode used doesn't matter for the BASS code but the GotThere module relies on a proper cursor mode being used.
The solution is to simply run mouse.Mode = eModeInteract; in game_start.

Chomba

Great! it worked for when the action is "interact", but if the function is "look" it doesn't walk to a certain place to wait to say the assigned phrase. I guess it's intended for interact actions only and the "look" thing can still be handled as usual.

Khris

The problem with the BASS template is that it doesn't rely on cursor modes, it calls the correct interaction based on what was clicked and the button that was used.
My module was built for the Sierra template, i.e. is completely based on cursor modes. It should be relatively simply to re-write for the BASS interface. Or to amend the BASS code to use the actual cursor modes.

Chomba

QuoteMy module was built for the Sierra template

That explains it all! Well, it's still great to have it running somehow. It'll come in handy for when I do a singleclick type game. :D

Thanks again Khris!

Khris

#8
I managed to find a solution for this that so far, seems to work:

1. Move TwoClickHandler above the GotThere module in the script tree (drag and drop the former on the latter)

2. Open the GotThere script and change the first line (31) of on_mouse_click to
Code: ags
  if (button == eMouseLeft || button == eMouseRight) {

3. Open the TwoClickHandler script and find the do_room_action function's first and main if block. In there, whenever it says Room.ProcessClick(mouse.x, mouse.y, eModeSomeMode);, replace that with just setting the mode instead, i.e. mouse.Mode = eModeSomeMode; (should be lines 126, 131 and 139).

4. Assign a cursor image to the interact and look cursors.


What happens is the BASS code now only changes the mode according to the type of click, but the actual click is now processed by GotThere. I haven't tested it thoroughly though.

Chomba

Ok, I applied it!
I had to delete the "i.e" because it took them as "undefined token" and change the eModeSomeMode to eModeLookat. Now it does all the functions well.

The only problem now is that (using the BASS demo) when I use an object with the hotspot, instead of doing the action defined for it (an unhandled_event), it performs the lookat action.
I didn't test assigning an action to use that item in that hotspot because I tested it in a free time. I will do more tests later.

Khris

"i.e." is an expression meaning "in other words", it was not part of the code obviously  :-D

And eModeSomeMode was a fictional generic mode illustrating you were supposed to use the mode from the Room Click command.

Anyway, using an inventory item with a hotspot works fine for me (I guess that's what you meant?) but one should probably insert a ClaimEvent() at certain places into do_room_action to prevent the click from also triggering the GotThere code.

For instance if you have an active inventory item, the mouse is over a hotspot and you right-click, what's supposed to happen? Should that always deselect the inv item, then do nothing further? Or still trigger a look at?

SMF spam blocked by CleanTalk