Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ConsoleCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,17 @@ public void OnMatchCommand(CCSPlayerController? player, CommandInfo? command)

StartMatchMode();
}
[ConsoleCommand("css_deathmatch", "Starts match mode")]
public void OnDeathmatchCommand(CCSPlayerController? player, CommandInfo? command)
{
if (!IsPlayerAdmin(player, "css_match", "@css/map", "@custom/prac"))
{
SendPlayerNotAdminMessage(player);
return;
}

StartDeathmatch();
}

[ConsoleCommand("css_exitprac", "Starts match mode")]
public void OnExitPracCommand(CCSPlayerController? player, CommandInfo? command)
Expand Down
5 changes: 4 additions & 1 deletion MatchZy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public partial class MatchZy : BasePlugin
public bool isMatchLive = false;
public long liveMatchId = -1;
public int autoStartMode = 1;
public bool isDeathmatch = false;

public bool mapReloadRequired = false;

Expand Down Expand Up @@ -202,7 +203,9 @@ public override void Load(bool hotReload) {
{ ".besttspawn", OnBestTSpawnCommand },
{ ".worsttspawn", OnWorstTSpawnCommand },
{ ".savepos", OnSavePosCommand},
{ ".loadpos", OnLoadPosCommand}
{ ".loadpos", OnLoadPosCommand},
{ ".deathmatch", OnDeathmatchCommand },
{ ".dm", OnDeathmatchCommand },
};

RegisterEventHandler<EventPlayerConnectFull>(EventPlayerConnectFullHandler);
Expand Down
18 changes: 17 additions & 1 deletion PracticeMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public partial class MatchZy

public Dictionary<byte, List<Position>> coachSpawns = GetEmptySpawnsData();

public List<Position> deathmatchSpawns;

public const string practiceCfgPath = "MatchZy/prac.cfg";
public const string dryrunCfgPath = "MatchZy/dryrun.cfg";

Expand Down Expand Up @@ -158,6 +160,7 @@ public void StartPracticeMode()
isDryRun = false;
isWarmup = false;
readyAvailable = false;
isDeathmatch = false;

var absolutePath = Path.Join(Server.GameDirectory + "/csgo/cfg", practiceCfgPath);

Expand Down Expand Up @@ -1071,8 +1074,21 @@ private static void ElevatePlayer(CCSPlayerController? player)
[GameEventHandler]
public HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
{
Random random = new();
//PrintToAllChat($"spawned");
var player = @event.Userid;
if (!IsPlayerValid(player)) return HookResult.Continue;
//PrintToAllChat($"deathmatch {isDeathmatch} spawned, {player.SteamID}");


//Deathmatch
if(isDeathmatch){
player!.InGameMoneyServices!.Account = 14001;

List<Position> DMSpawns = deathmatchSpawns;
Position newSpawn = DMSpawns[random.Next(0, DMSpawns.Count)];
player!.PlayerPawn.Value!.Teleport(newSpawn.PlayerPosition, newSpawn.PlayerAngle, new Vector(0, 0, 0));
}

// disable noclip on spawn -- all no clipping functionality is handled by the plugin!
// Movement adjustments are consistent with cs2-noclip.
Expand Down Expand Up @@ -1129,7 +1145,7 @@ public HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
});
}
}

return HookResult.Continue;
}

Expand Down
65 changes: 65 additions & 0 deletions Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ private void ResetMatch(bool warmupCfgRequired = true)
isDryRun = false;
isVeto = false;
isPreVeto = false;
isDeathmatch = false;

lastBackupFileName = "";
lastMatchZyBackupFileName = "";
Expand Down Expand Up @@ -627,6 +628,10 @@ private void HandleMapChangeCommand(CCSPlayerController? player, string mapName)
return;
}

if(isDeathmatch){
ResetMatch();
}

