mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +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
233 lines
7.6 KiB
Plaintext
233 lines
7.6 KiB
Plaintext
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:31
|
|
|
|
|
|
/obj/machinery/computer/robotics
|
|
name = "Robotics Control"
|
|
desc = "Used to remotely lockdown or detonate linked Cyborgs."
|
|
icon = 'icons/obj/computer.dmi'
|
|
icon_state = "robot"
|
|
req_access = list(access_robotics)
|
|
circuit = "/obj/item/weapon/circuitboard/robotics"
|
|
|
|
var/id = 0.0
|
|
var/temp = null
|
|
var/status = 0
|
|
var/timeleft = 60
|
|
var/stop = 0.0
|
|
var/screen = 0 // 0 - Main Menu, 1 - Cyborg Status, 2 - Kill 'em All! -- In text
|
|
|
|
|
|
/obj/machinery/computer/robotics/attack_ai(var/mob/user as mob)
|
|
return src.attack_hand(user)
|
|
|
|
/obj/machinery/computer/robotics/attack_paw(var/mob/user as mob)
|
|
|
|
return src.attack_hand(user)
|
|
return
|
|
|
|
/obj/machinery/computer/robotics/attack_hand(var/mob/user as mob)
|
|
if(..())
|
|
return
|
|
user.machine = src
|
|
var/dat
|
|
if (src.temp)
|
|
dat = "<TT>[src.temp]</TT><BR><BR><A href='?src=\ref[src];temp=1'>Clear Screen</A>"
|
|
else
|
|
if(screen == 0)
|
|
dat += "<h3>Cyborg Control Console</h3><BR>"
|
|
dat += "<A href='?src=\ref[src];screen=1'>1. Cyborg Status</A><BR>"
|
|
dat += "<A href='?src=\ref[src];screen=2'>2. Emergency Full Destruct</A><BR>"
|
|
if(screen == 1)
|
|
for(var/mob/living/silicon/robot/R in mob_list)
|
|
if(istype(user, /mob/living/silicon/ai))
|
|
if (R.connected_ai != user)
|
|
continue
|
|
if(istype(user, /mob/living/silicon/robot))
|
|
if (R != user)
|
|
continue
|
|
if(R.scrambledcodes)
|
|
continue
|
|
|
|
dat += "[R.name] |"
|
|
if(R.stat)
|
|
dat += " Not Responding |"
|
|
else if (!R.canmove)
|
|
dat += " Locked Down |"
|
|
else
|
|
dat += " Operating Normally |"
|
|
if (!R.canmove)
|
|
else if(R.cell)
|
|
dat += " Battery Installed ([R.cell.charge]/[R.cell.maxcharge]) |"
|
|
else
|
|
dat += " No Cell Installed |"
|
|
if(R.module)
|
|
dat += " Module Installed ([R.module.name]) |"
|
|
else
|
|
dat += " No Module Installed |"
|
|
if(R.connected_ai)
|
|
dat += " Slaved to [R.connected_ai.name] |"
|
|
else
|
|
dat += " Independent from AI |"
|
|
if (istype(user, /mob/living/silicon))
|
|
if((user.mind.special_role && user.mind.original == user) && !R.emagged)
|
|
dat += "<A href='?src=\ref[src];magbot=\ref[R]'>(<font color=blue><i>Hack</i></font>)</A> "
|
|
dat += "<A href='?src=\ref[src];stopbot=\ref[R]'>(<font color=green><i>[R.canmove ? "Lockdown" : "Release"]</i></font>)</A> "
|
|
dat += "<A href='?src=\ref[src];killbot=\ref[R]'>(<font color=red><i>Destroy</i></font>)</A>"
|
|
dat += "<BR>"
|
|
dat += "<A href='?src=\ref[src];screen=0'>(Return to Main Menu)</A><BR>"
|
|
if(screen == 2)
|
|
if(!src.status)
|
|
dat += {"<BR><B>Emergency Robot Self-Destruct</B><HR>\nStatus: Off<BR>
|
|
\n<BR>
|
|
\nCountdown: [src.timeleft]/60 <A href='?src=\ref[src];reset=1'>\[Reset\]</A><BR>
|
|
\n<BR>
|
|
\n<A href='?src=\ref[src];eject=1'>Start Sequence</A><BR>
|
|
\n<BR>
|
|
\n<A href='?src=\ref[user];mach_close=computer'>Close</A>"}
|
|
else
|
|
dat = {"<B>Emergency Robot Self-Destruct</B><HR>\nStatus: Activated<BR>
|
|
\n<BR>
|
|
\nCountdown: [src.timeleft]/60 \[Reset\]<BR>
|
|
\n<BR>\n<A href='?src=\ref[src];stop=1'>Stop Sequence</A><BR>
|
|
\n<BR>
|
|
\n<A href='?src=\ref[user];mach_close=computer'>Close</A>"}
|
|
dat += "<A href='?src=\ref[src];screen=0'>(Return to Main Menu)</A><BR>"
|
|
|
|
user << browse(dat, "window=computer;size=400x500")
|
|
onclose(user, "computer")
|
|
return
|
|
|
|
//Why is this in robot/computer and why does it exist when /obj/machinery/computer/engine does not? -Nodrak
|
|
/*/obj/machinery/computer/engine/process()
|
|
if(stat & (NOPOWER|BROKEN))
|
|
return
|
|
use_power(500)
|
|
src.updateDialog()
|
|
return*/
|
|
|
|
/obj/machinery/computer/robotics/Topic(href, href_list)
|
|
if(..())
|
|
return
|
|
if ((usr.contents.Find(src) || (in_range(src, usr) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon)))
|
|
usr.machine = src
|
|
|
|
if (href_list["eject"])
|
|
src.temp = {"Destroy Robots?<BR>
|
|
<BR><B><A href='?src=\ref[src];eject2=1'>\[Swipe ID to initiate destruction sequence\]</A></B><BR>
|
|
<A href='?src=\ref[src];temp=1'>Cancel</A>"}
|
|
|
|
else if (href_list["eject2"])
|
|
var/obj/item/weapon/card/id/I = usr.get_active_hand()
|
|
if (istype(I, /obj/item/device/pda))
|
|
var/obj/item/device/pda/pda = I
|
|
I = pda.id
|
|
if (istype(I))
|
|
if(src.check_access(I))
|
|
if (!status)
|
|
message_admins("\blue [key_name_admin(usr)] has initiated the global cyborg killswitch!")
|
|
log_game("\blue [key_name(usr)] has initiated the global cyborg killswitch!")
|
|
src.status = 1
|
|
src.start_sequence()
|
|
src.temp = null
|
|
|
|
else
|
|
usr << "\red Access Denied."
|
|
|
|
else if (href_list["stop"])
|
|
src.temp = {"
|
|
Stop Robot Destruction Sequence?<BR>
|
|
<BR><A href='?src=\ref[src];stop2=1'>Yes</A><BR>
|
|
<A href='?src=\ref[src];temp=1'>No</A>"}
|
|
|
|
else if (href_list["stop2"])
|
|
src.stop = 1
|
|
src.temp = null
|
|
src.status = 0
|
|
|
|
else if (href_list["reset"])
|
|
src.timeleft = 60
|
|
|
|
else if (href_list["temp"])
|
|
src.temp = null
|
|
else if (href_list["screen"])
|
|
switch(href_list["screen"])
|
|
if("0")
|
|
screen = 0
|
|
if("1")
|
|
screen = 1
|
|
if("2")
|
|
screen = 2
|
|
else if (href_list["killbot"])
|
|
if(src.allowed(usr))
|
|
var/mob/living/silicon/robot/R = locate(href_list["killbot"])
|
|
if(R)
|
|
var/choice = input("Are you certain you wish to detonate [R.name]?") in list("Confirm", "Abort")
|
|
if(choice == "Confirm")
|
|
if(R && istype(R))
|
|
if(R.mind && R.mind.special_role && R.emagged)
|
|
R << "Extreme danger. Termination codes detected. Scrambling security codes and automatic AI unlink triggered."
|
|
R.ResetSecurityCodes()
|
|
|
|
else
|
|
message_admins("\blue [key_name_admin(usr)] detonated [R.name]!")
|
|
log_game("\blue [key_name_admin(usr)] detonated [R.name]!")
|
|
R.self_destruct()
|
|
else
|
|
usr << "\red Access Denied."
|
|
|
|
else if (href_list["stopbot"])
|
|
if(src.allowed(usr))
|
|
var/mob/living/silicon/robot/R = locate(href_list["stopbot"])
|
|
if(R && istype(R)) // Extra sancheck because of input var references
|
|
var/choice = input("Are you certain you wish to [R.canmove ? "lock down" : "release"] [R.name]?") in list("Confirm", "Abort")
|
|
if(choice == "Confirm")
|
|
if(R && istype(R))
|
|
message_admins("\blue [key_name_admin(usr)] [R.canmove ? "locked down" : "released"] [R.name]!")
|
|
log_game("[key_name(usr)] [R.canmove ? "locked down" : "released"] [R.name]!")
|
|
R.canmove = !R.canmove
|
|
if (R.lockcharge)
|
|
// R.cell.charge = R.lockcharge
|
|
R.lockcharge = !R.lockcharge
|
|
R << "Your lockdown has been lifted!"
|
|
else
|
|
R.lockcharge = !R.lockcharge
|
|
// R.cell.charge = 0
|
|
R << "You have been locked down!"
|
|
|
|
else
|
|
usr << "\red Access Denied."
|
|
|
|
else if (href_list["magbot"])
|
|
if(src.allowed(usr))
|
|
var/mob/living/silicon/robot/R = locate(href_list["magbot"])
|
|
if(R)
|
|
var/choice = input("Are you certain you wish to hack [R.name]?") in list("Confirm", "Abort")
|
|
if(choice == "Confirm")
|
|
if(R && istype(R))
|
|
// message_admins("\blue [key_name_admin(usr)] emagged [R.name] using robotic console!")
|
|
log_game("[key_name(usr)] emagged [R.name] using robotic console!")
|
|
R.emagged = 1
|
|
if(R.mind.special_role)
|
|
R.verbs += /mob/living/silicon/robot/proc/ResetSecurityCodes
|
|
|
|
src.add_fingerprint(usr)
|
|
src.updateUsrDialog()
|
|
return
|
|
|
|
/obj/machinery/computer/robotics/proc/start_sequence()
|
|
|
|
do
|
|
if(src.stop)
|
|
src.stop = 0
|
|
return
|
|
src.timeleft--
|
|
sleep(10)
|
|
while(src.timeleft)
|
|
|
|
for(var/mob/living/silicon/robot/R in mob_list)
|
|
if(!R.scrambledcodes)
|
|
R.self_destruct()
|
|
|
|
return
|
|
|