Skip to content

Commit

Permalink
Port code for admin verb Freeze from Paradise
Browse files Browse the repository at this point in the history
  • Loading branch information
blinkdog committed Dec 25, 2023
1 parent 54d5806 commit c30f2f7
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 1 deletion.
6 changes: 5 additions & 1 deletion code/game/mecha/mecha.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
var/lights = FALSE
var/last_user_hud = 1 // used to show/hide the mecha hud while preserving previous preference
var/completely_disabled = FALSE //stops the mech from doing anything
var/frozen = FALSE // admin frozen

var/bumpsmash = 0 //Whether or not the mech destroys walls by running into it.
//inner atmos
Expand Down Expand Up @@ -565,7 +566,7 @@
/obj/mecha/relaymove(mob/living/user, direction)
if(completely_disabled)
return
if(!direction)
if(!direction || frozen)
return
if(user != occupant) //While not "realistic", this piece is player friendly.
user.forceMove(get_turf(src))
Expand Down Expand Up @@ -884,6 +885,9 @@
. = t_air.return_temperature()

/obj/mecha/MouseDrop_T(mob/M, mob/user)
if(frozen)
to_chat(user, "<span class='warning'>Do not enter Admin-Frozen mechs.</span>")
return TRUE
if((user != M) || user.incapacitated() || !Adjacent(user))
return
if(!ishuman(user)) // no silicons or drones in mechas.
Expand Down
6 changes: 6 additions & 0 deletions code/game/objects/effects/overlays.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
icon_state = "shieldsparkles"
anchored = TRUE

/obj/effect/overlay/adminoverlay
name = "adminoverlay"
icon = 'icons/effects/effects.dmi'
icon_state = "admin"
layer = 4.1

/obj/effect/overlay/vis
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
anchored = TRUE
Expand Down
1 change: 1 addition & 0 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ GLOBAL_PROTECT(admin_verbs_admin)
/client/proc/overmap_datum_token_manager,
/datum/admins/proc/open_borgopanel,
/client/proc/investigate_show, /*various admintools for investigation. Such as a singulo grief-log*/
/client/proc/freeze,
)

GLOBAL_LIST_INIT(admin_verbs_ban, list(
Expand Down
94 changes: 94 additions & 0 deletions code/modules/admin/verbs/freeze.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//////Freeze Mob/Mech Verb -- Ported from NSS Pheonix (Unbound Travels)/////////
////////////////////////////////////////////////////////////////////////////////
//////Allows admin's to right click on any mob/mech and freeze them in place.///
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

GLOBAL_LIST_EMPTY(frozen_atom_list) // A list of admin-frozen atoms.

/client/proc/freeze(atom/movable/M)
set name = "\[Admin\] Freeze"
set category = null

if(!check_rights(R_ADMIN))
return

M.admin_Freeze(src)

/// Created here as a base proc. Override as needed for any type of object or mob you want able to be frozen.
/atom/movable/proc/admin_Freeze(client/admin)
to_chat(admin, "<span class='warning'>Freeze is not able to be called on this type of object.</span")
return

///mob freeze procs
/mob/living/admin_Freeze(client/admin, skip_overlays = FALSE, mech = null)
if(!istype(admin))
return

if(!(src in GLOB.frozen_atom_list))
GLOB.frozen_atom_list += src

var/obj/effect/overlay/adminoverlay/AO = new
if(skip_overlays)
overlays += AO

anchored = TRUE
admin_prev_sleeping = AmountSleeping()
frozen = AO
PermaSleeping()

else
GLOB.frozen_atom_list -= src

if(skip_overlays)
overlays -= frozen

anchored = FALSE
frozen = null
SetSleeping(admin_prev_sleeping, TRUE)
admin_prev_sleeping = null

to_chat(src, "<b><font color= red>You have been [frozen ? "frozen" : "unfrozen"] by [admin]</b></font>")
message_admins("<span class='notice'>[key_name_admin(admin)] [frozen ? "froze" : "unfroze"] [key_name_admin(src)] [mech ? "in a [mech]" : ""]</span>")
log_admin("[key_name(admin)] [frozen ? "froze" : "unfroze"] [key_name(src)] [mech ? "in a [mech]" : ""]")
update_icons()

return frozen


/mob/living/simple_animal/slime/admin_Freeze(admin)
if(..()) // The result of the parent call here will be the value of the mob's `frozen` variable after they get (un)frozen.
adjustHealth(1000) //arbitrary large value
else
revive()

/mob/living/simple_animal/var/admin_prev_health = null

/mob/living/simple_animal/admin_Freeze(admin)
if(..()) // The result of the parent call here will be the value of the mob's `frozen` variable after they get (un)frozen.
admin_prev_health = health
health = 0
else
revive()
overlays.Cut()

//////////////////////////Freeze Mech

/obj/mecha/admin_Freeze(client/admin)
var/obj/effect/overlay/adminoverlay/freeze_overlay = new
if(!frozen)
GLOB.frozen_atom_list += src
frozen = TRUE
overlays += freeze_overlay
else
GLOB.frozen_atom_list -= src
frozen = FALSE
overlays -= freeze_overlay

if(occupant)
occupant.admin_Freeze(admin, mech = name) // We also want to freeze the driver of the mech.
else
message_admins("<span class='notice'>[key_name_admin(admin)] [frozen ? "froze" : "unfroze"] an empty [name]</span>")
log_admin("[key_name(admin)] [frozen ? "froze" : "unfroze"] an empty [name]")
5 changes: 5 additions & 0 deletions code/modules/mob/living/living_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
/// Flags that determine the potential of a mob to perform certain actions. Do not change this directly.
var/mobility_flags = MOBILITY_FLAGS_DEFAULT

/// Used for preventing attacks on admin-frozen mobs.
var/frozen = null
/// Used for keeping track of previous sleeping value with admin freeze.
var/admin_prev_sleeping = 0

var/resting = FALSE

/// Variable to track the body position of a mob, regardgless of the actual angle of rotation (usually matching it, but not necessarily).
Expand Down
1 change: 1 addition & 0 deletions shiptest.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,7 @@
#include "code\modules\admin\verbs\fax_manager.dm"
#include "code\modules\admin\verbs\fix_air.dm"
#include "code\modules\admin\verbs\fps.dm"
#include "code\modules\admin\verbs\freeze.dm"
#include "code\modules\admin\verbs\getlogs.dm"
#include "code\modules\admin\verbs\individual_logging.dm"
#include "code\modules\admin\verbs\machine_upgrade.dm"
Expand Down

0 comments on commit c30f2f7

Please sign in to comment.