From 656554b775d3742f2c567119ab83f2f0a29a0902 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Sun, 19 Jun 2016 19:40:10 +0700 Subject: [PATCH] Added weaponbox members Added new natives rg_find_bpack_item_by_name, rg_is_player_can_takedamage, rg_get_weaponbox_id Renamed rg_select_default_team to rg_get_join_team_priority Update CSSDK --- .../amxmodx/scripting/include/cssdk_const.inc | 6 + .../extra/amxmodx/scripting/include/reapi.inc | 1 + .../scripting/include/reapi_gamedll.inc | 36 ++- .../scripting/include/reapi_gamedll_const.inc | 148 ++++++++---- reapi/include/com_progdefs.h | 17 ++ reapi/include/cssdk/dlls/basemonster.h | 4 +- reapi/include/cssdk/dlls/buttons.h | 2 +- reapi/include/cssdk/dlls/cbase.h | 6 +- reapi/include/cssdk/dlls/client.h | 11 + reapi/include/cssdk/dlls/func_break.h | 4 +- reapi/include/cssdk/dlls/gamerules.h | 222 +++++++++++++----- reapi/include/cssdk/dlls/h_cycler.h | 4 +- reapi/include/cssdk/dlls/plats.h | 2 +- reapi/include/cssdk/dlls/player.h | 4 +- reapi/include/cssdk/dlls/regamedll_api.h | 15 +- reapi/include/cssdk/dlls/util.h | 1 + reapi/include/cssdk/dlls/vector.h | 26 +- reapi/src/main.cpp | 3 +- reapi/src/main.h | 1 - reapi/src/member_list.cpp | 109 +++++---- reapi/src/member_list.h | 82 ++++--- reapi/src/natives/natives_members.cpp | 18 +- reapi/src/natives/natives_misc.cpp | 114 ++++++++- 23 files changed, 601 insertions(+), 235 deletions(-) diff --git a/reapi/extra/amxmodx/scripting/include/cssdk_const.inc b/reapi/extra/amxmodx/scripting/include/cssdk_const.inc index e0f1a3f..87543db 100644 --- a/reapi/extra/amxmodx/scripting/include/cssdk_const.inc +++ b/reapi/extra/amxmodx/scripting/include/cssdk_const.inc @@ -624,6 +624,12 @@ // UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!! #define FCAP_FORCE_TRANSITION 0x00000080 // ALWAYS goes across transitions +// All monsters need this data +#define DONT_BLEED -1 +#define BLOOD_COLOR_RED 247 +#define BLOOD_COLOR_YELLOW 195 +#define BLOOD_COLOR_GREEN BLOOD_COLOR_YELLOW + // CBasePlayer::m_iIgnoreGlobalChat enum { diff --git a/reapi/extra/amxmodx/scripting/include/reapi.inc b/reapi/extra/amxmodx/scripting/include/reapi.inc index dad921f..2cf1ed7 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi.inc @@ -37,6 +37,7 @@ enum members_tables_e mt_csplayer, mt_baseitem, mt_baseweapon, + mt_weaponbox }; #define MAX_REGION_RANGE 1024 diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc index 3c74e20..3ab6be1 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -288,6 +288,17 @@ native rg_find_ent_by_class(start_index, const classname[]); */ native rg_find_ent_by_owner(&start_index, const classname[], owner); +/* +* Find the item by name in the player's inventory. +* +* @param index Client index +* @param item Item name +* +* @return Entity-index of item, 0 otherwise +* +*/ +native rg_find_bpack_item_by_name(const index, const item[]); + /* * Returns some information about a weapon. * @@ -531,9 +542,30 @@ native rg_switch_team(const index); native rg_switch_weapon(const index, const weapon); /* -* To priority autoselect join to team +* To get which team has a high priority to join. * * @return Returns the Team Name * */ -native TeamName:rg_select_default_team(); +native TeamName:rg_get_join_team_priority(); + +/* +* Can this player take damage from this attacker? +* +* @param index Client index +* @param attacker Attacker index +* +* @return 1 if successfully then can take a damage, 0 otherwise +* +*/ +native bool:rg_is_player_can_takedamage(const index, const attacker); + +/* +* To get WeaponIdType from weaponbox +* +* @param entity Weaponbox entity +* +* @return return enum's of WeaponIdType +* +*/ +native WeaponIdType:rg_get_weaponbox_id(const entity); diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index ab2821e..935fd4b 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -402,13 +402,13 @@ enum GamedllFunc_CBasePlayer enum GamedllFunc_CSGameRules { /* - * Description: - + * Description: should the player switch to this weapon? * Params: (const index, const weapon) */ RG_CSGameRules_FShouldSwitchWeapon = BEGIN_FUNC_REGION(gamerules), /* - * Description: - + * Description: I can't use this weapon anymore, get me the next best one. * Params: (const index, const currentWeapon) */ RG_CSGameRules_GetNextBestWeapon, @@ -420,55 +420,55 @@ enum GamedllFunc_CSGameRules RG_CSGameRules_FlPlayerFallDamage, /* - * Description: - + * Description: can this player take damage from this attacker? * Params: (const index, const attacker) */ RG_CSGameRules_FPlayerCanTakeDamage, /* - * Description: - + * Description: called by CBasePlayer::Spawn just before releasing player into the game * Params: (const index) */ RG_CSGameRules_PlayerSpawn, /* - * Description: - + * Description: is this player allowed to respawn now? * Params: (const index) */ RG_CSGameRules_FPlayerCanRespawn, /* - * Description: - + * Description: Place this player on their spawnspot and face them the proper direction. * Params: (const index) */ RG_CSGameRules_GetPlayerSpawnSpot, /* - * Description: - + * Description: the player has changed userinfo; can change it now * Params: (const index, infobuffer[]) */ RG_CSGameRules_ClientUserInfoChanged, /* - * Description: - + * Description: Called each time a player dies * Params: (const victim, const killer, const inflictor) */ RG_CSGameRules_PlayerKilled, /* - * Description: - + * Description: Call this from within a GameRules class to report an obituary. * Params: (const victim, const killer, const inflictor) */ RG_CSGameRules_DeathNotice, /* - * Description: - + * Description: The player is touching an CBasePlayerItem, do I give it to him? * Params: (const index, const item) */ RG_CSGameRules_CanHavePlayerItem, /* - * Description: - + * Description: what do I do with a player's weapons when he's killed? * Params: (const index) */ RG_CSGameRules_DeadPlayerWeapons, @@ -486,19 +486,21 @@ enum GamedllFunc_CSGameRules RG_CSGameRules_CheckMapConditions, /* - * Description: - + * Description: Recreate all the map entities from the map data (preserving their indices), + * then remove everything else except the players. + * Also get rid of all world decals. * Params: () */ RG_CSGameRules_CleanUpMap, /* - * Description: - + * Description: Call this on new round or restart round with member m_bCompleteReset is TRUE * Params: () */ RG_CSGameRules_RestartRound, /* - * Description: - + * Description: check if the scenario has been won/lost * Params: () */ RG_CSGameRules_CheckWinConditions, @@ -3917,7 +3919,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_iPlayEmptySound = BEGIN_MEMBER_REGION(baseweapon), + m_Weapon_iPlayEmptySound = BEGIN_MEMBER_REGION(baseweapon), /* * Description: - @@ -3925,7 +3927,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_fFireOnEmpty, + m_Weapon_fFireOnEmpty, /* * Description: soonest time ItemPostFrame will call PrimaryAttack @@ -3933,7 +3935,7 @@ enum CBasePlayerWeapon_Members * Get params: Float:get_member(index, member); * Set params: set_member(index, member, Float:value); */ - m_flNextPrimaryAttack, + m_Weapon_flNextPrimaryAttack, /* * Description: soonest time ItemPostFrame will call SecondaryAttack @@ -3941,7 +3943,15 @@ enum CBasePlayerWeapon_Members * Get params: Float:get_member(index, member); * Set params: set_member(index, member, Float:value); */ - m_flNextSecondaryAttack, + m_Weapon_flNextSecondaryAttack, + + /* + * Description: soonest time ItemPostFrame will call WeaponIdle + * Member type: float + * Get params: Float:get_member(index, member); + * Set params: set_member(index, member, Float:value); + */ + m_Weapon_flTimeWeaponIdle, /* * Description: "primary" ammo index into players m_rgAmmo[] @@ -3949,7 +3959,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_iPrimaryAmmoType, + m_Weapon_iPrimaryAmmoType, /* * Description: "secondary" ammo index into players m_rgAmmo[] @@ -3957,7 +3967,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_iSecondaryAmmoType, + m_Weapon_iSecondaryAmmoType, /* * Description: number of shots left in the primary weapon clip, -1 it not used @@ -3965,15 +3975,15 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_iClip, + m_Weapon_iClip, /* - * Description: the last version of m_iClip sent to hud dll + * Description: the last version of m_Weapon_iClip sent to hud dll * Member type: int * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_iClientClip, + m_Weapon_iClientClip, /* * Description: the last version of the weapon state sent to hud dll (is current weapon, is on target) @@ -3981,7 +3991,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_iClientWeaponState, + m_Weapon_iClientWeaponState, /* * Description: Are we in the middle of a reload @@ -3989,7 +3999,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_fInReload, + m_Weapon_fInReload, /* * Description: Are we in the middle of a reload for the shotguns @@ -3997,7 +4007,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_fInSpecialReload, + m_Weapon_fInSpecialReload, /* * Description: how much ammo you get when you pick up this weapon as placed by a level designer @@ -4005,7 +4015,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_iDefaultAmmo, + m_Weapon_iDefaultAmmo, /* * Description: - @@ -4013,7 +4023,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_iShellId, + m_Weapon_iShellId, /* * Description: - @@ -4021,7 +4031,7 @@ enum CBasePlayerWeapon_Members * Get params: Float:get_member(index, member); * Set params: set_member(index, member, Float:value); */ - m_fMaxSpeed, + m_Weapon_fMaxSpeed, /* * Description: - @@ -4029,7 +4039,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_bDelayFire, + m_Weapon_bDelayFire, /* * Description: - @@ -4037,7 +4047,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_iDirection, + m_Weapon_iDirection, /* * Description: - @@ -4045,7 +4055,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_bSecondarySilencerOn, + m_Weapon_bSecondarySilencerOn, /* * Description: - @@ -4053,7 +4063,7 @@ enum CBasePlayerWeapon_Members * Get params: Float:get_member(index, member); * Set params: set_member(index, member, Float:value); */ - m_flAccuracy, + m_Weapon_flAccuracy, /* * Description: - @@ -4061,7 +4071,7 @@ enum CBasePlayerWeapon_Members * Get params: Float:get_member(index, member); * Set params: set_member(index, member, Float:value); */ - m_flLastFire, + m_Weapon_flLastFire, /* * Description: - @@ -4069,7 +4079,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_iShotsFired, + m_Weapon_iShotsFired, /* * Description: time to shoot the remaining bullets of the glock18 burst fire @@ -4077,7 +4087,7 @@ enum CBasePlayerWeapon_Members * Get params: Float:get_member(index, member); * Set params: set_member(index, member, Float:value); */ - m_flGlock18Shoot, + m_Weapon_flGlock18Shoot, /* * Description: used to keep track of the shots fired during the Glock18 burst fire mode @@ -4085,7 +4095,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_iGlock18ShotsFired, + m_Weapon_iGlock18ShotsFired, /* * Description: - @@ -4093,7 +4103,7 @@ enum CBasePlayerWeapon_Members * Get params: Float:get_member(index, member); * Set params: set_member(index, member, Float:value); */ - m_flFamasShoot, + m_Weapon_flFamasShoot, /* * Description: - @@ -4101,7 +4111,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_iFamasShotsFired, + m_Weapon_iFamasShotsFired, /* * Description: - @@ -4109,7 +4119,7 @@ enum CBasePlayerWeapon_Members * Get params: Float:get_member(index, member); * Set params: set_member(index, member, Float:value); */ - m_fBurstSpread, + m_Weapon_fBurstSpread, /* * Description: - @@ -4117,7 +4127,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_iWeaponState, + m_Weapon_iWeaponState, /* * Description: - @@ -4125,7 +4135,7 @@ enum CBasePlayerWeapon_Members * Get params: Float:get_member(index, member); * Set params: set_member(index, member, Float:value); */ - m_flNextReload, + m_Weapon_flNextReload, /* * Description: - @@ -4133,7 +4143,7 @@ enum CBasePlayerWeapon_Members * Get params: Float:get_member(index, member); * Set params: set_member(index, member, Float:value); */ - m_flDecreaseShotsFired, + m_Weapon_flDecreaseShotsFired, /* * Description: - @@ -4141,7 +4151,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_usFireGlock18, + m_Weapon_usFireGlock18, /* * Description: - @@ -4149,7 +4159,7 @@ enum CBasePlayerWeapon_Members * Get params: get_member(index, member); * Set params: set_member(index, member, value); */ - m_usFireFamas, + m_Weapon_usFireFamas, /* * Description: - @@ -4157,7 +4167,7 @@ enum CBasePlayerWeapon_Members * Get params: Float:get_member(index, member); * Set params: set_member(index, member, Float:value); */ - m_flPrevPrimaryAttack, + m_Weapon_flPrevPrimaryAttack, /* * Description: - @@ -4165,5 +4175,49 @@ enum CBasePlayerWeapon_Members * Get params: Float:get_member(index, member); * Set params: set_member(index, member, Float:value); */ - m_flLastFireTime + m_Weapon_flLastFireTime +}; + +// CWeaponBox +enum CWeaponBox_Members +{ + /* + * Description: - + * Member type: class CBasePlayerItem *[6] + * Get params: get_member(index, member, element); + * Set params: set_member(index, member, value, element); + */ + m_WeaponBox_rgpPlayerItems = BEGIN_MEMBER_REGION(weaponbox), + + /* + * Description: - + * Member type: string_t [32] + * Get params: get_member(index, member, dest[], const lenght); + * Set params: set_member(index, member, const source[]); + */ + m_WeaponBox_rgiszAmmo, + + /* + * Description: - + * Member type: int [32] + * Get params: get_member(member); + * Set params: set_member(member, value, element); + */ + m_WeaponBox_rgAmmo, + + /* + * Description: - + * Member type: int + * Get params: get_member(index, member); + * Set params: set_member(index, member, value); + */ + m_WeaponBox_cAmmoTypes, + + /* + * Description: - + * Member type: bool + * Get params: get_member(index, member); + * Set params: set_member(index, member, value); + */ + m_WeaponBox_bIsBomb, }; diff --git a/reapi/include/com_progdefs.h b/reapi/include/com_progdefs.h index f38c051..b4c0772 100644 --- a/reapi/include/com_progdefs.h +++ b/reapi/include/com_progdefs.h @@ -303,3 +303,20 @@ struct com_playermove const char *(*PM_TraceTexture)(int ground, float *vstart, float *vend); void(*PM_PlaybackEventFull)(int flags, int clientindex, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); }; + +class CWeaponBox_COM: public CBaseEntity { +public: + virtual void Spawn() = 0; + virtual void Precache() = 0; + virtual void KeyValue(KeyValueData *pkvd) = 0; + virtual int Save(CSave &save) = 0; + virtual int Restore(CRestore &restore) = 0; + virtual void SetObjectCollisionBox() = 0; + virtual void Touch(CBaseEntity *pOther) = 0; +public: + CBasePlayerItem *m_rgpPlayerItems[MAX_ITEM_TYPES]; + qstring_t m_rgiszAmmo[MAX_AMMO_SLOTS]; + int m_rgAmmo[MAX_AMMO_SLOTS]; + int m_cAmmoTypes; + bool m_bIsBomb; +}; diff --git a/reapi/include/cssdk/dlls/basemonster.h b/reapi/include/cssdk/dlls/basemonster.h index 9b4b933..ad23197 100644 --- a/reapi/include/cssdk/dlls/basemonster.h +++ b/reapi/include/cssdk/dlls/basemonster.h @@ -49,8 +49,8 @@ class CBaseMonster: public CBaseToggle { public: virtual void KeyValue(KeyValueData *pkvd) = 0; virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) = 0; - virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - virtual int TakeHealth(float flHealth, int bitsDamageType) = 0; + virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; + virtual BOOL TakeHealth(float flHealth, int bitsDamageType) = 0; virtual void Killed(entvars_t *pevAttacker, int iGib) = 0; virtual int BloodColor() = 0; virtual BOOL IsAlive() = 0; diff --git a/reapi/include/cssdk/dlls/buttons.h b/reapi/include/cssdk/dlls/buttons.h index 27ac5b8..087417a 100644 --- a/reapi/include/cssdk/dlls/buttons.h +++ b/reapi/include/cssdk/dlls/buttons.h @@ -99,6 +99,6 @@ class CButtonTarget: public CBaseEntity { public: virtual void Spawn() = 0; virtual int ObjectCaps() = 0; - virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; + virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; }; diff --git a/reapi/include/cssdk/dlls/cbase.h b/reapi/include/cssdk/dlls/cbase.h index 235fec7..8a8da03 100644 --- a/reapi/include/cssdk/dlls/cbase.h +++ b/reapi/include/cssdk/dlls/cbase.h @@ -68,8 +68,8 @@ public: virtual void DeathNotice(entvars_t *pevChild) = 0; virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) = 0; - virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - virtual int TakeHealth(float flHealth, int bitsDamageType) = 0; + virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; + virtual BOOL TakeHealth(float flHealth, int bitsDamageType) = 0; virtual void Killed(entvars_t *pevAttacker, int iGib) = 0; virtual int BloodColor() = 0; virtual void TraceBleed(float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) = 0; @@ -268,7 +268,7 @@ public: virtual void Spawn() = 0; virtual void Precache() = 0; virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; + virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; virtual int Save(CSave &save) = 0; virtual int Restore(CRestore &restore) = 0; virtual int ObjectCaps() = 0; // Buttons that don't take damage can be IMPULSE used diff --git a/reapi/include/cssdk/dlls/client.h b/reapi/include/cssdk/dlls/client.h index f7f8a55..540fc4b 100644 --- a/reapi/include/cssdk/dlls/client.h +++ b/reapi/include/cssdk/dlls/client.h @@ -53,6 +53,17 @@ enum BuyItemMenuSlot MENU_SLOT_ITEM_SHIELD, }; +enum BuyItemID +{ + BUY_ITEM_VEST = 1, + BUY_ITEM_VESTHELM, + BUY_ITEM_FLASHGREN, + BUY_ITEM_HEGREN, + BUY_ITEM_SMOKEGREN, + BUY_ITEM_NVG, + BUY_ITEM_DEFUSEKIT +}; + #define CS_NUM_SKIN 4 #define CZ_NUM_SKIN 5 diff --git a/reapi/include/cssdk/dlls/func_break.h b/reapi/include/cssdk/dlls/func_break.h index 296c04e..b2f5978 100644 --- a/reapi/include/cssdk/dlls/func_break.h +++ b/reapi/include/cssdk/dlls/func_break.h @@ -77,7 +77,7 @@ public: virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) = 0; // breakables use an overridden takedamage - virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; + virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; virtual int DamageDecal(int bitsDamageType) = 0; virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; @@ -105,7 +105,7 @@ public: virtual int Save(CSave &save) = 0; virtual int Restore(CRestore &restore) = 0; virtual int ObjectCaps() = 0 - virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; + virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; virtual void Touch(CBaseEntity *pOther) = 0; virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; diff --git a/reapi/include/cssdk/dlls/gamerules.h b/reapi/include/cssdk/dlls/gamerules.h index f57a3fa..540cf6b 100644 --- a/reapi/include/cssdk/dlls/gamerules.h +++ b/reapi/include/cssdk/dlls/gamerules.h @@ -168,18 +168,24 @@ enum InfoMapBuyParam BUYING_NO_ONE, }; +// weapon respawning return codes enum { GR_NONE = 0, + GR_WEAPON_RESPAWN_YES, GR_WEAPON_RESPAWN_NO, + GR_AMMO_RESPAWN_YES, GR_AMMO_RESPAWN_NO, + GR_ITEM_RESPAWN_YES, GR_ITEM_RESPAWN_NO, + GR_PLR_DROP_GUN_ALL, GR_PLR_DROP_GUN_ACTIVE, GR_PLR_DROP_GUN_NO, + GR_PLR_DROP_AMMO_ALL, GR_PLR_DROP_AMMO_ACTIVE, GR_PLR_DROP_AMMO_NO, @@ -197,6 +203,7 @@ enum SCENARIO_BLOCK_HOSTAGE_RESCUE = (1 << 6), }; +// Player relationship return codes enum { GR_NOTTEAMMATE = 0, @@ -212,67 +219,103 @@ class CGameRules { protected: virtual ~CGameRules() {}; public: - virtual void RefreshSkillData() = 0; - virtual void Think() = 0; - virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity) = 0; - virtual BOOL FAllowFlashlight() = 0; - virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; - virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) = 0; - virtual BOOL IsMultiplayer() = 0; - virtual BOOL IsDeathmatch() = 0; - virtual BOOL IsTeamplay() = 0; - virtual BOOL IsCoOp() = 0; + virtual void RefreshSkillData() = 0; // fill skill data struct with proper values + virtual void Think() = 0; // runs every server frame, should handle any timer tasks, periodic events, etc. + virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity) = 0; // Can this item spawn (eg monsters don't spawn in deathmatch). - // this is the game name that gets seen in the server browser - virtual const char *GetGameDescription() = 0; - virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char *szRejectReason) = 0; - virtual void InitHUD(CBasePlayer *pl) = 0; - virtual void ClientDisconnected(edict_t *pClient) = 0; - virtual void UpdateGameMode(CBasePlayer *pPlayer) = 0; + virtual BOOL FAllowFlashlight() = 0; // Are players allowed to switch on their flashlight? + virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; // should the player switch to this weapon? + virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) = 0; // I can't use this weapon anymore, get me the next best one. + + // Functions to verify the single/multiplayer status of a game + virtual BOOL IsMultiplayer() = 0; // is this a multiplayer game? (either coop or deathmatch) + virtual BOOL IsDeathmatch() = 0; // is this a deathmatch game? + virtual BOOL IsTeamplay() = 0; // is this deathmatch game being played with team rules? + virtual BOOL IsCoOp() = 0; // is this a coop game? + virtual const char *GetGameDescription() = 0; // this is the game name that gets seen in the server browser + + // Client connection/disconnection + virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char *szRejectReason) = 0; // a client just connected to the server (player hasn't spawned yet) + virtual void InitHUD(CBasePlayer *pl) = 0; // the client dll is ready for updating + virtual void ClientDisconnected(edict_t *pClient) = 0; // a client just disconnected from the server + virtual void UpdateGameMode(CBasePlayer *pPlayer) = 0; // the client needs to be informed of the current game mode + + // Client damage rules virtual float FlPlayerFallDamage(CBasePlayer *pPlayer) = 0; - virtual BOOL FPlayerCanTakeDamage(CBasePlayer *pPlayer, CBaseEntity *pAttacker) = 0; + virtual BOOL FPlayerCanTakeDamage(CBasePlayer *pPlayer, CBaseEntity *pAttacker) = 0; // can this player take damage from this attacker? virtual BOOL ShouldAutoAim(CBasePlayer *pPlayer, edict_t *target) = 0; - virtual void PlayerSpawn(CBasePlayer *pPlayer) = 0; - virtual void PlayerThink(CBasePlayer *pPlayer) = 0; - virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer) = 0; - virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer) = 0; - virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer) = 0; + + // Client spawn/respawn control + virtual void PlayerSpawn(CBasePlayer *pPlayer) = 0; // called by CBasePlayer::Spawn just before releasing player into the game + virtual void PlayerThink(CBasePlayer *pPlayer) = 0; // called by CBasePlayer::PreThink every frame, before physics are run and after keys are accepted + virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer) = 0; // is this player allowed to respawn now? + virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer) = 0; // When in the future will this player be able to spawn? + virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer) = 0; // Place this player on their spawnspot and face them the proper direction. + virtual BOOL AllowAutoTargetCrosshair() = 0; virtual BOOL ClientCommand_DeadOrAlive(CBasePlayer *pPlayer, const char *pcmd) = 0; - virtual BOOL ClientCommand(CBasePlayer *pPlayer, const char *pcmd) = 0; - virtual void ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer) = 0; - virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled) = 0; - virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0; - virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor) = 0; - virtual BOOL CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem) = 0; - virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; - virtual int WeaponShouldRespawn(CBasePlayerItem *pWeapon) = 0; - virtual float FlWeaponRespawnTime(CBasePlayerItem *pWeapon) = 0; - virtual float FlWeaponTryRespawn(CBasePlayerItem *pWeapon) = 0; - virtual Vector VecWeaponRespawnSpot(CBasePlayerItem *pWeapon) = 0; - virtual BOOL CanHaveItem(CBasePlayer *pPlayer, CItem *pItem) = 0; - virtual void PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem) = 0; - virtual int ItemShouldRespawn(CItem *pItem) = 0; - virtual float FlItemRespawnTime(CItem *pItem) = 0; - virtual Vector VecItemRespawnSpot(CItem *pItem) = 0; - virtual BOOL CanHaveAmmo(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry) = 0; - virtual void PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount) = 0; - virtual int AmmoShouldRespawn(CBasePlayerAmmo *pAmmo) = 0; - virtual float FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo) = 0; - virtual Vector VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo) = 0; - virtual float FlHealthChargerRechargeTime() = 0; - virtual float FlHEVChargerRechargeTime() = 0; - virtual int DeadPlayerWeapons(CBasePlayer *pPlayer) = 0; - virtual int DeadPlayerAmmo(CBasePlayer *pPlayer) = 0; - virtual const char *GetTeamID(CBaseEntity *pEntity) = 0; - virtual int PlayerRelationship(CBasePlayer *pPlayer, CBaseEntity *pTarget) = 0; + virtual BOOL ClientCommand(CBasePlayer *pPlayer, const char *pcmd) = 0; // handles the user commands; returns TRUE if command handled properly + virtual void ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer) = 0; // the player has changed userinfo; can change it now + + // Client kills/scoring + virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled) = 0; // how many points do I award whoever kills this player? + virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0; // Called each time a player dies + virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor) = 0; // Call this from within a GameRules class to report an obituary. + + // Weapon retrieval + virtual BOOL CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem) = 0; // The player is touching an CBasePlayerItem, do I give it to him? + virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; // Called each time a player picks up a weapon from the ground + + // Weapon spawn/respawn control + virtual int WeaponShouldRespawn(CBasePlayerItem *pWeapon) = 0; // should this weapon respawn? + virtual float FlWeaponRespawnTime(CBasePlayerItem *pWeapon) = 0; // when may this weapon respawn? + virtual float FlWeaponTryRespawn(CBasePlayerItem *pWeapon) = 0; // can i respawn now, and if not, when should i try again? + virtual Vector VecWeaponRespawnSpot(CBasePlayerItem *pWeapon) = 0; // where in the world should this weapon respawn? + + // Item retrieval + virtual BOOL CanHaveItem(CBasePlayer *pPlayer, CItem *pItem) = 0; // is this player allowed to take this item? + virtual void PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem) = 0; // call each time a player picks up an item (battery, healthkit, longjump) + + // Item spawn/respawn control + virtual int ItemShouldRespawn(CItem *pItem) = 0; // Should this item respawn? + virtual float FlItemRespawnTime(CItem *pItem) = 0; // when may this item respawn? + virtual Vector VecItemRespawnSpot(CItem *pItem) = 0; // where in the world should this item respawn? + + // Ammo retrieval + virtual BOOL CanHaveAmmo(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry) = 0; // can this player take more of this ammo? + virtual void PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount) = 0; // called each time a player picks up some ammo in the world + + // Ammo spawn/respawn control + virtual int AmmoShouldRespawn(CBasePlayerAmmo *pAmmo) = 0; // should this ammo item respawn? + virtual float FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo) = 0; // when should this ammo item respawn? + virtual Vector VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo) = 0; // where in the world should this ammo item respawn? + + // Healthcharger respawn control + virtual float FlHealthChargerRechargeTime() = 0; // how long until a depleted HealthCharger recharges itself? + virtual float FlHEVChargerRechargeTime() = 0; // how long until a depleted HealthCharger recharges itself? + + // What happens to a dead player's weapons + virtual int DeadPlayerWeapons(CBasePlayer *pPlayer) = 0; // what do I do with a player's weapons when he's killed? + + // What happens to a dead player's ammo + virtual int DeadPlayerAmmo(CBasePlayer *pPlayer) = 0; // Do I drop ammo when the player dies? How much? + + // Teamplay stuff + virtual const char *GetTeamID(CBaseEntity *pEntity) = 0; // what team is this entity on? + virtual int PlayerRelationship(CBasePlayer *pPlayer, CBaseEntity *pTarget) = 0; // What is the player's relationship with this entity? virtual int GetTeamIndex(const char *pTeamName) = 0; virtual const char *GetIndexedTeamName(int teamIndex) = 0; virtual BOOL IsValidTeam(const char *pTeamName) = 0; virtual void ChangePlayerTeam(CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib) = 0; virtual const char *SetDefaultPlayerTeam(CBasePlayer *pPlayer) = 0; + + // Sounds virtual BOOL PlayTextureSounds() = 0; - virtual BOOL FAllowMonsters() = 0; + + // Monsters + virtual BOOL FAllowMonsters() = 0; // are monsters allowed + + // Immediately end a multiplayer game virtual void EndMultiplayerGame() = 0; // Stuff that is shared between client and server. @@ -287,6 +330,7 @@ public: char *m_GameDesc; }; +// CHalfLifeRules - rules for the single player Half-Life game. class CHalfLifeRules: public CGameRules { protected: virtual ~CHalfLifeRules() {}; @@ -294,46 +338,81 @@ public: virtual void Think() = 0; virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity) = 0; virtual BOOL FAllowFlashlight() = 0; + virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) = 0; + + // Functions to verify the single/multiplayer status of a game virtual BOOL IsMultiplayer() = 0; virtual BOOL IsDeathmatch() = 0; virtual BOOL IsCoOp() = 0; + + // Client connection/disconnection virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]) = 0; - virtual void InitHUD(CBasePlayer *pl) = 0; + virtual void InitHUD(CBasePlayer *pl) = 0; // the client dll is ready for updating virtual void ClientDisconnected(edict_t *pClient) = 0; + + // Client damage rules virtual float FlPlayerFallDamage(CBasePlayer *pPlayer) = 0; + + // Client spawn/respawn control virtual void PlayerSpawn(CBasePlayer *pPlayer) = 0; virtual void PlayerThink(CBasePlayer *pPlayer) = 0; virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer) = 0; virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer) = 0; virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer) = 0; + virtual BOOL AllowAutoTargetCrosshair() = 0; + + // Client kills/scoring virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled) = 0; virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0; virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0; + + // Weapon retrieval virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; + + // Weapon spawn/respawn control virtual int WeaponShouldRespawn(CBasePlayerItem *pWeapon) = 0; virtual float FlWeaponRespawnTime(CBasePlayerItem *pWeapon) = 0; virtual float FlWeaponTryRespawn(CBasePlayerItem *pWeapon) = 0; virtual Vector VecWeaponRespawnSpot(CBasePlayerItem *pWeapon) = 0; + + // Item retrieval virtual BOOL CanHaveItem(CBasePlayer *pPlayer, CItem *pItem) = 0; virtual void PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem) = 0; + + // Item spawn/respawn control virtual int ItemShouldRespawn(CItem *pItem) = 0; virtual float FlItemRespawnTime(CItem *pItem) = 0; virtual Vector VecItemRespawnSpot(CItem *pItem) = 0; + + // Ammo retrieval virtual void PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount) = 0; + + // Ammo spawn/respawn control virtual int AmmoShouldRespawn(CBasePlayerAmmo *pAmmo) = 0; virtual float FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo) = 0; virtual Vector VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo) = 0; + + // Healthcharger respawn control virtual float FlHealthChargerRechargeTime() = 0; + + // What happens to a dead player's weapons virtual int DeadPlayerWeapons(CBasePlayer *pPlayer) = 0; + + // What happens to a dead player's ammo virtual int DeadPlayerAmmo(CBasePlayer *pPlayer) = 0; + + // Teamplay stuff virtual const char *GetTeamID(CBaseEntity *pEntity) = 0; virtual int PlayerRelationship(CBasePlayer *pPlayer, CBaseEntity *pTarget) = 0; + + // Monsters virtual BOOL FAllowMonsters() = 0; }; +// CHalfLifeMultiplay - rules for the basic half life multiplayer competition class CHalfLifeMultiplay: public CGameRules { protected: virtual ~CHalfLifeMultiplay() {}; @@ -342,54 +421,91 @@ public: virtual void Think() = 0; virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity) = 0; virtual BOOL FAllowFlashlight() = 0; + virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) = 0; + virtual BOOL IsMultiplayer() = 0; virtual BOOL IsDeathmatch() = 0; virtual BOOL IsCoOp() = 0; + + // Client connection/disconnection + // If ClientConnected returns FALSE, the connection is rejected and the user is provided the reason specified in szRejectReason + // Only the client's name and remote address are provided to the dll for verification. virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]) = 0; virtual void InitHUD(CBasePlayer *pl) = 0; virtual void ClientDisconnected(edict_t *pClient) = 0; virtual void UpdateGameMode(CBasePlayer *pPlayer) = 0; + + // Client damage rules virtual float FlPlayerFallDamage(CBasePlayer *pPlayer) = 0; virtual BOOL FPlayerCanTakeDamage(CBasePlayer *pPlayer, CBaseEntity *pAttacker) = 0; + + // Client spawn/respawn control virtual void PlayerSpawn(CBasePlayer *pPlayer) = 0; virtual void PlayerThink(CBasePlayer *pPlayer) = 0; virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer) = 0; virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer) = 0; virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer) = 0; + virtual BOOL AllowAutoTargetCrosshair() = 0; + virtual BOOL ClientCommand_DeadOrAlive(CBasePlayer *pPlayer, const char *pcmd) = 0; virtual BOOL ClientCommand(CBasePlayer *pPlayer, const char *pcmd) = 0; virtual void ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer) = 0; + + // Client kills/scoring virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled) = 0; virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0; - - // Death notices virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0; + + // Weapon retrieval virtual BOOL CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; + + // Weapon spawn/respawn control virtual int WeaponShouldRespawn(CBasePlayerItem *pWeapon) = 0; virtual float FlWeaponRespawnTime(CBasePlayerItem *pWeapon) = 0; virtual float FlWeaponTryRespawn(CBasePlayerItem *pWeapon) = 0; virtual Vector VecWeaponRespawnSpot(CBasePlayerItem *pWeapon) = 0; + + // Item retrieval virtual BOOL CanHaveItem(CBasePlayer *pPlayer, CItem *pItem) = 0; virtual void PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem) = 0; + + // Item spawn/respawn control virtual int ItemShouldRespawn(CItem *pItem) = 0; virtual float FlItemRespawnTime(CItem *pItem) = 0; virtual Vector VecItemRespawnSpot(CItem *pItem) = 0; + + // Ammo retrieval virtual void PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount) = 0; + + // Ammo spawn/respawn control virtual int AmmoShouldRespawn(CBasePlayerAmmo *pAmmo) = 0; virtual float FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo) = 0; virtual Vector VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo) = 0; + + // Healthcharger respawn control virtual float FlHealthChargerRechargeTime() = 0; virtual float FlHEVChargerRechargeTime() = 0; + + // What happens to a dead player's weapons virtual int DeadPlayerWeapons(CBasePlayer *pPlayer) = 0; + + // What happens to a dead player's ammo virtual int DeadPlayerAmmo(CBasePlayer *pPlayer) = 0; + + // Teamplay stuff virtual const char *GetTeamID(CBaseEntity *pEntity) = 0; virtual int PlayerRelationship(CBasePlayer *pPlayer, CBaseEntity *pTarget) = 0; + virtual BOOL PlayTextureSounds() = 0; + + // Monsters virtual BOOL FAllowMonsters() = 0; + + // Immediately end a multiplayer game virtual void EndMultiplayerGame() = 0; virtual void ServerDeactivate() = 0; virtual void CheckMapConditions() = 0; diff --git a/reapi/include/cssdk/dlls/h_cycler.h b/reapi/include/cssdk/dlls/h_cycler.h index 4989620..5f9ab00 100644 --- a/reapi/include/cssdk/dlls/h_cycler.h +++ b/reapi/include/cssdk/dlls/h_cycler.h @@ -33,7 +33,7 @@ public: virtual int Save(CSave &save) = 0; virtual int Restore(CRestore &restore) = 0; virtual int ObjectCaps() = 0; - virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; + virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; // Don't treat as a live target virtual BOOL IsAlive() = 0; @@ -62,7 +62,7 @@ public: virtual int Save(CSave &save) = 0; virtual int Restore(CRestore &restore) = 0; virtual int ObjectCaps() = 0; - virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; + virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; virtual void Think() = 0; virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; public: diff --git a/reapi/include/cssdk/dlls/plats.h b/reapi/include/cssdk/dlls/plats.h index d9acf7c..8409525 100644 --- a/reapi/include/cssdk/dlls/plats.h +++ b/reapi/include/cssdk/dlls/plats.h @@ -169,7 +169,7 @@ public: virtual int ObjectCaps() = 0; virtual void Activate() = 0; virtual int Classify() = 0; - virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; + virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; virtual int BloodColor() = 0; virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; virtual Vector BodyTarget(const Vector &posSrc) = 0; diff --git a/reapi/include/cssdk/dlls/player.h b/reapi/include/cssdk/dlls/player.h index 4e0dc24..8aaede9 100644 --- a/reapi/include/cssdk/dlls/player.h +++ b/reapi/include/cssdk/dlls/player.h @@ -309,8 +309,8 @@ public: virtual int ObjectCaps() = 0; virtual int Classify() = 0; virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) = 0; - virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - virtual int TakeHealth(float flHealth, int bitsDamageType) = 0; + virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; + virtual BOOL TakeHealth(float flHealth, int bitsDamageType) = 0; virtual void Killed(entvars_t *pevAttacker, int iGib) = 0; virtual void AddPoints(int score, BOOL bAllowNegativeScore) = 0; virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore) = 0; diff --git a/reapi/include/cssdk/dlls/regamedll_api.h b/reapi/include/cssdk/dlls/regamedll_api.h index 3f2a2f0..c6ffce8 100644 --- a/reapi/include/cssdk/dlls/regamedll_api.h +++ b/reapi/include/cssdk/dlls/regamedll_api.h @@ -32,6 +32,7 @@ #include "interface.h" #include "player.h" #include "gamerules.h" +#include "client.h" #define REGAMEDLL_API_VERSION_MAJOR 3 #define REGAMEDLL_API_VERSION_MINOR 1 @@ -57,12 +58,12 @@ typedef IVoidHookChainClass IReGameHookRegistry_CBasePlayer_TraceAttack; // CBasePlayer::TakeDamage hook -typedef IHookChainClass IReGameHook_CBasePlayer_TakeDamage; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_TakeDamage; +typedef IHookChainClass IReGameHook_CBasePlayer_TakeDamage; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_TakeDamage; // CBasePlayer::TakeHealth hook -typedef IHookChainClass IReGameHook_CBasePlayer_TakeHealth; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_TakeHealth; +typedef IHookChainClass IReGameHook_CBasePlayer_TakeHealth; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_TakeHealth; // CBasePlayer::Killed hook typedef IVoidHookChainClass IReGameHook_CBasePlayer_Killed; @@ -301,6 +302,10 @@ typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_GoToIntermissio typedef IVoidHookChain<> IReGameHook_CSGameRules_BalanceTeams; typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_BalanceTeams; +// CanBuyThisItem hook +typedef IHookChain IReGameHook_CanBuyThisItem; +typedef IHookChainRegistry IReGameHookRegistry_CanBuyThisItem; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -374,6 +379,8 @@ public: virtual IReGameHookRegistry_CSGameRules_ChangeLevel* CSGameRules_ChangeLevel() = 0; virtual IReGameHookRegistry_CSGameRules_GoToIntermission* CSGameRules_GoToIntermission() = 0; virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams() = 0; + + virtual IReGameHookRegistry_CanBuyThisItem* CanBuyThisItem() = 0; }; struct ReGameFuncs_t { diff --git a/reapi/include/cssdk/dlls/util.h b/reapi/include/cssdk/dlls/util.h index c032d32..f5482ee 100644 --- a/reapi/include/cssdk/dlls/util.h +++ b/reapi/include/cssdk/dlls/util.h @@ -57,6 +57,7 @@ extern globalvars_t *gpGlobals; #define SND_CHANGE_VOL (1<<6) // duplicated in protocol.h change sound vol #define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch +// All monsters need this data #define DONT_BLEED -1 #define BLOOD_COLOR_RED (byte)247 #define BLOOD_COLOR_YELLOW (byte)195 diff --git a/reapi/include/cssdk/dlls/vector.h b/reapi/include/cssdk/dlls/vector.h index 57f6b6d..6427e1e 100644 --- a/reapi/include/cssdk/dlls/vector.h +++ b/reapi/include/cssdk/dlls/vector.h @@ -31,13 +31,15 @@ // operations that are treated as planar rather than 3d. class Vector2D { public: - inline Vector2D() : x(0.0), y(0.0) {} - inline Vector2D(float X, float Y) : x(0.0), y(0.0) { x = X; y = Y; } + inline Vector2D() : x(), y() {} + inline Vector2D(float X, float Y) : x(X), y(Y) {} + inline Vector2D(const Vector2D &v) { *(int*)&x = *(int*)&v.x; *(int*)&y = *(int*)&v.y; } inline Vector2D operator+(const Vector2D &v) const { return Vector2D(x + v.x, y + v.y); } inline Vector2D operator-(const Vector2D &v) const { return Vector2D(x - v.x, y - v.y); } inline Vector2D operator*(float fl) const { return Vector2D(x * fl, y * fl); } inline Vector2D operator/(float fl) const { return Vector2D(x / fl, y / fl); } inline Vector2D operator/=(float fl) const { return Vector2D(x / fl, y / fl); } + inline float Length() const { return sqrt(x * x + y * y); } inline float LengthSquared() const { return (x * x + y * y); } @@ -89,11 +91,10 @@ inline Vector2D operator*(float fl, const Vector2D &v) { return v * fl; } class Vector { public: // Construction/destruction - inline Vector() : x(0.0), y(0.0), z(0.0) {} - inline Vector(float X, float Y, float Z) : x(0.0), y(0.0), z(0.0) { x = X; y = Y; z = Z; } - - inline Vector(const Vector &v) : x(0.0), y(0.0), z(0.0) { x = v.x; y = v.y; z = v.z; } - inline Vector(const float rgfl[3]) : x(0.0), y(0.0), z(0.0) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } + inline Vector() : x(), y(), z() {} + inline Vector(float X, float Y, float Z) : x(X), y(Y), z(Z) {} + inline Vector(const Vector &v) { *(int*)&x = *(int*)&v.x; *(int*)&y = *(int*)&v.y; *(int*)&z = *(int*)&v.z; } + inline Vector(const float rgfl[3]) { *(int*)&x = *(int*)&rgfl[0]; *(int*)&y = *(int*)&rgfl[1]; *(int*)&z = *(int*)&rgfl[2]; } // Operators inline Vector operator-() const { return Vector(-x, -y, -z); } @@ -106,7 +107,7 @@ public: inline Vector operator/=(float fl) const{ return Vector(x / fl, y / fl, z / fl); } // Methods - inline void CopyToArray(float *rgfl) const { rgfl[0] = x; rgfl[1] = y; rgfl[2] = z; } + inline void CopyToArray(float *rgfl) const { *(int*)&rgfl[0] = *(int*)&x; *(int*)&rgfl[1] = *(int*)&y; *(int*)&rgfl[2] = *(int*)&z; } inline float Length() const { return sqrt(x * x + y * y + z * z); } inline float LengthSquared() const { return (x * x + y * y + z * z); } @@ -122,7 +123,14 @@ public: flLen = 1 / flLen; return Vector(x * flLen, y * flLen, z * flLen); } - inline Vector2D Make2D() const { return Vector2D(x, y); } + inline Vector2D Make2D() const + { + Vector2D Vec2; + *(int*)&Vec2.x = *(int*)&x; + *(int*)&Vec2.y = *(int*)&y; + return Vec2; + } + inline float Length2D() const { return sqrt(x * x + y * y); } inline bool IsLengthLessThan(float length) const { return (LengthSquared() < length * length); } diff --git a/reapi/src/main.cpp b/reapi/src/main.cpp index 23e06db..00a9a1a 100644 --- a/reapi/src/main.cpp +++ b/reapi/src/main.cpp @@ -3,7 +3,7 @@ edict_t* g_pEdicts; playermove_t* g_pMove; char g_szMapName[32]; -int gmsgSendAudio, gmsgStatusIcon, gmsgArmorType, gmsgTeamInfo, gmsgItemStatus; +int gmsgSendAudio, gmsgStatusIcon, gmsgArmorType, gmsgItemStatus; struct { @@ -13,7 +13,6 @@ struct { "SendAudio", gmsgSendAudio }, { "StatusIcon", gmsgStatusIcon }, { "ArmorType", gmsgArmorType }, - { "TeamInfo", gmsgTeamInfo }, { "ItemStatus", gmsgItemStatus }, }; diff --git a/reapi/src/main.h b/reapi/src/main.h index 1412c81..8f248fd 100644 --- a/reapi/src/main.h +++ b/reapi/src/main.h @@ -6,7 +6,6 @@ extern playermove_t* g_pMove; extern int gmsgSendAudio; extern int gmsgStatusIcon; extern int gmsgArmorType; -extern int gmsgTeamInfo; extern int gmsgItemStatus; void OnAmxxAttach(); diff --git a/reapi/src/member_list.cpp b/reapi/src/member_list.cpp index d324d2b..47aaab3 100644 --- a/reapi/src/member_list.cpp +++ b/reapi/src/member_list.cpp @@ -1,21 +1,22 @@ #include "precompiled.h" -#define CLASS_MEMBERS(cx, mx, pref) ((!(pref##mx & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (pref##mx & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltype(##cx::##mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(##cx, ##mx);ptr->type = getMemberType(f);}) : regmember(#mx) +#define CLASS_MEMBERS(cx, mx, postf, pref) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltype(##cx::##pref##mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(##cx, ##pref##mx);ptr->type = getMemberType(f);}) : regmember(#pref#mx) -#define GM_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx,) -#define GM_VOICE_MEMBERS(mx) CLASS_MEMBERS(CVoiceGameMgr, mx,) -#define BASE_MEMBERS(mx) CLASS_MEMBERS(CBaseEntity, mx,) -#define ANIM_MEMBERS(mx) CLASS_MEMBERS(CBaseAnimating, mx,) -#define MONST_MEMBERS(mx) CLASS_MEMBERS(CBaseMonster, mx,) -#define PL_MEMBERS(mx) CLASS_MEMBERS(CBasePlayer, mx,) -#define EVAR_MEMBERS(mx) CLASS_MEMBERS(com_entvars, mx, var_) -#define PMOVE_MEMBERS(mx) CLASS_MEMBERS(com_playermove, mx, pm_) -#define MOVEVAR_MEMBERS(mx) CLASS_MEMBERS(movevars_t, mx, mv_) -#define UCMD_MEMBERS(mx) CLASS_MEMBERS(usercmd_s, mx, ucmd_) -#define PMTRACE_MEMBERS(mx) CLASS_MEMBERS(pmtrace_s, mx, pmt_) -#define CSPL_MEMBERS(mx) CLASS_MEMBERS(CCSPlayer, mx,) -#define BASEITEM_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerItem, mx,) -#define BASEWPN_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerWeapon, mx,) +#define GM_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx, mx,) +#define GM_VOICE_MEMBERS(mx) CLASS_MEMBERS(CVoiceGameMgr, mx, mx,) +#define BASE_MEMBERS(mx) CLASS_MEMBERS(CBaseEntity, mx, mx,) +#define ANIM_MEMBERS(mx) CLASS_MEMBERS(CBaseAnimating, mx, mx,) +#define MONST_MEMBERS(mx) CLASS_MEMBERS(CBaseMonster, mx, mx,) +#define PL_MEMBERS(mx) CLASS_MEMBERS(CBasePlayer, mx, mx,) +#define EVAR_MEMBERS(mx) CLASS_MEMBERS(com_entvars, mx, var_##mx,) +#define PMOVE_MEMBERS(mx) CLASS_MEMBERS(com_playermove, mx, pm_##mx,) +#define MOVEVAR_MEMBERS(mx) CLASS_MEMBERS(movevars_t, mx, mv_##mx,) +#define UCMD_MEMBERS(mx) CLASS_MEMBERS(usercmd_s, mx, ucmd_##mx,) +#define PMTRACE_MEMBERS(mx) CLASS_MEMBERS(pmtrace_s, mx, pmt_##mx,) +#define CSPL_MEMBERS(mx) CLASS_MEMBERS(CCSPlayer, mx, mx,) +#define BASEITEM_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerItem, mx, mx,) +#define BASEWPN_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerWeapon, mx, m_Weapon_##mx, m_) +#define WPNBOX_MEMBERS(mx) CLASS_MEMBERS(CWeaponBox_COM, mx, m_WeaponBox_##mx, m_) inline MType getMemberType(float*) { return MEMBER_FLOAT; } inline MType getMemberType(float) { return MEMBER_FLOAT; } @@ -37,6 +38,7 @@ inline MType getMemberType(Vector) { return MEMBER_VECTOR; } inline MType getMemberType(char*) { return MEMBER_STRING; } inline MType getMemberType(qstring_t) { return MEMBER_QSTRING; } +inline MType getMemberType(qstring_t*) { return MEMBER_QSTRING; } inline MType getMemberType(char) { return MEMBER_BYTE; } inline MType getMemberType(byte) { return MEMBER_BYTE; } @@ -677,41 +679,49 @@ member_t memberlist_baseitem[] = { }; member_t memberlist_baseweapon[] = { - BASEWPN_MEMBERS(m_iPlayEmptySound), - BASEWPN_MEMBERS(m_fFireOnEmpty), - BASEWPN_MEMBERS(m_flNextPrimaryAttack), - BASEWPN_MEMBERS(m_flNextSecondaryAttack), - //BASEWPN_MEMBERS(m_flTimeWeaponIdle), // FIXME: conflict with CBasePlayer::m_flTimeWeaponIdle - BASEWPN_MEMBERS(m_iPrimaryAmmoType), - BASEWPN_MEMBERS(m_iSecondaryAmmoType), - BASEWPN_MEMBERS(m_iClip), - BASEWPN_MEMBERS(m_iClientClip), - BASEWPN_MEMBERS(m_iClientWeaponState), - BASEWPN_MEMBERS(m_fInReload), - BASEWPN_MEMBERS(m_fInSpecialReload), - BASEWPN_MEMBERS(m_iDefaultAmmo), - BASEWPN_MEMBERS(m_iShellId), - BASEWPN_MEMBERS(m_fMaxSpeed), - BASEWPN_MEMBERS(m_bDelayFire), - BASEWPN_MEMBERS(m_iDirection), - BASEWPN_MEMBERS(m_bSecondarySilencerOn), - BASEWPN_MEMBERS(m_flAccuracy), - BASEWPN_MEMBERS(m_flLastFire), - BASEWPN_MEMBERS(m_iShotsFired), - //BASEWPN_MEMBERS(m_vVecAiming), + BASEWPN_MEMBERS(iPlayEmptySound), + BASEWPN_MEMBERS(fFireOnEmpty), + BASEWPN_MEMBERS(flNextPrimaryAttack), + BASEWPN_MEMBERS(flNextSecondaryAttack), + BASEWPN_MEMBERS(flTimeWeaponIdle), // FIXME: conflict with CBasePlayer::m_flTimeWeaponIdle + BASEWPN_MEMBERS(iPrimaryAmmoType), + BASEWPN_MEMBERS(iSecondaryAmmoType), + BASEWPN_MEMBERS(iClip), + BASEWPN_MEMBERS(iClientClip), + BASEWPN_MEMBERS(iClientWeaponState), + BASEWPN_MEMBERS(fInReload), + BASEWPN_MEMBERS(fInSpecialReload), + BASEWPN_MEMBERS(iDefaultAmmo), + BASEWPN_MEMBERS(iShellId), + BASEWPN_MEMBERS(fMaxSpeed), + BASEWPN_MEMBERS(bDelayFire), + BASEWPN_MEMBERS(iDirection), + BASEWPN_MEMBERS(bSecondarySilencerOn), + BASEWPN_MEMBERS(flAccuracy), + BASEWPN_MEMBERS(flLastFire), + BASEWPN_MEMBERS(iShotsFired), + //BASEWPN_MEMBERS(vVecAiming), //BASEWPN_MEMBERS(model_name), - BASEWPN_MEMBERS(m_flGlock18Shoot), - BASEWPN_MEMBERS(m_iGlock18ShotsFired), - BASEWPN_MEMBERS(m_flFamasShoot), - BASEWPN_MEMBERS(m_iFamasShotsFired), - BASEWPN_MEMBERS(m_fBurstSpread), - BASEWPN_MEMBERS(m_iWeaponState), - BASEWPN_MEMBERS(m_flNextReload), - BASEWPN_MEMBERS(m_flDecreaseShotsFired), - BASEWPN_MEMBERS(m_usFireGlock18), - BASEWPN_MEMBERS(m_usFireFamas), - BASEWPN_MEMBERS(m_flPrevPrimaryAttack), - BASEWPN_MEMBERS(m_flLastFireTime), + BASEWPN_MEMBERS(flGlock18Shoot), + BASEWPN_MEMBERS(iGlock18ShotsFired), + BASEWPN_MEMBERS(flFamasShoot), + BASEWPN_MEMBERS(iFamasShotsFired), + BASEWPN_MEMBERS(fBurstSpread), + BASEWPN_MEMBERS(iWeaponState), + BASEWPN_MEMBERS(flNextReload), + BASEWPN_MEMBERS(flDecreaseShotsFired), + BASEWPN_MEMBERS(usFireGlock18), + BASEWPN_MEMBERS(usFireFamas), + BASEWPN_MEMBERS(flPrevPrimaryAttack), + BASEWPN_MEMBERS(flLastFireTime), +}; + +member_t memberlist_weaponbox[] = { + WPNBOX_MEMBERS(rgpPlayerItems), + WPNBOX_MEMBERS(rgiszAmmo), + WPNBOX_MEMBERS(rgAmmo), + WPNBOX_MEMBERS(cAmmoTypes), + WPNBOX_MEMBERS(bIsBomb), }; memberlist_t memberlist; @@ -737,6 +747,7 @@ member_t *memberlist_t::operator[](size_t members) const CASE(csplayer) CASE(baseitem) CASE(baseweapon) + CASE(weaponbox) } return nullptr; diff --git a/reapi/src/member_list.h b/reapi/src/member_list.h index 84f243a..f4f1add 100644 --- a/reapi/src/member_list.h +++ b/reapi/src/member_list.h @@ -52,7 +52,8 @@ struct memberlist_t mt_pmtrace, mt_csplayer, mt_baseitem, - mt_baseweapon + mt_baseweapon, + mt_weaponbox }; }; @@ -681,39 +682,48 @@ enum CBasePlayerItem_Members enum CBasePlayerWeapon_Members { - m_iPlayEmptySound = BEGIN_MEMBER_REGION(baseweapon), - m_fFireOnEmpty, - m_flNextPrimaryAttack, - m_flNextSecondaryAttack, - //m_flTimeWeaponIdle, - m_iPrimaryAmmoType, - m_iSecondaryAmmoType, - m_iClip, - m_iClientClip, - m_iClientWeaponState, - m_fInReload, - m_fInSpecialReload, - m_iDefaultAmmo, - m_iShellId, - m_fMaxSpeed, - m_bDelayFire, - m_iDirection, - m_bSecondarySilencerOn, - m_flAccuracy, - m_flLastFire, - m_iShotsFired, - //m_vVecAiming, - //model_name, - m_flGlock18Shoot, - m_iGlock18ShotsFired, - m_flFamasShoot, - m_iFamasShotsFired, - m_fBurstSpread, - m_iWeaponState, - m_flNextReload, - m_flDecreaseShotsFired, - m_usFireGlock18, - m_usFireFamas, - m_flPrevPrimaryAttack, - m_flLastFireTime + m_Weapon_iPlayEmptySound = BEGIN_MEMBER_REGION(baseweapon), + m_Weapon_fFireOnEmpty, + m_Weapon_flNextPrimaryAttack, + m_Weapon_flNextSecondaryAttack, + m_Weapon_flTimeWeaponIdle, + m_Weapon_iPrimaryAmmoType, + m_Weapon_iSecondaryAmmoType, + m_Weapon_iClip, + m_Weapon_iClientClip, + m_Weapon_iClientWeaponState, + m_Weapon_fInReload, + m_Weapon_fInSpecialReload, + m_Weapon_iDefaultAmmo, + m_Weapon_iShellId, + m_Weapon_fMaxSpeed, + m_Weapon_bDelayFire, + m_Weapon_iDirection, + m_Weapon_bSecondarySilencerOn, + m_Weapon_flAccuracy, + m_Weapon_flLastFire, + m_Weapon_iShotsFired, + //m_Weapon_vVecAiming, + //m_Weapon_model_name, + m_Weapon_flGlock18Shoot, + m_Weapon_iGlock18ShotsFired, + m_Weapon_flFamasShoot, + m_Weapon_iFamasShotsFired, + m_Weapon_fBurstSpread, + m_Weapon_iWeaponState, + m_Weapon_flNextReload, + m_Weapon_flDecreaseShotsFired, + m_Weapon_usFireGlock18, + m_Weapon_usFireFamas, + m_Weapon_flPrevPrimaryAttack, + m_Weapon_flLastFireTime +}; + +enum CWeaponBox_Members +{ + m_WeaponBox_rgpPlayerItems = BEGIN_MEMBER_REGION(weaponbox), + m_WeaponBox_rgiszAmmo, + m_WeaponBox_rgAmmo, + m_WeaponBox_cAmmoTypes, + m_WeaponBox_bIsBomb, }; diff --git a/reapi/src/natives/natives_members.cpp b/reapi/src/natives/natives_members.cpp index c75e20b..9eb2a29 100644 --- a/reapi/src/natives/natives_members.cpp +++ b/reapi/src/natives/natives_members.cpp @@ -554,27 +554,23 @@ cell get_member(void* pdata, const member_t *member, size_t element, cell* dest) switch (member->type) { case MEMBER_CLASSPTR: - // native any:get_member(_index, any:_member, element); - return indexOfEdict(get_member(pdata, member->offset, element)->pev); + { + // native any:get_member(_index, any:_member, element); + auto& pEntity = get_member(pdata, member->offset, element); + return pEntity ? indexOfEdict(pEntity->pev) : -1; + } case MEMBER_EHANDLE: { // native any:get_member(_index, any:_member, element); EHANDLE ehandle = get_member(pdata, member->offset, element); edict_t *pEntity = ehandle.Get(); - if (pEntity != nullptr) { - return indexOfEdict(pEntity); - } - return -1; + return pEntity ? indexOfEdict(pEntity) : -1; } case MEMBER_EDICT: { // native any:get_member(_index, any:_member, element); edict_t *pEntity = get_member(pdata, member->offset, element); - if (pEntity != nullptr) { - return indexOfEdict(pEntity); - } - - return -1; + return pEntity ? indexOfEdict(pEntity) : -1; } case MEMBER_VECTOR: { diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 9e4b353..f15fce7 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -539,6 +539,43 @@ cell AMX_NATIVE_CALL rg_find_ent_by_owner(AMX *amx, cell *params) return FALSE; } +/* +* Find the item by name in the player's inventory. +* +* @param index Client index +* @param item Item name +* +* @return Entity-index of item, 0 otherwise +* +* native rg_find_bpack_item_by_name(const index, const item[]); +*/ +cell AMX_NATIVE_CALL rg_find_item_bpack_by_name(AMX *amx, cell *params) +{ + enum args_e { arg_count, arg_index, arg_item }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]); + if (pPlayer == nullptr || pPlayer->has_disconnected) { + MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]); + return FALSE; + } + + const char *itemName = getAmxString(amx, params[arg_item]); + auto pInfo = g_ReGameApi->GetWeaponSlot(itemName); + auto pItem = pPlayer->m_rgpPlayerItems[ pInfo->slot ]; + + while (pItem) { + if (FClassnameIs(pItem->pev, itemName)) { + return indexOfEdict(pItem->pev); + } + + pItem = pItem->m_pNext; + } + + return 0; +} + /* * Returns some information about a weapon. * @@ -1015,10 +1052,7 @@ cell AMX_NATIVE_CALL rg_set_user_team(AMX *amx, cell *params) } if (params[arg_sendinfo] != 0) { - MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo); - WRITE_BYTE(args[arg_index]); - WRITE_STRING(GetTeamName(args[arg_team])); - MESSAGE_END(); + pPlayer->CSPlayer()->TeamChangeUpdate(); } g_amxxapi.SetPlayerTeamInfo(args[arg_index], args[arg_team], GetTeamName(args[arg_team])); @@ -1360,13 +1394,13 @@ cell AMX_NATIVE_CALL rg_switch_weapon(AMX *amx, cell *params) } /* -* To priority autoselect join to team +* To get which team has a high priority to join. * * @return Returns the Team Name * -* native TeamName:rg_select_default_team(); +* native TeamName:rg_get_join_team_priority(); */ -cell AMX_NATIVE_CALL rg_select_default_team(AMX *amx, cell *params) +cell AMX_NATIVE_CALL rg_get_join_team_priority(AMX *amx, cell *params) { if (g_pGameRules == nullptr) { MF_LogError(amx, AMX_ERR_NATIVE, "%s: gamerules not initialized", __FUNCTION__); @@ -1376,6 +1410,67 @@ cell AMX_NATIVE_CALL rg_select_default_team(AMX *amx, cell *params) return CSGameRules()->SelectDefaultTeam(); } +/* +* Can this player take damage from this attacker? +* +* @param index Client index +* @param attacker Attacker index +* +* @return 1 if successfully then can take a damage, 0 otherwise +* +* native bool:rg_is_player_can_takedamage(const index, const attacker); +*/ +cell AMX_NATIVE_CALL rg_is_player_can_takedamage(AMX *amx, cell *params) +{ + enum args_e { arg_count, arg_index, arg_attacker }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]); + if (pPlayer == nullptr || pPlayer->has_disconnected) { + MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]); + return FALSE; + } + + CBaseEntity *pAttacker = getPrivate(params[arg_attacker]); + if (!pAttacker) { + MF_LogError(amx, AMX_ERR_NATIVE, "%s: Invalid entity attacker", __FUNCTION__); + return FALSE; + } + + return CSGameRules()->FPlayerCanTakeDamage(pPlayer, pAttacker); +} + +/* +* To get WeaponIdType from weaponbox +* +* @param entity Weaponbox entity +* +* @return return enum's of WeaponIdType +* +* native WeaponIdType:rg_get_weaponbox_id(const entity); +*/ +cell AMX_NATIVE_CALL rg_get_weaponbox_id(AMX *amx, cell *params) +{ + enum args_e { arg_count, arg_entity }; + + CHECK_ISENTITY(arg_entity); + + CWeaponBox *pEntityBox = getPrivate(params[arg_entity]); + if (pEntityBox == nullptr) { + MF_LogError(amx, AMX_ERR_NATIVE, "%s: Invalid entity weaponbox", __FUNCTION__); + return FALSE; + } + + for (auto item : pEntityBox->m_rgpPlayerItems) { + if (item) { + return item->m_iId; + } + } + + return WEAPON_NONE; +} + AMX_NATIVE_INFO Misc_Natives_RG[] = { { "rg_set_animation", rg_set_animation }, @@ -1398,6 +1493,7 @@ AMX_NATIVE_INFO Misc_Natives_RG[] = { "rg_create_entity", rg_create_entity }, { "rg_find_ent_by_class", rg_find_ent_by_class }, { "rg_find_ent_by_owner", rg_find_ent_by_owner }, + { "rg_find_item_bpack_by_name", rg_find_item_bpack_by_name }, { "rg_get_weapon_info", rg_get_weapon_info }, { "rg_set_weapon_info", rg_set_weapon_info }, @@ -1430,7 +1526,9 @@ AMX_NATIVE_INFO Misc_Natives_RG[] = { "rg_swap_all_players", rg_swap_all_players }, { "rg_switch_team", rg_switch_team }, { "rg_switch_weapon", rg_switch_weapon }, - { "rg_select_default_team", rg_select_default_team }, + { "rg_get_join_team_priority", rg_get_join_team_priority }, + { "rg_is_player_can_takedamage", rg_is_player_can_takedamage }, + { "rg_get_weaponbox_id", rg_get_weaponbox_id }, { nullptr, nullptr } };