Request am28110 - Added tfc_get_user_goalitem native to determine if player is carrying a goal item (such as a flag or keycard)

This commit is contained in:
Scott Ehlert 2006-08-22 21:50:27 +00:00
parent 0cb316c764
commit 58abc3a655
4 changed files with 39 additions and 10 deletions

View File

@ -8,37 +8,39 @@
#ifndef __linux__ #ifndef __linux__
#define LINUXOFFSET 0 #define LINUXOFFSET 0
#define WEAP_LINUXOFFSET 0
#define CLIP_LINUXOFFSET 0 #define CLIP_LINUXOFFSET 0
#else #else
#define LINUXOFFSET 5 #define LINUXOFFSET 3
#define WEAP_LINUXOFFSET 3
#define CLIP_LINUXOFFSET 4 #define CLIP_LINUXOFFSET 4
#endif #endif
#define TFCMAX_CUSTOMWPNS 5 #define TFCMAX_CUSTOMWPNS 5
#define TFCMAX_WEAPONS MAX_WEAPONS + TFCMAX_CUSTOMWPNS #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_SENTRY_OWNER 83 + LINUXOFFSET
#define PD_TIMER_OWNER 932 + LINUXOFFSET #define PD_TIMER_OWNER 932 + LINUXOFFSET
#define MAX_TRACE 13 #define MAX_TRACE 13
//#define NADE_OFFSET 24 //#define NADE_OFFSET 24
#define ACT_NADE_NONE 0 #define ACT_NADE_NONE 0
#define ACT_NADE_SHOT 1<<0 #define ACT_NADE_SHOT 1<<0
#define ACT_NADE_PUT 1<<1 #define ACT_NADE_PUT 1<<1
#define PD_AMMO_SHELLS 53 + WEAP_LINUXOFFSET #define PD_AMMO_SHELLS 53 + LINUXOFFSET
#define PD_AMMO_BULLETS 55 + WEAP_LINUXOFFSET #define PD_AMMO_BULLETS 55 + LINUXOFFSET
#define PD_AMMO_CELLS 57 + WEAP_LINUXOFFSET #define PD_AMMO_CELLS 57 + LINUXOFFSET
#define PD_AMMO_ROCKETS 59 + WEAP_LINUXOFFSET #define PD_AMMO_ROCKETS 59 + LINUXOFFSET
#define PD_AMMO_NADE1 14 + WEAP_LINUXOFFSET #define PD_AMMO_NADE1 14 + LINUXOFFSET
#define PD_AMMO_NADE2 15 + WEAP_LINUXOFFSET #define PD_AMMO_NADE2 15 + LINUXOFFSET
#define PD_WEAPON_AMMO 307 + CLIP_LINUXOFFSET #define PD_WEAPON_AMMO 307 + CLIP_LINUXOFFSET
// For tfc_get_user_goalitem
#define CARRYING_GOALITEM (1<<0)
enum { enum {
TFC_AMMO_SHELLS = 0, TFC_AMMO_SHELLS = 0,
TFC_AMMO_BULLETS, TFC_AMMO_BULLETS,

View File

@ -342,6 +342,20 @@ static cell AMX_NATIVE_CALL TFC_SetWeaponAmmo(AMX *amx, cell *params)
return 1; 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) { static cell AMX_NATIVE_CALL TFC_GetWpnName(AMX *amx, cell *params) {
int iIndex = params[1]; int iIndex = params[1];
if ( iIndex < 1 || iIndex > TFCMAX_WEAPONS ){ if ( iIndex < 1 || iIndex > TFCMAX_WEAPONS ){
@ -426,6 +440,8 @@ AMX_NATIVE_INFO base_Natives[] = {
{"tfc_getweaponammo", TFC_GetWeaponAmmo}, {"tfc_getweaponammo", TFC_GetWeaponAmmo},
{"tfc_setweaponammo", TFC_SetWeaponAmmo}, {"tfc_setweaponammo", TFC_SetWeaponAmmo},
{"tfc_get_user_goalitem", TFC_GetUserGoalItem},
{"xmod_get_wpnname", TFC_GetWpnName}, {"xmod_get_wpnname", TFC_GetWpnName},
{"xmod_get_wpnlogname", TFC_GetWpnLogName}, {"xmod_get_wpnlogname", TFC_GetWpnLogName},
{"xmod_is_melee_wpn", TFC_IsMelee}, {"xmod_is_melee_wpn", TFC_IsMelee},

View File

@ -69,3 +69,8 @@ enum {
TFC_PC_CIVILIAN, 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)

View File

@ -127,3 +127,9 @@ native tfc_getweaponammo(index);
/* Sets amount of ammo in weapon's clip */ /* Sets amount of ammo in weapon's clip */
/* Index must be weapon's entity index */ /* Index must be weapon's entity index */
native tfc_setweaponammo(index, value); 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);