I've made a fair amount of progress with my first game but have run into a wall scripting the inventory I'd like to make.
Rather than the standard 'walk', 'use', 'look' pointers, I'd like to have just two pointers: a standard one and one to show that you are selecting an object or hotspot. This much I've done already.
Then, clicking on an object or hotspot will bring up your inventory window which will have buttons for 'look' 'use' (and 'talk'). I can make the GUI fine, but am having trouble making the buttons run the interactions differently for each object / hotspot.
Can anyone help or direct me to a thread which explains this? (I haven't been able to find one)
Thanks!!!!!!!
The basic idea is to store the coordinates of the click, then have your button call ProcessClick(stored_x, stored_y, button_action).
(It sounds like you're using the word inventory wrong; the player's inventory is the collection of items she has in her possession. What you are talking about is a verb coin. Or are you talking about using items on hotspots in addition to the verb buttons?)
Yes, I understood it as bringing up a Sierra-type inventory upon clicking on an object. IIRC, Five Days a Stranger had a similar UI (at least in the original version). Personally I didn't like this interaction, as it meant you could only bring up the inventory by clicking on some object on the screen, even if what you wanted to do within the inventory (e.g. examine an item or combine two inventory items) had nothing to do with that object. If it's a menu with only verbs, no inventory items, then it's a regular verb coin, like Khris says.
The other part that sounds strange is talking about having two pointers, one for "selecting an object or hotspot". So what's the other one for, then? Just walk? In that case, you could easily use a single cursor that acts as walk when you click on something that isn't an object or hotspot. Or if you want look as a separate action, why not use left-click/right-click for the two different types of interaction? There should never be any need for two different cursor modes.
Hey - thanks for replies, much appreciated - that makes sense, I will test out
Yes, to clarify, I meant also being able to use items in addition to verb buttons so it's all in one place (I checked this out and yes it's a similar idea to the one of the X Days games - the second one). Definitely take the point about not being able to combine items, but I like the 'clean' nature of it - everything being in one place
On the pointers point - I may be using the terminology wrong (definitely still a beginner!) - I meant that there would be a single cursor that was used for walk, but that the image of the cursor would change if it goes over something you can interact with (e.g. change to a different colour - I think this was the way it worked in Monkey Island 3)
Quote from: sag_aloo55 on Sun 17/05/2015 13:17:54
On the pointers point - I may be using the terminology wrong (definitely still a beginner!) - I meant that there would be a single cursor that was used for walk, but that the image of the cursor would change if it goes over something you can interact with (e.g. change to a different colour - I think this was the way it worked in Monkey Island 3)
That's relatively simple too. All you need to is check if your cursor is over something that allows interaction, and then change the sprite used by the cursor mode.
You also need to check what the mouse is currently over. A simple way (that may need some tweaking) would be to set the inactive sprite when the cursor "isn't over any thing", and to an active sprite of it is over "any thing".
So two commands are useful:
Mouse.ChangeModeGraphic(CursorMode, int slot) allows you to change the sprite used by a mouse mode. You could use a white and red cursor arrow, for example.
GetLocationType checks what type of "thing" is at the tested position.
You can read the details in the help file, but here's a code snippet:
if (GetLocationType(mouse.x, mouse.y) == eLocationNothing)
Mouse.ChangeModeGraphic(Mouse.Mode, INACTIVE_SPRITE_SLOT);
else
Mouse.ChangeModeGraphic(Mouse.Mode, ACTIVE_SPRITE_SLOT);
You want to put that into the repeatedly_execute function of your global script- should work right out of the box.
Note: The functionality of the mouse/mode isn't affected; all you do is changing the visuals, so even with an "inactive" sprite clicks will still be executed. You may want to block clicks depending on the used mode or desired type of interface.
I'd put a "look" and "use" item as the first two inventory items in the game, so they'll always show up first. Then add them to the player's inventory from the start. That way, all possible interactions are covered by the inv items.
Now turn on the option "Override built-in inventory window click handling" in General settings -> Inventory.
Then look for on_mouse_click in GlobalScript.asc and add two blocks for eMouseLeftInv and eMouseRightInv:
else if (button == eMouseRightInv) {
inventory[game.inv_activated].RunInteraction(eModeLookat);
}
else if (button == eMouseLeftInv) {
InventoryItem *ia = inventory[game.inv_activated]; // store clicked item
gInventory.Visible = false; // turn off GUI and...
Wait(1); // refresh screen
if (ia == iLookAt) ProcessClick(savedX, savedY, eModeLookat); // look at hotspot
else if (ia == iUse) ProcessClick(savedX, savedY, eModeInteract); // interact with hotspot
else { // use item on hotspot
player.ActiveInventory = ia;
ProcessClick(savedX, savedY, eModeUseinv);
}
}
Not tested!
(Note that if you use scrolling rooms, you should save room coordinates: savedX = mouse.x + GetViewportX(); then subtract the viewport again when calling ProcessClick(), otherwise the coordinates will be off if the room scrolls after clicking a hotspot and before an action is selected.)
Took me quite a while to be able to test these but they both worked well!
Big thanks for help with this