Skip to content

Commit

Permalink
Merge pull request tgstation#18131 from coiax/lazy-cloning
Browse files Browse the repository at this point in the history
Clone pod code tidying and bugfixes
  • Loading branch information
Jordie0608 committed Jun 3, 2016
2 parents 4c8f8ae + e17d1f2 commit bddfbcb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
19 changes: 19 additions & 0 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1369,3 +1369,22 @@ proc/pick_closest_path(value)
sleep(world.tick_lag*4)
//you might be thinking of adding more steps to this, or making it use a loop and a counter var
// not worth it.

/proc/flash_color(mob_or_client, color="#960000", time=20)
var/client/C
if(istype(mob_or_client, /mob))
var/mob/M = mob_or_client
if(M.client)
C = M.client
else
return
else if(istype(mob_or_client, /client))
C = mob_or_client

if(!istype(C))
return

var/old_color = C.color
C.color = "#960000"
spawn(0)
animate(C, color = old_color, time = 20)
31 changes: 22 additions & 9 deletions code/game/machinery/cloning.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#define CLONE_INITIAL_DAMAGE 190 //Clones in clonepods start with 190 cloneloss damage and 190 brainloss damage, thats just logical

#define SPEAK(message) radio.talk_into(src, message, radio_channel)
#define SPEAK(message) radio.talk_into(src, message, radio_channel, get_spans())

/obj/machinery/clonepod
anchored = 1
Expand All @@ -15,6 +15,7 @@
icon = 'icons/obj/cloning.dmi'
icon_state = "pod_0"
req_access = list(access_genetics) //For premature unlocking.
verb_say = "states"
var/heal_level = 90 //The clone is released once its health reaches this level.
var/locked = FALSE
var/obj/machinery/computer/cloning/connected = null //So we remember the connected clone machine.
Expand Down Expand Up @@ -181,6 +182,10 @@
H << "<span class='notice'><b>Consciousness slowly creeps over you \
as your body regenerates.</b><br><i>So this is what cloning \
feels like?</i></span>"
else if(grab_ghost_when == CLONER_MATURE_CLONE)
clonemind.current << "<span class='notice'>Your body is \
beginning to regenerate in a cloning pod. You will \
become conscious when it is complete.</span>"

H.hardset_dna(ui, se, H.real_name, null, mrace, features)
if(H)
Expand All @@ -201,12 +206,12 @@
go_out()

else if((occupant) && (occupant.loc == src))
if((occupant.stat == DEAD) || (occupant.suiciding) || !occupant.key || occupant.hellbound) //Autoeject corpses and suiciding dudes.
if((occupant.stat == DEAD) || (occupant.suiciding) || occupant.hellbound) //Autoeject corpses and suiciding dudes.
locked = FALSE
go_out()
connected_message("Clone Rejected: Deceased.")
SPEAK("The cloning of <b>[occupant]</b> has been aborted due to \
rejection.")
SPEAK("The cloning of <b>[occupant.real_name]</b> has been \
aborted due to unrecoverable tissue failure.")

else if(occupant.cloneloss > (100 - heal_level))
occupant.Paralyse(4)
Expand All @@ -229,7 +234,7 @@

else if((occupant.cloneloss <= (100 - heal_level)) && (!eject_wait))
connected_message("Cloning Process Complete.")
SPEAK("The cloning cycle of <b>[occupant]</b> is complete!")
SPEAK("The cloning cycle of <b>[occupant]</b> is complete.")
locked = FALSE
go_out()

Expand Down Expand Up @@ -303,8 +308,9 @@
return

if (mess) //Clean that mess and dump those gibs!
mess = 0
mess = FALSE
gibs(loc)
audible_message("<span class='italics'>You hear a splat.</span>")
icon_state = "pod_0"
return

Expand All @@ -313,6 +319,7 @@

if(grab_ghost_when == CLONER_MATURE_CLONE)
clonemind.transfer_to(occupant)
occupant.grab_ghost()
occupant << "<span class='notice'><b>The world is suddenly bright \
and sudden and loud!</b><br>\
<i>You feel your body weight suddenly, as your mind suddenly \
Expand All @@ -322,7 +329,7 @@
var/turf/T = get_turf(src)
occupant.forceMove(T)
icon_state = "pod_0"
eject_wait = 0 //If it's still set somehow.
eject_wait = FALSE //If it's still set somehow.
occupant.domutcheck() //Waiting until they're out before possible monkeyizing.
occupant = null

Expand All @@ -333,11 +340,17 @@
technician, as your warranty may be affected.")
mess = TRUE
icon_state = "pod_g"
if(occupant.mind != clonemind)
clonemind.transfer_to(occupant)
occupant.grab_ghost() // We really just want to make you suffer.
flash_color(occupant, color="#960000", time=100)
occupant << "<span class='warning'><b>Agony blazes across your \
consciousness as your body is torn apart.</b><br>\
<i>Is this what dying is like? Yes it is.</i></span>"
occupant.ghostize()
spawn(5)
playsound(src.loc, 'sound/machines/warning-buzzer.ogg', 50, 0)
occupant << sound('sound/hallucinations/veryfar_noise.ogg',0,1,50)
spawn(40)
occupant.ghostize()
qdel(occupant)

/obj/machinery/clonepod/relaymove(mob/user)
Expand Down
6 changes: 1 addition & 5 deletions code/game/machinery/doors/airlock_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,7 @@
var/atom/throwtarget
throwtarget = get_edge_target_turf(src, get_dir(src, get_step_away(M, src)))
M << pick(sound('sound/hallucinations/turn_around1.ogg',0,1,50), sound('sound/hallucinations/turn_around2.ogg',0,1,50))
if(M.client)
var/old_color = M.client.color
M.client.color = "#960000"
spawn(0)//animate is a delay, avoid delay, etc
animate(M.client,color = old_color, time = 20)
flash_color(M, color="#960000", time=20)
M.Weaken(2)
M.throw_at_fast(throwtarget, 5, 1,src)
return 0
Expand Down

0 comments on commit bddfbcb

Please sign in to comment.