Reveal hotspots on key press

Started by Carles, Wed 02/08/2023 16:36:56

Previous topic - Next topic

Carles

It's very simple, how can I show all the hotspot labels of a room? For example by pressing the "H" key.

Thanks!

Nahuel

#1
I've just recently saw something around twitter from @CaptainD @Postmodern Adventures and @Kini Games conversation on twitter status Kini and CaptainD's statustalking about this module

MODULE: Hint Highlighting or github

For the 'H' key you just need to add that on

KEY_FOR_DISPLAYING_HINTS
Which key is bound to overlay displaying. Used only when USE_CUSTOM_HANDLING is set to false.

Maybe it helps.
Life isn't a game. Let's develop a life-like-game.

Carles

Thanks for showing me the link, it might help me.

Gal Shemesh

#3
It's so great to have good and talented members that make such modules!

Yet, I think that a dedicated adventure game engine like AGS should have such option built-in, even just by using a GUI label with an 'asterix' that would blink for a second at the center of each and every hotspot, object and character in the room, while pausing the game when it does. Like in Simon the Sorcerer 2:


I tried making a GUI for this purpose, with labels to cover all 49 hotspot slots, and just about enough to cover all objects and characters in a given room, and to position them while they're hidden when entering a given room before FadeIn, based on the existence of the elements they're related to.

The logic as far as I understand should first count the number of elements when entering a given room; that is the number of characters, hotspots and objects, and save them in a temporary variable for each element. Then, a for loop comparison should be built to cycle through each of the elements in the room and compare them with the labels name within the GUI. If there's a match, it should position the label at the center of its corresponding element.

I thought about using IDs for both elements and labels for the comparison, but this won't be consistent when using a single GUI with labels for all the 3 elements (Characters, Hotspots and Objects), as ID numbers are unique, and can't have the same ID number for different labels. So I thought about using the 'Name' property of the labels with a certain syntax name, following with number. And then it should be sliced to grab only the number in it, and then to convert it into an 'int' for the comparison to work.

An example of what I mean is something like this:

lblCharacter0 == 0: cCharacter --> this is character index 0
lblHotspot1 == 1: hHotspotID1 (starting from 1 since 0 is the Eraser) --> this is hotspot index ID 1
lblObject0 == 0: oObjectID0 --> this is object index ID 0

Then, when the 'hint' key is triggered, the hint GUI will show up, revealing all the labels that has an existence element in the room, make them blink for a second, and then set them to be hidden again and close the GUI; only labels that have their corresponding element existence in a given room will be triggered. All the rest should remain hidden and ignored.

I'm not an expect yet to make such logic in script - only have it in my head. Maybe someone else could take this idea and put it into an actual script logic. :)
Gal Shemesh,
goldeng

Khris

#4
Here's the module I wrote some time ago:
[link removed, see below]

Import it and call this in game_start:
Code: ags
  ShowHotspots.SetKey(eKeyH); // default key is space
  ShowHotspots.Enable();

Hold down the key to show hotspots and objects. It draws everything on the room background so doesn't require a GUI.

Gal Shemesh

#5
Thanks @Khris! Just checked that up. It's great! I'm new to modules, but I can see that it can also be modified within AGS which is awesome. :) I modified it to show a text string astertix based on Font0.

Is there a way to make it to also show a symbol and label for characters?
Gal Shemesh,
goldeng

Snarky

I haven't looked at the module, but in general you'd need to add something like this:

Code: ags
  for(int i=0; i<Game.CharacterCount; i++)
  {
    Character* c = character[i];
    if(c.Room == player.Room)
    {
      // Calculate the vertical center of the character
      ViewFrame* frame = Game.GetViewFrame(c.View, c.Loop, c.Frame);
      int hotspot_y = c.y - Game.SpriteHeight[frame.Graphic]*c.Scaling/200; // c.Scaling/100 gives scaling factor, divide by 2 to get midpoint

      // TODO: Display a hotspot indicator at (c.x, hotspot_y)
    }
  }

Khris

Here's a fixed version: https://drive.google.com/file/d/1QnSQz-qSLhTmkMyyroxRf7zAtyihp2_0/view?usp=sharing
It also shows characters now and works with scrolling rooms :P
And it detects the Tumbleweed GUI and uses the proper hotspot name without >x.

eri0o

I have a module named Arrow Select that could theoretically be used too, it's meant for selecting things using the keyboard but it has a feature that retrieves a list of things on screen that can be interacted with and you can iterate this list to show something graphically for the things you wish too.

I know some old AGS games also did this by simply having a hidden scree sized object where the interesting stuff has hardcoded drawings to point to it and then you can simply show or hide this with a keypress.

SMF spam blocked by CleanTalk