mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-09 16:14:13 +00:00
-Almost every instance of 'for(mob in world)' has been killed. Because GODDAMN was it being run a bunch. Instead, a series of global lists have been made, and they are all handled auto-magically through New()'s, Del()'s, Login()'s, death()'s, etc... Lists are as follows: -mob_list : Contains all atom/mobs by ref -player_list : Like mob_list, but only contains mobs with clients attached -admin_list : Like player_list, but holds all mobs with clients attached and admin status -living_mob_list : Contains all mobs that ARE alive, regardless of client status -dead_mob_list : Contains all mobs that are dead, which comes down to corpses and ghosts -cable_list : A list containing every obj/structure/cable in existence Note: There is an object (/obj/item/debuglist) that you can use to check the contents of each of the lists except for cables (Since getting a message saying "a cable," x9001 isn't very helpful) These lists have been tested as much as I could on my own, and have been mostly implemented. There are still places where they could be used, but for now it's important that the core is working. If this all checks out I would really like to implement it into the MC as well, simply so it doesn't check call Life() on every mob by checking for all the ones in world every damn tick. Just testing locally I was able to notice improvements with certain aspects, like admin verbs being MUCH more responsive (They checked for every mob in the world every time they were clicked), many sources of needless lag were cut out (Like Adminwho and Who checking every single mob when clicked), and due to the cable_list powernet rebuilding is MUCH more efficient, because instead of checking for every cable in the world every time a powernet was broken (read: A cable was deleted), it runs though the pre-made list, and even with a singulo tearing all the way across the station, the powernet load was VERY small compared to pretty much everything else. If you want to know how any of this works, check global_lists.dm, there I have it rigorously commented, and it should provide an understanding of what's going on. Mob related in worlds before this commit: 1262 After: 4 I'm helping git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4179 316c924e-a436-60f5-8080-3fe189b3f50e
343 lines
8.7 KiB
Plaintext
343 lines
8.7 KiB
Plaintext
/obj/item/weapon/pinpointer
|
|
name = "pinpointer"
|
|
icon = 'icons/obj/device.dmi'
|
|
icon_state = "pinoff"
|
|
flags = FPRINT | TABLEPASS| CONDUCT
|
|
slot_flags = SLOT_BELT
|
|
w_class = 2.0
|
|
item_state = "electronic"
|
|
throw_speed = 4
|
|
throw_range = 20
|
|
m_amt = 500
|
|
var/obj/item/weapon/disk/nuclear/the_disk = null
|
|
var/active = 0
|
|
|
|
|
|
attack_self()
|
|
if(!active)
|
|
active = 1
|
|
workdisk()
|
|
usr << "\blue You activate the pinpointer"
|
|
else
|
|
active = 0
|
|
icon_state = "pinoff"
|
|
usr << "\blue You deactivate the pinpointer"
|
|
|
|
proc/workdisk()
|
|
if(!active) return
|
|
if(!the_disk)
|
|
the_disk = locate()
|
|
if(!the_disk)
|
|
icon_state = "pinonnull"
|
|
return
|
|
src.dir = get_dir(src,the_disk)
|
|
switch(get_dist(src,the_disk))
|
|
if(0)
|
|
icon_state = "pinondirect"
|
|
if(1 to 8)
|
|
icon_state = "pinonclose"
|
|
if(9 to 16)
|
|
icon_state = "pinonmedium"
|
|
if(16 to INFINITY)
|
|
icon_state = "pinonfar"
|
|
spawn(5) .()
|
|
|
|
examine()
|
|
..()
|
|
for(var/obj/machinery/nuclearbomb/bomb in world)
|
|
if(bomb.timing)
|
|
usr << "Extreme danger. Arming signal detected. Time remaining: [bomb.timeleft]"
|
|
|
|
|
|
/obj/item/weapon/pinpointer/advpinpointer
|
|
name = "Advanced Pinpointer"
|
|
icon = 'icons/obj/device.dmi'
|
|
desc = "A larger version of the normal pinpointer, this unit features a helpful quantum entanglement detection system to locate various objects that do not broadcast a locator signal."
|
|
var/mode = 0 // Mode 0 locates disk, mode 1 locates coordinates.
|
|
var/turf/location = null
|
|
var/obj/target = null
|
|
|
|
attack_self()
|
|
if(!active)
|
|
active = 1
|
|
if(mode == 0)
|
|
workdisk()
|
|
if(mode == 1)
|
|
worklocation()
|
|
if(mode == 2)
|
|
workobj()
|
|
usr << "\blue You activate the pinpointer"
|
|
else
|
|
active = 0
|
|
icon_state = "pinoff"
|
|
usr << "\blue You deactivate the pinpointer"
|
|
|
|
|
|
proc/worklocation()
|
|
if(!active)
|
|
return
|
|
if(!location)
|
|
icon_state = "pinonnull"
|
|
return
|
|
src.dir = get_dir(src,location)
|
|
switch(get_dist(src,location))
|
|
if(0)
|
|
icon_state = "pinondirect"
|
|
if(1 to 8)
|
|
icon_state = "pinonclose"
|
|
if(9 to 16)
|
|
icon_state = "pinonmedium"
|
|
if(16 to INFINITY)
|
|
icon_state = "pinonfar"
|
|
spawn(5) .()
|
|
|
|
|
|
proc/workobj()
|
|
if(!active)
|
|
return
|
|
if(!target)
|
|
icon_state = "pinonnull"
|
|
return
|
|
src.dir = get_dir(src,target)
|
|
switch(get_dist(src,target))
|
|
if(0)
|
|
icon_state = "pinondirect"
|
|
if(1 to 8)
|
|
icon_state = "pinonclose"
|
|
if(9 to 16)
|
|
icon_state = "pinonmedium"
|
|
if(16 to INFINITY)
|
|
icon_state = "pinonfar"
|
|
spawn(5) .()
|
|
|
|
/obj/item/weapon/pinpointer/advpinpointer/verb/toggle_mode()
|
|
set category = "Object"
|
|
set name = "Toggle Pinpointer Mode"
|
|
set src in view(1)
|
|
|
|
active = 0
|
|
icon_state = "pinoff"
|
|
target=null
|
|
location = null
|
|
|
|
switch(alert("Please select the mode you want to put the pinpointer in.", "Pinpointer Mode Select", "Location", "Disk Recovery", "Other Signature"))
|
|
if("Location")
|
|
mode = 1
|
|
|
|
var/locationx = input(usr, "Please input the x coordinate to search for.", "Location?" , "") as num
|
|
if(!locationx || !(usr in view(1,src)))
|
|
return
|
|
var/locationy = input(usr, "Please input the y coordinate to search for.", "Location?" , "") as num
|
|
if(!locationy || !(usr in view(1,src)))
|
|
return
|
|
|
|
var/turf/Z = get_turf(src)
|
|
|
|
location = locate(locationx,locationy,Z.z)
|
|
|
|
usr << "You set the pinpointer to locate [locationx],[locationy]"
|
|
|
|
|
|
return attack_self()
|
|
|
|
if("Disk Recovery")
|
|
mode = 0
|
|
return attack_self()
|
|
|
|
if("Other Signature")
|
|
mode = 2
|
|
switch(alert("Search for item signature or DNA fragment?" , "Signature Mode Select" , "" , "Item" , "DNA"))
|
|
if("Item")
|
|
var/datum/objective/steal/itemlist
|
|
itemlist = itemlist // To supress a 'variable defined but not used' error.
|
|
var/targetitem = input("Select item to search for.", "Item Mode Select","") as null|anything in itemlist.possible_items
|
|
if(!targetitem)
|
|
return
|
|
target=locate(itemlist.possible_items[targetitem])
|
|
if(!target)
|
|
usr << "Failed to locate [targetitem]!"
|
|
return
|
|
usr << "You set the pinpointer to locate [targetitem]"
|
|
if("DNA")
|
|
var/DNAstring = input("Input DNA string to search for." , "Please Enter String." , "")
|
|
if(!DNAstring)
|
|
return
|
|
for(var/mob/living/carbon/M in mob_list)
|
|
if(!M.dna)
|
|
continue
|
|
if(M.dna.unique_enzymes == DNAstring)
|
|
target = M
|
|
break
|
|
|
|
return attack_self()
|
|
|
|
|
|
|
|
/obj/item/weapon/pinpointer/nukeop//Used by nuke ops specifically so they can get their asses back to the shuttle
|
|
var/mode = 0 // Mode 0 locates disk, mode 1 locates the shuttle
|
|
var/location = null//Follow that shuttle!
|
|
var/obj/machinery/computer/syndicate_station/home = null
|
|
|
|
attack_self()
|
|
if(!active)
|
|
active = 1
|
|
if(mode == 0)
|
|
workdisk()
|
|
if(mode == 1)
|
|
worklocation()
|
|
usr << "\blue You activate the pinpointer"
|
|
else
|
|
active = 0
|
|
icon_state = "pinoff"
|
|
usr << "\blue You deactivate the pinpointer"
|
|
|
|
/obj/item/weapon/pinpointer/nukeop/workdisk()
|
|
if(!active) return
|
|
if(!the_disk)
|
|
the_disk = locate()
|
|
if(!the_disk)
|
|
icon_state = "pinonnull"
|
|
return
|
|
if(src.loc.z >1)//If you are on a different z-level from the station
|
|
icon_state = "pinonalert"
|
|
else
|
|
src.dir = get_dir(src,the_disk)
|
|
switch(get_dist(src,the_disk))
|
|
if(0)
|
|
icon_state = "pinondirect"
|
|
if(1 to 8)
|
|
icon_state = "pinonclose"
|
|
if(9 to 16)
|
|
icon_state = "pinonmedium"
|
|
if(16 to INFINITY)
|
|
icon_state = "pinonfar"
|
|
spawn(5) .()
|
|
|
|
/obj/item/weapon/pinpointer/nukeop/proc/worklocation()
|
|
if(!active)
|
|
return
|
|
if(!home)
|
|
home = locate()
|
|
if(!home)
|
|
icon_state = "pinonnull"
|
|
return
|
|
if(src.loc.z >2)//If you are on a different z-level from the shuttle
|
|
icon_state = "pinonalert"
|
|
else
|
|
src.dir = get_dir(src,home)
|
|
switch(get_dist(src,home))
|
|
if(0)
|
|
icon_state = "pinondirect"
|
|
if(1 to 8)
|
|
icon_state = "pinonclose"
|
|
if(9 to 16)
|
|
icon_state = "pinonmedium"
|
|
if(16 to INFINITY)
|
|
icon_state = "pinonfar"
|
|
|
|
spawn(5) .()
|
|
|
|
/obj/item/weapon/pinpointer/nukeop/verb/toggle_mode()
|
|
set category = "Object"
|
|
set name = "Toggle Pinpointer Mode"
|
|
set src in view(1)
|
|
|
|
active = 0
|
|
icon_state = "pinoff"
|
|
|
|
if(mode)
|
|
mode = 0
|
|
usr << "Nuclear Disk locator active."
|
|
return attack_self()
|
|
|
|
else
|
|
mode = 1
|
|
usr << "Shuttle locator active."
|
|
return attack_self()
|
|
|
|
|
|
/*/obj/item/weapon/pinpointer/New()
|
|
. = ..()
|
|
processing_objects.Add(src)
|
|
|
|
/obj/item/weapon/pinpointer/Del()
|
|
processing_objects.Remove(src)
|
|
. = ..()
|
|
|
|
/obj/item/weapon/pinpointer/attack_self(mob/user as mob)
|
|
user.machine = src
|
|
var/dat
|
|
if (src.temp)
|
|
dat = "[src.temp]<BR><BR><A href='byond://?src=\ref[src];temp=1'>Clear</A>"
|
|
else
|
|
dat = "<B>Nuclear Disk Pinpointer</B><HR>"
|
|
dat += "<A href='byond://?src=\ref[src];refresh=1'>Refresh</A>"
|
|
|
|
user << browse(dat, "window=radio")
|
|
onclose(user, "radio")
|
|
|
|
/obj/item/weapon/pinpointer/process()
|
|
/*
|
|
//TODO: REWRITE
|
|
set background = 1
|
|
var/turf/sr = get_turf(src)
|
|
|
|
if (sr)
|
|
for(var/obj/item/weapon/disk/nuclear/W in world)
|
|
var/turf/tr = get_turf(W)
|
|
if (tr && tr.z == sr.z)
|
|
src.dir = get_dir(sr, tr)
|
|
break
|
|
*/
|
|
/obj/item/weapon/pinpointer/Topic(href, href_list)
|
|
..()
|
|
|
|
if (usr.stat || usr.restrained())
|
|
return
|
|
|
|
if ((usr.contents.Find(src) || (in_range(src, usr) && istype(src.loc, /turf))))
|
|
usr.machine = src
|
|
if (href_list["refresh"])
|
|
src.temp = "<B>Nuclear Disk Pinpointer</B><HR>"
|
|
var/turf/sr = get_turf(src)
|
|
|
|
if (sr)
|
|
src.temp += "<B>Located Disks:</B><BR>"
|
|
|
|
for(var/obj/item/weapon/disk/nuclear/W in world)
|
|
var/turf/tr = get_turf(W)
|
|
if (tr && tr.z == sr.z)
|
|
var/distance = max(abs(tr.x - sr.x), abs(tr.y - sr.y))
|
|
var/strength = "unknown"
|
|
var/directional = dir2text(get_dir(sr, tr));
|
|
|
|
if (distance < 5)
|
|
strength = "very strong"
|
|
else if (distance < 10)
|
|
strength = "strong"
|
|
else if (distance < 15)
|
|
strength = "weak"
|
|
else if (distance < 20)
|
|
strength = "very weak"
|
|
directional = "unknown"
|
|
else
|
|
continue
|
|
|
|
if (!directional)
|
|
directional = "right on top of it"
|
|
|
|
src.temp += "[directional]-[strength]<BR>"
|
|
|
|
src.temp += "<B>You are at \[[sr.x],[sr.y],[sr.z]\]</B> in orbital coordinates.<BR><BR><A href='byond://?src=\ref[src];refresh=1'>Refresh</A><BR>"
|
|
else
|
|
src.temp += "<B><FONT color='red'>Processing Error:</FONT></B> Unable to locate orbital position.<BR>"
|
|
else if (href_list["temp"])
|
|
src.temp = null
|
|
|
|
if (istype(src.loc, /mob))
|
|
attack_self(src.loc)
|
|
else
|
|
for (var/mob/M in viewers(1, src))
|
|
if (M.client)
|
|
src.attack_self(M)
|
|
*/ |