Skip to content

Commit 221242e

Browse files
committed
deathmatch WIP
1 parent 3b7a583 commit 221242e

File tree

14 files changed

+616
-2
lines changed

14 files changed

+616
-2
lines changed

ConsoleCommands.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,17 @@ public void OnMatchCommand(CCSPlayerController? player, CommandInfo? command)
625625

626626
StartMatchMode();
627627
}
628+
[ConsoleCommand("css_deathmatch", "Starts match mode")]
629+
public void OnDeathmatchCommand(CCSPlayerController? player, CommandInfo? command)
630+
{
631+
if (!IsPlayerAdmin(player, "css_match", "@css/map", "@custom/prac"))
632+
{
633+
SendPlayerNotAdminMessage(player);
634+
return;
635+
}
636+
637+
StartDeathmatch();
638+
}
628639

629640
[ConsoleCommand("css_exitprac", "Starts match mode")]
630641
public void OnExitPracCommand(CCSPlayerController? player, CommandInfo? command)

MatchZy.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public partial class MatchZy : BasePlugin
3434
public bool isMatchLive = false;
3535
public long liveMatchId = -1;
3636
public int autoStartMode = 1;
37+
public bool isDeathmatch = false;
3738

3839
public bool mapReloadRequired = false;
3940

@@ -202,7 +203,9 @@ public override void Load(bool hotReload) {
202203
{ ".besttspawn", OnBestTSpawnCommand },
203204
{ ".worsttspawn", OnWorstTSpawnCommand },
204205
{ ".savepos", OnSavePosCommand},
205-
{ ".loadpos", OnLoadPosCommand}
206+
{ ".loadpos", OnLoadPosCommand},
207+
{ ".deathmatch", OnDeathmatchCommand },
208+
{ ".dm", OnDeathmatchCommand },
206209
};
207210

208211
RegisterEventHandler<EventPlayerConnectFull>(EventPlayerConnectFullHandler);

PracticeMode.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ public partial class MatchZy
128128

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

131+
public List<Position> deathmatchSpawns;
132+
131133
public const string practiceCfgPath = "MatchZy/prac.cfg";
132134
public const string dryrunCfgPath = "MatchZy/dryrun.cfg";
133135

@@ -158,6 +160,7 @@ public void StartPracticeMode()
158160
isDryRun = false;
159161
isWarmup = false;
160162
readyAvailable = false;
163+
isDeathmatch = false;
161164

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

@@ -1071,8 +1074,21 @@ private static void ElevatePlayer(CCSPlayerController? player)
10711074
[GameEventHandler]
10721075
public HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
10731076
{
1077+
Random random = new();
1078+
//PrintToAllChat($"spawned");
10741079
var player = @event.Userid;
10751080
if (!IsPlayerValid(player)) return HookResult.Continue;
1081+
//PrintToAllChat($"deathmatch {isDeathmatch} spawned, {player.SteamID}");
1082+
1083+
1084+
//Deathmatch
1085+
if(isDeathmatch){
1086+
player!.InGameMoneyServices!.Account = 14001;
1087+
1088+
List<Position> DMSpawns = deathmatchSpawns;
1089+
Position newSpawn = DMSpawns[random.Next(0, DMSpawns.Count)];
1090+
player!.PlayerPawn.Value!.Teleport(newSpawn.PlayerPosition, newSpawn.PlayerAngle, new Vector(0, 0, 0));
1091+
}
10761092

10771093
// disable noclip on spawn -- all no clipping functionality is handled by the plugin!
10781094
// Movement adjustments are consistent with cs2-noclip.
@@ -1129,7 +1145,7 @@ public HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
11291145
});
11301146
}
11311147
}
1132-
1148+
11331149
return HookResult.Continue;
11341150
}
11351151

Utility.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ private void ResetMatch(bool warmupCfgRequired = true)
394394
isDryRun = false;
395395
isVeto = false;
396396
isPreVeto = false;
397+
isDeathmatch = false;
397398

398399
lastBackupFileName = "";
399400
lastMatchZyBackupFileName = "";
@@ -627,6 +628,10 @@ private void HandleMapChangeCommand(CCSPlayerController? player, string mapName)
627628
return;
628629
}
629630

