Skip to content
Permalink
Browse files
Fix headshot crash (0x4AA2F4)
  • Loading branch information
DK22Pac committed May 1, 2017
1 parent d3507c7 commit 65e9c5fd35d3485106b59f7897c0529b72447330
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
@@ -1,20 +1,14 @@
#include "Headshot.h"
#include "plugin.h"
#include "game_sa\FxManager_c.h"

using namespace plugin;

void Headshot::Setup() {
patch::RedirectCall(0x4B3A49, DoHeadshot);
}

void __fastcall Headshot::DoHeadshot(CPed *ped, int, unsigned int boneId, int) {
if (ped->m_apBones[boneId]->m_pIFrame) {
void Headshot::DoHeadshot(CPed *ped, int bodyPartToRemove) {
if (bodyPartToRemove == 2 && ped->m_apBones[bodyPartToRemove]->m_pIFrame) {
ped->m_nPedFlags.bRemoveHead = true;
ped->m_nBodypartToRemove = boneId;
ped->m_nBodypartToRemove = bodyPartToRemove;
RwV3d position;
ped->GetBonePosition(position, 0, true);
FxSystem_c *particle = g_fxMan.CreateFxSystem("headshot", &position, 0, 0);
particle->PlayAndKill();
if (particle)
particle->PlayAndKill();
}
}
@@ -2,7 +2,6 @@
#include "game_sa\CPed.h"

class Headshot {
static void __fastcall DoHeadshot(CPed *ped, int, unsigned int boneId, int);
public:
static void Setup();
static void DoHeadshot(CPed *ped, int bodyPartToRemove);
};
@@ -26,6 +26,7 @@ IMFX::IMFX() {
static CdeclEvent<AddressList<0x53DE2B, H_CALL, 0x53E213, H_CALL>, PRIORITY_BEFORE, ArgPickNone, void()> imfxSpecialFxRender;
static CdeclEvent<AddressList<0x53EAD3, H_CALL>, PRIORITY_BEFORE, ArgPickNone, void()> imfxAfterPreRender;
static ThiscallEvent<AddressList<0x4A273E, H_CALL>, PRIORITY_BEFORE, ArgPick2N<FxPrimBP_c*, 0, RwMatrix*, 1>, void(FxPrimBP_c*, RwMatrix*)> imfxGetLocalParticleMatrix;
static ThiscallEvent<AddressList<0x4B3A49, H_CALL>, PRIORITY_AFTER, ArgPick2N<CPed *, 0, int, 1>, void(CPed*, int, int)> imfxRemovePedHeadEvent;

if (settings.bEnableDebugConsole) {
Events::drawingEvent += [] {
@@ -36,7 +37,7 @@ IMFX::IMFX() {
Events::initRwEvent += [] {
settings.Read();
if (settings.bEnableHeadshot) {
Headshot::Setup();
imfxRemovePedHeadEvent += Headshot::DoHeadshot;
}
if (settings.bEnableMoonphases) {
Moonphases::Setup();

0 comments on commit 65e9c5f

Please sign in to comment.