Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempts to fix set_species causing full heals #36706

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/datums/diseases/mega_kingston.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ Stage 3 - u r now catbeest
if(prob(1) && prob(50))
var/mob/living/carbon/human/H=affected_mob
to_chat(H, "<span class=\"warning\">You feel a wave of extreme pain and uncleanliness as your body morphs.</span>")
H.set_species("Tajaran")
H.set_species("Tajaran", transfer_damage = TRUE)
for(var/obj/item/W in H)
H.drop_from_inventory(W)
// TODO:
// ghostize()
// StartAI(hostile=1,ranged=0)
// StartAI(hostile=1,ranged=0)
4 changes: 2 additions & 2 deletions code/game/dna/genes/goon_disabilities.dm
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,11 @@
to_chat(H, "<span class='warning'>You have no flesh left to melt!</span>")
return 0
if(isvox(H))
H.set_species("Skeletal Vox")
H.set_species("Skeletal Vox", transfer_damage = TRUE)
H.regenerate_icons()
H.visible_message("<span class='danger'>[H.name]'s flesh melts right off! Holy shit!</span>")
H.drop_all()
else if(H.set_species("Skellington"))
else if(H.set_species("Skellington", transfer_damage = TRUE))
H.regenerate_icons()
H.visible_message("<span class='danger'>[H.name]'s flesh melts right off! Holy shit!</span>")
H.drop_all()
Expand Down
2 changes: 1 addition & 1 deletion code/game/dna/genes/monkey.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

var/mob/living/carbon/human/O = new(src)
if(Mo.greaterform)
O.set_species(Mo.greaterform)
O.set_species(Mo.greaterform) //Damage transfer is handled later in the code
Mo.transferImplantsTo(O)

if (M.dna.GetUIState(DNA_UI_GENDER))
Expand Down
8 changes: 4 additions & 4 deletions code/game/objects/items/weapons/dice.dm
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
to_chat(user, "<span class=sinister><B>A natural failure, your poor roll has cursed you. Better luck next time! </span></B>")
h.flash_eyes(visual = 1)
if(h.species.name != "Tajaran")
if(h.set_species("Tajaran"))
if(h.set_species("Tajaran", transfer_damage = TRUE))
h.regenerate_icons()
to_chat(user, "<span class=danger><B>You have been turned into a disgusting catbeast! </span></B>")
else
Expand Down Expand Up @@ -219,23 +219,23 @@
switch(pick(1,2,3))
if(1)
if(h.species.name != "Unathi")
if(h.set_species("Unathi"))
if(h.set_species("Unathi", transfer_damage = TRUE))
h.regenerate_icons()
to_chat(user, "<span class=danger><B>You have been turned into a disgusting lizard! </span></B>")
else
for(var/datum/organ/external/E in h.get_organs(LIMB_LEFT_ARM, LIMB_RIGHT_ARM)) //Someone who has already become a lizard can't get out of receiving a curse and so they lose their arms instead
E.droplimb(1)
if(2)
if(h.species.name != "Skrell")
if(h.set_species("Skrell"))
if(h.set_species("Skrell", transfer_damage = TRUE))
h.regenerate_icons()
to_chat(user, "<span class=danger><B>You have been turned into a disgusting squidman! </span></B>")
else
for(var/datum/organ/external/E in h.get_organs(LIMB_LEFT_ARM, LIMB_RIGHT_ARM)) //Someone who has already become a squid can't get out of receiving a curse and so they lose their arms instead
E.droplimb(1)
if(3)
if(h.species.name != "Vox")
if(h.set_species("Vox"))
if(h.set_species("Vox", transfer_damage = TRUE))
h.regenerate_icons()
to_chat(user, "<span class=danger><B>You have been turned into a dumb, diseased bird! </span></B>")
else
Expand Down
45 changes: 42 additions & 3 deletions code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@
multicolor_skin_g = rand(0,255)
multicolor_skin_b = rand(0,255)

create_reagents(1000) //Moved it here because it could sometimes lead to errors in set_species() in certain cases

if(!src.species)
if(new_species_name)
src.set_species(new_species_name)
Expand All @@ -157,8 +159,6 @@
default_language = get_default_language()
init_language = default_language

