-
-
Notifications
You must be signed in to change notification settings - Fork 539
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may not be viewable. --> <!-- You can view Contributing.MD for a detailed description of the pull request process. --> ## About The Pull Request Turret code was absolute garbage. This goes through and re-does practically all of it, plus adds some new goodies for good measure. Adds my own half-baked "simple beam" system, for when performance is allegedly important and you don't care that they look ugly and only show up when you can see the source object. ## Why It's Good For The Game Not spending so much time processing JUST turrets is super nice. Plus giving players the ability to actually control their turrets more is nice. ## Changelog :cl: add: You can now set turrets to filter by faction, mob type, and a few more criteria including "dangerous only" as well as the ability to disable retaliation. add: Turret retaliation is a lot more vengeful. Don't mess with them. add: Turrets will now spend a short time targetting you, pointing a beam at you to indicate that they're doing so. del: Turret covers, because they sucked. fix: Turretcode is a LOT less laggy. tweak: Turrets are now built like normal machines. The boards are currently not available (except through salvaging). tweak: You can now access full turret settings from the turret control panel. /:cl: <!-- Both :cl:'s are required for the changelog to work! You can put your name to the right of the first :cl: if you want to overwrite your GitHub username as author ingame. --> <!-- You can use multiple of the same prefix (they're only used for the icon ingame) and delete the unneeded ones. Despite some of the tags, changelogs should generally represent how a player might be affected by the changes rather than a summary of the PR's contents. -->
- Loading branch information
1 parent
126b402
commit 2dc59a5
Showing
28 changed files
with
1,344 additions
and
1,595 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,4 @@ | ||
SUBSYSTEM_DEF(turrets) | ||
PROCESSING_SUBSYSTEM_DEF(turrets) | ||
name = "Turrets" | ||
wait = 5 | ||
init_order = INIT_ORDER_MACHINES | ||
flags = SS_KEEP_TIMING | ||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME | ||
var/list/processing = list() | ||
var/list/currentrun = list() | ||
|
||
/datum/controller/subsystem/turrets/get_metrics() | ||
. = ..() | ||
var/list/cust = list() | ||
cust["processing"] = length(processing) | ||
.["custom"] = cust | ||
|
||
/datum/controller/subsystem/turrets/stat_entry(msg) | ||
msg = "M:[length(processing)]]" | ||
return ..() | ||
|
||
|
||
/datum/controller/subsystem/turrets/fire(resumed = 0) | ||
if (!resumed) | ||
src.currentrun = processing.Copy() | ||
|
||
//cache for sanic speed (lists are references anyways) | ||
var/list/currentrun = src.currentrun | ||
|
||
var/seconds = wait * 0.1 | ||
while(currentrun.len) | ||
var/obj/machinery/thing = currentrun[currentrun.len] | ||
currentrun.len-- | ||
if(QDELETED(thing) || thing.process(seconds) == PROCESS_KILL) | ||
processing -= thing | ||
if (!QDELETED(thing)) | ||
thing.datum_flags &= ~DF_ISPROCESSING | ||
if (MC_TICK_CHECK) | ||
return | ||
|
||
/datum/controller/subsystem/turrets/Recover() | ||
if (istype(SSturrets.processing)) | ||
processing = SSmachines.processing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/datum/simple_beam | ||
///The source of the beam, which must be visible for the beam to be seen. Can NOT be null. | ||
VAR_PRIVATE/atom/movable/origin | ||
///The target of the beam. Can be null. | ||
VAR_PRIVATE/atom/movable/target | ||
///The visual representation of the beam. | ||
VAR_PRIVATE/obj/effect/simple_beam/its_beam | ||
|
||
/datum/simple_beam/New(_origin, _target, icon = 'icons/effects/beam.dmi', icon_state = "1-full", icon_color = null, icon_alpha = 255) | ||
origin = _origin | ||
target = _target | ||
|
||
its_beam = new /obj/effect/simple_beam(origin, icon, icon_state, icon_color, icon_alpha) | ||
origin.vis_contents += its_beam | ||
|
||
set_target(target) | ||
|
||
/datum/simple_beam/Destroy(force) | ||
origin.vis_contents -= its_beam | ||
QDEL_NULL(its_beam) | ||
|
||
if(target) | ||
UnregisterSignal(origin, COMSIG_MOVABLE_MOVED) | ||
UnregisterSignal(target, COMSIG_MOVABLE_MOVED) | ||
|
||
return ..() | ||
|
||
/datum/simple_beam/proc/draw() | ||
if(origin.z != target.z) | ||
set_target(null) | ||
return | ||
|
||
var/f_dx = ((target.pixel_x - origin.pixel_x + 16) / world.icon_size) + (target.x - origin.x) | ||
var/f_dy = ((target.pixel_y - origin.pixel_y) / world.icon_size) + (target.y - origin.y) | ||
var/dist = sqrt(f_dx * f_dx + f_dy * f_dy) | ||
var/s_dx = f_dy/dist | ||
var/s_dy = -f_dx/dist | ||
var/matrix/translation = matrix() | ||
translation.Translate(0, 16) | ||
translation.Multiply(new /matrix(s_dx, f_dx, 0, s_dy, f_dy, 0)) | ||
|
||
its_beam.transform = translation | ||
|
||
/datum/simple_beam/proc/set_target(new_target) | ||
if(target) | ||
UnregisterSignal(target, COMSIG_MOVABLE_MOVED) | ||
UnregisterSignal(origin, COMSIG_MOVABLE_MOVED) | ||
|
||
target = new_target | ||
|
||
if(target) | ||
its_beam.vis_flags &= ~VIS_HIDE | ||
|
||
RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(draw)) | ||
RegisterSignal(origin, COMSIG_MOVABLE_MOVED, PROC_REF(draw)) | ||
|
||
draw() | ||
else | ||
its_beam.vis_flags |= VIS_HIDE | ||
|
||
/obj/effect/simple_beam | ||
layer = ABOVE_LIGHTING_LAYER | ||
plane = ABOVE_LIGHTING_PLANE | ||
|
||
/obj/effect/simple_beam/New(loc, icon, icon_state, icon_color, icon_alpha) | ||
src.icon = icon | ||
src.icon_state = icon_state | ||
src.color = icon_color | ||
src.alpha = icon_alpha | ||
|
||
return ..() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.