Skip to content

Commit

Permalink
Telespace jammer (TauCetiStation#9659)
Browse files Browse the repository at this point in the history
* telespace jammer

* Apply suggestions from code review

Co-authored-by: Sakuya-Izayoi <[email protected]>

* New icon, emp act

* no avoiding through wall ejecting

* Apply suggestions from code review

Co-authored-by: Sakuya-Izayoi <[email protected]>

* fix icon update

Co-authored-by: Sakuya-Izayoi <[email protected]>
  • Loading branch information
volas and Sakuya-Izayoi authored Jul 23, 2022
1 parent 0f1f312 commit a0bc97c
Show file tree
Hide file tree
Showing 12 changed files with 225 additions and 27 deletions.
5 changes: 5 additions & 0 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@
/// from base of atom/clean_blood (WHICH APPERANTLY CLEANS ALL DIRT OVERLAYS ?? ??? ?)
#define COMSIG_ATOM_CLEAN_BLOOD "atom_clean_blood"

///called when teleporting into a protected turf: (channel, turf/origin)
#define COMSIG_ATOM_INTERCEPT_TELEPORT "intercept_teleport"
#define COMPONENT_BLOCK_TELEPORT (1<<0)
//#define COMPONENT_INTERFERE_TELEPORT (1<<1)

/// from base /atom/movable/proc/Moved() and /atom/proc/set_dir() return dir
#define COMSIG_ATOM_CHANGE_DIR "change_dir"

Expand Down
3 changes: 1 addition & 2 deletions code/__DEFINES/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ var/global/list/bitflags = list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
#define PASSMOB 32

//turf-only flags
#define NOJAUNT 1
#define NOSTEPSOUND 2
#define NOSTEPSOUND 1

//flags for customizing id-cards
#define FORDBIDDEN_VIEW 1
Expand Down
38 changes: 38 additions & 0 deletions code/datums/components/teleblock.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Note in case if you want to port teleport channels from /tg/:
// in my opinion, we should not distinguish between magic, cult and bluespace teleportations technologies
// it's better to leave the question "what is magic?" open

/datum/component/teleblock
dupe_mode = COMPONENT_DUPE_ALLOWED // one turf can have multiple sources for teleportation interference

/datum/component/teleblock/Initialize(source)
if(!isturf(parent))
return COMPONENT_INCOMPATIBLE

/datum/component/teleblock/RegisterWithParent() //RegisterSignal
RegisterSignal(parent, COMSIG_ATOM_INTERCEPT_TELEPORT, .proc/intercept)

/datum/component/teleblock/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_ATOM_INTERCEPT_TELEPORT)

/datum/component/teleblock/proc/intercept()
return COMPONENT_BLOCK_TELEPORT



// see /obj/machinery/telescience_jammer
/datum/component/teleblock/jammer
var/obj/machinery/telescience_jammer/source

/datum/component/teleblock/jammer/Initialize(source)
if(!isturf(parent))
return COMPONENT_INCOMPATIBLE

if(!source)
return COMPONENT_NOT_ATTACHED

src.source = source

/datum/component/teleblock/jammer/intercept()
if(source.is_operational())
return COMPONENT_BLOCK_TELEPORT
4 changes: 4 additions & 0 deletions code/datums/helper_datums/teleport.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,17 @@
posturfs += T
destturf = safepick(posturfs - center)
else
// why this chain skips density_checks()
destturf = get_turf(destination)
if(isenvironmentturf(destturf) && (destturf.x <= TRANSITIONEDGE || destturf.x >= (world.maxx - TRANSITIONEDGE - 1) || destturf.y <= TRANSITIONEDGE || destturf.y >= (world.maxy - TRANSITIONEDGE - 1)))
return FALSE

if(!destturf || !curturf)
return FALSE

if(SEND_SIGNAL(destturf, COMSIG_ATOM_INTERCEPT_TELEPORT))
return FALSE

playSpecials(curturf,effectin,soundin)