create_reagents(1000)

if(!dna)
dna = new /datum/dna(null)
dna.species=species.name
Expand Down Expand Up @@ -1214,11 +1214,43 @@
else
to_chat(usr, "<span class='info'>You moved while counting. Try again.</span>")

/mob/living/carbon/human/proc/set_species(var/new_species_name, var/force_organs, var/default_colour)
//Record_organ datum, stores as much info as it can about each organ
/datum/record_organ
var/name

/datum/record_organ/external
var/brute_damage
var/burn_damage
var/list/wounds = list()
var/status_flags

/datum/record_organ/internal
boy2mantwicethefam marked this conversation as resolved.
Show resolved Hide resolved
var/damage
var/robotic

/mob/living/carbon/human/proc/set_species(var/new_species_name, var/force_organs, var/default_colour, var/transfer_damage = 0, var/mob/living/carbon/human/target_override)
set waitfor = FALSE
// Target override, in case we want to transfer stuff from a previous mob (the override) to the current one.
// Only applied to the damage transfer system.
var/mob/living/carbon/human/target = src
if(target_override && istype(target_override, /mob/living/carbon/human))
target = target_override
//Store all of the current mob damages, they will get randomly redistributed to the new mob
var/brute_damage = target.getBruteLoss()
var/burn_damage = target.getFireLoss()
var/oxy_damage = target.getOxyLoss()
var/tox_damage = target.getToxLoss()
var/clone_damage = target.getCloneLoss()

if(new_species_name)
if(src.species && src.species.name && (src.species.name == new_species_name))
if(transfer_damage)
if(target != src) //It's a different mob, let's apply the damage
take_overall_damage(brute_damage, burn_damage, no_damage_change = TRUE)
adjustOxyLoss(oxy_damage)
adjustToxLoss(tox_damage)
adjustCloneLoss(clone_damage)
handle_organs(TRUE)
return
else if(src.dna)
new_species_name = src.dna.species
Expand Down Expand Up @@ -1285,6 +1317,13 @@
meat_type = species.meat_type
src.movement_speed_modifier = species.move_speed_multiplier

//Now re-apply all the damages from before the transformation
if(transfer_damage)
take_overall_damage(brute_damage, burn_damage, no_damage_change = TRUE)
adjustOxyLoss(oxy_damage)
adjustToxLoss(tox_damage)
adjustCloneLoss(clone_damage)
handle_organs(TRUE)
if(dna)
dna.species = new_species_name

Expand Down
13 changes: 7 additions & 6 deletions code/modules/mob/living/carbon/human/human_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,12 @@ In most cases it makes more sense to use apply_damage() instead! And make sure t
UpdateDamageIcon()

// damage MANY external organs, in random order
/mob/living/carbon/human/take_overall_damage(var/brute, var/burn, var/sharp = 0, var/edge = 0, var/used_weapon = null)
if(species && species.burn_mod)
burn = burn*species.burn_mod
if(species && species.brute_mod)
brute = brute*species.brute_mod
/mob/living/carbon/human/take_overall_damage(var/brute, var/burn, var/sharp = 0, var/edge = 0, var/used_weapon = null, var/no_damage_change = FALSE)
if(!no_damage_change)
if(species && species.burn_mod)
burn = burn*species.burn_mod
if(species && species.brute_mod)
brute = brute*species.brute_mod

if(status_flags & GODMODE)
return 0 //godmode
Expand All @@ -268,7 +269,7 @@ In most cases it makes more sense to use apply_damage() instead! And make sure t
var/brute_was = picked.brute_dam
var/burn_was = picked.burn_dam