if (!long.TryParse(mapName, out _) && !mapName.Contains('_'))
{
mapName = "de_" + mapName;
Expand Down Expand Up @@ -715,6 +720,7 @@ private void HandleMatchStart()
{
isPractice = false;
isDryRun = false;
isDeathmatch = false;
if (isRoundRestorePending)
{
RestoreRoundBackup(null, pendingRestoreFileName);
Expand Down Expand Up @@ -2053,5 +2059,64 @@ public void RandomizeSpawns()
spawnPosition.Teleport(player);
}
}

private void StartDeathmatch()
{
if (!isWarmup) return;
ExecUnpracCommands();
//ExecDeathmatchCommands();
ResetMatch();
isDeathmatch = true;
RemoveSpawnBeams();

coachSpawns = GetEmptySpawnsData();


try
{
string spawnsConfigPath = Path.Combine(ModuleDirectory, "spawns", "deathmatch", $"{Server.MapName}.json");
string spawnsConfig = File.ReadAllText(spawnsConfigPath);

var jsonDictionary = JsonSerializer.Deserialize<Dictionary<string, List<Dictionary<string, string>>>>(spawnsConfig);
if (jsonDictionary is null) return;
foreach (var entry in jsonDictionary)
{
Log($"{entry}");
List<Position> positionList = new();

foreach (var positionData in entry.Value)
{
Log($"{entry.Value}");
string[] vectorArray = positionData["pos"].Split(' ');

// Parse position and angle
Vector vector = new(float.Parse(vectorArray[0]), float.Parse(vectorArray[1]), float.Parse(vectorArray[2]));
QAngle qAngle = new QAngle(0, 0 ,0);

Position position = new(vector, qAngle);

positionList.Add(position);
}
deathmatchSpawns = positionList;
}
Log($"[GetDeathmatchSpawns] Loaded {deathmatchSpawns.Count} deathmatch spawns");
}
catch (Exception ex)
{
Log($"[GetDeathmatchSpawns - FATAL] Error getting deathmatch spawns. [ERROR]: {ex.Message}");
}

const string deathmatchCfgPath = "MatchZy/deathmatch.cfg";
var absolutePath = Path.Join(Server.GameDirectory + "/csgo/cfg", deathmatchCfgPath);

if (File.Exists(absolutePath)) {
Log($"[ExecDryRunCFG] Starting Dryrun! Executing Dryrun CFG from {deathmatchCfgPath}");
Server.ExecuteCommand($"exec {deathmatchCfgPath}");
Server.ExecuteCommand("mp_restartgame 1;mp_warmup_end;");
}
Server.PrintToChatAll($"{chatPrefix} Deathmatch mode loaded!");


}
}
}
132 changes: 132 additions & 0 deletions cfg/MatchZy/deathmatch.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
ammo_grenade_limit_default 1
ammo_grenade_limit_flashbang 2
ammo_grenade_limit_total 4
bot_quota 0
cash_player_bomb_defused 300
cash_player_bomb_planted 300
cash_player_damage_hostage -30
cash_player_interact_with_hostage 300
cash_player_killed_enemy_default 300
cash_player_killed_enemy_factor 1
cash_player_killed_hostage -1000
cash_player_killed_teammate -300
cash_player_rescued_hostage 1000
cash_team_elimination_bomb_map 3250
cash_team_elimination_hostage_map_ct 3000
cash_team_elimination_hostage_map_t 3000
cash_team_hostage_alive 0
cash_team_hostage_interaction 600
cash_team_loser_bonus 1400
cash_team_loser_bonus_consecutive_rounds 500
cash_team_planted_bomb_but_defused 600
cash_team_rescued_hostage 600
cash_team_terrorist_win_bomb 3500
cash_team_win_by_defusing_bomb 3500
cash_team_win_by_hostage_rescue 2900
cash_team_win_by_time_running_out_bomb 3250
cash_team_win_by_time_running_out_hostage 3250
ff_damage_reduction_bullets 0.33
ff_damage_reduction_grenade 0.85
ff_damage_reduction_grenade_self 1
ff_damage_reduction_other 0.4
mp_afterroundmoney 0
mp_autokick 0
mp_autoteambalance 0
mp_backup_restore_load_autopause 1
mp_backup_round_auto 0
mp_buy_anywhere 0
mp_buy_during_immunity 0
mp_buytime 999999
mp_c4timer 40
mp_ct_default_melee weapon_knife
mp_ct_default_primary "weapon_ak47"
mp_ct_default_secondary weapon_hkp2000
mp_ct_default_grenades ""
mp_death_drop_defuser 1
mp_death_drop_grenade 2
mp_death_drop_gun 0
mp_defuser_allocation 0
mp_display_kill_assists 1
mp_endmatch_votenextmap 0
mp_forcecamera 1
mp_free_armor 1
mp_freezetime 6
mp_friendlyfire 1
mp_give_player_c4 1
mp_halftime 1
mp_halftime_duration 15
mp_halftime_pausetimer 0
mp_ignore_round_win_conditions 0
mp_limitteams 0
mp_match_can_clinch 1
mp_match_end_restart 0
mp_maxmoney 16000
mp_maxrounds 24
mp_overtime_enable 1
mp_overtime_halftime_pausetimer 0
mp_overtime_maxrounds 6
mp_overtime_startmoney 16000
mp_playercashawards 1
mp_randomspawn 0
mp_respawn_immunitytime -1
mp_respawn_on_death_ct 0
mp_respawn_on_death_t 0
mp_round_restart_delay 5
mp_roundtime 60
mp_roundtime_defuse 60
mp_roundtime_hostage 1.92
mp_solid_teammates 1
mp_starting_losses 1
mp_startmoney 16000
mp_t_default_melee weapon_knife
mp_t_default_primary "weapon_ak47"
mp_t_default_secondary weapon_glock
mp_t_default_grenades ""
mp_teamcashawards 1
mp_timelimit 0
mp_weapons_allow_map_placed 1
mp_weapons_allow_zeus 1
mp_win_panel_display_time 3
spec_freeze_deathanim_time 0
spec_freeze_time 2
spec_freeze_time_lock 2
spec_replay_enable 0
sv_allow_votes 1
sv_auto_full_alltalk_during_warmup_half_end 0
sv_damage_print_enable 0
sv_deadtalk 1
sv_hibernate_postgame_delay 300
sv_ignoregrenaderadio 0
sv_infinite_ammo 0
sv_talk_enemy_dead 0
sv_talk_enemy_living 0
sv_voiceenable 1
tv_relayvoice 1
mp_team_timeout_max 3
mp_team_timeout_time 30
mp_team_timeout_ot_max 1
mp_team_timeout_ot_add_each 1
sv_vote_command_delay 0
cash_team_bonus_shorthanded 0
mp_spectators_max 20
mp_team_intro_time 0
mp_disconnect_kills_players 0