if(force_teleport)
Expand Down
23 changes: 13 additions & 10 deletions code/datums/spells/ethereal_jaunt.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
var/icon/dissapear_animation //what animation is gonna get played on spell cast
var/icon/appear_animation //what animation is gonna get played on spell end
var/movement_cooldown = 2 //movement speed, less is faster
var/ignore_NOJAUNT = FALSE //ignores NOJAUNT turf flag
var/jaunt_duration = 6 SECONDS //how long jaunt will last

/obj/effect/proc_holder/spell/targeted/ethereal_jaunt/cast(list/targets) //magnets, so mostly hardcoded
Expand Down Expand Up @@ -94,7 +93,6 @@
action_icon_state = "jaunt"
jaunt_duration = 6 SECONDS
movement_cooldown = -1
ignore_NOJAUNT = TRUE
action_icon_state = "shadow_walk"

/obj/effect/proc_holder/spell/targeted/ethereal_jaunt/shadow_walk/cast(list/targets)
Expand Down Expand Up @@ -132,19 +130,24 @@
var/modifier_delay = 2

/obj/effect/dummy/spell_jaunt/relaymove(mob/user, direction)

if(last_move + modifier_delay > world.time)
return
if(user != master)
return

last_move = world.time

var/turf/newLoc = get_step(src,direction)
for(var/obj/effect/proc_holder/spell/targeted/ethereal_jaunt/J in master.spell_list)
if(!(newLoc.flags & NOJAUNT) || J.ignore_NOJAUNT)
if(canmove)
loc = newLoc
else
to_chat(user, "<span class='warning'>Some strange aura is blocking the way!</span>")

if(SEND_SIGNAL(newLoc, COMSIG_ATOM_INTERCEPT_TELEPORT))
to_chat(user, "<span class='warning'>Some strange aura is blocking the way!</span>")
return FALSE

if(canmove)
loc = newLoc // breaks entered/exit callbacks, but forcemove can trigger unnecessary things like traps

dir = direction
last_move = world.time
if(indicator)
var/turf/T = get_turf(loc)
indicator.icon_state = "marker[T.is_mob_placeable() ? "" : "_danger"]"
Expand Down Expand Up @@ -173,7 +176,7 @@
// chances of this occuring are very small
// as it requires 9x9 grid of impassable tiles ~getup1
for(var/turf/newloc in orange(1, mobloc))
if(newloc.is_mob_placeable(src) && !isenvironmentturf(newloc))
if(newloc.is_mob_placeable(src) && !isenvironmentturf(newloc) && !SEND_SIGNAL(newloc, COMSIG_ATOM_INTERCEPT_TELEPORT))
found_ground = TRUE
to_gib = FALSE
forceMove(newloc)
Expand Down
2 changes: 2 additions & 0 deletions code/datums/spells/turf_teleport.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
if(T.density && !include_dense) continue
if(T.x>world.maxx-outer_tele_radius || T.x<outer_tele_radius) continue //putting them at the edge is dumb
if(T.y>world.maxy-outer_tele_radius || T.y<outer_tele_radius) continue
if(SEND_SIGNAL(T, COMSIG_ATOM_INTERCEPT_TELEPORT))
continue
turfs += T

if(!turfs.len)
Expand Down
122 changes: 122 additions & 0 deletions code/game/machinery/jammer.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/obj/machinery/telescience_jammer
name = "Telescience Jammer"
desc = "Jammer that interferes with most telescience technologies"

icon = 'icons/obj/machines/jammer.dmi'
icon_state = "jammer"

layer = TURF_LAYER+0.1
plane = FLOOR_PLANE

anchored = TRUE

var/radius = 4
var/power_per_tile = 10

var/locked = TRUE

var/list/teleblocks

/obj/machinery/telescience_jammer/atom_init()

// lore purpose only
// no constuction because of balance reasons
component_parts = list()
component_parts += new /obj/item/bluespace_crystal/artificial

..()

return INITIALIZE_HINT_LATELOAD

/obj/machinery/telescience_jammer/atom_init_late()
update_radius()
update_affected_zone()
update_icon()

