# HG changeset patch # User Borja Ferrer # Date 1185847705 0 # Node ID 6f440a361fa70a2c00223bac15e5c1f4b622fbc2 # Parent a4e82ef4e7efa77fd27b17f1f598d383079e3334 added amb595, eye position and angle natives diff -r a4e82ef4e7ef -r 6f440a361fa7 extensions/sdktools/extension.cpp --- a/extensions/sdktools/extension.cpp Mon Jul 30 23:16:58 2007 +0000 +++ b/extensions/sdktools/extension.cpp Tue Jul 31 02:08:25 2007 +0000 @@ -42,6 +42,7 @@ IBinTools *g_pBinTools = NULL; IGameConfig *g_pGameConf = NULL; IGameHelpers *g_pGameHelpers = NULL; +IServerGameClients *serverClients = NULL; HandleType_t g_CallHandle = 0; HandleType_t g_TraceHandle = 0; @@ -115,6 +116,7 @@ GET_V_IFACE_ANY(engineFactory, enginetrace, IEngineTrace, INTERFACEVERSION_ENGINETRACE_SERVER); GET_V_IFACE_ANY(engineFactory, netstringtables, INetworkStringTableContainer, INTERFACENAME_NETWORKSTRINGTABLESERVER); GET_V_IFACE_ANY(engineFactory, pluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS); + GET_V_IFACE_ANY(serverFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS); return true; } diff -r a4e82ef4e7ef -r 6f440a361fa7 extensions/sdktools/extension.h --- a/extensions/sdktools/extension.h Mon Jul 30 23:16:58 2007 +0000 +++ b/extensions/sdktools/extension.h Tue Jul 31 02:08:25 2007 +0000 @@ -72,6 +72,7 @@ extern IEngineSound *engsound; extern INetworkStringTableContainer *netstringtables; extern IServerPluginHelpers *pluginhelpers; +extern IServerGameClients *serverClients; /* Interfaces from SourceMod */ extern IBinTools *g_pBinTools; extern IGameConfig *g_pGameConf; diff -r a4e82ef4e7ef -r 6f440a361fa7 extensions/sdktools/vnatives.cpp --- a/extensions/sdktools/vnatives.cpp Mon Jul 30 23:16:58 2007 +0000 +++ b/extensions/sdktools/vnatives.cpp Tue Jul 31 02:08:25 2007 +0000 @@ -502,21 +502,76 @@ 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[] = { - {"ExtinguishPlayer", ExtinguishPlayer}, - {"ExtinguishEntity", ExtinguishPlayer}, - {"ForcePlayerSuicide", ForcePlayerSuicide}, - {"GivePlayerItem", GiveNamedItem}, - {"GetPlayerWeaponSlot", GetPlayerWeaponSlot}, - {"IgnitePlayer", IgnitePlayer}, - {"IgniteEntity", IgnitePlayer}, - {"RemovePlayerItem", RemovePlayerItem}, - {"TeleportPlayer", TeleportPlayer}, - {"TeleportEntity", TeleportPlayer}, - {"SetClientViewEntity", SetClientViewEntity}, - {"SetLightStyle", SetLightStyle}, - {"SlapPlayer", SlapPlayer}, - {NULL, NULL}, + {"ExtinguishPlayer", ExtinguishPlayer}, + {"ExtinguishEntity", ExtinguishPlayer}, + {"ForcePlayerSuicide", ForcePlayerSuicide}, + {"GivePlayerItem", GiveNamedItem}, + {"GetPlayerWeaponSlot", GetPlayerWeaponSlot}, + {"IgnitePlayer", IgnitePlayer}, + {"IgniteEntity", IgnitePlayer}, + {"RemovePlayerItem", RemovePlayerItem}, + {"TeleportPlayer", TeleportPlayer}, + {"TeleportEntity", TeleportPlayer}, + {"SetClientViewEntity", SetClientViewEntity}, + {"SetLightStyle", SetLightStyle}, + {"SlapPlayer", SlapPlayer}, + {"GetClientEyePosition", GetClientEyePosition}, + {"GetClientEyeAngles", GetClientEyeAngles}, + {NULL, NULL}, }; diff -r a4e82ef4e7ef -r 6f440a361fa7 gamedata/sdktools.games.txt --- a/gamedata/sdktools.games.txt Mon Jul 30 23:16:58 2007 +0000 +++ b/gamedata/sdktools.games.txt Tue Jul 31 02:08:25 2007 +0000 @@ -173,6 +173,11 @@ "windows" "126" "linux" "127" } + "EyeAngles" + { + "windows" "118" + "linux" "119" + } } } @@ -221,6 +226,11 @@ "windows" "126" "linux" "127" } + "EyeAngles" + { + "windows" "118" + "linux" "119" + } } } @@ -269,6 +279,11 @@ "windows" "126" "linux" "127" } + "EyeAngles" + { + "windows" "118" + "linux" "119" + } } } @@ -318,6 +333,11 @@ "windows" "124" "linux" "125" } + "EyeAngles" + { + "windows" "116" + "linux" "117" + } /* Temp Entities */ "TE_GetServerClass" @@ -375,6 +395,11 @@ "windows" "128" "linux" "129" } + "EyeAngles" + { + "windows" "120" + "linux" "121" + } /* Offset into CBaseTempEntity constructor. * On Windows Dsytopia is heavily inlined; we use the function @@ -438,6 +463,11 @@ "windows" "115" "linux" "116" } + "EyeAngles" + { + "windows" "107" + "linux" "108" + } /* Temp Entities */ "s_pTempEntities" @@ -493,6 +523,11 @@ "windows" "126" "linux" "127" } + "EyeAngles" + { + "windows" "118" + "linux" "119" + } /* Temp Entities */ "s_pTempEntities" @@ -543,6 +578,11 @@ "windows" "114" "linux" "115" } + "EyeAngles" + { + "windows" "106" + "linux" "107" + } /* Temp Entities */ "s_pTempEntities" diff -r a4e82ef4e7ef -r 6f440a361fa7 plugins/include/sdktools_engine.inc --- a/plugins/include/sdktools_engine.inc Mon Jul 30 23:16:58 2007 +0000 +++ b/plugins/include/sdktools_engine.inc Tue Jul 31 02:08:25 2007 +0000 @@ -40,3 +40,13 @@ * @error Light style index is out of range. */ 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]); diff -r a4e82ef4e7ef -r 6f440a361fa7 plugins/include/sdktools_functions.inc --- a/plugins/include/sdktools_functions.inc Mon Jul 30 23:16:58 2007 +0000 +++ b/plugins/include/sdktools_functions.inc Tue Jul 31 02:08:25 2007 +0000 @@ -105,6 +105,16 @@ 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 */ stock IgnitePlayer(client, Float:time, bool:npc=false, Float:size=0.0, bool:level=false)