-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
* deathmatch (#81444) ## About The Pull Request ![image](https://github.com/tgstation/tgstation/assets/70376633/44f1d1af-2cd6-4e69-a13e-6d2a663d668d) adds a deathmatch minigame, a port and slightly redone version of the aetherstation deathmatch (by TheChosenEvilOne) the goal is to kill everyone else with loadouts ## Why It's Good For The Game CTF sucks and this is probably better to filter out the bloodthirsty terry players anyway ## Changelog :cl: add: deathmatch minigame /:cl: --------- * deathmatch --------- Co-authored-by: NovaBot <[email protected]> Co-authored-by: jimmyl <[email protected]> Co-authored-by: MrMelbert <[email protected]> Co-authored-by: Ghom <[email protected]>
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/datum/deathmatch_controller | ||
/// Assoc list of all lobbies (ckey = lobby) | ||
var/list/datum/deathmatch_lobby/lobbies = list() | ||
/// All deathmatch map templates | ||
var/list/datum/lazy_template/deathmatch/maps = list() | ||
/// All loadouts | ||
var/list/datum/outfit/loadouts | ||
|
||
/// All currently present spawnpoints, to be processed by a loading map | ||
var/list/spawnpoint_processing = list() | ||
|
||
/datum/deathmatch_controller/New() | ||
. = ..() | ||
if (GLOB.deathmatch_game) | ||
qdel(src) | ||
CRASH("A deathmatch controller already exists.") | ||
GLOB.deathmatch_game = src | ||
|
||
for (var/datum/lazy_template/deathmatch/template as anything in subtypesof(/datum/lazy_template/deathmatch)) | ||
var/map_name = initial(template.name) | ||
maps[map_name] = new template | ||
loadouts = subtypesof(/datum/outfit/deathmatch_loadout) | ||
|
||
/datum/deathmatch_controller/proc/create_new_lobby(mob/host) | ||
lobbies[host.ckey] = new /datum/deathmatch_lobby(host) | ||
deadchat_broadcast(" has opened a new deathmatch lobby. <a href=?src=[REF(lobbies[host.ckey])];join=1>(Join)</a>", "<B>[host]</B>") | ||
|
||
/datum/deathmatch_controller/proc/remove_lobby(ckey) | ||
var/lobby = lobbies[ckey] | ||
lobbies[ckey] = null | ||
lobbies.Remove(ckey) | ||
qdel(lobby) | ||
|
||
/datum/deathmatch_controller/proc/passoff_lobby(host, new_host) | ||
lobbies[new_host] = lobbies[host] | ||
lobbies[host] = null | ||
lobbies.Remove(host) | ||
|
||
/datum/deathmatch_controller/proc/load_lazyarena(map_key) | ||
if(!isnull(map_key) && !isnull(maps[map_key])) | ||
var/datum/lazy_template/deathmatch/temp = maps[map_key] | ||
return temp.lazy_load() //returns rezervation | ||
|
||
return FALSE | ||
|
||
/datum/deathmatch_controller/ui_state(mob/user) | ||
return GLOB.observer_state | ||
|
||
/datum/deathmatch_controller/ui_interact(mob/user, datum/tgui/ui) | ||
ui = SStgui.try_update_ui(user, src, null) | ||
if(!ui) | ||
ui = new(user, src, "DeathmatchPanel") | ||
ui.open() | ||
|
||
/datum/deathmatch_controller/ui_data(mob/user) | ||
. = ..() | ||
.["lobbies"] = list() | ||
.["hosting"] = FALSE | ||
.["admin"] = check_rights_for(user.client, R_ADMIN) | ||
for (var/ckey in lobbies) | ||
var/datum/deathmatch_lobby/lobby = lobbies[ckey] | ||
if (user.ckey == ckey) | ||
.["hosting"] = TRUE | ||
if (user.ckey in lobby.observers+lobby.players) | ||
.["playing"] = ckey | ||
.["lobbies"] += list(list( | ||
name = ckey, | ||
players = lobby.players.len, | ||
max_players = initial(lobby.map.max_players), | ||
map = initial(lobby.map.name), | ||
playing = lobby.playing | ||
)) | ||
|
||
/datum/deathmatch_controller/proc/find_lobby_by_user(ckey) | ||
for(var/lobbykey in lobbies) | ||
var/datum/deathmatch_lobby/lobby = lobbies[lobbykey] | ||
if(ckey in lobby.players+lobby.observers) | ||
return lobby | ||
|
||
/datum/deathmatch_controller/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) | ||
. = ..() | ||
if(. || !isobserver(usr)) | ||
return | ||
switch (action) | ||
if ("host") | ||
if (lobbies[usr.ckey]) | ||
return | ||
if(!SSticker.HasRoundStarted()) | ||
tgui_alert(usr, "The round hasn't started yet!") | ||
return | ||
ui.close() | ||
create_new_lobby(usr) | ||
if ("join") | ||
if (!lobbies[params["id"]]) | ||
return | ||
var/datum/deathmatch_lobby/playing_lobby = find_lobby_by_user(usr.ckey) | ||
var/datum/deathmatch_lobby/chosen_lobby = lobbies[params["id"]] | ||
if (!isnull(playing_lobby) && playing_lobby != chosen_lobby) | ||
playing_lobby.leave(usr.ckey) | ||
|
||
if(isnull(playing_lobby)) | ||
log_game("[usr.ckey] joined deathmatch lobby [params["id"]] as a player.") | ||
chosen_lobby.join(usr) | ||
|
||
chosen_lobby.ui_interact(usr) | ||
if ("spectate") | ||
var/datum/deathmatch_lobby/playing_lobby = find_lobby_by_user(usr.ckey) | ||
if (!lobbies[params["id"]]) | ||
return | ||
var/datum/deathmatch_lobby/chosen_lobby = lobbies[params["id"]] | ||
// if the player is in this lobby | ||
if(!isnull(playing_lobby) && playing_lobby != chosen_lobby) | ||
playing_lobby.leave(usr.ckey) | ||
else if(playing_lobby == chosen_lobby) | ||
chosen_lobby.ui_interact(usr) | ||
return | ||
// they werent in the lobby, lets add them | ||
if (!chosen_lobby.playing) | ||
chosen_lobby.add_observer(usr) | ||
chosen_lobby.ui_interact(usr) | ||
else | ||
chosen_lobby.spectate(usr) | ||
log_game("[usr.ckey] joined deathmatch lobby [params["id"]] as an observer.") | ||
if ("admin") | ||
if (!check_rights(R_ADMIN)) | ||
message_admins("[usr.key] has attempted to use admin functions in the deathmatch panel!") | ||
log_admin("[key_name(usr)] tried to use the deathmatch panel admin functions without authorization.") | ||
return | ||
var/lobby = params["id"] | ||
switch (params["func"]) | ||
if ("Close") | ||
remove_lobby(lobby) | ||
log_admin("[key_name(usr)] removed deathmatch lobby [lobby].") | ||
if ("View") | ||
lobbies[lobby].ui_interact(usr) |