Indicate Inventory Interactions

Started by Le Woltaire, Mon 04/11/2013 22:54:28

Previous topic - Next topic

Le Woltaire

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?



Khris

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
// 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
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
  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

Le Woltaire

Is there any possibility to change the cursor's graphic brightness to make the active inventory item glow?



Khris

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.

SMF spam blocked by CleanTalk