Skip to content

Commit

Permalink
Кнопки для гостоты
Browse files Browse the repository at this point in the history
  • Loading branch information
FeudeyTF committed Feb 8, 2024
1 parent 2fc5a00 commit 858a399
Show file tree
Hide file tree
Showing 9 changed files with 358 additions and 15 deletions.
2 changes: 2 additions & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
#include "code\_onclick\hud\animal.dm"
#include "code\_onclick\hud\chorus.dm"
#include "code\_onclick\hud\fullscreen.dm"
#include "code\_onclick\hud\ghost.dm"
#include "code\_onclick\hud\global_hud.dm"
#include "code\_onclick\hud\global_hud_inf.dm"
#include "code\_onclick\hud\gun_mode.dm"
Expand Down Expand Up @@ -2464,6 +2465,7 @@
#include "code\modules\mob\observer\ghost\ghost.dm"
#include "code\modules\mob\observer\ghost\login.dm"
#include "code\modules\mob\observer\ghost\logout.dm"
#include "code\modules\mob\observer\ghost\orbit.dm"
#include "code\modules\mob\observer\ghost\say.dm"
#include "code\modules\mob\observer\virtual\_constants.dm"
#include "code\modules\mob\observer\virtual\base.dm"
Expand Down
8 changes: 8 additions & 0 deletions code/_onclick/hud/_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,11 @@
#define ui_pai_light "NORTH,WEST+3:6"
#define ui_pai_rest "NORTH,WEST+4:6"

// Ghosts
#define ui_ghost_toggle_darkness "SOUTH:6,CENTER-3:16"
#define ui_ghost_jumptomob "SOUTH:6,CENTER-2:16"
#define ui_ghost_orbit "SOUTH:6,CENTER-1:16"
#define ui_ghost_reenter_corpse "SOUTH:6,CENTER:16"
#define ui_ghost_teleport "SOUTH:6,CENTER+1:16"
#define ui_ghost_mafia "SOUTH:6,CENTER+2:16"
#define ui_ghost_spawners_menu "SOUTH:6,CENTER-4:16"
51 changes: 51 additions & 0 deletions code/_onclick/hud/ghost.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/obj/screen/ghost
icon = 'icons/hud/screen_ghost.dmi'

/obj/screen/ghost/MouseExited(location, control, params)
. = ..()
flick(icon_state + "_anim", src)

/obj/screen/ghost/jumptomob
name = "Jump to mob"
icon_state = "jumptomob"
screen_loc = ui_ghost_jumptomob

/obj/screen/ghost/jumptomob/Click()
var/mob/observer/ghost/G = usr
G.jumptomob()

/obj/screen/ghost/orbit
name = "Orbit"
icon_state = "orbit"
screen_loc = ui_ghost_orbit

/obj/screen/ghost/orbit/Click()
var/mob/observer/ghost/G = usr
G.follow()

/obj/screen/ghost/reenter_corpse
name = "Reenter corpse"
icon_state = "reenter_corpse"
screen_loc = ui_ghost_reenter_corpse

/obj/screen/ghost/reenter_corpse/Click()
var/mob/observer/ghost/G = usr
G.reenter_corpse()

/obj/screen/ghost/teleport
name = "Teleport"
icon_state = "teleport"
screen_loc = ui_ghost_teleport

/obj/screen/ghost/teleport/Click()
var/mob/observer/ghost/G = usr
G.dead_tele()

/obj/screen/ghost/toggle_darkness
name = "Toggle Darkness"
icon_state = "toggle_darkness"
screen_loc = ui_ghost_toggle_darkness

/obj/screen/ghost/toggle_darkness/Click()
var/mob/observer/ghost/G = usr
G.toggle_darkness()
1 change: 1 addition & 0 deletions code/modules/mob/new_player/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
if(!client.holder && !config.antag_hud_allowed) // For new ghosts we remove the verb from even showing up if it's not allowed.
observer.verbs -= /mob/observer/ghost/verb/toggle_antagHUD // Poor guys, don't know what they are missing!
observer.key = key
observer.add_ghost_buttons()
qdel(src)

return 1
Expand Down
15 changes: 8 additions & 7 deletions code/modules/mob/observer/following.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
following = null

/mob/observer/proc/start_following(var/atom/a)
stop_following()
following = a
GLOB.destroyed_event.register(a, src, .proc/stop_following)
GLOB.moved_event.register(a, src, .proc/keep_following)
GLOB.dir_set_event.register(a, src, /atom/proc/recursive_dir_set)
keep_following(new_loc = get_turf(following))
if(!istype(a, /obj/screen))
stop_following()
following = a
GLOB.destroyed_event.register(a, src, .proc/stop_following)
GLOB.moved_event.register(a, src, .proc/keep_following)
GLOB.dir_set_event.register(a, src, /atom/proc/recursive_dir_set)
keep_following(new_loc = get_turf(following))

/mob/observer/proc/keep_following(var/atom/movable/moving_instance, var/atom/old_loc, var/atom/new_loc)
forceMove(get_turf(new_loc))
forceMove(get_turf(new_loc))
40 changes: 32 additions & 8 deletions code/modules/mob/observer/ghost/ghost.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ var/global/list/image/ghost_sightless_images = list() //this is a list of images
var/obj/item/device/multitool/ghost_multitool
var/list/hud_images // A list of hud images

var/thearea

/mob/observer/ghost/New(mob/body)
see_in_dark = 100
verbs += /mob/proc/toggle_antag_pool
Expand Down Expand Up @@ -71,7 +73,6 @@ var/global/list/image/ghost_sightless_images = list() //this is a list of images
ghost_multitool = new(src)

GLOB.ghost_mob_list += src

..()

/mob/observer/ghost/Destroy()
Expand Down Expand Up @@ -108,7 +109,6 @@ Works together with spawning an observer, noted above.
..()
if(!loc) return
if(!client) return 0

handle_hud_glasses()

if(antagHUD)
Expand Down Expand Up @@ -150,6 +150,7 @@ Works together with spawning an observer, noted above.
ghost.key = key
if(ghost.client && !ghost.client.holder && !config.antag_hud_allowed) // For new ghosts we remove the verb from even showing up if it's not allowed.
ghost.verbs -= /mob/observer/ghost/verb/toggle_antagHUD // Poor guys, don't know what they are missing!
ghost.add_ghost_buttons()
return ghost

/mob/observer/ghostize() // Do not create ghosts of ghosts.
Expand Down Expand Up @@ -233,6 +234,16 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
announce_ghost_joinleave(mind, 0, "They now occupy their body again.")
return 1

/mob/observer/ghost/proc/jumptomob()
var/mob/M = input(usr, "Pick a mob", "Pick a mob") as null|anything in SSmobs.mob_list
log_and_message_admins("jumped to [key_name(M)]")
var/turf/T = get_turf(M)
if(T && isturf(T))
jumpTo(T)
else
to_chat(usr, "This mob is not located in the game world.")


/mob/observer/ghost/verb/toggle_medHUD()
set category = "Ghost"
set name = "Toggle MedicHUD"
Expand Down Expand Up @@ -273,16 +284,17 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
M.antagHUD = 1
to_chat(src, SPAN_NOTICE("AntagHUD Enabled"))

/mob/observer/ghost/verb/dead_tele(A in area_repository.get_areas_by_z_level())
/mob/observer/ghost/verb/dead_tele()
set category = "Ghost"
set name = "Teleport"
set desc= "Teleport to a location"

var/A = input(usr, "Pick an area.", "Pick an area") as num|anything in area_repository.get_areas_by_z_level()
var/area/thearea = area_repository.get_areas_by_z_level()[A]

if(!thearea)
to_chat(src, "No area available.")
return

var/list/area_turfs = get_area_turfs(thearea, shall_check_if_holy() ? list(/proc/is_not_holy_turf) : list())
if(!area_turfs.len)
to_chat(src, "<span class='warning'>This area has been entirely made into sacred grounds, you cannot enter it while you are in this plane of existence!</span>")
Expand All @@ -300,13 +312,13 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
ghost_to_turf(T)
else
to_chat(src, "<span class='warning'>Invalid coordinates.</span>")
/mob/observer/ghost/verb/follow(var/datum/follow_holder/fh in get_follow_targets())

/mob/observer/ghost/verb/follow()
set category = "Ghost"
set name = "Follow"
set desc = "Follow and haunt a mob."

if(!fh.show_entry()) return
start_following(fh.followed_instance)
GLOB.orbit_menu.show(src)

/mob/observer/ghost/proc/ghost_to_turf(var/turf/target_turf)
if(check_is_holy_turf(target_turf))
Expand All @@ -326,7 +338,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
verbs -= /mob/observer/ghost/verb/scan_target
..()

/mob/observer/ghost/keep_following(var/atom/movable/am, var/old_loc, var/new_loc)
/mob/observer/ghost/keep_following(var/obj/am, var/old_loc, var/new_loc)
var/turf/T = get_turf(new_loc)
if(check_is_holy_turf(T))
to_chat(src, "<span class='warning'>You cannot follow something standing on holy grounds!</span>")
Expand Down Expand Up @@ -623,3 +635,15 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
M.respawned_time = world.time
M.key = key
log_and_message_admins("has respawned.", M)

/mob/observer/ghost/proc/add_ghost_buttons()
var/jumptomob = new /obj/screen/ghost/jumptomob()
var/orbit = new /obj/screen/ghost/orbit()
var/reenter_corpse = new /obj/screen/ghost/reenter_corpse()
var/teleport = new /obj/screen/ghost/teleport()
var/toggle_darkness = new /obj/screen/ghost/toggle_darkness()
client.screen.Add(jumptomob)
client.screen.Add(orbit)
client.screen.Add(reenter_corpse)
client.screen.Add(teleport)
client.screen.Add(toggle_darkness)
75 changes: 75 additions & 0 deletions code/modules/mob/observer/ghost/orbit.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
GLOBAL_DATUM_INIT(orbit_menu, /datum/orbit_menu, new)

/datum/orbit_menu

/datum/orbit_menu/tgui_state(mob/user)
return GLOB.tgui_observer_state

/datum/orbit_menu/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if (!ui)
ui = new(user, src, "Orbit", "Orbit")
ui.open()

/datum/orbit_menu/tgui_act(action, list/params)
. = ..()

if(.)
return

switch(action)
if("orbit")
var/datum/follow_holder/fh = locate(params["ref"]) in get_follow_targets()
var/atom/movable/a = fh.followed_instance
var/mob/observer/ghost/G = usr
if(a != usr)
G.start_following(a)
return TRUE
if("refresh")
update_tgui_static_data()
return TRUE

/datum/orbit_menu/tgui_static_data(mob/user)
var/list/data = list()
data["misc"] = list()
data["ghosts"] = list()
data["dead"] = list()
data["npcs"] = list()
data["alive"] = list()
data["antagonists"] = list()
for(var/datum/follow_holder/fh in get_follow_targets())
var/atom/movable/fi = fh.followed_instance
var/list/serialized = list()
serialized["name"] = fi.name
serialized["ref"] = "\ref[fh]"

if(!istype(fi, /mob))
data["misc"] += list(serialized)
continue
var/mob/M = fi
if(isobserver(M))
data["ghosts"] += list(serialized)
continue

if(M.stat == DEAD)
data["dead"] += list(serialized)
continue

if(M.mind == null)
data["npcs"] += list(serialized)
continue

data["alive"] += list(serialized)

var/mob/observer/ghost/O = user
if(O.antagHUD && M.get_antag_info())
var/antag_serialized = serialized.Copy()
for(var/antag_category in M.get_antag_info())
antag_serialized["antag"] += list(antag_category)
data["antagonists"] += list(antag_serialized)

return data

/// Shows the UI to the specified user.
/datum/orbit_menu/proc/show(mob/user)
tgui_interact(user)
Binary file added icons/hud/screen_ghost.dmi
Binary file not shown.
Loading

0 comments on commit 858a399

Please sign in to comment.