From af29e2fb81bca4b5d0f104881e141112e526622a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 26 May 2004 07:59:33 +0000 Subject: [PATCH] Updated engine includes Added natural selection includes --- plugins/include/engine.inc | 62 ++++++-- plugins/include/engine_const.inc | 25 ++- plugins/include/engine_stocks.inc | 39 ++++- plugins/include/ns2amxx.inc | 55 +++++++ plugins/include/ns2amxxdefines.inc | 182 ++++++++++++++++++++++ plugins/include/ns2amxxhelpers.inc | 242 +++++++++++++++++++++++++++++ 6 files changed, 590 insertions(+), 15 deletions(-) create mode 100755 plugins/include/ns2amxx.inc create mode 100755 plugins/include/ns2amxxdefines.inc create mode 100755 plugins/include/ns2amxxhelpers.inc diff --git a/plugins/include/engine.inc b/plugins/include/engine.inc index d223e6c3..69073abf 100755 --- a/plugins/include/engine.inc +++ b/plugins/include/engine.inc @@ -1,7 +1,7 @@ /* Engine functions * * by the AMX Mod X Development Team -* thanks to Vexd +* thanks to Vexd and mahnsawce * * This file is provided as is (no warranties). */ @@ -18,7 +18,7 @@ * or fully block it. Here is how it works: * If you hook a message, the message is stored but not sent. You have the opportunity to * not only execute code, but to get/set the contents of the message, before you choose to - * either block it or let it go on its way. The hooked function will be passed a msg_id. */ + * either block it or let it go on its way. The hooked function will be passed a msg_id, msg_dest, and entity index. */ native register_message(iMsgId, szFunction[]); /* The get/set _msg commands will utterly fail if used outside a hooked message scope. @@ -43,18 +43,22 @@ native set_msg_arg_int(argn, argtype, iValue); native set_msg_arg_float(argn, argtype, Float:fValue); native set_msg_arg_string(argn, szString[]); -/* Note, the offsets are passed as linux values, not windows values. - * Although the engine module will automatically calculate the difference, - * you must pass with the +5 linux offset (e.g. if 230 on windows, pass 235 no matter what) */ +/* Gets the origin of a message */ +native get_msg_origin(Float:_Origin[3]); + +/* NOTE: In old engine versions, this was not the case. Values are now WINDOWS values. + * You must pass with the windows offset (e.g. if 230 on windows, pass 230 no matter what) + * The module will automatically add +5 for Linux. + */ /* Gets pvPrivateData offset. */ -native get_offset(id, offset); +native get_offset_int(id, offset); native Float:get_offset_float(id, offset); native get_offset_short(id, offset); native get_offset_char(id, offset); /* sets pvPrivateData offset. */ -native set_offset(id, offset, value); +native set_offset_int(id, offset, value); native set_offset_float(id, offset, Float:value); native set_offset_short(id, offset, value); native set_offset_char(id, offset, value); @@ -88,11 +92,13 @@ native get_global_vector(variable, Float:vector[3]); native get_global_edict(variable); /* Set entity bounds. */ -native set_size(index, Float:mins[3], Float:maxs[3]); +native entity_set_size(index, Float:mins[3], Float:maxs[3]); /* Get decal index */ native get_decal_index(const szDecalName[]); +/* Returns the distance between two entities. */ +native Float:entity_range(ida,idb); /* Sets/gets things in an entities Entvars Struct. */ native entity_get_int(iIndex, iKey); @@ -124,6 +130,10 @@ native find_ent_in_sphere(start_from_ent, Float:origin[3], Float:radius); //this will CBaseEntity::Think() or something from the entity native call_think(entity) +/* Mirrors CBaseEntity->TakeDamage() - Forces an entity to take damage. + Potential for crash. If you have problems with this, I suggest using fakedamage(). */ +native takedamage(idVictim,idInflictor,idAttacker,Float:takedmgdamage,damagetype); + /* Is entity valid? */ native is_valid_ent(iIndex); @@ -161,6 +171,9 @@ native PointContents(Float:fCheckAt[3]); * and an entity index if an entity is hit. */ native trace_line(iIgnoreEnt, Float:fStart[3], Float:fEnd[3], Float:vReturn[3]); +/* Traces a hull. */ +native trace_hull(Float:origin[3],hull,ignoredent=0,ignoremonsters=0); + /* Traces a line, and returns the normal to the plane hit in vReturn. * Returns 0 if theres no normal. */ native trace_normal(iIgnoreEnt, Float:fStart[3], Float:fEnd[3], Float:vReturn[3]); @@ -168,6 +181,8 @@ native trace_normal(iIgnoreEnt, Float:fStart[3], Float:fEnd[3], Float:vReturn[3] /* Changes a Vector to an Angle vector. */ native vector_to_angle(Float:fVector[3], Float:vReturn[3]); +native anglevector(Float:vector[3],FRU,Float:ret[3]) + /* Gets the length of a vector (float[3]). */ native Float:vector_length(Float:vVector[3]); @@ -193,6 +208,21 @@ native attach_view(iIndex, iTargetIndex); /* Sets Player's View Mode. */ native set_view(iIndex, ViewType); +/* Direct copy of PLAYBACK_EVENT_FULL from Metamod/HLSDK. If you don't know how that works, you probably shouldn't be using it. */ +native playback_event(flags,invoker,eventindex,Float:delay,Float:origin[3],Float:angles[3],Float:fparam1,Float:fparam2,iparam1,iparam2,bparam1,bparam2); + +/* Gets parameters sent from CmdStart. + Note that you will receive modified values if any other plugin have + changed them. */ +native get_usercmd(type,{Float,_}:...); + +/* Sets the parameters sent from CmdStart. + Note that your changes will be seen by any other plugin doing get_usercmd() */ +native set_usercmd(type,{Float,_}:...); + +/* FORWARDS + **********/ + /* Called when 2 entities touch. */ forward pfn_touch(ptr, ptd); @@ -209,8 +239,22 @@ forward client_PostThink(id); /* Forward for impulses. */ forward client_impulse(id, impulse); +forward server_changelevel(map[]); + +/* Called when an entity "thinks" (DispatchThink) */ +forward pfn_think(entid); + +/* Called when an event is played */ +forward PlaybackEvent(flags, entid, eventid, Float:delay, Float:Origin[3], Float:Angles[3], Float:fparam1, Float:fparam2, iparam1, iparam2, bparam2); + +/* Called when an entity is spawned */ +forward pfn_spawn(entid); + +/* Called when an object uses another object */ +forward pfn_use(user, used); + //from jghg2 -/* Returns number of ents stored in entlist. Use to find a specific type of entity classname (specify in _lookforclassname) around a +/* As above, but returns number of ents stored in entlist. Use to find a specific type of entity classname (specify in _lookforclassname) around a * certain entity specified in aroundent. All matching ents are stored in entlist. Specify max amount of entities to find in maxents. * If aroundent is 0 its origin is not used, but origin in 6th parameter. Ie, do not specify 6th parameter (origin) if you specified an entity * in aroundent. diff --git a/plugins/include/engine_const.inc b/plugins/include/engine_const.inc index 59e74705..f1f580eb 100755 --- a/plugins/include/engine_const.inc +++ b/plugins/include/engine_const.inc @@ -356,4 +356,27 @@ enum { // Void (not supported) GL_pSaveData -} \ No newline at end of file +} + +enum +{ + usercmd_float_start, + usercmd_forwardmove, // Float + usercmd_sidemove, // Float + usercmd_upmove, // Float + usercmd_float_end, + usercmd_int_start, + usercmd_lerp_msec, // short + usercmd_msec, // byte + usercmd_lightlevel, // byte + usercmd_buttons, // unsigned short + usercmd_impulse, // byte + usercmd_weaponselect, // byte + usercmd_impact_index, // int + usercmd_int_end, + usercmd_vec_start, + usercmd_viewangles, // Vector + usercmd_impact_position, // vec + usercmd_vec_end + +}; \ No newline at end of file diff --git a/plugins/include/engine_stocks.inc b/plugins/include/engine_stocks.inc index d33c5246..aba85d17 100755 --- a/plugins/include/engine_stocks.inc +++ b/plugins/include/engine_stocks.inc @@ -11,14 +11,38 @@ #endif #define _engine_stocks_included +stock fakedamage(idvictim,szClassname[],Float:takedmgdamage,damagetype) +{ + new entity = create_entity("trigger_hurt") + if (entity) + { + DispatchKeyValue(entity,"classname","trigger_hurt") + new szDamage[16] + // Takedamages only do half damage per attack (damage is damage per second, and it's triggered in 0.5 second intervals). + // Compensate for that. + format(szDamage,15,"%f",takedmgdamage * 2) + DispatchKeyValue(entity,"dmg",szDamage) + format(szDamage,15,"%i",damagetype) + DispatchKeyValue(entity,"damagetype",szDamage) + DispatchKeyValue(entity,"origin","8192 8192 8192") + spawn(entity) + entity_set_string(entity, EV_SZ_classname, szClassname) + fake_touch(entity,idvictim) + remove_entity(entity) + return 1 + } + return 0 +} + //wrapper for find_ent_by_class stock find_ent(iStart, szClassname[]) { return find_ent_by_class(iStart, szClassname) } -/* Changes an integer vec to a floating vec */ - +/* Changes an integer vec to a floating vec + * This is not a for loop because that's slower + */ stock IVecFVec(IVec[3], Float:FVec[3]) { FVec[0] = float(IVec[0]) @@ -205,7 +229,12 @@ stock get_entity_visibility(entity) { return (entity_get_int(entity, EV_INT_effects) & EF_NODRAW) } -/* Returns true if entity is on ground, else false. */ -stock entity_is_on_ground(entity) { - return entity_get_int(entity, EV_INT_flags) & FL_ONGROUND +stock set_user_velocity(entity, Float:vec[3]) +{ + return entity_set_vector(entity, EV_SZ_velocity, vec) +} + +stock get_user_velocity(entity, Flaot:vec[3]) +{ + return entity_get_vector(entity, EV_SZ_velocity, vec) } \ No newline at end of file diff --git a/plugins/include/ns2amxx.inc b/plugins/include/ns2amxx.inc new file mode 100755 index 00000000..d107fa0d --- /dev/null +++ b/plugins/include/ns2amxx.inc @@ -0,0 +1,55 @@ +/* NS2AMX.INC + * Declares all natives/forwards for the ns2amxx module. + * version 0.2 + */ +#if defined __ns2amxx__ + #endinput +#endif +#define __ns2amxx__ 02 +#include + +/* Returns the number of specified entities in map if value is 0 + otherwise it returns the index of the #th entity of that class. */ +native ns_get_ent(classname[],Value); + +/* Same as get_ent, but only returns fully built structures (if Value > 0) */ +native ns_get_build(classname[],Value,Number=0,NSVersion=NS_VERSION); + +/* Mirrors MAKE_STRING() */ +native ns_make_string(svValue[]); +/* Mirrors STRING() */ +native ns_string(iValue,svReturnedValue[]); + +/* Get's spawn point for specified team (type). */ +native ns_get_spawn(type,number=0,Float:ret[3]); + +/* Returns 1 if the map is combat, 0 otherwise. */ +native ns_is_combat() + +/* Used to change the speed of players. Since this can vary, a static speed isn't set. + Rather, the module will add the speedchange to the player's maxspeed every frame. + Set speedchange to a negative value to slow the player down. */ +native ns_get_speedchange(id) +native ns_set_speedchange(id,speed) +native ns_get_maxspeed(id) + +/* Forces a player to spawn. I would not use this while the player's deadflags = 1 or 0. + Only use when the player is dead with deadflags of 2 or higher. + For class, use the fields specified in the NS Mini SDK (1=marine,3=skulk,4=gorge,5=lerk,6=fade,7=onos) */ +native ns_spawn_player(id,class=1,health=100,armor=25) + +/* Configures display of the custom menus. This display is _very_ similar to set_hudmessage() */ +native ns_set_menu(id,r=NSMENU_R,g=NSMENU_G,b=NSMENU_B,x=NSMENU_X,y=NSMENU_Y, effects=0, Float:fadeintime=0.0, Float:fadeouttime=0.0,channel1=4,channel2=3) + +/* Displays a custom menu. It will execute command(id,keys) when the menu is pressed. */ +native ns_show_menu(id,szCommand[],szText[],keys,time) + +/* Forces ns2amx to set the player's model/skin/body to the specified each frame. + Note that the model will not go back to standard when the player dies/changes classes. + Your plugin will have to tell the module to stop using the custom model. + Leave the second parameter out of any of these commands to force the module to go back to standard. */ +native ns_set_player_model(id,szModel[]="") +native ns_set_player_skin(id,skin=-1) +native ns_set_player_body(id,body=-1) + +#include diff --git a/plugins/include/ns2amxxdefines.inc b/plugins/include/ns2amxxdefines.inc new file mode 100755 index 00000000..95183683 --- /dev/null +++ b/plugins/include/ns2amxxdefines.inc @@ -0,0 +1,182 @@ +/* NS2AMXDEFINES.INC + * Various enums and definitions required for the ns2amx module. + * Version 1.0 + */ + +#if defined __ns2amxxdefines__ + #endinput +#endif +#define __ns2amxxdefines__ 02 + +// Set this to either 3 or 2. If set to two, it will do NS 2.01 offsets. +// If set to 3, it will do the most recent NS 3.0 offsets. +#define NS_VERSION 3 + + +// These values are customizable (for the custom menus) +// If your menu uses the default menu scheme, then it will use this. +#define NSMENU_X 0.2 +#define NSMENU_Y 0.1 +#define NSMENU_R 255 +#define NSMENU_G 200 +#define NSMENU_B 100 + + + + +#if NS_VERSION == 3 +#define PRIVATE_ALIEN_RES 0x190 +#define PRIVATE_AMMO_LMG 0xE6 +#define PRIVATE_AMMO_PISTOL 0xE7 +#define PRIVATE_AMMO_SHOTGUN 0xE8 +#define PRIVATE_AMMO_HMG 0xE9 +#define PRIVATE_AMMO_GL 0xEA + +//Thanks, voogru +#define PRIVATE_LEVELS_SPENT_WIN 0x62D +#define PRIVATE_EXPERIENCE_WIN 0x615 +#define PRIVATE_LEVELS_SPENT_LINUX 0x62D +#define PRIVATE_EXPERIENCE_LINUX 0x612 + +#else + +#define PRIVATE_ALIEN_RES 0x18E +#define PRIVATE_AMMO_LMG 0xE6 +#define PRIVATE_AMMO_PISTOL 0xE7 +#define PRIVATE_AMMO_SHOTGUN 0xE8 +#define PRIVATE_AMMO_HMG 0xE9 +#define PRIVATE_AMMO_GL 0xEA +#endif + +// Used for anglevector() +#define ANGLEVECTOR_FORWARD 1 +#define ANGLEVECTOR_RIGHT 2 +#define ANGLEVECTOR_UP 3 + +// used for gpglobals_return() +#define GPGLOBALS_FORWARD 1 +#define GPGLOBALS_RIGHT 2 +#define GPGLOBALS_UP 3 + +// Used for get_class +#define CLASS_UNKNOWN 0 +#define CLASS_SKULK 1 +#define CLASS_GORGE 2 +#define CLASS_LERK 3 +#define CLASS_FADE 4 +#define CLASS_ONOS 5 +#define CLASS_MARINE 6 +#define CLASS_JETPACK 7 +#define CLASS_HEAVY 8 +#define CLASS_COMMANDER 9 +#define CLASS_GESTATE 10 +#define CLASS_DEAD 11 +#define CLASS_NOTEAM 12 +// used for trace_hull +#define HULL_POINT 0 +#define HULL_HUMAN 1 +#define HULL_LARGE 2 +#define HULL_HEAD 3 + + // Taken from the NS mini SDK +enum +{ + WEAPON_NONE = 0, + WEAPON_CLAWS, + WEAPON_SPIT, + WEAPON_SPORES, + WEAPON_SPIKE, + WEAPON_BITE, + WEAPON_BITE2, + WEAPON_SWIPE, + WEAPON_WEBSPINNER, + WEAPON_METABOLIZE, + WEAPON_PARASITE, + WEAPON_BLINK, + WEAPON_DIVINEWIND, + WEAPON_KNIFE, + WEAPON_PISTOL, + WEAPON_MG, + WEAPON_SHOTGUN, + WEAPON_HMG, + WEAPON_WELDER, + WEAPON_MINE, + WEAPON_GRENADE_GUN, + WEAPON_LEAP, + WEAPON_CHARGE, + WEAPON_UMBRA, + WEAPON_PRIMALSCREAM, + WEAPON_BILEBOMB, + WEAPON_ACIDROCKET, + WEAPON_HEALINGSPRAY, + WEAPON_HANDGRENADE, + WEAPON_STOMP, + WEAPON_DEVOUR, + WEAPON_MAX +} +#define WEAPON_BABBLER WEAPON_HANDGRENADE +// A few of the AvHSpecials.h iuser4 flags, modified for ease-of-use... +enum +{ + MASK_NONE = 0, + MASK_SIGHTED = 1, + MASK_DETECTED = 2, + MASK_BUILDABLE = 4, + MASK_BASEBUILD0 = 8, // Base build slot #0 + MASK_WEAPONS1 = 8, // Marine weapons 1 + MASK_CARAPACE = 8, // Alien carapace + MASK_WEAPONS2 = 16, // Marines weapons 2 + MASK_REGENERATION = 16, // Alien regeneration + MASK_BASEBUILD1 = 16, // Base build slot #1 + MASK_WEAPONS3 = 32, // Marine weapons 3 + MASK_REDEMPTION = 32, // Alien redemption + MASK_BASEBUILD2 = 32, // Base build slot #2 + MASK_ARMOR1 = 64, // Marine armor 1 + MASK_CELERITY = 64, // Alien celerity + MASK_BASEBUILD3 = 64, // Base build slot #3 + MASK_ARMOR2 = 128, // Marine armor 2 + MASK_ADRENALINE = 128, // Alien adrenaline + MASK_BASEBUILD4 = 128, // Base build slot #4 + MASK_ARMOR3 = 256, // Marine armor 3 + MASK_SILENCE = 256, // Alien silence + MASK_BASEBUILD5 = 256, // Base build slot #5 + MASK_JETPACK = 512, // Marine jetpacks + MASK_CLOAKING = 512, // Alien cloaking + MASK_BASEBUILD6 = 512, // Base build slot #6 + MASK_FOCUS = 1024, // Alien focus + MASK_MOTION = 1024, // Marine motion tracking + MASK_BASEBUILD7 = 1024, // Base build slot #7 + MASK_SCENTOFFEAR = 2048, // Alien scent of fear + MASK_DEFENSE2 = 4096, // Defense level 2 + MASK_DEFENSE3 = 8192, // Defense level 3 + MASK_ELECTRICITY = 8192, // Electricy + MASK_MOVEMENT2 = 16384, // Movement level 2, + MASK_MOVEMENT3 = 32768, // Movement level 3 + MASK_HEAVYARMOR = 32768, // Marine heavy armor + MASK_SENSORY2 = 65536, // Sensory level 2 + MASK_SENSORY3 = 131072, // Sensory level 3 + MASK_ALIEN_MOVEMENT = 262144, // Onos is charging + MASK_WALLSTICKING = 524288, // Flag for wall-sticking + MASK_PRIMALSCREAM = 1048576, // Alien is in range of active primal scream + MASK_UMBRA = 2097152, // In umbra + MASK_DIGESTING = 4194304, // When set on a visible player, player is digesting. When set on invisible player, player is being digested + MASK_RECYCLING = 8388608, // Building is recycling + MASK_TOPDOWN = 16777216, // Commander view + MASK_PLAYER_STUNNED = 33554432, // Player has been stunned by stomp + MASK_ENSNARED = 67108864, // Webbed + MASK_ALIEN_EMBRYO = 268435456, // Gestating + MASK_SELECTABLE = 536870912, // ??? + MASK_PARASITED = 1073741824, // Parasite flag + MASK_SENSORY_NEARBY = 2147483648 // Sensory chamber in range + +} + +#if !defined NULL +#define NULL 0 +#endif +#if !defined FALSE +#define FALSE 0 +#endif +#if !defined TRUE +#define TRUE 1 +#endif diff --git a/plugins/include/ns2amxxhelpers.inc b/plugins/include/ns2amxxhelpers.inc new file mode 100755 index 00000000..b9ba60fc --- /dev/null +++ b/plugins/include/ns2amxxhelpers.inc @@ -0,0 +1,242 @@ +/* NS2AMXHELPERS.INC + * Provides many functions to ease developing for the NS2AMX module. + * Version 1.0 + */ +#if defined __ns2amxxhelpers__ + #endinput +#endif +#define __ns2amxxhelpers__ 02 + +#include +#include +#include +#include + +stock ns_getammo(id,Weapon) +{ + if (id > get_playersnum() || id < 1) + { + return 0 + } + if (Weapon == WEAPON_MG) + { + return get_offset_int(id,PRIVATE_AMMO_LMG) + } + if (Weapon == WEAPON_HMG) + { + return get_offset_int(id,PRIVATE_AMMO_HMG) + } + if (Weapon == WEAPON_GRENADE_GUN) + { + return get_offset_int(id,PRIVATE_AMMO_GL) + } + if (Weapon == WEAPON_PISTOL) + { + return get_offset_int(id,PRIVATE_AMMO_PISTOL) + } + if (Weapon == WEAPON_SHOTGUN) + { + return get_offset_int(id,PRIVATE_AMMO_SHOTGUN) + } + return 1 +} +stock ns_setammo(id,Weapon,Value) +{ + if (id > get_playersnum() || id < 1) + { + return 0 + } + if (Weapon == WEAPON_MG) + { + set_offset_int(id,PRIVATE_AMMO_LMG,Value) + return 1 + } + if (Weapon == WEAPON_HMG) + { + set_offset_int(id,PRIVATE_AMMO_HMG,Value) + return 1 + } + if (Weapon == WEAPON_GRENADE_GUN) + { + set_offset_int(id,PRIVATE_AMMO_GL,Value) + return 1 + } + if (Weapon == WEAPON_PISTOL) + { + set_offset_int(id,PRIVATE_AMMO_PISTOL,Value) + return 1 + } + if (Weapon == WEAPON_SHOTGUN) + { + set_offset_int(id,PRIVATE_AMMO_SHOTGUN,Value) + return 1 + } + return 0 +} +stock ns_giveitem(id,svClassname[]) +{ + new entity = create_entity(svClassname) + ns_moveto(entity,id) + entity_set_int(entity, EV_INT_team, entity_get_int(id, EV_INT_team)) + spawn(entity) + fake_touch(entity,id) + +} +stock ns_moveto(idMoved,idDest) +{ + new Float:origin[3] + new Float:dest[3] + entity_get_vector(idMoved, EV_VEC_origin, origin) + entity_get_vector(idDest, EV_VEC_origin, dest) + entity_set_vector(idMoved, dest) +} +stock ns_isdigesting(id) +{ + return ns_get_mask(id,MASK_DIGESTING) +} +stock ns_gethives() +{ + return ns_get_build("team_hive",1) +} +stock ns_inrange(ida,idb,range) +{ + if (entity_get_range(ida,idb) <= range) + { + return 1 + } + return 0 +} +stock ns_nspopup(id,svMessage[190]) +{ + message_begin(MSG_ONE,get_user_msgid("HudText2"),{0,0,0},id) + write_string(svMessage) + write_byte(0) + message_end() +} +stock ns_setres(id,value) +{ + if (entity_get_int(id,EV_INT_team) == 2) // this only works for aliens + { + set_offset_float(id,PRIVATE_ALIEN_RES,float(value)) + return 0; + } + return 1; +} +stock ns_getenergy(id) +{ + if (entity_get_int(id,EV_INT_iuser3) >= 3 && entity_get_int(id,EV_INT_iuser3) <= 7) + { + new Float:energy + entity_set_float(id,EV_FL_fuser3,energy) + return floatround(energy / 10.0) + } + return 0 +} +stock ns_setenergy(id,energy) +{ + if (entity_get_int(id,EV_INT_iuser3) >= 3 && entity_get_int(id,EV_INT_iuser3) <= 7) + { + entity_set_float(id,EV_FL_fuser3,float(energy * 10)) + } +} +stock ns_getjpfuel(id) +{ + if (get_offset_int(id,eni_team) == 1) + { + return floatround(get_offset_float(id,enf_fuser3) / 10.0) + } + return 0 +} +stock ns_setjpfuel(id,fuel) +{ + if (entity_get_int(id,EV_INT_team) == 1) + { + entity_set_float(id,EV_FL_fuser3, float(fuel * 10)) + return 1 + } + return 0 +} +stock ns_get_mask(id,mask) +{ + return (entity_get_int(id,EV_INT_iuser4) & mask) +} +stock ns_set_mask(id,mask,value) +{ + if (value) + { + if (ns_get_special(id,mask)) + return + entity_set_int(id,EV_INT_iuser3,entity_get_int(id,EV_INT_iuser4) + mask) + return + } + if (ns_get_special(id,mask)) + entity_set_int(id,EV_INT_iuser4,entity_get_int(id,EV_INT_iuser4) - mask) +} +stock ns_get_special(id,mask) +{ + if (entity_get_int(id,EV_INT_iuser4) & mask) + return 1 + return 0 +} +stock ns_get_res(id) +{ + if (id < 1 && id > get_maxplayers()) + return 0 + if (!is_user_connected(id)) + return 0 +#if NS_VERSION == 3 + if (entity_get_int(id,EV_INT_iuser1) > 0) + { + // This is only reported to be affected in first person spectator, but might as well be safe + new Float:res = get_offset_float(id,PRIVATE_ALIEN_RES) + return floatround(res) + } + else + { + // They aren't in spectator mode... + new Float:res[3] + entity_get_vector(id,EV_VEC_vuser4,res) + res[2] = (res[2] + 1.0) / 100 + return floatround(res[2]) + } + return 0 +#else + new Float:res[3] + entity_get_vector(id,EV_VEC_vuser4, res) + res[2] = (res[2] + 1.0) / 100 + return floatround(res[2]) +#endif + +} +stock ns_get_class(id) +{ + new iuser3 = entity_get_int(id,EV_INT_iuser3) + if (entity_get_int(id,EV_INT_deadflag) > 0) + return CLASS_DEAD + if (entity_get_int(id,EV_INT_team) == 0) + return CLASS_NOTEAM + if (iuser3 == 1) + { + // Light armor marine.. + if (entity_get_int(id,EV_INT_iuser4) & MASK_HEAVYARMOR) + return CLASS_HEAVY + if (entity_get_int(id,EV_INT_iuser4) & MASK_JETPACK) + return CLASS_JETPACK + return CLASS_MARINE + } + if (iuser3 == 2) + return CLASS_COMMANDER + if (iuser3 == 3) + return CLASS_SKULK + if (iuser3 == 4) + return CLASS_GORGE + if (iuser3 == 5) + return CLASS_LERK + if (iuser3 == 6) + return CLASS_FADE + if (iuser3 == 7) + return CLASS_ONOS + if (iuser3 == 8) + return CLASS_GESTATE + return CLASS_UNKNOWN +}