Merge pull request #7153 from VOREStation/upstream-merge-6934

[MIRROR] Adjust two things that loop forever
This commit is contained in:
Novacat
2020-04-05 22:37:32 -04:00
committed by GitHub
2 changed files with 179 additions and 185 deletions

View File

@@ -12,25 +12,34 @@
var/obj/item/weapon/disk/nuclear/the_disk = null var/obj/item/weapon/disk/nuclear/the_disk = null
var/active = 0 var/active = 0
/obj/item/weapon/pinpointer/Destroy()
active = 0
STOP_PROCESSING(SSobj, src)
return ..()
attack_self() /obj/item/weapon/pinpointer/attack_self()
if(!active) if(!active)
active = 1 active = 1
workdisk() START_PROCESSING(SSobj, src)
to_chat(usr, "<span class='notice'>You activate the pinpointer</span>") to_chat(usr, "<span class='notice'>You activate the pinpointer</span>")
else else
active = 0 active = 0
STOP_PROCESSING(SSobj, src)
icon_state = "pinoff" icon_state = "pinoff"
to_chat(usr, "<span>You deactivate the pinpointer</span>") to_chat(usr, "<span class='notice'>You deactivate the pinpointer</span>")
/obj/item/weapon/pinpointer/process()
if(!active)
return PROCESS_KILL
proc/workdisk()
if(!active) return
if(!the_disk) if(!the_disk)
the_disk = locate() the_disk = locate()
if(!the_disk) if(!the_disk)
icon_state = "pinonnull" icon_state = "pinonnull"
return return
set_dir(get_dir(src,the_disk)) set_dir(get_dir(src,the_disk))
switch(get_dist(src,the_disk)) switch(get_dist(src,the_disk))
if(0) if(0)
icon_state = "pinondirect" icon_state = "pinondirect"
@@ -40,17 +49,14 @@
icon_state = "pinonmedium" icon_state = "pinonmedium"
if(16 to INFINITY) if(16 to INFINITY)
icon_state = "pinonfar" icon_state = "pinonfar"
spawn(5) .()
examine(mob/user) /obj/item/weapon/pinpointer/examine(mob/user)
..(user) ..(user)
for(var/obj/machinery/nuclearbomb/bomb in machines) for(var/obj/machinery/nuclearbomb/bomb in machines)
if(bomb.timing) if(bomb.timing)
to_chat(user, "Extreme danger. Arming signal detected. Time remaining: [bomb.timeleft]") to_chat(user, "Extreme danger. Arming signal detected. Time remaining: [bomb.timeleft]")
/obj/item/weapon/pinpointer/Destroy()
active = 0
..()
/obj/item/weapon/pinpointer/advpinpointer /obj/item/weapon/pinpointer/advpinpointer
name = "Advanced Pinpointer" name = "Advanced Pinpointer"
@@ -60,29 +66,23 @@
var/turf/location = null var/turf/location = null
var/obj/target = null var/obj/target = null
attack_self() /obj/item/weapon/pinpointer/advpinpointer/process()
if(!active) if(!active)
active = 1 return PROCESS_KILL
if(mode == 0) if(mode == 0)
workdisk() ..()
if(mode == 1) if(mode == 1)
worklocation() worklocation()
if(mode == 2) if(mode == 2)
workobj() workobj()
to_chat(usr, "<span class='notice'>You activate the pinpointer</span>")
else
active = 0
icon_state = "pinoff"
to_chat(usr, "<span class='notice'>You deactivate the pinpointer</span>")
/obj/item/weapon/pinpointer/advpinpointer/proc/worklocation()
proc/worklocation()
if(!active)
return
if(!location) if(!location)
icon_state = "pinonnull" icon_state = "pinonnull"
return return
set_dir(get_dir(src,location)) set_dir(get_dir(src,location))
switch(get_dist(src,location)) switch(get_dist(src,location))
if(0) if(0)
icon_state = "pinondirect" icon_state = "pinondirect"
@@ -92,16 +92,14 @@
icon_state = "pinonmedium" icon_state = "pinonmedium"
if(16 to INFINITY) if(16 to INFINITY)
icon_state = "pinonfar" icon_state = "pinonfar"
spawn(5) .()
/obj/item/weapon/pinpointer/advpinpointer/proc/workobj()
proc/workobj()
if(!active)
return
if(!target) if(!target)
icon_state = "pinonnull" icon_state = "pinonnull"
return return
set_dir(get_dir(src,target)) set_dir(get_dir(src,target))
switch(get_dist(src,target)) switch(get_dist(src,target))
if(0) if(0)
icon_state = "pinondirect" icon_state = "pinondirect"
@@ -111,7 +109,6 @@
icon_state = "pinonmedium" icon_state = "pinonmedium"
if(16 to INFINITY) if(16 to INFINITY)
icon_state = "pinonfar" icon_state = "pinonfar"
spawn(5) .()
/obj/item/weapon/pinpointer/advpinpointer/verb/toggle_mode() /obj/item/weapon/pinpointer/advpinpointer/verb/toggle_mode()
set category = "Object" set category = "Object"
@@ -140,7 +137,6 @@
to_chat(usr, "You set the pinpointer to locate [locationx],[locationy]") to_chat(usr, "You set the pinpointer to locate [locationx],[locationy]")
return attack_self() return attack_self()
if("Disk Recovery") if("Disk Recovery")
@@ -150,9 +146,10 @@
if("Other Signature") if("Other Signature")
mode = 2 mode = 2
switch(alert("Search for item signature or DNA fragment?" , "Signature Mode Select" , "" , "Item" , "DNA")) switch(alert("Search for item signature or DNA fragment?" , "Signature Mode Select" , "" , "Item" , "DNA"))
if("Item") if("Item")
var/datum/objective/steal/itemlist var/datum/objective/steal/itemlist
itemlist = itemlist // To supress a 'variable defined but not used' error. itemlist = itemlist
var/targetitem = input("Select item to search for.", "Item Mode Select","") as null|anything in itemlist.possible_items var/targetitem = input("Select item to search for.", "Item Mode Select","") as null|anything in itemlist.possible_items
if(!targetitem) if(!targetitem)
return return
@@ -161,6 +158,7 @@
to_chat(usr, "Failed to locate [targetitem]!") to_chat(usr, "Failed to locate [targetitem]!")
return return
to_chat(usr, "You set the pinpointer to locate [targetitem]") to_chat(usr, "You set the pinpointer to locate [targetitem]")
if("DNA") if("DNA")
var/DNAstring = input("Input DNA string to search for." , "Please Enter String." , "") var/DNAstring = input("Input DNA string to search for." , "Please Enter String." , "")
if(!DNAstring) if(!DNAstring)
@@ -187,6 +185,7 @@
/obj/item/weapon/pinpointer/nukeop/attack_self(mob/user as mob) /obj/item/weapon/pinpointer/nukeop/attack_self(mob/user as mob)
if(!active) if(!active)
active = 1 active = 1
START_PROCESSING(SSobj, src)
if(!mode) if(!mode)
workdisk() workdisk()
to_chat(user, "<span class='notice'>Authentication Disk Locator active.</span>") to_chat(user, "<span class='notice'>Authentication Disk Locator active.</span>")
@@ -195,30 +194,35 @@
to_chat(user, "<span class='notice'>Shuttle Locator active.</span>") to_chat(user, "<span class='notice'>Shuttle Locator active.</span>")
else else
active = 0 active = 0
STOP_PROCESSING(SSobj, src)
icon_state = "pinoff" icon_state = "pinoff"
to_chat(user, "<span class='notice'>You deactivate the pinpointer.</span>") to_chat(user, "<span class='notice'>You deactivate the pinpointer.</span>")
/obj/item/weapon/pinpointer/nukeop/process()
if(!active)
return PROCESS_KILL
/obj/item/weapon/pinpointer/nukeop/workdisk() switch(mode)
if(!active) return if(0)
if(mode) //Check in case the mode changes while operating workdisk()
if(1)
worklocation() worklocation()
return
/obj/item/weapon/pinpointer/nukeop/proc/workdisk()
if(bomb_set) //If the bomb is set, lead to the shuttle if(bomb_set) //If the bomb is set, lead to the shuttle
mode = 1 //Ensures worklocation() continues to work mode = 1 //Ensures worklocation() continues to work
worklocation()
playsound(loc, 'sound/machines/twobeep.ogg', 50, 1) //Plays a beep playsound(loc, 'sound/machines/twobeep.ogg', 50, 1) //Plays a beep
visible_message("Shuttle Locator active.") //Lets the mob holding it know that the mode has changed visible_message("<span class='notice'>Shuttle Locator active.</span>") //Lets the mob holding it know that the mode has changed
return //Get outta here return //Get outta here
if(!the_disk) if(!the_disk)
the_disk = locate() the_disk = locate()
if(!the_disk) if(!the_disk)
icon_state = "pinonnull" icon_state = "pinonnull"
return return
// if(loc.z != the_disk.z) //If you are on a different z-level from the disk
// icon_state = "pinonnull"
// else
set_dir(get_dir(src, the_disk)) set_dir(get_dir(src, the_disk))
switch(get_dist(src, the_disk)) switch(get_dist(src, the_disk))
if(0) if(0)
icon_state = "pinondirect" icon_state = "pinondirect"
@@ -229,29 +233,25 @@
if(16 to INFINITY) if(16 to INFINITY)
icon_state = "pinonfar" icon_state = "pinonfar"
spawn(5) .()
/obj/item/weapon/pinpointer/nukeop/proc/worklocation() /obj/item/weapon/pinpointer/nukeop/proc/worklocation()
if(!active) return
if(!mode)
workdisk()
return
if(!bomb_set) if(!bomb_set)
mode = 0 mode = 0
workdisk()
playsound(loc, 'sound/machines/twobeep.ogg', 50, 1) playsound(loc, 'sound/machines/twobeep.ogg', 50, 1)
visible_message("<span class='notice'>Authentication Disk Locator active.</span>") visible_message("<span class='notice'>Authentication Disk Locator active.</span>")
return return
if(!home) if(!home)
home = locate() home = locate()
if(!home) if(!home)
icon_state = "pinonnull" icon_state = "pinonnull"
return return
if(loc.z != home.z) //If you are on a different z-level from the shuttle if(loc.z != home.z) //If you are on a different z-level from the shuttle
icon_state = "pinonnull" icon_state = "pinonnull"
else else
set_dir(get_dir(src, home)) set_dir(get_dir(src, home))
switch(get_dist(src, home)) switch(get_dist(src, home))
if(0) if(0)
icon_state = "pinondirect" icon_state = "pinondirect"
@@ -262,8 +262,6 @@
if(16 to INFINITY) if(16 to INFINITY)
icon_state = "pinonfar" icon_state = "pinonfar"
spawn(5) .()
// This one only points to the ship. Useful if there is no nuking to occur today. // This one only points to the ship. Useful if there is no nuking to occur today.
/obj/item/weapon/pinpointer/shuttle /obj/item/weapon/pinpointer/shuttle
@@ -273,16 +271,17 @@
/obj/item/weapon/pinpointer/shuttle/attack_self(mob/user as mob) /obj/item/weapon/pinpointer/shuttle/attack_self(mob/user as mob)
if(!active) if(!active)
active = TRUE active = TRUE
find_shuttle() START_PROCESSING(SSobj, src)
to_chat(user, "<span class='notice'>Shuttle Locator active.</span>") to_chat(user, "<span class='notice'>Shuttle Locator active.</span>")
else else
active = FALSE active = FALSE
STOP_PROCESSING(SSobj, src)
icon_state = "pinoff" icon_state = "pinoff"
to_chat(user, "<span class='notice'>You deactivate the pinpointer.</span>") to_chat(user, "<span class='notice'>You deactivate the pinpointer.</span>")
/obj/item/weapon/pinpointer/shuttle/proc/find_shuttle() /obj/item/weapon/pinpointer/shuttle/process()
if(!active) if(!active)
return return PROCESS_KILL
if(!our_shuttle) if(!our_shuttle)
for(var/obj/machinery/computer/shuttle_control/S in machines) for(var/obj/machinery/computer/shuttle_control/S in machines)
@@ -296,8 +295,10 @@
if(loc.z != our_shuttle.z) //If you are on a different z-level from the shuttle if(loc.z != our_shuttle.z) //If you are on a different z-level from the shuttle
icon_state = "pinonnull" icon_state = "pinonnull"
else else
set_dir(get_dir(src, our_shuttle)) set_dir(get_dir(src, our_shuttle))
switch(get_dist(src, our_shuttle)) switch(get_dist(src, our_shuttle))
if(0) if(0)
icon_state = "pinondirect" icon_state = "pinondirect"
@@ -308,9 +309,6 @@
if(16 to INFINITY) if(16 to INFINITY)
icon_state = "pinonfar" icon_state = "pinonfar"
spawn(5)
.()
/obj/item/weapon/pinpointer/shuttle/merc /obj/item/weapon/pinpointer/shuttle/merc
shuttle_comp_id = "Mercenary" shuttle_comp_id = "Mercenary"

