added amb595, eye position and angle natives
authorBorja Ferrer <faluco@alliedmods.net>
Tue Jul 31 02:08:25 2007 +0000 (2007-07-31)
changeset 12196f440a361fa7
parent 1218 a4e82ef4e7ef
child 1220 4f111b467bfa
added amb595, eye position and angle natives
extensions/sdktools/extension.cpp
extensions/sdktools/extension.h
extensions/sdktools/vnatives.cpp
gamedata/sdktools.games.txt
plugins/include/sdktools_engine.inc
plugins/include/sdktools_functions.inc
     1.1 --- a/extensions/sdktools/extension.cpp	Mon Jul 30 23:16:58 2007 +0000
     1.2 +++ b/extensions/sdktools/extension.cpp	Tue Jul 31 02:08:25 2007 +0000
     1.3 @@ -42,6 +42,7 @@
     1.4  IBinTools *g_pBinTools = NULL;
     1.5  IGameConfig *g_pGameConf = NULL;
     1.6  IGameHelpers *g_pGameHelpers = NULL;
     1.7 +IServerGameClients *serverClients = NULL;
     1.8  HandleType_t g_CallHandle = 0;
     1.9  HandleType_t g_TraceHandle = 0;
    1.10  
    1.11 @@ -115,6 +116,7 @@
    1.12  	GET_V_IFACE_ANY(engineFactory, enginetrace, IEngineTrace, INTERFACEVERSION_ENGINETRACE_SERVER);
    1.13  	GET_V_IFACE_ANY(engineFactory, netstringtables, INetworkStringTableContainer, INTERFACENAME_NETWORKSTRINGTABLESERVER);
    1.14  	GET_V_IFACE_ANY(engineFactory, pluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
    1.15 +	GET_V_IFACE_ANY(serverFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
    1.16  
    1.17  	return true;
    1.18  }
     2.1 --- a/extensions/sdktools/extension.h	Mon Jul 30 23:16:58 2007 +0000
     2.2 +++ b/extensions/sdktools/extension.h	Tue Jul 31 02:08:25 2007 +0000
     2.3 @@ -72,6 +72,7 @@
     2.4  extern IEngineSound *engsound;
     2.5  extern INetworkStringTableContainer *netstringtables;
     2.6  extern IServerPluginHelpers *pluginhelpers;
     2.7 +extern IServerGameClients *serverClients;
     2.8  /* Interfaces from SourceMod */
     2.9  extern IBinTools *g_pBinTools;
    2.10  extern IGameConfig *g_pGameConf;
     3.1 --- a/extensions/sdktools/vnatives.cpp	Mon Jul 30 23:16:58 2007 +0000
     3.2 +++ b/extensions/sdktools/vnatives.cpp	Tue Jul 31 02:08:25 2007 +0000
     3.3 @@ -502,21 +502,76 @@
     3.4  	return 1;
     3.5  }
     3.6  
     3.7 +static cell_t GetClientEyePosition(IPluginContext *pContext, const cell_t *params)
     3.8 +{
     3.9 +	IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
    3.10 +	if (player == NULL)
    3.11 +	{
    3.12 +		return pContext->ThrowNativeError("Invalid client index %d", params[1]);
    3.13 +	}
    3.14 +	if (!player->IsInGame())
    3.15 +	{
    3.16 +		return pContext->ThrowNativeError("Client %d is not in game", params[1]);
    3.17 +	}
    3.18 +
    3.19 +	Vector pos;
    3.20 +	serverClients->ClientEarPosition(player->GetEdict(), &pos);
    3.21 +
    3.22 +	cell_t *addr;
    3.23 +	pContext->LocalToPhysAddr(params[2], &addr);
    3.24 +	addr[0] = sp_ftoc(pos.x);
    3.25 +	addr[1] = sp_ftoc(pos.y);
    3.26 +	addr[2] = sp_ftoc(pos.z);
    3.27 +
    3.28 +	return 1;
    3.29 +}
    3.30 +
    3.31 +static cell_t GetClientEyeAngles(IPluginContext *pContext, const cell_t *params)
    3.32 +{
    3.33 +	static ValveCall *pCall = NULL;
    3.34 +	if (!pCall)
    3.35 +	{
    3.36 +		ValvePassInfo retinfo[1];
    3.37 +		InitPass(retinfo[0], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
    3.38 +		if (!CreateBaseCall("EyeAngles", ValveCall_Player, retinfo, NULL, 0, &pCall))
    3.39 +		{
    3.40 +			return pContext->ThrowNativeError("\"EyeAngles\" not supported by this mod");
    3.41 +		} else if (!pCall) {
    3.42 +			return pContext->ThrowNativeError("\"EyeAngles\" wrapper failed to initialized");
    3.43 +		}
    3.44 +	}
    3.45 +
    3.46 +	QAngle *ang;
    3.47 +	START_CALL();
    3.48 +	DECODE_VALVE_PARAM(1, thisinfo, 0);
    3.49 +	FINISH_CALL_SIMPLE(&ang);
    3.50 +	
    3.51 +	cell_t *addr;
    3.52 +	pContext->LocalToPhysAddr(params[2], &addr);
    3.53 +	addr[0] = sp_ftoc(ang->x);
    3.54 +	addr[1] = sp_ftoc(ang->y);
    3.55 +	addr[2] = sp_ftoc(ang->z);
    3.56 +
    3.57 +	return 1;
    3.58 +}
    3.59 +
    3.60  sp_nativeinfo_t g_Natives[] = 
    3.61  {
    3.62 -	{"ExtinguishPlayer",	ExtinguishPlayer},
    3.63 -	{"ExtinguishEntity",	ExtinguishPlayer},
    3.64 -	{"ForcePlayerSuicide",	ForcePlayerSuicide},
    3.65 -	{"GivePlayerItem",		GiveNamedItem},
    3.66 -	{"GetPlayerWeaponSlot",	GetPlayerWeaponSlot},
    3.67 -	{"IgnitePlayer",		IgnitePlayer},
    3.68 -	{"IgniteEntity",		IgnitePlayer},
    3.69 -	{"RemovePlayerItem",	RemovePlayerItem},
    3.70 -	{"TeleportPlayer",		TeleportPlayer},
    3.71 -	{"TeleportEntity",		TeleportPlayer},
    3.72 -	{"SetClientViewEntity",	SetClientViewEntity},
    3.73 -	{"SetLightStyle",		SetLightStyle},
    3.74 -	{"SlapPlayer",			SlapPlayer},
    3.75 -	{NULL,					NULL},
    3.76 +	{"ExtinguishPlayer",		ExtinguishPlayer},
    3.77 +	{"ExtinguishEntity",		ExtinguishPlayer},
    3.78 +	{"ForcePlayerSuicide",		ForcePlayerSuicide},
    3.79 +	{"GivePlayerItem",			GiveNamedItem},
    3.80 +	{"GetPlayerWeaponSlot",		GetPlayerWeaponSlot},
    3.81 +	{"IgnitePlayer",			IgnitePlayer},
    3.82 +	{"IgniteEntity",			IgnitePlayer},
    3.83 +	{"RemovePlayerItem",		RemovePlayerItem},
    3.84 +	{"TeleportPlayer",			TeleportPlayer},
    3.85 +	{"TeleportEntity",			TeleportPlayer},
    3.86 +	{"SetClientViewEntity",		SetClientViewEntity},
    3.87 +	{"SetLightStyle",			SetLightStyle},
    3.88 +	{"SlapPlayer",				SlapPlayer},
    3.89 +	{"GetClientEyePosition",	GetClientEyePosition},
    3.90 +	{"GetClientEyeAngles",		GetClientEyeAngles},
    3.91 +	{NULL,						NULL},
    3.92  };
    3.93  
     4.1 --- a/gamedata/sdktools.games.txt	Mon Jul 30 23:16:58 2007 +0000
     4.2 +++ b/gamedata/sdktools.games.txt	Tue Jul 31 02:08:25 2007 +0000
     4.3 @@ -173,6 +173,11 @@
     4.4  				"windows"	"126"
     4.5  				"linux"		"127"
     4.6  			}
     4.7 +			"EyeAngles"
     4.8 +			{
     4.9 +				"windows"	"118"
    4.10 +				"linux"		"119"
    4.11 +			}
    4.12  		}
    4.13  	}
    4.14  
    4.15 @@ -221,6 +226,11 @@
    4.16  				"windows"	"126"
    4.17  				"linux"		"127"
    4.18  			}
    4.19 +			"EyeAngles"
    4.20 +			{
    4.21 +				"windows"	"118"
    4.22 +				"linux"		"119"
    4.23 +			}
    4.24  		}
    4.25  	}
    4.26  	
    4.27 @@ -269,6 +279,11 @@
    4.28  				"windows"	"126"
    4.29  				"linux"		"127"
    4.30  			}
    4.31 +			"EyeAngles"
    4.32 +			{
    4.33 +				"windows"	"118"
    4.34 +				"linux"		"119"
    4.35 +			}
    4.36  		}
    4.37  	}
    4.38  	
    4.39 @@ -318,6 +333,11 @@
    4.40  				"windows"	"124"
    4.41  				"linux"		"125"
    4.42  			}
    4.43 +			"EyeAngles"
    4.44 +			{
    4.45 +				"windows"	"116"
    4.46 +				"linux"		"117"
    4.47 +			}
    4.48  			
    4.49  			/* Temp Entities */
    4.50  			"TE_GetServerClass"
    4.51 @@ -375,6 +395,11 @@
    4.52  				"windows"	"128"
    4.53  				"linux"		"129"
    4.54  			}
    4.55 +			"EyeAngles"
    4.56 +			{
    4.57 +				"windows"	"120"
    4.58 +				"linux"		"121"
    4.59 +			}
    4.60  
    4.61  			/* Offset into CBaseTempEntity constructor.
    4.62  			 * On Windows Dsytopia is heavily inlined; we use the function 
    4.63 @@ -438,6 +463,11 @@
    4.64  				"windows"	"115"
    4.65  				"linux"		"116"
    4.66  			}
    4.67 +			"EyeAngles"
    4.68 +			{
    4.69 +				"windows"	"107"
    4.70 +				"linux"		"108"
    4.71 +			}
    4.72  
    4.73  			/* Temp Entities */
    4.74  			"s_pTempEntities"
    4.75 @@ -493,6 +523,11 @@
    4.76  				"windows"	"126"
    4.77  				"linux"		"127"
    4.78  			}
    4.79 +			"EyeAngles"
    4.80 +			{
    4.81 +				"windows"	"118"
    4.82 +				"linux"		"119"
    4.83 +			}
    4.84  			
    4.85  			/* Temp Entities */
    4.86  			"s_pTempEntities"
    4.87 @@ -543,6 +578,11 @@
    4.88  				"windows"	"114"
    4.89  				"linux"		"115"
    4.90  			}
    4.91 +			"EyeAngles"
    4.92 +			{
    4.93 +				"windows"	"106"
    4.94 +				"linux"		"107"
    4.95 +			}
    4.96  
    4.97  			/* Temp Entities */
    4.98  			"s_pTempEntities"
     5.1 --- a/plugins/include/sdktools_engine.inc	Mon Jul 30 23:16:58 2007 +0000
     5.2 +++ b/plugins/include/sdktools_engine.inc	Tue Jul 31 02:08:25 2007 +0000
     5.3 @@ -40,3 +40,13 @@
     5.4   * @error				Light style index is out of range.
     5.5   */
     5.6  native SetLightStyle(style, const String:value[]);
     5.7 +
     5.8 +/**
     5.9 + * Returns the client's eye position.
    5.10 + *
    5.11 + * @param client		Player's index.
    5.12 + * @param pos			Destination vector to store the client's eye position.
    5.13 + * @noreturn
    5.14 + * @error				Invalid client index, client not in game, or no mod support.
    5.15 + */
    5.16 +native GetClientEyePosition(client, Float:pos[3]);
     6.1 --- a/plugins/include/sdktools_functions.inc	Mon Jul 30 23:16:58 2007 +0000
     6.2 +++ b/plugins/include/sdktools_functions.inc	Tue Jul 31 02:08:25 2007 +0000
     6.3 @@ -105,6 +105,16 @@
     6.4  native SlapPlayer(client, health=5, bool:sound=true);
     6.5  
     6.6  /**
     6.7 + * Returns the client's eye angles.
     6.8 + *
     6.9 + * @param client		Player's index.
    6.10 + * @param ang			Destination vector to store the client's eye angles.
    6.11 + * @noreturn
    6.12 + * @error				Invalid client index, client not in game, or no mod support.
    6.13 + */
    6.14 +native GetClientEyeAngles(client, Float:ang[3]);
    6.15 +
    6.16 +/**
    6.17   * @deprecated
    6.18   */
    6.19  stock IgnitePlayer(client, Float:time, bool:npc=false, Float:size=0.0, bool:level=false)