Skip to content

Commit 2f02715

Browse files
Merge pull request #260 from ANTINICKNAMES/master
Update CObject & CProjectile. Add CPedDamageResponse and CPedDamageResponseCalculator
2 parents 60d009c + b3e93d5 commit 2f02715

File tree

7 files changed

+139
-1
lines changed

7 files changed

+139
-1
lines changed

plugin_sa/game_sa/CObject.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,30 @@
66
*/
77
#include "CObject.h"
88

9+
void* CObject::operator new(unsigned int size) {
10+
return plugin::CallAndReturn<void*, 0x5A1EE0, unsigned int>(size);
11+
}
12+
13+
void* CObject::operator new(unsigned int size, int poolRef) {
14+
return plugin::CallAndReturn<void*, 0x5A1EF0, unsigned int, int>(size, poolRef);
15+
}
16+
17+
void CObject::operator delete(void* data) {
18+
plugin::Call<0x5A1F20, void*>(data);
19+
}
20+
21+
CObject::CObject() : CPhysical(plugin::dummy) {
22+
plugin::CallMethod<0x5A1D10, CObject*>(this);
23+
}
24+
25+
CObject::~CObject() {
26+
plugin::CallMethod<0x59F660, CObject*>(this);
27+
}
28+
29+
void CObject::SetIsStatic(bool isStatic) {
30+
plugin::CallMethod<0x5A0760, CObject*, bool>(this, isStatic);
31+
}
32+
933
// Converted from thiscall void CObject::ProcessGarageDoorBehaviour(void) 0x44A4D0
1034
void CObject::ProcessGarageDoorBehaviour() {
1135
((void(__thiscall *)(CObject*))0x44A4D0)(this);

plugin_sa/game_sa/CObject.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "CObjectInfo.h"
1212

1313
enum eObjectType {
14+
OBJECT_UNKNOWN,
1415
OBJECT_MISSION = 2,
1516
OBJECT_TEMPORARY = 3,
1617
OBJECT_MISSION2 = 6
@@ -85,6 +86,12 @@ class CObject : public CPhysical {
8586

8687
// class functions
8788

89+
static void* operator new(unsigned int size);
90+
static void* operator new(unsigned int size, int poolRef);
91+
static void operator delete(void* data);
92+
CObject();
93+
~CObject();
94+
void SetIsStatic(bool isStatic);
8895
void ProcessGarageDoorBehaviour();
8996
bool CanBeDeleted();
9097
void SetRelatedDummy(CDummyObject* relatedDummy);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#include "PluginBase.h"
4+
5+
class CPedDamageResponse {
6+
public:
7+
float m_fDamageHealth;
8+
float m_fDamageArmor;
9+
bool m_bHealthZero;
10+
bool m_bForceDeath;
11+
bool m_bDamageCalculated;
12+
bool m_bCheckIfAffectsPed;
13+
14+
inline CPedDamageResponse() {
15+
m_fDamageHealth = 0.0f;
16+
m_fDamageArmor = 0.0f;
17+
m_bHealthZero = false;
18+
m_bForceDeath = false;
19+
m_bDamageCalculated = false;
20+
m_bCheckIfAffectsPed = false;
21+
}
22+
};
23+
24+
VALIDATE_SIZE(CPedDamageResponse, 0xC);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
Plugin-SDK (Grand Theft Auto San Andreas) source file
3+
Authors: GTA Community. See more here
4+
https://github.com/DK22Pac/plugin-sdk
5+
Do not delete this comment block. Respect others' work!
6+
*/
7+
#include "CPedDamageResponseCalculator.h"
8+
9+
float& CPedDamageResponseCalculator::ms_damageFactor = *(float*)0x8A6260; // 5555.5498
10+
11+
// 0x4AD3F0
12+
CPedDamageResponseCalculator::CPedDamageResponseCalculator(CEntity* entity, float fDamage, eWeaponType weaponType, uint8_t bodyPart, bool bSpeak) {
13+
((void(__thiscall*)(CPedDamageResponseCalculator*, CEntity*, float, eWeaponType, uint8_t, bool))0x4AD3F0)(this, entity, fDamage, weaponType, bodyPart, bSpeak);
14+
}
15+
16+
// 0x4AD430
17+
void CPedDamageResponseCalculator::AccountForPedDamageStats(CPed* ped, CPedDamageResponse& response) {
18+
plugin::CallMethod<0x4AD430, CPedDamageResponseCalculator*, CPed*, CPedDamageResponse&>(this, ped, response);
19+
}
20+
21+
// 0x4AD550
22+
void CPedDamageResponseCalculator::AccountForPedArmour(CPed* ped, CPedDamageResponse& response) {
23+
plugin::CallMethod<0x4AD550, CPedDamageResponseCalculator*, CPed*, CPedDamageResponse&>(this, ped, response);
24+
}
25+
26+
// 0x4AD610
27+
bool CPedDamageResponseCalculator::ComputeWillForceDeath(CPed* ped, CPedDamageResponse& response) {
28+
return plugin::CallMethodAndReturn<bool, 0x4AD610, CPedDamageResponseCalculator*, CPed*, CPedDamageResponse&>(this, ped, response);
29+
}
30+
31+
// 0x4B3210
32+
void CPedDamageResponseCalculator::ComputeWillKillPed(CPed* ped, CPedDamageResponse& response, bool bSpeak) {
33+
plugin::CallMethod<0x4B3210, CPedDamageResponseCalculator*>(this, ped, response, bSpeak);
34+
}
35+
36+
// 0x4B5AC0
37+
void CPedDamageResponseCalculator::ComputeDamageResponse(CPed* ped, CPedDamageResponse& response, bool bSpeak)
38+
{
39+
plugin::CallMethod<0x4B5AC0, CPedDamageResponseCalculator*, CPed*, CPedDamageResponse&, bool>(this, ped, response, bSpeak);
40+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Plugin-SDK (Grand Theft Auto San Andreas) header file
3+
Authors: GTA Community. See more here
4+
https://github.com/DK22Pac/plugin-sdk
5+
Do not delete this comment block. Respect others' work!
6+
*/
7+
#pragma once
8+
9+
#include "PluginBase.h"
10+
#include "CPedDamageResponse.h"
11+
#include "eWeaponType.h"
12+
13+
class CEntity;
14+
class CPed;
15+
16+
class PLUGIN_API CPedDamageResponseCalculator
17+
{
18+
public:
19+
const CEntity* m_pDamager;
20+
float m_fDamageFactor;
21+
uint8_t m_bodyPart;
22+
eWeaponType m_weaponType;
23+
bool m_bSpeak;
24+
25+
static float& ms_damageFactor;
26+
27+
CPedDamageResponseCalculator(CEntity* entity, float fDamage, eWeaponType weaponType, uint8_t bodyPart, bool bSpeak);
28+
29+
public:
30+
void AccountForPedDamageStats(CPed* ped, CPedDamageResponse& response);
31+
void AccountForPedArmour(CPed* ped, CPedDamageResponse& response);
32+
bool ComputeWillForceDeath(CPed* ped, CPedDamageResponse& response);
33+
void ComputeWillKillPed(CPed* ped, CPedDamageResponse& response, bool bSpeak);
34+
void ComputeDamageResponse(CPed* ped, CPedDamageResponse& response, bool bSpeak);
35+
};
36+
37+
VALIDATE_SIZE(CPedDamageResponseCalculator, 0x14);

plugin_sa/game_sa/CProjectile.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@
44
https://github.com/DK22Pac/plugin-sdk
55
Do not delete this comment block. Respect others' work!
66
*/
7-
#include "CProjectile.h"
7+
#include "CProjectile.h"
8+
9+
// Converted from thiscall void CProjectile::CProjectile(int) 0x5A4030
10+
CProjectile::CProjectile(int index) {
11+
plugin::CallMethod<0x5A4030, CProjectile*, int>(this, index);
12+
}

plugin_sa/game_sa/CProjectile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
class PLUGIN_API CProjectile : public CObject {
1313
public:
14+
CProjectile(int index);
1415
};
1516

1617
VALIDATE_SIZE(CProjectile, 0x17C);

0 commit comments

Comments
 (0)