[READY]Refactors timestops to use fields (#30858)

* kek

* fixes

* Fixes

* fixes

* throw freeze

* woops

* double woops
This commit is contained in:
kevinz000
2017-09-28 19:46:10 -07:00
committed by CitadelStationBot
parent d25894447e
commit 724fa8ce54
7 changed files with 150 additions and 87 deletions

View File

@@ -57,6 +57,9 @@ SUBSYSTEM_DEF(throwing)
var/pure_diagonal
var/diagonal_error
var/datum/callback/callback
var/paused = FALSE
var/delayed_time = 0
var/last_move = 0
/datum/thrownthing/proc/tick()
var/atom/movable/AM = thrownthing
@@ -64,14 +67,20 @@ SUBSYSTEM_DEF(throwing)
finalize()
return
if(paused)
delayed_time += world.time - last_move
return
if (dist_travelled && hitcheck()) //to catch sneaky things moving on our tile while we slept
finalize()
return
var/atom/step
last_move = world.time
//calculate how many tiles to move, making up for any missed ticks.
var/tilestomove = Ceiling(min(((((world.time+world.tick_lag) - start_time) * speed) - (dist_travelled ? dist_travelled : -1)), speed*MAX_TICKS_TO_MAKE_UP) * (world.tick_lag * SSthrowing.wait))
var/tilestomove = Ceiling(min(((((world.time+world.tick_lag) - start_time + delayed_time) * speed) - (dist_travelled ? dist_travelled : -1)), speed*MAX_TICKS_TO_MAKE_UP) * (world.tick_lag * SSthrowing.wait))
while (tilestomove-- > 0)
if ((dist_travelled >= maxrange || AM.loc == target_turf) && AM.has_gravity(AM.loc))
finalize()

View File

@@ -33,7 +33,7 @@
if(!force_rebuild && range == current_range)
return FALSE
. = TRUE
current_range = range
var/list/checkers_local = checkers

View File

@@ -30,6 +30,7 @@
//Processing
var/process_inner_turfs = FALSE //Don't do this unless it's absolutely necessary
var/process_edge_turfs = FALSE //Don't do this either unless it's absolutely necessary, you can just track what things are inside manually or on the initial setup.
var/requires_processing = FALSE
var/setup_edge_turfs = FALSE //Setup edge turfs/all field turfs. Set either or both to ON when you need it, it's defaulting to off unless you do to save CPU.
var/setup_field_turfs = FALSE
var/use_host_turf = FALSE //For fields from items carried on mobs to check turf instead of loc...
@@ -41,6 +42,7 @@
/datum/proximity_monitor/advanced/Destroy()
full_cleanup()
STOP_PROCESSING(SSfields, src)
return ..()
/datum/proximity_monitor/advanced/proc/assume_params(list/field_params)
@@ -76,6 +78,10 @@
/datum/proximity_monitor/advanced/proc/process_edge_turf(turf/T)
/datum/proximity_monitor/advanced/New()
if(requires_processing)
START_PROCESSING(SSfields, src)
/datum/proximity_monitor/advanced/proc/Initialize()
setup_field()
post_setup_field()
@@ -250,11 +256,6 @@
setup_field_turfs = TRUE
setup_edge_turfs = TRUE
/datum/proximity_monitor/advanced/debug/recalculate_field()
..()
/datum/proximity_monitor/advanced/debug/post_setup_field()
..()
/datum/proximity_monitor/advanced/debug/setup_edge_turf(turf/T)
T.color = set_edgeturf_color

View File

@@ -5,6 +5,7 @@
name = "\improper Hyperkinetic Dampener Field"
setup_edge_turfs = TRUE
setup_field_turfs = TRUE
requires_processing = TRUE
field_shape = FIELD_SHAPE_RADIUS_SQUARE
var/static/image/edgeturf_south = image('icons/effects/fields.dmi', icon_state = "projectile_dampen_south")
var/static/image/edgeturf_north = image('icons/effects/fields.dmi', icon_state = "projectile_dampen_north")
@@ -21,13 +22,11 @@
use_host_turf = TRUE
/datum/proximity_monitor/advanced/peaceborg_dampener/New()
START_PROCESSING(SSfields, src)
tracked = list()
staging = list()
..()
/datum/proximity_monitor/advanced/peaceborg_dampener/Destroy()
STOP_PROCESSING(SSfields, src)
return ..()
/datum/proximity_monitor/advanced/peaceborg_dampener/process()

View File

@@ -0,0 +1,131 @@
/obj/effect/timestop
anchored = TRUE
name = "chronofield"
desc = "ZA WARUDO"
icon = 'icons/effects/160x160.dmi'
icon_state = "time"
layer = FLY_LAYER
pixel_x = -64
pixel_y = -64
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
var/list/immune = list() // the one who creates the timestop is immune
var/turf/target
var/freezerange = 2
var/duration = 140
var/datum/proximity_monitor/advanced/timestop/chronofield
alpha = 125
/obj/effect/timestop/Initialize(mapload, radius, time, list/immune_atoms, start = TRUE) //Immune atoms assoc list atom = TRUE
. = ..()
if(immune_atoms)
immune = immune_atoms.Copy()
if(!isnull(time))
duration = time
if(!isnull(radius))
freezerange = radius
for(var/mob/living/L in GLOB.player_list)
if(locate(/obj/effect/proc_holder/spell/aoe_turf/conjure/timestop) in L.mind.spell_list) //People who can stop time are immune to its effects
immune[L] = TRUE
if(start)
timestop()
/obj/effect/timestop/Destroy()
qdel(chronofield)
playsound(src, 'sound/magic/timeparadox2.ogg', 75, TRUE, frequency = -1) //reverse!
return ..()
/obj/effect/timestop/proc/timestop()
target = get_turf(src)
playsound(src, 'sound/magic/timeparadox2.ogg', 75, 1, -1)
chronofield = make_field(/datum/proximity_monitor/advanced/timestop, list("current_range" = freezerange, "host" = src, "immune" = immune))
QDEL_IN(src, duration)
/obj/effect/timestop/wizard
duration = 100
/datum/proximity_monitor/advanced/timestop
name = "chronofield"
setup_field_turfs = TRUE
field_shape = FIELD_SHAPE_RADIUS_SQUARE
requires_processing = TRUE
var/list/immune = list()
var/list/mob/living/frozen_mobs = list()
var/list/obj/item/projectile/frozen_projectiles = list()
var/list/atom/movable/frozen_throws = list()
/datum/proximity_monitor/advanced/timestop/Destroy()
unfreeze_all()
return ..()
/datum/proximity_monitor/advanced/timestop/field_turf_crossed(atom/movable/AM)
freeze_atom(AM)
/datum/proximity_monitor/advanced/timestop/proc/freeze_atom(atom/movable/A)
if(immune[A] || !istype(A))
return FALSE
if(A.throwing)
freeze_throwing(A)
if(isliving(A))
freeze_mob(A)
else if(istype(A, /obj/item/projectile))
freeze_projectile(A)
else
return FALSE
return TRUE
/datum/proximity_monitor/advanced/timestop/proc/unfreeze_all()
for(var/i in frozen_projectiles)
unfreeze_projectile(i)
for(var/i in frozen_mobs)
unfreeze_mob(i)
for(var/i in frozen_throws)
unfreeze_throw(i)
/datum/proximity_monitor/advanced/timestop/proc/freeze_throwing(atom/movable/AM)
var/datum/thrownthing/T = AM.throwing
T.paused = TRUE
frozen_throws[AM] = T
/datum/proximity_monitor/advanced/timestop/proc/unfreeze_throw(atom/movable/AM)
var/datum/thrownthing/T = frozen_throws[AM]
T.paused = FALSE
frozen_throws -= AM
/datum/proximity_monitor/advanced/timestop/process()
for(var/i in frozen_mobs)
var/mob/living/m = i
if(get_dist(get_turf(m), get_turf(host)) > current_range)
unfreeze_mob(m)
else
m.Stun(20, 1, 1)
/datum/proximity_monitor/advanced/timestop/setup_field_turf(turf/T)
for(var/i in T.contents)
freeze_atom(i)
return ..()
/datum/proximity_monitor/advanced/timestop/proc/unfreeze_projectile(obj/item/projectile/P)
frozen_projectiles -= P
P.paused = FALSE
/datum/proximity_monitor/advanced/timestop/proc/freeze_projectile(obj/item/projectile/P)
frozen_projectiles[P] = TRUE
P.paused = TRUE
/datum/proximity_monitor/advanced/timestop/proc/freeze_mob(mob/living/L)
L.Stun(20, 1, 1)
frozen_mobs[L] = L.anchored
L.anchored = TRUE
if(ishostile(L))
var/mob/living/simple_animal/hostile/H = L
H.AIStatus = AI_OFF
H.LoseTarget()
/datum/proximity_monitor/advanced/timestop/proc/unfreeze_mob(mob/living/L)
L.AdjustStun(-20, 1, 1)
L.anchored = frozen_mobs[L]
frozen_mobs -= L
if(ishostile(L))
var/mob/living/simple_animal/hostile/H = L
H.AIStatus = initial(H.AIStatus)

View File

@@ -542,84 +542,6 @@
log_admin("[key_name(G)] was made a golem by [key_name(user)].")
qdel(src)
/obj/effect/timestop
anchored = TRUE
name = "chronofield"
desc = "ZA WARUDO"
icon = 'icons/effects/160x160.dmi'
icon_state = "time"
layer = FLY_LAYER
pixel_x = -64
pixel_y = -64
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
var/mob/living/immune = list() // the one who creates the timestop is immune
var/list/stopped_atoms = list()
var/freezerange = 2
var/duration = 140
alpha = 125
/obj/effect/timestop/Initialize()
. = ..()
for(var/mob/living/L in GLOB.player_list)
if(locate(/obj/effect/proc_holder/spell/aoe_turf/conjure/timestop) in L.mind.spell_list) //People who can stop time are immune to its effects
immune += L
timestop()
/obj/effect/timestop/proc/timestop()
set waitfor = FALSE
playsound(src, 'sound/magic/timeparadox2.ogg', 75, 1, -1)
for(var/i in 1 to duration-1)
for(var/atom/A in orange (freezerange, src.loc))
if(isliving(A))
var/mob/living/M = A
if(M in immune)
continue
M.Stun(200, 1, 1)
M.anchored = TRUE
if(ishostile(M))
var/mob/living/simple_animal/hostile/H = M
H.AIStatus = AI_OFF
H.LoseTarget()
stopped_atoms |= M
else if(istype(A, /obj/item/projectile))
var/obj/item/projectile/P = A
P.paused = TRUE
stopped_atoms |= P
for(var/mob/living/M in stopped_atoms)
if(get_dist(get_turf(M),get_turf(src)) > freezerange) //If they lagged/ran past the timestop somehow, just ignore them
unfreeze_mob(M)
stopped_atoms -= M
stoplag()
//End
playsound(src, 'sound/magic/timeparadox2.ogg', 75, TRUE, frequency = -1) //reverse!
for(var/mob/living/M in stopped_atoms)
unfreeze_mob(M)
for(var/obj/item/projectile/P in stopped_atoms)
P.paused = FALSE
qdel(src)
return
/obj/effect/timestop/proc/unfreeze_mob(mob/living/M)
M.AdjustStun(-200, 1, 1)
M.anchored = FALSE
if(ishostile(M))
var/mob/living/simple_animal/hostile/H = M
H.AIStatus = initial(H.AIStatus)
/obj/effect/timestop/wizard
duration = 100
/obj/item/stack/tile/bluespace
name = "bluespace floor tile"
singular_name = "floor tile"

View File

@@ -1360,6 +1360,7 @@
#include "code\modules\events\wizard\summons.dm"
#include "code\modules\fields\fields.dm"
#include "code\modules\fields\peaceborg_dampener.dm"
#include "code\modules\fields\timestop.dm"
#include "code\modules\fields\turf_objects.dm"
#include "code\modules\flufftext\Dreaming.dm"
#include "code\modules\flufftext\Hallucination.dm"