Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
Dev (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS authored Jan 23, 2024
1 parent a72ea93 commit 0d58bb8
Show file tree
Hide file tree
Showing 14 changed files with 450 additions and 124 deletions.
9 changes: 9 additions & 0 deletions gamedata/Cs2Jailbreak.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"CBasePlayerController_SetPawn": {
"signatures": {
"library": "server",
"windows": "\\x44\\x88\\x4C\\x24\\x2A\\x55\\x57",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x41\\x54\\x49\\x89\\xFC\\x53\\x48\\x89\\xF3\\x48\\x81\\xEC\\xC8\\x00\\x00\\x00"
}
}
}
51 changes: 50 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"warden.laser_colour_command_desc": "!laser_colour - set laser colour",
"warden.marker_colour_command_desc": "!laser_colour - set marker colour",
"warden.swap_guard_desc": "Expected usage: !swap_guard <player name>",
"warden.wsd_command_desc": "!wsd - Call a warden special day",
"warden.wsd_ff_command_desc": "!wsd - Call a warden friendly fire special day",
"warden.warden_req_alive": "You must be alive to warden",
"warden.warden_req_ct": "You must be a CT to warden",
"warden.warden_taken": "{0} is already the warden",
Expand All @@ -25,6 +27,44 @@
"warden.gun_menu_disabled": "Gun menu is disabled!",
"warden.no_warden": "Their is no warden",
"warden.time": "Warden has been active for {0} minutes",
"warden.fire_guard" : "Firing guards",

"warden.take_warden_cmd": "w",
"warden.leave_warden_cmd": "uw",
"warden.remove_warden_cmd": "rw",
"warden.fire_guard_cmd": "fire_guard",
"warden.remove_marker_cmd": "remove_marker",
"warden.marker_colour_cmd": "marker_colour",
"warden.laser_colour_cmd": "laser_colour",
"warden.gun_cmd": "guns",
"warden.time_cmd": "wtime",
"warden.list_cmd": "wcommands",
"warden.warday_cmd": "wd",
"warden.swap_guard_cmd": "swap_guard",
"warden.no_block_cmd": "wub",
"warden.block_cmd": "wb",
"warden.force_open_cmd": "force_open",
"warden.force_close_cmd": "force_close",
"warden.sd_cmd": "wsd",
"warden.sd_ff_cmd": "wsd_ff",

"logs.ct": "CT",
"logs.t": "T",
"logs.logs_cmd": "logs",

"role.warden": "Warden",
"role.guard": "Guard",
"role.prisoner": "Prisoner",
"role.rebel": "Rebel",
"role.spectator": "Spectator",
"role.unknown": "Unknown",

"logs.format.damage": "{0} ({1}) damaged {2} ({3}) for {4} damage",
"logs.format.damage_self": "The world damaged {0} ({1}) for {2} damage",
"logs.format.kill": "{0} ({1}) killed {2} ({3})",
"logs.format.kill_self": "The world killed {0} ({1})",
"logs.format.button": "{0} ({1}) pressed button {2}->{3}",
"logs.format.grenade": "{0} ({1}) threw a {2}",

"mute.thirty": "All t's are muted for the first 30 seconds",
"mute.speak_quietly": "T's may now speak quietly",
Expand Down Expand Up @@ -65,6 +105,11 @@
"sd.tank_start": "Tank day started",
"sd.tank_end": "Tank day ended",
"sd.tank": "{0} is the tank!",

"sd.start_cmd": "sd",
"sd.start_ff_cmd": "sd_ff",
"sd.cancel_cmd": "sd_cancel",


"lr.rebel_last": "You must be the last player alive to rebel",
"lr.riot_start": "A riot has started! CT's have 15 seconds to hide",
Expand All @@ -78,5 +123,9 @@
"lr.player_rebel": "{0} is a rebel!",
"lr.knife_rebel": "{0} is knife a rebel!",
"lr.ready": "Last request is available! Type !lr",
"lr.wait": "Please wait 15 seconds into the round before starting an lr"
"lr.wait": "Please wait 15 seconds into the round before starting an lr",

"lr.cancel_lr_cmd": "cancel_lr",
"lr.start_lr_cmd": "lr",
"lr.stats_cmd": "lr_stats"
}
10 changes: 10 additions & 0 deletions src/Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ public static void hide_weapon_cmd(CCSPlayerController? invoke, CommandInfo comm
invoke.hide_weapon();
}

[RequiresPermissions("@jail/debug")]
public static void wsd_enable_cmd(CCSPlayerController? invoke, CommandInfo command)
{
if(invoke != null && invoke.is_valid())
{
invoke.PrintToChat("enable wsd");
JailPlugin.sd.wsd_round = 0x7000_0000;
}
}

[RequiresPermissions("@jail/debug")]
public static void is_muted_cmd(CCSPlayerController? invoke, CommandInfo command)
{
Expand Down
72 changes: 47 additions & 25 deletions src/Jail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class JailConfig : BasePluginConfig
[JsonPropertyName("warden_force_removal")]
public bool warden_force_removal { get; set; } = true;

[JsonPropertyName("strip_spawn_weapons")]
public bool strip_spawn_weapons { get; set; } = true;

[JsonPropertyName("warday_guns")]
public bool warday_guns { get; set; } = false;
Expand Down Expand Up @@ -121,6 +123,9 @@ public class JailConfig : BasePluginConfig

[JsonPropertyName("rebel_requirehit")]
public bool rebel_requirehit { get; set; } = false;

[JsonPropertyName("wsd_round")]
public int wsd_round { get; set; } = 50;
}

// main plugin file, controls central hooking
Expand Down Expand Up @@ -199,11 +204,12 @@ public static void purge_player_stats(CCSPlayerController? player)

public override string ModuleName => "CS2 Jailbreak - destoer";

public override string ModuleVersion => "v0.2.2";
public override string ModuleVersion => "v1.2.2";

public override void Load(bool hotReload)
{
global_ctx = this;
logs = new Logs(this);

register_commands();

Expand All @@ -216,6 +222,7 @@ public override void Load(bool hotReload)
Console.WriteLine("Sucessfully started JB");

AddTimer(Warden.LASER_TIME,warden.laser_tick,CSTimer.TimerFlags.REPEAT);

}

void stat_db_reload()
Expand All @@ -241,6 +248,8 @@ public void OnConfigParsed(JailConfig config)
warden.warday.config = config;
JailPlayer.config = config;

sd.config = config;

lr.lr_config_reload();
stat_db_reload();
}
Expand All @@ -254,40 +263,52 @@ void register_listener()
});
}

void add_localized_cmd(String base_name,String desc,CommandInfo.CommandCallback callback)
{
AddCommand("css_" + Localizer[base_name],desc,callback);
}