update |= picked.take_damage(brute,burn,sharp,edge,used_weapon)
update |= picked.take_damage(brute,burn,sharp,edge,used_weapon, no_damage_modifier = no_damage_change)
brute -= (picked.brute_dam - brute_was)
burn -= (picked.burn_dam - burn_was)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
qdel(src)
return
else
if(set_species("Ghoul"))
if(set_species("Ghoul", transfer_damage = TRUE))
to_chat(src, "<span class = 'notice'>You feel strangely at peace.</span>")
spawn(1 SECONDS)
setCloneLoss(0)
Expand Down
10 changes: 6 additions & 4 deletions code/modules/mob/transform_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@
comm.ai += O
if(mind)
mind.transfer_to(O)
O.mind.assigned_role = "AI"
else
O.key = key
O.verbs += /mob/living/silicon/ai/proc/show_laws_verb
O.verbs += /mob/living/silicon/ai/proc/ai_statuschange
O.job = "AI"
O.mind.assigned_role = "AI"
mob_rename_self(O,"ai", null, 1)
. = O
if(del_mob)
Expand Down Expand Up @@ -187,7 +187,8 @@
if(!skipnaming)
spawn()
O.Namepick()
O.mind.assigned_role = "Cyborg"
if(O.mind) //Otherwise it would runtime if done against mindless mobs
O.mind.assigned_role = "Cyborg"
qdel(src)
return O

Expand Down Expand Up @@ -215,7 +216,8 @@
if(!skipnaming)
spawn()
O.Namepick()
O.mind.assigned_role = "Mobile MMI"
if(O.mind)
O.mind.assigned_role = "Mobile MMI"
qdel(src)
return O

Expand Down Expand Up @@ -291,7 +293,7 @@
new_human.randomise_appearance_for(new_human.gender)
if(!new_species || !(new_species in all_species))
new_species = pick(whitelisted_species)
new_human.set_species(new_species)
new_human.set_species(new_species, transfer_damage = TRUE, target_override = src) //Transfer damage from the current mob to the new one
new_human.regenerate_icons()
if(isliving(src))
var/mob/living/L = src
Expand Down
27 changes: 14 additions & 13 deletions code/modules/organs/organ_external.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
new I(owner.loc)
droplimb(1, spawn_limb = 0, display_message = FALSE)

/datum/organ/external/proc/take_damage(brute, burn, sharp, edge, used_weapon = null, list/forbidden_limbs = list())
/datum/organ/external/proc/take_damage(brute, burn, sharp, edge, used_weapon = null, list/forbidden_limbs = list(), var/no_damage_modifier = FALSE)
if(cosmetic_only)
return
if(owner?.status_flags & GODMODE)
Expand All @@ -165,16 +165,17 @@
if(!is_existing()) //No limb there
return 0

if(!is_organic())
brute *= 0.66 //~2/3 damage for ROBOLIMBS
burn *= (status & (ORGAN_PEG) ? 2 : 0.66) //~2/3 damage for ROBOLIMBS 2x for peg
else
var/datum/species/species = src.species || owner.species
if(species)
if(species.brute_mod)
brute *= species.brute_mod
if(species.burn_mod)
burn *= species.burn_mod
if(!no_damage_modifier)
if(!is_organic())
brute *= 0.66 //~2/3 damage for ROBOLIMBS
burn *= (status & (ORGAN_PEG) ? 2 : 0.66) //~2/3 damage for ROBOLIMBS 2x for peg
else
var/datum/species/species = src.species || owner.species
if(species)
if(species.brute_mod)
brute *= species.brute_mod
if(species.burn_mod)
burn *= species.burn_mod

//If limb took enough damage, try to cut or tear it off
if(body_part != UPPER_TORSO && body_part != LOWER_TORSO) //As hilarious as it is, getting hit on the chest too much shouldn't effectively gib you.
Expand Down Expand Up @@ -1678,8 +1679,8 @@ Note that amputating the affected organ does in fact remove the infection from t
baseicon = 'icons/mob/human_races/o_robot.dmi'
return new /icon(baseicon, "[icon_name]_[gender]")