mp_ct_default_grenades ""
mp_ct_default_primary "weapon_ak47"
mp_t_default_grenades ""
mp_t_default_primary "weapon_ak47"


mp_buytime 999999
mp_buy_allow_grenades 0
mp_respawn_on_death_ct true
mp_respawn_on_death_t true
mp_team_intro_time 0
bot_quota_mode fill
mp_solid_teammates 2
mp_autoteambalance false
mp_teammates_are_enemies true
mp_freezetime 0

buddha 0
41 changes: 41 additions & 0 deletions spawns/deathmatch/de_ancient.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"spawnpoints": [
{
"pos" : "961.95 -190.61 143.46"},
{"pos" : "-551.00 78.15 149.67"},
{"pos" : "-901.20 -158.74 109.67"},
{"pos" : "-2,089.24 -224.13 92.11"},
{"pos" : "-1,380.00 509.55 93.00"},
{"pos" : "1,148.01 -1,171.71 21.00"},
{"pos" : "-2,043.64 417.93 91.85"},
{"pos" : "216.00 -451.60 202.33"},
{"pos" : "-1,206.00 -53.10 124.33"},
{"pos" : "-968.93 1,387.75 92.50"},
{"pos" : "-519.00 869.24 123.00"},
{"pos" : "-358.25 -1,961.85 -149.00"},
{"pos" : "-1,731.00 -705.10 92.33"},
{"pos" : "-1,789.81 74.67 92.97"},
{"pos" : "-511.68 457.04 179.00"},
{"pos" : "-1,366.54 1,248.27 118.52"},
{"pos" : "-1,122.50 -1,593.60 -12.33"},
{"pos" : "-626.50 -786.60 52.33"},
{"pos" : "-1,704.78 641.55 86.25"},
{"pos" : "464.53 -108.86 171.73"},
{"pos" : "-317.87 1,119.82 79.90"},
{"pos" : "1,006.80 114.60 149.00"},
{"pos" : "593.95 -1,901.06 -152.97"},
{"pos" : "162.50 -830.60 173.00"},
{"pos" : "817.13 796.32 134.40"},
{"pos" : "-1,117.86 956.91 77.52"},
{"pos" : "16.50 742.40 90.33"},
{"pos" : "-390.50 -2,371.61 -143.91"},
{"pos" : "887.53 -786.10 49.12"},
{"pos" : "-534.13 1,500.89 44.33"},
{"pos" : "-559.13 -266.48 76.06"},
{"pos" : "-1,977.50 943.90 73.00"},
{"pos" : "1,311.22 -565.78 48.11"},
{"pos" : "1,353.07 721.40 144.34"},
{"pos" : "-1,529.00 -104.60 124.33"},
{"pos" : "-1,651.92 -1,231.91 -4.25"}
]
}
43 changes: 43 additions & 0 deletions spawns/deathmatch/de_anubis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"spawnpoints": [
{"pos" : "762.31 -709.20 8.00"},
{"pos" : "-731.10 -693.08 126.00"},
{"pos" : "218.51 197.00 -170.00"},
{"pos" : "-395.24 -239.80 20.00"},
{"pos" : "1,001.01 201.00 -170.00"},
{"pos" : "526.01 -949.84 25.18"},
{"pos" : "1,683.12 1,614.24 -132.00"},
{"pos" : "299.01 2,290.50 -130.00"},
{"pos" : "-1,299.28 -386.40 126.46"},
{"pos" : "-715.99 833.00 55.33"},
{"pos" : "-749.49 1,534.00 -12.00"},
{"pos" : "-1,468.49 133.50 20.00"},
{"pos" : "16.02 -1,663.24 15.05"},
{"pos" : "-1,067.88 -694.87 84.00"},
{"pos" : "192.51 1,147.50 -12.00"},
{"pos" : "448.00 -1,648.01 17.33"},
{"pos" : "-370.33 1,098.50 79.87"},
{"pos" : "-379.50 -1,608.77 15.29"},
{"pos" : "-1,070.99 -1,126.00 84.00"},
{"pos" : "175.01 801.00 -12.00"},
{"pos" : "1,404.62 869.00 -132.00"},
{"pos" : "-167.56 3,052.37 -159.65"},
{"pos" : "-147.49 2,587.00 -76.00"},
{"pos" : "969.98 2,221.00 -22.00"},
{"pos" : "-1,874.53 205.61 78.00"},
{"pos" : "-1,239.91 1,398.72 -12.00"},
{"pos" : "669.13 201.58 -170.00"},
{"pos" : "1,366.51 207.00 20.00"},
{"pos" : "-406.67 246.60 -101.32"},
{"pos" : "371.82 -649.94 15.02"},
{"pos" : "-89.90 48.15 20.00"},
{"pos" : "1,210.51 2,059.00 -174.00"},
{"pos" : "834.79 -250.95 -44.44"},
{"pos" : "800.94 1,364.05 -68.00"},
{"pos" : "-524.90 2,976.77 -156.29"},
{"pos" : "204.01 3,051.00 -167.33"},
{"pos" : "-722.41 -1,462.06 22.66"},
{"pos" : "-1,460.99 468.00 20.00"},
{"pos" : "-1,249.49 985.50 20.00"}
]
}
Loading