Skip to content

Commit e5c3418

Browse files
authored
Merge branch 'dev' into readme-patch
2 parents 4584d08 + 01ce3f9 commit e5c3418

29 files changed

+1949
-124
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ko_fi: cs2surf

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
*.vs
2-
*.vscode
2+
*.vscode/*
3+
!.vscode/tasks.json
34
*.idea
45
src/bin/Debug/*
6+
src/bin/Release/*
57
src/obj/*
68
src/SurfTimer.csproj

.vscode/tasks.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build-debug",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/src/SurfTimer.csproj",
11+
"/property:Configuration=Debug"
12+
],
13+
"problemMatcher": "$msCompile"
14+
},
15+
{
16+
"label": "build-release",
17+
"command": "dotnet",
18+
"type": "process",
19+
"args": [
20+
"build",
21+
"${workspaceFolder}/src/SurfTimer.csproj",
22+
"/property:Configuration=Release"
23+
],
24+
"problemMatcher": "$msCompile"
25+
}
26+
]
27+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Bold & Italics = being worked on.
5050
- [ ] Stretch goal: sub-tick timing
5151
- [ ] Player Data
5252
- [X] Base player class
53-
- [ ] Player stat classes
53+
- [ ] **_Player stat classes_**
5454
- [ ] Profile implementation (DB)
5555
- [ ] Points/Skill Groups (DB)
5656
- [ ] Player settings (DB)

cfg/SurfTimer/server_settings.cfg

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ sv_full_alltalk 1
1818

1919
// Movement Settings
2020
sv_airaccelerate 150
21+
// sv_airaccelerate 2000
2122
sv_gravity 800
2223
sv_friction 5.2
2324
sv_maxspeed 350
@@ -26,6 +27,16 @@ sv_enablebunnyhopping 1
2627
sv_autobunnyhopping 1
2728
sv_staminajumpcost 0
2829
sv_staminalandcost 0
30+
sv_timebetweenducks 0
31+
32+
// Some replay bot shit (took so fucking long to debug)
33+
// bot_quota 1 No need for this, because the server handles it
34+
bot_quota_mode "normal"
35+
bot_join_after_player 1
36+
bot_join_team CT
37+
bot_zombie 1
38+
bot_stop 1
39+
bot_freeze 1
2940

3041
// Player Settings
3142
mp_spectators_max 64
@@ -36,8 +47,8 @@ mp_respawn_on_death_ct 1
3647
mp_respawn_on_death_t 1
3748
mp_ct_default_secondary weapon_usp_silencer
3849
mp_t_default_secondary weapon_usp_silencer
39-
mp_autoteambalance 0
4050
mp_limitteams 0
51+
mp_autoteambalance 0
4152
mp_playercashawards 0
4253
mp_teamcashawards 0
4354
mp_death_drop_c4 1
@@ -63,8 +74,7 @@ mp_freezetime 0
6374
mp_team_intro_time 0
6475
mp_warmup_end
6576
mp_warmuptime 0
66-
bot_quota 0
6777
sv_holiday_mode 0
6878
sv_party_mode 0
6979

70-
sv_cheats 0
80+
sv_cheats 0

src/ST-Commands/MapCommands.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ public void MapTier(CCSPlayerController? player, CommandInfo command)
1919
if (player == null)
2020
return;
2121

22-
player.PrintToChat($"{PluginPrefix} {CurrentMap.Name} - {ChatColors.Green}Tier {CurrentMap.Tier}{ChatColors.Default} - {ChatColors.Yellow}{CurrentMap.Stages} Stages{ChatColors.Default}");
22+
if (CurrentMap.Stages > 1)
23+
player.PrintToChat($"{PluginPrefix} {CurrentMap.Name} - {ChatColors.Green}Tier {CurrentMap.Tier}{ChatColors.Default} - Staged {ChatColors.Yellow}{CurrentMap.Stages} Stages{ChatColors.Default}");
24+
else
25+
player.PrintToChat($"{PluginPrefix} {CurrentMap.Name} - {ChatColors.Green}Tier {CurrentMap.Tier}{ChatColors.Default} - Linear {ChatColors.Yellow}{CurrentMap.Checkpoints} Checkpoints{ChatColors.Default}");
2326
return;
2427
}
2528

src/ST-Commands/PlayerCommands.cs

Lines changed: 228 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public void PlayerReset(CCSPlayerController? player, CommandInfo command)
1818

1919
// To-do: players[userid].Timer.Reset() -> teleport player
2020
playerList[player.UserId ?? 0].Timer.Reset();
21-
if (CurrentMap.StartZone != new Vector(0,0,0))
22-
Server.NextFrame(() => player.PlayerPawn.Value!.Teleport(CurrentMap.StartZone, new QAngle(0,0,0), new Vector(0,0,0)));
21+
if (CurrentMap.StartZone != new Vector(0, 0, 0))
22+
Server.NextFrame(() => player.PlayerPawn.Value!.Teleport(CurrentMap.StartZone, new QAngle(0, 0, 0), new Vector(0, 0, 0)));
2323
return;
2424
}
2525

@@ -32,10 +32,10 @@ public void PlayerResetStage(CCSPlayerController? player, CommandInfo command)
3232

3333
// To-do: players[userid].Timer.Reset() -> teleport player
3434
Player SurfPlayer = playerList[player.UserId ?? 0];
35-
if (SurfPlayer.Timer.Stage != 0 && CurrentMap.StageStartZone[SurfPlayer.Timer.Stage] != new Vector(0,0,0))
36-
Server.NextFrame(() => player.PlayerPawn.Value!.Teleport(CurrentMap.StageStartZone[SurfPlayer.Timer.Stage], CurrentMap.StageStartZoneAngles[SurfPlayer.Timer.Stage], new Vector(0,0,0)));
35+
if (SurfPlayer.Timer.Stage != 0 && CurrentMap.StageStartZone[SurfPlayer.Timer.Stage] != new Vector(0, 0, 0))
36+
Server.NextFrame(() => player.PlayerPawn.Value!.Teleport(CurrentMap.StageStartZone[SurfPlayer.Timer.Stage], CurrentMap.StageStartZoneAngles[SurfPlayer.Timer.Stage], new Vector(0, 0, 0)));
3737
else // Reset back to map start
38-
Server.NextFrame(() => player.PlayerPawn.Value!.Teleport(CurrentMap.StartZone, new QAngle(0,0,0), new Vector(0,0,0)));
38+
Server.NextFrame(() => player.PlayerPawn.Value!.Teleport(CurrentMap.StartZone, new QAngle(0, 0, 0), new Vector(0, 0, 0)));
3939
return;
4040
}
4141

@@ -47,7 +47,7 @@ public void PlayerGoToStage(CCSPlayerController? player, CommandInfo command)
4747
return;
4848

4949
int stage = Int32.Parse(command.ArgByIndex(1)) - 1;
50-
if (stage > CurrentMap.Stages - 1)
50+
if (stage > CurrentMap.Stages - 1 && CurrentMap.Stages > 0)
5151
stage = CurrentMap.Stages - 1;
5252

5353
// Must be 1 argument
@@ -60,28 +60,243 @@ public void PlayerGoToStage(CCSPlayerController? player, CommandInfo command)
6060
player.PrintToChat($"{PluginPrefix} {ChatColors.Red}Invalid arguments. Usage: {ChatColors.Green}!s <stage>");
6161
return;
6262
}
63-
6463
else if (CurrentMap.Stages <= 0)
6564
{
6665
player.PrintToChat($"{PluginPrefix} {ChatColors.Red}This map has no stages.");
6766
return;
6867
}
6968

70-
if (CurrentMap.StageStartZone[stage] != new Vector(0,0,0))
69+
if (CurrentMap.StageStartZone[stage] != new Vector(0, 0, 0))
7170
{
7271
if (stage == 0)
73-
Server.NextFrame(() => player.PlayerPawn.Value!.Teleport(CurrentMap.StartZone, CurrentMap.StartZoneAngles, new Vector(0,0,0)));
72+
Server.NextFrame(() => player.PlayerPawn.Value!.Teleport(CurrentMap.StartZone, CurrentMap.StartZoneAngles, new Vector(0, 0, 0)));
7473
else
75-
Server.NextFrame(() => player.PlayerPawn.Value!.Teleport(CurrentMap.StageStartZone[stage], CurrentMap.StageStartZoneAngles[stage], new Vector(0,0,0)));
76-
74+
Server.NextFrame(() => player.PlayerPawn.Value!.Teleport(CurrentMap.StageStartZone[stage], CurrentMap.StageStartZoneAngles[stage], new Vector(0, 0, 0)));
75+
7776
playerList[player.UserId ?? 0].Timer.Reset();
78-
playerList[player.UserId ?? 0].Timer.StageMode = true;
77+
playerList[player.UserId ?? 0].Timer.IsStageMode = true;
7978

8079
// To-do: If you run this while you're in the start zone, endtouch for the start zone runs after you've teleported
8180
// causing the timer to start. This needs to be fixed.
8281
}
8382

84-
else
83+
else
8584
player.PrintToChat($"{PluginPrefix} {ChatColors.Red}Invalid stage provided. Usage: {ChatColors.Green}!s <stage>");
8685
}
86+
87+
[ConsoleCommand("css_spec", "Moves a player automaticlly into spectator mode")]
88+
public void MovePlayerToSpectator(CCSPlayerController? player, CommandInfo command)
89+
{
90+
if (player == null || player.Team == CsTeam.Spectator)
91+
return;
92+
93+
player.ChangeTeam(CsTeam.Spectator);
94+
}
95+
96+
/*
97+
#########################
98+
Reaplay Commands
99+
#########################
100+
*/
101+
[ConsoleCommand("css_replaybotpause", "Pause the replay bot playback")]
102+
[ConsoleCommand("css_rbpause", "Pause the replay bot playback")]
103+
public void PauseReplay(CCSPlayerController? player, CommandInfo command)
104+
{
105+
if(player == null || player.Team != CsTeam.Spectator)
106+
return;
107+
108+
foreach(ReplayPlayer rb in CurrentMap.ReplayBots)
109+
{
110+
if(!rb.IsPlayable || !rb.IsPlaying || !playerList[player.UserId ?? 0].IsSpectating(rb.Controller!))
111+
continue;
112+
113+
rb.Pause();
114+
}
115+
}
116+
117+
[ConsoleCommand("css_replaybotflip", "Flips the replay bot between Forward/Backward playback")]
118+
[ConsoleCommand("css_rbflip", "Flips the replay bot between Forward/Backward playback")]
119+
public void ReverseReplay(CCSPlayerController? player, CommandInfo command)
120+
{
121+
if(player == null || player.Team != CsTeam.Spectator)
122+
return;
123+
124+
foreach(ReplayPlayer rb in CurrentMap.ReplayBots)
125+
{
126+
if(!rb.IsPlayable || !rb.IsPlaying || !playerList[player.UserId ?? 0].IsSpectating(rb.Controller!))
127+
continue;
128+
129+
rb.FrameTickIncrement *= -1;
130+
}
131+
}
132+
133+
[ConsoleCommand("css_pbreplay", "Allows for replay of player's PB")]
134+
public void PbReplay(CCSPlayerController? player, CommandInfo command)
135+
{
136+
if(player == null)
137+
return;
138+
139+
int maptime_id = playerList[player!.UserId ?? 0].Stats.PB[playerList[player.UserId ?? 0].Timer.Style].ID;
140+
if (command.ArgCount > 1)
141+
{
142+
try
143+
{
144+
maptime_id = int.Parse(command.ArgByIndex(1));
145+
}
146+
catch {}
147+
}
148+
149+
if(maptime_id == -1 || !CurrentMap.ConnectedMapTimes.Contains(maptime_id))
150+
{
151+
player.PrintToChat($"{PluginPrefix} {ChatColors.Red}No time was found");
152+
return;
153+
}
154+
155+
for(int i = 0; i < CurrentMap.ReplayBots.Count; i++)
156+
{
157+
if(CurrentMap.ReplayBots[i].Stat_MapTimeID == maptime_id)
158+
{
159+
player.PrintToChat($"{PluginPrefix} {ChatColors.Red}A bot of this run already playing");
160+
return;
161+
}
162+
}
163+
164+
CurrentMap.ReplayBots = CurrentMap.ReplayBots.Prepend(new ReplayPlayer() {
165+
Stat_MapTimeID = maptime_id,
166+
Stat_Prefix = "PB"
167+
}).ToList();
168+
169+
Server.NextFrame(() => {
170+
Server.ExecuteCommand($"bot_quota {CurrentMap.ReplayBots.Count}");
171+
});
172+
}
173+
174+
/*
175+
########################
176+
Saveloc Commands
177+
########################
178+
*/
179+
[ConsoleCommand("css_saveloc", "Save current player location to be practiced")]
180+
public void SavePlayerLocation(CCSPlayerController? player, CommandInfo command)
181+
{
182+
if(player == null || !player.PawnIsAlive || !playerList.ContainsKey(player.UserId ?? 0))
183+
return;
184+
185+
Player p = playerList[player.UserId ?? 0];
186+
if (!p.Timer.IsRunning)
187+
{
188+
p.Controller.PrintToChat($"{PluginPrefix} {ChatColors.Red}Cannot save location while not in run");
189+
return;
190+
}
191+
192+
var player_pos = p.Controller.Pawn.Value!.AbsOrigin!;
193+
var player_angle = p.Controller.PlayerPawn.Value!.EyeAngles;
194+
var player_velocity = p.Controller.PlayerPawn.Value!.AbsVelocity;
195+
196+
p.SavedLocations.Add(new SavelocFrame {
197+
Pos = new Vector(player_pos.X, player_pos.Y, player_pos.Z),
198+
Ang = new QAngle(player_angle.X, player_angle.Y, player_angle.Z),
199+
Vel = new Vector(player_velocity.X, player_velocity.Y, player_velocity.Z),
200+
Tick = p.Timer.Ticks
201+
});
202+
p.CurrentSavedLocation = p.SavedLocations.Count-1;
203+
204+
p.Controller.PrintToChat($"{PluginPrefix} {ChatColors.Green}Saved location! {ChatColors.Default} use !tele {p.SavedLocations.Count-1} to teleport to this location");
205+
}
206+
207+
[ConsoleCommand("css_tele", "Teleport player to current saved location")]
208+
public void TeleportPlayerLocation(CCSPlayerController? player, CommandInfo command)
209+
{
210+
if(player == null || !player.PawnIsAlive || !playerList.ContainsKey(player.UserId ?? 0))
211+
return;
212+
213+
Player p = playerList[player.UserId ?? 0];
214+
215+
if(p.SavedLocations.Count == 0)
216+
{
217+
p.Controller.PrintToChat($"{PluginPrefix} {ChatColors.Red}No saved locations");
218+
return;
219+
}
220+
221+
if(!p.Timer.IsRunning)
222+
p.Timer.Start();
223+
224+
if (!p.Timer.IsPracticeMode)
225+
{
226+
p.Controller.PrintToChat($"{PluginPrefix} {ChatColors.Red}Timer now on practice");
227+
p.Timer.IsPracticeMode = true;
228+
}
229+
230+
if(command.ArgCount > 1)
231+
try
232+
{
233+
int tele_n = int.Parse(command.ArgByIndex(1));
234+
if (tele_n < p.SavedLocations.Count)
235+
p.CurrentSavedLocation = tele_n;
236+
}
237+
catch { }
238+
SavelocFrame location = p.SavedLocations[p.CurrentSavedLocation];
239+
Server.NextFrame(() => {
240+
p.Controller.PlayerPawn.Value!.Teleport(location.Pos, location.Ang, location.Vel);
241+
p.Timer.Ticks = location.Tick;
242+
});
243+
244+
p.Controller.PrintToChat($"{PluginPrefix} Teleported #{p.CurrentSavedLocation}");
245+
}
246+
247+
[ConsoleCommand("css_teleprev", "Teleport player to previous saved location")]
248+
public void TeleportPlayerLocationPrev(CCSPlayerController? player, CommandInfo command)
249+
{
250+
if(player == null || !player.PawnIsAlive || !playerList.ContainsKey(player.UserId ?? 0))
251+
return;
252+
253+
Player p = playerList[player.UserId ?? 0];
254+
255+
if(p.SavedLocations.Count == 0)
256+
{
257+
p.Controller.PrintToChat($"{PluginPrefix} {ChatColors.Red}No saved locations");
258+
return;
259+
}
260+
261+
if(p.CurrentSavedLocation == 0)
262+
{
263+
p.Controller.PrintToChat($"{PluginPrefix} {ChatColors.Red}Already at first location");
264+
}
265+
else
266+
{
267+
p.CurrentSavedLocation--;
268+
}
269+
270+
TeleportPlayerLocation(player, command);
271+
272+
p.Controller.PrintToChat($"{PluginPrefix} Teleported #{p.CurrentSavedLocation}");
273+
}
274+
275+
[ConsoleCommand("css_telenext", "Teleport player to next saved location")]
276+
public void TeleportPlayerLocationNext(CCSPlayerController? player, CommandInfo command)
277+
{
278+
if(player == null || !player.PawnIsAlive || !playerList.ContainsKey(player.UserId ?? 0))
279+
return;
280+
281+
Player p = playerList[player.UserId ?? 0];
282+
283+
if(p.SavedLocations.Count == 0)
284+
{
285+
p.Controller.PrintToChat($"{PluginPrefix} {ChatColors.Red}No saved locations");
286+
return;
287+
}
288+
289+
if(p.CurrentSavedLocation == p.SavedLocations.Count-1)
290+
{
291+
p.Controller.PrintToChat($"{PluginPrefix} {ChatColors.Red}Already at last location");
292+
}
293+
else
294+
{
295+
p.CurrentSavedLocation++;
296+
}
297+
298+
TeleportPlayerLocation(player, command);
299+
300+
p.Controller.PrintToChat($"{PluginPrefix} Teleported #{p.CurrentSavedLocation}");
301+
}
87302
}

0 commit comments

Comments
 (0)