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

Siege Warfare: Energy Shield Edition #210

Merged
merged 4 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions code/__HELPERS/maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,41 @@
line += locate(current_x_step, current_y_step, starting_z)
return line

/**
* Get a list of turfs in a perimeter given the `center_atom` and `radius`.
* Automatically rounds down decimals and does not accept values less than positive 1 as they dont play well with it.
* Is efficient on large circles but ugly on small ones
* Uses [Jesko`s method to the midpoint circle Algorithm](https://en.wikipedia.org/wiki/Midpoint_circle_algorithm).
*/
/proc/get_perimeter(atom/center, radius)
if(radius < 1)
return
var/rounded_radius = round(radius)
var/x = center.x
var/y = center.y
var/z = center.z
var/t1 = rounded_radius/16
var/dx = rounded_radius
var/dy = 0
var/t2
var/list/perimeter = list()
while(dx >= dy)
perimeter += locate(x + dx, y + dy, z)
perimeter += locate(x - dx, y + dy, z)
perimeter += locate(x + dx, y - dy, z)
perimeter += locate(x - dx, y - dy, z)
perimeter += locate(x + dy, y + dx, z)
perimeter += locate(x - dy, y + dx, z)
perimeter += locate(x + dy, y - dx, z)
perimeter += locate(x - dy, y - dx, z)
dy += 1
t1 += dy
t2 = t1 - dx
if(t2 > 0)
t1 = t2
dx -= 1
return perimeter

///Format a power value in W, kW, MW, or GW.
/proc/display_power(powerused)
if(powerused < 1000) //Less than a kW
Expand Down
8 changes: 7 additions & 1 deletion code/datums/elements/blocks_explosives.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// Apply this element to a movable atom when you want it to block explosions
/// It will mirror the blocking down to that movable's turf, keeping explosion work cheap
/datum/element/blocks_explosives
element_flags = ELEMENT_DETACH_ON_HOST_DESTROY

/datum/element/blocks_explosives/Attach(datum/target)
if(!ismovable(target))
Expand All @@ -18,8 +19,13 @@
else if(moving_target.loc)
block_loc(moving_target.loc, moving_target.explosion_block)

/datum/element/blocks_explosives/Detach(datum/source)
/datum/element/blocks_explosives/Detach(atom/movable/source)
. = ..()
if(length(source.locs) > 1)
for(var/atom/location as anything in source.locs)
unblock_loc(location, source.explosion_block)
else if(source.loc)
unblock_loc(source.loc, source.explosion_block)
REMOVE_TRAIT(source, TRAIT_BLOCKING_EXPLOSIVES, TRAIT_GENERIC)

/// Call this when our blocking well, changes. we'll update our turf(s) with the details
Expand Down
Loading
Loading