Alien larva poll ghosts before bursting (#24523)

* Alien larva poll ghosts before bursting

🆑 coiax
add: Ghosts are polled if they want to play an alien larva that is about
to chestburst. They are also told who is the (un)lucky victim.
/🆑

* Messages and fixes

* Removed var from giant list of vars
This commit is contained in:
coiax
2017-03-02 06:33:17 +00:00
committed by oranges
parent 1f35a396c8
commit 1a73938c3d
3 changed files with 40 additions and 34 deletions
@@ -1,12 +1,11 @@
// This is to replace the previous datum/disease/alien_embryo for slightly improved handling and maintainability
// It functions almost identically (see code/datums/diseases/alien_embryo.dm)
var/const/ALIEN_AFK_BRACKET = 450 // 45 seconds
/obj/item/organ/body_egg/alien_embryo
name = "alien embryo"
icon = 'icons/mob/alien.dmi'
icon_state = "larva0_dead"
var/stage = 0
var/bursting = FALSE
/obj/item/organ/body_egg/alien_embryo/on_find(mob/living/finder)
..()
@@ -53,8 +52,7 @@ var/const/ALIEN_AFK_BRACKET = 450 // 45 seconds
/obj/item/organ/body_egg/alien_embryo/egg_process()
if(stage < 5 && prob(3))
stage++
spawn(0)
RefreshInfectionImage()
INVOKE_ASYNC(src, .proc/RefreshInfectionImage)
if(stage == 5 && prob(50))
for(var/datum/surgery/S in owner.surgeries)
@@ -65,45 +63,53 @@ var/const/ALIEN_AFK_BRACKET = 450 // 45 seconds
/obj/item/organ/body_egg/alien_embryo/proc/AttemptGrow(gib_on_success = 1)
if(!owner) return
var/list/candidates = get_candidates(ROLE_ALIEN, ALIEN_AFK_BRACKET, "alien candidate")
var/client/C = null
// To stop clientless larva, we will check that our host has a client
// if we find no ghosts to become the alien. If the host has a client
// he will become the alien but if he doesn't then we will set the stage
// to 4, so we don't do a process heavy check everytime.
if(candidates.len)
C = pick(candidates)
else if(owner.client && !(jobban_isbanned(owner, "alien candidate") || jobban_isbanned(owner, "Syndicate")))
C = owner.client
else
stage = 4 // Let's try again later.
/obj/item/organ/body_egg/alien_embryo/proc/AttemptGrow(gib_on_success=TRUE)
if(!owner || bursting)
return
bursting = TRUE
var/list/candidates = pollCandidates("Do you want to play as an alien larva that will burst out of [owner]?", ROLE_ALIEN, null, ROLE_ALIEN, 100, POLL_IGNORE_ALIEN_LARVA)
if(QDELETED(src) || QDELETED(owner))
return
if(!candidates.len || !owner)
bursting = FALSE
stage = 4
return
var/mob/dead/observer/ghost = pick(candidates)
var/overlay = image('icons/mob/alien.dmi', loc = owner, icon_state = "burst_lie")
owner.add_overlay(overlay)
var/atom/xeno_loc = get_turf(owner)
var/mob/living/carbon/alien/larva/new_xeno = new(xeno_loc)
new_xeno.key = C.key
new_xeno.key = ghost.key
new_xeno << sound('sound/voice/hiss5.ogg',0,0,0,100) //To get the player's attention
new_xeno.canmove = 0 //so we don't move during the bursting animation
new_xeno.notransform = 1
new_xeno.invisibility = INVISIBILITY_MAXIMUM
spawn(6)
if(new_xeno)
new_xeno.canmove = 1
new_xeno.notransform = 0
new_xeno.invisibility = 0
if(gib_on_success)
owner.gib(TRUE)
else
owner.adjustBruteLoss(40)
owner.cut_overlay(overlay)
qdel(src)
sleep(6)
if(QDELETED(src) || QDELETED(owner))
return
if(new_xeno)
new_xeno.canmove = 1
new_xeno.notransform = 0
new_xeno.invisibility = 0
if(gib_on_success)
new_xeno.visible_message("<span class='danger'>[new_xeno] bursts out of [owner] in a shower of gore!</span>", "<span class='userdanger'>You exit [owner], your previous host.</span>", "<span class='italics'>You hear organic matter ripping and tearing!</span>")
owner.gib(TRUE)
else
new_xeno.visible_message("<span class='danger'>[new_xeno] wriggles out of [owner]!</span>", "<span class='userdanger'>You exit [owner], your previous host.</span>")
owner.adjustBruteLoss(40)
owner.cut_overlay(overlay)
qdel(src)
/*----------------------------------------