mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Particle acceleration wiring.
This commit is contained in:
@@ -170,6 +170,7 @@
|
||||
#include "code\datums\wires\autolathe.dm"
|
||||
#include "code\datums\wires\camera.dm"
|
||||
#include "code\datums\wires\mulebot.dm"
|
||||
#include "code\datums\wires\particle_accelerator.dm"
|
||||
#include "code\datums\wires\robot.dm"
|
||||
#include "code\datums\wires\smartfridge.dm"
|
||||
#include "code\datums\wires\suit_storage_unit.dm"
|
||||
|
||||
52
code/datums/wires/particle_accelerator.dm
Normal file
52
code/datums/wires/particle_accelerator.dm
Normal file
@@ -0,0 +1,52 @@
|
||||
/datum/wires/particle_acc/control_box
|
||||
wire_count = 5
|
||||
holder_type = /obj/machinery/particle_accelerator/control_box
|
||||
|
||||
var/const/PARTICLE_TOGGLE_WIRE = 1 // Toggles whether the PA is on or not.
|
||||
var/const/PARTICLE_STRENGTH_WIRE = 2 // Determines the strength of the PA.
|
||||
var/const/PARTICLE_INTERFACE_WIRE = 4 // Determines the interface showing up.
|
||||
var/const/PARTICLE_LIMIT_POWER_WIRE = 8 // Determines how strong the PA can be.
|
||||
//var/const/PARTICLE_NOTHING_WIRE = 16 // Blank wire
|
||||
|
||||
/datum/wires/particle_acc/control_box/CanUse(var/mob/living/L)
|
||||
var/obj/machinery/particle_accelerator/control_box/C = holder
|
||||
if(C.construction_state == 2)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/datum/wires/particle_acc/control_box/UpdatePulsed(var/index)
|
||||
var/obj/machinery/particle_accelerator/control_box/C = holder
|
||||
switch(index)
|
||||
|
||||
if(PARTICLE_TOGGLE_WIRE)
|
||||
C.toggle_power()
|
||||
|
||||
if(PARTICLE_STRENGTH_WIRE)
|
||||
C.add_strength()
|
||||
|
||||
if(PARTICLE_INTERFACE_WIRE)
|
||||
C.interface_control = !C.interface_control
|
||||
|
||||
if(PARTICLE_LIMIT_POWER_WIRE)
|
||||
C.visible_message("\icon[C]<b>[C]</b> makes a large whirring noise.")
|
||||
|
||||
/datum/wires/particle_acc/control_box/UpdateCut(var/index, var/mended)
|
||||
var/obj/machinery/particle_accelerator/control_box/C = holder
|
||||
switch(index)
|
||||
|
||||
if(PARTICLE_TOGGLE_WIRE)
|
||||
if(C.active == !mended)
|
||||
C.toggle_power()
|
||||
|
||||
if(PARTICLE_STRENGTH_WIRE)
|
||||
|
||||
for(var/i = 1; i < 3; i++)
|
||||
C.remove_strength()
|
||||
|
||||
if(PARTICLE_INTERFACE_WIRE)
|
||||
C.interface_control = mended
|
||||
|
||||
if(PARTICLE_LIMIT_POWER_WIRE)
|
||||
C.strength_upper_limit = (mended ? 2 : 3)
|
||||
if(C.strength_upper_limit < C.strength)
|
||||
C.remove_strength()
|
||||
@@ -14,11 +14,15 @@
|
||||
construction_state = 0
|
||||
active = 0
|
||||
dir = 1
|
||||
var/strength_upper_limit = 2
|
||||
var/interface_control = 1
|
||||
var/list/obj/structure/particle_accelerator/connected_parts
|
||||
var/assembled = 0
|
||||
var/parts = null
|
||||
var/datum/wires/particle_acc/control_box/wires = null
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/New()
|
||||
wires = new(src)
|
||||
connected_parts = list()
|
||||
active_power_usage = initial(active_power_usage) * (strength + 1)
|
||||
..()
|
||||
@@ -27,6 +31,8 @@
|
||||
/obj/machinery/particle_accelerator/control_box/attack_hand(mob/user as mob)
|
||||
if(construction_state >= 3)
|
||||
interact(user)
|
||||
else if(construction_state == 2) // Wires exposed
|
||||
wires.Interact(user)
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/update_state()
|
||||
if(construction_state < 3)
|
||||
@@ -79,49 +85,51 @@
|
||||
usr << browse(null, "window=pacontrol")
|
||||
usr.unset_machine()
|
||||
return
|
||||
|
||||
if(href_list["togglep"])
|
||||
src.toggle_power()
|
||||
investigate_log("turned [active?"<font color='red'>ON</font>":"<font color='green'>OFF</font>"] by [usr.key]","singulo")
|
||||
if (active)
|
||||
message_admins("PA Control Computer turned ON by [key_name(usr, usr.client)](<A HREF='?_src_=holder;adminmoreinfo=\ref[usr]'>?</A>) in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("PA Control Computer turned ON by [usr.ckey]([usr]) in ([x],[y],[z])")
|
||||
if(!wires.IsIndexCut(PARTICLE_TOGGLE_WIRE))
|
||||
src.toggle_power()
|
||||
else if(href_list["scan"])
|
||||
src.part_scan()
|
||||
|
||||
else if(href_list["strengthup"])
|
||||
var/old_strength = strength
|
||||
strength++
|
||||
if(strength > 2)
|
||||
strength = 2
|
||||
else
|
||||
message_admins("PA Control Computer increased to [strength] by [key_name(usr, usr.client)](<A HREF='?_src_=holder;adminmoreinfo=\ref[usr]'>?</A>) in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("PA Control Computer increased to [strength] by [usr.ckey]([usr]) in ([x],[y],[z])")
|
||||
investigate_log("increased to <font color='red'>[strength]</font> by [usr.key]","singulo")
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
part.strength = strength
|
||||
part.update_icon()
|
||||
|
||||
if (strength != old_strength)
|
||||
active_power_usage = initial(active_power_usage) * (strength + 1)
|
||||
use_power(0) //update power usage
|
||||
if(!wires.IsIndexCut(PARTICLE_STRENGTH_WIRE))
|
||||
add_strength()
|
||||
|
||||
else if(href_list["strengthdown"])
|
||||
var/old_strength = strength
|
||||
strength--
|
||||
if(strength < 0)
|
||||
strength = 0
|
||||
else
|
||||
investigate_log("decreased to <font color='green'>[strength]</font> by [usr.key]","singulo")
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
part.strength = strength
|
||||
part.update_icon()
|
||||
|
||||
if (strength != old_strength)
|
||||
active_power_usage = initial(active_power_usage) * (strength + 1)
|
||||
use_power(0) //update power usage
|
||||
if(!wires.IsIndexCut(PARTICLE_STRENGTH_WIRE))
|
||||
remove_strength()
|
||||
|
||||
src.updateDialog()
|
||||
src.update_icon()
|
||||
return
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/strength_change()
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
part.strength = strength
|
||||
part.update_icon()
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/add_strength(var/s)
|
||||
if(assembled)
|
||||
strength++
|
||||
if(strength > strength_upper_limit)
|
||||
strength = strength_upper_limit
|
||||
else
|
||||
message_admins("PA Control Computer increased to [strength] by [key_name(usr, usr.client)](<A HREF='?_src_=holder;adminmoreinfo=\ref[usr]'>?</A>) in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("PA Control Computer increased to [strength] by [usr.ckey]([usr]) in ([x],[y],[z])")
|
||||
investigate_log("increased to <font color='red'>[strength]</font> by [usr.key]","singulo")
|
||||
strength_change()
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/remove_strength(var/s)
|
||||
if(assembled)
|
||||
strength--
|
||||
if(strength < 0)
|
||||
strength = 0
|
||||
else
|
||||
message_admins("PA Control Computer decreased to [strength] by [key_name(usr, usr.client)](<A HREF='?_src_=holder;adminmoreinfo=\ref[usr]'>?</A>) in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("PA Control Computer decreased to [strength] by [usr.ckey]([usr]) in ([x],[y],[z])")
|
||||
investigate_log("decreased to <font color='green'>[strength]</font> by [usr.key]","singulo")
|
||||
strength_change()
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/power_change()
|
||||
..()
|
||||
@@ -198,6 +206,9 @@
|
||||
|
||||
/obj/machinery/particle_accelerator/control_box/proc/toggle_power()
|
||||
src.active = !src.active
|
||||
investigate_log("turned [active?"<font color='red'>ON</font>":"<font color='green'>OFF</font>"] by [usr ? usr.key : "outside forces"]","singulo")
|
||||
message_admins("PA Control Computer turned [active ?"ON":"OFF"] by [key_name(usr, usr.client)](<A HREF='?_src_=holder;adminmoreinfo=\ref[usr]'>?</A>) in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("PA Control Computer turned [active ?"ON":"OFF"] by [usr.ckey]([usr]) in ([x],[y],[z])")
|
||||
if(src.active)
|
||||
update_use_power(2)
|
||||
for(var/obj/structure/particle_accelerator/part in connected_parts)
|
||||
@@ -241,4 +252,4 @@
|
||||
|
||||
user << browse(dat, "window=pacontrol;size=420x500")
|
||||
onclose(user, "pacontrol")
|
||||
return
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user