function door_UseInv() { if (player.ActiveInventory == IKey) { cChar.Say ("Hello!"); } else { cChar.Say ("Goodbye!"); } |
function on_mouse_click(MouseButton button) { if (IsGamePaused() == 1) { } else if (button == eMouseLeft) { ProcessClick(mouse.x,mouse.y, eModeInteract); ProcessClick(mouse.x,mouse.y, eModeWalkto); ProcessClick(mouse.x,mouse.y, eModeUseinv); } else if (button == eMouseRight)// right-click, so Lookat { ProcessClick(mouse.x,mouse.y, eModeLookat); mouse.Mode = eModeWalkto; } if (button == eMouseLeftInv) { player.ActiveInventory = inventory[game.inv_activated]; } else if (button == eMouseRightInv) { inventory[game.inv_activated].RunInteraction(eModeLookat); } |
ProcessClick(mouse.x,mouse.y, eModeInteract);
ProcessClick(mouse.x,mouse.y, eModeWalkto);
ProcessClick(mouse.x,mouse.y, eModeUseinv);
// 1. Find any usable object under the cursor:
Hotspot *h = Hotspot.GetAtScreenXY(mouse.x,mouse.y);
Object *o = Object.GetAtScreenXY(mouse.x,mouse.y);
Character *c = Character.GetAtScreenXY(mouse.x,mouse.y);
// 2. If there's an object, then...
if (h != null || o != null || c != null)
{
// 2.1. If player is holding an inventory item, then use it on object
if (player.ActiveInventory != null)
{
ProcessClick(mouse.x,mouse.y, eModeUseinv);
}
// 2.2 else interact with object
else
{
ProcessClick(mouse.x,mouse.y, eModeInteract);
}
}
// 3. If no object found, then simply walk
else
{
ProcessClick(mouse.x,mouse.y, eModeWalk);
}
int lt = GetLocationType(mouse.x, mouse.y);
InventoryItem*ai = player.ActiveInventory, ia = inventory[game.inv_activated];
if (button == eMouseLeft) {
if (lt == eLocationNothing) ProcessClick(mouse.x, mouse.y, eModeWalkto);
else if (ai) ProcessClick(mouse.x, mouse.y, eModeUseinv);
else ProcessClick(mouse.x, mouse.y, eModeInteract);
}
else if (button == eMouseRight) {
if (ai) player.ActiveInventory = null;
else ProcessClick(mouse.x, mouse.y, eModeLookat);
}
else if (button == eMouseLeftInv) {
if (ai) ia.RunInteraction(eModeUseinv);
else player.ActiveInventory = ia;
}
else if (button == eMouseRightInv) {
if (ai) player.ActiveInventory = null;
else ia.RunInteraction(eModeLookat);
}