From 58abc3a6554fecbd5a9fcf3d1d3caee1d7dbbc14 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Tue, 22 Aug 2006 21:50:27 +0000 Subject: [PATCH] Request am28110 - Added tfc_get_user_goalitem native to determine if player is carrying a goal item (such as a flag or keycard) --- dlls/tfc/tfcx/CMisc.h | 22 ++++++++++++---------- dlls/tfc/tfcx/NBase.cpp | 16 ++++++++++++++++ plugins/include/tfcconst.inc | 5 +++++ plugins/include/tfcx.inc | 6 ++++++ 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/dlls/tfc/tfcx/CMisc.h b/dlls/tfc/tfcx/CMisc.h index 5d88adec..1f95792a 100755 --- a/dlls/tfc/tfcx/CMisc.h +++ b/dlls/tfc/tfcx/CMisc.h @@ -8,37 +8,39 @@ #ifndef __linux__ #define LINUXOFFSET 0 - #define WEAP_LINUXOFFSET 0 #define CLIP_LINUXOFFSET 0 #else - #define LINUXOFFSET 5 - #define WEAP_LINUXOFFSET 3 + #define LINUXOFFSET 3 #define CLIP_LINUXOFFSET 4 #endif #define TFCMAX_CUSTOMWPNS 5 #define TFCMAX_WEAPONS MAX_WEAPONS + TFCMAX_CUSTOMWPNS +#define PD_HAS_GOALITEM 26 + LINUXOFFSET +#define PD_GOALITEM_TEAM 36 + LINUXOFFSET #define PD_SENTRY_OWNER 83 + LINUXOFFSET #define PD_TIMER_OWNER 932 + LINUXOFFSET #define MAX_TRACE 13 //#define NADE_OFFSET 24 - #define ACT_NADE_NONE 0 #define ACT_NADE_SHOT 1<<0 #define ACT_NADE_PUT 1<<1 -#define PD_AMMO_SHELLS 53 + WEAP_LINUXOFFSET -#define PD_AMMO_BULLETS 55 + WEAP_LINUXOFFSET -#define PD_AMMO_CELLS 57 + WEAP_LINUXOFFSET -#define PD_AMMO_ROCKETS 59 + WEAP_LINUXOFFSET -#define PD_AMMO_NADE1 14 + WEAP_LINUXOFFSET -#define PD_AMMO_NADE2 15 + WEAP_LINUXOFFSET +#define PD_AMMO_SHELLS 53 + LINUXOFFSET +#define PD_AMMO_BULLETS 55 + LINUXOFFSET +#define PD_AMMO_CELLS 57 + LINUXOFFSET +#define PD_AMMO_ROCKETS 59 + LINUXOFFSET +#define PD_AMMO_NADE1 14 + LINUXOFFSET +#define PD_AMMO_NADE2 15 + LINUXOFFSET #define PD_WEAPON_AMMO 307 + CLIP_LINUXOFFSET +// For tfc_get_user_goalitem +#define CARRYING_GOALITEM (1<<0) + enum { TFC_AMMO_SHELLS = 0, TFC_AMMO_BULLETS, diff --git a/dlls/tfc/tfcx/NBase.cpp b/dlls/tfc/tfcx/NBase.cpp index 897d469d..faa201b7 100755 --- a/dlls/tfc/tfcx/NBase.cpp +++ b/dlls/tfc/tfcx/NBase.cpp @@ -342,6 +342,20 @@ static cell AMX_NATIVE_CALL TFC_SetWeaponAmmo(AMX *amx, cell *params) return 1; } +static cell AMX_NATIVE_CALL TFC_GetUserGoalItem(AMX *amx, cell *params) +{ + int index = params[1]; + + CHECK_PLAYER(index); + + edict_t *pPlayer = MF_GetPlayerEdict(index); + cell *team = MF_GetAmxAddr(amx, params[2]); + + *team = *((int *)pPlayer->pvPrivateData + PD_GOALITEM_TEAM); + + return *((int *)pPlayer->pvPrivateData + PD_HAS_GOALITEM) & CARRYING_GOALITEM; +} + static cell AMX_NATIVE_CALL TFC_GetWpnName(AMX *amx, cell *params) { int iIndex = params[1]; if ( iIndex < 1 || iIndex > TFCMAX_WEAPONS ){ @@ -426,6 +440,8 @@ AMX_NATIVE_INFO base_Natives[] = { {"tfc_getweaponammo", TFC_GetWeaponAmmo}, {"tfc_setweaponammo", TFC_SetWeaponAmmo}, + {"tfc_get_user_goalitem", TFC_GetUserGoalItem}, + {"xmod_get_wpnname", TFC_GetWpnName}, {"xmod_get_wpnlogname", TFC_GetWpnLogName}, {"xmod_is_melee_wpn", TFC_IsMelee}, diff --git a/plugins/include/tfcconst.inc b/plugins/include/tfcconst.inc index 8657ad39..2f00d649 100755 --- a/plugins/include/tfcconst.inc +++ b/plugins/include/tfcconst.inc @@ -69,3 +69,8 @@ enum { TFC_PC_CIVILIAN, }; +// Goal items +#define TFC_GOALITEM_BLUE (1 << 17) +#define TFC_GOALITEM_RED (1 << 18) +#define TFC_GOALITEM_YELLOW (1 << 24) +#define TFC_GOALITEM_GREEN (1 << 25) diff --git a/plugins/include/tfcx.inc b/plugins/include/tfcx.inc index b1fdb73a..632e67d8 100755 --- a/plugins/include/tfcx.inc +++ b/plugins/include/tfcx.inc @@ -127,3 +127,9 @@ native tfc_getweaponammo(index); /* Sets amount of ammo in weapon's clip */ /* Index must be weapon's entity index */ native tfc_setweaponammo(index, value); + +/* Returns 1 if user is carrying a goal item such as a flag or a keycard, else 0. + * Team is by reference parameter that will be set to owning team(s) of the goal item. + * Use the TFC_GOALITEM_* constants to determine the owning team. + */ +native tfc_get_user_goalitem(index, &team);