Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Damage propagation for stock_parts and SMES overload (fixes #3457) #3460

Merged
merged 1 commit into from
Oct 22, 2023

Conversation

cyberillithid
Copy link
Contributor

Description of changes

Changed APCs failure from plain set_broken(TRUE) to getting dealt electrocute damage in SMES failure procedures.

To allow that to break more than a singular stock_part, damage returned from take_damage should be changed from being reduced only by armor (unapplicable to stock parts) to keeping track of the health the item had before damage; thus, sufficient amount of damage to machinery will dismantle it in one hit.

Why and what will this PR improve

Will make APCs repairable after SMES failures.

Authorship

Myself

Changelog

🆑
tweak: changed the SMES overloading APC failure damage
bugfix: fixed APCs being stuck irrepairable on overloading
bugfix: fixed clamping any machinery damage to one part per hit
/:cl:

@@ -18,9 +18,11 @@
return 0 //must return a number

//Apply damage
var/damage_taken = health // Initialize with current health value...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right to me - I feel like just doing damage = min(health, damage) and otherwise leaving the logic unchanged would do the job.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proc claims to return the damage taken by the object, not the amount of health left after taking damage.

Copy link
Contributor Author

@cyberillithid cyberillithid Oct 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's what I'm doing here, but the min is definitely more elegant.
On the other side, since we're already removed the <0 cases, even clamp could be removed? But alright.

for(var/obj/machinery/power/terminal/T in powernet.nodes)
var/obj/machinery/power/apc/A = T.master_machine()
if(istype(A))
if (prob(overload_chance))
A.overload_lighting()
if (prob(failure_chance))
A.set_broken(TRUE)
if (!(A in apcs))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apcs |= A will do a non-duplicating add, for reference.

@MistakeNot4892 MistakeNot4892 added the awaiting author This PR is awaiting action from the author before it can be merged. label Oct 21, 2023
@MistakeNot4892 MistakeNot4892 merged commit f7b7e32 into NebulaSS13:stable Oct 22, 2023
11 checks passed
@cyberillithid cyberillithid deleted the smesfailure branch October 23, 2023 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting author This PR is awaiting action from the author before it can be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants