Fix remaining reforming bugs

This commit is contained in:
TheGreatKitsune
2022-12-10 14:49:30 -06:00
parent 2fe9e2327f
commit 926f7d1e63
5 changed files with 114 additions and 19 deletions

View File

@@ -15,7 +15,7 @@ SUBSYSTEM_DEF(mobs)
var/list/currentrun = list()
var/log_extensively = FALSE
var/list/timelog = list()
var/slept_mobs = 0
var/list/process_z = list()
@@ -43,7 +43,12 @@ SUBSYSTEM_DEF(mobs)
else if(M.low_priority && !(M.loc && process_z[get_z(M)]))
slept_mobs++
continue
//CHOMPEdit Start - Enable pausing mobs (For transformation, holding until reformation, etc.)
else if(!M.enabled)
slept_mobs++
continue
//CHOMPEdit End
M.Life(times_fired)
if (MC_TICK_CHECK)
@@ -58,14 +63,14 @@ SUBSYSTEM_DEF(mobs)
log_world(msg)
return
msg += "Lists: currentrun: [currentrun.len], mob_list: [mob_list.len]\n"
if(!currentrun.len)
msg += "!!The subsystem just finished the mob_list list, and currentrun is empty (or has never run).\n"
msg += "!!The info below is the tail of mob_list instead of currentrun.\n"
var/datum/D = currentrun.len ? currentrun[currentrun.len] : mob_list[mob_list.len]
msg += "Tail entry: [describeThis(D)] (this is likely the item AFTER the problem item)\n"
var/position = mob_list.Find(D)
if(!position)
msg += "Unable to find context of tail entry in mob_list list.\n"
@@ -90,4 +95,4 @@ SUBSYSTEM_DEF(mobs)
/datum/controller/subsystem/mobs/critfail()
..()
log_recent()
log_recent()

View File

@@ -291,7 +291,7 @@
/obj/item/weapon/shockpaddles/proc/can_revive(mob/living/carbon/human/H) //This is checked right before attempting to revive
var/obj/item/organ/internal/brain/brain = H.internal_organs_by_name[O_BRAIN]
if(H.should_have_organ(O_BRAIN) && (!brain || brain.defib_timer <= 0 ) )
if(H.should_have_organ(O_BRAIN) && (!brain || (istype(brain) && brain.defib_timer <= 0 ) ) ) //CHOMPEdit - Fix a runtime when brain is an MMI
return "buzzes, \"Resuscitation failed - Excessive neural degeneration. Further attempts futile.\""
H.updatehealth()

View File

@@ -284,6 +284,10 @@
return
if(OldLoc in contents)
return //Someone dropping something (or being stripdigested)
//CHOMPEdit Start - Prevent reforming causing a lot of log spam/sounds
if(istype(OldLoc, /mob/observer) || istype(OldLoc, /obj/item/device/mmi))
return //Someone getting reformed most likely (And if not, uh... shouldn't happen anyways?)
//CHOMPEdit end
//Generic entered message
to_chat(owner,"<span class='notice'>[thing] slides into your [lowertext(name)].</span>")
@@ -713,6 +717,7 @@
//CHOMPEdit Start - Reverts TF on death. This fixes a bug with posibrains or similar, and also makes reforming easier.
if(M.tf_mob_holder && M.tf_mob_holder.loc == M)
M.tf_mob_holder.ckey = M.ckey
M.tf_mob_holder.enabled = TRUE
M.tf_mob_holder.loc = M.loc
M.tf_mob_holder.forceMove(M.loc)
QDEL_LIST_NULL(M.tf_mob_holder.vore_organs)
@@ -732,7 +737,7 @@
if(is_vore_predator(M))
M.release_vore_contents(include_absorbed = TRUE, silent = TRUE)
var/hasMMI = FALSE // CHOMPEdit - Adjust how MMI's are handled
var/obj/item/device/mmi/hasMMI // CHOMPEdit - Adjust how MMI's are handled
//Drop all items into the belly.
if(config.items_survive_digestion)
@@ -782,6 +787,7 @@
R.mmi.brainmob.languages = R.languages
R.mmi.brainmob.remove_language("Robot Talk")
hasMMI = R.mmi
M.mind.transfer_to(hasMMI.brainmob)
R.mmi = null
else if(!R.shell) // Shells don't have brainmobs in their MMIs.
to_chat(R, "<span class='danger'>Oops! Something went very wrong, your MMI was unable to receive your mind. You have been ghosted. Please make a bug report so we can fix this bug.</span>")
@@ -789,17 +795,17 @@
qdel(R)
return
if(hasMMI)
var/obj/item/device/mmi/MMI = hasMMI
M.mind.transfer_to(MMI.brainmob)
MMI.body_backup = M
M.forceMove(MMI)
if(istype(hasMMI))
hasMMI.body_backup = M
M.enabled = FALSE
M.forceMove(hasMMI)
else
//Another CHOMPEdit started here. I left the comment here, though obviously we're doing a lot more now as well.
var/mob/observer/G = M.ghostize(FALSE) //CHOMPEdit start. Make sure they're out, so we can copy attack logs and such.
if(G)
G.forceMove(src)
G.body_backup = M
M.enabled = FALSE
M.forceMove(G)
else
qdel(M)

View File

@@ -815,7 +815,7 @@
if(isobserver(target))
var/mob/observer/T = target
if(!ismob(T.body_backup) || prevent_respawns.Find(T.mind.name))
if(!ismob(T.body_backup) || prevent_respawns.Find(T.mind.name) || ispAI(T.body_backup))
to_chat(user,"<span class='warning'>They don't seem to be reformable!</span>")
return TRUE
@@ -826,16 +826,60 @@
if(isliving(T.body_backup))
var/mob/living/body_backup = T.body_backup
body_backup.revive()
if(ishuman(body_backup))
var/mob/living/carbon/human/H = body_backup
body_backup.adjustBruteLoss(-6)
body_backup.adjustFireLoss(-6)
body_backup.setOxyLoss(0)
if(H.isSynthetic())
H.adjustToxLoss(-H.getToxLoss())
else
H.adjustToxLoss(-6)
body_backup.adjustCloneLoss(-6)
body_backup.updatehealth()
// Now we do the check to see if we should revive...
var/should_proceed_with_revive = TRUE
var/obj/item/organ/internal/brain/brain = H.internal_organs_by_name[O_BRAIN]
should_proceed_with_revive &&= !H.should_have_organ(O_BRAIN) || (brain && (!istype(brain) || brain.defib_timer > 0))
if(!H.isSynthetic())
should_proceed_with_revive &&= !(HUSK in H.mutations) && H.can_defib
if(should_proceed_with_revive)
for(var/organ_tag in H.species.has_organ)
var/obj/item/organ/O = H.species.has_organ[organ_tag]
var/vital = initial(O.vital) //check for vital organs
if(vital)
O = H.internal_organs_by_name[organ_tag]
if(!O || O.damage > O.max_damage)
should_proceed_with_revive = FALSE
break
if(should_proceed_with_revive)
dead_mob_list.Remove(H)
if((H in living_mob_list) || (H in dead_mob_list))
WARNING("Mob [H] was defibbed but already in the living or dead list still!")
living_mob_list += H
H.timeofdeath = 0
H.set_stat(UNCONSCIOUS) //Life() can bring them back to consciousness if it needs to.
H.failed_last_breath = 0 //So mobs that died of oxyloss don't revive and have perpetual out of breath.
H.reload_fullscreen()
else
body_backup.revive()
body_backup.forceMove(T.loc)
body_backup.enabled = TRUE
body_backup.ajourn = 0
body_backup.key = T.key
body_backup.teleop = null
T.body_backup = null
host.vore_selected.release_specific_contents(T, TRUE)
if(istype(body_backup, /mob/living/simple_mob))
var/mob/living/simple_mob/sm = body_backup
if(sm.icon_rest && sm.resting)
sm.icon_state = sm.icon_rest
else
sm.icon_state = sm.icon_living
T.update_icon()
announce_ghost_joinleave(T.mind, 0, "They now occupy their body again.")
if(istype(target,/obj/item/device/mmi)) // A good bit of repeated code, sure, but... cleanest way to do this.
else if(istype(target,/obj/item/device/mmi)) // A good bit of repeated code, sure, but... cleanest way to do this.
var/obj/item/device/mmi/MMI = target
if(!ismob(MMI.body_backup) || !MMI.brainmob.mind || prevent_respawns.Find(MMI.brainmob.mind.name))
to_chat(user,"<span class='warning'>They don't seem to be reformable!</span>")
@@ -847,19 +891,28 @@
if(isliving(MMI.body_backup))
var/mob/living/body_backup = MMI.body_backup
body_backup.revive()
body_backup.enabled = TRUE
body_backup.forceMove(MMI.loc)
body_backup.ajourn = 0
body_backup.teleop = null
//And now installing the MMI into the body...
if(isrobot(body_backup)) //Just do the reverse of getting the MMI pulled out in /obj/belly/proc/digestion_death
var/mob/living/silicon/robot/R = body_backup
R.revive()
MMI.brainmob.mind.transfer_to(R)
MMI.loc = R
R.mmi = MMI
R.mmi.brainmob.add_language("Robot Talk")
else //reference /datum/surgery_step/robotics/install_mmi/end_step
var/obj/item/organ/internal/mmi_holder/holder = new(body_backup, 1)
var/obj/item/organ/internal/mmi_holder/holder
if(istype(MMI, /obj/item/device/mmi/digital/posibrain))
var/obj/item/organ/internal/mmi_holder/posibrain/holdertmp = new(body_backup, 1)
holder = holdertmp
else if(istype(MMI, /obj/item/device/mmi/digital/robot))
var/obj/item/organ/internal/mmi_holder/robot/holdertmp = new(body_backup, 1)
holder = holdertmp
else
holder = new(body_backup, 1)
body_backup.internal_organs_by_name["brain"] = holder
MMI.loc = holder
holder.stored_mmi = MMI
@@ -869,6 +922,36 @@
MMI.brainmob.mind.transfer_to(body_backup)
body_backup.languages = MMI.brainmob.languages
//You've hopefully already named yourself, so... not implementing that bit.
var/mob/living/carbon/human/H = body_backup
body_backup.adjustBruteLoss(-6, TRUE)
body_backup.adjustFireLoss(-6, TRUE)
body_backup.setOxyLoss(0)
H.adjustToxLoss(-H.getToxLoss())
body_backup.adjustCloneLoss(-6)
body_backup.updatehealth()
// Now we do the check to see if we should revive...
var/should_proceed_with_revive = TRUE
var/obj/item/organ/internal/brain/brain = H.internal_organs_by_name[O_BRAIN]
should_proceed_with_revive &&= !H.should_have_organ(O_BRAIN) || (brain && brain.defib_timer > 0 )
if(should_proceed_with_revive)
for(var/organ_tag in H.species.has_organ)
var/obj/item/organ/O = H.species.has_organ[organ_tag]
var/vital = initial(O.vital) //check for vital organs
if(vital)
O = H.internal_organs_by_name[organ_tag]
if(!O || O.damage > O.max_damage)
should_proceed_with_revive = FALSE
break
if(should_proceed_with_revive)
dead_mob_list.Remove(H)
if((H in living_mob_list) || (H in dead_mob_list))
WARNING("Mob [H] was defibbed but already in the living or dead list still!")
living_mob_list += H
H.timeofdeath = 0
H.set_stat(UNCONSCIOUS) //Life() can bring them back to consciousness if it needs to.
H.failed_last_breath = 0 //So mobs that died of oxyloss don't revive and have perpetual out of breath.
H.reload_fullscreen()
MMI.body_backup = null
return TRUE
//CHOMPEdit End

View File

@@ -1,3 +1,4 @@
/mob
var/voice_freq = 42500 // Preference for character voice frequency
var/list/voice_sounds_list = list() // The sound list containing our voice sounds!
var/list/voice_sounds_list = list() // The sound list containing our voice sounds!
var/enabled = TRUE //Pauses a mob if disabled (Prevents life ticks from happening)