From 72e12f6aae10e294c9265dd58c75db5c5c54bd24 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 3 Oct 2019 22:28:56 +0300 Subject: CPickups --- src/control/Pickups.h | 168 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 107 insertions(+), 61 deletions(-) (limited to 'src/control/Pickups.h') diff --git a/src/control/Pickups.h b/src/control/Pickups.h index 5b51a52a..44ce0c4f 100644 --- a/src/control/Pickups.h +++ b/src/control/Pickups.h @@ -1,62 +1,108 @@ -#pragma once -#include "Weapon.h" - -enum ePickupType : uint8 -{ - PICKUP_NONE = 0, - PICKUP_IN_SHOP = 1, - PICKUP_ON_STREET = 2, - PICKUP_ONCE = 3, - PICKUP_ONCE_TIMEOUT = 4, - PICKUP_COLLECTABLE1 = 5, - PICKUP_IN_SHOP_OUT_OF_STOCK = 6, - PICKUP_MONEY = 7, - PICKUP_MINE_INACTIVE = 8, - PICKUP_MINE_ARMED = 9, - PICKUP_NAUTICAL_MINE_INACTIVE = 10, - PICKUP_NAUTICAL_MINE_ARMED = 11, - PICKUP_FLOATINGPACKAGE = 12, - PICKUP_FLOATINGPACKAGE_FLOATING = 13, - PICKUP_ON_STREET_SLOW = 14, -}; - -class CEntity; -class CObject; - -class CPickup -{ +#pragma once +#include "Weapon.h" + +enum ePickupType : uint8 +{ + PICKUP_NONE = 0, + PICKUP_IN_SHOP, + PICKUP_ON_STREET, + PICKUP_ONCE, + PICKUP_ONCE_TIMEOUT, + PICKUP_COLLECTABLE1, + PICKUP_IN_SHOP_OUT_OF_STOCK, + PICKUP_MONEY, + PICKUP_MINE_INACTIVE, + PICKUP_MINE_ARMED, + PICKUP_NAUTICAL_MINE_INACTIVE, + PICKUP_NAUTICAL_MINE_ARMED, + PICKUP_FLOATINGPACKAGE, + PICKUP_FLOATINGPACKAGE_FLOATING, + PICKUP_ON_STREET_SLOW, + PICKUP_NUMOFTYPES +}; + +class CEntity; +class CObject; +class CVehicle; +class CPlayerPed; + +class CPickup +{ +public: ePickupType m_eType; - bool m_bRemoved; - uint16 m_wQuantity; - CObject *m_pObject; - uint32 m_nTimer; - int16 m_eModelIndex; - int16 m_wIndex; - CVector m_vecPos; -}; - -static_assert(sizeof(CPickup) == 0x1C, "CPickup: error"); - -class CPickups -{ -public: - static void RenderPickUpText(void); - static void DoCollectableEffects(CEntity *ent); - static void DoMoneyEffects(CEntity *ent); - static void DoMineEffects(CEntity *ent); - static void DoPickUpEffects(CEntity *ent); - static void RemoveAllFloatingPickups(); - static int32 GenerateNewOne(CVector, uint32, uint8, uint32); - static int32 GenerateNewOne_WeaponType(CVector, eWeaponType, uint8, uint32); - - static CPickup (&aPickUps)[NUMPICKUPS]; -}; - -extern uint16 AmmoForWeapon[20]; -extern uint16 AmmoForWeapon_OnStreet[20]; - -class CPacManPickups -{ -public: - static void Render(void); -}; + bool m_bRemoved; + uint16 m_wQuantity; + CObject *m_pObject; + uint32 m_nTimer; + int16 m_eModelIndex; + uint16 m_wIndex; + CVector m_vecPos; + + CObject *GiveUsAPickUpObject(int32 handle); + bool Update(CPlayerPed *player, CVehicle *vehicle, int playerId); +private: + bool IsMine() { return m_eType >= PICKUP_MINE_INACTIVE && m_eType <= PICKUP_FLOATINGPACKAGE_FLOATING; } + void RemoveKeepType(); + void Remove(); +}; + +static_assert(sizeof(CPickup) == 0x1C, "CPickup: error"); + +struct tPickupMessage +{ + CVector2D m_pos; + eWeaponType m_weaponType; + CVector2D m_dist; + CRGBA m_color; + uint8 m_bOutOfStock : 1; + uint8 m_quantity; +}; + +class CPickups +{ + static int32 aPickUpsCollected[NUMCOLLECTEDPICKUPS]; + static int16 CollectedPickUpIndex; + static int16 NumMessages; + static tPickupMessage aMessages[NUMPICKUPMESSAGES]; +public: + static void Init(); + static void Update(); + static void RenderPickUpText(); + static void DoCollectableEffects(CEntity *ent); + static void DoMoneyEffects(CEntity *ent); + static void DoMineEffects(CEntity *ent); + static void DoPickUpEffects(CEntity *ent); + static int32 GenerateNewOne(CVector pos, uint32 modelIndex, uint8 type, uint32 quantity); + static int32 GenerateNewOne_WeaponType(CVector pos, eWeaponType weaponType, uint8 type, uint32 quantity); + static void RemovePickUp(int32 pickupIndex); + static void RemoveAllFloatingPickups(); + static void AddToCollectedPickupsArray(int32 index); + static bool IsPickUpPickedUp(int32 pickupId); + static int32 ModelForWeapon(eWeaponType weaponType); + static enum eWeaponType WeaponForModel(int32 model); + static int32 FindColourIndexForWeaponMI(int32 model); + static int32 GetActualPickupIndex(int32 index); + static int32 GetNewUniquePickupIndex(int32 slot); + static void PassTime(uint32 time); + static bool GivePlayerGoodiesWithPickUpMI(int16 modelIndex, int playerIndex); + static void Load(uint8 *buffer, uint32 size); + static void Save(uint8 *buffer, uint32 *size); + + static CPickup(&aPickUps)[NUMPICKUPS]; + + // unused + static bool &bPickUpcamActivated; + static CVehicle *&pPlayerVehicle; + static CVector &StaticCamCoors; + static uint32 &StaticCamStartTime; +}; + +extern uint16 AmmoForWeapon[20]; +extern uint16 AmmoForWeapon_OnStreet[20]; +extern uint16 CostOfWeapon[20]; + +class CPacManPickups +{ +public: + static void Render(void); +}; -- cgit v1.2.3 From 2cf94348f522802f423d8b6563491a4301db9b50 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 3 Oct 2019 22:51:38 +0300 Subject: Drop w's --- src/control/Pickups.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/control/Pickups.h') diff --git a/src/control/Pickups.h b/src/control/Pickups.h index 44ce0c4f..4bcbdfb5 100644 --- a/src/control/Pickups.h +++ b/src/control/Pickups.h @@ -31,11 +31,11 @@ class CPickup public: ePickupType m_eType; bool m_bRemoved; - uint16 m_wQuantity; + uint16 m_nQuantity; CObject *m_pObject; uint32 m_nTimer; int16 m_eModelIndex; - uint16 m_wIndex; + uint16 m_nIndex; CVector m_vecPos; CObject *GiveUsAPickUpObject(int32 handle); -- cgit v1.2.3 From 679f7bbcfa72d47d465922f207ff325f6d205bfd Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 3 Oct 2019 23:32:31 +0300 Subject: Checks rewritten --- src/control/Pickups.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/control/Pickups.h') diff --git a/src/control/Pickups.h b/src/control/Pickups.h index 4bcbdfb5..b49a5544 100644 --- a/src/control/Pickups.h +++ b/src/control/Pickups.h @@ -42,6 +42,7 @@ public: bool Update(CPlayerPed *player, CVehicle *vehicle, int playerId); private: bool IsMine() { return m_eType >= PICKUP_MINE_INACTIVE && m_eType <= PICKUP_FLOATINGPACKAGE_FLOATING; } + inline bool CanBePickedUp(CPlayerPed *player); void RemoveKeepType(); void Remove(); }; -- cgit v1.2.3