Changes behind the scene stuff regarding transformation from monkey to human.

-Adds a humanize() proc
-Changes monkeyize() proc to a child of mob/living/carbon (not implemented or tested with anything beside humans, though)
-Adds various options for monkeyize and humanize as binary flags
-Removed all instances of monkey transformation code being copy pasted (dna, changeling, adminverbs) and replaced them with monkeyize(). This fixed various issues with admin-verbs where mobs would ghost after transformation due to invalid use of transfer_to (mind transfer proc).

-Humans will now retain their old name if turned into a monkey and back provided their UE are unchanged
-Transformation from monkey into human will now deal the same amount of damage as human to monkey.

Signed-off-by: dumpdavidson <gtb.schmidt@gmail.com>
This commit is contained in:
dumpdavidson
2013-05-10 17:23:20 +02:00
parent 7111f86a2b
commit 53529ea8f9
8 changed files with 255 additions and 272 deletions
+158 -15
View File
@@ -1,18 +1,26 @@
/mob/living/carbon/human/proc/monkeyize()
/mob/living/carbon/proc/monkeyize(tr_flags = (TR_KEEPITEMS | TR_KEEPVIRUS | TR_DEFAULTMSG), newname = null)
if (monkeyizing)
return
for(var/obj/item/W in src)
if (W==w_uniform) // will be torn
continue
drop_from_inventory(W)
//Handle items on mob
//first implants
var/list/implants = list()
if (tr_flags & TR_KEEPIMPLANTS)
for(var/obj/item/weapon/implant/W in src)
implants += W
//now the rest
if (tr_flags & TR_KEEPITEMS)
for(var/obj/item/W in (src.contents-implants))
drop_from_inventory(W)
//Make mob invisible and spawn animation
regenerate_icons()
monkeyizing = 1
canmove = 0
stunned = 1
icon = null
invisibility = 101
for(var/t in organs)
del(t)
var/atom/movable/overlay/animation = new /atom/movable/overlay( loc )
animation.icon_state = "blank"
animation.icon = 'icons/mob/mob.dmi'
@@ -23,24 +31,159 @@
var/mob/living/carbon/monkey/O = new /mob/living/carbon/monkey( loc )
del(animation)
O.name = "monkey"
// hash the original name?
if (tr_flags & TR_HASHNAME)
O.name = "monkey ([copytext(md5(real_name), 2, 6)])"
O.real_name = "monkey ([copytext(md5(real_name), 2, 6)])"
if (newname) //if there's a name as an argument, always take that one over the current name
O.name = newname
O.real_name = newname
//handle DNA and other attributes
O.dna = dna
dna = null
O.dna.struc_enzymes = setblock(O.dna.struc_enzymes, RACEBLOCK, construct_block(BAD_MUTATION_DIFFICULTY,BAD_MUTATION_DIFFICULTY))
if (!(tr_flags & TR_KEEPSE))
O.dna.struc_enzymes = setblock(O.dna.struc_enzymes, RACEBLOCK, construct_block(BAD_MUTATION_DIFFICULTY,BAD_MUTATION_DIFFICULTY))
if(suiciding)
O.suiciding = suiciding
O.loc = loc
O.viruses = viruses
viruses = list()
for(var/datum/disease/D in O.viruses)
D.affected_mob = O
O.a_intent = "harm"
//keep viruses?
if (tr_flags & TR_KEEPVIRUS)
O.viruses = viruses
viruses = list()
for(var/datum/disease/D in O.viruses)
D.affected_mob = O
//keep damage?
if (tr_flags & TR_KEEPDAMAGE)
O.setToxLoss(getToxLoss())
O.adjustBruteLoss(getBruteLoss())
O.setOxyLoss(getOxyLoss())
O.adjustFireLoss(getFireLoss())
//handle client key and mob so mind.transfer_to doesn't ghostize
if (client)
client.mob = O
if (key)
O.key = key
//re-add implants to new mob
for(var/obj/item/weapon/implant/I in implants)
I.loc = O
I.implanted = O
//transfer mind and delete old mob
if(mind)
mind.transfer_to(O)
if (tr_flags & TR_DEFAULTMSG)
O << "<B>You are now a monkey.</B>"
spawn(0)//To prevent the proc from returning null.
del(src)
updateappearance(O)
return O
////////////////////////// Humanize //////////////////////////////
//Could probably be merged with monkeyize but other transformations got their own procs, too
/mob/living/carbon/proc/humanize(tr_flags = (TR_KEEPITEMS | TR_KEEPVIRUS | TR_DEFAULTMSG), newname = null)
if (monkeyizing)
return
//Handle items on mob
//first implants
var/list/implants = list()
if (tr_flags & TR_KEEPIMPLANTS)
for(var/obj/item/weapon/implant/W in src)
implants += W
//now the rest
if (tr_flags & TR_KEEPITEMS)
for(var/obj/item/W in (src.contents-implants))
u_equip(W)
if (client)
client.screen -= W
if (W)
W.loc = loc
W.dropped(src)
W.layer = initial(W.layer)
// for(var/obj/item/W in src)
// drop_from_inventory(W)
//Make mob invisible and spawn animation
regenerate_icons()
monkeyizing = 1
canmove = 0
stunned = 1
icon = null
invisibility = 101
var/atom/movable/overlay/animation = new( loc )
animation.icon_state = "blank"
animation.icon = 'icons/mob/mob.dmi'
animation.master = src
flick("monkey2h", animation)
sleep(48)
var/mob/living/carbon/human/O = new( loc )
del(animation)
O.gender = (deconstruct_block(getblock(dna.uni_identity, DNA_GENDER_BLOCK), 2)-1) ? MALE : FEMALE
O.dna = dna
dna = null
if (newname) //if there's a name as an argument, always take that one over the current name
O.real_name = newname
else
if ( !(cmptext ("monkey",copytext(O.dna.real_name,1,7)) ) )
O.real_name = O.dna.real_name
else
O.real_name = random_name(O.gender)
O.name = O.real_name
if (!(tr_flags & TR_KEEPSE))
O.dna.struc_enzymes = setblock(O.dna.struc_enzymes, RACEBLOCK, construct_block(1,BAD_MUTATION_DIFFICULTY))
if(suiciding)
O.suiciding = suiciding
O.loc = loc
//keep viruses?
if (tr_flags & TR_KEEPVIRUS)
O.viruses = viruses
viruses = list()
for(var/datum/disease/D in O.viruses)
D.affected_mob = O
//keep damage?
if (tr_flags & TR_KEEPDAMAGE)
O.setToxLoss(getToxLoss())
O.adjustBruteLoss(getBruteLoss())
O.setOxyLoss(getOxyLoss())
O.adjustFireLoss(getFireLoss())
if (client)
client.mob = O
if (key)
O.key = key
//re-add implants to new mob
for(var/obj/item/weapon/implant/I in implants)
I.loc = O
I.implanted = O
if(mind)
mind.transfer_to(O)
O.a_intent = "harm"
O << "<B>You are now a monkey.</B>"
O.a_intent = "help"
if (tr_flags & TR_DEFAULTMSG)
O << "<B>You are now a human.</B>"
spawn(0)//To prevent the proc from returning null.
del(src)
updateappearance(O)
return O
/mob/new_player/AIize()