Respawning Tweaks (#646)

changes:

rscadd: "Respawn timers are now tracked individually for playing as animals (mice), small synthetics (drones and pAIs) and crew (everything else). This means you can now play as a mouse or drone while waiting to respawn as a full crewmember.".
tweak: "You can now spawn as a drone immediately upon joining as an observer, without having to wait ten minutes. There is still a cooldown between respawning as a drone if you just died as one."
tweak: "Slightly improved the error messages if you try to respawn when you've not waited long enough."
In addition, unlisted changes:
The admin verb 'Allow player to respawn' now sets all three respawn timers
Respawn times are now centralised in setup #defines, for easier editing in future
Nonliving mobs will no longer attempt to ghost when deleted. A comment in mob.dm explains this change
This commit is contained in:
NanakoAC
2016-08-03 22:34:41 +03:00
committed by skull132
parent af304c93e2
commit d6803a26e3
10 changed files with 173 additions and 43 deletions
+39 -11
View File
@@ -32,6 +32,9 @@ var/global/list/image/ghost_sightless_images = list() //this is a list of images
incorporeal_move = 1
/mob/dead/observer/New(mob/body)
if (istype(body, /mob/dead/observer))
return//A ghost can't become a ghost.
sight |= SEE_TURFS | SEE_MOBS | SEE_OBJS | SEE_SELF
see_invisible = SEE_INVISIBLE_OBSERVER
see_in_dark = 100
@@ -44,7 +47,7 @@ var/global/list/image/ghost_sightless_images = list() //this is a list of images
updateallghostimages()
var/turf/T
if(ismob(body))
if (ismob(body))
T = get_turf(body) //Where is the body located?
attack_log = body.attack_log //preserve our attack logs by copying them to our ghost
@@ -95,7 +98,17 @@ var/global/list/image/ghost_sightless_images = list() //this is a list of images
if(target)
ManualFollow(target)
/mob/dead/observer/proc/initialise_postkey()
//This function should be run after a ghost has been created and had a ckey assigned
//Death times are initialised if they were unset
//get/set death_time functions are in mob_helpers.dm
if (!get_death_time(ANIMAL))
set_death_time(ANIMAL, world.time - RESPAWN_ANIMAL)//allow instant mouse spawning
if (!get_death_time(MINISYNTH))
set_death_time(MINISYNTH, world.time - RESPAWN_MINISYNTH) //allow instant drone spawning
if (!get_death_time(CREW))
set_death_time(CREW, world.time)
/mob/dead/attackby(obj/item/W, mob/user)
if(istype(W,/obj/item/weapon/book/tome))
@@ -146,15 +159,30 @@ Works together with spawning an observer, noted above.
return 1
/mob/proc/ghostize(var/can_reenter_corpse = 1)
if(key)
if(ckey)
var/mob/dead/observer/ghost = new(src) //Transfer safety to observer spawning proc.
ghost.can_reenter_corpse = can_reenter_corpse
ghost.timeofdeath = src.stat == DEAD ? src.timeofdeath : world.time
ghost.key = key
//This is duplicated for robustness in cases where death might not be called.
//It is also set in the mob/death proc
if (isanimal(src))
set_death_time(ANIMAL, world.time)
else if (ispAI(src) || isdrone(src))
set_death_time(MINISYNTH, world.time)
else
set_death_time(CREW, world.time)//Crew is the fallback
ghost.ckey = ckey
ghost.client = client
ghost.initialise_postkey()
if(ghost.client)
ghost.client.time_died_as_mouse = ghost.timeofdeath
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/dead/observer/verb/toggle_antagHUD // Poor guys, don't know what they are missing!
if(!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/dead/observer/verb/toggle_antagHUD // Poor guys, don't know what they are missing!
return ghost
/*
@@ -429,11 +457,11 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
src << "<span class='warning'>You may not spawn as a mouse on this Z-level.</span>"
return
var/timedifference = world.time - client.time_died_as_mouse
if(client.time_died_as_mouse && timedifference <= mouse_respawn_time * 600)
var/timedifference_text
timedifference_text = time2text(mouse_respawn_time * 600 - timedifference,"mm:ss")
src << "<span class='warning'>You may only spawn again as a mouse more than [mouse_respawn_time] minutes after your death. You have [timedifference_text] left.</span>"
var/timedifference = world.time - get_death_time(ANIMAL)//get/set death_time functions are in mob_helpers.dm
if(timedifference <= RESPAWN_ANIMAL)
var/timedifference_text = time2text(RESPAWN_ANIMAL - timedifference,"mm:ss")
var/basetime = time2text(RESPAWN_ANIMAL,"mm:ss")
src << "<span class='warning'>You may only spawn again as a mouse more than [basetime] minutes after your death. You have [timedifference_text] left.</span>"
return
var/response = alert(src, "Are you -sure- you want to become a mouse?","Are you sure you want to squeek?","Squeek!","Nope!")
+6
View File
@@ -80,6 +80,12 @@
healths.icon_state = "health6"
timeofdeath = world.time
if (isanimal(src))
set_death_time(ANIMAL, world.time)
else if (ispAI(src) || isdrone(src))
set_death_time(MINISYNTH, world.time)
else if (isliving(src))
set_death_time(CREW, world.time)//Crew is the fallback
if(mind) mind.store_memory("Time of death: [worldtime2text()]", 0)
living_mob_list -= src
dead_mob_list |= src
@@ -99,7 +99,7 @@
src << "<span class='danger'>That verb is not currently permitted.</span>"
return
if (!src.stat)
if (!src.stat || !client)
return
if (usr != src)
@@ -108,30 +108,22 @@
if(jobban_isbanned(src,"Cyborg"))
usr << "<span class='danger'>You are banned from playing synthetics and cannot spawn as a drone.</span>"
return
if(!MayRespawn(1))
return
var/deathtime = world.time - src.timeofdeath
var/deathtime = world.time - get_death_time(MINISYNTH)//get/set death_time functions are in mob_helpers.dm
if(istype(src,/mob/dead/observer))
var/mob/dead/observer/G = src
if(G.has_enabled_antagHUD == 1 && config.antag_hud_restricted)
usr << "<span class='notice'>Upon using the antagHUD you forfeighted the ability to join the round.</span>"
return
var/deathtimeminutes = round(deathtime / 600)
var/pluralcheck = "minute"
if(deathtimeminutes == 0)
pluralcheck = ""
else if(deathtimeminutes == 1)
pluralcheck = " [deathtimeminutes] minute and"
else if(deathtimeminutes > 1)
pluralcheck = " [deathtimeminutes] minutes and"
var/deathtimeseconds = round((deathtime - deathtimeminutes * 600) / 10,1)
if (deathtime < 6000)
usr << "You have been dead for[pluralcheck] [deathtimeseconds] seconds."
usr << "You must wait 10 minutes to respawn as a drone!"
if (deathtime < RESPAWN_MINISYNTH)
var/timedifference_text = time2text(RESPAWN_MINISYNTH - deathtime,"mm:ss")
var/basetime = time2text(RESPAWN_MINISYNTH,"mm:ss")
usr << "<span class='warning'>You may only spawn again as a drone more than [basetime] minutes after your death. You have [timedifference_text] left.</span>"
return
var/list/all_fabricators = list()
+23 -14
View File
@@ -15,7 +15,19 @@
spellremove(src)
for(var/infection in viruses)
qdel(infection)
ghostize()
//Added this to prevent nonliving mobs from ghostising
//The only non 'living' mobs are:
//observers (ie ghosts),
//new_player, an abstraction used to handle people who are sitting in the lobby
//Freelook, an abstraction used to handle the AI looking through cameras, and possibly remote viewing mutation
//None of these mobs can 'die' in any sense, and none of them should be able to become ghosts.
//Ghosts are the only ones that even technically 'exist' and aren't just an abstraction using mob code for convenience
if (istype(src, /mob/living))
ghostize()
..()
/mob/proc/remove_screen_obj_references()
@@ -365,6 +377,9 @@
set name = "Respawn"
set category = "OOC"
if (!client)
return//This shouldnt happen
if (!( config.abandon_allowed ))
usr << "<span class='notice'>Respawn is disabled.</span>"
return
@@ -375,25 +390,19 @@
usr << "<span class='notice'>Respawn is disabled for this roundtype.</span>"
return
else
var/deathtime = world.time - src.timeofdeath
if(istype(src,/mob/dead/observer))
var/mob/dead/observer/G = src
if(G.has_enabled_antagHUD == 1 && config.antag_hud_restricted)
usr << "\blue <B>Upon using the antagHUD you forfeighted the ability to join the round.</B>"
return
var/deathtimeminutes = round(deathtime / 600)
var/pluralcheck = "minute"
if(deathtimeminutes == 0)
pluralcheck = ""
else if(deathtimeminutes == 1)
pluralcheck = " [deathtimeminutes] minute and"
else if(deathtimeminutes > 1)
pluralcheck = " [deathtimeminutes] minutes and"
var/deathtimeseconds = round((deathtime - deathtimeminutes * 600) / 10,1)
usr << "You have been dead for[pluralcheck] [deathtimeseconds] seconds."
if (deathtime < 18000)
usr << "You must wait 30 minutes to respawn!"
var/deathtime = world.time - get_death_time(CREW)//get/set death_time functions are in mob_helpers.dm
if (deathtime < RESPAWN_CREW)
var/timedifference_text = time2text(RESPAWN_CREW - deathtime,"mm:ss")
var/basetime = time2text(RESPAWN_CREW,"mm:ss")
usr << "<span class='warning'>You may only respawn than [basetime] minutes after your death. You have [timedifference_text] left.</span>"
return
else
usr << "You can respawn now, enjoy your new life!"
+28
View File
@@ -117,6 +117,11 @@
return 1
return 0
/proc/isdrone(A)
if(istype(A, /mob/living/silicon/robot/drone))
return 1
return 0
/proc/iscarbon(A)
if(istype(A, /mob/living/carbon))
return 1
@@ -937,4 +942,27 @@ proc/is_blind(A)
return null//If we get here, the holder must be buried many layers deep in nested containers. Shouldn't happen
//This proc retrieves the relevant time of death from
/mob/proc/get_death_time(var/which)
var/datum/preferences/P
if (client)
P = client.prefs
else if (ckey)
P = preferences_datums[ckey]
else return null
return P.time_of_death[which]
/mob/proc/set_death_time(var/which, var/value)
var/datum/preferences/P
if (client)
P = client.prefs
else if (ckey)
P = preferences_datums[ckey]
else
return 0
P.time_of_death[which] = value
return 1
#undef SAFE_PERP
+3 -3
View File
@@ -107,8 +107,7 @@
if(alert(src,"Are you sure you wish to observe? You will have to wait 30 minutes before being able to respawn!","Player Setup","Yes","No") == "Yes")
if(!client) return 1
var/mob/dead/observer/observer = new()
var/mob/dead/observer/observer = new /mob/dead/observer(src)
spawning = 1
src << sound(null, repeat = 0, wait = 0, volume = 85, channel = 1) // MAD JAMS cant last forever yo
@@ -134,7 +133,8 @@
observer.name = observer.real_name
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/dead/observer/verb/toggle_antagHUD // Poor guys, don't know what they are missing!
observer.key = key
observer.ckey = ckey
observer.initialise_postkey()
qdel(src)
return 1