From d9a9ae43e2c0b137ff2e4ec8c0e0ce12f92b359b Mon Sep 17 00:00:00 2001 From: Celio Lozatto Date: Wed, 14 Aug 2024 16:16:46 -0300 Subject: [PATCH 1/5] Implementation of new Natives --- reapi/src/natives/natives_misc.cpp | 128 ++++++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 1 deletion(-) diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 50300b99..604947c4 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -3345,6 +3345,122 @@ cell AMX_NATIVE_CALL rg_send_death_message(AMX *amx, cell *params) return TRUE; } +cell AMX_NATIVE_CALL rg_player_traceattack(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index, arg_attacker, arg_damage, arg_dir, arg_trace, arg_dmg_type }; + + CHECK_ISPLAYER(arg_index); + CHECK_ISENTITY(arg_attacker); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + pPlayer->TraceAttack(args[arg_attacker], args[arg_damage], args[arg_dir], args[arg_trace], args[arg_dmg_type]); + return TRUE; +} + +cell AMX_NATIVE_CALL rg_player_takedamage(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index, arg_inflictor, arg_attacker, arg_damage, arg_dmg_type }; + + CHECK_ISPLAYER(arg_index); + CHECK_ISENTITY(arg_inflictor); + CHECK_ISENTITY(arg_attacker); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + return pPlayer->TakeDamage(args[arg_attacker], args[arg_inflictor], args[arg_damage], args[arg_dmg_type]); +} + +cell AMX_NATIVE_CALL rg_player_takehealth(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index, arg_health, arg_dmg_type }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + return pPlayer->TakeHealth(args[arg_health], args[arg_dmg_type]); +} + +cell AMX_NATIVE_CALL rg_player_killed(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index, arg_attacker, arg_gib }; + + CHECK_ISPLAYER(arg_index); + CHECK_ISENTITY(arg_attacker); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + pPlayer->Killed(args[arg_attacker], args[arg_gib]); + return TRUE; +} + +cell AMX_NATIVE_CALL rg_player_addpoints(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index, arg_score, arg_allow_negative_score }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + pPlayer->AddPoints(args[arg_score], args[arg_allow_negative_score]); + return TRUE; +} + +cell AMX_NATIVE_CALL rg_is_player_alive(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + return pPlayer->IsAlive(); +} + +cell AMX_NATIVE_CALL rg_is_player_net_client(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + return pPlayer->IsNetClient(); +} + +cell AMX_NATIVE_CALL rg_get_player_gun_position(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index, arg_out }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + args[arg_out].vector() = pPlayer->GetGunPosition(); + return TRUE; +} + +cell AMX_NATIVE_CALL rg_is_player_bot(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + return pPlayer->IsBot(); +} + AMX_NATIVE_INFO Misc_Natives_RG[] = { { "rg_set_animation", rg_set_animation }, @@ -3460,6 +3576,16 @@ AMX_NATIVE_INFO Misc_Natives_RG[] = { "rg_send_death_message", rg_send_death_message }, + { "rg_player_traceattack", rg_player_traceattack }, + { "rg_player_takedamage", rg_player_takedamage }, + { "rg_player_takehealth", rg_player_takehealth }, + { "rg_player_killed", rg_player_killed }, + { "rg_player_addpoints", rg_player_addpoints }, + { "rg_is_player_alive", rg_is_player_alive }, + { "rg_is_player_net_client", rg_is_player_net_client }, + { "rg_get_player_gun_position", rg_get_player_gun_position }, + { "rg_is_player_bot", rg_is_player_bot }, + { nullptr, nullptr } }; @@ -3748,4 +3874,4 @@ void RegisterNatives_Misc() g_amxxapi.AddNatives(Misc_Natives_RG); g_amxxapi.AddNatives(Misc_Natives_RH); -} +} \ No newline at end of file From b0ff79ba2a7d423e7849c43ea33f0110552198f3 Mon Sep 17 00:00:00 2001 From: Celio Lozatto Date: Wed, 14 Aug 2024 16:16:46 -0300 Subject: [PATCH 2/5] Implementation of new Natives --- reapi/src/natives/natives_misc.cpp | 134 ++++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 50300b99..aba60b5f 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -3345,6 +3345,128 @@ cell AMX_NATIVE_CALL rg_send_death_message(AMX *amx, cell *params) return TRUE; } +cell AMX_NATIVE_CALL rg_player_traceattack(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index, arg_attacker, arg_damage, arg_dir, arg_trace, arg_dmg_type }; + + CHECK_ISPLAYER(arg_index); + CHECK_ISENTITY(arg_attacker); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + CAmxArgs args(amx, params); + pPlayer->TraceAttack(args[arg_attacker], args[arg_damage], args[arg_dir], args[arg_trace], args[arg_dmg_type]); + return TRUE; +} + +cell AMX_NATIVE_CALL rg_player_takedamage(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index, arg_inflictor, arg_attacker, arg_damage, arg_dmg_type }; + + CHECK_ISPLAYER(arg_index); + CHECK_ISENTITY(arg_inflictor); + CHECK_ISENTITY(arg_attacker); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + CAmxArgs args(amx, params); + return pPlayer->TakeDamage(args[arg_attacker], args[arg_inflictor], args[arg_damage], args[arg_dmg_type]); +} + +cell AMX_NATIVE_CALL rg_player_takehealth(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index, arg_health, arg_dmg_type }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + CAmxArgs args(amx, params); + return pPlayer->TakeHealth(args[arg_health], args[arg_dmg_type]); +} + +cell AMX_NATIVE_CALL rg_player_killed(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index, arg_attacker, arg_gib }; + + CHECK_ISPLAYER(arg_index); + CHECK_ISENTITY(arg_attacker); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + CAmxArgs args(amx, params); + pPlayer->Killed(args[arg_attacker], args[arg_gib]); + return TRUE; +} + +cell AMX_NATIVE_CALL rg_player_addpoints(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index, arg_score, arg_allow_negative_score }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + CAmxArgs args(amx, params); + pPlayer->AddPoints(args[arg_score], args[arg_allow_negative_score]); + return TRUE; +} + +cell AMX_NATIVE_CALL rg_is_player_alive(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + return pPlayer->IsAlive(); +} + +cell AMX_NATIVE_CALL rg_is_player_net_client(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + return pPlayer->IsNetClient(); +} + +cell AMX_NATIVE_CALL rg_get_player_gun_position(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index, arg_out }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + CAmxArgs args(amx, params); + args[arg_out].vector() = pPlayer->GetGunPosition(); + return TRUE; +} + +cell AMX_NATIVE_CALL rg_is_player_bot(AMX* amx, cell* params) +{ + enum args_e { arg_count, arg_index }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer* pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + return pPlayer->IsBot(); +} + AMX_NATIVE_INFO Misc_Natives_RG[] = { { "rg_set_animation", rg_set_animation }, @@ -3460,6 +3582,16 @@ AMX_NATIVE_INFO Misc_Natives_RG[] = { "rg_send_death_message", rg_send_death_message }, + { "rg_player_traceattack", rg_player_traceattack }, + { "rg_player_takedamage", rg_player_takedamage }, + { "rg_player_takehealth", rg_player_takehealth }, + { "rg_player_killed", rg_player_killed }, + { "rg_player_addpoints", rg_player_addpoints }, + { "rg_is_player_alive", rg_is_player_alive }, + { "rg_is_player_net_client", rg_is_player_net_client }, + { "rg_get_player_gun_position", rg_get_player_gun_position }, + { "rg_is_player_bot", rg_is_player_bot }, + { nullptr, nullptr } }; @@ -3748,4 +3880,4 @@ void RegisterNatives_Misc() g_amxxapi.AddNatives(Misc_Natives_RG); g_amxxapi.AddNatives(Misc_Natives_RH); -} +} \ No newline at end of file From a0fbf6875266c6a99497a1cf8c03d617f6a5a662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9lio=20Lozatto=20Baniuk?= Date: Fri, 16 Aug 2024 11:03:55 -0300 Subject: [PATCH 3/5] Delete .vs/reapi/v17/DocumentLayout.json --- .vs/reapi/v17/DocumentLayout.json | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 .vs/reapi/v17/DocumentLayout.json diff --git a/.vs/reapi/v17/DocumentLayout.json b/.vs/reapi/v17/DocumentLayout.json deleted file mode 100644 index 5b3cda22..00000000 --- a/.vs/reapi/v17/DocumentLayout.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "Version": 1, - "WorkspaceRootPath": "E:\\Repos\\reapi\\", - "Documents": [], - "DocumentGroupContainers": [ - { - "Orientation": 0, - "VerticalTabListWidth": 256, - "DocumentGroups": [] - } - ] -} \ No newline at end of file From 9829b022147801290f185d55f505ea8b767e6ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9lio=20Lozatto=20Baniuk?= Date: Fri, 16 Aug 2024 11:04:12 -0300 Subject: [PATCH 4/5] Delete .vs/VSWorkspaceState.json --- .vs/VSWorkspaceState.json | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .vs/VSWorkspaceState.json diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json deleted file mode 100644 index 7994a869..00000000 --- a/.vs/VSWorkspaceState.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "ExpandedNodes": [ - "" - ], - "SelectedNode": "\\reapi.sln", - "PreviewInSolutionExplorer": false -} \ No newline at end of file From 44bb9f8f8610257113f4fc0911aa3fd5d077dbed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9lio=20Lozatto=20Baniuk?= Date: Fri, 16 Aug 2024 11:04:12 -0300 Subject: [PATCH 5/5] Implementation of new Natives --- .vs/VSWorkspaceState.json | 7 ------- reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 .vs/VSWorkspaceState.json diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json deleted file mode 100644 index 7994a869..00000000 --- a/.vs/VSWorkspaceState.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "ExpandedNodes": [ - "" - ], - "SelectedNode": "\\reapi.sln", - "PreviewInSolutionExplorer": false -} \ No newline at end of file diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc index 7c8838b4..981f0f2f 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -1234,7 +1234,7 @@ native rg_send_death_message(const pKiller, const pVictim, const pAssister, cons * * @noreturn */ -native rg_player_traceattack(const index, const attacker, const Float:flDamage, Float:vecDir[3], const ptr, bitsDamageType); +native rg_player_traceattack(const index, const attacker, const Float:flDamage, Float:vecDir[3], const ptr, const bitsDamageType); /* * -