mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-31 20:11:56 +00:00
Please refer to #20867 and #20870 for a easier view of the changes. Those two PRs show all meaningful changes (hopefully) and doesn't show the files changed with just 3 lines changed. This PR does three things: It makes all children of /obj/ use the same damage system. Previously to make your new machine/structure be destroyable you needed to give it a var/health, and its own version of many damage related proc such as bullet_act(), take_damage(), attacked_by(), attack_animal(), attack_hulk(), ex_act(), etc... But now, all /obj/ use the same version of those procs at the /obj/ level in code/game/obj_defense.dm. All these obj share the same necessary vars: obj_integrity (health), max_integrity, integrity_failure (optional, below that health level failure happens), and the armor list var which was previously only for items, as well as the resistance_flags bitfield. When you want your new object to be destroyable, you only have to give it a value for those vars and maybe override one proc if you want a special behavior but that's it. This reorganization removes a lot of copypasta (most bullet_act() version for each obj were nearly identical). Two new elements are added to the armor list var: fire and acid armor values. How much damage an obj take depends on the armor value for each damage category. But some objects are INDESTRUCTIBLE and simply never take any damage no matter the type. The armor categories are: -melee(punches, item attacks, xeno/animal/hulk attacks, blob attacks, thrown weapons) -bullet -laser -energy (used by projectiles like ionrifle, taser, and also by EMPs) -bio (unused for this, only here because clothes use them when worn) -rad (same) -bomb (self-explanatory) -fire (for fire damage, not for heat damage though) -acid For machines and structures, when their health reaches zero the object is not just deleted but gets somewhat forcedeconstructed (the proc used is shared with the actual deconstruction system) which can drops things. To not frustrates players most of these objects drop most of the elements necessary to rebuild them (think window dropping shards). Machines drop a machine frame and all components for example (but the frame can then be itself smashed to pieces). For clothes, when they are damaged, they get a "damaged" overlay, which can also be seen when worn, similar to the "bloody" overlay. It refactors acid. See #20537. Some objects are ACID_PROOF and take no damage from acid, while others take varying amounts of damage depending on their acid armor value. Some objects are even UNACIDABLE, no acid effect can even land on them. Acid on objects can be washed off using water. It changes some aspect of damage from fires. All /obj/ can now take fire damage and be flammable, instead of just items. And instead of having just FLAMMABLE objs that become ON_FIRE as soon as some fire touch them (paper), we now have objects that are non flammable but do take damage from fire and become ashes if their health reaches zero (only for items). The damage taken varies depending on the obj's fire armor value and total health. There's also still obj and items that are FIRE_PROOF (although some might still be melted by lava if they're not LAVA_PROOF). When a mob is on fire, its clothes now take fire damage and can turn to ashes. Similarly, when a mob takes melee damages, its clothes gets damaged a bit and can turn to shreds. You can repair clothes with cloth that is produceable by botany's biogenerator. It also does many minor things: Clicking a structure/machine with an item on help intent never results in an attack (so you don't destroy a structure while trying to figure out which tool to use). I moved a lot of objects away from /obj/effect, it should only be used for visual effects, decals and stuff, not for things you can hit and destroy. I tweaked a bit how clothes shredding from bombs work. I made a machine or structure un/anchorable with the wrench, I don't remember which object... Since I changed the meaning of the FIRE_PROOF bitflag to actually mean fire immune, I'm buffing the slime extract that you apply on items to make them fire proof. well now they're really 100% fire proof! animals with environment_smash = 1 no longer one-hit destroy tables and stuff, we give them a decent obj_damage value so they can destroy most obj relatively fast depending on the animal. Probably a million things I forgot. If you want to know how the damage system works all you need is the three obj vars "obj_integrity", "max_integrity", "integrity_failure", as well as the armor list var and the resistance_flags bitfield, and read the file obj_defense.dm
367 lines
11 KiB
Plaintext
367 lines
11 KiB
Plaintext
/*
|
|
* Data HUDs have been rewritten in a more generic way.
|
|
* In short, they now use an observer-listener pattern.
|
|
* See code/datum/hud.dm for the generic hud datum.
|
|
* Update the HUD icons when needed with the appropriate hook. (see below)
|
|
*/
|
|
|
|
/* DATA HUD DATUMS */
|
|
|
|
/atom/proc/add_to_all_human_data_huds()
|
|
for(var/datum/atom_hud/data/human/hud in huds) hud.add_to_hud(src)
|
|
|
|
/atom/proc/remove_from_all_data_huds()
|
|
for(var/datum/atom_hud/data/hud in huds) hud.remove_from_hud(src)
|
|
|
|
/datum/atom_hud/data
|
|
|
|
/datum/atom_hud/data/human/medical
|
|
hud_icons = list(STATUS_HUD, HEALTH_HUD)
|
|
|
|
/datum/atom_hud/data/human/medical/basic
|
|
|
|
/datum/atom_hud/data/human/medical/basic/proc/check_sensors(mob/living/carbon/human/H)
|
|
if(!istype(H)) return 0
|
|
var/obj/item/clothing/under/U = H.w_uniform
|
|
if(!istype(U)) return 0
|
|
if(U.sensor_mode <= 2) return 0
|
|
return 1
|
|
|
|
/datum/atom_hud/data/human/medical/basic/add_to_single_hud(mob/M, mob/living/carbon/H)
|
|
if(check_sensors(H))
|
|
..()
|
|
|
|
/datum/atom_hud/data/human/medical/basic/proc/update_suit_sensors(mob/living/carbon/H)
|
|
check_sensors(H) ? add_to_hud(H) : remove_from_hud(H)
|
|
|
|
/datum/atom_hud/data/human/medical/advanced
|
|
|
|
/datum/atom_hud/data/human/security
|
|
|
|
/datum/atom_hud/data/human/security/basic
|
|
hud_icons = list(ID_HUD)
|
|
|
|
/datum/atom_hud/data/human/security/advanced
|
|
hud_icons = list(ID_HUD, IMPTRACK_HUD, IMPLOYAL_HUD, IMPCHEM_HUD, WANTED_HUD)
|
|
|
|
/datum/atom_hud/data/diagnostic
|
|
hud_icons = list (DIAG_HUD, DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_MECH_HUD, DIAG_BOT_HUD)
|
|
|
|
/* MED/SEC/DIAG HUD HOOKS */
|
|
|
|
/*
|
|
* THESE HOOKS SHOULD BE CALLED BY THE MOB SHOWING THE HUD
|
|
*/
|
|
|
|
/***********************************************
|
|
Medical HUD! Basic mode needs suit sensors on.
|
|
************************************************/
|
|
|
|
//HELPERS
|
|
|
|
//called when a carbon changes virus
|
|
/mob/living/carbon/proc/check_virus()
|
|
var/threat = 0
|
|
for(var/datum/disease/D in viruses)
|
|
if(!(D.visibility_flags & HIDDEN_SCANNER))
|
|
if (D.severity != NONTHREAT) //a buffing virus gets an icon
|
|
threat = 2
|
|
return threat //harmful viruses have priority
|
|
else
|
|
threat = 1 //aka good virus
|
|
|
|
return threat
|
|
|
|
//helper for getting the appropriate health status
|
|
/proc/RoundHealth(mob/living/M)
|
|
if(M.stat == DEAD || (M.status_flags & FAKEDEATH))
|
|
return "health-100" //what's our health? it doesn't matter, we're dead, or faking
|
|
var/maxi_health = M.maxHealth
|
|
if(iscarbon(M) && M.health < 0)
|
|
maxi_health = 100 //so crit shows up right for aliens and other high-health carbon mobs; noncarbons don't have crit.
|
|
var/resulthealth = (M.health / maxi_health) * 100
|
|
switch(resulthealth)
|
|
if(100 to INFINITY)
|
|
return "health100"
|
|
if(90.625 to 100)
|
|
return "health93.75"
|
|
if(84.375 to 90.625)
|
|
return "health87.5"
|
|
if(78.125 to 84.375)
|
|
return "health81.25"
|
|
if(71.875 to 78.125)
|
|
return "health75"
|
|
if(65.625 to 71.875)
|
|
return "health68.75"
|
|
if(59.375 to 65.625)
|
|
return "health62.5"
|
|
if(53.125 to 59.375)
|
|
return "health56.25"
|
|
if(46.875 to 53.125)
|
|
return "health50"
|
|
if(40.625 to 46.875)
|
|
return "health43.75"
|
|
if(34.375 to 40.625)
|
|
return "health37.5"
|
|
if(28.125 to 34.375)
|
|
return "health31.25"
|
|
if(21.875 to 28.125)
|
|
return "health25"
|
|
if(15.625 to 21.875)
|
|
return "health18.75"
|
|
if(9.375 to 15.625)
|
|
return "health12.5"
|
|
if(1 to 9.375)
|
|
return "health6.25"
|
|
if(-50 to 1)
|
|
return "health0"
|
|
if(-85 to -50)
|
|
return "health-50"
|
|
if(-99 to -85)
|
|
return "health-85"
|
|
else
|
|
return "health-100"
|
|
return "0"
|
|
|
|
//HOOKS
|
|
|
|
//called when a human changes suit sensors
|
|
/mob/living/carbon/proc/update_suit_sensors()
|
|
var/datum/atom_hud/data/human/medical/basic/B = huds[DATA_HUD_MEDICAL_BASIC]
|
|
B.update_suit_sensors(src)
|
|
|
|
var/turf/T = get_turf(src)
|
|
if (T) crewmonitor.queueUpdate(T.z)
|
|
|
|
//called when a living mob changes health
|
|
/mob/living/proc/med_hud_set_health()
|
|
var/image/holder = hud_list[HEALTH_HUD]
|
|
holder.icon_state = "hud[RoundHealth(src)]"
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
|
|
//for carbon suit sensors
|
|
/mob/living/carbon/med_hud_set_health()
|
|
..()
|
|
|
|
var/turf/T = get_turf(src)
|
|
if(T)
|
|
crewmonitor.queueUpdate(T.z)
|
|
|
|
//called when a carbon changes stat, virus or XENO_HOST
|
|
/mob/living/proc/med_hud_set_status()
|
|
var/image/holder = hud_list[STATUS_HUD]
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
if(stat == DEAD || (status_flags & FAKEDEATH))
|
|
holder.icon_state = "huddead"
|
|
else
|
|
holder.icon_state = "hudhealthy"
|
|
|
|
/mob/living/carbon/med_hud_set_status()
|
|
var/image/holder = hud_list[STATUS_HUD]
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
var/virus_state = check_virus()
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
if(status_flags & XENO_HOST)
|
|
holder.icon_state = "hudxeno"
|
|
else if(stat == DEAD || (status_flags & FAKEDEATH))
|
|
holder.icon_state = "huddead"
|
|
else if(virus_state == 2)
|
|
holder.icon_state = "hudill"
|
|
else if(virus_state == 1)
|
|
holder.icon_state = "hudbuff"
|
|
else
|
|
holder.icon_state = "hudhealthy"
|
|
|
|
|
|
/***********************************************
|
|
Security HUDs! Basic mode shows only the job.
|
|
************************************************/
|
|
|
|
//HOOKS
|
|
|
|
/mob/living/carbon/human/proc/sec_hud_set_ID()
|
|
var/image/holder = hud_list[ID_HUD]
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
holder.icon_state = "hudno_id"
|
|
if(wear_id)
|
|
holder.icon_state = "hud[ckey(wear_id.GetJobName())]"
|
|
sec_hud_set_security_status()
|
|
|
|
var/turf/T = get_turf(src)
|
|
if (T) crewmonitor.queueUpdate(T.z)
|
|
|
|
/mob/living/carbon/human/proc/sec_hud_set_implants()
|
|
var/image/holder
|
|
for(var/i in list(IMPTRACK_HUD, IMPLOYAL_HUD, IMPCHEM_HUD))
|
|
holder = hud_list[i]
|
|
holder.icon_state = null
|
|
for(var/obj/item/weapon/implant/I in src)
|
|
if(I.implanted)
|
|
if(istype(I,/obj/item/weapon/implant/tracking))
|
|
holder = hud_list[IMPTRACK_HUD]
|
|
var/icon/IC = icon(icon, icon_state, dir)
|
|
holder.pixel_y = IC.Height() - world.icon_size
|
|
holder.icon_state = "hud_imp_tracking"
|
|
else if(istype(I,/obj/item/weapon/implant/mindshield))
|
|
holder = hud_list[IMPLOYAL_HUD]
|
|
var/icon/IC = icon(icon, icon_state, dir)
|
|
holder.pixel_y = IC.Height() - world.icon_size
|
|
holder.icon_state = "hud_imp_loyal"
|
|
else if(istype(I,/obj/item/weapon/implant/chem))
|
|
holder = hud_list[IMPCHEM_HUD]
|
|
var/icon/IC = icon(icon, icon_state, dir)
|
|
holder.pixel_y = IC.Height() - world.icon_size
|
|
holder.icon_state = "hud_imp_chem"
|
|
|
|
/mob/living/carbon/human/proc/sec_hud_set_security_status()
|
|
var/image/holder = hud_list[WANTED_HUD]
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
var/perpname = get_face_name(get_id_name(""))
|
|
if(perpname)
|
|
var/datum/data/record/R = find_record("name", perpname, data_core.security)
|
|
if(R)
|
|
switch(R.fields["criminal"])
|
|
if("*Arrest*")
|
|
holder.icon_state = "hudwanted"
|
|
return
|
|
if("Incarcerated")
|
|
holder.icon_state = "hudincarcerated"
|
|
return
|
|
if("Parolled")
|
|
holder.icon_state = "hudparolled"
|
|
return
|
|
if("Discharged")
|
|
holder.icon_state = "huddischarged"
|
|
return
|
|
holder.icon_state = null
|
|
|
|
/***********************************************
|
|
Diagnostic HUDs!
|
|
************************************************/
|
|
|
|
//For Diag health and cell bars!
|
|
/proc/RoundDiagBar(value)
|
|
switch(value * 100)
|
|
if(95 to INFINITY)
|
|
return "max"
|
|
if(80 to 100)
|
|
return "good"
|
|
if(60 to 80)
|
|
return "high"
|
|
if(40 to 60)
|
|
return "med"
|
|
if(20 to 40)
|
|
return "low"
|
|
if(1 to 20)
|
|
return "crit"
|
|
else
|
|
return "dead"
|
|
return "dead"
|
|
|
|
//Sillycone hooks
|
|
/mob/living/silicon/proc/diag_hud_set_health()
|
|
var/image/holder = hud_list[DIAG_HUD]
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
if(stat == DEAD)
|
|
holder.icon_state = "huddiagdead"
|
|
else
|
|
holder.icon_state = "huddiag[RoundDiagBar(health/maxHealth)]"
|
|
|
|
/mob/living/silicon/proc/diag_hud_set_status()
|
|
var/image/holder = hud_list[DIAG_STAT_HUD]
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
switch(stat)
|
|
if(CONSCIOUS)
|
|
holder.icon_state = "hudstat"
|
|
if(UNCONSCIOUS)
|
|
holder.icon_state = "hudoffline"
|
|
else
|
|
holder.icon_state = "huddead2"
|
|
|
|
//Borgie battery tracking!
|
|
/mob/living/silicon/robot/proc/diag_hud_set_borgcell()
|
|
var/image/holder = hud_list[DIAG_BATT_HUD]
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
if(cell)
|
|
var/chargelvl = (cell.charge/cell.maxcharge)
|
|
holder.icon_state = "hudbatt[RoundDiagBar(chargelvl)]"
|
|
else
|
|
holder.icon_state = "hudnobatt"
|
|
|
|
/*~~~~~~~~~~~~~~~~~~~~
|
|
BIG STOMPY MECHS
|
|
~~~~~~~~~~~~~~~~~~~~~*/
|
|
/obj/mecha/proc/diag_hud_set_mechhealth()
|
|
var/image/holder = hud_list[DIAG_MECH_HUD]
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
holder.icon_state = "huddiag[RoundDiagBar(obj_integrity/max_integrity)]"
|
|
|
|
|
|
/obj/mecha/proc/diag_hud_set_mechcell()
|
|
var/image/holder = hud_list[DIAG_BATT_HUD]
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
if(cell)
|
|
var/chargelvl = cell.charge/cell.maxcharge
|
|
holder.icon_state = "hudbatt[RoundDiagBar(chargelvl)]"
|
|
else
|
|
holder.icon_state = "hudnobatt"
|
|
|
|
|
|
/obj/mecha/proc/diag_hud_set_mechstat()
|
|
var/image/holder = hud_list[DIAG_STAT_HUD]
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
holder.icon_state = null
|
|
if(internal_damage)
|
|
holder.icon_state = "hudwarn"
|
|
|
|
/*~~~~~~~~~
|
|
Bots!
|
|
~~~~~~~~~~*/
|
|
/mob/living/simple_animal/bot/proc/diag_hud_set_bothealth()
|
|
var/image/holder = hud_list[DIAG_HUD]
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
holder.icon_state = "huddiag[RoundDiagBar(health/maxHealth)]"
|
|
|
|
/mob/living/simple_animal/bot/proc/diag_hud_set_botstat() //On (With wireless on or off), Off, EMP'ed
|
|
var/image/holder = hud_list[DIAG_STAT_HUD]
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
if(on)
|
|
holder.icon_state = "hudstat"
|
|
else if(stat) //Generally EMP causes this
|
|
holder.icon_state = "hudoffline"
|
|
else //Bot is off
|
|
holder.icon_state = "huddead2"
|
|
|
|
/mob/living/simple_animal/bot/proc/diag_hud_set_botmode() //Shows a bot's current operation
|
|
var/image/holder = hud_list[DIAG_BOT_HUD]
|
|
var/icon/I = icon(icon, icon_state, dir)
|
|
holder.pixel_y = I.Height() - world.icon_size
|
|
if(client) //If the bot is player controlled, it will not be following mode logic!
|
|
holder.icon_state = "hudsentient"
|
|
return
|
|
|
|
switch(mode)
|
|
if(BOT_SUMMON, BOT_RESPONDING) //Responding to PDA or AI summons
|
|
holder.icon_state = "hudcalled"
|
|
if(BOT_CLEANING, BOT_REPAIRING, BOT_HEALING) //Cleanbot cleaning, Floorbot fixing, or Medibot Healing
|
|
holder.icon_state = "hudworking"
|
|
if(BOT_PATROL, BOT_START_PATROL) //Patrol mode
|
|
holder.icon_state = "hudpatrol"
|
|
if(BOT_PREP_ARREST, BOT_ARREST, BOT_HUNT) //STOP RIGHT THERE, CRIMINAL SCUM!
|
|
holder.icon_state = "hudalert"
|
|
if(BOT_MOVING, BOT_DELIVER, BOT_GO_HOME, BOT_NAV) //Moving to target for normal bots, moving to deliver or go home for MULES.
|
|
holder.icon_state = "hudmove"
|
|
else
|
|
holder.icon_state = "" |