diff --git a/source/game/item/ItemDirector.cc b/source/game/item/ItemDirector.cc index 5220b819..a1a2780e 100644 --- a/source/game/item/ItemDirector.cc +++ b/source/game/item/ItemDirector.cc @@ -18,6 +18,11 @@ void ItemDirector::calc() { } } +KartItem &ItemDirector::kartItem(size_t idx) { + ASSERT(idx < m_karts.size()); + return m_karts[idx]; +} + /// @addr{0x80799138} ItemDirector *ItemDirector::CreateInstance() { ASSERT(!s_instance); diff --git a/source/game/item/ItemDirector.hh b/source/game/item/ItemDirector.hh index b2082af7..f5ff388e 100644 --- a/source/game/item/ItemDirector.hh +++ b/source/game/item/ItemDirector.hh @@ -13,6 +13,8 @@ public: void init(); void calc(); + KartItem &kartItem(size_t idx); + static ItemDirector *CreateInstance(); static void DestroyInstance(); [[nodiscard]] static ItemDirector *Instance(); diff --git a/source/game/item/ItemInventory.cc b/source/game/item/ItemInventory.cc index 23ba79c7..37a417e2 100644 --- a/source/game/item/ItemInventory.cc +++ b/source/game/item/ItemInventory.cc @@ -21,6 +21,11 @@ void ItemInventory::useItem(int count) { return; } + clear(); +} + +/// @addr{0x807BC9C0} +void ItemInventory::clear() { m_currentId = ItemId::NONE; m_currentCount = 0; } diff --git a/source/game/item/ItemInventory.hh b/source/game/item/ItemInventory.hh index 96800c6e..a58fd323 100644 --- a/source/game/item/ItemInventory.hh +++ b/source/game/item/ItemInventory.hh @@ -13,6 +13,7 @@ public: /// @beginSetters void setItem(ItemId id); void useItem(int count); + void clear(); /// @endSetters /// @beginGetters diff --git a/source/game/item/KartItem.cc b/source/game/item/KartItem.cc index 1b796a43..1925917e 100644 --- a/source/game/item/KartItem.cc +++ b/source/game/item/KartItem.cc @@ -43,6 +43,13 @@ void KartItem::calc() { } } +/// @addr{0x80798848} +void KartItem::clear() { + if (m_inventory.id() != ItemId::NONE) { + m_inventory.clear(); + } +} + /// @addr{0x8079864C} void KartItem::activateMushroom() { move()->activateMushroom(); diff --git a/source/game/item/KartItem.hh b/source/game/item/KartItem.hh index 62fb7fa9..15f60136 100644 --- a/source/game/item/KartItem.hh +++ b/source/game/item/KartItem.hh @@ -17,6 +17,7 @@ public: void init(size_t playerIdx); void calc(); + void clear(); void activateMushroom(); void useMushroom(); diff --git a/source/game/kart/KartMove.cc b/source/game/kart/KartMove.cc index 0a0e6f2b..1d7a49c9 100644 --- a/source/game/kart/KartMove.cc +++ b/source/game/kart/KartMove.cc @@ -12,6 +12,9 @@ #include "game/field/CollisionDirector.hh" #include "game/field/KCollisionTypes.hh" +#include "game/item/ItemDirector.hh" +#include "game/item/KartItem.hh" + #include "game/system/CourseMap.hh" #include "game/system/RaceManager.hh" #include "game/system/map/MapdataCannonPoint.hh" @@ -308,6 +311,9 @@ void KartMove::calcRespawnStart() { EGG::Vector3f respawnRot = EGG::Vector3f(0.0f, jugemRot.y, 0.0f); setInitialPhysicsValues(respawnPos, respawnRot); + + Item::ItemDirector::Instance()->kartItem(0).clear(); + state()->setTriggerRespawn(false); state()->setInRespawn(true); }