MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / UseItem

Method UseItem

TombEngine/Game/gui.cpp:2042–2260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2040 }
2041
2042 void GuiController::UseItem(ItemInfo& item, int objectNumber)
2043 {
2044 if (!item.IsLara())
2045 {
2046 TENLog("Attempt to use inventory item with a non-player object.", LogLevel::Warning);
2047 return;
2048 }
2049
2050 auto& player = GetLaraInfo(item);
2051
2052 player.Inventory.OldBusy = false;
2053 item.MeshBits = ALL_JOINT_BITS;
2054
2055 InventoryItemChosen = objectNumber;
2056
2057 // Use item event handling.
2058 g_GameScript->OnUseItem((GAME_OBJECT_ID)InventoryItemChosen);
2059 HandleAllGlobalEvents(EventType::UseItem, (Activator)short(item.Index));
2060
2061 // Quickly discard further processing if chosen item was reset in script.
2062 if (InventoryItemChosen == NO_VALUE)
2063 return;
2064
2065 if (InventoryItemChosen == ID_PISTOLS_ITEM ||
2066 InventoryItemChosen == ID_UZI_ITEM ||
2067 InventoryItemChosen == ID_REVOLVER_ITEM)
2068 {
2069 if (player.Control.WaterStatus != WaterStatus::Dry &&
2070 player.Control.WaterStatus != WaterStatus::Wade)
2071 {
2072 return;
2073 }
2074
2075 if (player.Context.Vehicle != NO_VALUE)
2076 return;
2077
2078 switch (InventoryItemChosen)
2079 {
2080 case ID_PISTOLS_ITEM:
2081 player.Control.Weapon.RequestGunType = LaraWeaponType::Pistol;
2082 break;
2083
2084 case ID_UZI_ITEM:
2085 player.Control.Weapon.RequestGunType = LaraWeaponType::Uzi;
2086 break;
2087
2088 case ID_REVOLVER_ITEM:
2089 player.Control.Weapon.RequestGunType = LaraWeaponType::Revolver;
2090 break;
2091
2092 default:
2093 return;
2094 }
2095
2096 if (player.Control.HandStatus == HandStatus::Free &&
2097 player.Control.Weapon.GunType == player.Control.Weapon.RequestGunType)
2098 {
2099 InitializeNewWeapon(item);

Callers 2

HandlePlayerQuickActionsFunction · 0.80
UseItemFunction · 0.80

Calls 10

TENLogFunction · 0.85
HandleAllGlobalEventsFunction · 0.85
InitializeNewWeaponFunction · 0.85
TestStateFunction · 0.85
ClearAllActionsFunction · 0.85
HandleWeaponFunction · 0.85
SoundEffectFunction · 0.85
IsLaraMethod · 0.80
OnUseItemMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected