mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-20 03:25:49 +01:00
Maint drones now return to the drone manufacturer when shutdown (#23367)
* luv me some drones * uhhh WIP * ..() moment * Gaxeer review & misc change * henri review * tgui * boom, i think * oops * sirryan review * final stuff * lmaooo * Apply suggestions from code review Co-authored-by: Deniz <66401072+Oyu07@users.noreply.github.com> --------- Co-authored-by: Deniz <66401072+Oyu07@users.noreply.github.com>
This commit is contained in:
@@ -66,7 +66,8 @@
|
||||
health = round(D.health / D.maxHealth, 0.1),
|
||||
charge = round(D.cell.charge / D.cell.maxcharge, 0.1),
|
||||
location = "[A] ([T.x], [T.y])",
|
||||
sync_cd = D.sync_cooldown > world.time ? TRUE : FALSE
|
||||
sync_cd = D.sync_cooldown > world.time ? TRUE : FALSE,
|
||||
pathfinding = D.pathfinding
|
||||
)
|
||||
data["drones"] += list(drone_data)
|
||||
return data
|
||||
@@ -113,13 +114,14 @@
|
||||
to_chat(usr, "<span class='notice'>You issue a law synchronization directive for the drone.</span>")
|
||||
D.law_resync()
|
||||
|
||||
if("shutdown")
|
||||
if("recall")
|
||||
var/mob/living/silicon/robot/drone/D = locateUID(params["uid"])
|
||||
if(D)
|
||||
to_chat(usr, "<span class='warning'>You issue a kill command for the unfortunate drone.</span>")
|
||||
to_chat(usr, "<span class='warning'>You issue a recall command for the unfortunate drone.</span>")
|
||||
if(D != usr) // Don't need to bug admins about a suicide
|
||||
message_admins("[key_name_admin(usr)] issued kill order for drone [key_name_admin(D)] from control console.")
|
||||
log_game("[key_name(usr)] issued kill order for [key_name(D)] from control console.")
|
||||
message_admins("[key_name_admin(usr)] issued recall order for drone [key_name_admin(D)] from control console.")
|
||||
log_game("[key_name(usr)] issued recall order for [key_name(D)] from control console.")
|
||||
// Yes, I know this proc is called shut_down, I've kept the name the same because emagged drones use it for death
|
||||
D.shut_down()
|
||||
|
||||
/obj/machinery/computer/drone_control/proc/find_fab(mob/user)
|
||||
|
||||
@@ -87,6 +87,16 @@
|
||||
var/mob/dead/observer/ghost = user
|
||||
ghost.join_as_drone()
|
||||
|
||||
/obj/machinery/drone_fabricator/attack_hand(mob/user)
|
||||
. = ..()
|
||||
if(isdrone(user) && Adjacent(user))
|
||||
if(alert(user, "Would you like to shut down?", null, "Yes", "No") != "Yes")
|
||||
return
|
||||
var/mob/living/silicon/robot/drone/D = user
|
||||
if(!istype(D) || QDELETED(D))
|
||||
return
|
||||
D.cryo_with_dronefab(src)
|
||||
|
||||
/mob/dead/verb/join_as_drone()
|
||||
set category = "Ghost"
|
||||
set name = "Join As Drone"
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
)
|
||||
|
||||
holder_type = /obj/item/holder/drone
|
||||
// var/sprite[0]
|
||||
var/datum/pathfinding_mover/pathfinding
|
||||
|
||||
|
||||
/mob/living/silicon/robot/drone/New()
|
||||
@@ -125,6 +125,8 @@
|
||||
overlays.Cut()
|
||||
if(stat == CONSCIOUS)
|
||||
overlays += "eyes-[icon_state]"
|
||||
if(pathfinding)
|
||||
overlays += "eyes-repairbot-pathfinding"
|
||||
else
|
||||
overlays -= "eyes"
|
||||
|
||||
@@ -279,6 +281,10 @@
|
||||
to_chat(src, "<span class='warning'>You feel a system kill order percolate through your tiny brain, but it doesn't seem like a good idea to you.</span>")
|
||||
return
|
||||
|
||||
if(!emagged && pathfind_to_dronefab())
|
||||
to_chat(src, "<span class='warning'>You feel a system recall order percolate through your tiny brain, and you return to your drone fabricator.</span>")
|
||||
return
|
||||
|
||||
to_chat(src, "<span class='warning'>You feel a system kill order percolate through your tiny brain, and you obediently destroy yourself.</span>")
|
||||
death()
|
||||
|
||||
@@ -391,3 +397,73 @@
|
||||
qdel(src)
|
||||
return TRUE
|
||||
return ..()
|
||||
|
||||
/mob/living/silicon/robot/drone/do_suicide()
|
||||
ghostize(TRUE)
|
||||
shut_down()
|
||||
|
||||
/mob/living/silicon/robot/drone/proc/pathfind_to_dronefab()
|
||||
if(pathfinding)
|
||||
return TRUE
|
||||
|
||||
if(istype(get_turf(src), /turf/space))
|
||||
return FALSE // Pretty damn hard to path through space
|
||||
|
||||
var/turf/target
|
||||
for(var/obj/machinery/drone_fabricator/DF in GLOB.machines)
|
||||
if(DF.z != z)
|
||||
continue
|
||||
target = get_turf(DF)
|
||||
target = get_step(target, EAST)
|
||||
break
|
||||
|
||||
if(!target)
|
||||
return FALSE
|
||||
|
||||
// Mimic having the hide-ability activated
|
||||
layer = TURF_LAYER + 0.2
|
||||
pass_flags |= PASSDOOR
|
||||
|
||||
var/datum/pathfinding_mover/pathfind = new(src, target)
|
||||
|
||||
// I originally only wanted to make it use an ID if it couldnt pathfind otherwise, but that means it could take multiple minutes if both searches failed
|
||||
var/obj/item/card/id/temp_id = new(src)
|
||||
temp_id.access = get_all_accesses()
|
||||
set_pathfinding(pathfind)
|
||||
var/found_path = pathfind.generate_path(150, null, temp_id)
|
||||
qdel(temp_id)
|
||||
if(!found_path)
|
||||
set_pathfinding(null)
|
||||
return FALSE
|
||||
|
||||
pathfind.on_set_path_null = CALLBACK(src, PROC_REF(pathfind_failed_cleanup))
|
||||
pathfind.on_success = CALLBACK(src, PROC_REF(at_dronefab))
|
||||
pathfind.start()
|
||||
return TRUE
|
||||
|
||||
/mob/living/silicon/robot/drone/proc/pathfind_failed_cleanup(pathfind)
|
||||
set_pathfinding(null)
|
||||
death()
|
||||
|
||||
/mob/living/silicon/robot/drone/proc/at_dronefab(pathfind)
|
||||
set_pathfinding(null)
|
||||
cryo_with_dronefab()
|
||||
|
||||
/mob/living/silicon/robot/drone/proc/cryo_with_dronefab(obj/machinery/drone_fabricator/drone_fab)
|
||||
if(!drone_fab)
|
||||
drone_fab = locate() in range(1, src)
|
||||
if(!drone_fab)
|
||||
return FALSE
|
||||
drone_fab.drone_progress = 100 // recycling!
|
||||
|
||||
visible_message("<span class='notice'>[src] shuts down and enters [drone_fab].</span>")
|
||||
playsound(loc, 'sound/machines/twobeep.ogg', 50)
|
||||
qdel(src)
|
||||
return TRUE
|
||||
|
||||
/mob/living/silicon/robot/drone/proc/set_pathfinding(datum/pathfinding_mover/new_pathfind)
|
||||
if(isnull(new_pathfind) && istype(pathfinding))
|
||||
qdel(pathfinding)
|
||||
pathfinding = new_pathfind
|
||||
notransform = istype(new_pathfind) ? TRUE : FALSE // prevent them from moving themselves while pathfinding.
|
||||
update_icons()
|
||||
|
||||
Reference in New Issue
Block a user