Files
Paradise/code/game/objects/items/weapons/implants/implanter.dm
Ccomp5950 143016dd07 Code effeciency project: HUD items rewrite
Before: Every tick each HUD item would recalculate and redo images for every mob in view. For items like the secHUD where we're transversing implants and the various records this gets very expensive.

After: Mobs use their hud_list variable to store varius huditem images, when conditions change for those specific huditem images it updates the specific ones on demand. As a backup every 30 ticks or so the mob will update all of their hud_list.

Also: moved proc/RoundHealth() from 2 seperate locations into __HELPERS/mobs.dm

Conflicts:
	code/modules/mob/living/living.dm

Conflicts:
	code/__HELPERS/mobs.dm
	code/datums/mind.dm
	code/game/objects/items/weapons/implants/implanter.dm
	code/modules/mob/dead/observer/observer.dm
	code/modules/mob/living/carbon/human/human.dm
	code/modules/mob/living/carbon/human/life.dm
	code/modules/mob/living/living.dm
	code/modules/mob/living/living_defines.dm
	code/modules/mob/living/silicon/ai/ai.dm
	code/modules/mob/living/silicon/silicon.dm
	code/modules/virus2/helpers.dm
	code/setup.dm
	icons/mob/hud.dmi
2014-04-29 20:34:28 -04:00

166 lines
4.4 KiB
Plaintext

/obj/item/weapon/implanter
name = "implanter"
icon = 'icons/obj/items.dmi'
icon_state = "implanter0"
item_state = "syringe_0"
throw_speed = 1
throw_range = 5
w_class = 2.0
var/obj/item/weapon/implant/imp = null
/obj/item/weapon/implanter/proc/update()
/obj/item/weapon/implanter/update()
if (src.imp)
src.icon_state = "implanter1"
else
src.icon_state = "implanter0"
return
/obj/item/weapon/implanter/attack(mob/M as mob, mob/user as mob)
if (!istype(M, /mob/living/carbon))
return
if (user && src.imp)
for (var/mob/O in viewers(M, null))
O.show_message("\red [user] is attemping to implant [M].", 1)
var/turf/T1 = get_turf(M)
if (T1 && ((M == user) || do_after(user, 50)))
if(user && M && (get_turf(M) == T1) && src && src.imp)
for (var/mob/O in viewers(M, null))
O.show_message("\red [M] has been implanted by [user].", 1)
M.attack_log += text("\[[time_stamp()]\] <font color='orange'> Implanted with [src.name] ([src.imp.name]) by [user.name] ([user.ckey])</font>")
user.attack_log += text("\[[time_stamp()]\] <font color='red'>Used the [src.name] ([src.imp.name]) to implant [M.name] ([M.ckey])</font>")
msg_admin_attack("[user.name] ([user.ckey]) implanted [M.name] ([M.ckey]) with [src.name] (INTENT: [uppertext(user.a_intent)]) (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)")
user.show_message("\red You implanted the implant into [M].")
if(src.imp.implanted(M, user))
src.imp.loc = M
src.imp.imp_in = M
src.imp.implanted = 1
if (ishuman(M))
var/mob/living/carbon/human/H = M
var/datum/organ/external/affected = H.get_organ(user.zone_sel.selecting)
affected.implants += src.imp
imp.part = affected
H.hud_updateflag |= 1 << IMPLOYAL_HUD
M:implanting = 0
src.imp = null
update()
/obj/item/weapon/implanter/traitor
name = "implanter-greytide"
desc = "Greytide Stationwide."
New()
src.imp = new /obj/item/weapon/implant/traitor(src)
..()
update()
return
/obj/item/weapon/implanter/loyalty
name = "implanter-loyalty"
/obj/item/weapon/implanter/loyalty/New()
src.imp = new /obj/item/weapon/implant/loyalty( src )
..()
update()
return
/obj/item/weapon/implanter/explosive
name = "implanter (E)"
/obj/item/weapon/implanter/explosive/New()
src.imp = new /obj/item/weapon/implant/explosive( src )
..()
update()
return
/obj/item/weapon/implanter/adrenalin
name = "implanter-adrenalin"
/obj/item/weapon/implanter/adrenalin/New()
src.imp = new /obj/item/weapon/implant/adrenalin(src)
..()
update()
return
/obj/item/weapon/implanter/compressed
name = "implanter (C)"
icon_state = "cimplanter1"
var/list/forbidden_types=list(
// /obj/item/weapon/storage/bible // VG #11 - Recursion.
)
/obj/item/weapon/implanter/compressed/New()
imp = new /obj/item/weapon/implant/compressed( src )
..()
update()
return
/obj/item/weapon/implanter/compressed/update()
if (imp)
var/obj/item/weapon/implant/compressed/c = imp
if(!c.scanned)
icon_state = "cimplanter1"
else
icon_state = "cimplanter2"
else
icon_state = "cimplanter0"
return
/obj/item/weapon/implanter/compressed/attack(mob/M as mob, mob/user as mob)
// Attacking things in your hands tends to make this fuck up.
if(!istype(M))
return
var/obj/item/weapon/implant/compressed/c = imp
if (!c) return
if (c.scanned == null)
user << "Please scan an object with the implanter first."
return
..()
/obj/item/weapon/implanter/compressed/afterattack(var/obj/item/I, mob/user as mob)
if(is_type_in_list(I,forbidden_types))
user << "\red A red light flickers on the implanter."
return
if(istype(I) && imp)
var/obj/item/weapon/implant/compressed/c = imp
if (c.scanned)
user << "\red Something is already scanned inside the implant!"
return
if(user)
user.u_equip(I)
user.update_icons() //update our overlays
c.scanned = I
c.scanned.loc = c
update()
/obj/item/weapon/implanter/deadman
name = "implanter-deadman"
desc = "Switch it."
New()
src.imp = new /obj/item/weapon/implant/deadman(src)
..()
update()
return
/obj/item/weapon/implanter/death_alarm
name = "implanter-death alarm"
desc = "Announces the death of the implanted person over radio"
New()
src.imp = new /obj/item/weapon/implant/death_alarm(src)
..()
update()
return