From 084c0754ad431f4705da35c73c65077fab277195 Mon Sep 17 00:00:00 2001 From: Ccomp5950 Date: Sun, 9 Mar 2014 10:25:36 -0500 Subject: [PATCH] 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 --- code/__HELPERS/mobs.dm | 24 ++- code/datums/mind.dm | 16 +- .../game/gamemodes/autotraitor/autotraitor.dm | 1 + code/game/gamemodes/revolution/revolution.dm | 1 + .../gamemodes/revolution/rp-revolution.dm | 2 +- .../gamemodes/revolution/rp_revolution.dm | 1 + code/game/jobs/job_controller.dm | 4 + code/game/machinery/computer/security.dm | 2 + .../items/weapons/implants/implanter.dm | 3 + code/modules/clothing/glasses/hud.dm | 133 ++-------------- code/modules/mob/dead/observer/observer.dm | 108 +++---------- code/modules/mob/living/carbon/human/human.dm | 15 +- .../mob/living/carbon/human/human_damage.dm | 10 ++ code/modules/mob/living/carbon/human/life.dm | 149 ++++++++++++++++++ .../mob/living/carbon/human/update_icons.dm | 4 + code/modules/mob/living/living.dm | 6 +- code/modules/mob/living/living_defines.dm | 4 +- code/modules/mob/living/silicon/ai/ai.dm | 11 ++ .../modules/mob/living/silicon/robot/robot.dm | 12 ++ code/modules/mob/living/silicon/silicon.dm | 4 +- code/modules/surgery/implant.dm | 2 + code/modules/virus2/disease2.dm | 2 + code/modules/virus2/helpers.dm | 5 +- code/setup.dm | 12 +- icons/mob/hud.dmi | Bin 2951 -> 2955 bytes 25 files changed, 309 insertions(+), 222 deletions(-) diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm index 324cfad632..521f07c35e 100644 --- a/code/__HELPERS/mobs.dm +++ b/code/__HELPERS/mobs.dm @@ -74,4 +74,26 @@ proc/age2agedescription(age) if(45 to 60) return "middle-aged" if(60 to 70) return "aging" if(70 to INFINITY) return "elderly" - else return "unknown" \ No newline at end of file + else return "unknown" + +proc/RoundHealth(health) + switch(health) + if(100 to INFINITY) + return "health100" + if(70 to 100) + return "health80" + if(50 to 70) + return "health60" + if(30 to 50) + return "health40" + if(18 to 30) + return "health25" + if(5 to 18) + return "health10" + if(1 to 5) + return "health1" + if(-99 to 0) + return "health0" + else + return "health-100" + return "0" diff --git a/code/datums/mind.dm b/code/datums/mind.dm index 6a8bddf55c..ce47a37a76 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -499,6 +499,9 @@ datum/mind else if(href_list["implant"]) var/mob/living/carbon/human/H = current + + H.hud_updateflag |= (1 << IMPLOYAL_HUD) // updates that players HUD images so secHUD's pick up they are implanted or not. + switch(href_list["implant"]) if("remove") for(var/obj/item/weapon/implant/loyalty/I in H.contents) @@ -540,6 +543,8 @@ datum/mind log_admin("[key_name_admin(usr)] has de-traitor'ed [current].") else if (href_list["revolution"]) + current.hud_updateflag |= (1 << SPECIALROLE_HUD) + switch(href_list["revolution"]) if("clear") if(src in ticker.mode.revolutionaries) @@ -633,6 +638,7 @@ datum/mind usr << "\red Reequipping revolutionary goes wrong!" else if (href_list["cult"]) + current.hud_updateflag |= (1 << SPECIALROLE_HUD) switch(href_list["cult"]) if("clear") if(src in ticker.mode.cult) @@ -682,6 +688,8 @@ datum/mind usr << "\red Spawning amulet failed!" else if (href_list["wizard"]) + current.hud_updateflag |= (1 << SPECIALROLE_HUD) + switch(href_list["wizard"]) if("clear") if(src in ticker.mode.wizards) @@ -710,6 +718,7 @@ datum/mind usr << "\blue The objectives for wizard [key] have been generated. You can edit them and anounce manually." else if (href_list["changeling"]) + current.hud_updateflag |= (1 << SPECIALROLE_HUD) switch(href_list["changeling"]) if("clear") if(src in ticker.mode.changelings) @@ -744,6 +753,10 @@ datum/mind domutcheck(current, null) else if (href_list["nuclear"]) + var/mob/living/carbon/human/H = current + + current.hud_updateflag |= (1 << SPECIALROLE_HUD) + switch(href_list["nuclear"]) if("clear") if(src in ticker.mode.syndicates) @@ -773,7 +786,6 @@ datum/mind if("lair") current.loc = get_turf(locate("landmark*Syndicate-Spawn")) if("dressup") - var/mob/living/carbon/human/H = current del(H.belt) del(H.back) del(H.l_ear) @@ -800,6 +812,7 @@ datum/mind usr << "\red No valid nuke found!" else if (href_list["traitor"]) + current.hud_updateflag |= (1 << SPECIALROLE_HUD) switch(href_list["traitor"]) if("clear") if(src in ticker.mode.traitors) @@ -882,6 +895,7 @@ datum/mind current.radiation -= 50 else if (href_list["silicon"]) + current.hud_updateflag |= (1 << SPECIALROLE_HUD) switch(href_list["silicon"]) if("unmalf") if(src in ticker.mode.malf_ai) diff --git a/code/game/gamemodes/autotraitor/autotraitor.dm b/code/game/gamemodes/autotraitor/autotraitor.dm index 06b5274a92..43dea8c32f 100644 --- a/code/game/gamemodes/autotraitor/autotraitor.dm +++ b/code/game/gamemodes/autotraitor/autotraitor.dm @@ -135,6 +135,7 @@ newtraitor << "\red ATTENTION: \black It is time to pay your debt to the Syndicate..." newtraitor << "You are now a traitor." newtraitor.mind.special_role = "traitor" + newtraitor.hud_updateflag |= 1 << SPECIALROLE_HUD var/obj_count = 1 newtraitor << "\blue Your current objectives:" if(!config.objectives_disabled) diff --git a/code/game/gamemodes/revolution/revolution.dm b/code/game/gamemodes/revolution/revolution.dm index 3211c49642..f6199dcb16 100644 --- a/code/game/gamemodes/revolution/revolution.dm +++ b/code/game/gamemodes/revolution/revolution.dm @@ -208,6 +208,7 @@ if(rev_mind in revolutionaries) revolutionaries -= rev_mind rev_mind.special_role = null + rev_mind.current.hud_updateflag |= 1 << SPECIALROLE_HUD if(beingborged) rev_mind.current << "\red The frame's firmware detects and deletes your neural reprogramming! You remember nothing from the moment you were flashed until now." diff --git a/code/game/gamemodes/revolution/rp-revolution.dm b/code/game/gamemodes/revolution/rp-revolution.dm index 7456e73403..963579af7c 100644 --- a/code/game/gamemodes/revolution/rp-revolution.dm +++ b/code/game/gamemodes/revolution/rp-revolution.dm @@ -304,4 +304,4 @@ mob/living/carbon/human/proc else if(choice == "No!") M << "\red You reject this traitorous cause!" src << "\red [M] does not support the revolution!" - M.mind.rev_cooldown = world.time+50 \ No newline at end of file + M.mind.rev_cooldown = world.time+50 diff --git a/code/game/gamemodes/revolution/rp_revolution.dm b/code/game/gamemodes/revolution/rp_revolution.dm index f4504835b3..70fd1387f0 100644 --- a/code/game/gamemodes/revolution/rp_revolution.dm +++ b/code/game/gamemodes/revolution/rp_revolution.dm @@ -116,6 +116,7 @@ if(config.objectives_disabled) rev_mind.current << "Within the rules, try to act as an opposing force to the crew. Further RP and try to make sure other players have fun! If you are confused or at a loss, always adminhelp, and before taking extreme actions, please try to also contact the administration! Think through your actions and make the roleplay immersive! Please remember all rules aside from those without explicit exceptions apply to antagonists." update_rev_icons_added(rev_mind) + H.hud_updateflag |= 1 << SPECIALROLE_HUD return 1 ///////////////////////////// diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm index 2330ebcb74..83603ce838 100644 --- a/code/game/jobs/job_controller.dm +++ b/code/game/jobs/job_controller.dm @@ -439,6 +439,10 @@ var/global/datum/controller/occupations/job_master var/obj/item/clothing/glasses/G = H.glasses G.prescription = 1 // H.update_icons() + + H.hud_updateflag |= (1 << ID_HUD) + H.hud_updateflag |= (1 << IMPLOYAL_HUD) + H.hud_updateflag |= (1 << SPECIALROLE_HUD) return 1 diff --git a/code/game/machinery/computer/security.dm b/code/game/machinery/computer/security.dm index a772ff88f1..5ec442a3dd 100644 --- a/code/game/machinery/computer/security.dm +++ b/code/game/machinery/computer/security.dm @@ -525,6 +525,8 @@ What a mess.*/ if ("Change Criminal Status") if (active2) + for(var/mob/living/carbon/human/H in player_list) + H.hud_updateflag |= 1 << WANTED_HUD switch(href_list["criminal2"]) if("none") active2.fields["criminal"] = "None" diff --git a/code/game/objects/items/weapons/implants/implanter.dm b/code/game/objects/items/weapons/implants/implanter.dm index 28eeaaf5b8..3706ef6bfd 100644 --- a/code/game/objects/items/weapons/implants/implanter.dm +++ b/code/game/objects/items/weapons/implants/implanter.dm @@ -47,8 +47,11 @@ affected.implants += src.imp imp.part = affected + H.hud_updateflag |= 1 << IMPLOYAL_HUD + src.imp = null update() + return diff --git a/code/modules/clothing/glasses/hud.dm b/code/modules/clothing/glasses/hud.dm index aedb20c70d..f541c837e6 100644 --- a/code/modules/clothing/glasses/hud.dm +++ b/code/modules/clothing/glasses/hud.dm @@ -14,80 +14,25 @@ name = "Health Scanner HUD" desc = "A heads-up display that scans the humans in view and provides accurate data about their health status." icon_state = "healthhud" - proc - RoundHealth(health) - RoundHealth(health) - switch(health) - if(100 to INFINITY) - return "health100" - if(70 to 100) - return "health80" - if(50 to 70) - return "health60" - if(30 to 50) - return "health40" - if(18 to 30) - return "health25" - if(5 to 18) - return "health10" - if(1 to 5) - return "health1" - if(-99 to 0) - return "health0" - else - return "health-100" - return "0" - - process_hud(var/mob/M) - if(!M) return - if(!M.client) return - var/client/C = M.client - var/image/holder - for(var/mob/living/carbon/human/patient in view(get_turf(M))) - if(M.see_invisible < patient.invisibility) - continue - var/foundVirus = 0 - for(var/datum/disease/D in patient.viruses) - if(!D.hidden[SCANNER]) - foundVirus++ - for (var/ID in patient.virus2) - if (ID in virusDB) - foundVirus = 1 - break - if(!C) continue - - holder = patient.hud_list[HEALTH_HUD] - if(patient.stat == 2) - holder.icon_state = "hudhealth-100" - else - holder.icon_state = "hud[RoundHealth(patient.health)]" - C.images += holder - - holder = patient.hud_list[STATUS_HUD] - if(patient.stat == 2) - holder.icon_state = "huddead" - else if(patient.status_flags & XENO_HOST) - holder.icon_state = "hudxeno" - else if(foundVirus) - holder.icon_state = "hudill" - else if(patient.has_brain_worms()) - var/mob/living/simple_animal/borer/B = patient.has_brain_worms() - if(B.controlling) - holder.icon_state = "hudbrainworm" - else - holder.icon_state = "hudhealthy" - else - holder.icon_state = "hudhealthy" - C.images += holder +/obj/item/clothing/glasses/hud/health/process_hud(var/mob/M) + if(!M) return + if(!M.client) return + var/client/C = M.client + for(var/mob/living/carbon/human/patient in view(get_turf(M))) + if(M.see_invisible < patient.invisibility) + continue + C.images += patient.hud_list[HEALTH_HUD] + C.images += patient.hud_list[STATUS_HUD] /obj/item/clothing/glasses/hud/security name = "Security HUD" desc = "A heads-up display that scans the humans in view and provides accurate data about their ID status and security records." icon_state = "securityhud" + var/global/list/jobs[0] /obj/item/clothing/glasses/hud/security/jensenshades name = "Augmented shades" @@ -98,62 +43,16 @@ invisa_view = 2 /obj/item/clothing/glasses/hud/security/process_hud(var/mob/M) + if(!M) return if(!M.client) return var/client/C = M.client - var/image/holder for(var/mob/living/carbon/human/perp in view(get_turf(M))) if(M.see_invisible < perp.invisibility) continue if(!C) continue - var/perpname = perp.name - holder = perp.hud_list[ID_HUD] - if(perp.wear_id) - var/obj/item/weapon/card/id/I = perp.wear_id.GetID() - if(I) - perpname = I.registered_name - holder.icon_state = "hud[ckey(I.GetJobName())]" - C.images += holder - else - perpname = perp.name - holder.icon_state = "hudunknown" - C.images += holder - else - perpname = perp.name - holder.icon_state = "hudunknown" - C.images += holder - - for(var/datum/data/record/E in data_core.general) - if(E.fields["name"] == perpname) - holder = perp.hud_list[WANTED_HUD] - for (var/datum/data/record/R in data_core.security) - if((R.fields["id"] == E.fields["id"]) && (R.fields["criminal"] == "*Arrest*")) - holder.icon_state = "hudwanted" - C.images += holder - break - else if((R.fields["id"] == E.fields["id"]) && (R.fields["criminal"] == "Incarcerated")) - holder.icon_state = "hudprisoner" - C.images += holder - break - else if((R.fields["id"] == E.fields["id"]) && (R.fields["criminal"] == "Parolled")) - holder.icon_state = "hudparolled" - C.images += holder - break - else if((R.fields["id"] == E.fields["id"]) && (R.fields["criminal"] == "Released")) - holder.icon_state = "hudreleased" - C.images += holder - break - for(var/obj/item/weapon/implant/I in perp) - if(I.implanted) - if(istype(I,/obj/item/weapon/implant/tracking)) - holder = perp.hud_list[IMPTRACK_HUD] - holder.icon_state = "hud_imp_tracking" - C.images += holder - if(istype(I,/obj/item/weapon/implant/loyalty)) - holder = perp.hud_list[IMPLOYAL_HUD] - holder.icon_state = "hud_imp_loyal" - C.images += holder - if(istype(I,/obj/item/weapon/implant/chem)) - holder = perp.hud_list[IMPCHEM_HUD] - holder.icon_state = "hud_imp_chem" - C.images += holder \ No newline at end of file + C.images += perp.hud_list[ID_HUD] + C.images += perp.hud_list[WANTED_HUD] + C.images += perp.hud_list[IMPTRACK_HUD] + C.images += perp.hud_list[IMPLOYAL_HUD] + C.images += perp.hud_list[IMPCHEM_HUD] diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index 98f6e91e12..ec85aaeaa4 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -102,10 +102,11 @@ Works together with spawning an observer, noted above. for(var/image/hud in client.images) if(copytext(hud.icon_state,1,4) == "hud") client.images.Remove(hud) + if(antagHUD) var/list/target_list = list() - for(var/mob/living/target in oview(src)) - if( target.mind&&(target.mind.special_role||issilicon(target)) ) + for(var/mob/living/target in oview(src, 14)) + if(target.mind&&(target.mind.special_role||issilicon(target)) ) target_list += target if(target_list.len) assess_targets(target_list, src) @@ -113,91 +114,19 @@ Works together with spawning an observer, noted above. process_medHUD(src) -// Direct copied from medical HUD glasses proc, used to determine what health bar to put over the targets head. -/mob/dead/proc/RoundHealth(var/health) - switch(health) - if(100 to INFINITY) - return "health100" - if(70 to 100) - return "health80" - if(50 to 70) - return "health60" - if(30 to 50) - return "health40" - if(18 to 30) - return "health25" - if(5 to 18) - return "health10" - if(1 to 5) - return "health1" - if(-99 to 0) - return "health0" - else - return "health-100" - return "0" - - -// Pretty much a direct copy of Medical HUD stuff, except will show ill if they are ill instead of also checking for known illnesses. - -/mob/dead/proc/process_medHUD(var/mob/M) - var/client/C = M.client - var/image/holder - for(var/mob/living/carbon/human/patient in oview(M)) - var/foundVirus = 0 - if(patient.virus2.len) - foundVirus = 1 - if(!C) return - holder = patient.hud_list[HEALTH_HUD] - if(patient.stat == 2) - holder.icon_state = "hudhealth-100" - else - holder.icon_state = "hud[RoundHealth(patient.health)]" - C.images += holder - - holder = patient.hud_list[STATUS_HUD] - if(patient.stat == 2) - holder.icon_state = "huddead" - else if(patient.status_flags & XENO_HOST) - holder.icon_state = "hudxeno" - else if(foundVirus) - holder.icon_state = "hudill" - else if(patient.has_brain_worms()) - var/mob/living/simple_animal/borer/B = patient.has_brain_worms() - if(B.controlling) - holder.icon_state = "hudbrainworm" - else - holder.icon_state = "hudhealthy" - else - holder.icon_state = "hudhealthy" - - C.images += holder - - -/mob/dead/proc/assess_targets(list/target_list, mob/dead/observer/U) - var/icon/tempHud = 'icons/mob/hud.dmi' - for(var/mob/living/target in target_list) - if(iscarbon(target)) - switch(target.mind.special_role) - if("traitor","Syndicate") - U.client.images += image(tempHud,target,"hudsyndicate") - if("Revolutionary") - U.client.images += image(tempHud,target,"hudrevolutionary") - if("Head Revolutionary") - U.client.images += image(tempHud,target,"hudheadrevolutionary") - if("Cultist") - U.client.images += image(tempHud,target,"hudcultist") - if("Changeling") - U.client.images += image(tempHud,target,"hudchangeling") - if("Wizard","Fake Wizard") - U.client.images += image(tempHud,target,"hudwizard") - if("Hunter","Sentinel","Drone","Queen") - U.client.images += image(tempHud,target,"hudalien") - if("Death Commando") - U.client.images += image(tempHud,target,"huddeathsquad") - if("Ninja") - U.client.images += image(tempHud,target,"hudninja") - else//If we don't know what role they have but they have one. - U.client.images += image(tempHud,target,"hudunknown1") +/mob/dead/proc/process_medHUD(var/mob/M) + var/client/C = M.client + for(var/mob/living/carbon/human/patient in oview(M, 14)) + C.images += patient.hud_list[HEALTH_HUD] + C.images += patient.hud_list[STATUS_HUD_OOC] + +/mob/dead/proc/assess_targets(list/target_list, mob/dead/observer/U) + var/client/C = U.client + for(var/mob/living/carbon/human/target in target_list) + C.images += target.hud_list[SPECIALROLE_HUD] + + +/* else//If the silicon mob has no law datum, no inherent laws, or a law zero, add them to the hud. var/mob/living/silicon/silicon_target = target if(!silicon_target.laws||(silicon_target.laws&&(silicon_target.laws.zeroth||!silicon_target.laws.inherent.len))||silicon_target.mind.special_role=="traitor") @@ -205,8 +134,9 @@ Works together with spawning an observer, noted above. U.client.images += image(tempHud,silicon_target,"hudmalborg") else U.client.images += image(tempHud,silicon_target,"hudmalai") - return 1 - +*/ + return 1 + /mob/proc/ghostize(var/can_reenter_corpse = 1) if(key) var/mob/dead/observer/ghost = new(src) //Transfer safety to observer spawning proc. diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 7dc0594a8f..70c59f2bfe 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -4,7 +4,7 @@ voice_name = "unknown" icon = 'icons/mob/human.dmi' icon_state = "body_m_s" - var/list/hud_list = list() + var/list/hud_list[9] var/datum/species/species //Contains icon generation and language information, set during New(). var/embedded_flag //To check if we've need to roll for damage on movement while an item is imbedded in us. @@ -53,8 +53,16 @@ dna = new /datum/dna(null) dna.species=species.name - for(var/i=0;i<7;i++) // 2 for medHUDs and 5 for secHUDs - hud_list += image('icons/mob/hud.dmi', src, "hudunknown") + hud_list[HEALTH_HUD] = image('icons/mob/hud.dmi', src, "hudhealth100") + hud_list[STATUS_HUD] = image('icons/mob/hud.dmi', src, "hudhealthy") + hud_list[ID_HUD] = image('icons/mob/hud.dmi', src, "hudunknown") + hud_list[WANTED_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[IMPLOYAL_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[IMPCHEM_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[IMPTRACK_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[SPECIALROLE_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[STATUS_HUD_OOC] = image('icons/mob/hud.dmi', src, "hudhealthy") + ..() @@ -552,6 +560,7 @@ modified = 1 spawn() + hud_updateflag |= 1 << WANTED_HUD if(istype(usr,/mob/living/carbon/human)) var/mob/living/carbon/human/U = usr U.handle_regular_hud_updates() diff --git a/code/modules/mob/living/carbon/human/human_damage.dm b/code/modules/mob/living/carbon/human/human_damage.dm index 91b7ef0f96..3996467013 100644 --- a/code/modules/mob/living/carbon/human/human_damage.dm +++ b/code/modules/mob/living/carbon/human/human_damage.dm @@ -47,6 +47,7 @@ take_overall_damage(amount, 0) else heal_overall_damage(-amount, 0) + hud_updateflag |= 1 << HEALTH_HUD /mob/living/carbon/human/adjustFireLoss(var/amount) if(species && species.burn_mod) @@ -56,6 +57,7 @@ take_overall_damage(0, amount) else heal_overall_damage(0, -amount) + hud_updateflag |= 1 << HEALTH_HUD /mob/living/carbon/human/Stun(amount) if(HULK in mutations) return @@ -97,6 +99,8 @@ if (O.status & ORGAN_MUTATED) O.unmutate() src << "Your [O.display_name] is shaped normally again." + hud_updateflag |= 1 << HEALTH_HUD + //////////////////////////////////////////// //Returns a list of damaged organs @@ -124,6 +128,7 @@ var/datum/organ/external/picked = pick(parts) if(picked.heal_damage(brute,burn)) UpdateDamageIcon() + hud_updateflag |= 1 << HEALTH_HUD updatehealth() //Damages ONE external organ, organ gets randomly selected from damagable ones. @@ -135,6 +140,7 @@ var/datum/organ/external/picked = pick(parts) if(picked.take_damage(brute,burn,sharp)) UpdateDamageIcon() + hud_updateflag |= 1 << HEALTH_HUD updatehealth() @@ -156,6 +162,7 @@ parts -= picked updatehealth() + hud_updateflag |= 1 << HEALTH_HUD if(update) UpdateDamageIcon() // damage MANY external organs, in random order @@ -175,6 +182,7 @@ parts -= picked updatehealth() + hud_updateflag |= 1 << HEALTH_HUD if(update) UpdateDamageIcon() @@ -200,6 +208,7 @@ This function restores all organs. if(istype(E, /datum/organ/external)) if (E.heal_damage(brute, burn)) UpdateDamageIcon() + hud_updateflag |= 1 << HEALTH_HUD else return 0 return @@ -243,6 +252,7 @@ This function restores all organs. // Will set our damageoverlay icon to the next level, which will then be set back to the normal level the next mob.Life(). updatehealth() + hud_updateflag |= 1 << HEALTH_HUD //Embedded projectile code. if(!organ) return diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index bf575c3cb7..0a0d708042 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -63,6 +63,9 @@ in_stasis = istype(loc, /obj/structure/closet/body_bag/cryobag) && loc:opened == 0 if(in_stasis) loc:used++ + if(life_tick%30==15) + hud_updateflag = 1022 + //No need to update all of these procs if the guy is dead. if(stat != DEAD && !in_stasis) if(air_master.current_cycle%4==2 || failed_last_breath) //First, resolve location and get a breath @@ -1125,6 +1128,10 @@ proc/handle_regular_hud_updates() if(!client) return 0 + if(hud_updateflag) + handle_hud_list() + + for(var/image/hud in client.images) if(copytext(hud.icon_state,1,4) == "hud") //ugly, but icon comparison is worse, I believe client.images.Remove(hud) @@ -1544,6 +1551,148 @@ return temp +/* + Called by life(), instead of having the individual hud items update icons each tick and check for status changes + we only set those statuses and icons upon changes. Then those HUD items will simply add those pre-made images. + This proc below is only called when those HUD elements need to change as determined by the mobs hud_updateflag. +*/ + + +/mob/living/carbon/human/proc/handle_hud_list() + + if(hud_updateflag & 1 << HEALTH_HUD) + var/image/holder = hud_list[HEALTH_HUD] + if(stat == 2) + holder.icon_state = "hudhealth-100" // X_X + else + holder.icon_state = "hud[RoundHealth(health)]" + + hud_list[HEALTH_HUD] = holder + + if(hud_updateflag & 1 << STATUS_HUD) + var/foundVirus = 0 + for(var/datum/disease/D in viruses) + if(!D.hidden[SCANNER]) + foundVirus++ + for (var/ID in virus2) + if (ID in virusDB) + foundVirus = 1 + break + + var/image/holder = hud_list[STATUS_HUD] + var/image/holder2 = hud_list[STATUS_HUD_OOC] + if(stat == 2) + holder.icon_state = "huddead" + holder2.icon_state = "huddead" + else if(status_flags & XENO_HOST) + holder.icon_state = "hudxeno" + holder2.icon_state = "hudxeno" + else if(foundVirus) + holder.icon_state = "hudill" + else if(has_brain_worms()) + var/mob/living/simple_animal/borer/B = has_brain_worms() + if(B.controlling) + holder.icon_state = "hudbrainworm" + else + holder.icon_state = "hudhealthy" + holder2.icon_state = "hudbrainworm" + else + holder.icon_state = "hudhealthy" + if(virus2.len) + holder2.icon_state = "hudill" + else + holder2.icon_state = "hudhealthy" + + hud_list[STATUS_HUD] = holder + hud_list[STATUS_HUD_OOC] = holder2 + + if(hud_updateflag & 1 << ID_HUD) + var/image/holder = hud_list[ID_HUD] + if(wear_id) + var/obj/item/weapon/card/id/I = wear_id.GetID() + if(I) + holder.icon_state = "hud[ckey(I.GetJobName())]" + else + holder.icon_state = "hudunknown" + else + holder.icon_state = "hudunknown" + + + hud_list[ID_HUD] = holder + + if(hud_updateflag & 1 << WANTED_HUD) + var/image/holder = hud_list[WANTED_HUD] + holder.icon_state = "hudblank" + var/perpname = name + if(wear_id) + var/obj/item/weapon/card/id/I = wear_id.GetID() + if(I) + perpname = I.registered_name + + for(var/datum/data/record/E in data_core.general) + if(E.fields["name"] == perpname) + for (var/datum/data/record/R in data_core.security) + if((R.fields["id"] == E.fields["id"]) && (R.fields["criminal"] == "*Arrest*")) + holder.icon_state = "hudwanted" + break + else if((R.fields["id"] == E.fields["id"]) && (R.fields["criminal"] == "Incarcerated")) + holder.icon_state = "hudprisoner" + break + else if((R.fields["id"] == E.fields["id"]) && (R.fields["criminal"] == "Parolled")) + holder.icon_state = "hudparolled" + break + else if((R.fields["id"] == E.fields["id"]) && (R.fields["criminal"] == "Released")) + holder.icon_state = "hudreleased" + break + hud_list[WANTED_HUD] = holder + + if(hud_updateflag & 1 << IMPLOYAL_HUD || hud_updateflag & 1 << IMPCHEM_HUD || hud_updateflag & 1 << IMPTRACK_HUD) + var/image/holder1 = hud_list[IMPTRACK_HUD] + var/image/holder2 = hud_list[IMPLOYAL_HUD] + var/image/holder3 = hud_list[IMPCHEM_HUD] + + holder1.icon_state = "hudblank" + holder2.icon_state = "hudblank" + holder3.icon_state = "hudblank" + + for(var/obj/item/weapon/implant/I in src) + if(I.implanted) + if(istype(I,/obj/item/weapon/implant/tracking)) + holder1.icon_state = "hud_imp_tracking" + if(istype(I,/obj/item/weapon/implant/loyalty)) + holder2.icon_state = "hud_imp_loyal" + if(istype(I,/obj/item/weapon/implant/chem)) + holder3.icon_state = "hud_imp_chem" + + hud_list[IMPTRACK_HUD] = holder1 + hud_list[IMPLOYAL_HUD] = holder2 + hud_list[IMPCHEM_HUD] = holder3 + + if(hud_updateflag & 1 << SPECIALROLE_HUD) + var/image/holder = hud_list[SPECIALROLE_HUD] + holder.icon_state = "hudblank" + switch(mind.special_role) + if("traitor","Syndicate") + holder.icon_state = "hudsyndicate" + if("Revolutionary") + holder.icon_state = "hudrevolutionary" + if("Head Revolutionary") + holder.icon_state = "hudheadrevolutionary" + if("Cultist") + holder.icon_state = "hudcultist" + if("Changeling") + holder.icon_state = "hudchangeling" + if("Wizard","Fake Wizard") + holder.icon_state = "hudwizard" + if("Death Commando") + holder.icon_state = "huddeathsquad" + if("Ninja") + holder.icon_state = "hudninja" + + hud_list[SPECIALROLE_HUD] = holder + + hud_updateflag = 0 + #undef HUMAN_MAX_OXYLOSS #undef HUMAN_CRIT_MAX_OXYLOSS diff --git a/code/modules/mob/living/carbon/human/update_icons.dm b/code/modules/mob/living/carbon/human/update_icons.dm index a937ca56a8..38ad9cc0d0 100644 --- a/code/modules/mob/living/carbon/human/update_icons.dm +++ b/code/modules/mob/living/carbon/human/update_icons.dm @@ -516,6 +516,10 @@ proc/get_damage_icon_part(damage_state, body_part) overlays_standing[ID_LAYER] = null else overlays_standing[ID_LAYER] = null + + hud_updateflag |= 1 << ID_HUD + hud_updateflag |= 1 << WANTED_HUD + if(update_icons) update_icons() /mob/living/carbon/human/update_inv_gloves(var/update_icons=1) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 97e04597dc..3ada724051 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -264,6 +264,8 @@ if (C.legcuffed && !initial(C.legcuffed)) C.drop_from_inventory(C.legcuffed) C.legcuffed = initial(C.legcuffed) + hud_updateflag |= 1 << HEALTH_HUD + hud_updateflag |= 1 << STATUS_HUD /mob/living/proc/rejuvenate() @@ -310,7 +312,9 @@ // make the icons look correct regenerate_icons() - + + hud_updateflag |= 1 << HEALTH_HUD + hud_updateflag |= 1 << STATUS_HUD return /mob/living/proc/UpdateDamageIcon() diff --git a/code/modules/mob/living/living_defines.dm b/code/modules/mob/living/living_defines.dm index 2b3d9f861a..a93bfd2d19 100644 --- a/code/modules/mob/living/living_defines.dm +++ b/code/modules/mob/living/living_defines.dm @@ -5,6 +5,8 @@ var/maxHealth = 100 //Maximum health that should be possible. var/health = 100 //A mob's health + var/hud_updateflag = 0 + //Damage related vars, NOTE: THESE SHOULD ONLY BE MODIFIED BY PROCS var/bruteloss = 0.0 //Brutal damage caused by brute force (punching, being clubbed by a toolbox ect... this also accounts for pressure damage) var/oxyloss = 0.0 //Oxygen depravation damage (no air in lungs) @@ -35,4 +37,4 @@ var/tod = null // Time of death var/update_slimes = 1 - var/silent = null //Can't talk. Value goes down every life proc. \ No newline at end of file + var/silent = null //Can't talk. Value goes down every life proc. diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index f652f77ec8..154a7f047f 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -115,6 +115,17 @@ var/list/ai_list = list() src << "These laws may be changed by other players, or by you being the traitor." job = "AI" + + hud_list[HEALTH_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[STATUS_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[ID_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[WANTED_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[IMPLOYAL_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[IMPCHEM_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[IMPTRACK_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[SPECIALROLE_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + + ai_list += src ..() return diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index be0642ec24..12ae12babe 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -126,6 +126,18 @@ var/datum/robot_component/cell_component = components["power cell"] cell_component.wrapped = cell cell_component.installed = 1 + + hud_list[HEALTH_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[STATUS_HUD] = image('icons/mob/hud.dmi', src, "hudhealth100") + hud_list[ID_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[WANTED_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[IMPLOYAL_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[IMPCHEM_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[IMPTRACK_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[SPECIALROLE_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + + + playsound(loc, 'sound/voice/liveagain.ogg', 75, 1) diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index bfa4512498..6f770c8a71 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -7,7 +7,7 @@ var/list/alarms_to_show = list() var/list/alarms_to_clear = list() immune_to_ssd = 1 - + var/list/hud_list[9] var/list/alarm_types_show = list("Motion" = 0, "Fire" = 0, "Atmosphere" = 0, "Power" = 0, "Camera" = 0) var/list/alarm_types_clear = list("Motion" = 0, "Fire" = 0, "Atmosphere" = 0, "Power" = 0, "Camera" = 0) @@ -191,4 +191,4 @@ dat += data_core.get_manifest(1) // make it monochrome dat += "
" src << browse(dat, "window=airoster") - onclose(src, "airoster") \ No newline at end of file + onclose(src, "airoster") diff --git a/code/modules/surgery/implant.dm b/code/modules/surgery/implant.dm index 01d54bedaa..99f8466668 100644 --- a/code/modules/surgery/implant.dm +++ b/code/modules/surgery/implant.dm @@ -182,6 +182,8 @@ "\blue You take [obj] out of incision on [target]'s [affected.display_name]s with \the [tool]." ) affected.implants -= obj + target.hud_updateflag |= 1 << IMPLOYAL_HUD + //Handle possessive brain borers. if(istype(obj,/mob/living/simple_animal/borer)) var/mob/living/simple_animal/borer/worm = obj diff --git a/code/modules/virus2/disease2.dm b/code/modules/virus2/disease2.dm index 59c713ae98..bb64a5366d 100644 --- a/code/modules/virus2/disease2.dm +++ b/code/modules/virus2/disease2.dm @@ -79,6 +79,7 @@ for(var/datum/disease2/effectholder/e in effects) e.effect.deactivate(mob) mob.virus2.Remove("[uniqueID]") + mob.hud_updateflag |= 1 << STATUS_HUD /datum/disease2/disease/proc/minormutate() //uniqueID = rand(0,10000) @@ -175,6 +176,7 @@ proc/virus2_lesser_infection() for(var/mob/living/carbon/human/G in player_list) if(G.client && G.stat != DEAD) candidates += G + if(!candidates.len) return candidates = shuffle(candidates) diff --git a/code/modules/virus2/helpers.dm b/code/modules/virus2/helpers.dm index 520f7931ec..9c3f996245 100644 --- a/code/modules/virus2/helpers.dm +++ b/code/modules/virus2/helpers.dm @@ -77,6 +77,7 @@ proc/airborne_can_reach(turf/source, turf/target) D.minormutate() // log_debug("Adding virus") M.virus2["[D.uniqueID]"] = D + M.hud_updateflag |= 1 << STATUS_HUD //Infects mob M with random lesser disease, if he doesn't have one /proc/infect_mob_random_lesser(var/mob/living/carbon/M) @@ -84,12 +85,14 @@ proc/airborne_can_reach(turf/source, turf/target) D.makerandom() D.infectionchance = 1 M.virus2["[D.uniqueID]"] = D + M.hud_updateflag |= 1 << STATUS_HUD //Infects mob M with random greated disease, if he doesn't have one /proc/infect_mob_random_greater(var/mob/living/carbon/M) var/datum/disease2/disease/D = new /datum/disease2/disease D.makerandom(1) M.virus2["[D.uniqueID]"] = D + M.hud_updateflag |= 1 << STATUS_HUD //Fancy prob() function. /proc/dprob(var/p) @@ -135,4 +138,4 @@ proc/airborne_can_reach(turf/source, turf/target) for (var/ID in victim.virus2) var/datum/disease2/disease/V = victim.virus2[ID] if(V && V.spreadtype != vector) continue - infect_virus2(src,V) \ No newline at end of file + infect_virus2(src,V) diff --git a/code/setup.dm b/code/setup.dm index 66216f2a3f..c56aefde1d 100644 --- a/code/setup.dm +++ b/code/setup.dm @@ -691,13 +691,15 @@ var/list/be_special_flags = list( #define RIGHT 2 // for secHUDs and medHUDs and variants. The number is the location of the image on the list hud_list of humans. -#define HEALTH_HUD 1 // dead, alive, sick, health status -#define STATUS_HUD 2 // a simple line rounding the mob's number health +#define HEALTH_HUD 1 // a simple line rounding the mob's number health +#define STATUS_HUD 2 // alive, dead, diseased, etc. #define ID_HUD 3 // the job asigned to your ID #define WANTED_HUD 4 // wanted, released, parroled, security status -#define IMPLOYAL_HUD 5 // loyality implant +#define IMPLOYAL_HUD 5 // loyality implant #define IMPCHEM_HUD 6 // chemical implant -#define IMPTRACK_HUD 7 // tracking implant +#define IMPTRACK_HUD 7 // tracking implant +#define SPECIALROLE_HUD 8 // AntagHUD image +#define STATUS_HUD_OOC 9 // STATUS_HUD without virus db check for someone being ill. //Pulse levels, very simplified #define PULSE_NONE 0 //so !M.pulse checks would be possible @@ -758,4 +760,4 @@ var/list/RESTRICTED_CAMERA_NETWORKS = list( //Those networks can only be accesse #define COLOR_PINK "#FF00FF" #define COLOR_YELLOW "#FFFF00" #define COLOR_ORANGE "#FF9900" -#define COLOR_WHITE "#FFFFFF" \ No newline at end of file +#define COLOR_WHITE "#FFFFFF" diff --git a/icons/mob/hud.dmi b/icons/mob/hud.dmi index 006a6c64b13c30782241ad090ec269f0b302d34f..0ea9293c2acc6f5a8b959bed768324f0488f2767 100644 GIT binary patch delta 575 zcmV-F0>J%;7mF9LmH~eydQ@0+L}hbha%pgMX>V=-0C=30m(On7Fbu}e$x{UFwHwl= z8G6}eXfgD#zCyuBw8ci2JW7t2J^kpU13F*k;~+tc^wm(}Bs=jDO5 zNKUJ-tNYLEa?vPtd|rP< zB}N4EOdjEWamom{Q<5}h?GX6v&h2`Q!w)mqFEiNt8SLG5j&n0u9KCR=Nyl@fqb;{L z+yCtQ1U~jisWK#tUZv#3im;CQYVrWx^ttIRMRH0EN!bPAhEpqvF>{m)le%CayP7c< zrb{~Z;wa{(5r=ZMttR0n#Z8-a1*bOQbN_ZEzlTs11IN?-5So1DdaUgvV%`vwi z-Ew05?DuE)84VWIE|)&AimU8GvYQA}-?X;UJV#6=P*XbrGvRMwXGqAi`B3G+SpKSK z$W;q2B`^R{th_7uhLOf2SQY~H5v&WlDUXsz59S8p-t2z`(EN{igbeMZgCgZf+dNO5 zREh=6Dl`HQX`euolcYC-42Xh>%Oaavj*?n%7OA0Fse~F&w&p-^KFDv&2qlZfFHM772#|M?n7l8l( delta 571 zcmV-B0>u4`7l#+HmH~eudQ@0+L}hbha%pgMX>V=-0C=30mrZUPF${&*_9={Hn-)$S z7u|GIBq*|It`N`?XT(G!O(~6C_w?o1DUbq9@wC$zpCnRz{PE@L>;1Qf$JO2UhvlBN zNKUIStJ{z3<>DZ|2K(6DEEj>L5B2;}Dpj`SMVNeGiZvWBmJ5F`TI|Q`<)Tv>_`H6L zN{k5RnLNV%=JJ;(q4u5W7KQ*wo4eZUf#kmF+N8dTsq~kf#(U#k* z?LYQ?03Z86sWK#tQKjU>im;BxYVrWx^tl@?MRH0EN!bPAj#Dp*F>{m)le%CayP7c< z=1T_l;wa{>6Ni6Y^%Oab4j*@zC7OA0Fse~F&w&p-^KFBZ22qg4*MWZcxLCH_P42yWx8?ZfveLe~$%ZeIQ~ZgmPpm z7<;m6Zgnor7Afy@oaVAl3N_TZ1vhUh$22#oisk+k|JQ{tSND&1r@son0aNy>#DrdU J6SKqv#|K~(6(#@x