Skip to content

Commit

Permalink
Fix MakeBleed native call (add damage custom param)..
Browse files Browse the repository at this point in the history
  • Loading branch information
psychonic committed Oct 22, 2017
1 parent a5c213a commit 5cf6a0c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions extensions/tf2/natives.cpp
Expand Up @@ -45,7 +45,7 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
if(!pWrapper)
{
REGISTER_NATIVE_ADDR("MakeBleed",
PassInfo pass[5]; \
PassInfo pass[6]; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].size = sizeof(CBaseEntity *); \
pass[0].type = PassType_Basic; \
Expand All @@ -61,7 +61,10 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
pass[4].flags = PASSFLAG_BYVAL; \
pass[4].size = sizeof(bool); \
pass[4].type = PassType_Basic; \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 5))
pass[5].flags = PASSFLAG_BYVAL; \
pass[5].size = sizeof(int); \
pass[5].type = PassType_Basic; \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 6))
}

CBaseEntity *pEntity;
Expand All @@ -78,7 +81,7 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)

void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset);

unsigned char vstk[sizeof(void *) + 2*sizeof(CBaseEntity *) + sizeof(float) + sizeof(int) + sizeof(bool)];
unsigned char vstk[sizeof(void *) + 2*sizeof(CBaseEntity *) + sizeof(float) + sizeof(int) + sizeof(bool) + sizeof(int)];
unsigned char *vptr = vstk;

*(void **)vptr = obj;
Expand All @@ -89,9 +92,11 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
vptr += sizeof(CBaseEntity *);
*(float *)vptr = sp_ctof(params[3]);
vptr += sizeof(float);
*(int *)vptr = 4;
*(int *)vptr = 4; // Damage amount
vptr += sizeof(int);
*(bool *)vptr = false;
*(bool *)vptr = false; // Permanent
vptr += sizeof(bool);
*(int *)vptr = 34; // Custom Damage type (bleeding)

pWrapper->Execute(vstk, NULL);

Expand Down

0 comments on commit 5cf6a0c

Please sign in to comment.