MODULE: CancellableWalk 1.3

Started by Danvzare, Fri 20/09/2024 15:09:20

Previous topic - Next topic

Danvzare

This is a simple function that I use in all of my games, that allows you to easily cancel out of a walk.
I've tried to make it as generic as possible, so that it'll work in any project without any effort on your part. But it was originally adapted from code from a 9-Verb template, and I have mostly only used it in a BASS template, so you'll need to let me know if there are any issues. But from my tests, it seems to work just fine in the Sierra template.

It provides two functions: bool move_player (int x, int y, WalkWhere walkableArea) and bool walk_face(int x, int y, CharacterDirection faceDirection, WalkWhere walkableArea)
The walkableArea variable is completably optional, and is only there if you want the player character to walk over a non-walkable area. I can't think of a reason why you would want to, since if you cancelled out of it, you'd probably end up stopping in a non-walkable area. But it's there if you want it, and can be completely ignored if you don't want it.

Module supports AGS 3.3.0 and higher (might support lower, but I haven't tested it)

>>DOWNLOAD MODULE HERE<<
>>ALTERNATIVE MIRROR<<

USAGE:
Just use the new move_player function in a similar way to how you would the Walk function, but in an IF statement.
Code: ags
if(move_player(140, 140))
{
  player.Say("The door is locked.");
}

The new walk_face function is used in the same way, but you must also include the direction you want the character to face after reaching their destination.

If you want the OverHotspot functionality to work while in this cancellable state, there is one line of text "actionText = null;" in the game_start function which needs altering. You just need to replace null with the name of the gui element you use for said functionality.

If you have an animated wait cursor, then find waitModeView = -1  and replace -1 with the view number your wait cursor uses for its animation. If you don't have an animated wait cursor, this value can be safely ignored.

Limitations:
Animated cursors will not animate while in a cancellable state.
Requires all cursors that are used in the game, to have the same HotspotX and HotspotY as one another.



History:
1.0:
Initial release.

1.1:
Just fixed a minor bug involving the inventory icon messing up the cursor sprite. I accidentally introduced the bug while genericifying the code related to the cursor sprites, just before I released the module. Sorry about that.

1.2:
You no longer have to be at the pinpoint exact coordinates, which should fix any slight problems that might occur with the pathfinding. (The tolerance level can be set to whatever you want, by default it's at 2 pixels from the coordinates, but you can set it to 0 if you want exact coordinates only again.)
You also no longer have to set the interface to display normally during a pausing event in the global settings. You can have it be set to whatever you want now.
Only a single line of code (line 17 to be exact) now has to be altered to get the OverHotspot label working, as opposed to three lines in the previous release.
I also added an option to have the player walk over non-walkable ares if you want, as well as a new walk_face function, which walks to the location and then faces in the correct direction, just like the GotThere module.

1.3:
Firstly, I made the module compatible with AGS 3.3.0 and presumably older. You see the previous version broke compatibility with that new walk_face function, so I fixed that. I wouldn't recommend using such an old version of AGS, but if you are, you probably have your reasons, and there's no reason why this module shouldn't be compatible with the older versions. So that's why I fixed that.
Secondly, I fixed a problem where the module didn't work correctly if you had an animated wait cursor. Now it'll function as normal, although you will have to tell the module what view your animated wait cursor is using.
I probably won't be updating this again anytime soon, because I can't think of anything else that needs to or could be improved. So enjoy.

Crimson Wizard

I believe there's a module which does precisely same thing:
https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-gotthere-0-5/

maybe there are differences in how it handles secondary issues, like over-hotspot labels and such, but i never investigated that.

Danvzare

Quote from: Crimson Wizard on Sat 21/09/2024 20:29:18I believe there's a module which does precisely same thing:
https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-gotthere-0-5/

maybe there are differences in how it handles secondary issues, like over-hotspot labels and such, but i never investigated that.
I literally downloaded that module and plopped it into the BASS template just before I uploaded this one, and it didn't work. (Not without some modifications.)
So I personally think my version is better in terms of adaptability.
Although with that all being said, there are some clear limitations that mine has, that I'm going to try and iron out if possible.

SMF spam blocked by CleanTalk