added amb595, eye position and angle natives

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401225
This commit is contained in:
Borja Ferrer 2007-07-31 02:08:25 +00:00
parent 4a6a016790
commit d05a57fcba
6 changed files with 132 additions and 14 deletions

View File

@ -42,6 +42,7 @@ IServerPluginHelpers *pluginhelpers = NULL;
IBinTools *g_pBinTools = NULL; IBinTools *g_pBinTools = NULL;
IGameConfig *g_pGameConf = NULL; IGameConfig *g_pGameConf = NULL;
IGameHelpers *g_pGameHelpers = NULL; IGameHelpers *g_pGameHelpers = NULL;
IServerGameClients *serverClients = NULL;
HandleType_t g_CallHandle = 0; HandleType_t g_CallHandle = 0;
HandleType_t g_TraceHandle = 0; HandleType_t g_TraceHandle = 0;
@ -115,6 +116,7 @@ bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool
GET_V_IFACE_ANY(engineFactory, enginetrace, IEngineTrace, INTERFACEVERSION_ENGINETRACE_SERVER); GET_V_IFACE_ANY(engineFactory, enginetrace, IEngineTrace, INTERFACEVERSION_ENGINETRACE_SERVER);
GET_V_IFACE_ANY(engineFactory, netstringtables, INetworkStringTableContainer, INTERFACENAME_NETWORKSTRINGTABLESERVER); GET_V_IFACE_ANY(engineFactory, netstringtables, INetworkStringTableContainer, INTERFACENAME_NETWORKSTRINGTABLESERVER);
GET_V_IFACE_ANY(engineFactory, pluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS); GET_V_IFACE_ANY(engineFactory, pluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
GET_V_IFACE_ANY(serverFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
return true; return true;
} }

View File

@ -72,6 +72,7 @@ extern IEngineTrace *enginetrace;
extern IEngineSound *engsound; extern IEngineSound *engsound;
extern INetworkStringTableContainer *netstringtables; extern INetworkStringTableContainer *netstringtables;
extern IServerPluginHelpers *pluginhelpers; extern IServerPluginHelpers *pluginhelpers;
extern IServerGameClients *serverClients;
/* Interfaces from SourceMod */ /* Interfaces from SourceMod */
extern IBinTools *g_pBinTools; extern IBinTools *g_pBinTools;
extern IGameConfig *g_pGameConf; extern IGameConfig *g_pGameConf;

View File