631+
if(isDeathmatch){
632+
ResetMatch();
633+
}
634+
630635
if (!long.TryParse(mapName, out _) && !mapName.Contains('_'))
631636
{
632637
mapName = "de_" + mapName;
@@ -715,6 +720,7 @@ private void HandleMatchStart()
715720
{
716721
isPractice = false;
717722
isDryRun = false;
723+
isDeathmatch = false;
718724
if (isRoundRestorePending)
719725
{
720726
RestoreRoundBackup(null, pendingRestoreFileName);
@@ -2053,5 +2059,64 @@ public void RandomizeSpawns()
20532059
spawnPosition.Teleport(player);
20542060
}
20552061
}
2062+
2063+
private void StartDeathmatch()
2064+
{
2065+
if (!isWarmup) return;
2066+
ExecUnpracCommands();
2067+
//ExecDeathmatchCommands();
2068+
ResetMatch();
2069+
isDeathmatch = true;
2070+
RemoveSpawnBeams();
2071+
2072+
coachSpawns = GetEmptySpawnsData();
2073+
2074+
2075+
try
2076+
{
2077+
string spawnsConfigPath = Path.Combine(ModuleDirectory, "spawns", "deathmatch", $"{Server.MapName}.json");
2078+
string spawnsConfig = File.ReadAllText(spawnsConfigPath);
2079+
2080+
var jsonDictionary = JsonSerializer.Deserialize<Dictionary<string, List<Dictionary<string, string>>>>(spawnsConfig);
2081+
if (jsonDictionary is null) return;
2082+
foreach (var entry in jsonDictionary)
2083+
{
2084+
Log($"{entry}");
2085+
List<Position> positionList = new();
2086+
2087+
foreach (var positionData in entry.Value)
2088+
{
2089+
Log($"{entry.Value}");
2090+
string[] vectorArray = positionData["pos"].Split(' ');
2091+
2092+
// Parse position and angle
2093+
Vector vector = new(float.Parse(vectorArray[0]), float.Parse(vectorArray[1]), float.Parse(vectorArray[2]));
2094+
QAngle qAngle = new QAngle(0, 0 ,0);
2095+
2096+
Position position = new(vector, qAngle);
2097+
2098+
positionList.Add(position);
2099+
}
2100+
deathmatchSpawns = positionList;
2101+
}
2102+
Log($"[GetDeathmatchSpawns] Loaded {deathmatchSpawns.Count} deathmatch spawns");
2103+
}
2104+
catch (Exception ex)
2105+
{
2106+
Log($"[GetDeathmatchSpawns - FATAL] Error getting deathmatch spawns. [ERROR]: {ex.Message}");
2107+
}
2108+
2109+
const string deathmatchCfgPath = "MatchZy/deathmatch.cfg";
2110+
var absolutePath = Path.Join(Server.GameDirectory + "/csgo/cfg", deathmatchCfgPath);
2111+
2112+
if (File.Exists(absolutePath)) {
2113+
Log($"[ExecDryRunCFG] Starting Dryrun! Executing Dryrun CFG from {deathmatchCfgPath}");
2114+
Server.ExecuteCommand($"exec {deathmatchCfgPath}");
2115+
Server.ExecuteCommand("mp_restartgame 1;mp_warmup_end;");
2116+
}
2117+
Server.PrintToChatAll($"{chatPrefix} Deathmatch mode loaded!");
2118+
2119+
2120+
}
20562121
}
20572122
}

cfg/MatchZy/deathmatch.cfg

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
ammo_grenade_limit_default 1
2+
ammo_grenade_limit_flashbang 2
3+
ammo_grenade_limit_total 4
4+
bot_quota 0
5+
cash_player_bomb_defused 300
6+
cash_player_bomb_planted 300
7+
cash_player_damage_hostage -30
8+
cash_player_interact_with_hostage 300
9+
cash_player_killed_enemy_default 300
10+
cash_player_killed_enemy_factor 1
11+
cash_player_killed_hostage -1000
12+
cash_player_killed_teammate -300
13+
cash_player_rescued_hostage 1000
14+
cash_team_elimination_bomb_map 3250
15+
cash_team_elimination_hostage_map_ct 3000
16+
cash_team_elimination_hostage_map_t 3000
17+
cash_team_hostage_alive 0
18+
cash_team_hostage_interaction 600
19+
cash_team_loser_bonus 1400
20+
cash_team_loser_bonus_consecutive_rounds 500
21+
cash_team_planted_bomb_but_defused 600
22+
cash_team_rescued_hostage 600
23+
cash_team_terrorist_win_bomb 3500
24+
cash_team_win_by_defusing_bomb 3500
25+
cash_team_win_by_hostage_rescue 2900
26+
cash_team_win_by_time_running_out_bomb 3250
27+
cash_team_win_by_time_running_out_hostage 3250
28+
ff_damage_reduction_bullets 0.33
29+
ff_damage_reduction_grenade 0.85
30+
ff_damage_reduction_grenade_self 1
31+
ff_damage_reduction_other 0.4
32+
mp_afterroundmoney 0
33+
mp_autokick 0
34+
mp_autoteambalance 0
35+
mp_backup_restore_load_autopause 1
36+
mp_backup_round_auto 0
37+
mp_buy_anywhere 0
38+
mp_buy_during_immunity 0
39+
mp_buytime 999999
40+
mp_c4timer 40
41+
mp_ct_default_melee weapon_knife
42+
mp_ct_default_primary "weapon_ak47"
43+
mp_ct_default_secondary weapon_hkp2000
44+
mp_ct_default_grenades ""
45+
mp_death_drop_defuser 1
46+
mp_death_drop_grenade 2
47+
mp_death_drop_gun 0
48+
mp_defuser_allocation 0
49+
mp_display_kill_assists 1
50+
mp_endmatch_votenextmap 0
51+
mp_forcecamera 1
52+
mp_free_armor 1
53+
mp_freezetime 6
54+
mp_friendlyfire 1
55+
mp_give_player_c4 1
56+
mp_halftime 1
57+
mp_halftime_duration 15
58+
mp_halftime_pausetimer 0
59+
mp_ignore_round_win_conditions 0
60+
mp_limitteams 0
61+
mp_match_can_clinch 1
62+
mp_match_end_restart 0
63+
mp_maxmoney 16000
64+
mp_maxrounds 24
65+
mp_overtime_enable 1
66+
mp_overtime_halftime_pausetimer 0
67+
mp_overtime_maxrounds 6
68+
mp_overtime_startmoney 16000
69+
mp_playercashawards 1
70+
mp_randomspawn 0
71+
mp_respawn_immunitytime -1
72+
mp_respawn_on_death_ct 0
73+
mp_respawn_on_death_t 0
74+
mp_round_restart_delay 5
75+
mp_roundtime 60
76+
mp_roundtime_defuse 60
77+
mp_roundtime_hostage 1.92
78+
mp_solid_teammates 1
79+
mp_starting_losses 1
80+
mp_startmoney 16000
81+
mp_t_default_melee weapon_knife
82+
mp_t_default_primary "weapon_ak47"
83+
mp_t_default_secondary weapon_glock
84+
mp_t_default_grenades ""
85+
mp_teamcashawards 1
86+
mp_timelimit 0
87+
mp_weapons_allow_map_placed 1
88+
mp_weapons_allow_zeus 1
89+
mp_win_panel_display_time 3
90+
spec_freeze_deathanim_time 0
91+
spec_freeze_time 2
92+
spec_freeze_time_lock 2
93+
spec_replay_enable 0
94+
sv_allow_votes 1
95+
sv_auto_full_alltalk_during_warmup_half_end 0
96+
sv_damage_print_enable 0
97+
sv_deadtalk 1
98+
sv_hibernate_postgame_delay 300
99+
sv_ignoregrenaderadio 0
100+
sv_infinite_ammo 0
101+
sv_talk_enemy_dead 0
102+
sv_talk_enemy_living 0
103+
sv_voiceenable 1
104+
tv_relayvoice 1
105+
mp_team_timeout_max 3
106+
mp_team_timeout_time 30
107+
mp_team_timeout_ot_max 1
108+
mp_team_timeout_ot_add_each 1
109+
sv_vote_command_delay 0
110+
cash_team_bonus_shorthanded 0
111+
mp_spectators_max 20
112+
mp_team_intro_time 0
113+
mp_disconnect_kills_players 0
114+
115+
mp_ct_default_grenades ""
116+
mp_ct_default_primary "weapon_ak47"
117+
mp_t_default_grenades ""
118+
mp_t_default_primary "weapon_ak47"
119+
120+
121+
mp_buytime 999999
122+
mp_buy_allow_grenades 0
123+
mp_respawn_on_death_ct true
124+
mp_respawn_on_death_t true
125+
mp_team_intro_time 0
126+
bot_quota_mode fill
127+
mp_solid_teammates 2
128+
mp_autoteambalance false
129+
mp_teammates_are_enemies true
130+
mp_freezetime 0
131+
132+
buddha 0

