How to use only one cursor? (sierra template)

Started by skooperstooper, Tue 02/08/2022 12:44:18

Previous topic - Next topic

skooperstooper

I found threads for this but those users were way past where I'm at. I need to understand this from the ground up. Inventory can stay how it is. I want the game to use one cursor with this behavior:

- When you hover over an object, hotspot or character, it shows their name. 
- When you click on an object, hotspot or character, it interacts.

How it interacts depends on the thing. If it's a character, you'll talk to them. If it's a hotspot, a description will appear. If it's an object, you'll either take it or use it. I get how to script these things individually but I don't know how to do this globally.

1) Is all of this handled in the global script?
2) Which part of this can be done just by changing the built-in cursor mode settings?

I saw a thread mention setting standard mode to false for cursors you don't want. I see it removes that cursor from the list player cycles through. Is that all it does? I want to tackle this with my own custom cursor but I don't want to waste time so I'm asking about it first.

Thanks!

Bookmarked
https://adventuregamestudio.github.io/ags-manual/EditorCursor.html
https://adventuregamestudio.github.io/ags-manual/Mouse.html
Yes, I did the tutorial, went through the manual, and searched the forums and web. If I'm asking, it's because I missed it, forgot, or still don't get it.

heltenjon

Frankly, it sounds like you are better off using the BASS template, if your aim is to avoid cycling through options. BASS (Beneath a Steel Sky) uses left click to walk and interact and right click to look as standard, though it's easy to set up to use any click as well.

When you make a hotspot, object or character, you see a Properties panel down to the right. You can edit the "Name" to get the script name you want, and the "Description" to toggle what appears on screen when you hover the cursor over it. Then you may use the action panel (the lightning bolt) to choose what happens with any click, left click, right click or using inventory items on the hotspot/object/character. You may start a dialogue, change room, pick up the item or whatever you choose.

When you do it like this, you will automatically be placed in the correct script. Objects and hotspots go in the room script because they are set inside that particular room, while the characters and inventory items will be put in the global script. (I think, I've never actually checked, but that seems logical.)

It seems from what you write, that "Any click on hotspot" is the option you're looking for.

skooperstooper

#2
Thanks! I already started with the Sierra template because I like the overall function of it and can see how some things would work. I just know I don't want to use the cursor cycling this time. I'll load up another test game with the BASS template to compare the two.

I already know how to do the things you mentioned. It's the global control to dictate the cursor's behavior depending on what you're hovering/clicking on that I was asking about. The manual said some cursor modes are hard coded and I can tweak the rest, but I didn't know how much I could tweak from the global script alone.

Since I'd want it to behave the same for all hotspots, for example, I thought I could set up a global cursor behavior that dictates what happens when interacting with any hotspot. But I realized I'd still have to define it in the rooms anyway unless I want the output to be the same in every case too.

Because the global script could say "when clicking any hotspot, display its blurb", but the game wouldn't know what that blurb says without me defining it for each individual hotspot anyway.

Basically, apart from using only one cursor, I was trying to think of a way to reduce the amount of scripting by not defining every single mouse action and instead just assigning output to variables and having a global script call the variable.

I'll just bookmark this thread and try what I was thinking and post the code when I'm done with it because how I describe what I'm trying to do never comes out right lol Thanks again!
Yes, I did the tutorial, went through the manual, and searched the forums and web. If I'm asking, it's because I missed it, forgot, or still don't get it.

Snarky

#3
AGS was originally designed, more than twenty years ago, to make Sierra-style games, and that means some Sierra UI functionality is built into the engine, while doing anything different requires you to do it yourself in scripting. The different mouse modes is one of those built-in things, with some of them ("Walk," for example) hard-coded to do a particular thing. But of course you don't have to use it, you can use one mouse mode throughout; it just means you have to define for yourself what happens when you click.

It's not that hard to adjust the Sierra template to do what you want, and it's useful practice to learn how AGS and the game templates works. You can take a look at the BASS template to help you figure it out, but again, it's not particularly complex.

Basically, disable all the cursor modes except Interact, and look through the code in the GlobalScript, particularly function on_mouse_click(). Take out the bits that cause it to change mouse modes on right-click, and the handling of the other mouse modes. (There might also be similar code in on_key_press() to handle keyboard shortcuts.)

Then for anything you click on/interact with in the game, you just have to provide an interact event handler (using the events pane). In that handler you define what happens, whether it's providing a look-at description, starting a conversation, picking it up or whatever.

Keep in mind that you still need to handle walking (usually this is done in on_mouse_click() after testing that the mouse is not over any hotspot/object/character), using inventory items (so you probably want to keep that mouse mode as well), and interacting with the inventory (you might therefore need to keep the examine mode too, if you stick with the Sierra-style inventory). And you need to decide how to switch from inventory item mode to normal interaction mode (the BASS approach is to use right-click to deactivate inventory item mode).

For the "name on mouseover" effect, see the BASS template. (The code is probably in function repeatedly_execute(), using GetLocationName().)

Matti

#4
In my current project I'm doing something similar. I think I started it with an empty template.

In the game_start() section of the global script I set mouse.Mode = eModeInteract;

In the on_mouse_click function I have this (amongst other things):

Code: ags
  if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
  {
  }

  // Left click = walk/talk/interact
  else if (button == eMouseLeft) 
  {
    if      (player.ActiveInventory != null)                          Room.ProcessClick(mouse.x,mouse.y, eModeUseinv); // use item
    else if (GetLocationType(mouse.x, mouse.y) == eLocationHotspot)   Room.ProcessClick(mouse.x,mouse.y, eModeInteract); // interact with hotspot
    else if (GetLocationType(mouse.x, mouse.y) == eLocationObject)    Room.ProcessClick(mouse.x,mouse.y, eModeInteract); // interact with object
    else if (GetLocationType(mouse.x, mouse.y) == eLocationCharacter) Room.ProcessClick(mouse.x,mouse.y, eModeTalkto); // talk to character
    else    Room.ProcessClick(mouse.x,mouse.y, eModeWalkto); // walk
  }

Not sure if this is the best way to do it and I'm also not sure how much you would have to change the sierra (or bass) template to do this. But I think it should give you an idea.

I created a label called l_Hotspots and put this in the global script's repeatedly execute function to show the name of the things the cursor is hovering over:
Code: ags
l_Hotspots.Text = Game.GetLocationName(mouse.x, mouse.y);

skooperstooper

Thanks Snarky and Matti for the input! I'll post here when I get things running how I want. It'll be easy to test and get feedback on where I went wrong since I'm doing all of this practice with just two rooms before jumping into anything more complex.
Yes, I did the tutorial, went through the manual, and searched the forums and web. If I'm asking, it's because I missed it, forgot, or still don't get it.

SMF spam blocked by CleanTalk