Line ending apocalypse

This commit is contained in:
oranges
2015-12-17 14:12:37 +13:00
parent 9d32ef0060
commit 134a76cc8f
110 changed files with 37428 additions and 37428 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+261 -261
View File
@@ -1,261 +1,261 @@
//- Are all the floors with or without air, as they should be? (regular or airless)
//- Does the area have an APC?
//- Does the area have an Air Alarm?
//- Does the area have a Request Console?
//- Does the area have lights?
//- Does the area have a light switch?
//- Does the area have enough intercoms?
//- Does the area have enough security cameras? (Use the 'Camera Range Display' verb under Debug)
//- Is the area connected to the scrubbers air loop?
//- Is the area connected to the vent air loop? (vent pumps)
//- Is everything wired properly?
//- Does the area have a fire alarm and firedoors?
//- Do all pod doors work properly?
//- Are accesses set properly on doors, pod buttons, etc.
//- Are all items placed properly? (not below vents, scrubbers, tables)
//- Does the disposal system work properly from all the disposal units in this room and all the units, the pipes of which pass through this room?
//- Check for any misplaced or stacked piece of pipe (air and disposal)
//- Check for any misplaced or stacked piece of wire
//- Identify how hard it is to break into the area and where the weak points are
//- Check if the area has too much empty space. If so, make it smaller and replace the rest with maintenance tunnels.
var/intercom_range_display_status = 0
/obj/effect/debugging/marker
icon = 'icons/turf/areas.dmi'
icon_state = "yellow"
/obj/effect/debugging/marker/Move()
return 0
/client/proc/do_not_use_these()
set category = "Mapping"
set name = "-None of these are for ingame use!!"
..()
/client/proc/camera_view()
set category = "Mapping"
set name = "Camera Range Display"
var/on = 0
for(var/turf/T in world)
if(T.maptext)
on = 1
T.maptext = null
if(!on)
var/list/seen = list()
for(var/obj/machinery/camera/C in cameranet.cameras)
for(var/turf/T in C.can_see())
seen[T]++
for(var/turf/T in seen)
T.maptext = "[seen[T]]"
feedback_add_details("admin_verb","mCRD") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/sec_camera_report()
set category = "Mapping"
set name = "Camera Report"
if(!Master)
alert(usr,"Master_controller not found.","Sec Camera Report")
return 0
var/list/obj/machinery/camera/CL = list()
for(var/obj/machinery/camera/C in cameranet.cameras)
CL += C
var/output = {"<B>CAMERA ANNOMALITIES REPORT</B><HR>
<B>The following annomalities have been detected. The ones in red need immediate attention: Some of those in black may be intentional.</B><BR><ul>"}
for(var/obj/machinery/camera/C1 in CL)
for(var/obj/machinery/camera/C2 in CL)
if(C1 != C2)
if(C1.c_tag == C2.c_tag)
output += "<li><font color='red'>c_tag match for sec. cameras at \[[C1.x], [C1.y], [C1.z]\] ([C1.loc.loc]) and \[[C2.x], [C2.y], [C2.z]\] ([C2.loc.loc]) - c_tag is [C1.c_tag]</font></li>"
if(C1.loc == C2.loc && C1.dir == C2.dir && C1.pixel_x == C2.pixel_x && C1.pixel_y == C2.pixel_y)
output += "<li><font color='red'>FULLY overlapping sec. cameras at \[[C1.x], [C1.y], [C1.z]\] ([C1.loc.loc]) Networks: [C1.network] and [C2.network]</font></li>"
if(C1.loc == C2.loc)
output += "<li>overlapping sec. cameras at \[[C1.x], [C1.y], [C1.z]\] ([C1.loc.loc]) Networks: [C1.network] and [C2.network]</font></li>"
var/turf/T = get_step(C1,turn(C1.dir,180))
if(!T || !isturf(T) || !T.density )
if(!(locate(/obj/structure/grille,T)))
var/window_check = 0
for(var/obj/structure/window/W in T)
if (W.dir == turn(C1.dir,180) || W.dir in list(5,6,9,10) )
window_check = 1
break
if(!window_check)
output += "<li><font color='red'>Camera not connected to wall at \[[C1.x], [C1.y], [C1.z]\] ([C1.loc.loc]) Network: [C1.network]</color></li>"
output += "</ul>"
usr << browse(output,"window=airreport;size=1000x500")
feedback_add_details("admin_verb","mCRP") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/intercom_view()
set category = "Mapping"
set name = "Intercom Range Display"
if(intercom_range_display_status)
intercom_range_display_status = 0
else
intercom_range_display_status = 1
for(var/obj/effect/debugging/marker/M in world)
qdel(M)
if(intercom_range_display_status)
for(var/obj/item/device/radio/intercom/I in world)
for(var/turf/T in orange(7,I))
var/obj/effect/debugging/marker/F = new/obj/effect/debugging/marker(T)
if (!(F in view(7,I.loc)))
qdel(F)
feedback_add_details("admin_verb","mIRD") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/cmd_show_at_list()
set category = "Mapping"
set name = "Show roundstart AT list"
set desc = "Displays a list of active turfs coordinates at roundstart"
var/dat = {"<b>Coordinate list of Active Turfs at Roundstart</b>
<br>Real-time Active Turfs list you can see in Air Subsystem at active_turfs var<br>"}
for(var/i=1; i<=active_turfs_startlist.len; i++)
dat += active_turfs_startlist[i]
dat += "<br>"
usr << browse(dat, "window=at_list")
feedback_add_details("admin_verb","mATL") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/enable_debug_verbs()
set category = "Debug"
set name = "Debug verbs"
if(!check_rights(R_DEBUG)) return
src.verbs += /client/proc/do_not_use_these //-errorage
src.verbs += /client/proc/camera_view //-errorage
src.verbs += /client/proc/sec_camera_report //-errorage
src.verbs += /client/proc/intercom_view //-errorage
src.verbs += /client/proc/air_status //Air things
src.verbs += /client/proc/Cell //More air things
src.verbs += /client/proc/atmosscan //check plumbing
src.verbs += /client/proc/powerdebug //check power
src.verbs += /client/proc/count_objects_on_z_level
src.verbs += /client/proc/count_objects_all
src.verbs += /client/proc/cmd_assume_direct_control //-errorage
src.verbs += /client/proc/startSinglo
src.verbs += /client/proc/fps //allows you to set the ticklag.
src.verbs += /client/proc/cmd_admin_grantfullaccess
src.verbs += /client/proc/cmd_admin_areatest
src.verbs += /client/proc/cmd_admin_rejuvenate
src.verbs += /datum/admins/proc/show_traitor_panel
src.verbs += /client/proc/disable_communication
src.verbs += /client/proc/print_pointers
src.verbs += /client/proc/count_movable_instances
src.verbs += /client/proc/cmd_show_at_list
src.verbs += /client/proc/cmd_show_at_list
src.verbs += /client/proc/manipulate_organs
feedback_add_details("admin_verb","mDV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/count_movable_instances()
set category = "Debug"
set name = "Count Movable Instances"
var/count = 0;
// Apparently there's a BYOND limit on the number of instances for non-turfs.
for(var/thing in world)
if(isturf(thing))
continue
count++;
usr << "There are [count]/[MAX_FLAG] instances of non-turfs in the world."
/client/proc/count_objects_on_z_level()
set category = "Mapping"
set name = "Count Objects On Level"
var/level = input("Which z-level?","Level?") as text
if(!level) return
var/num_level = text2num(level)
if(!num_level) return
if(!isnum(num_level)) return
var/type_text = input("Which type path?","Path?") as text
if(!type_text) return
var/type_path = text2path(type_text)
if(!type_path) return
var/count = 0
var/list/atom/atom_list = list()
for(var/atom/A in world)
if(istype(A,type_path))
var/atom/B = A
while(!(isturf(B.loc)))
if(B && B.loc)
B = B.loc
else
break
if(B)
if(B.z == num_level)
count++
atom_list += A
/*
var/atom/temp_atom
for(var/i = 0; i <= (atom_list.len/10); i++)
var/line = ""
for(var/j = 1; j <= 10; j++)
if(i*10+j <= atom_list.len)
temp_atom = atom_list[i*10+j]
line += " no.[i+10+j]@\[[temp_atom.x], [temp_atom.y], [temp_atom.z]\]; "
world << line*/
world << "There are [count] objects of type [type_path] on z-level [num_level]"
feedback_add_details("admin_verb","mOBJZ") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/count_objects_all()
set category = "Mapping"
set name = "Count Objects All"
var/type_text = input("Which type path?","") as text
if(!type_text) return
var/type_path = text2path(type_text)
if(!type_path) return
var/count = 0
for(var/atom/A in world)
if(istype(A,type_path))
count++
/*
var/atom/temp_atom
for(var/i = 0; i <= (atom_list.len/10); i++)
var/line = ""
for(var/j = 1; j <= 10; j++)
if(i*10+j <= atom_list.len)
temp_atom = atom_list[i*10+j]
line += " no.[i+10+j]@\[[temp_atom.x], [temp_atom.y], [temp_atom.z]\]; "
world << line*/
world << "There are [count] objects of type [type_path] in the game world"
feedback_add_details("admin_verb","mOBJ") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
//This proc is intended to detect lag problems relating to communication procs
var/global/say_disabled = 0
/client/proc/disable_communication()
set category = "Mapping"
set name = "Disable all communication verbs"
say_disabled = !say_disabled
if(say_disabled)
message_admins("[src.ckey] used 'Disable all communication verbs', killing all communication methods.")
else
message_admins("[src.ckey] used 'Disable all communication verbs', restoring all communication methods.")
//- Are all the floors with or without air, as they should be? (regular or airless)
//- Does the area have an APC?
//- Does the area have an Air Alarm?
//- Does the area have a Request Console?
//- Does the area have lights?
//- Does the area have a light switch?
//- Does the area have enough intercoms?
//- Does the area have enough security cameras? (Use the 'Camera Range Display' verb under Debug)
//- Is the area connected to the scrubbers air loop?
//- Is the area connected to the vent air loop? (vent pumps)
//- Is everything wired properly?
//- Does the area have a fire alarm and firedoors?
//- Do all pod doors work properly?
//- Are accesses set properly on doors, pod buttons, etc.
//- Are all items placed properly? (not below vents, scrubbers, tables)
//- Does the disposal system work properly from all the disposal units in this room and all the units, the pipes of which pass through this room?
//- Check for any misplaced or stacked piece of pipe (air and disposal)
//- Check for any misplaced or stacked piece of wire
//- Identify how hard it is to break into the area and where the weak points are
//- Check if the area has too much empty space. If so, make it smaller and replace the rest with maintenance tunnels.
var/intercom_range_display_status = 0
/obj/effect/debugging/marker
icon = 'icons/turf/areas.dmi'
icon_state = "yellow"
/obj/effect/debugging/marker/Move()
return 0
/client/proc/do_not_use_these()
set category = "Mapping"
set name = "-None of these are for ingame use!!"
..()
/client/proc/camera_view()
set category = "Mapping"
set name = "Camera Range Display"
var/on = 0
for(var/turf/T in world)
if(T.maptext)
on = 1
T.maptext = null
if(!on)
var/list/seen = list()
for(var/obj/machinery/camera/C in cameranet.cameras)
for(var/turf/T in C.can_see())
seen[T]++
for(var/turf/T in seen)
T.maptext = "[seen[T]]"
feedback_add_details("admin_verb","mCRD") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/sec_camera_report()
set category = "Mapping"
set name = "Camera Report"
if(!Master)
alert(usr,"Master_controller not found.","Sec Camera Report")
return 0
var/list/obj/machinery/camera/CL = list()
for(var/obj/machinery/camera/C in cameranet.cameras)
CL += C
var/output = {"<B>CAMERA ANNOMALITIES REPORT</B><HR>
<B>The following annomalities have been detected. The ones in red need immediate attention: Some of those in black may be intentional.</B><BR><ul>"}
for(var/obj/machinery/camera/C1 in CL)
for(var/obj/machinery/camera/C2 in CL)
if(C1 != C2)
if(C1.c_tag == C2.c_tag)
output += "<li><font color='red'>c_tag match for sec. cameras at \[[C1.x], [C1.y], [C1.z]\] ([C1.loc.loc]) and \[[C2.x], [C2.y], [C2.z]\] ([C2.loc.loc]) - c_tag is [C1.c_tag]</font></li>"
if(C1.loc == C2.loc && C1.dir == C2.dir && C1.pixel_x == C2.pixel_x && C1.pixel_y == C2.pixel_y)
output += "<li><font color='red'>FULLY overlapping sec. cameras at \[[C1.x], [C1.y], [C1.z]\] ([C1.loc.loc]) Networks: [C1.network] and [C2.network]</font></li>"
if(C1.loc == C2.loc)
output += "<li>overlapping sec. cameras at \[[C1.x], [C1.y], [C1.z]\] ([C1.loc.loc]) Networks: [C1.network] and [C2.network]</font></li>"
var/turf/T = get_step(C1,turn(C1.dir,180))
if(!T || !isturf(T) || !T.density )
if(!(locate(/obj/structure/grille,T)))
var/window_check = 0
for(var/obj/structure/window/W in T)
if (W.dir == turn(C1.dir,180) || W.dir in list(5,6,9,10) )
window_check = 1
break
if(!window_check)
output += "<li><font color='red'>Camera not connected to wall at \[[C1.x], [C1.y], [C1.z]\] ([C1.loc.loc]) Network: [C1.network]</color></li>"
output += "</ul>"
usr << browse(output,"window=airreport;size=1000x500")
feedback_add_details("admin_verb","mCRP") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/intercom_view()
set category = "Mapping"
set name = "Intercom Range Display"
if(intercom_range_display_status)
intercom_range_display_status = 0
else
intercom_range_display_status = 1
for(var/obj/effect/debugging/marker/M in world)
qdel(M)
if(intercom_range_display_status)
for(var/obj/item/device/radio/intercom/I in world)
for(var/turf/T in orange(7,I))
var/obj/effect/debugging/marker/F = new/obj/effect/debugging/marker(T)
if (!(F in view(7,I.loc)))
qdel(F)
feedback_add_details("admin_verb","mIRD") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/cmd_show_at_list()
set category = "Mapping"
set name = "Show roundstart AT list"
set desc = "Displays a list of active turfs coordinates at roundstart"
var/dat = {"<b>Coordinate list of Active Turfs at Roundstart</b>
<br>Real-time Active Turfs list you can see in Air Subsystem at active_turfs var<br>"}
for(var/i=1; i<=active_turfs_startlist.len; i++)
dat += active_turfs_startlist[i]
dat += "<br>"
usr << browse(dat, "window=at_list")
feedback_add_details("admin_verb","mATL") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/enable_debug_verbs()
set category = "Debug"
set name = "Debug verbs"
if(!check_rights(R_DEBUG)) return
src.verbs += /client/proc/do_not_use_these //-errorage
src.verbs += /client/proc/camera_view //-errorage
src.verbs += /client/proc/sec_camera_report //-errorage
src.verbs += /client/proc/intercom_view //-errorage
src.verbs += /client/proc/air_status //Air things
src.verbs += /client/proc/Cell //More air things
src.verbs += /client/proc/atmosscan //check plumbing
src.verbs += /client/proc/powerdebug //check power
src.verbs += /client/proc/count_objects_on_z_level
src.verbs += /client/proc/count_objects_all
src.verbs += /client/proc/cmd_assume_direct_control //-errorage
src.verbs += /client/proc/startSinglo
src.verbs += /client/proc/fps //allows you to set the ticklag.
src.verbs += /client/proc/cmd_admin_grantfullaccess
src.verbs += /client/proc/cmd_admin_areatest
src.verbs += /client/proc/cmd_admin_rejuvenate
src.verbs += /datum/admins/proc/show_traitor_panel
src.verbs += /client/proc/disable_communication
src.verbs += /client/proc/print_pointers
src.verbs += /client/proc/count_movable_instances
src.verbs += /client/proc/cmd_show_at_list
src.verbs += /client/proc/cmd_show_at_list
src.verbs += /client/proc/manipulate_organs
feedback_add_details("admin_verb","mDV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/count_movable_instances()
set category = "Debug"
set name = "Count Movable Instances"
var/count = 0;
// Apparently there's a BYOND limit on the number of instances for non-turfs.
for(var/thing in world)
if(isturf(thing))
continue
count++;
usr << "There are [count]/[MAX_FLAG] instances of non-turfs in the world."
/client/proc/count_objects_on_z_level()
set category = "Mapping"
set name = "Count Objects On Level"
var/level = input("Which z-level?","Level?") as text
if(!level) return
var/num_level = text2num(level)
if(!num_level) return
if(!isnum(num_level)) return
var/type_text = input("Which type path?","Path?") as text
if(!type_text) return
var/type_path = text2path(type_text)
if(!type_path) return
var/count = 0
var/list/atom/atom_list = list()
for(var/atom/A in world)
if(istype(A,type_path))
var/atom/B = A
while(!(isturf(B.loc)))
if(B && B.loc)
B = B.loc
else
break
if(B)
if(B.z == num_level)
count++
atom_list += A
/*
var/atom/temp_atom
for(var/i = 0; i <= (atom_list.len/10); i++)
var/line = ""
for(var/j = 1; j <= 10; j++)
if(i*10+j <= atom_list.len)
temp_atom = atom_list[i*10+j]
line += " no.[i+10+j]@\[[temp_atom.x], [temp_atom.y], [temp_atom.z]\]; "
world << line*/
world << "There are [count] objects of type [type_path] on z-level [num_level]"
feedback_add_details("admin_verb","mOBJZ") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/count_objects_all()
set category = "Mapping"
set name = "Count Objects All"
var/type_text = input("Which type path?","") as text
if(!type_text) return
var/type_path = text2path(type_text)
if(!type_path) return
var/count = 0
for(var/atom/A in world)
if(istype(A,type_path))
count++
/*
var/atom/temp_atom
for(var/i = 0; i <= (atom_list.len/10); i++)
var/line = ""
for(var/j = 1; j <= 10; j++)
if(i*10+j <= atom_list.len)
temp_atom = atom_list[i*10+j]
line += " no.[i+10+j]@\[[temp_atom.x], [temp_atom.y], [temp_atom.z]\]; "
world << line*/
world << "There are [count] objects of type [type_path] in the game world"
feedback_add_details("admin_verb","mOBJ") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
//This proc is intended to detect lag problems relating to communication procs
var/global/say_disabled = 0
/client/proc/disable_communication()
set category = "Mapping"
set name = "Disable all communication verbs"
say_disabled = !say_disabled
if(say_disabled)
message_admins("[src.ckey] used 'Disable all communication verbs', killing all communication methods.")
else
message_admins("[src.ckey] used 'Disable all communication verbs', restoring all communication methods.")
File diff suppressed because it is too large Load Diff
+345 -345
View File
@@ -1,345 +1,345 @@
//These are meant for spawning on maps, namely Away Missions.
//If someone can do this in a neater way, be my guest-Kor
//To do: Allow corpses to appear mangled, bloody, etc. Allow customizing the bodies appearance (they're all bald and white right now).
/obj/effect/landmark/corpse
name = "Unknown"
var/mobname = "default" //Use for the ghost spawner variant, so they don't come out named "sleeper"
var/mobgender = MALE //Set to male by default due to the patriarchy. Other options include FEMALE and NEUTER
var/mob_species = null //Set to make them a mutant race such as lizard or skeleton. Uses the datum typepath instead of the ID.
var/corpseuniform = null //Set this to an object path to have the slot filled with said object on the corpse.
var/corpsesuit = null
var/corpseshoes = null
var/corpsegloves = null
var/corpseradio = null
var/corpseglasses = null
var/corpsemask = null
var/corpsehelmet = null
var/corpsebelt = null
var/corpsepocket1 = null
var/corpsepocket2 = null
var/corpseback = null
var/corpseid = 0 //Just set to 1 if you want them to have an ID
var/corpseidjob = null // Needs to be in quotes, such as "Clown" or "Chef." This just determines what the ID reads as, not their access
var/corpseidaccess = null //This is for access. See access.dm for which jobs give what access. Again, put in quotes. Use "Captain" if you want it to be all access.
var/corpseidicon = null //For setting it to be a gold, silver, centcom etc ID
var/corpsehusk = null
var/corpsebrute = null //set brute damage on the corpse
var/corpseoxy = null //set suffocation damage on the corpse
var/roundstart = TRUE
var/death = TRUE
var/flavour_text = "The mapper forgot to set this!"
var/faction = null
density = 1
/obj/effect/landmark/corpse/initialize()
if(roundstart)
createCorpse(death = src.death)
else
return
/obj/effect/landmark/corpse/New()
..()
invisibility = 0
/obj/effect/landmark/corpse/proc/createCorpse(death, ckey) //Creates a mob and checks for gear in each slot before attempting to equip it.
var/mob/living/carbon/human/M = new /mob/living/carbon/human (src.loc)
if(mobname != "default")
M.real_name = mobname
else
M.real_name = src.name
M.gender = src.mobgender
if(mob_species)
M.set_species(mob_species)
if(death)
M.death(1) //Kills the new mob
if(src.corpsehusk)
M.Drain()
if(faction)
M.faction = list(src.faction)
M.adjustBruteLoss(src.corpsebrute)
M.adjustOxyLoss(src.corpseoxy)
if(src.corpseuniform)
M.equip_to_slot_or_del(new src.corpseuniform(M), slot_w_uniform)
if(src.corpsesuit)
M.equip_to_slot_or_del(new src.corpsesuit(M), slot_wear_suit)
if(src.corpseshoes)
M.equip_to_slot_or_del(new src.corpseshoes(M), slot_shoes)
if(src.corpsegloves)
M.equip_to_slot_or_del(new src.corpsegloves(M), slot_gloves)
if(src.corpseradio)
M.equip_to_slot_or_del(new src.corpseradio(M), slot_ears)
if(src.corpseglasses)
M.equip_to_slot_or_del(new src.corpseglasses(M), slot_glasses)
if(src.corpsemask)
M.equip_to_slot_or_del(new src.corpsemask(M), slot_wear_mask)
if(src.corpsehelmet)
M.equip_to_slot_or_del(new src.corpsehelmet(M), slot_head)
if(src.corpsebelt)
M.equip_to_slot_or_del(new src.corpsebelt(M), slot_belt)
if(src.corpsepocket1)
M.equip_to_slot_or_del(new src.corpsepocket1(M), slot_r_store)
if(src.corpsepocket2)
M.equip_to_slot_or_del(new src.corpsepocket2(M), slot_l_store)
if(src.corpseback)
M.equip_to_slot_or_del(new src.corpseback(M), slot_back)
if(src.corpseid == 1)
var/obj/item/weapon/card/id/W = new(M)
var/datum/job/jobdatum
for(var/jobtype in typesof(/datum/job))
var/datum/job/J = new jobtype
if(J.title == corpseidaccess)
jobdatum = J
break
if(src.corpseidicon)
W.icon_state = corpseidicon
if(src.corpseidaccess)
if(jobdatum)
W.access = jobdatum.get_access()
else
W.access = list()
if(corpseidjob)
W.assignment = corpseidjob
W.registered_name = M.real_name
W.update_label()
M.equip_to_slot_or_del(W, slot_wear_id)
if(ckey)
M.ckey = ckey
M << "[flavour_text]"
qdel(src)
/obj/effect/landmark/corpse/AICorpse/createCorpse() //Creates a corrupted AI
var/A = locate(/mob/living/silicon/ai) in loc //variable A looks for an AI at the location of the landmark
if(A) //if variable A is true
return //stop executing the proc
var/L = new /datum/ai_laws/default/asimov/ //variable L is a new Asimov lawset
var/B = new /obj/item/device/mmi/ //variable B is a new MMI
var/mob/living/silicon/ai/M = new(src.loc, L, B, 1) //spawn new AI at landmark as var M
M.name = src.name
M.real_name = src.name
M.aiPDA.toff = 1 //turns the AI's PDA messenger off, stopping it showing up on player PDAs
M.death() //call the AI's death proc
qdel(src)
/obj/effect/landmark/corpse/slimeCorpse
var/mobcolour = "grey"
icon = 'icons/mob/slimes.dmi'
icon_state = "grey baby slime" //sets the icon in the map editor
/obj/effect/landmark/corpse/slimeCorpse/createCorpse() //proc creates a dead slime
var/A = locate(/mob/living/simple_animal/slime/) in loc //variable A looks for a slime at the location of the landmark
if(A) //if variable A is true
return //stop executing the proc
var/mob/living/simple_animal/slime/M = new(src.loc) //variable M is a new slime at the location of the landmark
M.colour = src.mobcolour //slime colour is set by landmark's mobcolour var
M.adjustToxLoss(9001) //kills the slime, death() doesn't update its icon correctly
qdel(src)
/obj/effect/landmark/corpse/facehugCorpse/createCorpse() //Creates a squashed facehugger
var/obj/item/clothing/mask/facehugger/O = new(src.loc) //variable O is a new facehugger at the location of the landmark
O.name = src.name
O.Die() //call the facehugger's death proc
qdel(src)
// I'll work on making a list of corpses people request for maps, or that I think will be commonly used. Syndicate operatives for example.
/obj/effect/landmark/corpse/syndicatesoldier
name = "Syndicate Operative"
corpseuniform = /obj/item/clothing/under/syndicate
corpsesuit = /obj/item/clothing/suit/armor/vest
corpseshoes = /obj/item/clothing/shoes/combat
corpsegloves = /obj/item/clothing/gloves/combat
corpseradio = /obj/item/device/radio/headset
corpsemask = /obj/item/clothing/mask/gas
corpsehelmet = /obj/item/clothing/head/helmet/swat
corpseback = /obj/item/weapon/storage/backpack
corpseid = 1
corpseidjob = "Operative"
corpseidaccess = "Syndicate"
/obj/effect/landmark/corpse/syndicatecommando
name = "Syndicate Commando"
corpseuniform = /obj/item/clothing/under/syndicate
corpsesuit = /obj/item/clothing/suit/space/hardsuit/syndi
corpseshoes = /obj/item/clothing/shoes/combat
corpsegloves = /obj/item/clothing/gloves/combat
corpseradio = /obj/item/device/radio/headset
corpsemask = /obj/item/clothing/mask/gas/syndicate
corpsehelmet = /obj/item/clothing/head/helmet/space/hardsuit/syndi
corpseback = /obj/item/weapon/tank/jetpack/oxygen
corpsepocket1 = /obj/item/weapon/tank/internals/emergency_oxygen
corpseid = 1
corpseidjob = "Operative"
corpseidaccess = "Syndicate"
///////////Civilians//////////////////////
/obj/effect/landmark/corpse/cook
name = "Cook"
corpseuniform = /obj/item/clothing/under/rank/chef
corpsesuit = /obj/item/clothing/suit/apron/chef
corpseshoes = /obj/item/clothing/shoes/sneakers/black
corpsehelmet = /obj/item/clothing/head/chefhat
corpseback = /obj/item/weapon/storage/backpack
corpseradio = /obj/item/device/radio/headset
corpseid = 1
corpseidjob = "Cook"
corpseidaccess = "Cook"
/obj/effect/landmark/corpse/doctor
name = "Doctor"
corpseradio = /obj/item/device/radio/headset/headset_med
corpseuniform = /obj/item/clothing/under/rank/medical
corpsesuit = /obj/item/clothing/suit/toggle/labcoat
corpseback = /obj/item/weapon/storage/backpack/medic
corpsepocket1 = /obj/item/device/flashlight/pen
corpseshoes = /obj/item/clothing/shoes/sneakers/black
corpseid = 1
corpseidjob = "Medical Doctor"
corpseidaccess = "Medical Doctor"
/obj/effect/landmark/corpse/engineer
name = "Engineer"
corpseradio = /obj/item/device/radio/headset/headset_eng
corpseuniform = /obj/item/clothing/under/rank/engineer
corpseback = /obj/item/weapon/storage/backpack/industrial
corpseshoes = /obj/item/clothing/shoes/sneakers/orange
corpsebelt = /obj/item/weapon/storage/belt/utility/full
corpsegloves = /obj/item/clothing/gloves/color/yellow
corpsehelmet = /obj/item/clothing/head/hardhat
corpseid = 1
corpseidjob = "Station Engineer"
corpseidaccess = "Station Engineer"
/obj/effect/landmark/corpse/engineer/rig
corpsesuit = /obj/item/clothing/suit/space/hardsuit/engine
corpsemask = /obj/item/clothing/mask/breath
/obj/effect/landmark/corpse/clown
name = "Clown"
corpseuniform = /obj/item/clothing/under/rank/clown
corpseshoes = /obj/item/clothing/shoes/clown_shoes
corpseradio = /obj/item/device/radio/headset
corpsemask = /obj/item/clothing/mask/gas/clown_hat
corpsepocket1 = /obj/item/weapon/bikehorn
corpseback = /obj/item/weapon/storage/backpack/clown
corpseid = 1
corpseidjob = "Clown"
corpseidaccess = "Clown"
/obj/effect/landmark/corpse/scientist
name = "Scientist"
corpseradio = /obj/item/device/radio/headset/headset_sci
corpseuniform = /obj/item/clothing/under/rank/scientist
corpsesuit = /obj/item/clothing/suit/toggle/labcoat/science
corpseback = /obj/item/weapon/storage/backpack
corpseshoes = /obj/item/clothing/shoes/sneakers/white
corpseid = 1
corpseidjob = "Scientist"
corpseidaccess = "Scientist"
/obj/effect/landmark/corpse/miner
corpseradio = /obj/item/device/radio/headset/headset_cargo
corpseuniform = /obj/item/clothing/under/rank/miner
corpsegloves = /obj/item/clothing/gloves/fingerless
corpseback = /obj/item/weapon/storage/backpack/industrial
corpseshoes = /obj/item/clothing/shoes/sneakers/black
corpseid = 1
corpseidjob = "Shaft Miner"
corpseidaccess = "Shaft Miner"
/obj/effect/landmark/corpse/miner/rig
corpsesuit = /obj/item/clothing/suit/space/hardsuit/mining
corpsemask = /obj/item/clothing/mask/breath
/obj/effect/landmark/corpse/plasmaman
mob_species = /datum/species/plasmaman
corpsehelmet = /obj/item/clothing/head/helmet/space/plasmaman
corpseuniform = /obj/item/clothing/under/plasmaman
corpseback = /obj/item/weapon/tank/internals/plasmaman/full
corpsemask = /obj/item/clothing/mask/breath
/////////////////Officers//////////////////////
/obj/effect/landmark/corpse/bridgeofficer
name = "Bridge Officer"
corpseradio = /obj/item/device/radio/headset/heads/hop
corpseuniform = /obj/item/clothing/under/rank/centcom_officer
corpsesuit = /obj/item/clothing/suit/armor/bulletproof
corpseshoes = /obj/item/clothing/shoes/sneakers/black
corpseglasses = /obj/item/clothing/glasses/sunglasses
corpseid = 1
corpseidjob = "Bridge Officer"
corpseidaccess = "Captain"
/obj/effect/landmark/corpse/commander
name = "Commander"
corpseuniform = /obj/item/clothing/under/rank/centcom_commander
corpsesuit = /obj/item/clothing/suit/armor
corpseradio = /obj/item/device/radio/headset/heads/captain
corpseglasses = /obj/item/clothing/glasses/eyepatch
corpsemask = /obj/item/clothing/mask/cigarette/cigar/cohiba
corpsehelmet = /obj/item/clothing/head/centhat
corpsegloves = /obj/item/clothing/gloves/combat
corpseshoes = /obj/item/clothing/shoes/combat/swat
corpsepocket1 = /obj/item/weapon/lighter
corpseid = 1
corpseidjob = "Commander"
corpseidaccess = "Captain"
/obj/effect/landmark/corpse/commander/alive
death = FALSE
roundstart = FALSE
mobname = "Nanotrasen Commander"
name = "sleeper"
icon = 'icons/obj/Cryogenic2.dmi'
icon_state = "sleeper"
flavour_text = "You are a Nanotrasen Commander!"
/obj/effect/landmark/corpse/attack_ghost(mob/user)
if(ticker.current_state != GAME_STATE_PLAYING)
return
var/ghost_role = alert("Become [mobname]? (Warning, You can no longer be cloned!)",,"Yes","No")
if(ghost_role == "No")
return
createCorpse(death = src.death, ckey = user.ckey)
/////////////////Spooky Undead//////////////////////
/obj/effect/landmark/corpse/skeleton
name = "skeletal remains"
mobname = "skeleton"
mob_species = /datum/species/skeleton
mobgender = NEUTER
/obj/effect/landmark/corpse/skeleton/alive
death = FALSE
roundstart = FALSE
icon = 'icons/effects/blood.dmi'
icon_state = "remains"
flavour_text = "By unknown powers, your skeletal remains have been reanimated! Walk this mortal plain and terrorize all living adventurers who dare cross your path."
/obj/effect/landmark/corpse/zombie
name = "rotting corpse"
mobname = "zombie"
mob_species = /datum/species/zombie
/obj/effect/landmark/corpse/zombie/alive
death = FALSE
roundstart = FALSE
icon = 'icons/effects/blood.dmi'
icon_state = "remains"
flavour_text = "By unknown powers, your rotting remains have been resurrected! Walk this mortal plain and terrorize all living adventurers who dare cross your path."
//These are meant for spawning on maps, namely Away Missions.
//If someone can do this in a neater way, be my guest-Kor
//To do: Allow corpses to appear mangled, bloody, etc. Allow customizing the bodies appearance (they're all bald and white right now).
/obj/effect/landmark/corpse
name = "Unknown"
var/mobname = "default" //Use for the ghost spawner variant, so they don't come out named "sleeper"
var/mobgender = MALE //Set to male by default due to the patriarchy. Other options include FEMALE and NEUTER
var/mob_species = null //Set to make them a mutant race such as lizard or skeleton. Uses the datum typepath instead of the ID.
var/corpseuniform = null //Set this to an object path to have the slot filled with said object on the corpse.
var/corpsesuit = null
var/corpseshoes = null
var/corpsegloves = null
var/corpseradio = null
var/corpseglasses = null
var/corpsemask = null
var/corpsehelmet = null
var/corpsebelt = null
var/corpsepocket1 = null
var/corpsepocket2 = null
var/corpseback = null
var/corpseid = 0 //Just set to 1 if you want them to have an ID
var/corpseidjob = null // Needs to be in quotes, such as "Clown" or "Chef." This just determines what the ID reads as, not their access
var/corpseidaccess = null //This is for access. See access.dm for which jobs give what access. Again, put in quotes. Use "Captain" if you want it to be all access.
var/corpseidicon = null //For setting it to be a gold, silver, centcom etc ID
var/corpsehusk = null
var/corpsebrute = null //set brute damage on the corpse
var/corpseoxy = null //set suffocation damage on the corpse
var/roundstart = TRUE
var/death = TRUE
var/flavour_text = "The mapper forgot to set this!"
var/faction = null
density = 1
/obj/effect/landmark/corpse/initialize()
if(roundstart)
createCorpse(death = src.death)
else
return
/obj/effect/landmark/corpse/New()
..()
invisibility = 0
/obj/effect/landmark/corpse/proc/createCorpse(death, ckey) //Creates a mob and checks for gear in each slot before attempting to equip it.
var/mob/living/carbon/human/M = new /mob/living/carbon/human (src.loc)
if(mobname != "default")
M.real_name = mobname
else
M.real_name = src.name
M.gender = src.mobgender
if(mob_species)
M.set_species(mob_species)
if(death)
M.death(1) //Kills the new mob
if(src.corpsehusk)
M.Drain()
if(faction)
M.faction = list(src.faction)
M.adjustBruteLoss(src.corpsebrute)
M.adjustOxyLoss(src.corpseoxy)
if(src.corpseuniform)
M.equip_to_slot_or_del(new src.corpseuniform(M), slot_w_uniform)
if(src.corpsesuit)
M.equip_to_slot_or_del(new src.corpsesuit(M), slot_wear_suit)
if(src.corpseshoes)
M.equip_to_slot_or_del(new src.corpseshoes(M), slot_shoes)
if(src.corpsegloves)
M.equip_to_slot_or_del(new src.corpsegloves(M), slot_gloves)
if(src.corpseradio)
M.equip_to_slot_or_del(new src.corpseradio(M), slot_ears)
if(src.corpseglasses)
M.equip_to_slot_or_del(new src.corpseglasses(M), slot_glasses)
if(src.corpsemask)
M.equip_to_slot_or_del(new src.corpsemask(M), slot_wear_mask)
if(src.corpsehelmet)
M.equip_to_slot_or_del(new src.corpsehelmet(M), slot_head)
if(src.corpsebelt)
M.equip_to_slot_or_del(new src.corpsebelt(M), slot_belt)
if(src.corpsepocket1)
M.equip_to_slot_or_del(new src.corpsepocket1(M), slot_r_store)
if(src.corpsepocket2)
M.equip_to_slot_or_del(new src.corpsepocket2(M), slot_l_store)
if(src.corpseback)
M.equip_to_slot_or_del(new src.corpseback(M), slot_back)
if(src.corpseid == 1)
var/obj/item/weapon/card/id/W = new(M)
var/datum/job/jobdatum
for(var/jobtype in typesof(/datum/job))
var/datum/job/J = new jobtype
if(J.title == corpseidaccess)
jobdatum = J
break
if(src.corpseidicon)
W.icon_state = corpseidicon
if(src.corpseidaccess)
if(jobdatum)
W.access = jobdatum.get_access()
else
W.access = list()
if(corpseidjob)
W.assignment = corpseidjob
W.registered_name = M.real_name
W.update_label()
M.equip_to_slot_or_del(W, slot_wear_id)
if(ckey)
M.ckey = ckey
M << "[flavour_text]"
qdel(src)
/obj/effect/landmark/corpse/AICorpse/createCorpse() //Creates a corrupted AI
var/A = locate(/mob/living/silicon/ai) in loc //variable A looks for an AI at the location of the landmark
if(A) //if variable A is true
return //stop executing the proc
var/L = new /datum/ai_laws/default/asimov/ //variable L is a new Asimov lawset
var/B = new /obj/item/device/mmi/ //variable B is a new MMI
var/mob/living/silicon/ai/M = new(src.loc, L, B, 1) //spawn new AI at landmark as var M
M.name = src.name
M.real_name = src.name
M.aiPDA.toff = 1 //turns the AI's PDA messenger off, stopping it showing up on player PDAs
M.death() //call the AI's death proc
qdel(src)
/obj/effect/landmark/corpse/slimeCorpse
var/mobcolour = "grey"
icon = 'icons/mob/slimes.dmi'
icon_state = "grey baby slime" //sets the icon in the map editor
/obj/effect/landmark/corpse/slimeCorpse/createCorpse() //proc creates a dead slime
var/A = locate(/mob/living/simple_animal/slime/) in loc //variable A looks for a slime at the location of the landmark
if(A) //if variable A is true
return //stop executing the proc
var/mob/living/simple_animal/slime/M = new(src.loc) //variable M is a new slime at the location of the landmark
M.colour = src.mobcolour //slime colour is set by landmark's mobcolour var
M.adjustToxLoss(9001) //kills the slime, death() doesn't update its icon correctly
qdel(src)
/obj/effect/landmark/corpse/facehugCorpse/createCorpse() //Creates a squashed facehugger
var/obj/item/clothing/mask/facehugger/O = new(src.loc) //variable O is a new facehugger at the location of the landmark
O.name = src.name
O.Die() //call the facehugger's death proc
qdel(src)
// I'll work on making a list of corpses people request for maps, or that I think will be commonly used. Syndicate operatives for example.
/obj/effect/landmark/corpse/syndicatesoldier
name = "Syndicate Operative"
corpseuniform = /obj/item/clothing/under/syndicate
corpsesuit = /obj/item/clothing/suit/armor/vest
corpseshoes = /obj/item/clothing/shoes/combat
corpsegloves = /obj/item/clothing/gloves/combat
corpseradio = /obj/item/device/radio/headset
corpsemask = /obj/item/clothing/mask/gas
corpsehelmet = /obj/item/clothing/head/helmet/swat
corpseback = /obj/item/weapon/storage/backpack
corpseid = 1
corpseidjob = "Operative"
corpseidaccess = "Syndicate"
/obj/effect/landmark/corpse/syndicatecommando
name = "Syndicate Commando"
corpseuniform = /obj/item/clothing/under/syndicate
corpsesuit = /obj/item/clothing/suit/space/hardsuit/syndi
corpseshoes = /obj/item/clothing/shoes/combat
corpsegloves = /obj/item/clothing/gloves/combat
corpseradio = /obj/item/device/radio/headset
corpsemask = /obj/item/clothing/mask/gas/syndicate
corpsehelmet = /obj/item/clothing/head/helmet/space/hardsuit/syndi
corpseback = /obj/item/weapon/tank/jetpack/oxygen
corpsepocket1 = /obj/item/weapon/tank/internals/emergency_oxygen
corpseid = 1
corpseidjob = "Operative"
corpseidaccess = "Syndicate"
///////////Civilians//////////////////////
/obj/effect/landmark/corpse/cook
name = "Cook"
corpseuniform = /obj/item/clothing/under/rank/chef
corpsesuit = /obj/item/clothing/suit/apron/chef
corpseshoes = /obj/item/clothing/shoes/sneakers/black
corpsehelmet = /obj/item/clothing/head/chefhat
corpseback = /obj/item/weapon/storage/backpack
corpseradio = /obj/item/device/radio/headset
corpseid = 1
corpseidjob = "Cook"
corpseidaccess = "Cook"
/obj/effect/landmark/corpse/doctor
name = "Doctor"
corpseradio = /obj/item/device/radio/headset/headset_med
corpseuniform = /obj/item/clothing/under/rank/medical
corpsesuit = /obj/item/clothing/suit/toggle/labcoat
corpseback = /obj/item/weapon/storage/backpack/medic
corpsepocket1 = /obj/item/device/flashlight/pen
corpseshoes = /obj/item/clothing/shoes/sneakers/black
corpseid = 1
corpseidjob = "Medical Doctor"
corpseidaccess = "Medical Doctor"
/obj/effect/landmark/corpse/engineer
name = "Engineer"
corpseradio = /obj/item/device/radio/headset/headset_eng
corpseuniform = /obj/item/clothing/under/rank/engineer
corpseback = /obj/item/weapon/storage/backpack/industrial
corpseshoes = /obj/item/clothing/shoes/sneakers/orange
corpsebelt = /obj/item/weapon/storage/belt/utility/full
corpsegloves = /obj/item/clothing/gloves/color/yellow
corpsehelmet = /obj/item/clothing/head/hardhat
corpseid = 1
corpseidjob = "Station Engineer"
corpseidaccess = "Station Engineer"
/obj/effect/landmark/corpse/engineer/rig
corpsesuit = /obj/item/clothing/suit/space/hardsuit/engine
corpsemask = /obj/item/clothing/mask/breath
/obj/effect/landmark/corpse/clown
name = "Clown"
corpseuniform = /obj/item/clothing/under/rank/clown
corpseshoes = /obj/item/clothing/shoes/clown_shoes
corpseradio = /obj/item/device/radio/headset
corpsemask = /obj/item/clothing/mask/gas/clown_hat
corpsepocket1 = /obj/item/weapon/bikehorn
corpseback = /obj/item/weapon/storage/backpack/clown
corpseid = 1
corpseidjob = "Clown"
corpseidaccess = "Clown"
/obj/effect/landmark/corpse/scientist
name = "Scientist"
corpseradio = /obj/item/device/radio/headset/headset_sci
corpseuniform = /obj/item/clothing/under/rank/scientist
corpsesuit = /obj/item/clothing/suit/toggle/labcoat/science
corpseback = /obj/item/weapon/storage/backpack
corpseshoes = /obj/item/clothing/shoes/sneakers/white
corpseid = 1
corpseidjob = "Scientist"
corpseidaccess = "Scientist"
/obj/effect/landmark/corpse/miner
corpseradio = /obj/item/device/radio/headset/headset_cargo
corpseuniform = /obj/item/clothing/under/rank/miner
corpsegloves = /obj/item/clothing/gloves/fingerless
corpseback = /obj/item/weapon/storage/backpack/industrial
corpseshoes = /obj/item/clothing/shoes/sneakers/black
corpseid = 1
corpseidjob = "Shaft Miner"
corpseidaccess = "Shaft Miner"
/obj/effect/landmark/corpse/miner/rig
corpsesuit = /obj/item/clothing/suit/space/hardsuit/mining
corpsemask = /obj/item/clothing/mask/breath
/obj/effect/landmark/corpse/plasmaman
mob_species = /datum/species/plasmaman
corpsehelmet = /obj/item/clothing/head/helmet/space/plasmaman
corpseuniform = /obj/item/clothing/under/plasmaman
corpseback = /obj/item/weapon/tank/internals/plasmaman/full
corpsemask = /obj/item/clothing/mask/breath
/////////////////Officers//////////////////////
/obj/effect/landmark/corpse/bridgeofficer
name = "Bridge Officer"
corpseradio = /obj/item/device/radio/headset/heads/hop
corpseuniform = /obj/item/clothing/under/rank/centcom_officer
corpsesuit = /obj/item/clothing/suit/armor/bulletproof
corpseshoes = /obj/item/clothing/shoes/sneakers/black
corpseglasses = /obj/item/clothing/glasses/sunglasses
corpseid = 1
corpseidjob = "Bridge Officer"
corpseidaccess = "Captain"
/obj/effect/landmark/corpse/commander
name = "Commander"
corpseuniform = /obj/item/clothing/under/rank/centcom_commander
corpsesuit = /obj/item/clothing/suit/armor
corpseradio = /obj/item/device/radio/headset/heads/captain
corpseglasses = /obj/item/clothing/glasses/eyepatch
corpsemask = /obj/item/clothing/mask/cigarette/cigar/cohiba
corpsehelmet = /obj/item/clothing/head/centhat
corpsegloves = /obj/item/clothing/gloves/combat
corpseshoes = /obj/item/clothing/shoes/combat/swat
corpsepocket1 = /obj/item/weapon/lighter
corpseid = 1
corpseidjob = "Commander"
corpseidaccess = "Captain"
/obj/effect/landmark/corpse/commander/alive
death = FALSE
roundstart = FALSE
mobname = "Nanotrasen Commander"
name = "sleeper"
icon = 'icons/obj/Cryogenic2.dmi'
icon_state = "sleeper"
flavour_text = "You are a Nanotrasen Commander!"
/obj/effect/landmark/corpse/attack_ghost(mob/user)
if(ticker.current_state != GAME_STATE_PLAYING)
return
var/ghost_role = alert("Become [mobname]? (Warning, You can no longer be cloned!)",,"Yes","No")
if(ghost_role == "No")
return
createCorpse(death = src.death, ckey = user.ckey)
/////////////////Spooky Undead//////////////////////
/obj/effect/landmark/corpse/skeleton
name = "skeletal remains"
mobname = "skeleton"
mob_species = /datum/species/skeleton
mobgender = NEUTER
/obj/effect/landmark/corpse/skeleton/alive
death = FALSE
roundstart = FALSE
icon = 'icons/effects/blood.dmi'
icon_state = "remains"
flavour_text = "By unknown powers, your skeletal remains have been reanimated! Walk this mortal plain and terrorize all living adventurers who dare cross your path."
/obj/effect/landmark/corpse/zombie
name = "rotting corpse"
mobname = "zombie"
mob_species = /datum/species/zombie
/obj/effect/landmark/corpse/zombie/alive
death = FALSE
roundstart = FALSE
icon = 'icons/effects/blood.dmi'
icon_state = "remains"
flavour_text = "By unknown powers, your rotting remains have been resurrected! Walk this mortal plain and terrorize all living adventurers who dare cross your path."
+240 -240
View File
@@ -1,240 +1,240 @@
/*
Asset cache quick users guide:
Make a datum at the bottom of this file with your assets for your thing.
The simple subsystem will most like be of use for most cases.
Then call get_asset_datum() with the type of the datum you created and store the return
Then call .send(client) on that stored return value.
You can set verify to TRUE if you want send() to sleep until the client has the assets.
*/
// Amount of time(ds) MAX to send per asset, if this get exceeded we cancel the sleeping.
// This is doubled for the first asset, then added per asset after
#define ASSET_CACHE_SEND_TIMEOUT 7
//When sending mutiple assets, how many before we give the client a quaint little sending resources message
#define ASSET_CACHE_TELL_CLIENT_AMOUNT 8
/client
var/list/cache = list() // List of all assets sent to this client by the asset cache.
var/list/completed_asset_jobs = list() // List of all completed jobs, awaiting acknowledgement.
var/list/sending = list()
var/last_asset_job = 0 // Last job done.
//This proc sends the asset to the client, but only if it needs it.
//This proc blocks(sleeps) unless verify is set to false
/proc/send_asset(var/client/client, var/asset_name, var/verify = TRUE)
if(!istype(client))
if(ismob(client))
var/mob/M = client
if(M.client)
client = M.client
else
return 0
else
return 0
if(client.cache.Find(asset_name) || client.sending.Find(asset_name))
return 0
client << browse_rsc(SSasset.cache[asset_name], asset_name)
if(!verify || !winexists(client, "asset_cache_browser")) // Can't access the asset cache browser, rip.
if (client)
client.cache += asset_name
return 1
if (!client)
return 0
client.sending |= asset_name
var/job = ++client.last_asset_job
client << browse({"
<script>
window.location.href="?asset_cache_confirm_arrival=[job]"
</script>
"}, "window=asset_cache_browser")
var/t = 0
var/timeout_time = (ASSET_CACHE_SEND_TIMEOUT * client.sending.len) + ASSET_CACHE_SEND_TIMEOUT
while(client && !client.completed_asset_jobs.Find(job) && t < timeout_time) // Reception is handled in Topic()
sleep(1) // Lock up the caller until this is received.
t++
if(client)
client.sending -= asset_name
client.cache |= asset_name
client.completed_asset_jobs -= job
return 1
//This proc blocks(sleeps) unless verify is set to false
/proc/send_asset_list(var/client/client, var/list/asset_list, var/verify = TRUE)
if(!istype(client))
if(ismob(client))
var/mob/M = client
if(M.client)
client = M.client
else
return 0
else
return 0
var/list/unreceived = asset_list - (client.cache + client.sending)
if(!unreceived || !unreceived.len)
return 0
if (unreceived.len >= ASSET_CACHE_TELL_CLIENT_AMOUNT)
client << "Sending Resources..."
for(var/asset in unreceived)
if (asset in SSasset.cache)
client << browse_rsc(SSasset.cache[asset], asset)
if(!verify || !winexists(client, "asset_cache_browser")) // Can't access the asset cache browser, rip.
if (client)
client.cache += unreceived
return 1
if (!client)
return 0
client.sending |= unreceived
var/job = ++client.last_asset_job
client << browse({"
<script>
window.location.href="?asset_cache_confirm_arrival=[job]"
</script>
"}, "window=asset_cache_browser")
var/t = 0
var/timeout_time = ASSET_CACHE_SEND_TIMEOUT * client.sending.len
while(client && !client.completed_asset_jobs.Find(job) && t < timeout_time) // Reception is handled in Topic()
sleep(1) // Lock up the caller until this is received.
t++
if(client)
client.sending -= unreceived
client.cache |= unreceived
client.completed_asset_jobs -= job
return 1
//This proc will download the files without clogging up the browse() queue, used for passively sending files on connection start.
//The proc calls procs that sleep for long times.
/proc/getFilesSlow(var/client/client, var/list/files, var/register_asset = TRUE)
for(var/file in files)
if (!client)
break
if (register_asset)
register_asset(file,files[file])
send_asset(client,file)
sleep(-1) //queuing calls like this too quickly can cause issues in some client versions
//This proc "registers" an asset, it adds it to the cache for further use, you cannot touch it from this point on or you'll fuck things up.
//if it's an icon or something be careful, you'll have to copy it before further use.
/proc/register_asset(var/asset_name, var/asset)
SSasset.cache[asset_name] = asset
//These datums are used to populate the asset cache, the proc "register()" does this.
//all of our asset datums, used for referring to these later
/var/global/list/asset_datums = list()
//get a assetdatum or make a new one
/proc/get_asset_datum(var/type)
if (!(type in asset_datums))
return new type()
return asset_datums[type]
/datum/asset/New()
asset_datums[type] = src
/datum/asset/proc/register()
return
/datum/asset/proc/send(client)
return
//If you don't need anything complicated.
/datum/asset/simple
var/assets = list()
var/verify = FALSE
/datum/asset/simple/register()
for(var/asset_name in assets)
register_asset(asset_name, assets[asset_name])
/datum/asset/simple/send(client)
send_asset_list(client,assets,verify)
//DEFINITIONS FOR ASSET DATUMS START HERE.
/datum/asset/simple/nanoui
assets = list(
"nanoui.lib.js" = 'nano/assets/nanoui.lib.js',
"nanoui.main.js" = 'nano/assets/nanoui.main.js',
"nanoui.templates.js" = 'nano/assets/nanoui.templates.js',
"nanoui.lib.css" = 'nano/assets/nanoui.lib.css',
"nanoui.common.css" = 'nano/assets/nanoui.common.css',
"nanoui.generic.css" = 'nano/assets/nanoui.generic.css',
"nanoui.nanotrasen.css" = 'nano/assets/nanoui.nanotrasen.css',
"fontawesome-webfont.eot" = 'nano/assets/fontawesome-webfont.eot',
"fontawesome-webfont.woff2" = 'nano/assets/fontawesome-webfont.woff2'
)
/datum/asset/simple/pda
assets = list(
"pda_atmos.png" = 'icons/pda_icons/pda_atmos.png',
"pda_back.png" = 'icons/pda_icons/pda_back.png',
"pda_bell.png" = 'icons/pda_icons/pda_bell.png',
"pda_blank.png" = 'icons/pda_icons/pda_blank.png',
"pda_boom.png" = 'icons/pda_icons/pda_boom.png',
"pda_bucket.png" = 'icons/pda_icons/pda_bucket.png',
"pda_medbot.png" = 'icons/pda_icons/pda_medbot.png',
"pda_floorbot.png" = 'icons/pda_icons/pda_floorbot.png',
"pda_cleanbot.png" = 'icons/pda_icons/pda_cleanbot.png',
"pda_crate.png" = 'icons/pda_icons/pda_crate.png',
"pda_cuffs.png" = 'icons/pda_icons/pda_cuffs.png',
"pda_eject.png" = 'icons/pda_icons/pda_eject.png',
"pda_exit.png" = 'icons/pda_icons/pda_exit.png',
"pda_flashlight.png" = 'icons/pda_icons/pda_flashlight.png',
"pda_honk.png" = 'icons/pda_icons/pda_honk.png',
"pda_mail.png" = 'icons/pda_icons/pda_mail.png',
"pda_medical.png" = 'icons/pda_icons/pda_medical.png',
"pda_menu.png" = 'icons/pda_icons/pda_menu.png',
"pda_mule.png" = 'icons/pda_icons/pda_mule.png',
"pda_notes.png" = 'icons/pda_icons/pda_notes.png',
"pda_power.png" = 'icons/pda_icons/pda_power.png',
"pda_rdoor.png" = 'icons/pda_icons/pda_rdoor.png',
"pda_reagent.png" = 'icons/pda_icons/pda_reagent.png',
"pda_refresh.png" = 'icons/pda_icons/pda_refresh.png',
"pda_scanner.png" = 'icons/pda_icons/pda_scanner.png',
"pda_signaler.png" = 'icons/pda_icons/pda_signaler.png',
"pda_status.png" = 'icons/pda_icons/pda_status.png'
)
/datum/asset/simple/paper
assets = list(
"large_stamp-clown.png" = 'icons/stamp_icons/large_stamp-clown.png',
"large_stamp-deny.png" = 'icons/stamp_icons/large_stamp-deny.png',
"large_stamp-ok.png" = 'icons/stamp_icons/large_stamp-ok.png',
"large_stamp-hop.png" = 'icons/stamp_icons/large_stamp-hop.png',
"large_stamp-cmo.png" = 'icons/stamp_icons/large_stamp-cmo.png',
"large_stamp-ce.png" = 'icons/stamp_icons/large_stamp-ce.png',
"large_stamp-hos.png" = 'icons/stamp_icons/large_stamp-hos.png',
"large_stamp-rd.png" = 'icons/stamp_icons/large_stamp-rd.png',
"large_stamp-cap.png" = 'icons/stamp_icons/large_stamp-cap.png',
"large_stamp-qm.png" = 'icons/stamp_icons/large_stamp-qm.png',
"large_stamp-law.png" = 'icons/stamp_icons/large_stamp-law.png'
)
//Registers HTML Interface assets.
/datum/asset/HTML_interface/register()
for(var/path in typesof(/datum/html_interface))
var/datum/html_interface/hi = new path()
hi.registerResources()
/*
Asset cache quick users guide:
Make a datum at the bottom of this file with your assets for your thing.
The simple subsystem will most like be of use for most cases.
Then call get_asset_datum() with the type of the datum you created and store the return
Then call .send(client) on that stored return value.
You can set verify to TRUE if you want send() to sleep until the client has the assets.
*/
// Amount of time(ds) MAX to send per asset, if this get exceeded we cancel the sleeping.
// This is doubled for the first asset, then added per asset after
#define ASSET_CACHE_SEND_TIMEOUT 7
//When sending mutiple assets, how many before we give the client a quaint little sending resources message
#define ASSET_CACHE_TELL_CLIENT_AMOUNT 8
/client
var/list/cache = list() // List of all assets sent to this client by the asset cache.
var/list/completed_asset_jobs = list() // List of all completed jobs, awaiting acknowledgement.
var/list/sending = list()
var/last_asset_job = 0 // Last job done.
//This proc sends the asset to the client, but only if it needs it.
//This proc blocks(sleeps) unless verify is set to false
/proc/send_asset(var/client/client, var/asset_name, var/verify = TRUE)
if(!istype(client))
if(ismob(client))
var/mob/M = client
if(M.client)
client = M.client
else
return 0
else
return 0
if(client.cache.Find(asset_name) || client.sending.Find(asset_name))
return 0
client << browse_rsc(SSasset.cache[asset_name], asset_name)
if(!verify || !winexists(client, "asset_cache_browser")) // Can't access the asset cache browser, rip.
if (client)
client.cache += asset_name
return 1
if (!client)
return 0
client.sending |= asset_name
var/job = ++client.last_asset_job
client << browse({"
<script>
window.location.href="?asset_cache_confirm_arrival=[job]"
</script>
"}, "window=asset_cache_browser")
var/t = 0
var/timeout_time = (ASSET_CACHE_SEND_TIMEOUT * client.sending.len) + ASSET_CACHE_SEND_TIMEOUT
while(client && !client.completed_asset_jobs.Find(job) && t < timeout_time) // Reception is handled in Topic()
sleep(1) // Lock up the caller until this is received.
t++
if(client)
client.sending -= asset_name
client.cache |= asset_name
client.completed_asset_jobs -= job
return 1
//This proc blocks(sleeps) unless verify is set to false
/proc/send_asset_list(var/client/client, var/list/asset_list, var/verify = TRUE)
if(!istype(client))
if(ismob(client))
var/mob/M = client
if(M.client)
client = M.client
else
return 0
else
return 0
var/list/unreceived = asset_list - (client.cache + client.sending)
if(!unreceived || !unreceived.len)
return 0
if (unreceived.len >= ASSET_CACHE_TELL_CLIENT_AMOUNT)
client << "Sending Resources..."
for(var/asset in unreceived)
if (asset in SSasset.cache)
client << browse_rsc(SSasset.cache[asset], asset)
if(!verify || !winexists(client, "asset_cache_browser")) // Can't access the asset cache browser, rip.
if (client)
client.cache += unreceived
return 1
if (!client)
return 0
client.sending |= unreceived
var/job = ++client.last_asset_job
client << browse({"
<script>
window.location.href="?asset_cache_confirm_arrival=[job]"
</script>
"}, "window=asset_cache_browser")
var/t = 0
var/timeout_time = ASSET_CACHE_SEND_TIMEOUT * client.sending.len
while(client && !client.completed_asset_jobs.Find(job) && t < timeout_time) // Reception is handled in Topic()
sleep(1) // Lock up the caller until this is received.
t++
if(client)
client.sending -= unreceived
client.cache |= unreceived
client.completed_asset_jobs -= job
return 1
//This proc will download the files without clogging up the browse() queue, used for passively sending files on connection start.
//The proc calls procs that sleep for long times.
/proc/getFilesSlow(var/client/client, var/list/files, var/register_asset = TRUE)
for(var/file in files)
if (!client)
break
if (register_asset)
register_asset(file,files[file])
send_asset(client,file)
sleep(-1) //queuing calls like this too quickly can cause issues in some client versions
//This proc "registers" an asset, it adds it to the cache for further use, you cannot touch it from this point on or you'll fuck things up.
//if it's an icon or something be careful, you'll have to copy it before further use.
/proc/register_asset(var/asset_name, var/asset)
SSasset.cache[asset_name] = asset
//These datums are used to populate the asset cache, the proc "register()" does this.
//all of our asset datums, used for referring to these later
/var/global/list/asset_datums = list()
//get a assetdatum or make a new one
/proc/get_asset_datum(var/type)
if (!(type in asset_datums))
return new type()
return asset_datums[type]
/datum/asset/New()
asset_datums[type] = src
/datum/asset/proc/register()
return
/datum/asset/proc/send(client)
return
//If you don't need anything complicated.
/datum/asset/simple
var/assets = list()
var/verify = FALSE
/datum/asset/simple/register()
for(var/asset_name in assets)
register_asset(asset_name, assets[asset_name])
/datum/asset/simple/send(client)
send_asset_list(client,assets,verify)
//DEFINITIONS FOR ASSET DATUMS START HERE.
/datum/asset/simple/nanoui
assets = list(
"nanoui.lib.js" = 'nano/assets/nanoui.lib.js',
"nanoui.main.js" = 'nano/assets/nanoui.main.js',
"nanoui.templates.js" = 'nano/assets/nanoui.templates.js',
"nanoui.lib.css" = 'nano/assets/nanoui.lib.css',
"nanoui.common.css" = 'nano/assets/nanoui.common.css',
"nanoui.generic.css" = 'nano/assets/nanoui.generic.css',
"nanoui.nanotrasen.css" = 'nano/assets/nanoui.nanotrasen.css',
"fontawesome-webfont.eot" = 'nano/assets/fontawesome-webfont.eot',
"fontawesome-webfont.woff2" = 'nano/assets/fontawesome-webfont.woff2'
)
/datum/asset/simple/pda
assets = list(
"pda_atmos.png" = 'icons/pda_icons/pda_atmos.png',
"pda_back.png" = 'icons/pda_icons/pda_back.png',
"pda_bell.png" = 'icons/pda_icons/pda_bell.png',
"pda_blank.png" = 'icons/pda_icons/pda_blank.png',
"pda_boom.png" = 'icons/pda_icons/pda_boom.png',
"pda_bucket.png" = 'icons/pda_icons/pda_bucket.png',
"pda_medbot.png" = 'icons/pda_icons/pda_medbot.png',
"pda_floorbot.png" = 'icons/pda_icons/pda_floorbot.png',
"pda_cleanbot.png" = 'icons/pda_icons/pda_cleanbot.png',
"pda_crate.png" = 'icons/pda_icons/pda_crate.png',
"pda_cuffs.png" = 'icons/pda_icons/pda_cuffs.png',
"pda_eject.png" = 'icons/pda_icons/pda_eject.png',
"pda_exit.png" = 'icons/pda_icons/pda_exit.png',
"pda_flashlight.png" = 'icons/pda_icons/pda_flashlight.png',
"pda_honk.png" = 'icons/pda_icons/pda_honk.png',
"pda_mail.png" = 'icons/pda_icons/pda_mail.png',
"pda_medical.png" = 'icons/pda_icons/pda_medical.png',
"pda_menu.png" = 'icons/pda_icons/pda_menu.png',
"pda_mule.png" = 'icons/pda_icons/pda_mule.png',
"pda_notes.png" = 'icons/pda_icons/pda_notes.png',
"pda_power.png" = 'icons/pda_icons/pda_power.png',
"pda_rdoor.png" = 'icons/pda_icons/pda_rdoor.png',
"pda_reagent.png" = 'icons/pda_icons/pda_reagent.png',
"pda_refresh.png" = 'icons/pda_icons/pda_refresh.png',
"pda_scanner.png" = 'icons/pda_icons/pda_scanner.png',
"pda_signaler.png" = 'icons/pda_icons/pda_signaler.png',
"pda_status.png" = 'icons/pda_icons/pda_status.png'
)
/datum/asset/simple/paper
assets = list(
"large_stamp-clown.png" = 'icons/stamp_icons/large_stamp-clown.png',
"large_stamp-deny.png" = 'icons/stamp_icons/large_stamp-deny.png',
"large_stamp-ok.png" = 'icons/stamp_icons/large_stamp-ok.png',
"large_stamp-hop.png" = 'icons/stamp_icons/large_stamp-hop.png',
"large_stamp-cmo.png" = 'icons/stamp_icons/large_stamp-cmo.png',
"large_stamp-ce.png" = 'icons/stamp_icons/large_stamp-ce.png',
"large_stamp-hos.png" = 'icons/stamp_icons/large_stamp-hos.png',
"large_stamp-rd.png" = 'icons/stamp_icons/large_stamp-rd.png',
"large_stamp-cap.png" = 'icons/stamp_icons/large_stamp-cap.png',
"large_stamp-qm.png" = 'icons/stamp_icons/large_stamp-qm.png',
"large_stamp-law.png" = 'icons/stamp_icons/large_stamp-law.png'
)
//Registers HTML Interface assets.
/datum/asset/HTML_interface/register()
for(var/path in typesof(/datum/html_interface))
var/datum/html_interface/hi = new path()
hi.registerResources()
+339 -339
View File
@@ -1,339 +1,339 @@
////////////
//SECURITY//
////////////
#define UPLOAD_LIMIT 1048576 //Restricts client uploads to the server to 1MB //Could probably do with being lower.
#define MIN_CLIENT_VERSION 0 //Just an ambiguously low version for now, I don't want to suddenly stop people playing.
//I would just like the code ready should it ever need to be used.
/*
When somebody clicks a link in game, this Topic is called first.
It does the stuff in this proc and then is redirected to the Topic() proc for the src=[0xWhatever]
(if specified in the link). ie locate(hsrc).Topic()
Such links can be spoofed.
Because of this certain things MUST be considered whenever adding a Topic() for something:
- Can it be fed harmful values which could cause runtimes?
- Is the Topic call an admin-only thing?
- If so, does it have checks to see if the person who called it (usr.client) is an admin?
- Are the processes being called by Topic() particularly laggy?
- If so, is there any protection against somebody spam-clicking a link?
If you have any questions about this stuff feel free to ask. ~Carn
*/
/client/Topic(href, href_list, hsrc)
if(!usr || usr != mob) //stops us calling Topic for somebody else's client. Also helps prevent usr=null
return
// NanoUI
if(href_list["nano_error"])
src << href_list["nano_error"]
throw EXCEPTION("NanoUI: [href_list["nano_error"]]")
if(href_list["nano_log"])
src << href_list["nano_log"]
return
// asset_cache
if(href_list["asset_cache_confirm_arrival"])
//src << "ASSET JOB [href_list["asset_cache_confirm_arrival"]] ARRIVED."
var/job = text2num(href_list["asset_cache_confirm_arrival"])
completed_asset_jobs += job
return
//Admin PM
if(href_list["priv_msg"])
if (href_list["ahelp_reply"])
cmd_ahelp_reply(href_list["priv_msg"])
return
cmd_admin_pm(href_list["priv_msg"],null)
return
//Logs all hrefs
if(config && config.log_hrefs && href_logfile)
href_logfile << "<small>[time2text(world.timeofday,"hh:mm")] [src] (usr:[usr])</small> || [hsrc ? "[hsrc] " : ""][href]<br>"
switch(href_list["_src_"])
if("holder") hsrc = holder
if("usr") hsrc = mob
if("prefs") return prefs.process_link(usr,href_list)
if("vars") return view_var_Topic(href,href_list,hsrc)
..() //redirect to hsrc.Topic()
/client/proc/is_content_unlocked()
if(!prefs.unlock_content)
src << "Become a BYOND member to access member-perks and features, as well as support the engine that makes this game possible. Only 10 bucks for 3 months! <a href='http://www.byond.com/membership'>Click Here to find out more</a>."
return 0
return 1
/client/proc/handle_spam_prevention(message, mute_type)
if(config.automute_on && !holder && src.last_message == message)
src.last_message_count++
if(src.last_message_count >= SPAM_TRIGGER_AUTOMUTE)
src << "<span class='danger'>You have exceeded the spam filter limit for identical messages. An auto-mute was applied.</span>"
cmd_admin_mute(src, mute_type, 1)
return 1
if(src.last_message_count >= SPAM_TRIGGER_WARNING)
src << "<span class='danger'>You are nearing the spam filter limit for identical messages.</span>"
return 0
else
last_message = message
src.last_message_count = 0
return 0
//This stops files larger than UPLOAD_LIMIT being sent from client to server via input(), client.Import() etc.
/client/AllowUpload(filename, filelength)
if(filelength > UPLOAD_LIMIT)
src << "<font color='red'>Error: AllowUpload(): File Upload too large. Upload Limit: [UPLOAD_LIMIT/1024]KiB.</font>"
return 0
/* //Don't need this at the moment. But it's here if it's needed later.
//Helps prevent multiple files being uploaded at once. Or right after eachother.
var/time_to_wait = fileaccess_timer - world.time
if(time_to_wait > 0)
src << "<font color='red'>Error: AllowUpload(): Spam prevention. Please wait [round(time_to_wait/10)] seconds.</font>"
return 0
fileaccess_timer = world.time + FTPDELAY */
return 1
///////////
//CONNECT//
///////////
#if (PRELOAD_RSC == 0)
var/list/external_rsc_urls
var/next_external_rsc = 0
#endif
/client/New(TopicData)
TopicData = null //Prevent calls to client.Topic from connect
if(connection != "seeker" && connection != "web")//Invalid connection type.
return null
if(byond_version < MIN_CLIENT_VERSION) //Out of date client.
return null
#if (PRELOAD_RSC == 0)
if(external_rsc_urls && external_rsc_urls.len)
next_external_rsc = Wrap(next_external_rsc+1, 1, external_rsc_urls.len+1)
preload_rsc = external_rsc_urls[next_external_rsc]
#endif
clients += src
directory[ckey] = src
//Admin Authorisation
if(protected_config.autoadmin)
if(!admin_datums[ckey])
var/datum/admin_rank/autorank
for(var/datum/admin_rank/R in admin_ranks)
if(R.name == protected_config.autoadmin_rank)
autorank = R
break
if(!autorank)
world << "Autoadmin rank not found"
else
var/datum/admins/D = new(autorank, ckey)
admin_datums[ckey] = D
holder = admin_datums[ckey]
if(holder)
admins += src
holder.owner = src
//preferences datum - also holds some persistant data for the client (because we may as well keep these datums to a minimum)
prefs = preferences_datums[ckey]
if(!prefs)
prefs = new /datum/preferences(src)
preferences_datums[ckey] = prefs
prefs.last_ip = address //these are gonna be used for banning
prefs.last_id = computer_id //these are gonna be used for banning
. = ..() //calls mob.Login()
if (connection == "web")
if (!config.allowwebclient)
src << "Web client is disabled"
del(src)
return 0
if (config.webclientmembersonly && !IsByondMember())
src << "Sorry, but the web client is restricted to byond members only."
del(src)
return 0
if( (world.address == address || !address) && !host )
host = key
world.update_status()
if(holder)
add_admin_verbs()
admin_memo_output("Show")
adminGreet()
if((global.comms_key == "default_pwd" || length(global.comms_key) <= 6) && global.comms_allowed) //It's the default value or less than 6 characters long, but it somehow didn't disable comms.
src << "<span class='danger'>The server's API key is either too short or is the default value! Consider changing it immediately!</span>"
add_verbs_from_config()
set_client_age_from_db()
if (isnum(player_age) && player_age == -1) //first connection
if (config.panic_bunker && !holder && !(ckey in deadmins))
log_access("Failed Login: [key] - New account attempting to connect during panic bunker")
message_admins("<span class='adminnotice'>Failed Login: [key] - New account attempting to connect during panic bunker</span>")
src << "Sorry but the server is currently not accepting connections from never before seen players."
del(src)
return 0
if (config.notify_new_player_age >= 0)
message_admins("New user: [key_name_admin(src)] is connecting here for the first time.")
if (config.irc_first_connection_alert)
send2irc_adminless_only("New-user", "[key_name(src)] is connecting for the first time!")
player_age = 0 // set it from -1 to 0 so the job selection code doesn't have a panic attack
else if (isnum(player_age) && player_age < config.notify_new_player_age)
message_admins("New user: [key_name_admin(src)] just connected with an age of [player_age] day[(player_age==1?"":"s")]")
sync_client_with_db()
send_resources()
if(!void)
void = new()
screen += void
if(prefs.lastchangelog != changelog_hash) //bolds the changelog button on the interface so we know there are updates.
src << "<span class='info'>You have unread updates in the changelog.</span>"
if(config.aggressive_changelog)
src.changes()
else
winset(src, "rpane.changelogb", "background-color=#eaeaea;font-style=bold")
if (ckey in clientmessages)
for (var/message in clientmessages[ckey])
src << message
clientmessages.Remove(ckey)
if (config && config.autoconvert_notes)
convert_notes_sql(ckey)
if(!winexists(src, "asset_cache_browser")) // The client is using a custom skin, tell them.
src << "<span class='warning'>Unable to access asset cache browser, if you are using a custom skin file, please allow DS to download the updated version, if you are not, then make a bug report. This is not a critical issue but can cause issues with resource downloading, as it is impossible to know when extra resources arrived to you.</span>"
//This is down here because of the browse() calls in tooltip/New()
if(!tooltips)
tooltips = new /datum/tooltip(src)
//////////////
//DISCONNECT//
//////////////
/client/Del()
if(holder)
adminGreet(1)
holder.owner = null
admins -= src
directory -= ckey
clients -= src
return ..()
/client/proc/set_client_age_from_db()
if (IsGuestKey(src.key))
return
establish_db_connection()
if(!dbcon.IsConnected())
return
var/sql_ckey = sanitizeSQL(src.ckey)
var/DBQuery/query = dbcon.NewQuery("SELECT id, datediff(Now(),firstseen) as age FROM [format_table_name("player")] WHERE ckey = '[sql_ckey]'")
if (!query.Execute())
return
while (query.NextRow())
player_age = text2num(query.item[2])
return
//no match mark it as a first connection for use in client/New()
player_age = -1
/client/proc/sync_client_with_db()
if (IsGuestKey(src.key))
return
establish_db_connection()
if (!dbcon.IsConnected())
return
var/sql_ckey = sanitizeSQL(src.ckey)
var/DBQuery/query_ip = dbcon.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE ip = '[address]' AND ckey != '[sql_ckey]'")
query_ip.Execute()
related_accounts_ip = ""
while(query_ip.NextRow())
related_accounts_ip += "[query_ip.item[1]], "
var/DBQuery/query_cid = dbcon.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE computerid = '[computer_id]' AND ckey != '[sql_ckey]'")
query_cid.Execute()
related_accounts_cid = ""
while (query_cid.NextRow())
related_accounts_cid += "[query_cid.item[1]], "
var/watchreason = check_watchlist(sql_ckey)
if(watchreason)
message_admins("<font color='red'><B>Notice: </B></font><font color='blue'>[key_name_admin(src)] is on the watchlist and has just connected - Reason: [watchreason]</font>")
send2irc_adminless_only("Watchlist", "[key_name(src)] is on the watchlist and has just connected - Reason: [watchreason]")
var/admin_rank = "Player"
if (src.holder && src.holder.rank)
admin_rank = src.holder.rank.name
var/sql_ip = sanitizeSQL(src.address)
var/sql_computerid = sanitizeSQL(src.computer_id)
var/sql_admin_rank = sanitizeSQL(admin_rank)
var/DBQuery/query_insert = dbcon.NewQuery("INSERT INTO [format_table_name("player")] (id, ckey, firstseen, lastseen, ip, computerid, lastadminrank) VALUES (null, '[sql_ckey]', Now(), Now(), '[sql_ip]', '[sql_computerid]', '[sql_admin_rank]') ON DUPLICATE KEY UPDATE lastseen = VALUES(lastseen), ip = VALUES(ip), computerid = VALUES(computerid), lastadminrank = VALUES(lastadminrank)")
query_insert.Execute()
//Logging player access
var/serverip = "[world.internet_address]:[world.port]"
var/DBQuery/query_accesslog = dbcon.NewQuery("INSERT INTO `[format_table_name("connection_log")]` (`id`,`datetime`,`serverip`,`ckey`,`ip`,`computerid`) VALUES(null,Now(),'[serverip]','[sql_ckey]','[sql_ip]','[sql_computerid]');")
query_accesslog.Execute()
/client/proc/add_verbs_from_config()
if(config.see_own_notes)
verbs += /client/proc/self_notes
#undef TOPIC_SPAM_DELAY
#undef UPLOAD_LIMIT
#undef MIN_CLIENT_VERSION
//checks if a client is afk
//3000 frames = 5 minutes
/client/proc/is_afk(duration=3000)
if(inactivity > duration) return inactivity
return 0
// Byond seemingly calls stat, each tick.
// Calling things each tick can get expensive real quick.
// So we slow this down a little.
// See: http://www.byond.com/docs/ref/info.html#/client/proc/Stat
/client/Stat()
. = ..()
sleep(1)
//send resources to the client. It's here in its own proc so we can move it around easiliy if need be
/client/proc/send_resources()
//get the common files
getFiles(
'html/search.js',
'html/panels.css',
'html/browser/common.css',
'html/browser/scannernew.css',
'html/browser/playeroptions.css',
)
spawn (10)
//Precache the client with all other assets slowly, so as to not block other browse() calls
getFilesSlow(src, SSasset.cache, register_asset = FALSE)
////////////
//SECURITY//
////////////
#define UPLOAD_LIMIT 1048576 //Restricts client uploads to the server to 1MB //Could probably do with being lower.
#define MIN_CLIENT_VERSION 0 //Just an ambiguously low version for now, I don't want to suddenly stop people playing.
//I would just like the code ready should it ever need to be used.
/*
When somebody clicks a link in game, this Topic is called first.
It does the stuff in this proc and then is redirected to the Topic() proc for the src=[0xWhatever]
(if specified in the link). ie locate(hsrc).Topic()
Such links can be spoofed.
Because of this certain things MUST be considered whenever adding a Topic() for something:
- Can it be fed harmful values which could cause runtimes?
- Is the Topic call an admin-only thing?
- If so, does it have checks to see if the person who called it (usr.client) is an admin?
- Are the processes being called by Topic() particularly laggy?
- If so, is there any protection against somebody spam-clicking a link?
If you have any questions about this stuff feel free to ask. ~Carn
*/
/client/Topic(href, href_list, hsrc)
if(!usr || usr != mob) //stops us calling Topic for somebody else's client. Also helps prevent usr=null
return
// NanoUI
if(href_list["nano_error"])
src << href_list["nano_error"]
throw EXCEPTION("NanoUI: [href_list["nano_error"]]")
if(href_list["nano_log"])
src << href_list["nano_log"]
return
// asset_cache
if(href_list["asset_cache_confirm_arrival"])
//src << "ASSET JOB [href_list["asset_cache_confirm_arrival"]] ARRIVED."
var/job = text2num(href_list["asset_cache_confirm_arrival"])
completed_asset_jobs += job
return
//Admin PM
if(href_list["priv_msg"])
if (href_list["ahelp_reply"])
cmd_ahelp_reply(href_list["priv_msg"])
return
cmd_admin_pm(href_list["priv_msg"],null)
return
//Logs all hrefs
if(config && config.log_hrefs && href_logfile)
href_logfile << "<small>[time2text(world.timeofday,"hh:mm")] [src] (usr:[usr])</small> || [hsrc ? "[hsrc] " : ""][href]<br>"
switch(href_list["_src_"])
if("holder") hsrc = holder
if("usr") hsrc = mob
if("prefs") return prefs.process_link(usr,href_list)
if("vars") return view_var_Topic(href,href_list,hsrc)
..() //redirect to hsrc.Topic()
/client/proc/is_content_unlocked()
if(!prefs.unlock_content)
src << "Become a BYOND member to access member-perks and features, as well as support the engine that makes this game possible. Only 10 bucks for 3 months! <a href='http://www.byond.com/membership'>Click Here to find out more</a>."
return 0
return 1
/client/proc/handle_spam_prevention(message, mute_type)
if(config.automute_on && !holder && src.last_message == message)
src.last_message_count++
if(src.last_message_count >= SPAM_TRIGGER_AUTOMUTE)
src << "<span class='danger'>You have exceeded the spam filter limit for identical messages. An auto-mute was applied.</span>"
cmd_admin_mute(src, mute_type, 1)
return 1
if(src.last_message_count >= SPAM_TRIGGER_WARNING)
src << "<span class='danger'>You are nearing the spam filter limit for identical messages.</span>"
return 0
else
last_message = message
src.last_message_count = 0
return 0
//This stops files larger than UPLOAD_LIMIT being sent from client to server via input(), client.Import() etc.
/client/AllowUpload(filename, filelength)
if(filelength > UPLOAD_LIMIT)
src << "<font color='red'>Error: AllowUpload(): File Upload too large. Upload Limit: [UPLOAD_LIMIT/1024]KiB.</font>"
return 0
/* //Don't need this at the moment. But it's here if it's needed later.
//Helps prevent multiple files being uploaded at once. Or right after eachother.
var/time_to_wait = fileaccess_timer - world.time
if(time_to_wait > 0)
src << "<font color='red'>Error: AllowUpload(): Spam prevention. Please wait [round(time_to_wait/10)] seconds.</font>"
return 0
fileaccess_timer = world.time + FTPDELAY */
return 1
///////////
//CONNECT//
///////////
#if (PRELOAD_RSC == 0)
var/list/external_rsc_urls
var/next_external_rsc = 0
#endif
/client/New(TopicData)
TopicData = null //Prevent calls to client.Topic from connect
if(connection != "seeker" && connection != "web")//Invalid connection type.
return null
if(byond_version < MIN_CLIENT_VERSION) //Out of date client.
return null
#if (PRELOAD_RSC == 0)
if(external_rsc_urls && external_rsc_urls.len)
next_external_rsc = Wrap(next_external_rsc+1, 1, external_rsc_urls.len+1)
preload_rsc = external_rsc_urls[next_external_rsc]
#endif
clients += src
directory[ckey] = src
//Admin Authorisation
if(protected_config.autoadmin)
if(!admin_datums[ckey])
var/datum/admin_rank/autorank
for(var/datum/admin_rank/R in admin_ranks)
if(R.name == protected_config.autoadmin_rank)
autorank = R
break
if(!autorank)
world << "Autoadmin rank not found"
else
var/datum/admins/D = new(autorank, ckey)
admin_datums[ckey] = D
holder = admin_datums[ckey]
if(holder)
admins += src
holder.owner = src
//preferences datum - also holds some persistant data for the client (because we may as well keep these datums to a minimum)
prefs = preferences_datums[ckey]
if(!prefs)
prefs = new /datum/preferences(src)
preferences_datums[ckey] = prefs
prefs.last_ip = address //these are gonna be used for banning
prefs.last_id = computer_id //these are gonna be used for banning
. = ..() //calls mob.Login()
if (connection == "web")
if (!config.allowwebclient)
src << "Web client is disabled"
del(src)
return 0
if (config.webclientmembersonly && !IsByondMember())
src << "Sorry, but the web client is restricted to byond members only."
del(src)
return 0
if( (world.address == address || !address) && !host )
host = key
world.update_status()
if(holder)
add_admin_verbs()
admin_memo_output("Show")
adminGreet()
if((global.comms_key == "default_pwd" || length(global.comms_key) <= 6) && global.comms_allowed) //It's the default value or less than 6 characters long, but it somehow didn't disable comms.
src << "<span class='danger'>The server's API key is either too short or is the default value! Consider changing it immediately!</span>"
add_verbs_from_config()
set_client_age_from_db()
if (isnum(player_age) && player_age == -1) //first connection
if (config.panic_bunker && !holder && !(ckey in deadmins))
log_access("Failed Login: [key] - New account attempting to connect during panic bunker")
message_admins("<span class='adminnotice'>Failed Login: [key] - New account attempting to connect during panic bunker</span>")
src << "Sorry but the server is currently not accepting connections from never before seen players."
del(src)
return 0
if (config.notify_new_player_age >= 0)
message_admins("New user: [key_name_admin(src)] is connecting here for the first time.")
if (config.irc_first_connection_alert)
send2irc_adminless_only("New-user", "[key_name(src)] is connecting for the first time!")
player_age = 0 // set it from -1 to 0 so the job selection code doesn't have a panic attack
else if (isnum(player_age) && player_age < config.notify_new_player_age)
message_admins("New user: [key_name_admin(src)] just connected with an age of [player_age] day[(player_age==1?"":"s")]")
sync_client_with_db()
send_resources()
if(!void)
void = new()
screen += void
if(prefs.lastchangelog != changelog_hash) //bolds the changelog button on the interface so we know there are updates.
src << "<span class='info'>You have unread updates in the changelog.</span>"
if(config.aggressive_changelog)
src.changes()
else
winset(src, "rpane.changelogb", "background-color=#eaeaea;font-style=bold")
if (ckey in clientmessages)
for (var/message in clientmessages[ckey])
src << message
clientmessages.Remove(ckey)
if (config && config.autoconvert_notes)
convert_notes_sql(ckey)
if(!winexists(src, "asset_cache_browser")) // The client is using a custom skin, tell them.
src << "<span class='warning'>Unable to access asset cache browser, if you are using a custom skin file, please allow DS to download the updated version, if you are not, then make a bug report. This is not a critical issue but can cause issues with resource downloading, as it is impossible to know when extra resources arrived to you.</span>"
//This is down here because of the browse() calls in tooltip/New()
if(!tooltips)
tooltips = new /datum/tooltip(src)
//////////////
//DISCONNECT//
//////////////
/client/Del()
if(holder)
adminGreet(1)
holder.owner = null
admins -= src
directory -= ckey
clients -= src
return ..()
/client/proc/set_client_age_from_db()
if (IsGuestKey(src.key))
return
establish_db_connection()
if(!dbcon.IsConnected())
return
var/sql_ckey = sanitizeSQL(src.ckey)
var/DBQuery/query = dbcon.NewQuery("SELECT id, datediff(Now(),firstseen) as age FROM [format_table_name("player")] WHERE ckey = '[sql_ckey]'")
if (!query.Execute())
return
while (query.NextRow())
player_age = text2num(query.item[2])
return
//no match mark it as a first connection for use in client/New()
player_age = -1
/client/proc/sync_client_with_db()
if (IsGuestKey(src.key))
return
establish_db_connection()
if (!dbcon.IsConnected())
return
var/sql_ckey = sanitizeSQL(src.ckey)
var/DBQuery/query_ip = dbcon.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE ip = '[address]' AND ckey != '[sql_ckey]'")
query_ip.Execute()
related_accounts_ip = ""
while(query_ip.NextRow())
related_accounts_ip += "[query_ip.item[1]], "
var/DBQuery/query_cid = dbcon.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE computerid = '[computer_id]' AND ckey != '[sql_ckey]'")
query_cid.Execute()
related_accounts_cid = ""
while (query_cid.NextRow())
related_accounts_cid += "[query_cid.item[1]], "
var/watchreason = check_watchlist(sql_ckey)
if(watchreason)
message_admins("<font color='red'><B>Notice: </B></font><font color='blue'>[key_name_admin(src)] is on the watchlist and has just connected - Reason: [watchreason]</font>")
send2irc_adminless_only("Watchlist", "[key_name(src)] is on the watchlist and has just connected - Reason: [watchreason]")
var/admin_rank = "Player"
if (src.holder && src.holder.rank)
admin_rank = src.holder.rank.name
var/sql_ip = sanitizeSQL(src.address)
var/sql_computerid = sanitizeSQL(src.computer_id)
var/sql_admin_rank = sanitizeSQL(admin_rank)
var/DBQuery/query_insert = dbcon.NewQuery("INSERT INTO [format_table_name("player")] (id, ckey, firstseen, lastseen, ip, computerid, lastadminrank) VALUES (null, '[sql_ckey]', Now(), Now(), '[sql_ip]', '[sql_computerid]', '[sql_admin_rank]') ON DUPLICATE KEY UPDATE lastseen = VALUES(lastseen), ip = VALUES(ip), computerid = VALUES(computerid), lastadminrank = VALUES(lastadminrank)")
query_insert.Execute()
//Logging player access
var/serverip = "[world.internet_address]:[world.port]"
var/DBQuery/query_accesslog = dbcon.NewQuery("INSERT INTO `[format_table_name("connection_log")]` (`id`,`datetime`,`serverip`,`ckey`,`ip`,`computerid`) VALUES(null,Now(),'[serverip]','[sql_ckey]','[sql_ip]','[sql_computerid]');")
query_accesslog.Execute()
/client/proc/add_verbs_from_config()
if(config.see_own_notes)
verbs += /client/proc/self_notes
#undef TOPIC_SPAM_DELAY
#undef UPLOAD_LIMIT
#undef MIN_CLIENT_VERSION
//checks if a client is afk
//3000 frames = 5 minutes
/client/proc/is_afk(duration=3000)
if(inactivity > duration) return inactivity
return 0
// Byond seemingly calls stat, each tick.
// Calling things each tick can get expensive real quick.
// So we slow this down a little.
// See: http://www.byond.com/docs/ref/info.html#/client/proc/Stat
/client/Stat()
. = ..()
sleep(1)
//send resources to the client. It's here in its own proc so we can move it around easiliy if need be
/client/proc/send_resources()
//get the common files
getFiles(
'html/search.js',
'html/panels.css',
'html/browser/common.css',
'html/browser/scannernew.css',
'html/browser/playeroptions.css',
)
spawn (10)
//Precache the client with all other assets slowly, so as to not block other browse() calls
getFilesSlow(src, SSasset.cache, register_asset = FALSE)
File diff suppressed because it is too large Load Diff
+426 -426
View File
@@ -1,426 +1,426 @@
//This is the lowest supported version, anything below this is completely obsolete and the entire savefile will be wiped.
#define SAVEFILE_VERSION_MIN 8
//This is the current version, anything below this will attempt to update (if it's not obsolete)
#define SAVEFILE_VERSION_MAX 12
/*
SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn
This proc checks if the current directory of the savefile S needs updating
It is to be used by the load_character and load_preferences procs.
(S.cd=="/" is preferences, S.cd=="/character[integer]" is a character slot, etc)
if the current directory's version is below SAVEFILE_VERSION_MIN it will simply wipe everything in that directory
(if we're at root "/" then it'll just wipe the entire savefile, for instance.)
if its version is below SAVEFILE_VERSION_MAX but above the minimum, it will load data but later call the
respective update_preferences() or update_character() proc.
Those procs allow coders to specify format changes so users do not lose their setups and have to redo them again.
Failing all that, the standard sanity checks are performed. They simply check the data is suitable, reverting to
initial() values if necessary.
*/
/datum/preferences/proc/savefile_needs_update(savefile/S)
var/savefile_version
S["version"] >> savefile_version
if(savefile_version < SAVEFILE_VERSION_MIN)
S.dir.Cut()
return -2
if(savefile_version < SAVEFILE_VERSION_MAX)
return savefile_version
return -1
/datum/preferences/proc/update_antagchoices(current_version)
if((!islist(be_special) || old_be_special ) && current_version < 12)
//Archived values of when antag pref defines were a bitfield+fitflags
var/B_traitor = 1
var/B_operative = 2
var/B_changeling = 4
var/B_wizard = 8
var/B_malf = 16
var/B_rev = 32
var/B_alien = 64
var/B_pai = 128
var/B_cultist = 256
var/B_blob = 512
var/B_ninja = 1024
var/B_monkey = 2048
var/B_gang = 4096
var/B_shadowling = 8192
var/B_abductor = 16384
var/B_revenant = 32768
var/list/archived = list(B_traitor,B_operative,B_changeling,B_wizard,B_malf,B_rev,B_alien,B_pai,B_cultist,B_blob,B_ninja,B_monkey,B_gang,B_shadowling,B_abductor,B_revenant)
be_special = list()
for(var/flag in archived)
if(old_be_special & flag)
//this is shitty, but this proc should only be run once per player and then never again for the rest of eternity,
switch(flag)
if(1) //why aren't these the variables above? Good question, it's because byond complains the expression isn't constant, when it is.
be_special += ROLE_TRAITOR
if(2)
be_special += ROLE_OPERATIVE
if(4)
be_special += ROLE_CHANGELING
if(8)
be_special += ROLE_WIZARD
if(16)
be_special += ROLE_MALF
if(32)
be_special += ROLE_REV
if(64)
be_special += ROLE_ALIEN
if(128)
be_special += ROLE_PAI
if(256)
be_special += ROLE_CULTIST
if(512)
be_special += ROLE_BLOB
if(1024)
be_special += ROLE_NINJA
if(2048)
be_special += ROLE_MONKEY
if(4096)
be_special += ROLE_GANG
if(8192)
be_special += ROLE_SHADOWLING
if(16384)
be_special += ROLE_ABDUCTOR
if(32768)
be_special += ROLE_REVENANT
/datum/preferences/proc/update_preferences(current_version)
if(current_version < 10)
toggles |= MEMBER_PUBLIC
if(current_version < 11)
chat_toggles = TOGGLES_DEFAULT_CHAT
toggles = TOGGLES_DEFAULT
if(current_version < 12)
ignoring = list()
//should this proc get fairly long (say 3 versions long),
//just increase SAVEFILE_VERSION_MIN so it's not as far behind
//SAVEFILE_VERSION_MAX and then delete any obsolete if clauses
//from this proc.
//It's only really meant to avoid annoying frequent players
//if your savefile is 3 months out of date, then 'tough shit'.
/datum/preferences/proc/update_character(current_version)
if(current_version < 9) //an example, underwear were an index for a hardcoded list, converting to a string
if(gender == MALE)
switch(underwear)
if(1) underwear = "Mens White"
if(2) underwear = "Mens Grey"
if(3) underwear = "Mens Green"
if(4) underwear = "Mens Blue"
if(5) underwear = "Mens Black"
if(6) underwear = "Mankini"
if(7) underwear = "Mens Hearts Boxer"
if(8) underwear = "Mens Black Boxer"
if(9) underwear = "Mens Grey Boxer"
if(10) underwear = "Mens Striped Boxer"
if(11) underwear = "Mens Kinky"
if(12) underwear = "Mens Red"
if(13) underwear = "Nude"
else
switch(underwear)
if(1) underwear = "Ladies Red"
if(2) underwear = "Ladies White"
if(3) underwear = "Ladies Yellow"
if(4) underwear = "Ladies Blue"
if(5) underwear = "Ladies Black"
if(6) underwear = "Ladies Thong"
if(7) underwear = "Babydoll"
if(8) underwear = "Ladies Baby-Blue"
if(9) underwear = "Ladies Green"
if(10) underwear = "Ladies Pink"
if(11) underwear = "Ladies Kinky"
if(12) underwear = "Tankini"
if(13) underwear = "Nude"
if(!(pref_species in species_list))
pref_species = new /datum/species/human()
return
/datum/preferences/proc/load_path(ckey,filename="preferences.sav")
if(!ckey) return
path = "data/player_saves/[copytext(ckey,1,2)]/[ckey]/[filename]"
/datum/preferences/proc/load_preferences()
if(!path) return 0
if(!fexists(path)) return 0
var/savefile/S = new /savefile(path)
if(!S) return 0
S.cd = "/"
var/needs_update = savefile_needs_update(S)
if(needs_update == -2) //fatal, can't load any data
return 0
//general preferences
S["ooccolor"] >> ooccolor
S["lastchangelog"] >> lastchangelog
S["UI_style"] >> UI_style
S["nanoui_fancy"] >> nanoui_fancy
S["be_special"] >> be_special
if(islist(S["be_special"]))
S["be_special"] >> be_special
else //force update and store the old bitflag version of be_special
needs_update = 11
S["be_special"] >> old_be_special
S["default_slot"] >> default_slot
S["chat_toggles"] >> chat_toggles
S["toggles"] >> toggles
S["ghost_form"] >> ghost_form
S["preferred_map"] >> preferred_map
S["ignoring"] >> ignoring
//try to fix any outdated data if necessary
if(needs_update >= 0)
update_preferences(needs_update) //needs_update = savefile_version if we need an update (positive integer)
update_antagchoices(needs_update)
//Sanitize
ooccolor = sanitize_ooccolor(sanitize_hexcolor(ooccolor, 6, 1, initial(ooccolor)))
lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog))
UI_style = sanitize_inlist(UI_style, list("Midnight", "Plasmafire", "Retro"), initial(UI_style))
nanoui_fancy = sanitize_integer(nanoui_fancy, 0, 1, initial(nanoui_fancy))
default_slot = sanitize_integer(default_slot, 1, max_save_slots, initial(default_slot))
toggles = sanitize_integer(toggles, 0, 65535, initial(toggles))
ghost_form = sanitize_inlist(ghost_form, ghost_forms, initial(ghost_form))
return 1
/datum/preferences/proc/save_preferences()
if(!path) return 0
var/savefile/S = new /savefile(path)
if(!S) return 0
S.cd = "/"
S["version"] << SAVEFILE_VERSION_MAX //updates (or failing that the sanity checks) will ensure data is not invalid at load. Assume up-to-date
//general preferences
S["ooccolor"] << ooccolor
S["lastchangelog"] << lastchangelog
S["UI_style"] << UI_style
S["nanoui_fancy"] << nanoui_fancy
S["be_special"] << be_special
S["default_slot"] << default_slot
S["toggles"] << toggles
S["chat_toggles"] << chat_toggles
S["ghost_form"] << ghost_form
S["preferred_map"] << preferred_map
S["ignoring"] << ignoring
return 1
/datum/preferences/proc/load_character(slot)
if(!path) return 0
if(!fexists(path)) return 0
var/savefile/S = new /savefile(path)
if(!S) return 0
S.cd = "/"
if(!slot) slot = default_slot
slot = sanitize_integer(slot, 1, max_save_slots, initial(default_slot))
if(slot != default_slot)
default_slot = slot
S["default_slot"] << slot
S.cd = "/character[slot]"
var/needs_update = savefile_needs_update(S)
if(needs_update == -2) //fatal, can't load any data
return 0
//Species
var/species_id
S["species"] >> species_id
if(config.mutant_races && species_id && (species_id in roundstart_species))
var/newtype = roundstart_species[species_id]
pref_species = new newtype()
else
pref_species = new /datum/species/human()
if(!S["features["mcolor"]"] || S["features["mcolor"]"] == "#000")
S["features["mcolor"]"] << "#FFF"
//Character
S["OOC_Notes"] >> metadata
S["real_name"] >> real_name
S["name_is_always_random"] >> be_random_name
S["body_is_always_random"] >> be_random_body
S["gender"] >> gender
S["age"] >> age
S["hair_color"] >> hair_color
S["facial_hair_color"] >> facial_hair_color
S["eye_color"] >> eye_color
S["skin_tone"] >> skin_tone
S["hair_style_name"] >> hair_style
S["facial_style_name"] >> facial_hair_style
S["underwear"] >> underwear
S["undershirt"] >> undershirt
S["socks"] >> socks
S["backbag"] >> backbag
S["feature_mcolor"] >> features["mcolor"]
S["feature_lizard_tail"] >> features["tail_lizard"]
S["feature_lizard_snout"] >> features["snout"]
S["feature_lizard_horns"] >> features["horns"]
S["feature_lizard_frills"] >> features["frills"]
S["feature_lizard_spines"] >> features["spines"]
S["feature_lizard_body_markings"] >> features["body_markings"]
if(!config.mutant_humans)
features["tail_human"] = "none"
features["ears"] = "none"
else
S["feature_human_tail"] >> features["tail_human"]
S["feature_human_ears"] >> features["ears"]
S["clown_name"] >> custom_names["clown"]
S["mime_name"] >> custom_names["mime"]
S["ai_name"] >> custom_names["ai"]
S["cyborg_name"] >> custom_names["cyborg"]
S["religion_name"] >> custom_names["religion"]
S["deity_name"] >> custom_names["deity"]
//Jobs
S["userandomjob"] >> userandomjob
S["job_civilian_high"] >> job_civilian_high
S["job_civilian_med"] >> job_civilian_med
S["job_civilian_low"] >> job_civilian_low
S["job_medsci_high"] >> job_medsci_high
S["job_medsci_med"] >> job_medsci_med
S["job_medsci_low"] >> job_medsci_low
S["job_engsec_high"] >> job_engsec_high
S["job_engsec_med"] >> job_engsec_med
S["job_engsec_low"] >> job_engsec_low
//try to fix any outdated data if necessary
if(needs_update >= 0)
update_character(needs_update) //needs_update == savefile_version if we need an update (positive integer)
//Sanitize
metadata = sanitize_text(metadata, initial(metadata))
real_name = reject_bad_name(real_name)
if(!features["mcolor"] || features["mcolor"] == "#000")
features["mcolor"] = pick("FFFFFF","7F7F7F", "7FFF7F", "7F7FFF", "FF7F7F", "7FFFFF", "FF7FFF", "FFFF7F")
if(!real_name) real_name = random_unique_name(gender)
be_random_name = sanitize_integer(be_random_name, 0, 1, initial(be_random_name))
be_random_body = sanitize_integer(be_random_body, 0, 1, initial(be_random_body))
gender = sanitize_gender(gender)
if(gender == MALE)
hair_style = sanitize_inlist(hair_style, hair_styles_male_list)
facial_hair_style = sanitize_inlist(facial_hair_style, facial_hair_styles_male_list)
underwear = sanitize_inlist(underwear, underwear_m)
undershirt = sanitize_inlist(undershirt, undershirt_m)
socks = sanitize_inlist(socks, socks_m)
else
hair_style = sanitize_inlist(hair_style, hair_styles_female_list)
facial_hair_style = sanitize_inlist(facial_hair_style, facial_hair_styles_female_list)
underwear = sanitize_inlist(underwear, underwear_f)
undershirt = sanitize_inlist(undershirt, undershirt_f)
socks = sanitize_inlist(socks, socks_f)
age = sanitize_integer(age, AGE_MIN, AGE_MAX, initial(age))
hair_color = sanitize_hexcolor(hair_color, 3, 0)
facial_hair_color = sanitize_hexcolor(facial_hair_color, 3, 0)
eye_color = sanitize_hexcolor(eye_color, 3, 0)
skin_tone = sanitize_inlist(skin_tone, skin_tones)
backbag = sanitize_integer(backbag, 1, backbaglist.len, initial(backbag))
features["mcolor"] = sanitize_hexcolor(features["mcolor"], 3, 0)
features["tail_lizard"] = sanitize_inlist(features["tail_lizard"], tails_list_lizard)
features["tail_human"] = sanitize_inlist(features["tail_human"], tails_list_human, "None")
features["snout"] = sanitize_inlist(features["snout"], snouts_list)
features["horns"] = sanitize_inlist(features["horns"], horns_list)
features["ears"] = sanitize_inlist(features["ears"], ears_list, "None")
features["frills"] = sanitize_inlist(features["frills"], frills_list)
features["spines"] = sanitize_inlist(features["spines"], spines_list)
features["body_markings"] = sanitize_inlist(features["body_markings"], body_markings_list)
userandomjob = sanitize_integer(userandomjob, 0, 1, initial(userandomjob))
job_civilian_high = sanitize_integer(job_civilian_high, 0, 65535, initial(job_civilian_high))
job_civilian_med = sanitize_integer(job_civilian_med, 0, 65535, initial(job_civilian_med))
job_civilian_low = sanitize_integer(job_civilian_low, 0, 65535, initial(job_civilian_low))
job_medsci_high = sanitize_integer(job_medsci_high, 0, 65535, initial(job_medsci_high))
job_medsci_med = sanitize_integer(job_medsci_med, 0, 65535, initial(job_medsci_med))
job_medsci_low = sanitize_integer(job_medsci_low, 0, 65535, initial(job_medsci_low))
job_engsec_high = sanitize_integer(job_engsec_high, 0, 65535, initial(job_engsec_high))
job_engsec_med = sanitize_integer(job_engsec_med, 0, 65535, initial(job_engsec_med))
job_engsec_low = sanitize_integer(job_engsec_low, 0, 65535, initial(job_engsec_low))
return 1
/datum/preferences/proc/save_character()
if(!path) return 0
var/savefile/S = new /savefile(path)
if(!S) return 0
S.cd = "/character[default_slot]"
S["version"] << SAVEFILE_VERSION_MAX //load_character will sanitize any bad data, so assume up-to-date.
//Character
S["OOC_Notes"] << metadata
S["real_name"] << real_name
S["name_is_always_random"] << be_random_name
S["body_is_always_random"] << be_random_body
S["gender"] << gender
S["age"] << age
S["hair_color"] << hair_color
S["facial_hair_color"] << facial_hair_color
S["eye_color"] << eye_color
S["skin_tone"] << skin_tone
S["hair_style_name"] << hair_style
S["facial_style_name"] << facial_hair_style
S["underwear"] << underwear
S["undershirt"] << undershirt
S["socks"] << socks
S["backbag"] << backbag
S["species"] << pref_species.id
S["feature_mcolor"] << features["mcolor"]
S["feature_lizard_tail"] << features["tail_lizard"]
S["feature_human_tail"] << features["tail_human"]
S["feature_lizard_snout"] << features["snout"]
S["feature_lizard_horns"] << features["horns"]
S["feature_human_ears"] << features["ears"]
S["feature_lizard_frills"] << features["frills"]
S["feature_lizard_spines"] << features["spines"]
S["feature_lizard_body_markings"] << features["body_markings"]
S["clown_name"] << custom_names["clown"]
S["mime_name"] << custom_names["mime"]
S["ai_name"] << custom_names["ai"]
S["cyborg_name"] << custom_names["cyborg"]
S["religion_name"] << custom_names["religion"]
S["deity_name"] << custom_names["deity"]
//Jobs
S["userandomjob"] << userandomjob
S["job_civilian_high"] << job_civilian_high
S["job_civilian_med"] << job_civilian_med
S["job_civilian_low"] << job_civilian_low
S["job_medsci_high"] << job_medsci_high
S["job_medsci_med"] << job_medsci_med
S["job_medsci_low"] << job_medsci_low
S["job_engsec_high"] << job_engsec_high
S["job_engsec_med"] << job_engsec_med
S["job_engsec_low"] << job_engsec_low
return 1
#undef SAVEFILE_VERSION_MAX
#undef SAVEFILE_VERSION_MIN
/*
//DEBUG
//Some crude tools for testing savefiles
//path is the savefile path
/client/verb/savefile_export(path as text)
var/savefile/S = new /savefile(path)
S.ExportText("/",file("[path].txt"))
//path is the savefile path
/client/verb/savefile_import(path as text)
var/savefile/S = new /savefile(path)
S.ImportText("/",file("[path].txt"))
*/
//This is the lowest supported version, anything below this is completely obsolete and the entire savefile will be wiped.
#define SAVEFILE_VERSION_MIN 8
//This is the current version, anything below this will attempt to update (if it's not obsolete)
#define SAVEFILE_VERSION_MAX 12
/*
SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn
This proc checks if the current directory of the savefile S needs updating
It is to be used by the load_character and load_preferences procs.
(S.cd=="/" is preferences, S.cd=="/character[integer]" is a character slot, etc)
if the current directory's version is below SAVEFILE_VERSION_MIN it will simply wipe everything in that directory
(if we're at root "/" then it'll just wipe the entire savefile, for instance.)
if its version is below SAVEFILE_VERSION_MAX but above the minimum, it will load data but later call the
respective update_preferences() or update_character() proc.
Those procs allow coders to specify format changes so users do not lose their setups and have to redo them again.
Failing all that, the standard sanity checks are performed. They simply check the data is suitable, reverting to
initial() values if necessary.
*/
/datum/preferences/proc/savefile_needs_update(savefile/S)
var/savefile_version
S["version"] >> savefile_version
if(savefile_version < SAVEFILE_VERSION_MIN)
S.dir.Cut()
return -2
if(savefile_version < SAVEFILE_VERSION_MAX)
return savefile_version
return -1
/datum/preferences/proc/update_antagchoices(current_version)
if((!islist(be_special) || old_be_special ) && current_version < 12)
//Archived values of when antag pref defines were a bitfield+fitflags
var/B_traitor = 1
var/B_operative = 2
var/B_changeling = 4
var/B_wizard = 8
var/B_malf = 16
var/B_rev = 32
var/B_alien = 64
var/B_pai = 128
var/B_cultist = 256
var/B_blob = 512
var/B_ninja = 1024
var/B_monkey = 2048
var/B_gang = 4096
var/B_shadowling = 8192
var/B_abductor = 16384
var/B_revenant = 32768
var/list/archived = list(B_traitor,B_operative,B_changeling,B_wizard,B_malf,B_rev,B_alien,B_pai,B_cultist,B_blob,B_ninja,B_monkey,B_gang,B_shadowling,B_abductor,B_revenant)
be_special = list()
for(var/flag in archived)
if(old_be_special & flag)
//this is shitty, but this proc should only be run once per player and then never again for the rest of eternity,
switch(flag)
if(1) //why aren't these the variables above? Good question, it's because byond complains the expression isn't constant, when it is.
be_special += ROLE_TRAITOR
if(2)
be_special += ROLE_OPERATIVE
if(4)
be_special += ROLE_CHANGELING
if(8)
be_special += ROLE_WIZARD
if(16)
be_special += ROLE_MALF
if(32)
be_special += ROLE_REV
if(64)
be_special += ROLE_ALIEN
if(128)
be_special += ROLE_PAI
if(256)
be_special += ROLE_CULTIST
if(512)
be_special += ROLE_BLOB
if(1024)
be_special += ROLE_NINJA
if(2048)
be_special += ROLE_MONKEY
if(4096)
be_special += ROLE_GANG
if(8192)
be_special += ROLE_SHADOWLING
if(16384)
be_special += ROLE_ABDUCTOR
if(32768)
be_special += ROLE_REVENANT
/datum/preferences/proc/update_preferences(current_version)
if(current_version < 10)
toggles |= MEMBER_PUBLIC
if(current_version < 11)
chat_toggles = TOGGLES_DEFAULT_CHAT
toggles = TOGGLES_DEFAULT
if(current_version < 12)
ignoring = list()
//should this proc get fairly long (say 3 versions long),
//just increase SAVEFILE_VERSION_MIN so it's not as far behind
//SAVEFILE_VERSION_MAX and then delete any obsolete if clauses
//from this proc.
//It's only really meant to avoid annoying frequent players
//if your savefile is 3 months out of date, then 'tough shit'.
/datum/preferences/proc/update_character(current_version)
if(current_version < 9) //an example, underwear were an index for a hardcoded list, converting to a string
if(gender == MALE)
switch(underwear)
if(1) underwear = "Mens White"
if(2) underwear = "Mens Grey"
if(3) underwear = "Mens Green"
if(4) underwear = "Mens Blue"
if(5) underwear = "Mens Black"
if(6) underwear = "Mankini"
if(7) underwear = "Mens Hearts Boxer"
if(8) underwear = "Mens Black Boxer"
if(9) underwear = "Mens Grey Boxer"
if(10) underwear = "Mens Striped Boxer"
if(11) underwear = "Mens Kinky"
if(12) underwear = "Mens Red"
if(13) underwear = "Nude"
else
switch(underwear)
if(1) underwear = "Ladies Red"
if(2) underwear = "Ladies White"
if(3) underwear = "Ladies Yellow"
if(4) underwear = "Ladies Blue"
if(5) underwear = "Ladies Black"
if(6) underwear = "Ladies Thong"
if(7) underwear = "Babydoll"
if(8) underwear = "Ladies Baby-Blue"
if(9) underwear = "Ladies Green"
if(10) underwear = "Ladies Pink"
if(11) underwear = "Ladies Kinky"
if(12) underwear = "Tankini"
if(13) underwear = "Nude"
if(!(pref_species in species_list))
pref_species = new /datum/species/human()
return
/datum/preferences/proc/load_path(ckey,filename="preferences.sav")
if(!ckey) return
path = "data/player_saves/[copytext(ckey,1,2)]/[ckey]/[filename]"
/datum/preferences/proc/load_preferences()
if(!path) return 0
if(!fexists(path)) return 0
var/savefile/S = new /savefile(path)
if(!S) return 0
S.cd = "/"
var/needs_update = savefile_needs_update(S)
if(needs_update == -2) //fatal, can't load any data
return 0
//general preferences
S["ooccolor"] >> ooccolor
S["lastchangelog"] >> lastchangelog
S["UI_style"] >> UI_style
S["nanoui_fancy"] >> nanoui_fancy
S["be_special"] >> be_special
if(islist(S["be_special"]))
S["be_special"] >> be_special
else //force update and store the old bitflag version of be_special
needs_update = 11
S["be_special"] >> old_be_special
S["default_slot"] >> default_slot
S["chat_toggles"] >> chat_toggles
S["toggles"] >> toggles
S["ghost_form"] >> ghost_form
S["preferred_map"] >> preferred_map
S["ignoring"] >> ignoring
//try to fix any outdated data if necessary
if(needs_update >= 0)
update_preferences(needs_update) //needs_update = savefile_version if we need an update (positive integer)
update_antagchoices(needs_update)
//Sanitize
ooccolor = sanitize_ooccolor(sanitize_hexcolor(ooccolor, 6, 1, initial(ooccolor)))
lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog))
UI_style = sanitize_inlist(UI_style, list("Midnight", "Plasmafire", "Retro"), initial(UI_style))
nanoui_fancy = sanitize_integer(nanoui_fancy, 0, 1, initial(nanoui_fancy))
default_slot = sanitize_integer(default_slot, 1, max_save_slots, initial(default_slot))
toggles = sanitize_integer(toggles, 0, 65535, initial(toggles))
ghost_form = sanitize_inlist(ghost_form, ghost_forms, initial(ghost_form))
return 1
/datum/preferences/proc/save_preferences()
if(!path) return 0
var/savefile/S = new /savefile(path)
if(!S) return 0
S.cd = "/"
S["version"] << SAVEFILE_VERSION_MAX //updates (or failing that the sanity checks) will ensure data is not invalid at load. Assume up-to-date
//general preferences
S["ooccolor"] << ooccolor
S["lastchangelog"] << lastchangelog
S["UI_style"] << UI_style
S["nanoui_fancy"] << nanoui_fancy
S["be_special"] << be_special
S["default_slot"] << default_slot
S["toggles"] << toggles
S["chat_toggles"] << chat_toggles
S["ghost_form"] << ghost_form
S["preferred_map"] << preferred_map
S["ignoring"] << ignoring
return 1
/datum/preferences/proc/load_character(slot)
if(!path) return 0
if(!fexists(path)) return 0
var/savefile/S = new /savefile(path)
if(!S) return 0
S.cd = "/"
if(!slot) slot = default_slot
slot = sanitize_integer(slot, 1, max_save_slots, initial(default_slot))
if(slot != default_slot)
default_slot = slot
S["default_slot"] << slot
S.cd = "/character[slot]"
var/needs_update = savefile_needs_update(S)
if(needs_update == -2) //fatal, can't load any data
return 0
//Species
var/species_id
S["species"] >> species_id
if(config.mutant_races && species_id && (species_id in roundstart_species))
var/newtype = roundstart_species[species_id]
pref_species = new newtype()
else
pref_species = new /datum/species/human()
if(!S["features["mcolor"]"] || S["features["mcolor"]"] == "#000")
S["features["mcolor"]"] << "#FFF"
//Character
S["OOC_Notes"] >> metadata
S["real_name"] >> real_name
S["name_is_always_random"] >> be_random_name
S["body_is_always_random"] >> be_random_body
S["gender"] >> gender
S["age"] >> age
S["hair_color"] >> hair_color
S["facial_hair_color"] >> facial_hair_color
S["eye_color"] >> eye_color
S["skin_tone"] >> skin_tone
S["hair_style_name"] >> hair_style
S["facial_style_name"] >> facial_hair_style
S["underwear"] >> underwear
S["undershirt"] >> undershirt
S["socks"] >> socks
S["backbag"] >> backbag
S["feature_mcolor"] >> features["mcolor"]
S["feature_lizard_tail"] >> features["tail_lizard"]
S["feature_lizard_snout"] >> features["snout"]
S["feature_lizard_horns"] >> features["horns"]
S["feature_lizard_frills"] >> features["frills"]
S["feature_lizard_spines"] >> features["spines"]
S["feature_lizard_body_markings"] >> features["body_markings"]
if(!config.mutant_humans)
features["tail_human"] = "none"
features["ears"] = "none"
else
S["feature_human_tail"] >> features["tail_human"]
S["feature_human_ears"] >> features["ears"]
S["clown_name"] >> custom_names["clown"]
S["mime_name"] >> custom_names["mime"]
S["ai_name"] >> custom_names["ai"]
S["cyborg_name"] >> custom_names["cyborg"]
S["religion_name"] >> custom_names["religion"]
S["deity_name"] >> custom_names["deity"]
//Jobs
S["userandomjob"] >> userandomjob
S["job_civilian_high"] >> job_civilian_high
S["job_civilian_med"] >> job_civilian_med
S["job_civilian_low"] >> job_civilian_low
S["job_medsci_high"] >> job_medsci_high
S["job_medsci_med"] >> job_medsci_med
S["job_medsci_low"] >> job_medsci_low
S["job_engsec_high"] >> job_engsec_high
S["job_engsec_med"] >> job_engsec_med
S["job_engsec_low"] >> job_engsec_low
//try to fix any outdated data if necessary
if(needs_update >= 0)
update_character(needs_update) //needs_update == savefile_version if we need an update (positive integer)
//Sanitize
metadata = sanitize_text(metadata, initial(metadata))
real_name = reject_bad_name(real_name)
if(!features["mcolor"] || features["mcolor"] == "#000")
features["mcolor"] = pick("FFFFFF","7F7F7F", "7FFF7F", "7F7FFF", "FF7F7F", "7FFFFF", "FF7FFF", "FFFF7F")
if(!real_name) real_name = random_unique_name(gender)
be_random_name = sanitize_integer(be_random_name, 0, 1, initial(be_random_name))
be_random_body = sanitize_integer(be_random_body, 0, 1, initial(be_random_body))
gender = sanitize_gender(gender)
if(gender == MALE)
hair_style = sanitize_inlist(hair_style, hair_styles_male_list)
facial_hair_style = sanitize_inlist(facial_hair_style, facial_hair_styles_male_list)
underwear = sanitize_inlist(underwear, underwear_m)
undershirt = sanitize_inlist(undershirt, undershirt_m)
socks = sanitize_inlist(socks, socks_m)
else
hair_style = sanitize_inlist(hair_style, hair_styles_female_list)
facial_hair_style = sanitize_inlist(facial_hair_style, facial_hair_styles_female_list)
underwear = sanitize_inlist(underwear, underwear_f)
undershirt = sanitize_inlist(undershirt, undershirt_f)
socks = sanitize_inlist(socks, socks_f)
age = sanitize_integer(age, AGE_MIN, AGE_MAX, initial(age))
hair_color = sanitize_hexcolor(hair_color, 3, 0)
facial_hair_color = sanitize_hexcolor(facial_hair_color, 3, 0)
eye_color = sanitize_hexcolor(eye_color, 3, 0)
skin_tone = sanitize_inlist(skin_tone, skin_tones)
backbag = sanitize_integer(backbag, 1, backbaglist.len, initial(backbag))
features["mcolor"] = sanitize_hexcolor(features["mcolor"], 3, 0)
features["tail_lizard"] = sanitize_inlist(features["tail_lizard"], tails_list_lizard)
features["tail_human"] = sanitize_inlist(features["tail_human"], tails_list_human, "None")
features["snout"] = sanitize_inlist(features["snout"], snouts_list)
features["horns"] = sanitize_inlist(features["horns"], horns_list)
features["ears"] = sanitize_inlist(features["ears"], ears_list, "None")
features["frills"] = sanitize_inlist(features["frills"], frills_list)
features["spines"] = sanitize_inlist(features["spines"], spines_list)
features["body_markings"] = sanitize_inlist(features["body_markings"], body_markings_list)
userandomjob = sanitize_integer(userandomjob, 0, 1, initial(userandomjob))
job_civilian_high = sanitize_integer(job_civilian_high, 0, 65535, initial(job_civilian_high))
job_civilian_med = sanitize_integer(job_civilian_med, 0, 65535, initial(job_civilian_med))
job_civilian_low = sanitize_integer(job_civilian_low, 0, 65535, initial(job_civilian_low))
job_medsci_high = sanitize_integer(job_medsci_high, 0, 65535, initial(job_medsci_high))
job_medsci_med = sanitize_integer(job_medsci_med, 0, 65535, initial(job_medsci_med))
job_medsci_low = sanitize_integer(job_medsci_low, 0, 65535, initial(job_medsci_low))
job_engsec_high = sanitize_integer(job_engsec_high, 0, 65535, initial(job_engsec_high))
job_engsec_med = sanitize_integer(job_engsec_med, 0, 65535, initial(job_engsec_med))
job_engsec_low = sanitize_integer(job_engsec_low, 0, 65535, initial(job_engsec_low))
return 1
/datum/preferences/proc/save_character()
if(!path) return 0
var/savefile/S = new /savefile(path)
if(!S) return 0
S.cd = "/character[default_slot]"
S["version"] << SAVEFILE_VERSION_MAX //load_character will sanitize any bad data, so assume up-to-date.
//Character
S["OOC_Notes"] << metadata
S["real_name"] << real_name
S["name_is_always_random"] << be_random_name
S["body_is_always_random"] << be_random_body
S["gender"] << gender
S["age"] << age
S["hair_color"] << hair_color
S["facial_hair_color"] << facial_hair_color
S["eye_color"] << eye_color
S["skin_tone"] << skin_tone
S["hair_style_name"] << hair_style
S["facial_style_name"] << facial_hair_style
S["underwear"] << underwear
S["undershirt"] << undershirt
S["socks"] << socks
S["backbag"] << backbag
S["species"] << pref_species.id
S["feature_mcolor"] << features["mcolor"]
S["feature_lizard_tail"] << features["tail_lizard"]
S["feature_human_tail"] << features["tail_human"]
S["feature_lizard_snout"] << features["snout"]
S["feature_lizard_horns"] << features["horns"]
S["feature_human_ears"] << features["ears"]
S["feature_lizard_frills"] << features["frills"]
S["feature_lizard_spines"] << features["spines"]
S["feature_lizard_body_markings"] << features["body_markings"]
S["clown_name"] << custom_names["clown"]
S["mime_name"] << custom_names["mime"]
S["ai_name"] << custom_names["ai"]
S["cyborg_name"] << custom_names["cyborg"]
S["religion_name"] << custom_names["religion"]
S["deity_name"] << custom_names["deity"]
//Jobs
S["userandomjob"] << userandomjob
S["job_civilian_high"] << job_civilian_high
S["job_civilian_med"] << job_civilian_med
S["job_civilian_low"] << job_civilian_low
S["job_medsci_high"] << job_medsci_high
S["job_medsci_med"] << job_medsci_med
S["job_medsci_low"] << job_medsci_low
S["job_engsec_high"] << job_engsec_high
S["job_engsec_med"] << job_engsec_med
S["job_engsec_low"] << job_engsec_low
return 1
#undef SAVEFILE_VERSION_MAX
#undef SAVEFILE_VERSION_MIN
/*
//DEBUG
//Some crude tools for testing savefiles
//path is the savefile path
/client/verb/savefile_export(path as text)
var/savefile/S = new /savefile(path)
S.ExportText("/",file("[path].txt"))
//path is the savefile path
/client/verb/savefile_import(path as text)
var/savefile/S = new /savefile(path)
S.ImportText("/",file("[path].txt"))
*/
+299 -299
View File
@@ -1,300 +1,300 @@
/obj/item/clothing/suit/armor
allowed = list(/obj/item/weapon/gun/energy,/obj/item/weapon/reagent_containers/spray/pepper,/obj/item/weapon/gun/projectile,/obj/item/ammo_box,/obj/item/ammo_casing,/obj/item/weapon/melee/baton,/obj/item/weapon/restraints/handcuffs,/obj/item/device/flashlight/seclite,/obj/item/weapon/melee/classic_baton/telescopic)
body_parts_covered = CHEST
cold_protection = CHEST|GROIN
min_cold_protection_temperature = ARMOR_MIN_TEMP_PROTECT
heat_protection = CHEST|GROIN
max_heat_protection_temperature = ARMOR_MAX_TEMP_PROTECT
strip_delay = 60
put_on_delay = 40
burn_state = FIRE_PROOF
/obj/item/clothing/suit/armor/vest
name = "armor"
desc = "A slim armored vest that protects against most types of damage."
icon_state = "armor"
item_state = "armor"
blood_overlay_type = "armor"
armor = list(melee = 25, bullet = 15, laser = 25, energy = 10, bomb = 25, bio = 0, rad = 0)
/obj/item/clothing/suit/armor/hos
name = "armored greatcoat"
desc = "A greatcoat enchanced with a special alloy for some protection and style for those with a commanding presence."
icon_state = "hos"
item_state = "greatcoat"
body_parts_covered = CHEST|GROIN|ARMS|LEGS
armor = list(melee = 30, bullet = 30, laser = 30, energy = 10, bomb = 25, bio = 0, rad = 0)
flags_inv = HIDEJUMPSUIT
cold_protection = CHEST|GROIN|LEGS|ARMS
heat_protection = CHEST|GROIN|LEGS|ARMS
strip_delay = 80
/obj/item/clothing/suit/armor/hos/trenchcoat
name = "armored trenchoat"
desc = "A trenchcoat enchanced with a special lightweight kevlar. The epitome of tactical plainclothes."
icon_state = "hostrench"
item_state = "hostrench"
flags_inv = 0
strip_delay = 80
/obj/item/clothing/suit/armor/vest/warden
name = "warden's jacket"
desc = "A red jacket with silver rank pips and body armor strapped on top."
icon_state = "warden_jacket"
item_state = "armor"
body_parts_covered = CHEST|GROIN|ARMS
cold_protection = CHEST|GROIN|ARMS|HANDS
heat_protection = CHEST|GROIN|ARMS|HANDS
strip_delay = 70
burn_state = FLAMMABLE
/obj/item/clothing/suit/armor/vest/warden/alt
name = "warden's armored jacket"
desc = "A navy-blue armored jacket with blue shoulder designations and '/Warden/' stitched into one of the chest pockets."
icon_state = "warden_alt"
/obj/item/clothing/suit/armor/vest/leather
name = "security overcoat"
desc = "Lightly armored leather overcoat meant as casual wear for high-ranking officers. Bears the crest of Nanotrasen Security."
icon_state = "leathercoat-sec"
item_state = "hostrench"
body_parts_covered = CHEST|GROIN|ARMS|LEGS
cold_protection = CHEST|GROIN|LEGS|ARMS
heat_protection = CHEST|GROIN|LEGS|ARMS
/obj/item/clothing/suit/armor/vest/capcarapace
name = "captain's carapace"
desc = "An armored vest reinforced with ceramic plates and pauldrons to provide additional protection whilst still offering maximum mobility and flexibility. Issued only to the station's finest, although it does chafe your nipples."
icon_state = "capcarapace"
item_state = "armor"
body_parts_covered = CHEST|GROIN
armor = list(melee = 50, bullet = 40, laser = 50, energy = 10, bomb = 25, bio = 0, rad = 0)
/obj/item/clothing/suit/armor/vest/capcarapace/alt
name = "captain's parade jacket"
desc = "For when an armoured vest isn't fashionable enough."
icon_state = "capformal"
item_state = "capspacesuit"
/obj/item/clothing/suit/armor/riot
name = "riot suit"
desc = "A suit of armor with heavy padding to protect against melee attacks. Looks like it might impair movement."
icon_state = "riot"
item_state = "swat_suit"
body_parts_covered = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
cold_protection = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
heat_protection = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
armor = list(melee = 50, bullet = 10, laser = 10, energy = 10, bomb = 0, bio = 0, rad = 0)
flags_inv = HIDEJUMPSUIT
strip_delay = 80
put_on_delay = 60
/obj/item/clothing/suit/armor/bulletproof
name = "bulletproof armor"
desc = "A bulletproof vest that excels in protecting the wearer against traditional projectile weaponry and explosives to a minor extent."
icon_state = "bulletproof"
item_state = "armor"
blood_overlay_type = "armor"
armor = list(melee = 15, bullet = 80, laser = 10, energy = 10, bomb = 40, bio = 0, rad = 0)
strip_delay = 70
put_on_delay = 50
/obj/item/clothing/suit/armor/laserproof
name = "reflector vest"
desc = "A vest that excels in protecting the wearer against energy projectiles, as well as occasionally reflecting them."
icon_state = "armor_reflec"
item_state = "armor_reflec"
blood_overlay_type = "armor"
armor = list(melee = 10, bullet = 10, laser = 60, energy = 50, bomb = 0, bio = 0, rad = 0)
var/hit_reflect_chance = 40
/obj/item/clothing/suit/armor/laserproof/IsReflect(def_zone)
if(!(def_zone in list("chest", "groin"))) //If not shot where ablative is covering you, you don't get the reflection bonus!
return 0
if (prob(hit_reflect_chance))
return 1
/obj/item/clothing/suit/armor/vest/det_suit
name = "armor"
desc = "An armored vest with a detective's badge on it."
icon_state = "detective-armor"
allowed = list(/obj/item/weapon/tank/internals/emergency_oxygen,/obj/item/weapon/reagent_containers/spray/pepper,/obj/item/device/flashlight,/obj/item/weapon/gun/energy,/obj/item/weapon/gun/projectile,/obj/item/ammo_box,/obj/item/ammo_casing,/obj/item/weapon/melee/baton,/obj/item/weapon/restraints/handcuffs,/obj/item/weapon/storage/fancy/cigarettes,/obj/item/weapon/lighter,/obj/item/device/detective_scanner,/obj/item/device/taperecorder)
burn_state = FLAMMABLE
//Reactive armor
//When the wearer gets hit, this armor will teleport the user a short distance away (to safety or to more danger, no one knows. That's the fun of it!)
/obj/item/clothing/suit/armor/reactive
name = "reactive teleport armor"
desc = "Someone seperated our Research Director from his own head!"
var/active = 0
icon_state = "reactiveoff"
item_state = "reactiveoff"
blood_overlay_type = "armor"
armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0)
action_button_name = "Toggle Armor"
unacidable = 1
hit_reaction_chance = 50
/obj/item/clothing/suit/armor/reactive/attack_self(mob/user)
src.active = !( src.active )
if (src.active)
user << "<span class='notice'>[src] is now active.</span>"
src.icon_state = "reactive"
src.item_state = "reactive"
else
user << "<span class='notice'>[src] is now inactive.</span>"
src.icon_state = "reactiveoff"
src.item_state = "reactiveoff"
src.add_fingerprint(user)
return
/obj/item/clothing/suit/armor/reactive/emp_act(severity)
active = 0
src.icon_state = "reactiveoff"
src.item_state = "reactiveoff"
..()
/obj/item/clothing/suit/armor/reactive/hit_reaction(mob/living/carbon/human/owner, attack_text, final_block_chance)
if(!active)
return 0
if(prob(hit_reaction_chance))
var/mob/living/carbon/human/H = owner
owner.visible_message("<span class='danger'>The reactive teleport system flings [H] clear of [attack_text]!</span>")
var/list/turfs = new/list()
for(var/turf/T in orange(6, H))
if(T.density)
continue
if(T.x>world.maxx-6 || T.x<6)
continue
if(T.y>world.maxy-6 || T.y<6)
continue
turfs += T
if(!turfs.len)
turfs += pick(/turf in orange(6, H))
var/turf/picked = pick(turfs)
if(!isturf(picked))
return
if(H.buckled)
H.buckled.unbuckle_mob()
H.forceMove(picked)
return 1
return 0
/obj/item/clothing/suit/armor/reactive/fire
name = "reactive incendiary armor"
/obj/item/clothing/suit/armor/reactive/fire/hit_reaction(mob/living/carbon/human/owner, attack_text)
if(!active)
return 0
if(prob(hit_reaction_chance))
owner.visible_message("<span class='danger'>The [src] blocks the [attack_text], sending out jets of flame!</span>")
for(var/mob/living/carbon/C in range(6, owner))
if(C != owner)
C.fire_stacks += 8
C.IgniteMob()
owner.fire_stacks = -20
return 1
return 0
/obj/item/clothing/suit/armor/reactive/stealth
name = "reactive stealth armor"
/obj/item/clothing/suit/armor/reactive/stealth/hit_reaction(mob/living/carbon/human/owner, attack_text)
if(!active)
return 0
if(prob(hit_reaction_chance))
var/mob/living/simple_animal/hostile/illusion/escape/E = new(owner.loc)
E.Copy_Parent(owner, 50)
E.GiveTarget(owner) //so it starts running right away
E.Goto(owner, E.move_to_delay, E.minimum_distance)
owner.alpha = 0
owner.visible_message("<span class='danger'>[owner] is hit by [attack_text] in the chest!</span>") //We pretend to be hit, since blocking it would stop the message otherwise
spawn(40)
owner.alpha = initial(owner.alpha)
return 1
//All of the armor below is mostly unused
/obj/item/clothing/suit/armor/centcom
name = "\improper Centcom armor"
desc = "A suit that protects against some damage."
icon_state = "centcom"
item_state = "centcom"
w_class = 4//bulky item
body_parts_covered = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
allowed = list(/obj/item/weapon/gun/energy,/obj/item/weapon/melee/baton,/obj/item/weapon/restraints/handcuffs,/obj/item/weapon/tank/internals/emergency_oxygen)
flags = THICKMATERIAL
flags_inv = HIDEGLOVES|HIDESHOES|HIDEJUMPSUIT
cold_protection = CHEST | GROIN | LEGS | FEET | ARMS | HANDS
min_cold_protection_temperature = SPACE_SUIT_MIN_TEMP_PROTECT
heat_protection = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
max_heat_protection_temperature = SPACE_SUIT_MAX_TEMP_PROTECT
/obj/item/clothing/suit/armor/heavy
name = "heavy armor"
desc = "A heavily armored suit that protects against moderate damage."
icon_state = "heavy"
item_state = "swat_suit"
w_class = 4//bulky item
gas_transfer_coefficient = 0.90
flags = THICKMATERIAL
body_parts_covered = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
slowdown = 3
flags_inv = HIDEGLOVES|HIDESHOES|HIDEJUMPSUIT
/obj/item/clothing/suit/armor/tdome
body_parts_covered = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
flags_inv = HIDEGLOVES|HIDESHOES|HIDEJUMPSUIT
flags = THICKMATERIAL
cold_protection = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
heat_protection = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
/obj/item/clothing/suit/armor/tdome/red
name = "thunderdome suit"
desc = "Reddish armor."
icon_state = "tdred"
item_state = "tdred"
/obj/item/clothing/suit/armor/tdome/green
name = "thunderdome suit"
desc = "Pukish armor." //classy.
icon_state = "tdgreen"
item_state = "tdgreen"
/obj/item/clothing/suit/armor/riot/knight
name = "plate armour"
desc = "A classic suit of plate armour, highly effective at stopping melee attacks."
icon_state = "knight_green"
item_state = "knight_green"
/obj/item/clothing/suit/armor/riot/knight/yellow
icon_state = "knight_yellow"
item_state = "knight_yellow"
/obj/item/clothing/suit/armor/riot/knight/blue
icon_state = "knight_blue"
item_state = "knight_blue"
/obj/item/clothing/suit/armor/riot/knight/red
icon_state = "knight_red"
item_state = "knight_red"
/obj/item/clothing/suit/armor/riot/knight/templar
name = "crusader armour"
desc = "God wills it!"
icon_state = "knight_templar"
/obj/item/clothing/suit/armor
allowed = list(/obj/item/weapon/gun/energy,/obj/item/weapon/reagent_containers/spray/pepper,/obj/item/weapon/gun/projectile,/obj/item/ammo_box,/obj/item/ammo_casing,/obj/item/weapon/melee/baton,/obj/item/weapon/restraints/handcuffs,/obj/item/device/flashlight/seclite,/obj/item/weapon/melee/classic_baton/telescopic)
body_parts_covered = CHEST
cold_protection = CHEST|GROIN
min_cold_protection_temperature = ARMOR_MIN_TEMP_PROTECT
heat_protection = CHEST|GROIN
max_heat_protection_temperature = ARMOR_MAX_TEMP_PROTECT
strip_delay = 60
put_on_delay = 40
burn_state = FIRE_PROOF
/obj/item/clothing/suit/armor/vest
name = "armor"
desc = "A slim armored vest that protects against most types of damage."
icon_state = "armor"
item_state = "armor"
blood_overlay_type = "armor"
armor = list(melee = 25, bullet = 15, laser = 25, energy = 10, bomb = 25, bio = 0, rad = 0)
/obj/item/clothing/suit/armor/hos
name = "armored greatcoat"
desc = "A greatcoat enchanced with a special alloy for some protection and style for those with a commanding presence."
icon_state = "hos"
item_state = "greatcoat"
body_parts_covered = CHEST|GROIN|ARMS|LEGS
armor = list(melee = 30, bullet = 30, laser = 30, energy = 10, bomb = 25, bio = 0, rad = 0)
flags_inv = HIDEJUMPSUIT
cold_protection = CHEST|GROIN|LEGS|ARMS
heat_protection = CHEST|GROIN|LEGS|ARMS
strip_delay = 80
/obj/item/clothing/suit/armor/hos/trenchcoat
name = "armored trenchoat"
desc = "A trenchcoat enchanced with a special lightweight kevlar. The epitome of tactical plainclothes."
icon_state = "hostrench"
item_state = "hostrench"
flags_inv = 0
strip_delay = 80
/obj/item/clothing/suit/armor/vest/warden
name = "warden's jacket"
desc = "A red jacket with silver rank pips and body armor strapped on top."
icon_state = "warden_jacket"
item_state = "armor"
body_parts_covered = CHEST|GROIN|ARMS
cold_protection = CHEST|GROIN|ARMS|HANDS
heat_protection = CHEST|GROIN|ARMS|HANDS
strip_delay = 70
burn_state = FLAMMABLE
/obj/item/clothing/suit/armor/vest/warden/alt
name = "warden's armored jacket"
desc = "A navy-blue armored jacket with blue shoulder designations and '/Warden/' stitched into one of the chest pockets."
icon_state = "warden_alt"
/obj/item/clothing/suit/armor/vest/leather
name = "security overcoat"
desc = "Lightly armored leather overcoat meant as casual wear for high-ranking officers. Bears the crest of Nanotrasen Security."
icon_state = "leathercoat-sec"
item_state = "hostrench"
body_parts_covered = CHEST|GROIN|ARMS|LEGS
cold_protection = CHEST|GROIN|LEGS|ARMS
heat_protection = CHEST|GROIN|LEGS|ARMS
/obj/item/clothing/suit/armor/vest/capcarapace
name = "captain's carapace"
desc = "An armored vest reinforced with ceramic plates and pauldrons to provide additional protection whilst still offering maximum mobility and flexibility. Issued only to the station's finest, although it does chafe your nipples."
icon_state = "capcarapace"
item_state = "armor"
body_parts_covered = CHEST|GROIN
armor = list(melee = 50, bullet = 40, laser = 50, energy = 10, bomb = 25, bio = 0, rad = 0)
/obj/item/clothing/suit/armor/vest/capcarapace/alt
name = "captain's parade jacket"
desc = "For when an armoured vest isn't fashionable enough."
icon_state = "capformal"
item_state = "capspacesuit"
/obj/item/clothing/suit/armor/riot
name = "riot suit"
desc = "A suit of armor with heavy padding to protect against melee attacks. Looks like it might impair movement."
icon_state = "riot"
item_state = "swat_suit"
body_parts_covered = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
cold_protection = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
heat_protection = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
armor = list(melee = 50, bullet = 10, laser = 10, energy = 10, bomb = 0, bio = 0, rad = 0)
flags_inv = HIDEJUMPSUIT
strip_delay = 80
put_on_delay = 60
/obj/item/clothing/suit/armor/bulletproof
name = "bulletproof armor"
desc = "A bulletproof vest that excels in protecting the wearer against traditional projectile weaponry and explosives to a minor extent."
icon_state = "bulletproof"
item_state = "armor"
blood_overlay_type = "armor"
armor = list(melee = 15, bullet = 80, laser = 10, energy = 10, bomb = 40, bio = 0, rad = 0)
strip_delay = 70
put_on_delay = 50
/obj/item/clothing/suit/armor/laserproof
name = "reflector vest"
desc = "A vest that excels in protecting the wearer against energy projectiles, as well as occasionally reflecting them."
icon_state = "armor_reflec"
item_state = "armor_reflec"
blood_overlay_type = "armor"
armor = list(melee = 10, bullet = 10, laser = 60, energy = 50, bomb = 0, bio = 0, rad = 0)
var/hit_reflect_chance = 40
/obj/item/clothing/suit/armor/laserproof/IsReflect(def_zone)
if(!(def_zone in list("chest", "groin"))) //If not shot where ablative is covering you, you don't get the reflection bonus!
return 0
if (prob(hit_reflect_chance))
return 1
/obj/item/clothing/suit/armor/vest/det_suit
name = "armor"
desc = "An armored vest with a detective's badge on it."
icon_state = "detective-armor"
allowed = list(/obj/item/weapon/tank/internals/emergency_oxygen,/obj/item/weapon/reagent_containers/spray/pepper,/obj/item/device/flashlight,/obj/item/weapon/gun/energy,/obj/item/weapon/gun/projectile,/obj/item/ammo_box,/obj/item/ammo_casing,/obj/item/weapon/melee/baton,/obj/item/weapon/restraints/handcuffs,/obj/item/weapon/storage/fancy/cigarettes,/obj/item/weapon/lighter,/obj/item/device/detective_scanner,/obj/item/device/taperecorder)
burn_state = FLAMMABLE
//Reactive armor
//When the wearer gets hit, this armor will teleport the user a short distance away (to safety or to more danger, no one knows. That's the fun of it!)
/obj/item/clothing/suit/armor/reactive
name = "reactive teleport armor"
desc = "Someone seperated our Research Director from his own head!"
var/active = 0
icon_state = "reactiveoff"
item_state = "reactiveoff"
blood_overlay_type = "armor"
armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0)
action_button_name = "Toggle Armor"
unacidable = 1
hit_reaction_chance = 50
/obj/item/clothing/suit/armor/reactive/attack_self(mob/user)
src.active = !( src.active )
if (src.active)
user << "<span class='notice'>[src] is now active.</span>"
src.icon_state = "reactive"
src.item_state = "reactive"
else
user << "<span class='notice'>[src] is now inactive.</span>"
src.icon_state = "reactiveoff"
src.item_state = "reactiveoff"
src.add_fingerprint(user)
return
/obj/item/clothing/suit/armor/reactive/emp_act(severity)
active = 0
src.icon_state = "reactiveoff"
src.item_state = "reactiveoff"
..()
/obj/item/clothing/suit/armor/reactive/hit_reaction(mob/living/carbon/human/owner, attack_text, final_block_chance)
if(!active)
return 0
if(prob(hit_reaction_chance))
var/mob/living/carbon/human/H = owner
owner.visible_message("<span class='danger'>The reactive teleport system flings [H] clear of [attack_text]!</span>")
var/list/turfs = new/list()
for(var/turf/T in orange(6, H))
if(T.density)
continue
if(T.x>world.maxx-6 || T.x<6)
continue
if(T.y>world.maxy-6 || T.y<6)
continue
turfs += T
if(!turfs.len)
turfs += pick(/turf in orange(6, H))
var/turf/picked = pick(turfs)
if(!isturf(picked))
return
if(H.buckled)
H.buckled.unbuckle_mob()
H.forceMove(picked)
return 1
return 0
/obj/item/clothing/suit/armor/reactive/fire
name = "reactive incendiary armor"
/obj/item/clothing/suit/armor/reactive/fire/hit_reaction(mob/living/carbon/human/owner, attack_text)
if(!active)
return 0
if(prob(hit_reaction_chance))
owner.visible_message("<span class='danger'>The [src] blocks the [attack_text], sending out jets of flame!</span>")
for(var/mob/living/carbon/C in range(6, owner))
if(C != owner)
C.fire_stacks += 8
C.IgniteMob()
owner.fire_stacks = -20
return 1
return 0
/obj/item/clothing/suit/armor/reactive/stealth
name = "reactive stealth armor"
/obj/item/clothing/suit/armor/reactive/stealth/hit_reaction(mob/living/carbon/human/owner, attack_text)
if(!active)
return 0
if(prob(hit_reaction_chance))
var/mob/living/simple_animal/hostile/illusion/escape/E = new(owner.loc)
E.Copy_Parent(owner, 50)
E.GiveTarget(owner) //so it starts running right away
E.Goto(owner, E.move_to_delay, E.minimum_distance)
owner.alpha = 0
owner.visible_message("<span class='danger'>[owner] is hit by [attack_text] in the chest!</span>") //We pretend to be hit, since blocking it would stop the message otherwise
spawn(40)
owner.alpha = initial(owner.alpha)
return 1
//All of the armor below is mostly unused
/obj/item/clothing/suit/armor/centcom
name = "\improper Centcom armor"
desc = "A suit that protects against some damage."
icon_state = "centcom"
item_state = "centcom"
w_class = 4//bulky item
body_parts_covered = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
allowed = list(/obj/item/weapon/gun/energy,/obj/item/weapon/melee/baton,/obj/item/weapon/restraints/handcuffs,/obj/item/weapon/tank/internals/emergency_oxygen)
flags = THICKMATERIAL
flags_inv = HIDEGLOVES|HIDESHOES|HIDEJUMPSUIT
cold_protection = CHEST | GROIN | LEGS | FEET | ARMS | HANDS
min_cold_protection_temperature = SPACE_SUIT_MIN_TEMP_PROTECT
heat_protection = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
max_heat_protection_temperature = SPACE_SUIT_MAX_TEMP_PROTECT
/obj/item/clothing/suit/armor/heavy
name = "heavy armor"
desc = "A heavily armored suit that protects against moderate damage."
icon_state = "heavy"
item_state = "swat_suit"
w_class = 4//bulky item
gas_transfer_coefficient = 0.90
flags = THICKMATERIAL
body_parts_covered = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
slowdown = 3
flags_inv = HIDEGLOVES|HIDESHOES|HIDEJUMPSUIT
/obj/item/clothing/suit/armor/tdome
body_parts_covered = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
flags_inv = HIDEGLOVES|HIDESHOES|HIDEJUMPSUIT
flags = THICKMATERIAL
cold_protection = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
heat_protection = CHEST|GROIN|LEGS|FEET|ARMS|HANDS
/obj/item/clothing/suit/armor/tdome/red
name = "thunderdome suit"
desc = "Reddish armor."
icon_state = "tdred"
item_state = "tdred"
/obj/item/clothing/suit/armor/tdome/green
name = "thunderdome suit"
desc = "Pukish armor." //classy.
icon_state = "tdgreen"
item_state = "tdgreen"
/obj/item/clothing/suit/armor/riot/knight
name = "plate armour"
desc = "A classic suit of plate armour, highly effective at stopping melee attacks."
icon_state = "knight_green"
item_state = "knight_green"
/obj/item/clothing/suit/armor/riot/knight/yellow
icon_state = "knight_yellow"
item_state = "knight_yellow"
/obj/item/clothing/suit/armor/riot/knight/blue
icon_state = "knight_blue"
item_state = "knight_blue"
/obj/item/clothing/suit/armor/riot/knight/red
icon_state = "knight_red"
item_state = "knight_red"
/obj/item/clothing/suit/armor/riot/knight/templar
name = "crusader armour"
desc = "God wills it!"
icon_state = "knight_templar"
item_state = "knight_templar"
File diff suppressed because it is too large Load Diff
+430 -430
View File
@@ -1,431 +1,431 @@
var/list/image/ghost_darkness_images = list() //this is a list of images for things ghosts should still be able to see when they toggle darkness
/mob/dead/observer
name = "ghost"
desc = "It's a g-g-g-g-ghooooost!" //jinkies!
icon = 'icons/mob/mob.dmi'
icon_state = "ghost"
layer = MOB_LAYER + 1
stat = DEAD
density = 0
canmove = 0
anchored = 1 // don't get pushed around
invisibility = INVISIBILITY_OBSERVER
languages = ALL
var/can_reenter_corpse
var/datum/hud/living/carbon/hud = null // hud
var/bootime = 0
var/started_as_observer //This variable is set to 1 when you enter the game as an observer.
//If you died in the game and are a ghsot - this will remain as null.
//Note that this is not a reliable way to determine if admins started as observers, since they change mobs a lot.
var/atom/movable/following = null
var/fun_verbs = 0
var/image/ghostimage = null //this mobs ghost image, for deleting and stuff
var/ghostvision = 1 //is the ghost able to see things humans can't?
var/seedarkness = 1
var/ghost_hud_enabled = 1 //did this ghost disable the on-screen HUD?
var/data_hud_seen = 0 //this should one of the defines in __DEFINES/hud.dm
/mob/dead/observer/New(mob/body)
sight |= SEE_TURFS | SEE_MOBS | SEE_OBJS | SEE_SELF
see_invisible = SEE_INVISIBLE_OBSERVER
see_in_dark = 100
verbs += /mob/dead/observer/proc/dead_tele
stat = DEAD
ghostimage = image(src.icon,src,src.icon_state)
ghost_darkness_images |= ghostimage
updateallghostimages()
var/turf/T
if(ismob(body))
T = get_turf(body) //Where is the body located?
attack_log = body.attack_log //preserve our attack logs by copying them to our ghost
gender = body.gender
if(body.mind && body.mind.name)
name = body.mind.name
else
if(body.real_name)
name = body.real_name
else
name = random_unique_name(gender)
mind = body.mind //we don't transfer the mind but we keep a reference to it.
if(!T) T = pick(latejoin) //Safety in case we cannot find the body's position
loc = T
if(!name) //To prevent nameless ghosts
name = random_unique_name(gender)
real_name = name
if(!fun_verbs)
verbs -= /mob/dead/observer/verb/boo
verbs -= /mob/dead/observer/verb/possess
animate(src, pixel_y = 2, time = 10, loop = -1)
..()
/mob/dead/observer/Destroy()
if (ghostimage)
ghost_darkness_images -= ghostimage
qdel(ghostimage)
ghostimage = null
updateallghostimages()
return ..()
/mob/dead/CanPass(atom/movable/mover, turf/target, height=0)
return 1
/*
Transfer_mind is there to check if mob is being deleted/not going to have a body.
Works together with spawning an observer, noted above.
*/
/mob/proc/ghostize(can_reenter_corpse = 1)
if(key)
if(!cmptext(copytext(key,1,2),"@")) //aghost
var/mob/dead/observer/ghost = new(src) //Transfer safety to observer spawning proc.
ghost.can_reenter_corpse = can_reenter_corpse
ghost.key = key
return ghost
/*
This is the proc mobs get to turn into a ghost. Forked from ghostize due to compatibility issues.
*/
/mob/living/verb/ghost()
set category = "OOC"
set name = "Ghost"
set desc = "Relinquish your life and enter the land of the dead."
if(stat != DEAD)
succumb()
if(stat == DEAD)
ghostize(1)
else
var/response = alert(src, "Are you -sure- you want to ghost?\n(You are alive. If you ghost whilst still alive you may not play again this round! You can't change your mind so choose wisely!!)","Are you sure you want to ghost?","Ghost","Stay in body")
if(response != "Ghost") return //didn't want to ghost after-all
ghostize(0) //0 parameter is so we can never re-enter our body, "Charlie, you can never come baaaack~" :3
return
/mob/dead/observer/Move(NewLoc, direct)
if(NewLoc)
loc = NewLoc
for(var/obj/effect/step_trigger/S in NewLoc)
S.Crossed(src)
return
loc = get_turf(src) //Get out of closets and such as a ghost
if((direct & NORTH) && y < world.maxy)
y++
else if((direct & SOUTH) && y > 1)
y--
if((direct & EAST) && x < world.maxx)
x++
else if((direct & WEST) && x > 1)
x--
for(var/obj/effect/step_trigger/S in locate(x, y, z)) //<-- this is dumb
S.Crossed(src)
/mob/dead/observer/is_active()
return 0
/mob/dead/observer/Stat()
..()
if(statpanel("Status"))
stat(null, "Station Time: [worldtime2text()]")
if(ticker)
if(ticker.mode)
//world << "DEBUG: ticker not null"
if(ticker.mode.name == "AI malfunction")
var/datum/game_mode/malfunction/malf = ticker.mode
//world << "DEBUG: malf mode ticker test"
if(malf.malf_mode_declared && (malf.apcs > 0))
stat(null, "Time left: [max(malf.AI_win_timeleft/malf.apcs, 0)]")
for(var/datum/gang/G in ticker.mode.gangs)
if(isnum(G.dom_timer))
stat(null, "[G.name] Gang Takeover: [max(G.dom_timer, 0)]")
/mob/dead/observer/verb/reenter_corpse()
set category = "Ghost"
set name = "Re-enter Corpse"
if(!client) return
if(!(mind && mind.current))
src << "<span class='warning'>You have no body.</span>"
return
if(!can_reenter_corpse)
src << "<span class='warning'>You cannot re-enter your body.</span>"
return
if(mind.current.key && copytext(mind.current.key,1,2)!="@") //makes sure we don't accidentally kick any clients
usr << "<span class='warning'>Another consciousness is in your body...It is resisting you.</span>"
return
mind.current.key = key
return 1
/mob/dead/observer/proc/notify_cloning(var/message, var/sound, var/atom/source)
if(message)
src << "<span class='ghostalert'>[message]</span>"
if(source)
var/obj/screen/alert/A = throw_alert("\ref[source]_notify_cloning", /obj/screen/alert/notify_cloning)
if(A)
A.desc = message
var/old_layer = source.layer
source.layer = FLOAT_LAYER
A.overlays += source
source.layer = old_layer
src << "<span class='ghostalert'><a href=?src=\ref[src];reenter=1>(Click to re-enter)</a></span>"
if(sound)
src << sound(sound)
/mob/dead/observer/proc/dead_tele()
set category = "Ghost"
set name = "Teleport"
set desc= "Teleport to a location"
if(!istype(usr, /mob/dead/observer))
usr << "Not when you're not dead!"
return
usr.verbs -= /mob/dead/observer/proc/dead_tele
spawn(30)
usr.verbs += /mob/dead/observer/proc/dead_tele
var/A
A = input("Area to jump to", "BOOYEA", A) as null|anything in sortedAreas
var/area/thearea = A
if(!thearea) return
var/list/L = list()
for(var/turf/T in get_area_turfs(thearea.type))
L+=T
if(!L || !L.len)
usr << "No area available."
usr.loc = pick(L)
/mob/dead/observer/verb/follow()
set category = "Ghost"
set name = "Orbit" // "Haunt"
set desc = "Follow and orbit a mob."
var/list/mobs = getpois(skip_mindless=1)
var/input = input("Please, select a mob!", "Haunt", null, null) as null|anything in mobs
var/mob/target = mobs[input]
ManualFollow(target)
// This is the ghost's follow verb with an argument
/mob/dead/observer/proc/ManualFollow(atom/movable/target)
if (!istype(target))
return
var/icon/I = icon(target.icon,target.icon_state,target.dir)
var/orbitsize = (I.Width()+I.Height())*0.5
orbitsize -= (orbitsize/world.icon_size)*(world.icon_size*0.25)
if(orbiting != target)
src << "<span class='notice'>Now orbiting [target].</span>"
orbit(target,orbitsize,0)
/mob/dead/observer/orbit()
..()
//restart our floating animation after orbit is done.
sleep 2 //orbit sets up a 2ds animation when it finishes, so we wait for that to end
if (!orbiting) //make sure another orbit hasn't started
pixel_y = 0
animate(src, pixel_y = 2, time = 10, loop = -1)
/mob/dead/observer/verb/jumptomob() //Moves the ghost instead of just changing the ghosts's eye -Nodrak
set category = "Ghost"
set name = "Jump to Mob"
set desc = "Teleport to a mob"
if(istype(usr, /mob/dead/observer)) //Make sure they're an observer!
var/list/dest = list() //List of possible destinations (mobs)
var/target = null //Chosen target.
dest += getpois(mobs_only=1) //Fill list, prompt user with list
target = input("Please, select a player!", "Jump to Mob", null, null) as null|anything in dest
if (!target)//Make sure we actually have a target
return
else
var/mob/M = dest[target] //Destination mob
var/mob/A = src //Source mob
var/turf/T = get_turf(M) //Turf of the destination mob
if(T && isturf(T)) //Make sure the turf exists, then move the source to that destination.
A.loc = T
else
A << "This mob is not located in the game world."
/mob/dead/observer/verb/boo()
set category = "Ghost"
set name = "Boo!"
set desc= "Scare your crew members because of boredom!"
if(bootime > world.time) return
var/obj/machinery/light/L = locate(/obj/machinery/light) in view(1, src)
if(L)
L.flicker()
bootime = world.time + 600
return
//Maybe in the future we can add more <i>spooky</i> code here!
return
/mob/dead/observer/memory()
set hidden = 1
src << "<span class='danger'>You are dead! You have no mind to store memory!</span>"
/mob/dead/observer/add_memory()
set hidden = 1
src << "<span class='danger'>You are dead! You have no mind to store memory!</span>"
/mob/dead/observer/verb/toggle_ghostsee()
set name = "Toggle Ghost Vision"
set desc = "Toggles your ability to see things only ghosts can see, like other ghosts"
set category = "Ghost"
ghostvision = !(ghostvision)
updateghostsight()
usr << "You [(ghostvision?"now":"no longer")] have ghost vision."
/mob/dead/observer/verb/toggle_darkness()
set name = "Toggle Darkness"
set category = "Ghost"
seedarkness = !(seedarkness)
updateghostsight()
/mob/dead/observer/proc/updateghostsight()
if (!seedarkness)
see_invisible = SEE_INVISIBLE_OBSERVER_NOLIGHTING
else
see_invisible = SEE_INVISIBLE_OBSERVER
if (!ghostvision)
see_invisible = SEE_INVISIBLE_LIVING;
updateghostimages()
/proc/updateallghostimages()
for (var/mob/dead/observer/O in player_list)
O.updateghostimages()
/mob/dead/observer/proc/updateghostimages()
if (!client)
return
if (seedarkness || !ghostvision)
client.images -= ghost_darkness_images
else
//add images for the 60inv things ghosts can normally see when darkness is enabled so they can see them now
client.images |= ghost_darkness_images
if (ghostimage)
client.images -= ghostimage //remove ourself
/mob/dead/observer/verb/possess()
set category = "Ghost"
set name = "Possess!"
set desc= "Take over the body of a mindless creature!"
var/list/possessible = list()
for(var/mob/living/L in living_mob_list)
if(!(L in player_list) && !L.mind)
possessible += L
var/mob/living/target = input("Your new life begins today!", "Possess Mob", null, null) as null|anything in possessible
if(!target)
return 0
if(can_reenter_corpse || (mind && mind.current))
if(alert(src, "Your soul is still tied to your former life as [mind.current.name], if you go foward there is no going back to that life. Are you sure you wish to continue?", "Move On", "Yes", "No") == "No")
return 0
if(target.key)
src << "<span class='warning'>Someone has taken this body while you were choosing!</span>"
return 0
target.key = key
return 1
//this is a mob verb instead of atom for performance reasons
//see /mob/verb/examinate() in mob.dm for more info
//overriden here and in /mob/living for different point span classes and sanity checks
/mob/dead/observer/pointed(atom/A as mob|obj|turf in view())
if(!..())
return 0
usr.visible_message("<span class='deadsay'><b>[src]</b> points to [A].</span>")
return 1
/mob/dead/observer/verb/view_manifest()
set name = "View Crew Manifest"
set category = "Ghost"
var/dat
dat += "<h4>Crew Manifest</h4>"
dat += data_core.get_manifest()
src << browse(dat, "window=manifest;size=387x420;can_close=1")
//this is called when a ghost is drag clicked to something.
/mob/dead/observer/MouseDrop(atom/over)
if(!usr || !over) return
if (isobserver(usr) && usr.client.holder && isliving(over))
if (usr.client.holder.cmd_ghost_drag(src,over))
return
return ..()
/mob/dead/observer/Topic(href, href_list)
..()
if(usr == src)
if(href_list["follow"])
var/atom/movable/target = locate(href_list["follow"])
if(istype(target) && (target != src))
ManualFollow(target)
if(href_list["reenter"])
reenter_corpse()
//We don't want to update the current var
//But we will still carry a mind.
/mob/dead/observer/mind_initialize()
return
/mob/dead/observer/verb/toggle_ghosthud()
set name = "Toggle Ghost HUD"
set desc = "Toggles your ghost's on-screen HUD"
set category = "Ghost"
ghost_hud_enabled = !ghost_hud_enabled
hud_used.ghost_hud()
/mob/dead/observer/proc/show_me_the_hud(hud_index)
var/datum/atom_hud/H = huds[hud_index]
H.add_hud_to(src)
data_hud_seen = hud_index
/mob/dead/observer/verb/toggle_ghost_med_sec_diag_hud()
set name = "Toggle Sec/Med/Diag HUD"
set desc = "Toggles whether you see medical/security/diagnostic HUDs"
set category = "Ghost"
if(data_hud_seen) //remove old huds
var/datum/atom_hud/H = huds[data_hud_seen]
H.remove_hud_from(src)
switch(data_hud_seen) //give new huds
if(0)
show_me_the_hud(DATA_HUD_SECURITY_BASIC)
src << "<span class='notice'>Security HUD set.</span>"
if(DATA_HUD_SECURITY_BASIC)
show_me_the_hud(DATA_HUD_MEDICAL_ADVANCED)
src << "<span class='notice'>Medical HUD set.</span>"
if(DATA_HUD_MEDICAL_ADVANCED)
show_me_the_hud(DATA_HUD_DIAGNOSTIC)
src << "<span class='notice'>Diagnostic HUD set.</span>"
if(DATA_HUD_DIAGNOSTIC)
data_hud_seen = 0
src << "<span class='notice'>HUDs disabled.</span>"
/mob/dead/observer/canUseTopic()
if(check_rights(R_ADMIN, 0))
return 1
var/list/image/ghost_darkness_images = list() //this is a list of images for things ghosts should still be able to see when they toggle darkness
/mob/dead/observer
name = "ghost"
desc = "It's a g-g-g-g-ghooooost!" //jinkies!
icon = 'icons/mob/mob.dmi'
icon_state = "ghost"
layer = MOB_LAYER + 1
stat = DEAD
density = 0
canmove = 0
anchored = 1 // don't get pushed around
invisibility = INVISIBILITY_OBSERVER
languages = ALL
var/can_reenter_corpse
var/datum/hud/living/carbon/hud = null // hud
var/bootime = 0
var/started_as_observer //This variable is set to 1 when you enter the game as an observer.
//If you died in the game and are a ghsot - this will remain as null.
//Note that this is not a reliable way to determine if admins started as observers, since they change mobs a lot.
var/atom/movable/following = null
var/fun_verbs = 0
var/image/ghostimage = null //this mobs ghost image, for deleting and stuff
var/ghostvision = 1 //is the ghost able to see things humans can't?
var/seedarkness = 1
var/ghost_hud_enabled = 1 //did this ghost disable the on-screen HUD?
var/data_hud_seen = 0 //this should one of the defines in __DEFINES/hud.dm
/mob/dead/observer/New(mob/body)
sight |= SEE_TURFS | SEE_MOBS | SEE_OBJS | SEE_SELF
see_invisible = SEE_INVISIBLE_OBSERVER
see_in_dark = 100
verbs += /mob/dead/observer/proc/dead_tele
stat = DEAD
ghostimage = image(src.icon,src,src.icon_state)
ghost_darkness_images |= ghostimage
updateallghostimages()
var/turf/T
if(ismob(body))
T = get_turf(body) //Where is the body located?
attack_log = body.attack_log //preserve our attack logs by copying them to our ghost
gender = body.gender
if(body.mind && body.mind.name)
name = body.mind.name
else
if(body.real_name)
name = body.real_name
else
name = random_unique_name(gender)
mind = body.mind //we don't transfer the mind but we keep a reference to it.
if(!T) T = pick(latejoin) //Safety in case we cannot find the body's position
loc = T
if(!name) //To prevent nameless ghosts
name = random_unique_name(gender)
real_name = name
if(!fun_verbs)
verbs -= /mob/dead/observer/verb/boo
verbs -= /mob/dead/observer/verb/possess
animate(src, pixel_y = 2, time = 10, loop = -1)
..()
/mob/dead/observer/Destroy()
if (ghostimage)
ghost_darkness_images -= ghostimage
qdel(ghostimage)
ghostimage = null
updateallghostimages()
return ..()
/mob/dead/CanPass(atom/movable/mover, turf/target, height=0)
return 1
/*
Transfer_mind is there to check if mob is being deleted/not going to have a body.
Works together with spawning an observer, noted above.
*/
/mob/proc/ghostize(can_reenter_corpse = 1)
if(key)
if(!cmptext(copytext(key,1,2),"@")) //aghost
var/mob/dead/observer/ghost = new(src) //Transfer safety to observer spawning proc.
ghost.can_reenter_corpse = can_reenter_corpse
ghost.key = key
return ghost
/*
This is the proc mobs get to turn into a ghost. Forked from ghostize due to compatibility issues.
*/
/mob/living/verb/ghost()
set category = "OOC"
set name = "Ghost"
set desc = "Relinquish your life and enter the land of the dead."
if(stat != DEAD)
succumb()
if(stat == DEAD)
ghostize(1)
else
var/response = alert(src, "Are you -sure- you want to ghost?\n(You are alive. If you ghost whilst still alive you may not play again this round! You can't change your mind so choose wisely!!)","Are you sure you want to ghost?","Ghost","Stay in body")
if(response != "Ghost") return //didn't want to ghost after-all
ghostize(0) //0 parameter is so we can never re-enter our body, "Charlie, you can never come baaaack~" :3
return
/mob/dead/observer/Move(NewLoc, direct)
if(NewLoc)
loc = NewLoc
for(var/obj/effect/step_trigger/S in NewLoc)
S.Crossed(src)
return
loc = get_turf(src) //Get out of closets and such as a ghost
if((direct & NORTH) && y < world.maxy)
y++
else if((direct & SOUTH) && y > 1)
y--
if((direct & EAST) && x < world.maxx)
x++
else if((direct & WEST) && x > 1)
x--
for(var/obj/effect/step_trigger/S in locate(x, y, z)) //<-- this is dumb
S.Crossed(src)
/mob/dead/observer/is_active()
return 0
/mob/dead/observer/Stat()
..()
if(statpanel("Status"))
stat(null, "Station Time: [worldtime2text()]")
if(ticker)
if(ticker.mode)
//world << "DEBUG: ticker not null"
if(ticker.mode.name == "AI malfunction")
var/datum/game_mode/malfunction/malf = ticker.mode
//world << "DEBUG: malf mode ticker test"
if(malf.malf_mode_declared && (malf.apcs > 0))
stat(null, "Time left: [max(malf.AI_win_timeleft/malf.apcs, 0)]")
for(var/datum/gang/G in ticker.mode.gangs)
if(isnum(G.dom_timer))
stat(null, "[G.name] Gang Takeover: [max(G.dom_timer, 0)]")
/mob/dead/observer/verb/reenter_corpse()
set category = "Ghost"
set name = "Re-enter Corpse"
if(!client) return
if(!(mind && mind.current))
src << "<span class='warning'>You have no body.</span>"
return
if(!can_reenter_corpse)
src << "<span class='warning'>You cannot re-enter your body.</span>"
return
if(mind.current.key && copytext(mind.current.key,1,2)!="@") //makes sure we don't accidentally kick any clients
usr << "<span class='warning'>Another consciousness is in your body...It is resisting you.</span>"
return
mind.current.key = key
return 1
/mob/dead/observer/proc/notify_cloning(var/message, var/sound, var/atom/source)
if(message)
src << "<span class='ghostalert'>[message]</span>"
if(source)
var/obj/screen/alert/A = throw_alert("\ref[source]_notify_cloning", /obj/screen/alert/notify_cloning)
if(A)
A.desc = message
var/old_layer = source.layer
source.layer = FLOAT_LAYER
A.overlays += source
source.layer = old_layer
src << "<span class='ghostalert'><a href=?src=\ref[src];reenter=1>(Click to re-enter)</a></span>"
if(sound)
src << sound(sound)
/mob/dead/observer/proc/dead_tele()
set category = "Ghost"
set name = "Teleport"
set desc= "Teleport to a location"
if(!istype(usr, /mob/dead/observer))
usr << "Not when you're not dead!"
return
usr.verbs -= /mob/dead/observer/proc/dead_tele
spawn(30)
usr.verbs += /mob/dead/observer/proc/dead_tele
var/A
A = input("Area to jump to", "BOOYEA", A) as null|anything in sortedAreas
var/area/thearea = A
if(!thearea) return
var/list/L = list()
for(var/turf/T in get_area_turfs(thearea.type))
L+=T
if(!L || !L.len)
usr << "No area available."
usr.loc = pick(L)
/mob/dead/observer/verb/follow()
set category = "Ghost"
set name = "Orbit" // "Haunt"
set desc = "Follow and orbit a mob."
var/list/mobs = getpois(skip_mindless=1)
var/input = input("Please, select a mob!", "Haunt", null, null) as null|anything in mobs
var/mob/target = mobs[input]
ManualFollow(target)
// This is the ghost's follow verb with an argument
/mob/dead/observer/proc/ManualFollow(atom/movable/target)
if (!istype(target))
return
var/icon/I = icon(target.icon,target.icon_state,target.dir)
var/orbitsize = (I.Width()+I.Height())*0.5
orbitsize -= (orbitsize/world.icon_size)*(world.icon_size*0.25)
if(orbiting != target)
src << "<span class='notice'>Now orbiting [target].</span>"
orbit(target,orbitsize,0)
/mob/dead/observer/orbit()
..()
//restart our floating animation after orbit is done.
sleep 2 //orbit sets up a 2ds animation when it finishes, so we wait for that to end
if (!orbiting) //make sure another orbit hasn't started
pixel_y = 0
animate(src, pixel_y = 2, time = 10, loop = -1)
/mob/dead/observer/verb/jumptomob() //Moves the ghost instead of just changing the ghosts's eye -Nodrak
set category = "Ghost"
set name = "Jump to Mob"
set desc = "Teleport to a mob"
if(istype(usr, /mob/dead/observer)) //Make sure they're an observer!
var/list/dest = list() //List of possible destinations (mobs)
var/target = null //Chosen target.
dest += getpois(mobs_only=1) //Fill list, prompt user with list
target = input("Please, select a player!", "Jump to Mob", null, null) as null|anything in dest
if (!target)//Make sure we actually have a target
return
else
var/mob/M = dest[target] //Destination mob
var/mob/A = src //Source mob
var/turf/T = get_turf(M) //Turf of the destination mob
if(T && isturf(T)) //Make sure the turf exists, then move the source to that destination.
A.loc = T
else
A << "This mob is not located in the game world."
/mob/dead/observer/verb/boo()
set category = "Ghost"
set name = "Boo!"
set desc= "Scare your crew members because of boredom!"
if(bootime > world.time) return
var/obj/machinery/light/L = locate(/obj/machinery/light) in view(1, src)
if(L)
L.flicker()
bootime = world.time + 600
return
//Maybe in the future we can add more <i>spooky</i> code here!
return
/mob/dead/observer/memory()
set hidden = 1
src << "<span class='danger'>You are dead! You have no mind to store memory!</span>"
/mob/dead/observer/add_memory()
set hidden = 1
src << "<span class='danger'>You are dead! You have no mind to store memory!</span>"
/mob/dead/observer/verb/toggle_ghostsee()
set name = "Toggle Ghost Vision"
set desc = "Toggles your ability to see things only ghosts can see, like other ghosts"
set category = "Ghost"
ghostvision = !(ghostvision)
updateghostsight()
usr << "You [(ghostvision?"now":"no longer")] have ghost vision."
/mob/dead/observer/verb/toggle_darkness()
set name = "Toggle Darkness"
set category = "Ghost"
seedarkness = !(seedarkness)
updateghostsight()
/mob/dead/observer/proc/updateghostsight()
if (!seedarkness)
see_invisible = SEE_INVISIBLE_OBSERVER_NOLIGHTING
else
see_invisible = SEE_INVISIBLE_OBSERVER
if (!ghostvision)
see_invisible = SEE_INVISIBLE_LIVING;
updateghostimages()
/proc/updateallghostimages()
for (var/mob/dead/observer/O in player_list)
O.updateghostimages()
/mob/dead/observer/proc/updateghostimages()
if (!client)
return
if (seedarkness || !ghostvision)
client.images -= ghost_darkness_images
else
//add images for the 60inv things ghosts can normally see when darkness is enabled so they can see them now
client.images |= ghost_darkness_images
if (ghostimage)
client.images -= ghostimage //remove ourself
/mob/dead/observer/verb/possess()
set category = "Ghost"
set name = "Possess!"
set desc= "Take over the body of a mindless creature!"
var/list/possessible = list()
for(var/mob/living/L in living_mob_list)
if(!(L in player_list) && !L.mind)
possessible += L
var/mob/living/target = input("Your new life begins today!", "Possess Mob", null, null) as null|anything in possessible
if(!target)
return 0
if(can_reenter_corpse || (mind && mind.current))
if(alert(src, "Your soul is still tied to your former life as [mind.current.name], if you go foward there is no going back to that life. Are you sure you wish to continue?", "Move On", "Yes", "No") == "No")
return 0
if(target.key)
src << "<span class='warning'>Someone has taken this body while you were choosing!</span>"
return 0
target.key = key
return 1
//this is a mob verb instead of atom for performance reasons
//see /mob/verb/examinate() in mob.dm for more info
//overriden here and in /mob/living for different point span classes and sanity checks
/mob/dead/observer/pointed(atom/A as mob|obj|turf in view())
if(!..())
return 0
usr.visible_message("<span class='deadsay'><b>[src]</b> points to [A].</span>")
return 1
/mob/dead/observer/verb/view_manifest()
set name = "View Crew Manifest"
set category = "Ghost"
var/dat
dat += "<h4>Crew Manifest</h4>"
dat += data_core.get_manifest()
src << browse(dat, "window=manifest;size=387x420;can_close=1")
//this is called when a ghost is drag clicked to something.
/mob/dead/observer/MouseDrop(atom/over)
if(!usr || !over) return
if (isobserver(usr) && usr.client.holder && isliving(over))
if (usr.client.holder.cmd_ghost_drag(src,over))
return
return ..()
/mob/dead/observer/Topic(href, href_list)
..()
if(usr == src)
if(href_list["follow"])
var/atom/movable/target = locate(href_list["follow"])
if(istype(target) && (target != src))
ManualFollow(target)
if(href_list["reenter"])
reenter_corpse()
//We don't want to update the current var
//But we will still carry a mind.
/mob/dead/observer/mind_initialize()
return
/mob/dead/observer/verb/toggle_ghosthud()
set name = "Toggle Ghost HUD"
set desc = "Toggles your ghost's on-screen HUD"
set category = "Ghost"
ghost_hud_enabled = !ghost_hud_enabled
hud_used.ghost_hud()
/mob/dead/observer/proc/show_me_the_hud(hud_index)
var/datum/atom_hud/H = huds[hud_index]
H.add_hud_to(src)
data_hud_seen = hud_index
/mob/dead/observer/verb/toggle_ghost_med_sec_diag_hud()
set name = "Toggle Sec/Med/Diag HUD"
set desc = "Toggles whether you see medical/security/diagnostic HUDs"
set category = "Ghost"
if(data_hud_seen) //remove old huds
var/datum/atom_hud/H = huds[data_hud_seen]
H.remove_hud_from(src)
switch(data_hud_seen) //give new huds
if(0)
show_me_the_hud(DATA_HUD_SECURITY_BASIC)
src << "<span class='notice'>Security HUD set.</span>"
if(DATA_HUD_SECURITY_BASIC)
show_me_the_hud(DATA_HUD_MEDICAL_ADVANCED)
src << "<span class='notice'>Medical HUD set.</span>"
if(DATA_HUD_MEDICAL_ADVANCED)
show_me_the_hud(DATA_HUD_DIAGNOSTIC)
src << "<span class='notice'>Diagnostic HUD set.</span>"
if(DATA_HUD_DIAGNOSTIC)
data_hud_seen = 0
src << "<span class='notice'>HUDs disabled.</span>"
/mob/dead/observer/canUseTopic()
if(check_rights(R_ADMIN, 0))
return 1
return
@@ -1,75 +1,75 @@
//Space bears!
/mob/living/simple_animal/hostile/bear
name = "space bear"
desc = "You don't need to be faster than a space bear, you just need to outrun your crewmates."
icon_state = "bear"
icon_living = "bear"
icon_dead = "bear_dead"
icon_gib = "bear_gib"
speak = list("RAWR!","Rawr!","GRR!","Growl!")
speak_emote = list("growls", "roars")
emote_hear = list("rawrs.","grumbles.","grawls.")
emote_taunt = list("stares ferociously", "stomps")
speak_chance = 1
taunt_chance = 25
turns_per_move = 5
see_in_dark = 6
butcher_results = list(/obj/item/weapon/reagent_containers/food/snacks/meat/slab/bear = 5, /obj/item/clothing/head/bearpelt = 1)
response_help = "pets"
response_disarm = "gently pushes aside"
response_harm = "hits"
maxHealth = 60
health = 60
melee_damage_lower = 20
melee_damage_upper = 30
attacktext = "claws"
attack_sound = 'sound/weapons/bladeslice.ogg'
friendly = "bear hugs"
//Space bears aren't affected by cold.
atmos_requirements = list("min_oxy" = 0, "max_oxy" = 0, "min_tox" = 0, "max_tox" = 0, "min_co2" = 0, "max_co2" = 0, "min_n2" = 0, "max_n2" = 0)
minbodytemp = 0
maxbodytemp = 1500
faction = list("russian")
gold_core_spawnable = 1
//SPACE BEARS! SQUEEEEEEEE~ OW! FUCK! IT BIT MY HAND OFF!!
/mob/living/simple_animal/hostile/bear/Hudson
name = "Hudson"
desc = "Feared outlaw, this guy is one bad news bear." //I'm sorry...
/mob/living/simple_animal/hostile/bear/snow
name = "space polar bear"
icon_state = "snowbear"
icon_living = "snowbear"
icon_dead = "snowbear_dead"
desc = "It's a polar bear, in space, but not actually in space. "
/mob/living/simple_animal/hostile/bear/Process_Spacemove(movement_dir = 0)
return 1 //No drifting in space for space bears!
//Space bears!
/mob/living/simple_animal/hostile/bear
name = "space bear"
desc = "You don't need to be faster than a space bear, you just need to outrun your crewmates."
icon_state = "bear"
icon_living = "bear"
icon_dead = "bear_dead"
icon_gib = "bear_gib"
speak = list("RAWR!","Rawr!","GRR!","Growl!")
speak_emote = list("growls", "roars")
emote_hear = list("rawrs.","grumbles.","grawls.")
emote_taunt = list("stares ferociously", "stomps")
speak_chance = 1
taunt_chance = 25
turns_per_move = 5
see_in_dark = 6
butcher_results = list(/obj/item/weapon/reagent_containers/food/snacks/meat/slab/bear = 5, /obj/item/clothing/head/bearpelt = 1)
response_help = "pets"
response_disarm = "gently pushes aside"
response_harm = "hits"
maxHealth = 60
health = 60
melee_damage_lower = 20
melee_damage_upper = 30
attacktext = "claws"
attack_sound = 'sound/weapons/bladeslice.ogg'
friendly = "bear hugs"
//Space bears aren't affected by cold.
atmos_requirements = list("min_oxy" = 0, "max_oxy" = 0, "min_tox" = 0, "max_tox" = 0, "min_co2" = 0, "max_co2" = 0, "min_n2" = 0, "max_n2" = 0)
minbodytemp = 0
maxbodytemp = 1500
faction = list("russian")
gold_core_spawnable = 1
//SPACE BEARS! SQUEEEEEEEE~ OW! FUCK! IT BIT MY HAND OFF!!
/mob/living/simple_animal/hostile/bear/Hudson
name = "Hudson"
desc = "Feared outlaw, this guy is one bad news bear." //I'm sorry...
/mob/living/simple_animal/hostile/bear/snow
name = "space polar bear"
icon_state = "snowbear"
icon_living = "snowbear"
icon_dead = "snowbear_dead"
desc = "It's a polar bear, in space, but not actually in space. "
/mob/living/simple_animal/hostile/bear/Process_Spacemove(movement_dir = 0)
return 1 //No drifting in space for space bears!
File diff suppressed because it is too large Load Diff
+153 -153
View File
@@ -1,154 +1,154 @@
/mob
density = 1
layer = 4
animate_movement = 2
flags = HEAR
hud_possible = list(ANTAG_HUD)
pressure_resistance = 8
var/datum/mind/mind
var/list/datum/action/actions = list()
var/stat = 0 //Whether a mob is alive or dead. TODO: Move this to living - Nodrak
var/obj/screen/flash = null
var/obj/screen/blind = null
var/obj/screen/hands = null
var/obj/screen/pullin = null
var/obj/screen/internals = null
var/obj/screen/i_select = null
var/obj/screen/m_select = null
var/obj/screen/healths = null
var/obj/screen/throw_icon = null
var/obj/screen/damageoverlay = null
/*A bunch of this stuff really needs to go under their own defines instead of being globally attached to mob.
A variable should only be globally attached to turfs/objects/whatever, when it is in fact needed as such.
The current method unnecessarily clusters up the variable list, especially for humans (although rearranging won't really clean it up a lot but the difference will be noticable for other mobs).
I'll make some notes on where certain variable defines should probably go.
Changing this around would probably require a good look-over the pre-existing code.
*/
var/obj/screen/zone_sel/zone_sel = null
var/obj/screen/leap_icon = null
var/obj/screen/healthdoll = null
var/damageoverlaytemp = 0
var/computer_id = null
var/lastattacker = null
var/lastattacked = null
var/attack_log = list( )
var/obj/machinery/machine = null
var/other_mobs = null
var/memory = ""
var/disabilities = 0 //Carbon
var/atom/movable/pulling = null
var/next_move = null
var/notransform = null //Carbon
var/hand = null
var/eye_blind = 0 //Carbon
var/eye_blurry = 0 //Carbon
var/ear_deaf = 0 //Carbon
var/ear_damage = 0 //Carbon
var/stuttering = null //Carbon
var/slurring = 0 //Carbon
var/real_name = null
var/druggy = 0 //Carbon
var/confused = 0 //Carbon
var/sleeping = 0 //Carbon
var/resting = 0 //Carbon
var/lying = 0
var/lying_prev = 0
var/canmove = 1
var/eye_stat = null//Living, potentially Carbon
var/lastpuke = 0
var/name_archive //For admin things like possession
var/timeofdeath = 0//Living
var/cpr_time = 1//Carbon
var/bodytemperature = 310.055 //98.7 F
var/drowsyness = 0//Carbon
var/dizziness = 0//Carbon
var/jitteriness = 0//Carbon
var/nutrition = NUTRITION_LEVEL_FED + 50//Carbon
var/satiety = 0//Carbon
var/overeatduration = 0 // How long this guy is overeating //Carbon
var/paralysis = 0
var/stunned = 0
var/weakened = 0
var/losebreath = 0//Carbon
var/shakecamera = 0
var/a_intent = "help"//Living
var/m_intent = "run"//Living
var/lastKnownIP = null
var/atom/movable/buckled = null//Living
var/obj/item/l_hand = null//Living
var/obj/item/r_hand = null//Living
var/obj/item/weapon/storage/s_active = null//Carbon
var/see_override = 0 //0 for no override, sets see_invisible = see_override in mob life process
var/datum/hud/hud_used = null
var/research_scanner = 0 //For research scanner equipped mobs. Enable to show research data when examining.
var/datum/action/innate/scan_mode/scanner = new
var/list/grabbed_by = list( )
var/list/requests = list( )
var/list/mapobjs = list()
var/in_throw_mode = 0
var/music_lastplayed = "null"
var/job = null//Living
var/radiation = 0//Carbon
var/voice_name = "unidentifiable voice"
var/list/faction = list("neutral") //A list of factions that this mob is currently in, for hostile mob targetting, amongst other things
var/move_on_shuttle = 1 // Can move on the shuttle.
//The last mob/living/carbon to push/drag/grab this mob (mostly used by slimes friend recognition)
var/mob/living/carbon/LAssailant = null
var/list/mob_spell_list = list() //construct spells and mime spells. Spells that do not transfer from one mob to another and can not be lost in mindswap.
//Changlings, but can be used in other modes
// var/obj/effect/proc_holder/changpower/list/power_list = list()
//List of active diseases
var/list/viruses = list() // replaces var/datum/disease/virus
var/list/resistances = list()
mouse_drag_pointer = MOUSE_ACTIVE_POINTER
var/status_flags = CANSTUN|CANWEAKEN|CANPARALYSE|CANPUSH //bitflags defining which status effects can be inflicted (replaces canweaken, canstun, etc)
var/digitalcamo = 0 // Can they be tracked by the AI?
var/digitalinvis = 0 //Are they ivisible to the AI?
var/image/digitaldisguise = null //what does the AI see instead of them?
var/weakeyes = 0 //Are they vulnerable to flashes?
var/has_unlimited_silicon_privilege = 0 // Can they interact with station electronics
var/force_compose = 0 //If this is nonzero, the mob will always compose it's own hear message instead of using the one given in the arguments.
var/obj/control_object //Used by admins to possess objects. All mobs should have this var
var/atom/movable/remote_control //Calls relaymove() to whatever it is
var/remote_view = 0 // Set to 1 to prevent view resets on Life
var/turf/listed_turf = null //the current turf being examined in the stat panel
var/list/permanent_huds = list()
var/permanent_sight_flags = 0
/mob
density = 1
layer = 4
animate_movement = 2
flags = HEAR
hud_possible = list(ANTAG_HUD)
pressure_resistance = 8
var/datum/mind/mind
var/list/datum/action/actions = list()
var/stat = 0 //Whether a mob is alive or dead. TODO: Move this to living - Nodrak
var/obj/screen/flash = null
var/obj/screen/blind = null
var/obj/screen/hands = null
var/obj/screen/pullin = null
var/obj/screen/internals = null
var/obj/screen/i_select = null
var/obj/screen/m_select = null
var/obj/screen/healths = null
var/obj/screen/throw_icon = null
var/obj/screen/damageoverlay = null
/*A bunch of this stuff really needs to go under their own defines instead of being globally attached to mob.
A variable should only be globally attached to turfs/objects/whatever, when it is in fact needed as such.
The current method unnecessarily clusters up the variable list, especially for humans (although rearranging won't really clean it up a lot but the difference will be noticable for other mobs).
I'll make some notes on where certain variable defines should probably go.
Changing this around would probably require a good look-over the pre-existing code.
*/
var/obj/screen/zone_sel/zone_sel = null
var/obj/screen/leap_icon = null
var/obj/screen/healthdoll = null
var/damageoverlaytemp = 0
var/computer_id = null
var/lastattacker = null
var/lastattacked = null
var/attack_log = list( )
var/obj/machinery/machine = null
var/other_mobs = null
var/memory = ""
var/disabilities = 0 //Carbon
var/atom/movable/pulling = null
var/next_move = null
var/notransform = null //Carbon
var/hand = null
var/eye_blind = 0 //Carbon
var/eye_blurry = 0 //Carbon
var/ear_deaf = 0 //Carbon
var/ear_damage = 0 //Carbon
var/stuttering = null //Carbon
var/slurring = 0 //Carbon
var/real_name = null
var/druggy = 0 //Carbon
var/confused = 0 //Carbon
var/sleeping = 0 //Carbon
var/resting = 0 //Carbon
var/lying = 0
var/lying_prev = 0
var/canmove = 1
var/eye_stat = null//Living, potentially Carbon
var/lastpuke = 0
var/name_archive //For admin things like possession
var/timeofdeath = 0//Living
var/cpr_time = 1//Carbon
var/bodytemperature = 310.055 //98.7 F
var/drowsyness = 0//Carbon
var/dizziness = 0//Carbon
var/jitteriness = 0//Carbon
var/nutrition = NUTRITION_LEVEL_FED + 50//Carbon
var/satiety = 0//Carbon
var/overeatduration = 0 // How long this guy is overeating //Carbon
var/paralysis = 0
var/stunned = 0
var/weakened = 0
var/losebreath = 0//Carbon
var/shakecamera = 0
var/a_intent = "help"//Living
var/m_intent = "run"//Living
var/lastKnownIP = null
var/atom/movable/buckled = null//Living
var/obj/item/l_hand = null//Living
var/obj/item/r_hand = null//Living
var/obj/item/weapon/storage/s_active = null//Carbon
var/see_override = 0 //0 for no override, sets see_invisible = see_override in mob life process
var/datum/hud/hud_used = null
var/research_scanner = 0 //For research scanner equipped mobs. Enable to show research data when examining.
var/datum/action/innate/scan_mode/scanner = new
var/list/grabbed_by = list( )
var/list/requests = list( )
var/list/mapobjs = list()
var/in_throw_mode = 0
var/music_lastplayed = "null"
var/job = null//Living
var/radiation = 0//Carbon
var/voice_name = "unidentifiable voice"
var/list/faction = list("neutral") //A list of factions that this mob is currently in, for hostile mob targetting, amongst other things
var/move_on_shuttle = 1 // Can move on the shuttle.
//The last mob/living/carbon to push/drag/grab this mob (mostly used by slimes friend recognition)
var/mob/living/carbon/LAssailant = null
var/list/mob_spell_list = list() //construct spells and mime spells. Spells that do not transfer from one mob to another and can not be lost in mindswap.
//Changlings, but can be used in other modes
// var/obj/effect/proc_holder/changpower/list/power_list = list()
//List of active diseases
var/list/viruses = list() // replaces var/datum/disease/virus
var/list/resistances = list()
mouse_drag_pointer = MOUSE_ACTIVE_POINTER
var/status_flags = CANSTUN|CANWEAKEN|CANPARALYSE|CANPUSH //bitflags defining which status effects can be inflicted (replaces canweaken, canstun, etc)
var/digitalcamo = 0 // Can they be tracked by the AI?
var/digitalinvis = 0 //Are they ivisible to the AI?
var/image/digitaldisguise = null //what does the AI see instead of them?
var/weakeyes = 0 //Are they vulnerable to flashes?
var/has_unlimited_silicon_privilege = 0 // Can they interact with station electronics
var/force_compose = 0 //If this is nonzero, the mob will always compose it's own hear message instead of using the one given in the arguments.
var/obj/control_object //Used by admins to possess objects. All mobs should have this var
var/atom/movable/remote_control //Calls relaymove() to whatever it is
var/remote_view = 0 // Set to 1 to prevent view resets on Life
var/turf/listed_turf = null //the current turf being examined in the stat panel
var/list/permanent_huds = list()
var/permanent_sight_flags = 0
var/resize = 1 //Badminnery resize
+404 -404
View File
@@ -1,405 +1,405 @@
/**
* NanoUI
*
* Contains the NanoUI datum, and its procs.
*
* /tg/station user interface library
* thanks to baystation12
*
* modified by neersighted
**/
/**
* NanoUI datum:
*
* Represents a NanoUI.
**/
/datum/nanoui
var/mob/user // The mob who opened/is using the NanoUI.
var/atom/movable/src_object // The object which owns the NanoUI.
var/title // The title of te NanoUI.
var/ui_key // The ui_key of the NanoUI. This allows multiple UIs for one src_object.
var/window_id // The window_id for browse() and onclose().
var/width = 0 // The window width.
var/height = 0 // The window height
var/window_options = list( // Extra options to winset().
"focus" = 0,
"titlebar" = 1,
"can_resize" = 1,
"can_minimize" = 1,
"can_maximize" = 0,
"can_close" = 1,
"auto_format" = 0
)
var/atom/ref = null // An extra ref to call when the window is closed.
var/layout = "nanotrasen" // The layout to be used for this UI.
var/template // The template to be used for this UI.
var/auto_update = 1 // Update the NanoUI every MC tick.
var/list/initial_data // The data (and datastructure) used to initialize the NanoUI
var/status = NANO_INTERACTIVE // The status/visibility of the NanoUI.
var/datum/topic_state/state = null // Topic state used to determine status. Topic states are in interactions/.
var/datum/nanoui/master_ui // The parent NanoUI.
var/list/datum/nanoui/children = list() // Children of this NanoUI.
/**
* public
*
* Create a new NanoUI.
*
* required user mob The mob who opened/is using the NanoUI.
* required src_object atom/movable The object which owns the NanoUI.
* required ui_key string The ui_key of the NanoUI.
* required template string The template to render the NanoUI content with.
* optional title string The title of the NanoUI.
* optional width int The window width.
* optional height int The window height.
* optional ref atom An extra ref to use when the window is closed.
* optional master_ui datum/nanoui The parent NanoUI.
* optional state datum/topic_state The state used to determine status.
*
* return datum/nanoui The requested NanoUI.
**/
/datum/nanoui/New(mob/user, atom/movable/src_object, ui_key, template, \
title = 0, width = 0, height = 0, \
atom/ref = null, datum/nanoui/master_ui = null, \
datum/topic_state/state = default_state)
src.user = user
src.src_object = src_object
src.ui_key = ui_key
src.window_id = "\ref[src_object]-[ui_key]"
set_template(template)
if (title)
src.title = sanitize(title)
if (width)
src.width = width
if (height)
src.height = height
if (ref)
src.ref = ref
src.master_ui = master_ui
if(master_ui)
master_ui.children += src
src.state = state
var/datum/asset/assets = get_asset_datum(/datum/asset/simple/nanoui)
assets.send(user)
/**
* public
*
* Enable/disable auto-updating of the NanoUI.
*
* required state bool Enable/disable auto-updating.
**/
/datum/nanoui/proc/set_auto_update(state = 1)
auto_update = state
/**
* private
*
* Set the data to initialize the NanoUI with.
* The datastructure cannot be changed by subsequent updates.
*
* optional data list The data/datastructure to initialize the NanoUI with.
**/
/datum/nanoui/proc/set_initial_data(list/data)
initial_data = data
/**
* private
*
* Get the config data/datastructure to initialize the NanoUI with.
*
* return list The config data.
**/
/datum/nanoui/proc/get_config_data()
var/list/config_data = list(
"title" = title,
"status" = status,
"ref" = "\ref[src]",
"window" = list(
"width" = width,
"height" = height,
"ref" = window_id
),
"user" = list(
"name" = user.name,
"fancy" = user.client.prefs.nanoui_fancy,
"ref" = "\ref[user]"
),
"srcObject" = list(
"name" = src_object.name,
"ref" = "\ref[src_object]"
),
"templates" = list(
"layout" = "_[layout]",
"content" = "[template]"
)
)
return config_data
/**
* private
*
* Package the data to send to the UI.
* This is the (regular) data and config data, bundled together.
*
* return list The packaged data.
**/
/datum/nanoui/proc/get_send_data(list/data)
var/list/send_data = list()
send_data["config"] = get_config_data()
if (!isnull(data))
send_data["data"] = data
return send_data
/**
* public
*
* Sets the browse() window options for this NanoUI.
*
* required window_options list The window options to set.
**/
/datum/nanoui/proc/set_window_options(list/window_options)
src.window_options = window_options
/**
* public
*
* Set the layout for this NanoUI.
* This loads custom layout styles and templates for this NanoUI.
*
* required layout string The new UI layout.
**/
/datum/nanoui/proc/set_layout(layout)
src.layout = lowertext(layout)
/**
* public
*
* Set the template for this NanoUI.
*
* required template string The new UI template.
**/
/datum/nanoui/proc/set_template(template)
src.template = lowertext(template)
/**
* private
*
* Generate HTML for this NanoUI.
*
* return string NanoUI HTML output.
**/
/datum/nanoui/proc/get_html()
// Generate <script> and <link> tags.
var/script_html = {"
<script type='text/javascript' src='nanoui.lib.js'></script>
<script type='text/javascript' src='nanoui.main.js'></script>
<script type='text/javascript' src='nanoui.templates.js'></script>
"}
var/stylesheet_html = {"
<link rel="stylesheet" type='text/css' href='http://css-spinners.com/css/spinner/hexdots.css'>
<link rel='stylesheet' type='text/css' href='nanoui.lib.css' />
<link rel='stylesheet' type='text/css' href='nanoui.common.css' />
<link rel='stylesheet' type='text/css' href='nanoui.[layout].css' />
"}
// Generate JSON.
var/list/send_data = get_send_data(initial_data)
var/initial_data_json = replacetext(JSON.stringify(send_data), "'", "\\'")
// Generate the HTML document.
return {"
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<script type='text/javascript'>
function receiveUpdate(dataString) {
if (typeof NanoBus !== 'undefined') {
NanoBus.emit('serverUpdate', dataString);
}
};
</script>
[stylesheet_html]
[script_html]
</head>
<body>
<div id='data' data-initial='[initial_data_json]'></div>
<div id='layout'>
<div class='hexdots-loader' style='position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);-ms-transform:translate(-50%, -50%);'>
Sending Resources...
</div>
</div>
<noscript>
<h1>Javascript Required</h1>
<p>Javascript is required in order to use this NanoUI interface.</p>
<p>Please enable Javascript in Internet Explorer, and restart your game.</p>
</noscript>
</body>
</html>
"}
/**
* public
*
* Open this NanoUI (and initialize it with data).
*
* optional data list The data to intialize the UI with.
**/
/datum/nanoui/proc/open(list/data = null)
if(!user.client) return
if (!initial_data)
if (!data) // If we don't have initial_data and data was not passed, get data from the src_object.
data = src_object.get_ui_data(user)
set_initial_data(data) // Otherwise use the passed data.
var/window_size = ""
if (width && height) // If we have a width and height, use them.
window_size = "size=[width]x[height];"
update_status(push = 0) // Update the window state.
if (status == NANO_CLOSE)
return // Bail if we should close.
user << browse(get_html(), "window=[window_id];[window_size][list2params(window_options)]") // Open the window.
winset(user, window_id, "on-close=\"nanoclose \ref[src]\"") // Instruct the client to signal NanoUI when the window is closed.
SSnano.ui_opened(src) // Call the opened handler.
/**
* public
*
* Reinitialize the NanoUI.
* (Possibly with a new template and/or data).
*
* optional template string The filename of the new template.
* optional data list The new initial data.
**/
/datum/nanoui/proc/reinitialize(template, list/data)
if(template)
src.template = template // Set a new template.
if(data)
set_initial_data(data) // Replace the initial_data.
open()
/**
* public
*
* Close the NanoUI, and all its children.
**/
/datum/nanoui/proc/close()
set_auto_update(0) // Disable auto-updates.
user << browse(null, "window=[window_id]") // Close the window.
SSnano.ui_closed(src) // Call the closed handler.
for(var/datum/nanoui/child in children) // Loop through and close all children.
child.close()
/**
* private
*
* Push data to an already open NanoUI.
*
* required data list The data to send.
* optional force bool If the update should be sent regardless of state.
**/
/datum/nanoui/proc/push_data(data, force = 0)
update_status(push = 0) // Update the window state.
if (status == NANO_DISABLED && !force)
return // Cannot update UI, we have no visibility.
var/list/send_data = get_send_data(data) // Get the data to send.
// Send the new data to the recieveUpdate() Javascript function.
user << output(list2params(list(JSON.stringify(send_data))), "[window_id].browser:receiveUpdate")
/**
* private
*
* Handle clicks from the NanoUI.
* Call the src_object's Topic() if status is NANO_INTERACTIVE.
* If the src_object's Topic() returns 1, update all UIs attacked to it.
**/
/datum/nanoui/Topic(href, href_list)
update_status(push = 0) // Update the window state.
if (status != NANO_INTERACTIVE || user != usr)
return // If UI is not interactive or usr calling Topic is not the UI user.
var/action = href_list["nano"] // Pull the action out.
href_list -= "nano"
var/update = src_object.ui_act(action, href_list, state) // Call Topic() on the src_object.
if (src_object && update)
SSnano.update_uis(src_object) // If we have a src_object and its Topic() told us to update.
/**
* private
*
* Update the NanoUI. Only updates the contents/layout if update is true,
* otherwise only updates the status.
*
* optional force bool If the UI should be forced to update.
**/
/datum/nanoui/process(force = 0)
if (!src_object || !user) // If the object or user died (or something else), abort.
close()
return
if (status && (force || auto_update))
update() // Update the UI if the status and update settings allow it.
else
update_status(push = 1) // Otherwise only update status.
/**
* private
*
* Updates the UI by interacting with the src_object again, which will hopefully
* call try_ui_update on it.
*
* optional force_open bool If force_open should be passed to ui_interact.
**/
/datum/nanoui/proc/update(force_open = 0)
src_object.ui_interact(user, ui_key, src, force_open, master_ui, state)
/**
* private
*
* Set the status/visibility of the NanoUI.
*
* required state int The status to set (NANO_CLOSE/NANO_DISABLED/NANO_UPDATE/NANO_INTERACTIVE).
* optional push bool Push an update to the UI (an update is always sent for NANO_DISABLED).
**/
/datum/nanoui/proc/set_status(state, push = 0)
if (state != status) // Only update if status has changed.
if (status == NANO_DISABLED)
status = state
if (push)
update()
else
status = state
if (push || status == 0) // Force an update if NANO_DISABLED.
push_data(null, 1)
/**
* private
*
* Update the status/visibility of the NanoUI for its user.
*
* optional push bool Push an update to the UI (an update is always sent for NANO_DISABLED).
**/
/datum/nanoui/proc/update_status(push = 0)
var/new_status = src_object.CanUseTopic(user, state)
if(master_ui)
new_status = min(new_status, master_ui.status)
set_status(new_status, push)
if(new_status == NANO_CLOSE)
/**
* NanoUI
*
* Contains the NanoUI datum, and its procs.
*
* /tg/station user interface library
* thanks to baystation12
*
* modified by neersighted
**/
/**
* NanoUI datum:
*
* Represents a NanoUI.
**/
/datum/nanoui
var/mob/user // The mob who opened/is using the NanoUI.
var/atom/movable/src_object // The object which owns the NanoUI.
var/title // The title of te NanoUI.
var/ui_key // The ui_key of the NanoUI. This allows multiple UIs for one src_object.
var/window_id // The window_id for browse() and onclose().
var/width = 0 // The window width.
var/height = 0 // The window height
var/window_options = list( // Extra options to winset().
"focus" = 0,
"titlebar" = 1,
"can_resize" = 1,
"can_minimize" = 1,
"can_maximize" = 0,
"can_close" = 1,
"auto_format" = 0
)
var/atom/ref = null // An extra ref to call when the window is closed.
var/layout = "nanotrasen" // The layout to be used for this UI.
var/template // The template to be used for this UI.
var/auto_update = 1 // Update the NanoUI every MC tick.
var/list/initial_data // The data (and datastructure) used to initialize the NanoUI
var/status = NANO_INTERACTIVE // The status/visibility of the NanoUI.
var/datum/topic_state/state = null // Topic state used to determine status. Topic states are in interactions/.
var/datum/nanoui/master_ui // The parent NanoUI.
var/list/datum/nanoui/children = list() // Children of this NanoUI.
/**
* public
*
* Create a new NanoUI.
*
* required user mob The mob who opened/is using the NanoUI.
* required src_object atom/movable The object which owns the NanoUI.
* required ui_key string The ui_key of the NanoUI.
* required template string The template to render the NanoUI content with.
* optional title string The title of the NanoUI.
* optional width int The window width.
* optional height int The window height.
* optional ref atom An extra ref to use when the window is closed.
* optional master_ui datum/nanoui The parent NanoUI.
* optional state datum/topic_state The state used to determine status.
*
* return datum/nanoui The requested NanoUI.
**/
/datum/nanoui/New(mob/user, atom/movable/src_object, ui_key, template, \
title = 0, width = 0, height = 0, \
atom/ref = null, datum/nanoui/master_ui = null, \
datum/topic_state/state = default_state)
src.user = user
src.src_object = src_object
src.ui_key = ui_key
src.window_id = "\ref[src_object]-[ui_key]"
set_template(template)
if (title)
src.title = sanitize(title)
if (width)
src.width = width
if (height)
src.height = height
if (ref)
src.ref = ref
src.master_ui = master_ui
if(master_ui)
master_ui.children += src
src.state = state
var/datum/asset/assets = get_asset_datum(/datum/asset/simple/nanoui)
assets.send(user)
/**
* public
*
* Enable/disable auto-updating of the NanoUI.
*
* required state bool Enable/disable auto-updating.
**/
/datum/nanoui/proc/set_auto_update(state = 1)
auto_update = state
/**
* private
*
* Set the data to initialize the NanoUI with.
* The datastructure cannot be changed by subsequent updates.
*
* optional data list The data/datastructure to initialize the NanoUI with.
**/
/datum/nanoui/proc/set_initial_data(list/data)
initial_data = data
/**
* private
*
* Get the config data/datastructure to initialize the NanoUI with.
*
* return list The config data.
**/
/datum/nanoui/proc/get_config_data()
var/list/config_data = list(
"title" = title,
"status" = status,
"ref" = "\ref[src]",
"window" = list(
"width" = width,
"height" = height,
"ref" = window_id
),
"user" = list(
"name" = user.name,
"fancy" = user.client.prefs.nanoui_fancy,
"ref" = "\ref[user]"
),
"srcObject" = list(
"name" = src_object.name,
"ref" = "\ref[src_object]"
),
"templates" = list(
"layout" = "_[layout]",
"content" = "[template]"
)
)
return config_data
/**
* private
*
* Package the data to send to the UI.
* This is the (regular) data and config data, bundled together.
*
* return list The packaged data.
**/
/datum/nanoui/proc/get_send_data(list/data)
var/list/send_data = list()
send_data["config"] = get_config_data()
if (!isnull(data))
send_data["data"] = data
return send_data
/**
* public
*
* Sets the browse() window options for this NanoUI.
*
* required window_options list The window options to set.
**/
/datum/nanoui/proc/set_window_options(list/window_options)
src.window_options = window_options
/**
* public
*
* Set the layout for this NanoUI.
* This loads custom layout styles and templates for this NanoUI.
*
* required layout string The new UI layout.
**/
/datum/nanoui/proc/set_layout(layout)
src.layout = lowertext(layout)
/**
* public
*
* Set the template for this NanoUI.
*
* required template string The new UI template.
**/
/datum/nanoui/proc/set_template(template)
src.template = lowertext(template)
/**
* private
*
* Generate HTML for this NanoUI.
*
* return string NanoUI HTML output.
**/
/datum/nanoui/proc/get_html()
// Generate <script> and <link> tags.
var/script_html = {"
<script type='text/javascript' src='nanoui.lib.js'></script>
<script type='text/javascript' src='nanoui.main.js'></script>
<script type='text/javascript' src='nanoui.templates.js'></script>
"}
var/stylesheet_html = {"
<link rel="stylesheet" type='text/css' href='http://css-spinners.com/css/spinner/hexdots.css'>
<link rel='stylesheet' type='text/css' href='nanoui.lib.css' />
<link rel='stylesheet' type='text/css' href='nanoui.common.css' />
<link rel='stylesheet' type='text/css' href='nanoui.[layout].css' />
"}
// Generate JSON.
var/list/send_data = get_send_data(initial_data)
var/initial_data_json = replacetext(JSON.stringify(send_data), "'", "\\'")
// Generate the HTML document.
return {"
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<script type='text/javascript'>
function receiveUpdate(dataString) {
if (typeof NanoBus !== 'undefined') {
NanoBus.emit('serverUpdate', dataString);
}
};
</script>
[stylesheet_html]
[script_html]
</head>
<body>
<div id='data' data-initial='[initial_data_json]'></div>
<div id='layout'>
<div class='hexdots-loader' style='position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);-ms-transform:translate(-50%, -50%);'>
Sending Resources...
</div>
</div>
<noscript>
<h1>Javascript Required</h1>
<p>Javascript is required in order to use this NanoUI interface.</p>
<p>Please enable Javascript in Internet Explorer, and restart your game.</p>
</noscript>
</body>
</html>
"}
/**
* public
*
* Open this NanoUI (and initialize it with data).
*
* optional data list The data to intialize the UI with.
**/
/datum/nanoui/proc/open(list/data = null)
if(!user.client) return
if (!initial_data)
if (!data) // If we don't have initial_data and data was not passed, get data from the src_object.
data = src_object.get_ui_data(user)
set_initial_data(data) // Otherwise use the passed data.
var/window_size = ""
if (width && height) // If we have a width and height, use them.
window_size = "size=[width]x[height];"
update_status(push = 0) // Update the window state.
if (status == NANO_CLOSE)
return // Bail if we should close.
user << browse(get_html(), "window=[window_id];[window_size][list2params(window_options)]") // Open the window.
winset(user, window_id, "on-close=\"nanoclose \ref[src]\"") // Instruct the client to signal NanoUI when the window is closed.
SSnano.ui_opened(src) // Call the opened handler.
/**
* public
*
* Reinitialize the NanoUI.
* (Possibly with a new template and/or data).
*
* optional template string The filename of the new template.
* optional data list The new initial data.
**/
/datum/nanoui/proc/reinitialize(template, list/data)
if(template)
src.template = template // Set a new template.
if(data)
set_initial_data(data) // Replace the initial_data.
open()
/**
* public
*
* Close the NanoUI, and all its children.
**/
/datum/nanoui/proc/close()
set_auto_update(0) // Disable auto-updates.
user << browse(null, "window=[window_id]") // Close the window.
SSnano.ui_closed(src) // Call the closed handler.
for(var/datum/nanoui/child in children) // Loop through and close all children.
child.close()
/**
* private
*
* Push data to an already open NanoUI.
*
* required data list The data to send.
* optional force bool If the update should be sent regardless of state.
**/
/datum/nanoui/proc/push_data(data, force = 0)
update_status(push = 0) // Update the window state.
if (status == NANO_DISABLED && !force)
return // Cannot update UI, we have no visibility.
var/list/send_data = get_send_data(data) // Get the data to send.
// Send the new data to the recieveUpdate() Javascript function.
user << output(list2params(list(JSON.stringify(send_data))), "[window_id].browser:receiveUpdate")
/**
* private
*
* Handle clicks from the NanoUI.
* Call the src_object's Topic() if status is NANO_INTERACTIVE.
* If the src_object's Topic() returns 1, update all UIs attacked to it.
**/
/datum/nanoui/Topic(href, href_list)
update_status(push = 0) // Update the window state.
if (status != NANO_INTERACTIVE || user != usr)
return // If UI is not interactive or usr calling Topic is not the UI user.
var/action = href_list["nano"] // Pull the action out.
href_list -= "nano"
var/update = src_object.ui_act(action, href_list, state) // Call Topic() on the src_object.
if (src_object && update)
SSnano.update_uis(src_object) // If we have a src_object and its Topic() told us to update.
/**
* private
*
* Update the NanoUI. Only updates the contents/layout if update is true,
* otherwise only updates the status.
*
* optional force bool If the UI should be forced to update.
**/
/datum/nanoui/process(force = 0)
if (!src_object || !user) // If the object or user died (or something else), abort.
close()
return
if (status && (force || auto_update))
update() // Update the UI if the status and update settings allow it.
else
update_status(push = 1) // Otherwise only update status.
/**
* private
*
* Updates the UI by interacting with the src_object again, which will hopefully
* call try_ui_update on it.
*
* optional force_open bool If force_open should be passed to ui_interact.
**/
/datum/nanoui/proc/update(force_open = 0)
src_object.ui_interact(user, ui_key, src, force_open, master_ui, state)
/**
* private
*
* Set the status/visibility of the NanoUI.
*
* required state int The status to set (NANO_CLOSE/NANO_DISABLED/NANO_UPDATE/NANO_INTERACTIVE).
* optional push bool Push an update to the UI (an update is always sent for NANO_DISABLED).
**/
/datum/nanoui/proc/set_status(state, push = 0)
if (state != status) // Only update if status has changed.
if (status == NANO_DISABLED)
status = state
if (push)
update()
else
status = state
if (push || status == 0) // Force an update if NANO_DISABLED.
push_data(null, 1)
/**
* private
*
* Update the status/visibility of the NanoUI for its user.
*
* optional push bool Push an update to the UI (an update is always sent for NANO_DISABLED).
**/
/datum/nanoui/proc/update_status(push = 0)
var/new_status = src_object.CanUseTopic(user, state)
if(master_ui)
new_status = min(new_status, master_ui.status)
set_status(new_status, push)
if(new_status == NANO_CLOSE)
close()
+231 -231
View File
@@ -1,231 +1,231 @@
/**
* NanoUI Subsystem
*
* Contains all NanoUI state and subsystem code.
*
* /tg/station user interface library
* thanks to baystation12
*
* modified by neersighted
**/
/**
* public
*
* Get a open NanoUI given a user, src_object, and ui_key and try to update it with data.
*
* required user mob The mob who opened/is using the NanoUI.
* required src_object atom/movable The object which owns the NanoUI.
* required ui_key string The ui_key of the NanoUI.
* optional ui datum/nanoui The UI to be updated, if it exists.
* optional data list The data to update the UI with, if it exists.
* optional force_open bool If the UI should be re-opened instead of updated.
*
* return datum/nanoui The found NanoUI.
**/
/datum/subsystem/nano/proc/try_update_ui(mob/user, atom/movable/src_object, ui_key, datum/nanoui/ui, \
list/data = null, force_open = 0)
if (!data)
data = src_object.get_ui_data(user)
if (isnull(ui)) // No NanoUI was passed, so look for one.
ui = get_open_ui(user, src_object, ui_key)
if (!isnull(ui))
if (!force_open) // UI is already open; update it.
ui.push_data(data)
else // Re-open it anyways.
ui.reinitialize(null, data)
return ui // We found the UI, return it.
else
return null // We couldn't find a UI.
/**
* private
*
* Get a open NanoUI given a user, src_object, and ui_key.
*
* required user mob The mob who opened/is using the NanoUI.
* required src_object atom/movable The object which owns the NanoUI.
* required ui_key string The ui_key of the NanoUI.
*
* return datum/nanoui The found NanoUI.
**/
/datum/subsystem/nano/proc/get_open_ui(mob/user, atom/movable/src_object, ui_key)
var/src_object_key = "\ref[src_object]"
if (isnull(open_uis[src_object_key]) || !istype(open_uis[src_object_key], /list))
return null // No UIs open.
else if (isnull(open_uis[src_object_key][ui_key]) || !istype(open_uis[src_object_key][ui_key], /list))
return null // No UIs open for this object.
for (var/datum/nanoui/ui in open_uis[src_object_key][ui_key]) // Find UIs for this object.
if (ui.user == user) // Make sure we have the right user
return ui
return null // Couldn't find a UI!
/**
* private
*
* Update all NanoUIs attached to src_object.
*
* required src_object atom/movable The object which owns the NanoUIs.
*
* return int The number of NanoUIs updated.
**/
/datum/subsystem/nano/proc/update_uis(atom/movable/src_object)
var/src_object_key = "\ref[src_object]"
if (isnull(open_uis[src_object_key]) || !istype(open_uis[src_object_key], /list))
return 0 // Couldn't find any UIs for this object.
var/update_count = 0
for (var/ui_key in open_uis[src_object_key])
for (var/datum/nanoui/ui in open_uis[src_object_key][ui_key])
if(ui && ui.src_object && ui.user && ui.src_object.nano_host()) // Check the UI is valid.
ui.process(force = 1) // Update the UI.
update_count++ // Count each UI we update.
return update_count
/**
* private
*
* Close all NanoUIs attached to src_object.
*
* required src_object atom/movable The object which owns the NanoUIs.
*
* return int The number of NanoUIs closed.
**/
/datum/subsystem/nano/proc/close_uis(atom/movable/src_object)
var/src_object_key = "\ref[src_object]"
if (isnull(open_uis[src_object_key]) || !istype(open_uis[src_object_key], /list))
return 0 // Couldn't find any UIs for this object.
var/close_count = 0
for (var/ui_key in open_uis[src_object_key])
for (var/datum/nanoui/ui in open_uis[src_object_key][ui_key])
if(ui && ui.src_object && ui.user && ui.src_object.nano_host()) // Check the UI is valid.
ui.close() // Close the UI.
close_count++ // Count each UI we close.
return close_count
/**
* private
*
* Update all NanoUIs belonging to a user.
*
* required user mob The mob who opened/is using the NanoUI.
* optional src_object atom/movable If provided, only update UIs belonging this atom.
* optional ui_key string If provided, only update UIs with this UI key.
*
* return int The number of NanoUIs updated.
**/
/datum/subsystem/nano/proc/update_user_uis(mob/user, atom/movable/src_object = null, ui_key = null)
if (isnull(user.open_uis) || !istype(user.open_uis, /list) || open_uis.len == 0)
return 0 // Couldn't find any UIs for this user.
var/update_count = 0
for (var/datum/nanoui/ui in user.open_uis)
if ((isnull(src_object) || !isnull(src_object) && ui.src_object == src_object) && (isnull(ui_key) || !isnull(ui_key) && ui.ui_key == ui_key))
ui.process(force = 1) // Update the UI.
update_count++ // Count each UI we upadte.
return update_count
/**
* private
*
* Close all NanoUIs belonging to a user.
*
* required user mob The mob who opened/is using the NanoUI.
* optional src_object atom/movable If provided, only update UIs belonging this atom.
* optional ui_key string If provided, only update UIs with this UI key.
*
* return int The number of NanoUIs closed.
**/
/datum/subsystem/nano/proc/close_user_uis(mob/user, atom/movable/src_object = null, ui_key = null)
if (isnull(user.open_uis) || !istype(user.open_uis, /list) || open_uis.len == 0)
return 0 // Couldn't find any UIs for this user.
var/close_count = 0
for (var/datum/nanoui/ui in user.open_uis)
if ((isnull(src_object) || !isnull(src_object) && ui.src_object == src_object) && (isnull(ui_key) || !isnull(ui_key) && ui.ui_key == ui_key))
ui.close() // Close the UI.
close_count++ // Count each UI we close.
return close_count
/**
* private
*
* Add a NanoUI to the list of open UIs.
*
* required ui datum/nanoui The UI to be added.
**/
/datum/subsystem/nano/proc/ui_opened(datum/nanoui/ui)
var/src_object_key = "\ref[ui.src_object]"
if (isnull(open_uis[src_object_key]) || !istype(open_uis[src_object_key], /list))
open_uis[src_object_key] = list(ui.ui_key = list()) // Make a list for the ui_key and src_object.
else if (isnull(open_uis[src_object_key][ui.ui_key]) || !istype(open_uis[src_object_key][ui.ui_key], /list))
open_uis[src_object_key][ui.ui_key] = list() // Make a list for the ui_key.
// Append the UI to all the lists.
ui.user.open_uis |= ui
var/list/uis = open_uis[src_object_key][ui.ui_key]
uis |= ui
processing_uis |= ui
/**
* private
*
* Remove a NanoUI from the list of open UIs.
*
* required ui datum/nanoui The UI to be removed.
*
* return bool If the UI was removed or not.
**/
/datum/subsystem/nano/proc/ui_closed(datum/nanoui/ui)
var/src_object_key = "\ref[ui.src_object]"
if (isnull(open_uis[src_object_key]) || !istype(open_uis[src_object_key], /list))
return 0 // It wasn't open.
else if (isnull(open_uis[src_object_key][ui.ui_key]) || !istype(open_uis[src_object_key][ui.ui_key], /list))
return 0 // It wasn't open.
processing_uis.Remove(ui) // Remove it from the list of processing UIs.
if(ui.user) // If the user exists, remove it from them too.
ui.user.open_uis.Remove(ui)
var/list/uis = open_uis[src_object_key][ui.ui_key] // Remove it from the list of open UIs.
uis.Remove(ui)
return 1 // Let the caller know we did it.
/**
* private
*
* Handle client logout, by closing all their NanoUIs.
*
* required user mob The mob which logged out.
*
* return int The number of NanoUIs closed.
**/
/datum/subsystem/nano/proc/user_logout(mob/user)
return close_user_uis(user)
/**
* private
*
* Handle clients switching mobs, by transfering their NanoUIs.
*
* required user oldMob The client's original mob.
* required user newMob The client's new mob.
*
* return bool If the NanoUIs were transferred.
**/
/datum/subsystem/nano/proc/user_transferred(mob/oldMob, mob/newMob)
if (!oldMob || isnull(oldMob.open_uis) || !istype(oldMob.open_uis, /list) || open_uis.len == 0)
return 0 // The old mob had no open NanoUIs.
if (isnull(newMob.open_uis) || !istype(newMob.open_uis, /list))
newMob.open_uis = list() // Create a list for the new mob if needed.
for (var/datum/nanoui/ui in oldMob.open_uis)
ui.user = newMob // Inform the UIs of their new owner.
newMob.open_uis.Add(ui) // Transfer all the NanoUIs.
oldMob.open_uis.Cut() // Clear the old list.
return 1 // Let the caller know we did it.
/**
* NanoUI Subsystem
*
* Contains all NanoUI state and subsystem code.
*
* /tg/station user interface library
* thanks to baystation12
*
* modified by neersighted
**/
/**
* public
*
* Get a open NanoUI given a user, src_object, and ui_key and try to update it with data.
*
* required user mob The mob who opened/is using the NanoUI.
* required src_object atom/movable The object which owns the NanoUI.
* required ui_key string The ui_key of the NanoUI.
* optional ui datum/nanoui The UI to be updated, if it exists.
* optional data list The data to update the UI with, if it exists.
* optional force_open bool If the UI should be re-opened instead of updated.
*
* return datum/nanoui The found NanoUI.
**/
/datum/subsystem/nano/proc/try_update_ui(mob/user, atom/movable/src_object, ui_key, datum/nanoui/ui, \
list/data = null, force_open = 0)
if (!data)
data = src_object.get_ui_data(user)
if (isnull(ui)) // No NanoUI was passed, so look for one.
ui = get_open_ui(user, src_object, ui_key)
if (!isnull(ui))
if (!force_open) // UI is already open; update it.
ui.push_data(data)
else // Re-open it anyways.
ui.reinitialize(null, data)
return ui // We found the UI, return it.
else
return null // We couldn't find a UI.
/**
* private
*
* Get a open NanoUI given a user, src_object, and ui_key.
*
* required user mob The mob who opened/is using the NanoUI.
* required src_object atom/movable The object which owns the NanoUI.
* required ui_key string The ui_key of the NanoUI.
*
* return datum/nanoui The found NanoUI.
**/
/datum/subsystem/nano/proc/get_open_ui(mob/user, atom/movable/src_object, ui_key)
var/src_object_key = "\ref[src_object]"
if (isnull(open_uis[src_object_key]) || !istype(open_uis[src_object_key], /list))
return null // No UIs open.
else if (isnull(open_uis[src_object_key][ui_key]) || !istype(open_uis[src_object_key][ui_key], /list))
return null // No UIs open for this object.
for (var/datum/nanoui/ui in open_uis[src_object_key][ui_key]) // Find UIs for this object.
if (ui.user == user) // Make sure we have the right user
return ui
return null // Couldn't find a UI!
/**
* private
*
* Update all NanoUIs attached to src_object.
*
* required src_object atom/movable The object which owns the NanoUIs.
*
* return int The number of NanoUIs updated.
**/
/datum/subsystem/nano/proc/update_uis(atom/movable/src_object)
var/src_object_key = "\ref[src_object]"
if (isnull(open_uis[src_object_key]) || !istype(open_uis[src_object_key], /list))
return 0 // Couldn't find any UIs for this object.
var/update_count = 0
for (var/ui_key in open_uis[src_object_key])
for (var/datum/nanoui/ui in open_uis[src_object_key][ui_key])
if(ui && ui.src_object && ui.user && ui.src_object.nano_host()) // Check the UI is valid.
ui.process(force = 1) // Update the UI.
update_count++ // Count each UI we update.
return update_count
/**
* private
*
* Close all NanoUIs attached to src_object.
*
* required src_object atom/movable The object which owns the NanoUIs.
*
* return int The number of NanoUIs closed.
**/
/datum/subsystem/nano/proc/close_uis(atom/movable/src_object)
var/src_object_key = "\ref[src_object]"
if (isnull(open_uis[src_object_key]) || !istype(open_uis[src_object_key], /list))
return 0 // Couldn't find any UIs for this object.
var/close_count = 0
for (var/ui_key in open_uis[src_object_key])
for (var/datum/nanoui/ui in open_uis[src_object_key][ui_key])
if(ui && ui.src_object && ui.user && ui.src_object.nano_host()) // Check the UI is valid.
ui.close() // Close the UI.
close_count++ // Count each UI we close.
return close_count
/**
* private
*
* Update all NanoUIs belonging to a user.
*
* required user mob The mob who opened/is using the NanoUI.
* optional src_object atom/movable If provided, only update UIs belonging this atom.
* optional ui_key string If provided, only update UIs with this UI key.
*
* return int The number of NanoUIs updated.
**/
/datum/subsystem/nano/proc/update_user_uis(mob/user, atom/movable/src_object = null, ui_key = null)
if (isnull(user.open_uis) || !istype(user.open_uis, /list) || open_uis.len == 0)
return 0 // Couldn't find any UIs for this user.
var/update_count = 0
for (var/datum/nanoui/ui in user.open_uis)
if ((isnull(src_object) || !isnull(src_object) && ui.src_object == src_object) && (isnull(ui_key) || !isnull(ui_key) && ui.ui_key == ui_key))
ui.process(force = 1) // Update the UI.
update_count++ // Count each UI we upadte.
return update_count
/**
* private
*
* Close all NanoUIs belonging to a user.
*
* required user mob The mob who opened/is using the NanoUI.
* optional src_object atom/movable If provided, only update UIs belonging this atom.
* optional ui_key string If provided, only update UIs with this UI key.
*
* return int The number of NanoUIs closed.
**/
/datum/subsystem/nano/proc/close_user_uis(mob/user, atom/movable/src_object = null, ui_key = null)
if (isnull(user.open_uis) || !istype(user.open_uis, /list) || open_uis.len == 0)
return 0 // Couldn't find any UIs for this user.
var/close_count = 0
for (var/datum/nanoui/ui in user.open_uis)
if ((isnull(src_object) || !isnull(src_object) && ui.src_object == src_object) && (isnull(ui_key) || !isnull(ui_key) && ui.ui_key == ui_key))
ui.close() // Close the UI.
close_count++ // Count each UI we close.
return close_count
/**
* private
*
* Add a NanoUI to the list of open UIs.
*
* required ui datum/nanoui The UI to be added.
**/
/datum/subsystem/nano/proc/ui_opened(datum/nanoui/ui)
var/src_object_key = "\ref[ui.src_object]"
if (isnull(open_uis[src_object_key]) || !istype(open_uis[src_object_key], /list))
open_uis[src_object_key] = list(ui.ui_key = list()) // Make a list for the ui_key and src_object.
else if (isnull(open_uis[src_object_key][ui.ui_key]) || !istype(open_uis[src_object_key][ui.ui_key], /list))
open_uis[src_object_key][ui.ui_key] = list() // Make a list for the ui_key.
// Append the UI to all the lists.
ui.user.open_uis |= ui
var/list/uis = open_uis[src_object_key][ui.ui_key]
uis |= ui
processing_uis |= ui
/**
* private
*
* Remove a NanoUI from the list of open UIs.
*
* required ui datum/nanoui The UI to be removed.
*
* return bool If the UI was removed or not.
**/
/datum/subsystem/nano/proc/ui_closed(datum/nanoui/ui)
var/src_object_key = "\ref[ui.src_object]"
if (isnull(open_uis[src_object_key]) || !istype(open_uis[src_object_key], /list))
return 0 // It wasn't open.
else if (isnull(open_uis[src_object_key][ui.ui_key]) || !istype(open_uis[src_object_key][ui.ui_key], /list))
return 0 // It wasn't open.
processing_uis.Remove(ui) // Remove it from the list of processing UIs.
if(ui.user) // If the user exists, remove it from them too.
ui.user.open_uis.Remove(ui)
var/list/uis = open_uis[src_object_key][ui.ui_key] // Remove it from the list of open UIs.
uis.Remove(ui)
return 1 // Let the caller know we did it.
/**
* private
*
* Handle client logout, by closing all their NanoUIs.
*
* required user mob The mob which logged out.
*
* return int The number of NanoUIs closed.
**/
/datum/subsystem/nano/proc/user_logout(mob/user)
return close_user_uis(user)
/**
* private
*
* Handle clients switching mobs, by transfering their NanoUIs.
*
* required user oldMob The client's original mob.
* required user newMob The client's new mob.
*
* return bool If the NanoUIs were transferred.
**/
/datum/subsystem/nano/proc/user_transferred(mob/oldMob, mob/newMob)
if (!oldMob || isnull(oldMob.open_uis) || !istype(oldMob.open_uis, /list) || open_uis.len == 0)
return 0 // The old mob had no open NanoUIs.
if (isnull(newMob.open_uis) || !istype(newMob.open_uis, /list))
newMob.open_uis = list() // Create a list for the new mob if needed.
for (var/datum/nanoui/ui in oldMob.open_uis)
ui.user = newMob // Inform the UIs of their new owner.
newMob.open_uis.Add(ui) // Transfer all the NanoUIs.
oldMob.open_uis.Cut() // Clear the old list.
return 1 // Let the caller know we did it.
File diff suppressed because one or more lines are too long
+1190 -1190
View File
File diff suppressed because it is too large Load Diff
+418 -418
View File
@@ -1,418 +1,418 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
/obj/singularity
name = "gravitational singularity"
desc = "A gravitational singularity."
icon = 'icons/obj/singularity.dmi'
icon_state = "singularity_s1"
anchored = 1
density = 1
layer = 6
luminosity = 6
unacidable = 1 //Don't comment this out.
var/current_size = 1
var/allowed_size = 1
var/contained = 1 //Are we going to move around?
var/energy = 100 //How strong are we?
var/dissipate = 1 //Do we lose energy over time?
var/dissipate_delay = 10
var/dissipate_track = 0
var/dissipate_strength = 1 //How much energy do we lose?
var/move_self = 1 //Do we move on our own?
var/grav_pull = 4 //How many tiles out do we pull?
var/consume_range = 0 //How many tiles out do we eat
var/event_chance = 15 //Prob for event each tick
var/target = null //its target. moves towards the target if it has one
var/last_failed_movement = 0//Will not move in the same dir if it couldnt before, will help with the getting stuck on fields thing
var/last_warning
var/consumedSupermatter = 0 //If the singularity has eaten a supermatter shard and can go to stage six
/obj/singularity/New(loc, var/starting_energy = 50, var/temp = 0)
//CARN: admin-alert for chuckle-fuckery.
admin_investigate_setup()
src.energy = starting_energy
..()
SSobj.processing |= src
poi_list |= src
for(var/obj/machinery/power/singularity_beacon/singubeacon in machines)
if(singubeacon.active)
target = singubeacon
break
return
/obj/singularity/Destroy()
SSobj.processing.Remove(src)
poi_list.Remove(src)
return ..()
/obj/singularity/Move(atom/newloc, direct)
if(current_size >= STAGE_FIVE || check_turfs_in(direct))
last_failed_movement = 0//Reset this because we moved
return ..()
else
last_failed_movement = direct
return 0
/obj/singularity/attack_hand(mob/user)
consume(user)
return 1
/obj/singularity/Process_Spacemove() //The singularity stops drifting for no man!
return 0
/obj/singularity/blob_act(severity)
return
/obj/singularity/ex_act(severity, target)
switch(severity)
if(1)
if(current_size <= STAGE_TWO)
investigate_log("has been destroyed by a heavy explosion.","singulo")
qdel(src)
return
else
energy -= round(((energy+1)/2),1)
if(2)
energy -= round(((energy+1)/3),1)
if(3)
energy -= round(((energy+1)/4),1)
return
/obj/singularity/bullet_act(obj/item/projectile/P)
return 0 //Will there be an impact? Who knows. Will we see it? No.
/obj/singularity/Bump(atom/A)
consume(A)
return
/obj/singularity/Bumped(atom/A)
consume(A)
return
/obj/singularity/process()
if(current_size >= STAGE_TWO)
move()
pulse()
if(prob(event_chance))//Chance for it to run a special event TODO:Come up with one or two more that fit
event()
eat()
dissipate()
check_energy()
return
/obj/singularity/attack_ai() //to prevent ais from gibbing themselves when they click on one.
return
/obj/singularity/proc/admin_investigate_setup()
last_warning = world.time
var/count = locate(/obj/machinery/field/containment) in ultra_range(30, src, 1)
if(!count) message_admins("A singulo has been created without containment fields active ([x],[y],[z])",1)
investigate_log("was created. [count?"":"<font color='red'>No containment fields were active</font>"]","singulo")
/obj/singularity/proc/dissipate()
if(!dissipate)
return
if(dissipate_track >= dissipate_delay)
src.energy -= dissipate_strength
dissipate_track = 0
else
dissipate_track++
/obj/singularity/proc/expand(force_size = 0)
var/temp_allowed_size = src.allowed_size
if(force_size)
temp_allowed_size = force_size
if(temp_allowed_size >= STAGE_SIX && !consumedSupermatter)
temp_allowed_size = STAGE_FIVE
switch(temp_allowed_size)
if(STAGE_ONE)
current_size = STAGE_ONE
icon = 'icons/obj/singularity.dmi'
icon_state = "singularity_s1"
pixel_x = 0
pixel_y = 0
grav_pull = 4
consume_range = 0
dissipate_delay = 10
dissipate_track = 0
dissipate_strength = 1
if(STAGE_TWO)//1 to 3 does not check for the turfs if you put the gens right next to a 1x1 then its going to eat them
current_size = STAGE_TWO
icon = 'icons/effects/96x96.dmi'
icon_state = "singularity_s3"
pixel_x = -32
pixel_y = -32
grav_pull = 6
consume_range = 1
dissipate_delay = 5
dissipate_track = 0
dissipate_strength = 5
if(STAGE_THREE)
if((check_turfs_in(1,2))&&(check_turfs_in(2,2))&&(check_turfs_in(4,2))&&(check_turfs_in(8,2)))
current_size = STAGE_THREE
icon = 'icons/effects/160x160.dmi'
icon_state = "singularity_s5"
pixel_x = -64
pixel_y = -64
grav_pull = 8
consume_range = 2
dissipate_delay = 4
dissipate_track = 0
dissipate_strength = 20
if(STAGE_FOUR)
if((check_turfs_in(1,3))&&(check_turfs_in(2,3))&&(check_turfs_in(4,3))&&(check_turfs_in(8,3)))
current_size = STAGE_FOUR
icon = 'icons/effects/224x224.dmi'
icon_state = "singularity_s7"
pixel_x = -96
pixel_y = -96
grav_pull = 10
consume_range = 3
dissipate_delay = 10
dissipate_track = 0
dissipate_strength = 10
if(STAGE_FIVE)//this one also lacks a check for gens because it eats everything
current_size = STAGE_FIVE
icon = 'icons/effects/288x288.dmi'
icon_state = "singularity_s9"
pixel_x = -128
pixel_y = -128
grav_pull = 10
consume_range = 4
dissipate = 0 //It cant go smaller due to e loss
if(STAGE_SIX) //This only happens if a stage 5 singulo consumes a supermatter shard.
current_size = STAGE_SIX
icon = 'icons/effects/352x352.dmi'
icon_state = "singularity_s11"
pixel_x = -160
pixel_y = -160
grav_pull = 15
consume_range = 5
dissipate = 0
if(current_size == allowed_size)
investigate_log("<font color='red'>grew to size [current_size]</font>","singulo")
return 1
else if(current_size < (--temp_allowed_size))
expand(temp_allowed_size)
else
return 0
/obj/singularity/proc/check_energy()
if(energy <= 0)
investigate_log("collapsed.","singulo")
qdel(src)
return 0
switch(energy)//Some of these numbers might need to be changed up later -Mport
if(1 to 199)
allowed_size = STAGE_ONE
if(200 to 499)
allowed_size = STAGE_TWO
if(500 to 999)
allowed_size = STAGE_THREE
if(1000 to 1999)
allowed_size = STAGE_FOUR
if(2000 to INFINITY)
if(energy >= 3000 && consumedSupermatter)
allowed_size = STAGE_SIX
else
allowed_size = STAGE_FIVE
if(current_size != allowed_size)
expand()
return 1
/obj/singularity/proc/eat()
set background = BACKGROUND_ENABLED
var/list/L = grav_pull > 8 ? ultra_range(grav_pull, src, 1) : orange(grav_pull, src)
for(var/atom/X in L)
var/dist = get_dist(X, src)
var/obj/singularity/S = src
if(dist > consume_range)
X.singularity_pull(S, current_size)
else if(dist <= consume_range)
consume(X)
return
/obj/singularity/proc/consume(atom/A)
var/gain = A.singularity_act(current_size, src)
src.energy += gain
if(istype(A, /obj/machinery/power/supermatter_shard) && !consumedSupermatter)
desc = "[initial(desc)] It glows fiercely with inner fire."
name = "supermatter-charged [initial(name)]"
consumedSupermatter = 1
luminosity = 10
return
/obj/singularity/proc/move(force_move = 0)
if(!move_self)
return 0
var/movement_dir = pick(alldirs - last_failed_movement)
if(force_move)
movement_dir = force_move
if(target && prob(60))
movement_dir = get_dir(src,target) //moves to a singulo beacon, if there is one
step(src, movement_dir)
/obj/singularity/proc/check_turfs_in(direction = 0, step = 0)
if(!direction)
return 0
var/steps = 0
if(!step)
switch(current_size)
if(STAGE_ONE)
steps = 1
if(STAGE_TWO)
steps = 3//Yes this is right
if(STAGE_THREE)
steps = 3
if(STAGE_FOUR)
steps = 4
if(STAGE_FIVE)
steps = 5
else
steps = step
var/list/turfs = list()
var/turf/T = src.loc
for(var/i = 1 to steps)
T = get_step(T,direction)
if(!isturf(T))
return 0
turfs.Add(T)
var/dir2 = 0
var/dir3 = 0
switch(direction)
if(NORTH||SOUTH)
dir2 = 4
dir3 = 8
if(EAST||WEST)
dir2 = 1
dir3 = 2
var/turf/T2 = T
for(var/j = 1 to steps-1)
T2 = get_step(T2,dir2)
if(!isturf(T2))
return 0
turfs.Add(T2)
for(var/k = 1 to steps-1)
T = get_step(T,dir3)
if(!isturf(T))
return 0
turfs.Add(T)
for(var/turf/T3 in turfs)
if(isnull(T3))
continue
if(!can_move(T3))
return 0
return 1
/obj/singularity/proc/can_move(turf/T)
if(!T)
return 0
if((locate(/obj/machinery/field/containment) in T)||(locate(/obj/machinery/shieldwall) in T))
return 0
else if(locate(/obj/machinery/field/generator) in T)
var/obj/machinery/field/generator/G = locate(/obj/machinery/field/generator) in T
if(G && G.active)
return 0
else if(locate(/obj/machinery/shieldwallgen) in T)
var/obj/machinery/shieldwallgen/S = locate(/obj/machinery/shieldwallgen) in T
if(S && S.active)
return 0
return 1
/obj/singularity/proc/event()
var/numb = pick(1,2,3,4,5,6)
switch(numb)
if(1)//EMP
emp_area()
if(2,3)//tox damage all carbon mobs in area
toxmob()
if(4)//Stun mobs who lack optic scanners
mezzer()
if(5,6) //Sets all nearby mobs on fire
if(current_size < STAGE_SIX)
return 0
combust_mobs()
else
return 0
return 1
/obj/singularity/proc/toxmob()
var/toxrange = 10
var/radiation = 15
var/radiationmin = 3
if (energy>200)
radiation += round((energy-150)/10,1)
radiationmin = round((radiation/5),1)
for(var/mob/living/M in view(toxrange, src.loc))
M.rad_act(rand(radiationmin,radiation))
/obj/singularity/proc/combust_mobs()
for(var/mob/living/carbon/C in ultra_range(20, src, 1))
C.visible_message("<span class='warning'>[C]'s skin bursts into flame!</span>", \
"<span class='userdanger'>You feel an inner fire as your skin bursts into flames!</span>")
C.adjust_fire_stacks(5)
C.IgniteMob()
return
/obj/singularity/proc/mezzer()
for(var/mob/living/carbon/M in oviewers(8, src))
if(istype(M, /mob/living/carbon/brain)) //Ignore brains
continue
if(M.stat == CONSCIOUS)
if (istype(M,/mob/living/carbon/human))
var/mob/living/carbon/human/H = M
if(istype(H.glasses, /obj/item/clothing/glasses/meson))
var/obj/item/clothing/glasses/meson/MS = H.glasses
if(MS.vision_flags == SEE_TURFS)
H << "<span class='notice'>You look directly into the [src.name], good thing you had your protective eyewear on!</span>"
return
M.apply_effect(3, STUN)
M.visible_message("<span class='danger'>[M] stares blankly at the [src.name]!</span>", \
"<span class='userdanger'>You look directly into the [src.name] and feel weak.</span>")
return
/obj/singularity/proc/emp_area()
empulse(src, 8, 10)
return
/obj/singularity/proc/pulse()
for(var/obj/machinery/power/rad_collector/R in rad_collectors)
if(get_dist(R, src) <= 15) // Better than using orange() every process
R.receive_pulse(energy)
return
/obj/singularity/singularity_act()
var/gain = (energy/2)
var/dist = max((current_size - 2),1)
explosion(src.loc,(dist),(dist*2),(dist*4))
qdel(src)
return(gain)
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
/obj/singularity
name = "gravitational singularity"
desc = "A gravitational singularity."
icon = 'icons/obj/singularity.dmi'
icon_state = "singularity_s1"
anchored = 1
density = 1
layer = 6
luminosity = 6
unacidable = 1 //Don't comment this out.
var/current_size = 1
var/allowed_size = 1
var/contained = 1 //Are we going to move around?
var/energy = 100 //How strong are we?
var/dissipate = 1 //Do we lose energy over time?
var/dissipate_delay = 10
var/dissipate_track = 0
var/dissipate_strength = 1 //How much energy do we lose?
var/move_self = 1 //Do we move on our own?
var/grav_pull = 4 //How many tiles out do we pull?
var/consume_range = 0 //How many tiles out do we eat
var/event_chance = 15 //Prob for event each tick
var/target = null //its target. moves towards the target if it has one
var/last_failed_movement = 0//Will not move in the same dir if it couldnt before, will help with the getting stuck on fields thing
var/last_warning
var/consumedSupermatter = 0 //If the singularity has eaten a supermatter shard and can go to stage six
/obj/singularity/New(loc, var/starting_energy = 50, var/temp = 0)
//CARN: admin-alert for chuckle-fuckery.
admin_investigate_setup()
src.energy = starting_energy
..()
SSobj.processing |= src
poi_list |= src
for(var/obj/machinery/power/singularity_beacon/singubeacon in machines)
if(singubeacon.active)
target = singubeacon
break
return
/obj/singularity/Destroy()
SSobj.processing.Remove(src)
poi_list.Remove(src)
return ..()
/obj/singularity/Move(atom/newloc, direct)
if(current_size >= STAGE_FIVE || check_turfs_in(direct))
last_failed_movement = 0//Reset this because we moved
return ..()
else
last_failed_movement = direct
return 0
/obj/singularity/attack_hand(mob/user)
consume(user)
return 1
/obj/singularity/Process_Spacemove() //The singularity stops drifting for no man!
return 0
/obj/singularity/blob_act(severity)
return
/obj/singularity/ex_act(severity, target)
switch(severity)
if(1)
if(current_size <= STAGE_TWO)
investigate_log("has been destroyed by a heavy explosion.","singulo")
qdel(src)
return
else
energy -= round(((energy+1)/2),1)
if(2)
energy -= round(((energy+1)/3),1)
if(3)
energy -= round(((energy+1)/4),1)
return
/obj/singularity/bullet_act(obj/item/projectile/P)
return 0 //Will there be an impact? Who knows. Will we see it? No.
/obj/singularity/Bump(atom/A)
consume(A)
return
/obj/singularity/Bumped(atom/A)
consume(A)
return
/obj/singularity/process()
if(current_size >= STAGE_TWO)
move()
pulse()
if(prob(event_chance))//Chance for it to run a special event TODO:Come up with one or two more that fit
event()
eat()
dissipate()
check_energy()
return
/obj/singularity/attack_ai() //to prevent ais from gibbing themselves when they click on one.
return
/obj/singularity/proc/admin_investigate_setup()
last_warning = world.time
var/count = locate(/obj/machinery/field/containment) in ultra_range(30, src, 1)
if(!count) message_admins("A singulo has been created without containment fields active ([x],[y],[z])",1)
investigate_log("was created. [count?"":"<font color='red'>No containment fields were active</font>"]","singulo")
/obj/singularity/proc/dissipate()
if(!dissipate)
return
if(dissipate_track >= dissipate_delay)
src.energy -= dissipate_strength
dissipate_track = 0
else
dissipate_track++
/obj/singularity/proc/expand(force_size = 0)
var/temp_allowed_size = src.allowed_size
if(force_size)
temp_allowed_size = force_size
if(temp_allowed_size >= STAGE_SIX && !consumedSupermatter)
temp_allowed_size = STAGE_FIVE
switch(temp_allowed_size)
if(STAGE_ONE)
current_size = STAGE_ONE
icon = 'icons/obj/singularity.dmi'
icon_state = "singularity_s1"
pixel_x = 0
pixel_y = 0
grav_pull = 4
consume_range = 0
dissipate_delay = 10
dissipate_track = 0
dissipate_strength = 1
if(STAGE_TWO)//1 to 3 does not check for the turfs if you put the gens right next to a 1x1 then its going to eat them
current_size = STAGE_TWO
icon = 'icons/effects/96x96.dmi'
icon_state = "singularity_s3"
pixel_x = -32
pixel_y = -32
grav_pull = 6
consume_range = 1
dissipate_delay = 5
dissipate_track = 0
dissipate_strength = 5
if(STAGE_THREE)
if((check_turfs_in(1,2))&&(check_turfs_in(2,2))&&(check_turfs_in(4,2))&&(check_turfs_in(8,2)))
current_size = STAGE_THREE
icon = 'icons/effects/160x160.dmi'
icon_state = "singularity_s5"
pixel_x = -64
pixel_y = -64
grav_pull = 8
consume_range = 2
dissipate_delay = 4
dissipate_track = 0
dissipate_strength = 20
if(STAGE_FOUR)
if((check_turfs_in(1,3))&&(check_turfs_in(2,3))&&(check_turfs_in(4,3))&&(check_turfs_in(8,3)))
current_size = STAGE_FOUR
icon = 'icons/effects/224x224.dmi'
icon_state = "singularity_s7"
pixel_x = -96
pixel_y = -96
grav_pull = 10
consume_range = 3
dissipate_delay = 10
dissipate_track = 0
dissipate_strength = 10
if(STAGE_FIVE)//this one also lacks a check for gens because it eats everything
current_size = STAGE_FIVE
icon = 'icons/effects/288x288.dmi'
icon_state = "singularity_s9"
pixel_x = -128
pixel_y = -128
grav_pull = 10
consume_range = 4
dissipate = 0 //It cant go smaller due to e loss
if(STAGE_SIX) //This only happens if a stage 5 singulo consumes a supermatter shard.
current_size = STAGE_SIX
icon = 'icons/effects/352x352.dmi'
icon_state = "singularity_s11"
pixel_x = -160
pixel_y = -160
grav_pull = 15
consume_range = 5
dissipate = 0
if(current_size == allowed_size)
investigate_log("<font color='red'>grew to size [current_size]</font>","singulo")
return 1
else if(current_size < (--temp_allowed_size))
expand(temp_allowed_size)
else
return 0
/obj/singularity/proc/check_energy()
if(energy <= 0)
investigate_log("collapsed.","singulo")
qdel(src)
return 0
switch(energy)//Some of these numbers might need to be changed up later -Mport
if(1 to 199)
allowed_size = STAGE_ONE
if(200 to 499)
allowed_size = STAGE_TWO
if(500 to 999)
allowed_size = STAGE_THREE
if(1000 to 1999)
allowed_size = STAGE_FOUR
if(2000 to INFINITY)
if(energy >= 3000 && consumedSupermatter)
allowed_size = STAGE_SIX
else
allowed_size = STAGE_FIVE
if(current_size != allowed_size)
expand()
return 1
/obj/singularity/proc/eat()
set background = BACKGROUND_ENABLED
var/list/L = grav_pull > 8 ? ultra_range(grav_pull, src, 1) : orange(grav_pull, src)
for(var/atom/X in L)
var/dist = get_dist(X, src)
var/obj/singularity/S = src
if(dist > consume_range)
X.singularity_pull(S, current_size)
else if(dist <= consume_range)
consume(X)
return
/obj/singularity/proc/consume(atom/A)
var/gain = A.singularity_act(current_size, src)
src.energy += gain
if(istype(A, /obj/machinery/power/supermatter_shard) && !consumedSupermatter)
desc = "[initial(desc)] It glows fiercely with inner fire."
name = "supermatter-charged [initial(name)]"
consumedSupermatter = 1
luminosity = 10
return
/obj/singularity/proc/move(force_move = 0)
if(!move_self)
return 0
var/movement_dir = pick(alldirs - last_failed_movement)
if(force_move)
movement_dir = force_move
if(target && prob(60))
movement_dir = get_dir(src,target) //moves to a singulo beacon, if there is one
step(src, movement_dir)
/obj/singularity/proc/check_turfs_in(direction = 0, step = 0)
if(!direction)
return 0
var/steps = 0
if(!step)
switch(current_size)
if(STAGE_ONE)
steps = 1
if(STAGE_TWO)
steps = 3//Yes this is right
if(STAGE_THREE)
steps = 3
if(STAGE_FOUR)
steps = 4
if(STAGE_FIVE)
steps = 5
else
steps = step
var/list/turfs = list()
var/turf/T = src.loc
for(var/i = 1 to steps)
T = get_step(T,direction)
if(!isturf(T))
return 0
turfs.Add(T)
var/dir2 = 0
var/dir3 = 0
switch(direction)
if(NORTH||SOUTH)
dir2 = 4
dir3 = 8
if(EAST||WEST)
dir2 = 1
dir3 = 2
var/turf/T2 = T
for(var/j = 1 to steps-1)
T2 = get_step(T2,dir2)
if(!isturf(T2))
return 0
turfs.Add(T2)
for(var/k = 1 to steps-1)
T = get_step(T,dir3)
if(!isturf(T))
return 0
turfs.Add(T)
for(var/turf/T3 in turfs)
if(isnull(T3))
continue
if(!can_move(T3))
return 0
return 1
/obj/singularity/proc/can_move(turf/T)
if(!T)
return 0
if((locate(/obj/machinery/field/containment) in T)||(locate(/obj/machinery/shieldwall) in T))
return 0
else if(locate(/obj/machinery/field/generator) in T)
var/obj/machinery/field/generator/G = locate(/obj/machinery/field/generator) in T
if(G && G.active)
return 0
else if(locate(/obj/machinery/shieldwallgen) in T)
var/obj/machinery/shieldwallgen/S = locate(/obj/machinery/shieldwallgen) in T
if(S && S.active)
return 0
return 1
/obj/singularity/proc/event()
var/numb = pick(1,2,3,4,5,6)
switch(numb)
if(1)//EMP
emp_area()
if(2,3)//tox damage all carbon mobs in area
toxmob()
if(4)//Stun mobs who lack optic scanners
mezzer()
if(5,6) //Sets all nearby mobs on fire
if(current_size < STAGE_SIX)
return 0
combust_mobs()
else
return 0
return 1
/obj/singularity/proc/toxmob()
var/toxrange = 10
var/radiation = 15
var/radiationmin = 3
if (energy>200)
radiation += round((energy-150)/10,1)
radiationmin = round((radiation/5),1)
for(var/mob/living/M in view(toxrange, src.loc))
M.rad_act(rand(radiationmin,radiation))
/obj/singularity/proc/combust_mobs()
for(var/mob/living/carbon/C in ultra_range(20, src, 1))
C.visible_message("<span class='warning'>[C]'s skin bursts into flame!</span>", \
"<span class='userdanger'>You feel an inner fire as your skin bursts into flames!</span>")
C.adjust_fire_stacks(5)
C.IgniteMob()
return
/obj/singularity/proc/mezzer()
for(var/mob/living/carbon/M in oviewers(8, src))
if(istype(M, /mob/living/carbon/brain)) //Ignore brains
continue
if(M.stat == CONSCIOUS)
if (istype(M,/mob/living/carbon/human))
var/mob/living/carbon/human/H = M
if(istype(H.glasses, /obj/item/clothing/glasses/meson))
var/obj/item/clothing/glasses/meson/MS = H.glasses
if(MS.vision_flags == SEE_TURFS)
H << "<span class='notice'>You look directly into the [src.name], good thing you had your protective eyewear on!</span>"
return
M.apply_effect(3, STUN)
M.visible_message("<span class='danger'>[M] stares blankly at the [src.name]!</span>", \
"<span class='userdanger'>You look directly into the [src.name] and feel weak.</span>")
return
/obj/singularity/proc/emp_area()
empulse(src, 8, 10)
return
/obj/singularity/proc/pulse()
for(var/obj/machinery/power/rad_collector/R in rad_collectors)
if(get_dist(R, src) <= 15) // Better than using orange() every process
R.receive_pulse(energy)
return
/obj/singularity/singularity_act()
var/gain = (energy/2)
var/dist = max((current_size - 2),1)
explosion(src.loc,(dist),(dist*2),(dist*4))
qdel(src)
return(gain)
+439 -439
View File
@@ -1,440 +1,440 @@
// the SMES
// stores power
#define SMESRATE 0.05 // rate of internal charge to external power
//Cache defines
#define SMES_CLEVEL_1 1
#define SMES_CLEVEL_2 2
#define SMES_CLEVEL_3 3
#define SMES_CLEVEL_4 4
#define SMES_CLEVEL_5 5
#define SMES_OUTPUTTING 6
#define SMES_NOT_OUTPUTTING 7
#define SMES_INPUTTING 8
#define SMES_INPUT_ATTEMPT 9
/obj/machinery/power/smes
name = "power storage unit"
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit."
icon_state = "smes"
density = 1
anchored = 1
use_power = 0
var/capacity = 5e6 // maximum charge
var/charge = 0 // actual charge
var/input_attempt = 1 // 1 = attempting to charge, 0 = not attempting to charge
var/inputting = 1 // 1 = actually inputting, 0 = not inputting
var/input_level = 50000 // amount of power the SMES attempts to charge by
var/input_level_max = 200000 // cap on input_level
var/input_available = 0 // amount of charge available from input last tick
var/output_attempt = 1 // 1 = attempting to output, 0 = not attempting to output
var/outputting = 1 // 1 = actually outputting, 0 = not outputting
var/output_level = 50000 // amount of power the SMES attempts to output
var/output_level_max = 200000 // cap on output_level
var/output_used = 0 // amount of power actually outputted. may be less than output_level if the powernet returns excess power
var/obj/machinery/power/terminal/terminal = null
var/static/list/smesImageCache
/obj/machinery/power/smes/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/smes(null)
component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
component_parts += new /obj/item/weapon/stock_parts/capacitor(null)
component_parts += new /obj/item/stack/cable_coil(null, 5)
RefreshParts()
spawn(5)
dir_loop:
for(var/d in cardinal)
var/turf/T = get_step(src, d)
for(var/obj/machinery/power/terminal/term in T)
if(term && term.dir == turn(d, 180))
terminal = term
break dir_loop
if(!terminal)
stat |= BROKEN
return
terminal.master = src
update_icon()
return
/obj/machinery/power/smes/RefreshParts()
var/IO = 0
var/C = 0
for(var/obj/item/weapon/stock_parts/capacitor/CP in component_parts)
IO += CP.rating
input_level_max = 200000 * IO
output_level_max = 200000 * IO
for(var/obj/item/weapon/stock_parts/cell/PC in component_parts)
C += PC.maxcharge
capacity = C / (15000) * 1e6
/obj/machinery/power/smes/attackby(obj/item/I, mob/user, params)
//opening using screwdriver
if(default_deconstruction_screwdriver(user, "[initial(icon_state)]-o", initial(icon_state), I))
update_icon()
return
//changing direction using wrench
if(default_change_direction_wrench(user, I))
terminal = null
var/turf/T = get_step(src, dir)
for(var/obj/machinery/power/terminal/term in T)
if(term && term.dir == turn(dir, 180))
terminal = term
terminal.master = src
user << "<span class='notice'>Terminal found.</span>"
break
if(!terminal)
user << "<span class='alert'>No power source found.</span>"
return
stat &= ~BROKEN
update_icon()
return
//exchanging parts using the RPE
if(exchange_parts(user, I))
return
//building and linking a terminal
if(istype(I, /obj/item/stack/cable_coil))
var/dir = get_dir(user,src)
if(dir & (dir-1))//we don't want diagonal click
return
if(terminal) //is there already a terminal ?
user << "<span class='warning'>This SMES already have a power terminal!</span>"
return
if(!panel_open) //is the panel open ?
user << "<span class='warning'>You must open the maintenance panel first!</span>"
return
var/turf/T = get_turf(user)
if (T.intact) //is the floor plating removed ?
user << "<span class='warning'>You must first remove the floor plating!</span>"
return
var/obj/item/stack/cable_coil/C = I
if(C.amount < 10)
user << "<span class='warning'>You need more wires!</span>"
return
user << "<span class='notice'>You start building the power terminal...</span>"
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
if(do_after(user, 20, target = src) && C.amount >= 10)
var/obj/structure/cable/N = T.get_cable_node() //get the connecting node cable, if there's one
if (prob(50) && electrocute_mob(usr, N, N)) //animate the electrocution if uncautious and unlucky
var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
s.set_up(5, 1, src)
s.start()
return
C.use(10)
user.visible_message(\
"[user.name] has built a power terminal.",\
"<span class='notice'>You build the power terminal.</span>")
//build the terminal and link it to the network
make_terminal(T)
terminal.connect_to_network()
return
//disassembling the terminal
if(istype(I, /obj/item/weapon/wirecutters) && terminal && panel_open)
terminal.dismantle(user)
//crowbarring it !
if(default_deconstruction_crowbar(I))
message_admins("[src] has been deconstructed by [key_name_admin(user)](<A HREF='?_src_=holder;adminmoreinfo=\ref[user]'>?</A>) (<A HREF='?_src_=holder;adminplayerobservefollow=\ref[user]'>FLW</A>) in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
log_game("[src] has been deconstructed by [key_name(user)]")
investigate_log("SMES deconstructed by [key_name(user)]","singulo")
/obj/machinery/power/smes/Destroy()
if(ticker && ticker.current_state == GAME_STATE_PLAYING)
var/area/area = get_area(src)
message_admins("SMES deleted at (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>[area.name]</a>)")
log_game("SMES deleted at ([area.name])")
investigate_log("<font color='red'>deleted</font> at ([area.name])","singulo")
if(terminal)
disconnect_terminal()
return ..()
// create a terminal object pointing towards the SMES
// wires will attach to this
/obj/machinery/power/smes/proc/make_terminal(turf/T)
terminal = new/obj/machinery/power/terminal(T)
terminal.dir = get_dir(T,src)
terminal.master = src
/obj/machinery/power/smes/disconnect_terminal()
if(terminal)
terminal.master = null
terminal = null
/obj/machinery/power/smes/update_icon()
overlays.Cut()
if(stat & BROKEN) return
if(panel_open)
return
if(!smesImageCache || !smesImageCache.len)
smesImageCache = list()
smesImageCache.len = 9
smesImageCache[SMES_CLEVEL_1] = image('icons/obj/power.dmi',"smes-og1")
smesImageCache[SMES_CLEVEL_2] = image('icons/obj/power.dmi',"smes-og2")
smesImageCache[SMES_CLEVEL_3] = image('icons/obj/power.dmi',"smes-og3")
smesImageCache[SMES_CLEVEL_4] = image('icons/obj/power.dmi',"smes-og4")
smesImageCache[SMES_CLEVEL_5] = image('icons/obj/power.dmi',"smes-og5")
smesImageCache[SMES_OUTPUTTING] = image('icons/obj/power.dmi', "smes-op1")
smesImageCache[SMES_NOT_OUTPUTTING] = image('icons/obj/power.dmi',"smes-op0")
smesImageCache[SMES_INPUTTING] = image('icons/obj/power.dmi', "smes-oc1")
smesImageCache[SMES_INPUT_ATTEMPT] = image('icons/obj/power.dmi', "smes-oc0")
if(outputting)
overlays += smesImageCache[SMES_OUTPUTTING]
else
overlays += smesImageCache[SMES_NOT_OUTPUTTING]
if(inputting)
overlays += smesImageCache[SMES_INPUTTING]
else
if(input_attempt)
overlays += smesImageCache[SMES_INPUT_ATTEMPT]
var/clevel = chargedisplay()
if(clevel>0)
overlays += smesImageCache[clevel]
return
/obj/machinery/power/smes/proc/chargedisplay()
return round(5.5*charge/capacity)
/obj/machinery/power/smes/process()
if(stat & BROKEN) return
//store machine state to see if we need to update the icon overlays
var/last_disp = chargedisplay()
var/last_chrg = inputting
var/last_onln = outputting
//inputting
if(terminal && input_attempt)
input_available = terminal.surplus()
if(inputting)
if(input_available > 0 && input_available >= input_level) // if there's power available, try to charge
var/load = min((capacity-charge)/SMESRATE, input_level) // charge at set rate, limited to spare capacity
charge += load * SMESRATE // increase the charge
add_load(load) // add the load to the terminal side network
else // if not enough capcity
inputting = 0 // stop inputting
else
if(input_attempt && input_available > 0 && input_available >= input_level)
inputting = 1
//outputting
if(outputting)
output_used = min( charge/SMESRATE, output_level) //limit output to that stored
charge -= output_used*SMESRATE // reduce the storage (may be recovered in /restore() if excessive)
add_avail(output_used) // add output to powernet (smes side)
if(output_used < 0.0001) // either from no charge or set to 0
outputting = 0
investigate_log("lost power and turned <font color='red'>off</font>","singulo")
else if(output_attempt && charge > output_level && output_level > 0)
outputting = 1
else
output_used = 0
// only update icon if state changed
if(last_disp != chargedisplay() || last_chrg != inputting || last_onln != outputting)
update_icon()
// called after all power processes are finished
// restores charge level to smes if there was excess this ptick
/obj/machinery/power/smes/proc/restore()
if(stat & BROKEN)
return
if(!outputting)
output_used = 0
return
var/excess = powernet.netexcess // this was how much wasn't used on the network last ptick, minus any removed by other SMESes
excess = min(output_used, excess) // clamp it to how much was actually output by this SMES last ptick
excess = min((capacity-charge)/SMESRATE, excess) // for safety, also limit recharge by space capacity of SMES (shouldn't happen)
// now recharge this amount
var/clev = chargedisplay()
charge += excess * SMESRATE // restore unused power
powernet.netexcess -= excess // remove the excess from the powernet, so later SMESes don't try to use it
output_used -= excess
if(clev != chargedisplay() ) //if needed updates the icons overlay
update_icon()
return
/obj/machinery/power/smes/add_load(amount)
if(terminal && terminal.powernet)
terminal.powernet.load += amount
/obj/machinery/power/smes/attack_hand(mob/user)
if (!user)
return
add_fingerprint(user)
interact(user)
/obj/machinery/power/smes/interact(mob/user)
if (stat & BROKEN)
return
ui_interact(user)
/obj/machinery/power/smes/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 0)
ui = SSnano.try_update_ui(user, src, ui_key, ui, force_open = force_open)
if (!ui)
ui = new(user, src, ui_key, "smes", name, 500, 455)
ui.open()
/obj/machinery/power/smes/get_ui_data()
var/list/data = list(
"capacityPercent" = round(100*charge/capacity, 0.1),
"capacity" = capacity,
"charge" = charge,
"inputAttempt" = input_attempt,
"inputting" = inputting,
"inputLevel" = input_level,
"inputLevelMax" = input_level_max,
"inputAvailable" = input_available,
"outputAttempt" = output_attempt,
"outputting" = outputting,
"outputLevel" = output_level,
"outputLevelMax" = output_level_max,
"outputUsed" = output_used
)
return data
/obj/machinery/power/smes/ui_act(action, params)
if(..())
return
switch(action)
if("tryinput")
input_attempt = !input_attempt
log_smes(usr.ckey)
update_icon()
if("tryoutput")
output_attempt = !output_attempt
log_smes(usr.ckey)
update_icon()
if("input")
switch(params["set"])
if("custom")
var/custom = input(usr, "What rate would you like this SMES to attempt to charge at? Max is [input_level_max].") as null|num
if(custom)
input_level = custom
if("min")
input_level = 0
if("max")
input_level = input_level_max
if("plus")
input_level += 10000
if("minus")
input_level -= 10000
input_level = Clamp(input_level, 0, input_level_max)
log_smes(usr.ckey)
if("output")
switch(params["set"])
if("custom")
var/custom = input(usr, "What rate would you like this SMES to attempt to output at? Max is [output_level_max].") as null|num
if(custom)
output_level = custom
if("min")
output_level = 0
if("max")
output_level = output_level_max
if("plus")
output_level += 10000
if("minus")
output_level -= 10000
output_level = Clamp(output_level, 0, output_level_max)
log_smes(usr.ckey)
return 1
/obj/machinery/power/smes/proc/log_smes(user = "")
investigate_log("input/output; [input_level>output_level?"<font color='green'>":"<font color='red'>"][input_level]/[output_level]</font> | Charge: [charge] | Output-mode: [output_attempt?"<font color='green'>on</font>":"<font color='red'>off</font>"] | Input-mode: [input_attempt?"<font color='green'>auto</font>":"<font color='red'>off</font>"] by [user]","singulo")
/obj/machinery/power/smes/emp_act(severity)
input_attempt = rand(0,1)
inputting = input_attempt
output_attempt = rand(0,1)
outputting = output_attempt
output_level = rand(0, output_level_max)
input_level = rand(0, input_level_max)
charge -= 1e6/severity
if (charge < 0)
charge = 0
update_icon()
log_smes("an emp")
..()
/obj/machinery/power/smes/engineering
charge = 1.5e6 // Engineering starts with some charge for singulo
/obj/machinery/power/smes/magical
name = "magical power storage unit"
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit. Magically produces power."
process()
capacity = INFINITY
charge = INFINITY
..()
#undef SMESRATE
#undef SMES_CLEVEL_1
#undef SMES_CLEVEL_2
#undef SMES_CLEVEL_3
#undef SMES_CLEVEL_4
#undef SMES_CLEVEL_5
#undef SMES_OUTPUTTING
#undef SMES_NOT_OUTPUTTING
#undef SMES_INPUTTING
// the SMES
// stores power
#define SMESRATE 0.05 // rate of internal charge to external power
//Cache defines
#define SMES_CLEVEL_1 1
#define SMES_CLEVEL_2 2
#define SMES_CLEVEL_3 3
#define SMES_CLEVEL_4 4
#define SMES_CLEVEL_5 5
#define SMES_OUTPUTTING 6
#define SMES_NOT_OUTPUTTING 7
#define SMES_INPUTTING 8
#define SMES_INPUT_ATTEMPT 9
/obj/machinery/power/smes
name = "power storage unit"
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit."
icon_state = "smes"
density = 1
anchored = 1
use_power = 0
var/capacity = 5e6 // maximum charge
var/charge = 0 // actual charge
var/input_attempt = 1 // 1 = attempting to charge, 0 = not attempting to charge
var/inputting = 1 // 1 = actually inputting, 0 = not inputting
var/input_level = 50000 // amount of power the SMES attempts to charge by
var/input_level_max = 200000 // cap on input_level
var/input_available = 0 // amount of charge available from input last tick
var/output_attempt = 1 // 1 = attempting to output, 0 = not attempting to output
var/outputting = 1 // 1 = actually outputting, 0 = not outputting
var/output_level = 50000 // amount of power the SMES attempts to output
var/output_level_max = 200000 // cap on output_level
var/output_used = 0 // amount of power actually outputted. may be less than output_level if the powernet returns excess power
var/obj/machinery/power/terminal/terminal = null
var/static/list/smesImageCache
/obj/machinery/power/smes/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/smes(null)
component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
component_parts += new /obj/item/weapon/stock_parts/capacitor(null)
component_parts += new /obj/item/stack/cable_coil(null, 5)
RefreshParts()
spawn(5)
dir_loop:
for(var/d in cardinal)
var/turf/T = get_step(src, d)
for(var/obj/machinery/power/terminal/term in T)
if(term && term.dir == turn(d, 180))
terminal = term
break dir_loop
if(!terminal)
stat |= BROKEN
return
terminal.master = src
update_icon()
return
/obj/machinery/power/smes/RefreshParts()
var/IO = 0
var/C = 0
for(var/obj/item/weapon/stock_parts/capacitor/CP in component_parts)
IO += CP.rating
input_level_max = 200000 * IO
output_level_max = 200000 * IO
for(var/obj/item/weapon/stock_parts/cell/PC in component_parts)
C += PC.maxcharge
capacity = C / (15000) * 1e6
/obj/machinery/power/smes/attackby(obj/item/I, mob/user, params)
//opening using screwdriver
if(default_deconstruction_screwdriver(user, "[initial(icon_state)]-o", initial(icon_state), I))
update_icon()
return
//changing direction using wrench
if(default_change_direction_wrench(user, I))
terminal = null
var/turf/T = get_step(src, dir)
for(var/obj/machinery/power/terminal/term in T)
if(term && term.dir == turn(dir, 180))
terminal = term
terminal.master = src
user << "<span class='notice'>Terminal found.</span>"
break
if(!terminal)
user << "<span class='alert'>No power source found.</span>"
return
stat &= ~BROKEN
update_icon()
return
//exchanging parts using the RPE
if(exchange_parts(user, I))
return
//building and linking a terminal
if(istype(I, /obj/item/stack/cable_coil))
var/dir = get_dir(user,src)
if(dir & (dir-1))//we don't want diagonal click
return
if(terminal) //is there already a terminal ?
user << "<span class='warning'>This SMES already have a power terminal!</span>"
return
if(!panel_open) //is the panel open ?
user << "<span class='warning'>You must open the maintenance panel first!</span>"
return
var/turf/T = get_turf(user)
if (T.intact) //is the floor plating removed ?
user << "<span class='warning'>You must first remove the floor plating!</span>"
return
var/obj/item/stack/cable_coil/C = I
if(C.amount < 10)
user << "<span class='warning'>You need more wires!</span>"
return
user << "<span class='notice'>You start building the power terminal...</span>"
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
if(do_after(user, 20, target = src) && C.amount >= 10)
var/obj/structure/cable/N = T.get_cable_node() //get the connecting node cable, if there's one
if (prob(50) && electrocute_mob(usr, N, N)) //animate the electrocution if uncautious and unlucky
var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
s.set_up(5, 1, src)
s.start()
return
C.use(10)
user.visible_message(\
"[user.name] has built a power terminal.",\
"<span class='notice'>You build the power terminal.</span>")
//build the terminal and link it to the network
make_terminal(T)
terminal.connect_to_network()
return
//disassembling the terminal
if(istype(I, /obj/item/weapon/wirecutters) && terminal && panel_open)
terminal.dismantle(user)
//crowbarring it !
if(default_deconstruction_crowbar(I))
message_admins("[src] has been deconstructed by [key_name_admin(user)](<A HREF='?_src_=holder;adminmoreinfo=\ref[user]'>?</A>) (<A HREF='?_src_=holder;adminplayerobservefollow=\ref[user]'>FLW</A>) in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
log_game("[src] has been deconstructed by [key_name(user)]")
investigate_log("SMES deconstructed by [key_name(user)]","singulo")
/obj/machinery/power/smes/Destroy()
if(ticker && ticker.current_state == GAME_STATE_PLAYING)
var/area/area = get_area(src)
message_admins("SMES deleted at (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>[area.name]</a>)")
log_game("SMES deleted at ([area.name])")
investigate_log("<font color='red'>deleted</font> at ([area.name])","singulo")
if(terminal)
disconnect_terminal()
return ..()
// create a terminal object pointing towards the SMES
// wires will attach to this
/obj/machinery/power/smes/proc/make_terminal(turf/T)
terminal = new/obj/machinery/power/terminal(T)
terminal.dir = get_dir(T,src)
terminal.master = src
/obj/machinery/power/smes/disconnect_terminal()
if(terminal)
terminal.master = null
terminal = null
/obj/machinery/power/smes/update_icon()
overlays.Cut()
if(stat & BROKEN) return
if(panel_open)
return
if(!smesImageCache || !smesImageCache.len)
smesImageCache = list()
smesImageCache.len = 9
smesImageCache[SMES_CLEVEL_1] = image('icons/obj/power.dmi',"smes-og1")
smesImageCache[SMES_CLEVEL_2] = image('icons/obj/power.dmi',"smes-og2")
smesImageCache[SMES_CLEVEL_3] = image('icons/obj/power.dmi',"smes-og3")
smesImageCache[SMES_CLEVEL_4] = image('icons/obj/power.dmi',"smes-og4")
smesImageCache[SMES_CLEVEL_5] = image('icons/obj/power.dmi',"smes-og5")
smesImageCache[SMES_OUTPUTTING] = image('icons/obj/power.dmi', "smes-op1")
smesImageCache[SMES_NOT_OUTPUTTING] = image('icons/obj/power.dmi',"smes-op0")
smesImageCache[SMES_INPUTTING] = image('icons/obj/power.dmi', "smes-oc1")
smesImageCache[SMES_INPUT_ATTEMPT] = image('icons/obj/power.dmi', "smes-oc0")
if(outputting)
overlays += smesImageCache[SMES_OUTPUTTING]
else
overlays += smesImageCache[SMES_NOT_OUTPUTTING]
if(inputting)
overlays += smesImageCache[SMES_INPUTTING]
else
if(input_attempt)
overlays += smesImageCache[SMES_INPUT_ATTEMPT]
var/clevel = chargedisplay()
if(clevel>0)
overlays += smesImageCache[clevel]
return
/obj/machinery/power/smes/proc/chargedisplay()
return round(5.5*charge/capacity)
/obj/machinery/power/smes/process()
if(stat & BROKEN) return
//store machine state to see if we need to update the icon overlays
var/last_disp = chargedisplay()
var/last_chrg = inputting
var/last_onln = outputting
//inputting
if(terminal && input_attempt)
input_available = terminal.surplus()
if(inputting)
if(input_available > 0 && input_available >= input_level) // if there's power available, try to charge
var/load = min((capacity-charge)/SMESRATE, input_level) // charge at set rate, limited to spare capacity
charge += load * SMESRATE // increase the charge
add_load(load) // add the load to the terminal side network
else // if not enough capcity
inputting = 0 // stop inputting
else
if(input_attempt && input_available > 0 && input_available >= input_level)
inputting = 1
//outputting
if(outputting)
output_used = min( charge/SMESRATE, output_level) //limit output to that stored
charge -= output_used*SMESRATE // reduce the storage (may be recovered in /restore() if excessive)
add_avail(output_used) // add output to powernet (smes side)
if(output_used < 0.0001) // either from no charge or set to 0
outputting = 0
investigate_log("lost power and turned <font color='red'>off</font>","singulo")
else if(output_attempt && charge > output_level && output_level > 0)
outputting = 1
else
output_used = 0
// only update icon if state changed
if(last_disp != chargedisplay() || last_chrg != inputting || last_onln != outputting)
update_icon()
// called after all power processes are finished
// restores charge level to smes if there was excess this ptick
/obj/machinery/power/smes/proc/restore()
if(stat & BROKEN)
return
if(!outputting)
output_used = 0
return
var/excess = powernet.netexcess // this was how much wasn't used on the network last ptick, minus any removed by other SMESes
excess = min(output_used, excess) // clamp it to how much was actually output by this SMES last ptick
excess = min((capacity-charge)/SMESRATE, excess) // for safety, also limit recharge by space capacity of SMES (shouldn't happen)
// now recharge this amount
var/clev = chargedisplay()
charge += excess * SMESRATE // restore unused power
powernet.netexcess -= excess // remove the excess from the powernet, so later SMESes don't try to use it
output_used -= excess
if(clev != chargedisplay() ) //if needed updates the icons overlay
update_icon()
return
/obj/machinery/power/smes/add_load(amount)
if(terminal && terminal.powernet)
terminal.powernet.load += amount
/obj/machinery/power/smes/attack_hand(mob/user)
if (!user)
return
add_fingerprint(user)
interact(user)
/obj/machinery/power/smes/interact(mob/user)
if (stat & BROKEN)
return
ui_interact(user)
/obj/machinery/power/smes/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 0)
ui = SSnano.try_update_ui(user, src, ui_key, ui, force_open = force_open)
if (!ui)
ui = new(user, src, ui_key, "smes", name, 500, 455)
ui.open()
/obj/machinery/power/smes/get_ui_data()
var/list/data = list(
"capacityPercent" = round(100*charge/capacity, 0.1),
"capacity" = capacity,
"charge" = charge,
"inputAttempt" = input_attempt,
"inputting" = inputting,
"inputLevel" = input_level,
"inputLevelMax" = input_level_max,
"inputAvailable" = input_available,
"outputAttempt" = output_attempt,
"outputting" = outputting,
"outputLevel" = output_level,
"outputLevelMax" = output_level_max,
"outputUsed" = output_used
)
return data
/obj/machinery/power/smes/ui_act(action, params)
if(..())
return
switch(action)
if("tryinput")
input_attempt = !input_attempt
log_smes(usr.ckey)
update_icon()
if("tryoutput")
output_attempt = !output_attempt
log_smes(usr.ckey)
update_icon()
if("input")
switch(params["set"])
if("custom")
var/custom = input(usr, "What rate would you like this SMES to attempt to charge at? Max is [input_level_max].") as null|num
if(custom)
input_level = custom
if("min")
input_level = 0
if("max")
input_level = input_level_max
if("plus")
input_level += 10000
if("minus")
input_level -= 10000
input_level = Clamp(input_level, 0, input_level_max)
log_smes(usr.ckey)
if("output")
switch(params["set"])
if("custom")
var/custom = input(usr, "What rate would you like this SMES to attempt to output at? Max is [output_level_max].") as null|num
if(custom)
output_level = custom
if("min")
output_level = 0
if("max")
output_level = output_level_max
if("plus")
output_level += 10000
if("minus")
output_level -= 10000
output_level = Clamp(output_level, 0, output_level_max)
log_smes(usr.ckey)
return 1
/obj/machinery/power/smes/proc/log_smes(user = "")
investigate_log("input/output; [input_level>output_level?"<font color='green'>":"<font color='red'>"][input_level]/[output_level]</font> | Charge: [charge] | Output-mode: [output_attempt?"<font color='green'>on</font>":"<font color='red'>off</font>"] | Input-mode: [input_attempt?"<font color='green'>auto</font>":"<font color='red'>off</font>"] by [user]","singulo")
/obj/machinery/power/smes/emp_act(severity)
input_attempt = rand(0,1)
inputting = input_attempt
output_attempt = rand(0,1)
outputting = output_attempt
output_level = rand(0, output_level_max)
input_level = rand(0, input_level_max)
charge -= 1e6/severity
if (charge < 0)
charge = 0
update_icon()
log_smes("an emp")
..()
/obj/machinery/power/smes/engineering
charge = 1.5e6 // Engineering starts with some charge for singulo
/obj/machinery/power/smes/magical
name = "magical power storage unit"
desc = "A high-capacity superconducting magnetic energy storage (SMES) unit. Magically produces power."
process()
capacity = INFINITY
charge = INFINITY
..()
#undef SMESRATE
#undef SMES_CLEVEL_1
#undef SMES_CLEVEL_2
#undef SMES_CLEVEL_3
#undef SMES_CLEVEL_4
#undef SMES_CLEVEL_5
#undef SMES_OUTPUTTING
#undef SMES_NOT_OUTPUTTING
#undef SMES_INPUTTING
#undef SMES_INPUT_ATTEMPT
File diff suppressed because it is too large Load Diff
@@ -1,354 +1,354 @@
/obj/machinery/chem_dispenser
name = "chem dispenser"
desc = "Creates and dispenses chemicals."
density = 1
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "dispenser"
use_power = 1
idle_power_usage = 40
interact_offline = 1
var/energy = 100
var/max_energy = 100
var/amount = 30
var/recharged = 0
var/recharge_delay = 5
var/image/icon_beaker = null
var/obj/item/weapon/reagent_containers/beaker = null
var/list/dispensable_reagents = list(
"hydrogen",
"lithium",
"carbon",
"nitrogen",
"oxygen",
"fluorine",
"sodium",
"aluminium",
"silicon",
"phosphorus",
"sulfur",
"chlorine",
"potassium",
"iron",
"copper",
"mercury",
"radium",
"water",
"ethanol",
"sugar",
"sacid",
"welding_fuel",
"silver",
"iodine",
"bromine",
"stable_plasma"
)
/obj/machinery/chem_dispenser/New()
..()
recharge()
dispensable_reagents = sortList(dispensable_reagents)
/obj/machinery/chem_dispenser/power_change()
if(powered())
stat &= ~NOPOWER
else
spawn(rand(0, 15))
stat |= NOPOWER
/obj/machinery/chem_dispenser/process()
if(recharged < 0)
recharge()
recharged = recharge_delay
else
recharged -= 1
/obj/machinery/chem_dispenser/proc/recharge()
if(stat & (BROKEN|NOPOWER)) return
var/addenergy = 1
var/oldenergy = energy
energy = min(energy + addenergy, max_energy)
if(energy != oldenergy)
use_power(2500)
/obj/machinery/chem_dispenser/ex_act(severity, target)
if(severity < 3)
..()
/obj/machinery/chem_dispenser/blob_act()
if(prob(50))
qdel(src)
/obj/machinery/chem_dispenser/interact(mob/user)
if(stat & BROKEN)
return
ui_interact(user)
/obj/machinery/chem_dispenser/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 0)
ui = SSnano.try_update_ui(user, src, ui_key, ui, force_open = force_open)
if (!ui)
ui = new(user, src, ui_key, "chem_dispenser", name, 530, 700)
ui.open()
/obj/machinery/chem_dispenser/get_ui_data()
var/data = list()
data["amount"] = amount
data["energy"] = energy
data["maxEnergy"] = max_energy
data["isBeakerLoaded"] = beaker ? 1 : 0
var beakerContents[0]
var beakerCurrentVolume = 0
if(beaker && beaker.reagents && beaker.reagents.reagent_list.len)
for(var/datum/reagent/R in beaker.reagents.reagent_list)
beakerContents.Add(list(list("name" = R.name, "volume" = R.volume))) // list in a list because Byond merges the first list...
beakerCurrentVolume += R.volume
data["beakerContents"] = beakerContents
if (beaker)
data["beakerCurrentVolume"] = beakerCurrentVolume
data["beakerMaxVolume"] = beaker.volume
data["beakerTransferAmounts"] = beaker.possible_transfer_amounts
else
data["beakerCurrentVolume"] = null
data["beakerMaxVolume"] = null
data["beakerTransferAmounts"] = null
var chemicals[0]
for(var/re in dispensable_reagents)
var/datum/reagent/temp = chemical_reagents_list[re]
if(temp)
chemicals.Add(list(list("title" = temp.name, "id" = temp.id, "commands" = list("reagent" = temp.id))))
data["chemicals"] = chemicals
return data
/obj/machinery/chem_dispenser/ui_act(action, params)
if(..())
return
switch(action)
if("amount")
amount = round(text2num(params["set"]), 5) // round to nearest 5
if (amount < 0) // Since the user can actually type the commands himself, some sanity checking
amount = 0
if (amount > 100)
amount = 100
if("dispense")
if(beaker && dispensable_reagents.Find(params["reagent"]))
var/datum/reagents/R = beaker.reagents
var/space = R.maximum_volume - R.total_volume
R.add_reagent(params["reagent"], min(amount, energy * 10, space))
energy = max(energy - min(amount, energy * 10, space) / 10, 0)
if("remove")
if(beaker)
var/amount = text2num(params["amount"])
if(isnum(amount) && (amount > 0) && (amount in beaker.possible_transfer_amounts))
beaker.reagents.remove_all(amount)
if("eject")
if(beaker)
beaker.loc = loc
beaker = null
overlays.Cut()
return 1
/obj/machinery/chem_dispenser/attackby(obj/item/I, mob/user, params)
if(default_unfasten_wrench(user, I))
return
if(isrobot(user))
return
var/obj/item/weapon/reagent_containers/B = I // Get a beaker from it?
if(!istype(B))
return // Not a beaker?
if(beaker)
user << "<span class='warning'>A beaker is already loaded into the machine!</span>"
return
if(!user.drop_item()) // Can't let go?
return
beaker = B
beaker.loc = src
user << "<span class='notice'>You add the beaker to the machine.</span>"
if(!icon_beaker)
icon_beaker = image('icons/obj/chemical.dmi', src, "disp_beaker") //randomize beaker overlay position.
icon_beaker.pixel_x = rand(-10,5)
overlays += icon_beaker
/obj/machinery/chem_dispenser/attack_hand(mob/user)
if (!user)
return
interact(user)
/obj/machinery/chem_dispenser/constructable
name = "portable chem dispenser"
icon = 'icons/obj/chemical.dmi'
icon_state = "minidispenser"
energy = 10
max_energy = 10
amount = 5
recharge_delay = 30
dispensable_reagents = list()
var/list/dispensable_reagent_tiers = list(
list(
"hydrogen",
"oxygen",
"silicon",
"phosphorus",
"sulfur",
"carbon",
"nitrogen",
"water"
),
list(
"lithium",
"sugar",
"sacid",
"copper",
"mercury",
"sodium",
"iodine",
"bromine"
),
list(
"ethanol",
"chlorine",
"potassium",
"aluminium",
"radium",
"fluorine",
"iron",
"welding_fuel",
"silver",
"stable_plasma"
),
list(
"oil",
"ash",
"acetone",
"saltpetre",
"ammonia",
"diethylamine"
)
)
/obj/machinery/chem_dispenser/constructable/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/chem_dispenser(null)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(null)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(null)
component_parts += new /obj/item/weapon/stock_parts/manipulator(null)
component_parts += new /obj/item/weapon/stock_parts/capacitor(null)
component_parts += new /obj/item/weapon/stock_parts/console_screen(null)
component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
RefreshParts()
/obj/machinery/chem_dispenser/constructable/RefreshParts()
var/time = 0
var/temp_energy = 0
var/i
for(var/obj/item/weapon/stock_parts/matter_bin/M in component_parts)
temp_energy += M.rating
temp_energy--
max_energy = temp_energy * 5 //max energy = (bin1.rating + bin2.rating - 1) * 5, 5 on lowest 25 on highest
for(var/obj/item/weapon/stock_parts/capacitor/C in component_parts)
time += C.rating
for(var/obj/item/weapon/stock_parts/cell/P in component_parts)
time += round(P.maxcharge, 10000) / 10000
recharge_delay /= time/2 //delay between recharges, double the usual time on lowest 50% less than usual on highest
for(var/obj/item/weapon/stock_parts/manipulator/M in component_parts)
for(i=1, i<=M.rating, i++)
dispensable_reagents |= dispensable_reagent_tiers[i]
dispensable_reagents = sortList(dispensable_reagents)
/obj/machinery/chem_dispenser/constructable/attackby(var/obj/item/I, var/mob/user, params)
..()
if(default_deconstruction_screwdriver(user, "minidispenser-o", "minidispenser", I))
return
if(exchange_parts(user, I))
return
if(panel_open)
if(istype(I, /obj/item/weapon/crowbar))
if(beaker)
beaker.loc = loc
beaker = null
default_deconstruction_crowbar(I)
return 1
/obj/machinery/chem_dispenser/drinks
name = "soda dispenser"
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "soda_dispenser"
amount = 10
dispensable_reagents = list(
"water",
"ice",
"coffee",
"cream",
"tea",
"icetea",
"cola",
"spacemountainwind",
"dr_gibb",
"space_up",
"tonic",
"sodawater",
"lemon_lime",
"sugar",
"orangejuice",
"limejuice",
"tomatojuice"
)
/obj/machinery/chem_dispenser/drinks/attackby(obj/item/I, mob/user)
if(default_unfasten_wrench(user, I))
return
if (istype(I, /obj/item/weapon/reagent_containers/glass) || \
istype(I, /obj/item/weapon/reagent_containers/food/drinks/drinkingglass) || \
istype(I, /obj/item/weapon/reagent_containers/food/drinks/shaker))
if (beaker)
return 1
else
if(!user.drop_item())
return 1
src.beaker = I
beaker.loc = src
update_icon()
return
/obj/machinery/chem_dispenser/drinks/beer
name = "booze dispenser"
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "booze_dispenser"
dispensable_reagents = list(
"lemon_lime",
"sugar",
"orangejuice",
"limejuice",
"sodawater",
"tonic",
"beer",
"kahlua",
"whiskey",
"wine",
"vodka",
"gin",
"rum",
"tequila",
"vermouth",
"cognac",
"ale"
)
/obj/machinery/chem_dispenser
name = "chem dispenser"
desc = "Creates and dispenses chemicals."
density = 1
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "dispenser"
use_power = 1
idle_power_usage = 40
interact_offline = 1
var/energy = 100
var/max_energy = 100
var/amount = 30
var/recharged = 0
var/recharge_delay = 5
var/image/icon_beaker = null
var/obj/item/weapon/reagent_containers/beaker = null
var/list/dispensable_reagents = list(
"hydrogen",
"lithium",
"carbon",
"nitrogen",
"oxygen",
"fluorine",
"sodium",
"aluminium",
"silicon",
"phosphorus",
"sulfur",
"chlorine",
"potassium",
"iron",
"copper",
"mercury",
"radium",
"water",
"ethanol",
"sugar",
"sacid",
"welding_fuel",
"silver",
"iodine",
"bromine",
"stable_plasma"
)
/obj/machinery/chem_dispenser/New()
..()
recharge()
dispensable_reagents = sortList(dispensable_reagents)
/obj/machinery/chem_dispenser/power_change()
if(powered())
stat &= ~NOPOWER
else
spawn(rand(0, 15))
stat |= NOPOWER
/obj/machinery/chem_dispenser/process()
if(recharged < 0)
recharge()
recharged = recharge_delay
else
recharged -= 1
/obj/machinery/chem_dispenser/proc/recharge()
if(stat & (BROKEN|NOPOWER)) return
var/addenergy = 1
var/oldenergy = energy
energy = min(energy + addenergy, max_energy)
if(energy != oldenergy)
use_power(2500)
/obj/machinery/chem_dispenser/ex_act(severity, target)
if(severity < 3)
..()
/obj/machinery/chem_dispenser/blob_act()
if(prob(50))
qdel(src)
/obj/machinery/chem_dispenser/interact(mob/user)
if(stat & BROKEN)
return
ui_interact(user)
/obj/machinery/chem_dispenser/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 0)
ui = SSnano.try_update_ui(user, src, ui_key, ui, force_open = force_open)
if (!ui)
ui = new(user, src, ui_key, "chem_dispenser", name, 530, 700)
ui.open()
/obj/machinery/chem_dispenser/get_ui_data()
var/data = list()
data["amount"] = amount
data["energy"] = energy
data["maxEnergy"] = max_energy
data["isBeakerLoaded"] = beaker ? 1 : 0
var beakerContents[0]
var beakerCurrentVolume = 0
if(beaker && beaker.reagents && beaker.reagents.reagent_list.len)
for(var/datum/reagent/R in beaker.reagents.reagent_list)
beakerContents.Add(list(list("name" = R.name, "volume" = R.volume))) // list in a list because Byond merges the first list...
beakerCurrentVolume += R.volume
data["beakerContents"] = beakerContents
if (beaker)
data["beakerCurrentVolume"] = beakerCurrentVolume
data["beakerMaxVolume"] = beaker.volume
data["beakerTransferAmounts"] = beaker.possible_transfer_amounts
else
data["beakerCurrentVolume"] = null
data["beakerMaxVolume"] = null
data["beakerTransferAmounts"] = null
var chemicals[0]
for(var/re in dispensable_reagents)
var/datum/reagent/temp = chemical_reagents_list[re]
if(temp)
chemicals.Add(list(list("title" = temp.name, "id" = temp.id, "commands" = list("reagent" = temp.id))))
data["chemicals"] = chemicals
return data
/obj/machinery/chem_dispenser/ui_act(action, params)
if(..())
return
switch(action)
if("amount")
amount = round(text2num(params["set"]), 5) // round to nearest 5
if (amount < 0) // Since the user can actually type the commands himself, some sanity checking
amount = 0
if (amount > 100)
amount = 100
if("dispense")
if(beaker && dispensable_reagents.Find(params["reagent"]))
var/datum/reagents/R = beaker.reagents
var/space = R.maximum_volume - R.total_volume
R.add_reagent(params["reagent"], min(amount, energy * 10, space))
energy = max(energy - min(amount, energy * 10, space) / 10, 0)
if("remove")
if(beaker)
var/amount = text2num(params["amount"])
if(isnum(amount) && (amount > 0) && (amount in beaker.possible_transfer_amounts))
beaker.reagents.remove_all(amount)
if("eject")
if(beaker)
beaker.loc = loc
beaker = null
overlays.Cut()
return 1
/obj/machinery/chem_dispenser/attackby(obj/item/I, mob/user, params)
if(default_unfasten_wrench(user, I))
return
if(isrobot(user))
return
var/obj/item/weapon/reagent_containers/B = I // Get a beaker from it?
if(!istype(B))
return // Not a beaker?
if(beaker)
user << "<span class='warning'>A beaker is already loaded into the machine!</span>"
return
if(!user.drop_item()) // Can't let go?
return
beaker = B
beaker.loc = src
user << "<span class='notice'>You add the beaker to the machine.</span>"
if(!icon_beaker)
icon_beaker = image('icons/obj/chemical.dmi', src, "disp_beaker") //randomize beaker overlay position.
icon_beaker.pixel_x = rand(-10,5)
overlays += icon_beaker
/obj/machinery/chem_dispenser/attack_hand(mob/user)
if (!user)
return
interact(user)
/obj/machinery/chem_dispenser/constructable
name = "portable chem dispenser"
icon = 'icons/obj/chemical.dmi'
icon_state = "minidispenser"
energy = 10
max_energy = 10
amount = 5
recharge_delay = 30
dispensable_reagents = list()
var/list/dispensable_reagent_tiers = list(
list(
"hydrogen",
"oxygen",
"silicon",
"phosphorus",
"sulfur",
"carbon",
"nitrogen",
"water"
),
list(
"lithium",
"sugar",
"sacid",
"copper",
"mercury",
"sodium",
"iodine",
"bromine"
),
list(
"ethanol",
"chlorine",
"potassium",
"aluminium",
"radium",
"fluorine",
"iron",
"welding_fuel",
"silver",
"stable_plasma"
),
list(
"oil",
"ash",
"acetone",
"saltpetre",
"ammonia",
"diethylamine"
)
)
/obj/machinery/chem_dispenser/constructable/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/chem_dispenser(null)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(null)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(null)
component_parts += new /obj/item/weapon/stock_parts/manipulator(null)
component_parts += new /obj/item/weapon/stock_parts/capacitor(null)
component_parts += new /obj/item/weapon/stock_parts/console_screen(null)
component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
RefreshParts()
/obj/machinery/chem_dispenser/constructable/RefreshParts()
var/time = 0
var/temp_energy = 0
var/i
for(var/obj/item/weapon/stock_parts/matter_bin/M in component_parts)
temp_energy += M.rating
temp_energy--
max_energy = temp_energy * 5 //max energy = (bin1.rating + bin2.rating - 1) * 5, 5 on lowest 25 on highest
for(var/obj/item/weapon/stock_parts/capacitor/C in component_parts)
time += C.rating
for(var/obj/item/weapon/stock_parts/cell/P in component_parts)
time += round(P.maxcharge, 10000) / 10000
recharge_delay /= time/2 //delay between recharges, double the usual time on lowest 50% less than usual on highest
for(var/obj/item/weapon/stock_parts/manipulator/M in component_parts)
for(i=1, i<=M.rating, i++)
dispensable_reagents |= dispensable_reagent_tiers[i]
dispensable_reagents = sortList(dispensable_reagents)
/obj/machinery/chem_dispenser/constructable/attackby(var/obj/item/I, var/mob/user, params)
..()
if(default_deconstruction_screwdriver(user, "minidispenser-o", "minidispenser", I))
return
if(exchange_parts(user, I))
return
if(panel_open)
if(istype(I, /obj/item/weapon/crowbar))
if(beaker)
beaker.loc = loc
beaker = null
default_deconstruction_crowbar(I)
return 1
/obj/machinery/chem_dispenser/drinks
name = "soda dispenser"
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "soda_dispenser"
amount = 10
dispensable_reagents = list(
"water",
"ice",
"coffee",
"cream",
"tea",
"icetea",
"cola",
"spacemountainwind",
"dr_gibb",
"space_up",
"tonic",
"sodawater",
"lemon_lime",
"sugar",
"orangejuice",
"limejuice",
"tomatojuice"
)
/obj/machinery/chem_dispenser/drinks/attackby(obj/item/I, mob/user)
if(default_unfasten_wrench(user, I))
return
if (istype(I, /obj/item/weapon/reagent_containers/glass) || \
istype(I, /obj/item/weapon/reagent_containers/food/drinks/drinkingglass) || \
istype(I, /obj/item/weapon/reagent_containers/food/drinks/shaker))
if (beaker)
return 1
else
if(!user.drop_item())
return 1
src.beaker = I
beaker.loc = src
update_icon()
return
/obj/machinery/chem_dispenser/drinks/beer
name = "booze dispenser"
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "booze_dispenser"
dispensable_reagents = list(
"lemon_lime",
"sugar",
"orangejuice",
"limejuice",
"sodawater",
"tonic",
"beer",
"kahlua",
"whiskey",
"wine",
"vodka",
"gin",
"rum",
"tequila",
"vermouth",
"cognac",
"ale"
)
@@ -1,126 +1,126 @@
/obj/machinery/chem_heater
name = "chemical heater"
density = 1
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "mixer0b"
use_power = 1
idle_power_usage = 40
var/obj/item/weapon/reagent_containers/beaker = null
var/desired_temp = 300
var/heater_coefficient = 0.10
var/on = FALSE
/obj/machinery/chem_heater/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/chem_heater(null)
component_parts += new /obj/item/weapon/stock_parts/micro_laser(null)
component_parts += new /obj/item/weapon/stock_parts/console_screen(null)
RefreshParts()
/obj/machinery/chem_heater/RefreshParts()
heater_coefficient = 0.10
for(var/obj/item/weapon/stock_parts/micro_laser/M in component_parts)
heater_coefficient *= M.rating
/obj/machinery/chem_heater/process()
..()
if(stat & NOPOWER)
return
if(on)
if(beaker)
if(beaker.reagents.chem_temp > desired_temp)
beaker.reagents.chem_temp += min(-1, (desired_temp - beaker.reagents.chem_temp) * heater_coefficient)
if(beaker.reagents.chem_temp < desired_temp)
beaker.reagents.chem_temp += max(1, (desired_temp - beaker.reagents.chem_temp) * heater_coefficient)
beaker.reagents.chem_temp = round(beaker.reagents.chem_temp) //stops stuff like 456.12312312302
beaker.reagents.handle_reactions()
/obj/machinery/chem_heater/power_change()
if(powered())
stat &= ~NOPOWER
else
spawn(rand(0, 15))
stat |= NOPOWER
/obj/machinery/chem_heater/attackby(obj/item/I, mob/user, params)
if(isrobot(user))
return
if(istype(I, /obj/item/weapon/reagent_containers/glass))
if(beaker)
user << "<span class='warning'>A beaker is already loaded into the machine!</span>"
return
if(user.drop_item())
beaker = I
I.loc = src
user << "<span class='notice'>You add the beaker to the machine.</span>"
icon_state = "mixer1b"
if(default_deconstruction_screwdriver(user, "mixer0b", "mixer0b", I))
return
if(exchange_parts(user, I))
return
if(panel_open)
if(istype(I, /obj/item/weapon/crowbar))
eject_beaker()
default_deconstruction_crowbar(I)
return 1
/obj/machinery/chem_heater/attack_hand(mob/user)
if (!user)
return
interact(user)
/obj/machinery/chem_heater/ui_act(action, params)
if(..())
return
switch(action)
if("power")
on = !on
if("temperature")
desired_temp = Clamp(input("Please input the target temperature", name) as num, 0, 1000)
if("eject")
eject_beaker()
return 1
/obj/machinery/chem_heater/interact(mob/user)
if(stat & BROKEN)
return
ui_interact(user)
/obj/machinery/chem_heater/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 0)
ui = SSnano.try_update_ui(user, src, ui_key, ui, force_open = force_open)
if (!ui)
ui = new(user, src, ui_key, "chem_heater", name, 350, 400)
ui.open()
/obj/machinery/chem_heater/get_ui_data()
var/data = list()
data["targetTemp"] = desired_temp
data["isActive"] = on
data["isBeakerLoaded"] = beaker ? 1 : 0
data["currentTemp"] = beaker ? beaker.reagents.chem_temp : null
data["beakerCurrentVolume"] = beaker ? beaker.reagents.total_volume : null
data["beakerMaxVolume"] = beaker ? beaker.volume : null
var beakerContents[0]
if(beaker)
for(var/datum/reagent/R in beaker.reagents.reagent_list)
beakerContents.Add(list(list("name" = R.name, "volume" = R.volume))) // list in a list because Byond merges the first list...
data["beakerContents"] = beakerContents
return data
/obj/machinery/chem_heater/proc/eject_beaker()
if(beaker)
beaker.loc = get_turf(src)
beaker.reagents.handle_reactions()
beaker = null
/obj/machinery/chem_heater
name = "chemical heater"
density = 1
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "mixer0b"
use_power = 1
idle_power_usage = 40
var/obj/item/weapon/reagent_containers/beaker = null
var/desired_temp = 300
var/heater_coefficient = 0.10
var/on = FALSE
/obj/machinery/chem_heater/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/chem_heater(null)
component_parts += new /obj/item/weapon/stock_parts/micro_laser(null)
component_parts += new /obj/item/weapon/stock_parts/console_screen(null)
RefreshParts()
/obj/machinery/chem_heater/RefreshParts()
heater_coefficient = 0.10
for(var/obj/item/weapon/stock_parts/micro_laser/M in component_parts)
heater_coefficient *= M.rating
/obj/machinery/chem_heater/process()
..()
if(stat & NOPOWER)
return
if(on)
if(beaker)
if(beaker.reagents.chem_temp > desired_temp)
beaker.reagents.chem_temp += min(-1, (desired_temp - beaker.reagents.chem_temp) * heater_coefficient)
if(beaker.reagents.chem_temp < desired_temp)
beaker.reagents.chem_temp += max(1, (desired_temp - beaker.reagents.chem_temp) * heater_coefficient)
beaker.reagents.chem_temp = round(beaker.reagents.chem_temp) //stops stuff like 456.12312312302
beaker.reagents.handle_reactions()
/obj/machinery/chem_heater/power_change()
if(powered())
stat &= ~NOPOWER
else
spawn(rand(0, 15))
stat |= NOPOWER
/obj/machinery/chem_heater/attackby(obj/item/I, mob/user, params)
if(isrobot(user))
return
if(istype(I, /obj/item/weapon/reagent_containers/glass))
if(beaker)
user << "<span class='warning'>A beaker is already loaded into the machine!</span>"
return
if(user.drop_item())
beaker = I
I.loc = src
user << "<span class='notice'>You add the beaker to the machine.</span>"
icon_state = "mixer1b"
if(default_deconstruction_screwdriver(user, "mixer0b", "mixer0b", I))
return
if(exchange_parts(user, I))
return
if(panel_open)
if(istype(I, /obj/item/weapon/crowbar))
eject_beaker()
default_deconstruction_crowbar(I)
return 1
/obj/machinery/chem_heater/attack_hand(mob/user)
if (!user)
return
interact(user)
/obj/machinery/chem_heater/ui_act(action, params)
if(..())
return
switch(action)
if("power")
on = !on
if("temperature")
desired_temp = Clamp(input("Please input the target temperature", name) as num, 0, 1000)
if("eject")
eject_beaker()
return 1
/obj/machinery/chem_heater/interact(mob/user)
if(stat & BROKEN)
return
ui_interact(user)
/obj/machinery/chem_heater/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 0)
ui = SSnano.try_update_ui(user, src, ui_key, ui, force_open = force_open)
if (!ui)
ui = new(user, src, ui_key, "chem_heater", name, 350, 400)
ui.open()
/obj/machinery/chem_heater/get_ui_data()
var/data = list()
data["targetTemp"] = desired_temp
data["isActive"] = on
data["isBeakerLoaded"] = beaker ? 1 : 0
data["currentTemp"] = beaker ? beaker.reagents.chem_temp : null
data["beakerCurrentVolume"] = beaker ? beaker.reagents.total_volume : null
data["beakerMaxVolume"] = beaker ? beaker.volume : null
var beakerContents[0]
if(beaker)
for(var/datum/reagent/R in beaker.reagents.reagent_list)
beakerContents.Add(list(list("name" = R.name, "volume" = R.volume))) // list in a list because Byond merges the first list...
data["beakerContents"] = beakerContents
return data
/obj/machinery/chem_heater/proc/eject_beaker()
if(beaker)
beaker.loc = get_turf(src)
beaker.reagents.handle_reactions()
beaker = null
icon_state = "mixer0b"
File diff suppressed because it is too large Load Diff
+44 -44
View File
@@ -1,45 +1,45 @@
/datum/surgery/cavity_implant
name = "cavity implant"
steps = list(/datum/surgery_step/incise, /datum/surgery_step/clamp_bleeders, /datum/surgery_step/retract_skin, /datum/surgery_step/incise, /datum/surgery_step/handle_cavity, /datum/surgery_step/close)
species = list(/mob/living/carbon/human, /mob/living/carbon/monkey)
possible_locs = list("chest")
//handle cavity
/datum/surgery_step/handle_cavity
name = "implant item"
accept_hand = 1
accept_any_item = 1
time = 32
var/obj/item/IC = null
/datum/surgery_step/handle_cavity/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
for(var/obj/item/I in target.internal_organs)
if(!istype(I, /obj/item/organ))
IC = I
break
if(tool)
user.visible_message("[user] begins to insert [tool] into [target]'s [target_zone].", "<span class='notice'>You begin to insert [tool] into [target]'s [target_zone]...</span>")
else
user.visible_message("[user] checks for items in [target]'s [target_zone].", "<span class='notice'>You check for items in [target]'s [target_zone]...</span>")
/datum/surgery_step/handle_cavity/success(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
if(tool)
if(IC || tool.w_class > 3 || NODROP in tool.flags || istype(tool, /obj/item/organ))
user << "<span class='warning'>You can't seem to fit [tool] in [target]'s [target_zone]!</span>"
return 0
else
user.visible_message("[user] stuffs [tool] into [target]'s [target_zone]!", "<span class='notice'>You stuff [tool] into [target]'s [target_zone].</span>")
user.drop_item()
target.internal_organs += tool
tool.loc = target
return 1
else
if(IC)
user.visible_message("[user] pulls [IC] out of [target]'s [target_zone]!", "<span class='notice'>You pull [IC] out of [target]'s [target_zone].</span>")
user.put_in_hands(IC)
target.internal_organs -= IC
return 1
else
user << "<span class='warning'>You don't find anything in [target]'s [target_zone].</span>"
/datum/surgery/cavity_implant
name = "cavity implant"
steps = list(/datum/surgery_step/incise, /datum/surgery_step/clamp_bleeders, /datum/surgery_step/retract_skin, /datum/surgery_step/incise, /datum/surgery_step/handle_cavity, /datum/surgery_step/close)
species = list(/mob/living/carbon/human, /mob/living/carbon/monkey)
possible_locs = list("chest")
//handle cavity
/datum/surgery_step/handle_cavity
name = "implant item"
accept_hand = 1
accept_any_item = 1
time = 32
var/obj/item/IC = null
/datum/surgery_step/handle_cavity/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
for(var/obj/item/I in target.internal_organs)
if(!istype(I, /obj/item/organ))
IC = I
break
if(tool)
user.visible_message("[user] begins to insert [tool] into [target]'s [target_zone].", "<span class='notice'>You begin to insert [tool] into [target]'s [target_zone]...</span>")
else
user.visible_message("[user] checks for items in [target]'s [target_zone].", "<span class='notice'>You check for items in [target]'s [target_zone]...</span>")
/datum/surgery_step/handle_cavity/success(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
if(tool)
if(IC || tool.w_class > 3 || NODROP in tool.flags || istype(tool, /obj/item/organ))
user << "<span class='warning'>You can't seem to fit [tool] in [target]'s [target_zone]!</span>"
return 0
else
user.visible_message("[user] stuffs [tool] into [target]'s [target_zone]!", "<span class='notice'>You stuff [tool] into [target]'s [target_zone].</span>")
user.drop_item()
target.internal_organs += tool
tool.loc = target
return 1
else
if(IC)
user.visible_message("[user] pulls [IC] out of [target]'s [target_zone]!", "<span class='notice'>You pull [IC] out of [target]'s [target_zone].</span>")
user.put_in_hands(IC)
target.internal_organs -= IC
return 1
else
user << "<span class='warning'>You don't find anything in [target]'s [target_zone].</span>"
return 0