void register_commands()
{
// reg warden comamnds
AddCommand("css_w", "take warden", warden.take_warden_cmd);
AddCommand("css_uw", "leave warden", warden.leave_warden_cmd);
AddCommand("css_rw", "remove warden", warden.remove_warden_cmd);
AddCommand("css_clear_marker", "remove warden marker",warden.remove_marker_cmd);
add_localized_cmd("warden.take_warden_cmd", "take warden", warden.take_warden_cmd);
add_localized_cmd("warden.leave_warden_cmd", "leave warden", warden.leave_warden_cmd);
add_localized_cmd("warden.remove_warden_cmd", "remove warden", warden.remove_warden_cmd);
add_localized_cmd("warden.remove_marker_cmd","remove warden marker",warden.remove_marker_cmd);

add_localized_cmd("warden.marker_colour_cmd", "set marker colour", warden.marker_colour_cmd);
add_localized_cmd("warden.laser_colour_cmd", "set laser colour", warden.laser_colour_cmd);

AddCommand("css_wub","warden : disable block",warden.wub_cmd);
AddCommand("css_wb","warden : enable block",warden.wb_cmd);
AddCommand("css_marker_colour", "set laser colour", warden.marker_colour_cmd);
AddCommand("css_laser_colour", "set laser colour", warden.laser_colour_cmd);
add_localized_cmd("warden.no_block_cmd","warden : disable block",warden.wub_cmd);
add_localized_cmd("warden.block_cmd","warden : enable block",warden.wb_cmd);

AddCommand("css_swap_guard","admin : move a player to ct",warden.swap_guard_cmd);
add_localized_cmd("warden.sd_cmd","warden : call a special day",sd.warden_sd_cmd);
add_localized_cmd("warden.sd_ff_cmd","warden : call a friendly fire special day",sd.warden_sd_ff_cmd);

AddCommand("css_wd","warden : start warday",warden.warday_cmd);
AddCommand("css_wcommands", "warden : show all commands",warden.cmd_info);
AddCommand("css_wtime", "how long as warden been active?", warden.warden_time_cmd);
add_localized_cmd("warden.swap_guard","admin : move a player to ct",warden.swap_guard_cmd);

add_localized_cmd("warden.warday_cmd","warden : start warday",warden.warday_cmd);
add_localized_cmd("warden.list_cmd", "warden : show all commands",warden.cmd_info);
add_localized_cmd("warden.time_cmd","how long as warden been active?",warden.warden_time_cmd);

AddCommand("css_guns","give ct guns",warden.cmd_ct_guns);
AddCommand("css_force_open","force open every door and vent",warden.force_open_cmd);
AddCommand("css_force_close","force close every door",warden.force_close_cmd);
add_localized_cmd("warden.gun_cmd","give ct guns",warden.cmd_ct_guns);

add_localized_cmd("warden.force_open_cmd","force open every door and vent",warden.force_open_cmd);
add_localized_cmd("warden.force_close_cmd","force close every door",warden.force_close_cmd);

add_localized_cmd("warden.fire_guard_cmd","admin : Remove all guards apart from warden",warden.fire_guard_cmd);

// reg lr commands
AddCommand("css_lr","start an lr",lr.lr_cmd);
AddCommand("css_cancel_lr","admin : cancel lr",lr.cancel_lr_cmd);
AddCommand("css_lr_stats","list lr stats",jail_stats.lr_stats_cmd);
add_localized_cmd("lr.start_lr_cmd","start an lr",lr.lr_cmd);
add_localized_cmd("lr.cancel_lr_cmd","admin : cancel lr",lr.cancel_lr_cmd);
add_localized_cmd("lr.stats_cmd","list lr stats",jail_stats.lr_stats_cmd);

// reg sd commands
AddCommand("css_sd","start a sd",sd.sd_cmd);
AddCommand("css_sd_ff","start a ff sd",sd.sd_ff_cmd);
AddCommand("css_cancel_sd","cancel an sd",sd.cancel_sd_cmd);
add_localized_cmd("sd.start_cmd","start a sd",sd.sd_cmd);
add_localized_cmd("sd.start_ff_cmd","start a ff sd",sd.sd_ff_cmd);
add_localized_cmd("sd.cancel_cmd","cancel an sd",sd.cancel_sd_cmd);

add_localized_cmd("logs.logs_cmd", "show round logs", logs.LogsCommand);
AddCommandListener("jointeam",join_team);

// debug
Expand Down Expand Up @@ -318,7 +339,7 @@ public HookResult join_team(CCSPlayerController? invoke, CommandInfo command)
{
jail_player.load_player(invoke);
}

if(!warden.join_team(invoke,command))
{
return HookResult.Stop;
Expand Down Expand Up @@ -359,8 +380,6 @@ void register_hook()

AddCommandListener("player_ping", CommandListener_RadioCommand);

AddCommandListener("player_ping", CommandListener_RadioCommand);

// TODO: need to hook weapon drop
}

Expand Down Expand Up @@ -401,6 +420,7 @@ HookResult OnButtonPressed(CEntityIOOutput output, String name, CEntityInstance
if(player != null && player.is_valid() && ent != null && ent.IsValid)
{
Lib.print_console_all($"{player.PlayerName} pressed button '{ent.Entity?.Name}' -> '{output?.Connections?.TargetDesc}'",true);
logs.AddLocalized(player, "logs.format.button", ent.Entity?.Name ?? "Unlabeled", output?.Connections?.TargetDesc ?? "None");
}

return HookResult.Continue;
Expand All @@ -419,6 +439,7 @@ HookResult OnGrenadeThrown(EventGrenadeThrown @event, GameEventInfo info)
{
lr.grenade_thrown(player);
sd.grenade_thrown(player);
logs.AddLocalized(player, "logs.format.grenade", @event.Weapon);
}

return HookResult.Continue;
Expand Down Expand Up @@ -657,4 +678,5 @@ public static String localise(string name,params Object[] args)
public static LastRequest lr = new LastRequest();
public static SpecialDay sd = new SpecialDay();
public static JailStats jail_stats = new JailStats();
public static Logs logs;
}
2 changes: 1 addition & 1 deletion src/LastRequest/Dodgeball.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public override void player_hurt(int damage, int health, int hitgroup)
public override void grenade_thrown()
{
CCSPlayerController? player = Utilities.GetPlayerFromSlot(player_slot);
Lib.give_event_nade_delay(player,1.4f,"weapon_flashbang");
give_lr_nade_delay(1.4f,"weapon_flashbang");
}

public override void ent_created(CEntityInstance entity)
Expand Down
2 changes: 1 addition & 1 deletion src/LastRequest/Grenade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ public override void grenade_thrown()
{
CCSPlayerController? player = Utilities.GetPlayerFromSlot(player_slot);
player.strip_weapons(true);
Lib.give_event_nade_delay(player,1.4f,"weapon_hegrenade");
give_lr_nade_delay(1.4f,"weapon_hegrenade");
}
}
22 changes: 22 additions & 0 deletions src/LastRequest/LRBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,28 @@ public virtual bool weapon_equip(String name)
return (winner,loser,winner_lr);
}


public void give_lr_nade_delay(float delay, String name)
{
if(JailPlugin.global_ctx == null)
{
return;
}

JailPlugin.global_ctx.AddTimer(delay,() =>
{
CCSPlayerController? player = Utilities.GetPlayerFromSlot(player_slot);

// need to double check LR is actually still active...
if(player != null && player.is_valid_alive() && manager.in_lr(player))
{
//Server.PrintToChatAll("give nade");
player.strip_weapons(true);
player.GiveNamedItem(name);
}
});
}

static public void print_countdown(LRBase lr, int delay)
{
if(lr.partner == null)
Expand Down
2 changes: 1 addition & 1 deletion src/LastRequest/Rebel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void rebel_guns(CCSPlayerController player, ChatMenuOption option)

player.strip_weapons();

player.GiveNamedItem("weapon_" + Lib.gun_give_name(option.Text));
player.GiveNamedItem(Lib.gun_give_name(option.Text));
player.GiveNamedItem("weapon_deagle");

player.GiveNamedItem("item_assaultsuit");
Expand Down
Loading

0 comments on commit 0d58bb8

Please sign in to comment.