Files
VOREStation/code/game/objects/alien/facehugger.dm
elly1989@rocketmail.com 8961bd96d0 WARNING: This has been thoroughly tested and I'm happy that it's -stable- (it shouldn't runtime). However, it might have a few niggly bugs caused by specific items using no-standard or weird code. Most bugs will be stuff like it not updating overlays and such and can be fixed simply by dropping the item. That being said, if you're not comfortable with this, I'd suggest waiting to update past this revision.
update_clothing() has been broken up into it's key parts. A full explanation can be found in code/modules/mob/living/carbon/human/update_icons.dm
the tl;dr of it is that overlay updates are no longer called by the gameticker. Instead they are called by procs such as u_equip db_cick etc. This means faster updates (although admittedly, more of them can be called per tick). This however is offset by the fact that specific overlays can be updated now, vastly improving its efficiency. This will especially help when there are large numbers of dead mobs.

Fixed the throw code for TKgrab so it can be toggled.

Cloaking for aliens/humans/ninjas was changed. It's very crude at the moment and for that I apologise. But it works and is very efficient.It also stops cloaked individuals becomming invincible due to people being unable to hit them (even when they know exactly where  they are)

Fixed a bunch of bugs with damage-overlays. They  were updating FAR FAR to frequently. They were also horribly inefficient. They should now be virtually seamless when updating and only use cached icons, so they aren't affected by lag as badly. This may help with explosions lag a little.

There's still a tonne of stuff I need to refine with this. I'll be refining it down into some helper procs to reduce on code duplication and such

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3811 316c924e-a436-60f5-8080-3fe189b3f50e
2012-06-13 19:03:25 +00:00

272 lines
6.2 KiB
Plaintext

//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:32
var/const/MIN_IMPREGNATION_TIME = 100 //time it takes to impregnate someone
var/const/MAX_IMPREGNATION_TIME = 150
var/const/MIN_ACTIVE_TIME = 300 //time between being dropped and going idle
var/const/MAX_ACTIVE_TIME = 600
/obj/item/clothing/mask/facehugger
name = "alien"
desc = "It has some sort of a tube at the end of its tail."
icon_state = "facehugger"
item_state = "facehugger"
w_class = 1 //note: can be picked up by aliens unlike most other items of w_class below 4
flags = FPRINT|TABLEPASS|MASKCOVERSMOUTH|MASKCOVERSEYES
var/stat = UNCONSCIOUS //UNCONSCIOUS is the idle state in this case
var/sterile = 0
var/strength = 5
var/attached = 0
attack_paw(user as mob) //can be picked up by aliens
if(isalien(user))
attack_hand(user)
return
else
..()
return
attack_hand(user as mob)
if(stat == CONSCIOUS && !isalien(user))
Attach(user)
return
else
..()
return
attack(mob/living/M as mob, mob/user as mob)
..()
Attach(M)
New()
if(aliens_allowed)
..()
else
del(src)
examine()
..()
switch(stat)
if(DEAD,UNCONSCIOUS)
usr << "\red \b [src] is not moving."
if(CONSCIOUS)
usr << "\red \b [src] seems to be active."
if (sterile)
usr << "\red \b It looks like the proboscis has been removed."
return
attackby()
Die()
return
bullet_act()
Die()
return
temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
if(exposed_temperature > 300)
Die()
return
HasEntered(atom/target)
Attach(target)
return
dropped()
..()
GoActive()
return
throw_impact(atom/hit_atom)
Attach(hit_atom)
return
proc/Attach(M as mob)
if(!isliving(M) || isalien(M))
return
if(attached)
return
else
attached++
spawn(MAX_IMPREGNATION_TIME)
attached = 0
var/mob/living/L = M //just so I don't need to use :
if(stat != CONSCIOUS)
return
if(!sterile) L.take_organ_damage(strength,0) //done here so that even borgs and humans in helmets take damage
loc = L.loc
if(issilicon(L))
for(var/mob/O in viewers(src, null))
O.show_message("\red \b [src] smashes against [L]'s frame!", 1)
Die()
return
var/mob/living/carbon/target = L
for(var/mob/O in viewers(target, null))
O.show_message("\red \b [src] leaps at [target]'s face!", 1)
if(ishuman(target))
var/mob/living/carbon/human/H = target
if(H.head && H.head.flags & HEADCOVERSMOUTH)
for(var/mob/O in viewers(H, null))
O.show_message("\red \b [src] smashes against [H]'s [H.head]!", 1)
Die()
return
if(target.wear_mask)
var/obj/item/clothing/W = target.wear_mask
if(!W.canremove)
return
target.u_equip(W)
if (target.client)
target.client.screen -= W
W.loc = target.loc
W.dropped(target)
W.layer = initial(W.layer)
for(var/mob/O in viewers(target, null))
O.show_message("\red \b [src] tears [W] off of [target]'s face!", 1)
if(istype(loc,/mob/living/carbon/alien)) //just taking it off from the alien's UI
var/mob/living/carbon/alien/host = loc
host.u_equip(src)
if (host.client)
host.client.screen -= src
add_fingerprint(host)
loc = target
layer = 20
target.wear_mask = src
target.update_inv_wear_mask()
GoIdle() //so it doesn't jump the people that tear it off
if(!sterile) target.Paralyse(MAX_IMPREGNATION_TIME/6) //something like 25 ticks = 20 seconds with the default settings
spawn(rand(MIN_IMPREGNATION_TIME,MAX_IMPREGNATION_TIME))
Impregnate(target)
return
proc/Impregnate(mob/living/carbon/target as mob)
if(target.wear_mask != src) //was taken off or something
return
if(!sterile)
target.contract_disease(new /datum/disease/alien_embryo(0)) //so infection chance is same as virus infection chance
for(var/datum/disease/alien_embryo/A in target.viruses)
target.alien_egg_flag = max(1,target.alien_egg_flag)
for(var/mob/O in viewers(target,null))
O.show_message("\red \b [src] falls limp after violating [target]'s face!", 1)
Die()
else
for(var/mob/O in viewers(target,null))
O.show_message("\red \b [src] violates [target]'s face!", 1)
target.update_inv_wear_mask()
return
proc/GoActive()
if(stat == DEAD || stat == CONSCIOUS)
return
stat = CONSCIOUS
for(var/mob/living/carbon/alien/alien in world)
var/image/activeIndicator = image('alien.dmi', loc = src, icon_state = "facehugger_active")
activeIndicator.override = 1
if(alien && alien.client)
alien.client.images += activeIndicator
spawn(rand(MIN_ACTIVE_TIME,MAX_ACTIVE_TIME))
GoIdle()
return
proc/GoIdle()
if(stat == DEAD || stat == UNCONSCIOUS)
return
RemoveActiveIndicators()
stat = UNCONSCIOUS
return
proc/Die()
if(stat == DEAD)
return
RemoveActiveIndicators()
icon_state = "facehugger_dead"
stat = DEAD
for(var/mob/O in viewers(src, null))
O.show_message("\red \b[src] curls up into a ball!", 1)
return
proc/RemoveActiveIndicators() //removes the "active" facehugger indicator from all aliens in the world for this hugger
for(var/mob/living/carbon/alien/alien in world)
if(alien.client)
for(var/image/image in alien.client.images)
if(image.icon_state == "facehugger_active" && image.loc == src)
del(image)
return
/obj/item/clothing/mask/facehugger/angry
stat = CONSCIOUS
/obj/item/clothing/mask/facehugger/angry/HasProximity(atom/movable/AM as mob|obj)
if(istype(AM , /mob/living/))
Attach(AM)
/*
/obj/item/clothing/mask/facehugger/angry/New()
processing_objects.Add(src)
/obj/item/clothing/mask/facehugger/angry/process()
if(!src || src.stat == (DEAD))
return
for(var/mob/living/carbon/C in range(1,src))
Attach(C)
return
for(var/mob/living/carbon/C in range(5,src))
if(isInSight(C,src))
step_to(src,C,0)
spawn(5)
if(C in range(1,src))
Attach(C)
return
step_rand(src)
return
/obj/item/clothing/mask/facehugger/angry/Attach(var/mob/M as mob)
..(M)
processing_objects.Remove(src)
*/