From 59eed0b48b9d752549d1fbe8e0a03349ca558560 Mon Sep 17 00:00:00 2001 From: maybegreat48 <96936658+maybegreat48@users.noreply.github.com> Date: Sun, 7 Jul 2024 15:32:27 +0000 Subject: [PATCH] Add CEventInventoryItemPickedUp (#21) CEvent CEventGroup --- classes.cpp | 3 ++ event/CEvent.hpp | 17 +++++++++ event/CEventGroup.hpp | 15 ++++++++ event/CEventInventoryItemPickedUp.hpp | 14 ++++++++ rage/vector.hpp | 52 +++++++++++++++++++++++++++ script/scrVector.hpp | 5 +++ script/types.hpp | 11 +++--- 7 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 event/CEvent.hpp create mode 100644 event/CEventGroup.hpp create mode 100644 event/CEventInventoryItemPickedUp.hpp diff --git a/classes.cpp b/classes.cpp index 083c3f7..a86b329 100644 --- a/classes.cpp +++ b/classes.cpp @@ -4,6 +4,9 @@ #include "base/fwRefAwareBaseImpl.hpp" #include "base/pgBase.hpp" #include "entity/fwEntity.hpp" +#include "event/CEvent.hpp" +#include "event/CEventGroup.hpp" +#include "event/CEventInventoryItemPickedUp.hpp" #include "network/CNetGamePlayer.hpp" #include "network/CNetworkPlayerMgr.hpp" #include "network/CScriptedGameEvent.hpp" diff --git a/event/CEvent.hpp b/event/CEvent.hpp new file mode 100644 index 0000000..2f12e60 --- /dev/null +++ b/event/CEvent.hpp @@ -0,0 +1,17 @@ +#pragma once + +class CEvent +{ +public: + virtual ~CEvent() = default; + virtual CEvent* Clone() = 0; + virtual bool operator==(CEvent& other) = 0; + virtual int _0x18() = 0; + virtual float _0x20() = 0; + virtual float _0x28() = 0; + virtual bool IsEventScriptCommand() = 0; + virtual bool ExtractData(void* data, int size) = 0; + + char m_pad[0x58]; +}; +static_assert(sizeof(CEvent) == 0x60); \ No newline at end of file diff --git a/event/CEventGroup.hpp b/event/CEventGroup.hpp new file mode 100644 index 0000000..331a6c0 --- /dev/null +++ b/event/CEventGroup.hpp @@ -0,0 +1,15 @@ +#pragma once + +class CEvent; +class CEventGroup +{ +public: + virtual ~CEventGroup() = default; + virtual void AddEvent(CEvent* event, bool) = 0; + virtual void Cleanup() = 0; + virtual int GetEventGroupType() = 0; +}; + +class CEventGroupNetwork : public CEventGroup +{ +}; \ No newline at end of file diff --git a/event/CEventInventoryItemPickedUp.hpp b/event/CEventInventoryItemPickedUp.hpp new file mode 100644 index 0000000..99e41c3 --- /dev/null +++ b/event/CEventInventoryItemPickedUp.hpp @@ -0,0 +1,14 @@ +#pragma once +#include "CEvent.hpp" +#include "script/types.hpp" + +class CEventInventoryItemPickedUp : public CEvent +{ + SCR_INT m_Unk; + SCR_INT m_RewardHash; + SCR_INT m_ItemHash; + SCR_BOOL m_Unk2; + SCR_BOOL m_Unk3; + PICKUP_INDEX m_Pickup; +}; +static_assert(sizeof(CEventInventoryItemPickedUp) == 0x90); \ No newline at end of file diff --git a/rage/vector.hpp b/rage/vector.hpp index 7a92b6e..d3a1c82 100644 --- a/rage/vector.hpp +++ b/rage/vector.hpp @@ -40,6 +40,58 @@ namespace rage z() { } + + template + vector3 operator+(const vector3& other) + { + vector3 vec; + vec.x = this->x + other.x; + vec.y = this->y + other.y; + vec.z = this->z + other.z; + return vec; + } + + template + vector3 operator-(const vector3& other) + { + vector3 vec; + vec.x = this->x - other.x; + vec.y = this->y - other.y; + vec.z = this->z - other.z; + return vec; + } + + template + vector3 operator*(const vector3& other) + { + vector3 vec; + vec.x = this->x * other.x; + vec.y = this->y * other.y; + vec.z = this->z * other.z; + return vec; + } + + template + vector3 operator*(const float& other) + { + vector3 vec; + vec.x = this->x * other; + vec.y = this->y * other; + vec.z = this->z * other; + return vec; + } + + template + bool operator==(const vector3& other) + { + return this->x == other.x && this->y == other.y && this->z == other.z; + } + + template + bool operator!=(const vector3& other) + { + return this->x != other.x || this->y != other.y || this->z != other.z; + } }; template diff --git a/script/scrVector.hpp b/script/scrVector.hpp index cbbe0c1..b88fd77 100644 --- a/script/scrVector.hpp +++ b/script/scrVector.hpp @@ -80,6 +80,11 @@ namespace rage return os; } + operator rage::fvector3() + { + return { x, y, z }; + } + alignas(8) float x{}; alignas(8) float y{}; alignas(8) float z{}; diff --git a/script/types.hpp b/script/types.hpp index 8d24e2a..d640e26 100644 --- a/script/types.hpp +++ b/script/types.hpp @@ -41,11 +41,12 @@ typedef int PopZone; typedef int PersChar; typedef int Prompt; -#define PLAYER_INDEX alignas(8) Player -#define ENTITY_INDEX alignas(8) Entity -#define PED_INDEX alignas(8) Ped -#define VEHICLE_INDEX alignas(8) Vehicle -#define INTERIOR_INDEX alignas(8) Interior +#define PLAYER_INDEX alignas(8) int +#define ENTITY_INDEX alignas(8) int +#define PED_INDEX alignas(8) int +#define PICKUP_INDEX alignas(8) int +#define VEHICLE_INDEX alignas(8) int +#define INTERIOR_INDEX alignas(8) int #define NETWORK_INDEX alignas(8) int #define SCR_HASH alignas(8) Hash