View File

@@ -10,7 +10,7 @@
var/proximity_needed = 12 // How many tiles a mob with a client must be for this to run. var/proximity_needed = 12 // How many tiles a mob with a client must be for this to run.
var/ignore_ghosts = FALSE // If true, ghosts won't satisfy the above requirement. var/ignore_ghosts = FALSE // If true, ghosts won't satisfy the above requirement.
var/ignore_afk = TRUE // If true, AFK people (5 minutes) won't satisfy it as well. var/ignore_afk = TRUE // If true, AFK people (5 minutes) won't satisfy it as well.
var/retry_delay = 3 SECONDS // How long until we check for players again. var/retry_delay = 5 SECONDS // How long until we check for players again.
/obj/effect/map_effect/ex_act() /obj/effect/map_effect/ex_act()
return return
@@ -46,15 +46,11 @@
return // Do not pass .(), do not recursively collect 200 thaler. return // Do not pass .(), do not recursively collect 200 thaler.
if(!always_run && !check_for_player_proximity(src, proximity_needed, ignore_ghosts, ignore_afk)) if(!always_run && !check_for_player_proximity(src, proximity_needed, ignore_ghosts, ignore_afk))
spawn(retry_delay) // Maybe someday we'll have fancy TG timers/schedulers. //Nobody home, try again after retry_delay
if(!QDELETED(src)) addtimer(CALLBACK(src, .proc/handle_interval_delay), retry_delay)
.() else
return //Someone was here!
addtimer(CALLBACK(src, .proc/trigger), rand(interval_lower_bound, interval_upper_bound))
var/next_interval = rand(interval_lower_bound, interval_upper_bound)
spawn(next_interval)
if(!QDELETED(src))
trigger()
// Helper proc to optimize the use of effects by making sure they do not run if nobody is around to perceive it. // Helper proc to optimize the use of effects by making sure they do not run if nobody is around to perceive it.
/proc/check_for_player_proximity(var/atom/proximity_to, var/radius = 12, var/ignore_ghosts = FALSE, var/ignore_afk = TRUE) /proc/check_for_player_proximity(var/atom/proximity_to, var/radius = 12, var/ignore_ghosts = FALSE, var/ignore_afk = TRUE)