spawns/deathmatch/de_ancient.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"spawnpoints": [
3+
{
4+
"pos" : "961.95 -190.61 143.46"},
5+
{"pos" : "-551.00 78.15 149.67"},
6+
{"pos" : "-901.20 -158.74 109.67"},
7+
{"pos" : "-2,089.24 -224.13 92.11"},
8+
{"pos" : "-1,380.00 509.55 93.00"},
9+
{"pos" : "1,148.01 -1,171.71 21.00"},
10+
{"pos" : "-2,043.64 417.93 91.85"},
11+
{"pos" : "216.00 -451.60 202.33"},
12+
{"pos" : "-1,206.00 -53.10 124.33"},
13+
{"pos" : "-968.93 1,387.75 92.50"},
14+
{"pos" : "-519.00 869.24 123.00"},
15+
{"pos" : "-358.25 -1,961.85 -149.00"},
16+
{"pos" : "-1,731.00 -705.10 92.33"},
17+
{"pos" : "-1,789.81 74.67 92.97"},
18+
{"pos" : "-511.68 457.04 179.00"},
19+
{"pos" : "-1,366.54 1,248.27 118.52"},
20+
{"pos" : "-1,122.50 -1,593.60 -12.33"},
21+
{"pos" : "-626.50 -786.60 52.33"},
22+
{"pos" : "-1,704.78 641.55 86.25"},
23+
{"pos" : "464.53 -108.86 171.73"},
24+
{"pos" : "-317.87 1,119.82 79.90"},
25+
{"pos" : "1,006.80 114.60 149.00"},
26+
{"pos" : "593.95 -1,901.06 -152.97"},
27+
{"pos" : "162.50 -830.60 173.00"},
28+
{"pos" : "817.13 796.32 134.40"},
29+
{"pos" : "-1,117.86 956.91 77.52"},
30+
{"pos" : "16.50 742.40 90.33"},
31+
{"pos" : "-390.50 -2,371.61 -143.91"},
32+
{"pos" : "887.53 -786.10 49.12"},
33+
{"pos" : "-534.13 1,500.89 44.33"},
34+
{"pos" : "-559.13 -266.48 76.06"},
35+
{"pos" : "-1,977.50 943.90 73.00"},
36+
{"pos" : "1,311.22 -565.78 48.11"},
37+
{"pos" : "1,353.07 721.40 144.34"},
38+
{"pos" : "-1,529.00 -104.60 124.33"},
39+
{"pos" : "-1,651.92 -1,231.91 -4.25"}
40+
]
41+
}

spawns/deathmatch/de_anubis.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"spawnpoints": [
3+
{"pos" : "762.31 -709.20 8.00"},
4+
{"pos" : "-731.10 -693.08 126.00"},
5+
{"pos" : "218.51 197.00 -170.00"},
6+
{"pos" : "-395.24 -239.80 20.00"},
7+
{"pos" : "1,001.01 201.00 -170.00"},
8+
{"pos" : "526.01 -949.84 25.18"},
9+
{"pos" : "1,683.12 1,614.24 -132.00"},
10+
{"pos" : "299.01 2,290.50 -130.00"},
11+
{"pos" : "-1,299.28 -386.40 126.46"},
12+
{"pos" : "-715.99 833.00 55.33"},
13+
{"pos" : "-749.49 1,534.00 -12.00"},
14+
{"pos" : "-1,468.49 133.50 20.00"},
15+
{"pos" : "16.02 -1,663.24 15.05"},
16+
{"pos" : "-1,067.88 -694.87 84.00"},
17+
{"pos" : "192.51 1,147.50 -12.00"},
18+
{"pos" : "448.00 -1,648.01 17.33"},
19+
{"pos" : "-370.33 1,098.50 79.87"},
20+
{"pos" : "-379.50 -1,608.77 15.29"},
21+
{"pos" : "-1,070.99 -1,126.00 84.00"},
22+
{"pos" : "175.01 801.00 -12.00"},
23+
{"pos" : "1,404.62 869.00 -132.00"},
24+
{"pos" : "-167.56 3,052.37 -159.65"},
25+
{"pos" : "-147.49 2,587.00 -76.00"},
26+
{"pos" : "969.98 2,221.00 -22.00"},
27+
{"pos" : "-1,874.53 205.61 78.00"},
28+
{"pos" : "-1,239.91 1,398.72 -12.00"},
29+
{"pos" : "669.13 201.58 -170.00"},
30+
{"pos" : "1,366.51 207.00 20.00"},
31+
{"pos" : "-406.67 246.60 -101.32"},
32+
{"pos" : "371.82 -649.94 15.02"},
33+
{"pos" : "-89.90 48.15 20.00"},
34+
{"pos" : "1,210.51 2,059.00 -174.00"},
35+
{"pos" : "834.79 -250.95 -44.44"},
36+
{"pos" : "800.94 1,364.05 -68.00"},
37+
{"pos" : "-524.90 2,976.77 -156.29"},
38+
{"pos" : "204.01 3,051.00 -167.33"},
39+
{"pos" : "-722.41 -1,462.06 22.66"},
40+
{"pos" : "-1,460.99 468.00 20.00"},
41+
{"pos" : "-1,249.49 985.50 20.00"}
42+
]
43+
}

0 commit comments

Comments
 (0)