/datum/organ/external/head/take_damage(brute, burn, sharp, edge, used_weapon = null, list/forbidden_limbs = list())
..(brute, burn, sharp, edge, used_weapon, forbidden_limbs)
/datum/organ/external/head/take_damage(brute, burn, sharp, edge, used_weapon = null, list/forbidden_limbs = list(), no_damage_modifier)
..(brute, burn, sharp, edge, used_weapon, forbidden_limbs, no_damage_modifier)
if(!disfigured)
/*
if(brute_dam > 40)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/reagents/Chemistry-Recipes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4086,11 +4086,11 @@
if(isskellington(H) || isskelevox(H) || islich(H))
bigBoned(H, created_volume)
if(isvox(H)) //Copy paste of the melt power, ack ack
H.set_species("Skeletal Vox")
H.set_species("Skeletal Vox", transfer_damage = TRUE)
H.regenerate_icons()
H.visible_message("<span class='danger'>[H.name]'s skeleton jumps right out of their skin, forcefully!</span>")
H.drop_all()
else if(H.set_species("Skellington"))
else if(H.set_species("Skellington", transfer_damage = TRUE))
H.regenerate_icons()
H.visible_message("<span class='danger'>[H.name]'s skeleton jumps right out of their skin, forcefully!</span>")
H.drop_all()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/randomized_reagent.dm
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
return

if(tf_catbeast && !iscatbeast(H))
H.set_species("Tajaran")
H.set_species("Tajaran", transfer_damage = TRUE)
H.regenerate_icons()
H.emote("me", MESSAGE_HEAR, pick("meows", "mews"))
playsound(H, 'sound/voice/catmeow.ogg', 100)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/spells/general/shapeshift.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
if(humanform)
identity = user.dna.Clone()
appearance = user.my_appearance.Copy()
user.set_species("Vampire")
user.set_species("Vampire", transfer_damage = TRUE)
user.name = "Nosferatu"
user.real_name = "Nosferatu"
humanform = FALSE
else
user.set_species(identity.species, 0)
user.set_species(identity.species, 0, transfer_damage = TRUE)
user.set_default_language(user.init_language)
user.name = identity.real_name
user.real_name = identity.real_name
Expand Down
14 changes: 7 additions & 7 deletions code/modules/virus2/effect/stage_4.dm
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
E.createwound(CUT, pick(2, 4, 6, 8, 10))

if(prob(30))
if(H.set_species("Skellington"))
if(H.set_species("Skellington", transfer_damage = TRUE))
to_chat(mob, "<span class='warning'>A massive amount of flesh sloughs off your bones!</span>")
H.regenerate_icons()

Expand Down Expand Up @@ -1106,7 +1106,7 @@
/datum/disease2/effect/catbeast/activate(var/mob/living/mob)
if(ishuman(mob) && !iscatbeast(mob))
var/mob/living/carbon/human/H = mob
H.set_species("Tajaran")
H.set_species("Tajaran", transfer_damage = TRUE)
H.regenerate_icons()


Expand All @@ -1131,7 +1131,7 @@
/datum/disease2/effect/vox/activate(var/mob/living/mob)
if(ishuman(mob) && !isvox(mob))
var/mob/living/carbon/human/H = mob
H.set_species("Vox")
H.set_species("Vox", transfer_damage = TRUE)
H.regenerate_icons()


Expand All @@ -1144,7 +1144,7 @@
/datum/disease2/effect/human/activate(var/mob/living/mob)
if(ishuman(mob) && !isjusthuman(mob))
var/mob/living/carbon/human/H = mob
H.set_species("Human")
H.set_species("Human", transfer_damage = TRUE)
H.regenerate_icons()

/datum/disease2/effect/lizard
Expand All @@ -1156,7 +1156,7 @@
/datum/disease2/effect/lizard/activate(var/mob/living/mob)
if(ishuman(mob) && !isunathi(mob))
var/mob/living/carbon/human/H = mob
H.set_species("Unathi")
H.set_species("Unathi", transfer_damage = TRUE)
H.regenerate_icons()

/datum/disease2/effect/insectoid
Expand All @@ -1168,7 +1168,7 @@
/datum/disease2/effect/insectoid/activate(var/mob/living/mob)
if(ishuman(mob) && !isinsectoid(mob))
var/mob/living/carbon/human/H = mob
H.set_species("Insectoid")
H.set_species("Insectoid", transfer_damage = TRUE)
H.regenerate_icons()
if(prob(5))
mob.say("How about if I sleep a little bit longer and forget all this nonsense.")
Expand All @@ -1182,7 +1182,7 @@
/datum/disease2/effect/grey/activate(var/mob/living/mob)
if(ishuman(mob) && !isgrey(mob))
var/mob/living/carbon/human/H = mob
H.set_species("Grey")
H.set_species("Grey", transfer_damage = TRUE)
H.regenerate_icons()

/*
Expand Down
Loading