mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-23 07:26:05 +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
149 lines
5.7 KiB
Plaintext
149 lines
5.7 KiB
Plaintext
// Global var to track modular computers
|
|
var/list/global_modular_computers = list()
|
|
|
|
// Modular Computer - device that runs various programs and operates with hardware
|
|
// DO NOT SPAWN THIS TYPE. Use /laptop/ or /console/ instead.
|
|
/obj/machinery/modular_computer
|
|
name = "modular computer"
|
|
desc = "An advanced computer."
|
|
|
|
use_power = 1
|
|
idle_power_usage = 5
|
|
var/hardware_flag = 0 // A flag that describes this device type
|
|
var/last_power_usage = 0 // Power usage during last tick
|
|
|
|
// Modular computers can run on various devices. Each DEVICE (Laptop, Console, Tablet,..)
|
|
// must have it's own DMI file. Icon states must be called exactly the same in all files, but may look differently
|
|
// If you create a program which is limited to Laptops and Consoles you don't have to add it's icon_state overlay for Tablets too, for example.
|
|
|
|
icon = null
|
|
icon_state = null
|
|
var/icon_state_unpowered = null // Icon state when the computer is turned off.
|
|
var/icon_state_powered = null // Icon state when the computer is turned on.
|
|
var/screen_icon_state_menu = "menu" // Icon state overlay when the computer is turned on, but no program is loaded that would override the screen.
|
|
var/screen_icon_screensaver = "standby" // Icon state overlay when the computer is powered, but not 'switched on'.
|
|
var/max_hardware_size = 0 // Maximal hardware size. Currently, tablets have 1, laptops 2 and consoles 3. Limits what hardware types can be installed.
|
|
var/steel_sheet_cost = 10 // Amount of steel sheets refunded when disassembling an empty frame of this computer.
|
|
var/light_strength = 0 // Light luminosity when turned on
|
|
var/base_active_power_usage = 100 // Power usage when the computer is open (screen is active) and can be interacted with. Remember hardware can use power too.
|
|
var/base_idle_power_usage = 10 // Power usage when the computer is idle and screen is off (currently only applies to laptops)
|
|
|
|
var/obj/item/device/modular_computer/processor/cpu = null // CPU that handles most logic while this type only handles power and other specific things.
|
|
|
|
/obj/machinery/modular_computer/New()
|
|
..()
|
|
cpu = new(src)
|
|
cpu.physical = src
|
|
global_modular_computers.Add(src)
|
|
|
|
/obj/machinery/modular_computer/Destroy()
|
|
if(cpu)
|
|
qdel(cpu)
|
|
cpu = null
|
|
return ..()
|
|
|
|
/obj/machinery/modular_computer/attack_ghost(mob/dead/observer/user)
|
|
if(cpu)
|
|
cpu.attack_ghost(user)
|
|
|
|
/obj/machinery/modular_computer/emag_act(mob/user)
|
|
return cpu ? cpu.emag_act(user) : 1
|
|
|
|
/obj/machinery/modular_computer/update_icon()
|
|
cut_overlays()
|
|
icon_state = icon_state_powered
|
|
|
|
if(!cpu || !cpu.enabled)
|
|
if (!(stat & NOPOWER) && (cpu && cpu.use_power()))
|
|
add_overlay(screen_icon_screensaver)
|
|
else
|
|
icon_state = icon_state_unpowered
|
|
SetLuminosity(0)
|
|
else
|
|
SetLuminosity(light_strength)
|
|
if(cpu.active_program)
|
|
add_overlay(cpu.active_program.program_icon_state ? cpu.active_program.program_icon_state : screen_icon_state_menu)
|
|
else
|
|
overlays.Add(screen_icon_state_menu)
|
|
|
|
if(cpu && cpu.obj_integrity <= cpu.integrity_failure)
|
|
add_overlay("bsod")
|
|
add_overlay("broken")
|
|
|
|
// Eject ID card from computer, if it has ID slot with card inside.
|
|
/obj/machinery/modular_computer/proc/eject_id()
|
|
set name = "Eject ID"
|
|
set category = "Object"
|
|
set src in view(1)
|
|
|
|
if(cpu)
|
|
cpu.eject_id()
|
|
|
|
// Eject ID card from computer, if it has ID slot with card inside.
|
|
/obj/machinery/modular_computer/proc/eject_disk()
|
|
set name = "Eject Data Disk"
|
|
set category = "Object"
|
|
set src in view(1)
|
|
|
|
if(cpu)
|
|
cpu.eject_disk()
|
|
|
|
/obj/machinery/modular_computer/AltClick(mob/user)
|
|
if(cpu)
|
|
cpu.AltClick(user)
|
|
|
|
// On-click handling. Turns on the computer if it's off and opens the GUI.
|
|
/obj/machinery/modular_computer/attack_hand(mob/user)
|
|
if(cpu)
|
|
cpu.attack_self(user) // CPU is an item, that's why we route attack_hand to attack_self
|
|
|
|
// Process currently calls handle_power(), may be expanded in future if more things are added.
|
|
/obj/machinery/modular_computer/process()
|
|
if(cpu)
|
|
// Keep names in sync.
|
|
cpu.name = src.name
|
|
cpu.process()
|
|
|
|
// Used in following function to reduce copypaste
|
|
/obj/machinery/modular_computer/proc/power_failure(malfunction = 0)
|
|
var/obj/item/weapon/computer_hardware/battery/battery_module = cpu.all_components[MC_CELL]
|
|
if(cpu && cpu.enabled) // Shut down the computer
|
|
visible_message("<span class='danger'>\The [src]'s screen flickers [battery_module ? "\"BATTERY [malfunction ? "MALFUNCTION" : "CRITICAL"]\"" : "\"EXTERNAL POWER LOSS\""] warning as it shuts down unexpectedly.</span>")
|
|
if(cpu)
|
|
cpu.shutdown_computer(0)
|
|
stat |= NOPOWER
|
|
update_icon()
|
|
|
|
|
|
// Modular computers can have battery in them, we handle power in previous proc, so prevent this from messing it up for us.
|
|
/obj/machinery/modular_computer/power_change()
|
|
if(cpu && cpu.use_power()) // If MC_CPU still has a power source, PC wouldn't go offline.
|
|
stat &= ~NOPOWER
|
|
update_icon()
|
|
return
|
|
..()
|
|
update_icon()
|
|
|
|
/obj/machinery/modular_computer/attackby(var/obj/item/weapon/W as obj, mob/user)
|
|
if(cpu)
|
|
return cpu.attackby(W, user)
|
|
return ..()
|
|
|
|
|
|
// Stronger explosions cause serious damage to internal components
|
|
// Minor explosions are mostly mitigitated by casing.
|
|
/obj/machinery/modular_computer/ex_act(severity)
|
|
if(cpu)
|
|
cpu.ex_act(severity)
|
|
|
|
// EMPs are similar to explosions, but don't cause physical damage to the casing. Instead they screw up the components
|
|
/obj/machinery/modular_computer/emp_act(severity)
|
|
if(cpu)
|
|
cpu.emp_act(severity)
|
|
|
|
// "Stun" weapons can cause minor damage to components (short-circuits?)
|
|
// "Burn" damage is equally strong against internal components and exterior casing
|
|
// "Brute" damage mostly damages the casing.
|
|
/obj/machinery/modular_computer/bullet_act(obj/item/projectile/Proj)
|
|
if(cpu)
|
|
cpu.bullet_act(Proj) |