Veteran Member
|
10-30-2013
, 14:48
Re: About SV_StudioSetupBones
|
#3
|
Ok,thanks. Look this thread http://forums.alliedmods.net/showthread.php?t=196602
Problem with hitboxes.
SV_StudioSetupBones called with mp.dll,but doesn't called with swds.dll
Need hook it with mp.dll and called it with arguments from swds.dll, but i get problem with arguments.
I'm create npc (info_target), function is called, but not all arguments is correct
Debug: frame 30.000000 Animation 2, angles 0.000000 0.000000 0.000000, origin 0.
000000 -1.#QNAN0 0.000000
problem with angles,origin ...
PHP Code:
#include <extdll.h>
#include <meta_api.h>
#include "СHooker.h"
#if _MSC_VER
#if _MSC_VER >= 1400
#define stricmp _stricmp
#endif
#endif
#ifdef __linux__
#define stricmp strcasecmp
#endif
plugin_info_t Plugin_info =
{
META_INTERFACE_VERSION, // ifvers
"x", // name
"0.0.0.1", // version
"30/10/2013", // date
"Andrei", // author
"x", // url
"x", // logtag, all caps please
PT_ANYTIME, // (when) loadable
PT_ANYPAUSE // (when) unloadable
};
meta_globals_t *gpMetaGlobals;
mutil_funcs_t *gpMetaUtilFuncs;
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
gamedll_funcs_t *gpGamedllFuncs;
CHooker HookerClass;
CHooker* Hooker = &HookerClass;
typedef void ( *FuncSV_StudioSetupBones ) ( struct model_s *, float, int, const vec3_t, const vec3_t, const byte *, const byte *, edict_t *, signed int );
void FuncSV_StudioSetupBones_Hook( struct model_s *pModel, float frame, int sequence, const vec3_t angles, const vec3_t origin, const byte *pcontroller, const byte *pblending,
edict_t * pEdict, signed int iBone );
CFunc* FuncSV_StudioSetupBonesHook = NULL;
FuncSV_StudioSetupBones FuncSV_StudioSetupBonesOrig = NULL;
void FuncSV_StudioSetupBones_Hook( struct model_s *pModel, float frame, int sequence, const vec3_t angles, const vec3_t origin, const byte *pcontroller, const byte *pblending,
edict_t * pEdict, signed int iBone )
{
printf( "Debug: frame %f Animation %d, angles %f %f %f, origin %f %f %f\n", frame, sequence, angles.x,angles.y,angles.z, origin.x, origin.y, origin.z );
/*if( FuncSV_StudioSetupBonesHook->Restore() )
{
FuncSV_StudioSetupBones_Hook( pModel, frame, sequence, angles, origin, pcontroller, pblending, pEdict, iBone );
FuncSV_StudioSetupBonesHook->Patch();
}*/
}
C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs)
{
gpMetaUtilFuncs = pMetaUtilFuncs;
*pPlugInfo = &Plugin_info;
return(TRUE);
}
static META_FUNCTIONS gMetaFunctionTable;
C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs)
{
gpMetaGlobals = pMGlobals;
gpGamedllFuncs=pGamedllFuncs;
memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS));
FuncSV_StudioSetupBonesOrig = Hooker->MemorySearch< FuncSV_StudioSetupBones >( "0x81,0xEC,*,*,*,*,0x53,0x55,0x8B,0xAC,0x24,0x68,0x02,0x00,0x00,0x56,0x57,0x55,0x33,0xFF,0xFF,0x15,*,*,*,*,0x8B,0x8C,0x24,0x7C,0x02,0x00,0x00,0x83,0xC4,0x04,0x85,0xC9,0xA3,*,*,*,*,0x7C,*,0x3B,0x88,0xA4,0x00,0x00,0x00,0x7C,*", ( void* )MDLL_Spawn, FALSE );
//FuncSV_StudioSetupBonesOrig_Engine = Hooker->MemorySearch< FuncSV_StudioSetupBones_Engine >( "0x55,0x8B,0xEC,0x83,0xEC,0x48,0xA1,*,*,*,*,0x8B,0x0D,*,*,*,*,0x53,0x56,0x8B,0x90,0xDC,0x02,0x00,0x00,0x8B,0xB1,0xA4,0x00,0x00,0x00,0x3B,0xD6,0x57,0x7C,*,0xC7,0x80,0xDC,0x02,0x00,0x00,0x00,0x00,0x00,0x00", "engine", FALSE );
FuncSV_StudioSetupBonesHook = Hooker->CreateHook( ( void* )FuncSV_StudioSetupBonesOrig, ( void* )FuncSV_StudioSetupBones_Hook, TRUE );
return(TRUE);
}
#ifdef __linux__
// linux prototype
C_DLLEXPORT void GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals)
{
#else
#ifdef _MSC_VER
// MSVC: Simulate __stdcall calling convention
C_DLLEXPORT __declspec(naked) void GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals)
{
__asm // Prolog
{
// Save ebp
push ebp
// Set stack frame pointer
mov ebp, esp
// Allocate space for local variables
// The MSVC compiler gives us the needed size in __LOCAL_SIZE.
sub esp, __LOCAL_SIZE
// Push registers
push ebx
push esi
push edi
}
#else // _MSC_VER
#ifdef __GNUC__
// GCC can also work with this
C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
{
#else // __GNUC__
// compiler not known
#error There is no support (yet) for your compiler. Please use MSVC or GCC compilers or contact the AMX Mod X dev team.
#endif // __GNUC__
#endif // _MSC_VER
#endif // __linux__
// ** Function core <--
memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
gpGlobals = pGlobals;
// --> ** Function core
#ifdef _MSC_VER
// Epilog
if (sizeof(int*) == 8)
{ // 64 bit
__asm
{
// Pop registers
pop edi
pop esi
pop ebx
// Restore stack frame pointer
mov esp, ebp
// Restore ebp
pop ebp
// 2 * sizeof(int*) = 16 on 64 bit
ret 16
}
}
else
{ // 32 bit
__asm
{
// Pop registers
pop edi
pop esi
pop ebx
// Restore stack frame pointer
mov esp, ebp
// Restore ebp
pop ebp
// 2 * sizeof(int*) = 8 on 32 bit
ret 8
}
}
#endif // #ifdef _MSC_VER
}
PHP Code:
#include < amxmodx >
#include < fakemeta >
#define g_szModel "models/alien.mdl"
new Float:vecOrigin[ 3 ];
public plugin_precache( )
precache_model( g_szModel );
public plugin_init( )
{
register_clcmd( "say /Origin", "ClientCommand_Origin" );
register_clcmd( "say /Create", "ClientCommand__CreateEntity" );
}
public ClientCommand_Origin( pPlayer )
pev( pPlayer, pev_origin, vecOrigin );
public ClientCommand__CreateEntity( pPlayer )
{
new pEntity = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) );
if( !pev_valid( pEntity ) )
return;
set_pev( pEntity, pev_classname, "Alien" );
set_pev( pEntity, pev_model, g_szModel );
set_pev( pEntity, pev_solid, SOLID_BBOX);
set_pev( pEntity, pev_movetype, MOVETYPE_PUSHSTEP);
vecOrigin[ 1 ] += 50.0;
engfunc( EngFunc_SetModel, pEntity, g_szModel);
engfunc( EngFunc_SetSize, pEntity, Float:{ -32.0, -32.0, -36.0}, Float:{ 32.0, 32.0, 32.0 });
engfunc( EngFunc_SetOrigin, pEntity, vecOrigin );
set_pev( pEntity, pev_sequence, 2 );
set_pev( pEntity, pev_frame, 30);
set_pev( pEntity, pev_animtime, get_gametime());
set_pev( pEntity, pev_framerate, 1.0 );
}
Why arguments are passed is not true? Sorry for my bad English
Last edited by Bos93; 10-31-2013 at 01:41.
|
|