Post: Trouble getting Tag Positon
11-26-2016, 06:06 AM #1
(adsbygoogle = window.adsbygoogle || []).push({}); Ok so I've tried calling both AimTarget_GetTagPos (sub_54C8Cool Man (aka Tustin) and AimTarget_GetTagPos_0 (sub_58100) but it always crashes me, an example of how i try to call AimTarget_GetTagPos
    
//int __cdecl AimTarget_GetTagPos(int localClientNum, centity_s *cent, unsigned int tagName, float *pos)
unsigned short tagpos[8];
float storeOutPos[3];
AimTarget_GetTagPos(0,(cEntity*)getCentityPtr(0),tagpos[0],storeOutPos);

But this crashes me..

I've also tried AimTarget_GetTagPos_0
    //void __cdecl AimTarget_GetTagPos_0(centity_s *ent, unsigned int tagName, float *pos)
unsigned short tagpos[8];
float storeOutPos[3];
AimTarget_GetTagPos_0((cEntity*)getCentityPtr(0),tagpos[0],storeOutPos);


but it crashes me as well. (I'm doing everything within a cg_draw2d hook btw)

I don't see why this would crash me? I've (for the most part) used the same method which works fine on other cods, but not bo1?

Any help would be appreciated Smile
Last edited by geegeewap ; 11-26-2016 at 06:09 AM.
11-26-2016, 06:53 PM #2
mrtn
Little One
Originally posted by geegeewap View Post
Ok so I've tried calling both AimTarget_GetTagPos (sub_54C8Cool Man (aka Tustin) and AimTarget_GetTagPos_0 (sub_58100) but it always crashes me, an example of how i try to call AimTarget_GetTagPos
    
//int __cdecl AimTarget_GetTagPos(int localClientNum, centity_s *cent, unsigned int tagName, float *pos)
unsigned short tagpos[8];
float storeOutPos[3];
AimTarget_GetTagPos(0,(cEntity*)getCentityPtr(0),tagpos[0],storeOutPos);

But this crashes me..

I've also tried AimTarget_GetTagPos_0
    //void __cdecl AimTarget_GetTagPos_0(centity_s *ent, unsigned int tagName, float *pos)
unsigned short tagpos[8];
float storeOutPos[3];
AimTarget_GetTagPos_0((cEntity*)getCentityPtr(0),tagpos[0],storeOutPos);


but it crashes me as well. (I'm doing everything within a cg_draw2d hook btw)

I don't see why this would crash me? I've (for the most part) used the same method which works fine on other cods, but not bo1?

Any help would be appreciated Smile


This works perfectly fine for me:
    
centity_s* CentityPtr(int clientNum) {
return (centity_s*)((*(int*)0xC3DFC0) + 0x31C * clientNum);
}

opd_s AimTarget_GetTagPos_t = { 0x54C88, TOC };
opd_s SL_GetString_t = { 0x5B99C8, TOC };
int(*SL_GetString)(const char* string, unsigned int user, scriptInstance_t inst) = (int(*)(const char*, unsigned int, scriptInstance_t))&SL_GetString_t;
int(*AimTarget_GetTagPos)(int localClientNum, centity_s* cent, unsigned int tagName, float pos[3]) = (int(*)(int, centity_s*, unsigned int, float[3]))&AimTarget_GetTagPos_t;

void test(int clientNum) {
float pos[3];
unsigned int tagIndex = SL_GetString("j_head", 0, SCRIPTINSTANCE_SERVER);
if(AimTarget_GetTagPos(0, CentityPtr(clientNum), tagIndex, pos))
printf("pos: %f, %f, %f\n", pos[0], pos[1], pos[2]);
}
11-26-2016, 08:01 PM #3
mrtn
Little One
Originally posted by geegeewap View Post
Ok so I've tried calling both AimTarget_GetTagPos (sub_54C8Cool Man (aka Tustin) and AimTarget_GetTagPos_0 (sub_58100) but it always crashes me, an example of how i try to call AimTarget_GetTagPos
    
//int __cdecl AimTarget_GetTagPos(int localClientNum, centity_s *cent, unsigned int tagName, float *pos)
unsigned short tagpos[8];
float storeOutPos[3];
AimTarget_GetTagPos(0,(cEntity*)getCentityPtr(0),tagpos[0],storeOutPos);

But this crashes me..

I've also tried AimTarget_GetTagPos_0
    //void __cdecl AimTarget_GetTagPos_0(centity_s *ent, unsigned int tagName, float *pos)
unsigned short tagpos[8];
float storeOutPos[3];
AimTarget_GetTagPos_0((cEntity*)getCentityPtr(0),tagpos[0],storeOutPos);


but it crashes me as well. (I'm doing everything within a cg_draw2d hook btw)

I don't see why this would crash me? I've (for the most part) used the same method which works fine on other cods, but not bo1?

Any help would be appreciated Smile


Forgot that I only tested that once in Split Screen ages ago and that works, but you'll crash in multiplayer I'm pretty sure. You'll have to rebuild the function to make it work
11-26-2016, 10:54 PM #4
Originally posted by mrtn View Post
This works perfectly fine for me:
    
centity_s* CentityPtr(int clientNum) {
return (centity_s*)((*(int*)0xC3DFC0) + 0x31C * clientNum);
}

opd_s AimTarget_GetTagPos_t = { 0x54C88, TOC };
opd_s SL_GetString_t = { 0x5B99C8, TOC };
int(*SL_GetString)(const char* string, unsigned int user, scriptInstance_t inst) = (int(*)(const char*, unsigned int, scriptInstance_t))&SL_GetString_t;
int(*AimTarget_GetTagPos)(int localClientNum, centity_s* cent, unsigned int tagName, float pos[3]) = (int(*)(int, centity_s*, unsigned int, float[3]))&AimTarget_GetTagPos_t;

void test(int clientNum) {
float pos[3];
unsigned int tagIndex = SL_GetString("j_head", 0, SCRIPTINSTANCE_SERVER);
if(AimTarget_GetTagPos(0, CentityPtr(clientNum), tagIndex, pos))
printf("pos: %f, %f, %f\n", pos[0], pos[1], pos[2]);
}


Have you actually personally tried this? Because this was the very first thing i tried when attempting to get tag pos. I'll give it another try, still quite sure it will cause a crash. Things seem weird in bo1, e.g. certain functions will cause a crash yet in other cods it doesn't
11-26-2016, 11:06 PM #5
mrtn
Little One
Originally posted by geegeewap View Post
Have you actually personally tried this? Because this was the very first thing i tried when attempting to get tag pos. I'll give it another try, still quite sure it will cause a crash. Things seem weird in bo1, e.g. certain functions will cause a crash yet in other cods it doesn't


Look at my above post
11-26-2016, 11:25 PM #6
Originally posted by mrtn View Post
Look at my above post


My bad just saw it haha
11-26-2016, 11:26 PM #7
Originally posted by mrtn View Post
Look at my above post


I wonder if it'll work using a different calling convention (e.g. inline asm)
11-28-2016, 06:13 PM #8
-JM-
Space Ninja
Originally posted by geegeewap View Post
I wonder if it'll work using a different calling convention (e.g. inline asm)


Here an idea VM_notify ?

Copyright © 2025, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo