Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Le Woltaire on Mon 04/11/2013 22:54:28

Title: Indicate Inventory Interactions
Post by: Le Woltaire on Mon 04/11/2013 22:54:28
I would like to indicate possible inventory interactions to the player.

So if the player has an active inventory and flows over another inventory item
the curser starts to glow if the inventory interaction is possible.
The same for objects, characters and hotspots.

Like this people don't have to tryout that much unnecessary inventory combinations.

What would be the best approach for this script?
Title: Re: Indicate Inventory Interactions
Post by: Khris on Mon 04/11/2013 23:24:20
There's no elegant solution to this as far as I can see.

The best way I can see is use a struct containing an array of bools. That way you can have variables like obj[3].inv[19].
Code (ags) Select
// header
struct TwoDim {
  bool inv[AGS_MAX_INV_ITEMS];
};

import TwoDim obj[100];

// main
TwoDim obj[100];
export obj;


Then add an extender function:
Code (ags) Select
void RegisterItem(this Object*, InventoryItem *item, bool usable) {
  obj[this.ID].inv[item.ID] = usable;
}


Now you can use this:  oChair.RegisterItem(iSaw, true);

In repeatedly_execute:

Code (ags) Select
  bool interaction_available = false;
  int lt = GetLocationType(mouse.x, mouse.y);
  if (mouse.mode == eModeUseinv) {
    if (lt == eLocationObject) {
      Object *o = Object.GetAtScreenXY(mouse.x, mouse.y);
      interaction_available = obj[o.ID].inv[player.ActiveInventory.ID];
    }
    ...
  }
  if (interaction_available)
  // change cursor
Title: Re: Indicate Inventory Interactions
Post by: Le Woltaire on Tue 05/11/2013 07:45:46
Is there any possibility to change the cursor's graphic brightness to make the active inventory item glow?
Title: Re: Indicate Inventory Interactions
Post by: Khris on Tue 05/11/2013 09:04:54
Not built-in.
You could create brighter icons dynamically in the game by painting over them (read the pixel value, and if it isn't transparent, calculate an increase in brightness, then paint over the pixel).
I guess you could also hide the mouse, show a character at its position, assign the cursor graphic to its first viewframe and tint it. Won't show on top of GUIs though, so probably not feasible.