@ -502,21 +502,76 @@ static cell_t SlapPlayer(IPluginContext *pContext, const cell_t *params)
return 1; return 1;
} }
static cell_t GetClientEyePosition(IPluginContext *pContext, const cell_t *params)
{
IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
if (player == NULL)
{
return pContext->ThrowNativeError("Invalid client index %d", params[1]);
}
if (!player->IsInGame())
{
return pContext->ThrowNativeError("Client %d is not in game", params[1]);
}
Vector pos;
serverClients->ClientEarPosition(player->GetEdict(), &pos);
cell_t *addr;
pContext->LocalToPhysAddr(params[2], &addr);
addr[0] = sp_ftoc(pos.x);
addr[1] = sp_ftoc(pos.y);
addr[2] = sp_ftoc(pos.z);
return 1;
}
static cell_t GetClientEyeAngles(IPluginContext *pContext, const cell_t *params)
{
static ValveCall *pCall = NULL;
if (!pCall)
{
ValvePassInfo retinfo[1];
InitPass(retinfo[0], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
if (!CreateBaseCall("EyeAngles", ValveCall_Player, retinfo, NULL, 0, &pCall))
{
return pContext->ThrowNativeError("\"EyeAngles\" not supported by this mod");
} else if (!pCall) {
return pContext->ThrowNativeError("\"EyeAngles\" wrapper failed to initialized");
}
}
QAngle *ang;
START_CALL();
DECODE_VALVE_PARAM(1, thisinfo, 0);
FINISH_CALL_SIMPLE(&ang);
cell_t *addr;
pContext->LocalToPhysAddr(params[2], &addr);
addr[0] = sp_ftoc(ang->x);
addr[1] = sp_ftoc(ang->y);
addr[2] = sp_ftoc(ang->z);
return 1;
}
sp_nativeinfo_t g_Natives[] = sp_nativeinfo_t g_Natives[] =
{ {
{"ExtinguishPlayer", ExtinguishPlayer}, {"ExtinguishPlayer", ExtinguishPlayer},
{"ExtinguishEntity", ExtinguishPlayer}, {"ExtinguishEntity", ExtinguishPlayer},
{"ForcePlayerSuicide", ForcePlayerSuicide}, {"ForcePlayerSuicide", ForcePlayerSuicide},
{"GivePlayerItem", GiveNamedItem}, {"GivePlayerItem", GiveNamedItem},
{"GetPlayerWeaponSlot", GetPlayerWeaponSlot}, {"GetPlayerWeaponSlot", GetPlayerWeaponSlot},
{"IgnitePlayer", IgnitePlayer}, {"IgnitePlayer", IgnitePlayer},
{"IgniteEntity", IgnitePlayer}, {"IgniteEntity", IgnitePlayer},
{"RemovePlayerItem", RemovePlayerItem}, {"RemovePlayerItem", RemovePlayerItem},
{"TeleportPlayer", TeleportPlayer}, {"TeleportPlayer", TeleportPlayer},
{"TeleportEntity", TeleportPlayer}, {"TeleportEntity", TeleportPlayer},
{"SetClientViewEntity", SetClientViewEntity}, {"SetClientViewEntity", SetClientViewEntity},
{"SetLightStyle", SetLightStyle}, {"SetLightStyle", SetLightStyle},
{"SlapPlayer", SlapPlayer}, {"SlapPlayer", SlapPlayer},
{NULL, NULL}, {"GetClientEyePosition", GetClientEyePosition},
{"GetClientEyeAngles", GetClientEyeAngles},
{NULL, NULL},
}; };

View File

@ -173,6 +173,11 @@
"windows" "126" "windows" "126"
"linux" "127" "linux" "127"
} }
"EyeAngles"
{
"windows" "118"
"linux" "119"
}
} }
} }
@ -221,6 +226,11 @@
"windows" "126" "windows" "126"
"linux" "127" "linux" "127"
} }
"EyeAngles"
{
"windows" "118"
"linux" "119"
}
} }
} }
@ -269,6 +279,11 @@
"windows" "126" "windows" "126"
"linux" "127" "linux" "127"
} }
"EyeAngles"
{
"windows" "118"
"linux" "119"
}
} }
} }
@ -318,6 +333,11 @@
"windows" "124" "windows" "124"
"linux" "125" "linux" "125"
} }
"EyeAngles"
{
"windows" "116"
"linux" "117"
}
/* Temp Entities */ /* Temp Entities */
"TE_GetServerClass" "TE_GetServerClass"
@ -375,6 +395,11 @@
"windows" "128" "windows" "128"
"linux" "129" "linux" "129"
} }
"EyeAngles"
{
"windows" "120"
"linux" "121"
}
/* Offset into CBaseTempEntity constructor. /* Offset into CBaseTempEntity constructor.
* On Windows Dsytopia is heavily inlined; we use the function * On Windows Dsytopia is heavily inlined; we use the function
@ -438,6 +463,11 @@
"windows" "115" "windows" "115"
"linux" "116" "linux" "116"
} }
"EyeAngles"
{
"windows" "107"
"linux" "108"
}
/* Temp Entities */ /* Temp Entities */
"s_pTempEntities" "s_pTempEntities"
@ -493,6 +523,11 @@
"windows" "126" "windows" "126"
"linux" "127" "linux" "127"
} }
"EyeAngles"
{
"windows" "118"
"linux" "119"
}
/* Temp Entities */ /* Temp Entities */
"s_pTempEntities" "s_pTempEntities"
@ -543,6 +578,11 @@
"windows" "114" "windows" "114"
"linux" "115" "linux" "115"
} }
"EyeAngles"
{
"windows" "106"
"linux" "107"
}
/* Temp Entities */ /* Temp Entities */
"s_pTempEntities" "s_pTempEntities"

View File

@ -40,3 +40,13 @@ native SetClientViewEntity(client, entity);
* @error Light style index is out of range. * @error Light style index is out of range.
*/ */
native SetLightStyle(style, const String:value[]); native SetLightStyle(style, const String:value[]);
/**
* Returns the client's eye position.
*
* @param client Player's index.
* @param pos Destination vector to store the client's eye position.
* @noreturn
* @error Invalid client index, client not in game, or no mod support.
*/
native GetClientEyePosition(client, Float:pos[3]);

View File

@ -104,6 +104,16 @@ native ForcePlayerSuicide(client);
*/ */
native SlapPlayer(client, health=5, bool:sound=true); native SlapPlayer(client, health=5, bool:sound=true);
/**
* Returns the client's eye angles.
*
* @param client Player's index.
* @param ang Destination vector to store the client's eye angles.
* @noreturn
* @error Invalid client index, client not in game, or no mod support.
*/
native GetClientEyeAngles(client, Float:ang[3]);
/** /**
* @deprecated * @deprecated
*/ */