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

SSTurrets #3453

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
#define INIT_ORDER_ATOMS 30
#define INIT_ORDER_LANGUAGE 25
#define INIT_ORDER_MACHINES 20
#define INIT_ORDER_TURRETS 17
#define INIT_ORDER_SKILLS 15
#define INIT_ORDER_TIMER 1
#define INIT_ORDER_DEFAULT 0
Expand Down
41 changes: 41 additions & 0 deletions code/controllers/subsystem/turrets.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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
3 changes: 2 additions & 1 deletion code/game/machinery/porta_turret/portable_turret.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ DEFINE_BITFIELD(turret_flags, list(
integrity_failure = 0.5
armor = list("melee" = 50, "bullet" = 30, "laser" = 30, "energy" = 30, "bomb" = 30, "bio" = 0, "rad" = 0, "fire" = 90, "acid" = 90)
base_icon_state = "standard"
subsystem_type = /datum/controller/subsystem/turrets
/// Scan range of the turret for locating targets
var/scan_range = 7
/// For turrets inside other objects
Expand Down Expand Up @@ -79,7 +80,7 @@ DEFINE_BITFIELD(turret_flags, list(
var/obj/machinery/porta_turret_cover/cover = null
/// World.time the turret last fired
var/last_fired = 0
/// Ticks until next shot (1.5 ?)
/// Ticks until next shot (1.5 ?) If this needs to go below 5, use SSFastProcess
var/shot_delay = 15
/// Turret flags about who is turret allowed to shoot
var/turret_flags = TURRET_FLAG_SHOOT_CRIMINALS | TURRET_FLAG_SHOOT_ANOMALOUS
Expand Down
1 change: 1 addition & 0 deletions shiptest.dme
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@
#include "code\controllers\subsystem\title.dm"
#include "code\controllers\subsystem\traumas.dm"
#include "code\controllers\subsystem\turf_fire.dm"
#include "code\controllers\subsystem\turrets.dm"
#include "code\controllers\subsystem\verb_manager.dm"
#include "code\controllers\subsystem\vis_overlays.dm"
#include "code\controllers\subsystem\vote.dm"
Expand Down
Loading