Skip to content

Commit

Permalink
feat: add AMX Mod X 'advancedmachinegundeployer' plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanlinat committed Apr 22, 2024
1 parent 157e2e9 commit 8429151
Show file tree
Hide file tree
Showing 27 changed files with 178 additions and 9 deletions.
6 changes: 4 additions & 2 deletions dodserver/serverfiles/dod/addons/amxmodx/configs/plugins.ini
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ statssounds.amxx ; precache plugin for stats plugins
statslogging.amxx ; weapons stats logging (DoD Module required!)

; Custom - Add 3rd party plugins here
jl_advancedmachinegundeployer.amxx ; enhances the deployment mechanism for machine guns in-game
jl_awayfromkeyboardkicker.amxx ; monitors player activity to identify and manage players who are Away From Keyboard (AFK) for an extended period, ensuring active participation and fairness in gameplay
jl_deatheffectenhancer.amxx ; significantly enriches the visual and gameplay experience upon a player's death in-game
jl_instantspawner.amxx ; completely removes the spawn delay when players die
;jl_nextmapselectionrandomizer.amxx ; automates the process of map selection, randomizing the next map from those listed in mapcycle.txt, ensuring a varied and unpredictable map rotation
jl_parachuteprovider.amxx ; provides a parachute to players when they are falling from a height, allowing for a slow and safe descent
jl_playerhealer.amxx ; enables players to gradually recover health points over time
jl_scoreboardhotnameslider.amxx ; updates the server's hostname on the scoreboard to create a sliding text effect
jl_staminaunlimiter.amxx ; eliminates stamina limitations for players
jl_svcbadpreventer.amxx ; aims to prevent the SVC_BAD error from causing players to be kicked out of the server
jl_weaponsregistrationenhancer.amxx ; optimizes hit detection for various weapons in the game, ensuring more reliable and consistent registration of hits

;jl_nextmapselectionrandomizer.amxx ; automates the process of map selection, randomizing the next map from those listed in mapcycle.txt, ensuring a varied and unpredictable map rotation
;jl_staminaunlimiter.amxx ; eliminates stamina limitations for players
Binary file modified dodserver/serverfiles/dod/addons/amxmodx/plugins/adminchat.amxx
Binary file not shown.
Binary file modified dodserver/serverfiles/dod/addons/amxmodx/plugins/adminhelp.amxx
Binary file not shown.
Binary file modified dodserver/serverfiles/dod/addons/amxmodx/plugins/adminslots.amxx
Binary file not shown.
Binary file modified dodserver/serverfiles/dod/addons/amxmodx/plugins/antiflood.amxx
Binary file not shown.
Binary file modified dodserver/serverfiles/dod/addons/amxmodx/plugins/dodstats.amxx
Binary file not shown.
Binary file modified dodserver/serverfiles/dod/addons/amxmodx/plugins/imessage.amxx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified dodserver/serverfiles/dod/addons/amxmodx/plugins/nextmap.amxx
Binary file not shown.
Binary file modified dodserver/serverfiles/dod/addons/amxmodx/plugins/pausecfg.amxx
Binary file not shown.
Binary file modified dodserver/serverfiles/dod/addons/amxmodx/plugins/scrollmsg.amxx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified dodserver/serverfiles/dod/addons/amxmodx/plugins/timeleft.amxx
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#define PLUGIN "Advanced Machine Gun Deployer"
#define VERSION "1.0.0"
#define AUTHOR "Jonathan Linat"
#define URL "https://github.com/jonathanlinat"

/*
* This plugin enhances the deployment mechanism for machine guns in-game.
*
* It has been successfully tested with AMX Mod X v1.10+.
*/

#include <amxmodx>
#include <amxmisc>
#include <dodx>
#include <fakemeta>

#pragma semicolon 1

#define TRACE_DIST_A 250.0
#define TRACE_DIST_B 30.0
#define TRACE_V_OFFSET 20.0
#define SANDBAG_RANGE 25.0

new Float:g_fBelowLines[3] = { -5.0, -10.0, -15.0 };
new Float:g_ViewOfs[33];

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR, URL);

register_forward(FM_PlayerPreThink, "hook_player_prethink");
register_forward(FM_UpdateClientData, "hook_update_client_data_post", 1);
}

public hook_player_prethink(id) {
if (!is_user_alive(id) || is_user_bot(id)) {
return PLUGIN_CONTINUE;
}

if (dod_get_deploystate(id) < 2 && !touching_sandbag(id)) {
dod_set_deploystate(id, get_deploy_ability(id));
}

return PLUGIN_CONTINUE;
}

public get_deploy_ability(id) {
if (dod_get_pronestate(id) || pev(id, pev_button) & IN_DUCK || !deployable_weapon(id)) {
return 0;
}

new bClear_Above = clear_path(id, TRACE_DIST_A, TRACE_V_OFFSET);

if (bClear_Above && support_below(id, TRACE_DIST_B)) {
return 1;
}

g_ViewOfs[id] = 0.0;

return 0;
}

public hook_update_client_data_post(id, sendweapons, cd_handle) {
if (is_user_bot(id)) {
return PLUGIN_CONTINUE;
}

if (g_ViewOfs[id] != 0.0 && dod_get_deploystate(id) == 2) {
new Float:fNewView[3];
get_view_ofs(id, fNewView);
set_cd(cd_handle, CD_ViewOfs, fNewView);
} else if (g_ViewOfs[id] != 0.0 && dod_get_deploystate(id) == 0) {
g_ViewOfs[id] = 0.0;
}

return PLUGIN_CONTINUE;
}

stock clear_path(id, Float:fDist, Float:fZOffset) {
new Float:fStartOrigin[3], Float:fAngle[3], Float:fSize[3];
pev(id, pev_origin, fStartOrigin);
pev(id, pev_v_angle, fAngle);
pev(id, pev_size, fSize);

fStartOrigin[2] += fZOffset;

new Float:fEndOrigin[3];
fEndOrigin[0] = fStartOrigin[0] + floatcos(fAngle[1], degrees) * (fDist + fSize[0]);
fEndOrigin[1] = fStartOrigin[1] + floatsin(fAngle[1], degrees) * (fDist + fSize[1]);
fEndOrigin[2] = (fStartOrigin[2] - floatsin(fAngle[0], degrees) * (fDist + fSize[2])) + 5;

new Float:fStop[3];
fm_trace_line(id, fStartOrigin, fEndOrigin, fStop);

return vectors_equal(fEndOrigin, fStop);
}

stock support_below(id, Float:fZOffset) {
for (new i; i < sizeof g_fBelowLines; i++) {
if (!clear_path(id, fZOffset, g_fBelowLines[i])) {
g_ViewOfs[id] = g_fBelowLines[i];

return 1;
}
}

return 0;
}

stock get_view_ofs(id, Float:fNewView[3]) {
fNewView[2] = 22.0 + g_ViewOfs[id];
}

stock vectors_equal(Float:vec_a[3], Float:vec_b[3]) {
if (vec_a[0] == vec_b[0] && vec_a[1] == vec_b[1] && vec_a[2] == vec_b[2]) {
return 1;
}

return 0;
}

stock touching_sandbag(id) {
new m_curEnt = -1, m_flOrigin[3];
pev(id, pev_origin, m_flOrigin);

while((m_curEnt = engfunc(EngFunc_FindEntityInSphere, m_curEnt, m_flOrigin, SANDBAG_RANGE)) != 0) {
new m_szClassname[32];
pev(m_curEnt, pev_classname, m_szClassname, 31);

if (equal(m_szClassname, "dod_trigger_sandbag")) {
return m_curEnt;
}
}

return 0;
}

stock deployable_weapon(id) {
new clip, ammo, wpn = get_user_weapon(id, clip, ammo);

if (wpn == DODW_30_CAL || wpn == DODW_MG34 || wpn == DODW_MG42 || wpn == DODW_BAR || wpn == DODW_FG42 || wpn == DODW_BREN) {
return 1;
}

return 0;
}

stock fm_trace_line(ignoreent, const Float:start[3], const Float:end[3], Float:ret[3]) {
engfunc(EngFunc_TraceLine, start, end, ignoreent == -1 ? 1 : 0, ignoreent, 0);

new ent = get_tr2(0, TR_pHit);
get_tr2(0, TR_vecEndPos, ret);

return pev_valid(ent) ? ent : 0;
}

stock dod_set_deploystate(id, flag) {
new Float:m_vector[3];
m_vector[0] = float(flag);
set_pev(id, pev_vuser1, m_vector);
}

stock dod_get_deploystate(id) {
new Float:m_vector[3];
pev(id, pev_vuser1, m_vector);

return floatround(m_vector[0]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ new g_oldangles[33][3];
new g_afktime[33];
new g_maxafktime;
new g_minplayers;
new bool:g_spawned[33] = {true, ...};
new bool:g_spawned[33] = { true, ... };

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR, URL);

g_maxafktime = register_cvar("amx_awayfromkeyboardkicker_maxtime", "90");
g_minplayers = register_cvar("amx_awayfromkeyboardkicker_minplayers", "16");

set_task(float(CHECK_FREQ), "checkPlayers", _, _, _, "b");
register_event("ResetHUD", "playerSpawned", "be");
set_task(float(CHECK_FREQ), "check_players", _, _, _, "b");
register_event("ResetHUD", "player_spawned", "be");
}

public checkPlayers() {
public check_players() {
for (new i = 1; i <= get_maxplayers(); i++) {
if (is_user_alive(i) && is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i) && g_spawned[i]) {
new newangle[3];
Expand Down Expand Up @@ -92,16 +92,16 @@ public client_putinserver(id) {
return PLUGIN_HANDLED;
}

public playerSpawned(id) {
public player_spawned(id) {
g_spawned[id] = false;
new sid[1];
sid[0] = id;
set_task(0.75, "delayedSpawn", _, sid, 1);
set_task(0.75, "delayed_spawn", _, sid, 1);

return PLUGIN_HANDLED;
}

public delayedSpawn(sid[]) {
public delayed_spawn(sid[]) {
get_user_origin(sid[0], g_oldangles[sid[0]]);
g_spawned[sid[0]] = true;

Expand Down

0 comments on commit 8429151

Please sign in to comment.