/obj/machinery/telescience_jammer/proc/update_affected_zone()

if(teleblocks)
for(var/datum/component/teleblock/jammer/COMP as anything in teleblocks)
qdel(COMP)

if(anchored)
var/turf/center = get_turf(src)
for(var/turf/T as anything in RANGE_TURFS(radius, center))
LAZYADD(teleblocks, T.AddComponent(/datum/component/teleblock/jammer, src))

/obj/machinery/telescience_jammer/proc/update_radius(new_radius)
if(new_radius)
radius = new_radius

idle_power_usage = (radius ** 2) * power_per_tile
update_power_use()

/obj/machinery/telescience_jammer/is_operational()
return anchored && ..()

/obj/machinery/telescience_jammer/update_icon()
if(anchored && !(stat & (NOPOWER | BROKEN | MAINT)))
icon_state = "jammer_on"
else
icon_state = "jammer"

/obj/machinery/telescience_jammer/attackby(obj/item/I, mob/user)
user.SetNextMove(CLICK_CD_INTERACT)
if(!user.IsAdvancedToolUser())
to_chat(user, "<span class='warning'>It's too complicated for you.</span>")
return

if(istype(I, /obj/item/weapon/card/id))
var/obj/item/weapon/card/id/card = I
if(emagged || (access_heads in card.access))
if(locked)
locked = FALSE
stat |= MAINT
set_power_use(IDLE_POWER_USE)
to_chat(user, "<span class='notice'>You unlock and turn off [src].</span>")
else
locked = TRUE
stat &= ~MAINT
set_power_use(NO_POWER_USE)
to_chat(user, "<span class='notice'>You lock and turn on [src].</span>")

update_icon()
else
to_chat(user, "<span class='warning'>Access Denied.</span>")

return

if(!locked)
if (ismultitool(I))
var/new_radius = clamp(input(user, "Set new radius in range 1-5", "Radius", radius) as num, 1, 5)

if(Adjacent(usr))
update_radius(new_radius)
update_affected_zone()

return

else if(default_unfasten_wrench(user, I))
update_affected_zone()
return

/obj/machinery/telescience_jammer/emag_act(mob/user)
if(emagged)
return FALSE
to_chat(user, "<span class='notice'>Looks like you can unlock it with any ID card now.</span>")
emagged = TRUE

/obj/machinery/telescience_jammer/emp_act(severity)
if(!is_operational())
return
if(prob(80/severity))
stat |= EMPED
addtimer(CALLBACK(src, .proc/after_emp), 10 MINUTES / severity)

/obj/machinery/telescience_jammer/proc/after_emp()
stat &= ~EMPED

/obj/machinery/telescience_jammer/Destroy()
for(var/datum/component/teleblock/jammer/COMP as anything in teleblocks)
qdel(COMP)
return ..()
6 changes: 1 addition & 5 deletions code/game/turfs/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
return 0
return 1 //Nothing found to block so return success!

/turf/proc/is_mob_placeable(mob/M)
/turf/proc/is_mob_placeable(mob/M) // todo: maybe rewrite as COMSIG_ATOM_INTERCEPT_TELEPORT
if(density)
return FALSE
var/static/list/allowed_types = list(/obj/structure/window, /obj/machinery/door,
Expand Down Expand Up @@ -388,10 +388,6 @@
spawn(0)
M.take_damage(100, "brute")

/turf/proc/Bless()
flags |= NOJAUNT


////////////////
//Distance procs
////////////////
Expand Down
4 changes: 4 additions & 0 deletions code/modules/telesci/telesci_computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@
var/atom/A = X
if(A.density)
return FALSE

if(SEND_SIGNAL(exit, COMSIG_ATOM_INTERCEPT_TELEPORT))
return FALSE

active_wormhole = new (telepad.loc, exit)
active_wormhole.linked_console = src
return active_wormhole
Expand Down
Binary file added icons/obj/machines/jammer.dmi
Binary file not shown.
Loading

0 comments on commit a0bc97c

Please sign in to comment.