Merge pull request #220 from Sergeanur/Pickups

CPickups
This commit is contained in:
aap 2019-10-03 22:34:58 +02:00 committed by GitHub
commit 03df2d5716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1178 additions and 85 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4,56 +4,103 @@
enum ePickupType : uint8 enum ePickupType : uint8
{ {
PICKUP_NONE = 0, PICKUP_NONE = 0,
PICKUP_IN_SHOP = 1, PICKUP_IN_SHOP,
PICKUP_ON_STREET = 2, PICKUP_ON_STREET,
PICKUP_ONCE = 3, PICKUP_ONCE,
PICKUP_ONCE_TIMEOUT = 4, PICKUP_ONCE_TIMEOUT,
PICKUP_COLLECTABLE1 = 5, PICKUP_COLLECTABLE1,
PICKUP_IN_SHOP_OUT_OF_STOCK = 6, PICKUP_IN_SHOP_OUT_OF_STOCK,
PICKUP_MONEY = 7, PICKUP_MONEY,
PICKUP_MINE_INACTIVE = 8, PICKUP_MINE_INACTIVE,
PICKUP_MINE_ARMED = 9, PICKUP_MINE_ARMED,
PICKUP_NAUTICAL_MINE_INACTIVE = 10, PICKUP_NAUTICAL_MINE_INACTIVE,
PICKUP_NAUTICAL_MINE_ARMED = 11, PICKUP_NAUTICAL_MINE_ARMED,
PICKUP_FLOATINGPACKAGE = 12, PICKUP_FLOATINGPACKAGE,
PICKUP_FLOATINGPACKAGE_FLOATING = 13, PICKUP_FLOATINGPACKAGE_FLOATING,
PICKUP_ON_STREET_SLOW = 14, PICKUP_ON_STREET_SLOW,
PICKUP_NUMOFTYPES
}; };
class CEntity; class CEntity;
class CObject; class CObject;
class CVehicle;
class CPlayerPed;
class CPickup class CPickup
{ {
public:
ePickupType m_eType; ePickupType m_eType;
bool m_bRemoved; bool m_bRemoved;
uint16 m_wQuantity; uint16 m_nQuantity;
CObject *m_pObject; CObject *m_pObject;
uint32 m_nTimer; uint32 m_nTimer;
int16 m_eModelIndex; int16 m_eModelIndex;
int16 m_wIndex; uint16 m_nIndex;
CVector m_vecPos; 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; }
inline bool CanBePickedUp(CPlayerPed *player);
void RemoveKeepType();
void Remove();
}; };
static_assert(sizeof(CPickup) == 0x1C, "CPickup: error"); 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 class CPickups
{ {
static int32 aPickUpsCollected[NUMCOLLECTEDPICKUPS];
static int16 CollectedPickUpIndex;
static int16 NumMessages;
static tPickupMessage aMessages[NUMPICKUPMESSAGES];
public: public:
static void RenderPickUpText(void); static void Init();
static void Update();
static void RenderPickUpText();
static void DoCollectableEffects(CEntity *ent); static void DoCollectableEffects(CEntity *ent);
static void DoMoneyEffects(CEntity *ent); static void DoMoneyEffects(CEntity *ent);
static void DoMineEffects(CEntity *ent); static void DoMineEffects(CEntity *ent);
static void DoPickUpEffects(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 RemoveAllFloatingPickups();
static int32 GenerateNewOne(CVector, uint32, uint8, uint32); static void AddToCollectedPickupsArray(int32 index);
static int32 GenerateNewOne_WeaponType(CVector, eWeaponType, uint8, uint32); 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]; static CPickup(&aPickUps)[NUMPICKUPS];
// unused
static bool &bPickUpcamActivated;
static CVehicle *&pPlayerVehicle;
static CVector &StaticCamCoors;
static uint32 &StaticCamStartTime;
}; };
extern uint16 AmmoForWeapon[20]; extern uint16 AmmoForWeapon[20];
extern uint16 AmmoForWeapon_OnStreet[20]; extern uint16 AmmoForWeapon_OnStreet[20];
extern uint16 CostOfWeapon[20];
class CPacManPickups class CPacManPickups
{ {

View File

@ -13,6 +13,7 @@ CDummyPool *&CPools::ms_pDummyPool = *(CDummyPool**)0x8F2C18;
CAudioScriptObjectPool *&CPools::ms_pAudioScriptObjectPool = *(CAudioScriptObjectPool**)0x8F1B6C; CAudioScriptObjectPool *&CPools::ms_pAudioScriptObjectPool = *(CAudioScriptObjectPool**)0x8F1B6C;
WRAPPER void CPools::Initialise(void) { EAXJMP(0x4A1770); } WRAPPER void CPools::Initialise(void) { EAXJMP(0x4A1770); }
WRAPPER void CPools::MakeSureSlotInObjectPoolIsEmpty(int32 handle) { EAXJMP(0x4A2DB0); }
#if 0 #if 0
void void

View File

@ -49,4 +49,5 @@ public:
static CVehicle *GetVehicle(int32 handle); static CVehicle *GetVehicle(int32 handle);
static int32 GetObjectRef(CObject *object); static int32 GetObjectRef(CObject *object);
static CObject *GetObject(int32 handle); static CObject *GetObject(int32 handle);
static void MakeSureSlotInObjectPoolIsEmpty(int32 handle);
}; };

View File

@ -68,10 +68,14 @@ enum Config {
NUMCORONAS = 56, NUMCORONAS = 56,
NUMPOINTLIGHTS = 32, NUMPOINTLIGHTS = 32,
NUMMONEYMESSAGES = 16, NUMMONEYMESSAGES = 16,
NUMPICKUPMESSAGES = 16,
NUMONSCREENTIMERENTRIES = 1, NUMONSCREENTIMERENTRIES = 1,
NUMRADARBLIPS = 32, NUMRADARBLIPS = 32,
NUMPICKUPS = 336, NUMGENERALPICKUPS = 320,
NUMSCRIPTEDPICKUPS = 16,
NUMPICKUPS = NUMGENERALPICKUPS + NUMSCRIPTEDPICKUPS,
NUMCOLLECTEDPICKUPS = 20,
NUMEVENTS = 64, NUMEVENTS = 64,
NUM_CARGENS = 160, NUM_CARGENS = 160,
@ -141,3 +145,4 @@ enum Config {
#define ANIMATE_PED_COL_MODEL #define ANIMATE_PED_COL_MODEL
//#define REMOVE_TREADABLE_PATHFIND //#define REMOVE_TREADABLE_PATHFIND
#define VC_PED_PORTS #define VC_PED_PORTS
//#define MONEY_MESSAGES

View File

@ -204,6 +204,22 @@ public:
m_matrix.at.y = 0.0f; m_matrix.at.y = 0.0f;
m_matrix.at.z = 1.0f; m_matrix.at.z = 1.0f;
} }
void SetRotateZOnlyScaled(float angle, float scale) {
float c = Cos(angle);
float s = Sin(angle);
m_matrix.right.x = c * scale;
m_matrix.right.y = s * scale;
m_matrix.right.z = 0.0f;
m_matrix.up.x = -s * scale;
m_matrix.up.y = c * scale;
m_matrix.up.z = 0.0f;
m_matrix.at.x = 0.0f;
m_matrix.at.y = 0.0f;
m_matrix.at.z = scale;
}
void SetRotateZ(float angle){ void SetRotateZ(float angle){
SetRotateZOnly(angle); SetRotateZOnly(angle);
m_matrix.pos.x = 0.0f; m_matrix.pos.x = 0.0f;

View File

@ -14,7 +14,9 @@ int16 &CObject::nNoTempObjects = *(int16*)0x95CCA2;
int16 &CObject::nBodyCastHealth = *(int16*)0x5F7D4C; // 1000 int16 &CObject::nBodyCastHealth = *(int16*)0x5F7D4C; // 1000
void *CObject::operator new(size_t sz) { return CPools::GetObjectPool()->New(); } void *CObject::operator new(size_t sz) { return CPools::GetObjectPool()->New(); }
void *CObject::operator new(size_t sz, int handle) { return CPools::GetObjectPool()->New(handle);};
void CObject::operator delete(void *p, size_t sz) { CPools::GetObjectPool()->Delete((CObject*)p); } void CObject::operator delete(void *p, size_t sz) { CPools::GetObjectPool()->Delete((CObject*)p); }
void CObject::operator delete(void *p, int handle) { CPools::GetObjectPool()->Delete((CObject*)p); }
CObject::CObject(void) CObject::CObject(void)
{ {
@ -32,7 +34,7 @@ CObject::CObject(void)
field_172 = 0; field_172 = 0;
bIsPickup = false; bIsPickup = false;
m_obj_flag2 = false; m_obj_flag2 = false;
m_obj_flag4 = false; bOutOfStock = false;
m_obj_flag8 = false; m_obj_flag8 = false;
m_obj_flag10 = false; m_obj_flag10 = false;
bHasBeenDamaged = false; bHasBeenDamaged = false;

View File

@ -34,13 +34,13 @@ public:
int8 ObjectCreatedBy; int8 ObjectCreatedBy;
int8 bIsPickup : 1; int8 bIsPickup : 1;
int8 m_obj_flag2 : 1; int8 m_obj_flag2 : 1;
int8 m_obj_flag4 : 1; int8 bOutOfStock : 1;
int8 m_obj_flag8 : 1; int8 m_obj_flag8 : 1;
int8 m_obj_flag10 : 1; int8 m_obj_flag10 : 1;
int8 bHasBeenDamaged : 1; int8 bHasBeenDamaged : 1;
int8 bUseVehicleColours : 1; int8 bUseVehicleColours : 1;
int8 m_obj_flag80 : 1; int8 m_obj_flag80 : 1;
int8 field_172; int8 field_172; // car for a bonus pickup?
int8 field_173; int8 field_173;
float m_fCollisionDamageMultiplier; float m_fCollisionDamageMultiplier;
uint8 m_nCollisionDamageEffect; uint8 m_nCollisionDamageEffect;
@ -63,7 +63,9 @@ public:
static int16 &nBodyCastHealth; static int16 &nBodyCastHealth;
static void *operator new(size_t); static void *operator new(size_t);
static void *operator new(size_t, int);
static void operator delete(void*, size_t); static void operator delete(void*, size_t);
static void operator delete(void*, int);
CObject(void); CObject(void);
CObject(int32, bool); CObject(int32, bool);