@@ -1,40 +1,40 @@
|
||||
/obj/item/weapon/am_containment
|
||||
name = "antimatter containment jar"
|
||||
desc = "Holds antimatter."
|
||||
icon = 'icons/obj/machines/antimatter.dmi'
|
||||
icon_state = "jar"
|
||||
density = 0
|
||||
anchored = 0
|
||||
force = 8
|
||||
throwforce = 10
|
||||
throw_speed = 1
|
||||
throw_range = 2
|
||||
|
||||
var/fuel = 10000
|
||||
var/fuel_max = 10000//Lets try this for now
|
||||
var/stability = 100//TODO: add all the stability things to this so its not very safe if you keep hitting in on things
|
||||
|
||||
|
||||
/obj/item/weapon/am_containment/ex_act(severity, target)
|
||||
switch(severity)
|
||||
if(1)
|
||||
/obj/item/weapon/am_containment
|
||||
name = "antimatter containment jar"
|
||||
desc = "Holds antimatter."
|
||||
icon = 'icons/obj/machines/antimatter.dmi'
|
||||
icon_state = "jar"
|
||||
density = 0
|
||||
anchored = 0
|
||||
force = 8
|
||||
throwforce = 10
|
||||
throw_speed = 1
|
||||
throw_range = 2
|
||||
|
||||
var/fuel = 10000
|
||||
var/fuel_max = 10000//Lets try this for now
|
||||
var/stability = 100//TODO: add all the stability things to this so its not very safe if you keep hitting in on things
|
||||
|
||||
|
||||
/obj/item/weapon/am_containment/ex_act(severity, target)
|
||||
switch(severity)
|
||||
if(1)
|
||||
explosion(get_turf(src), 1, 2, 3, 5)//Should likely be larger but this works fine for now I guess
|
||||
if(src)
|
||||
qdel(src)
|
||||
if(2)
|
||||
if(prob((fuel/10)-stability))
|
||||
if(src)
|
||||
qdel(src)
|
||||
if(2)
|
||||
if(prob((fuel/10)-stability))
|
||||
explosion(get_turf(src), 1, 2, 3, 5)
|
||||
if(src)
|
||||
qdel(src)
|
||||
return
|
||||
stability -= 40
|
||||
if(3)
|
||||
stability -= 20
|
||||
//check_stability()
|
||||
return
|
||||
|
||||
/obj/item/weapon/am_containment/proc/usefuel(wanted)
|
||||
if(fuel < wanted)
|
||||
wanted = fuel
|
||||
fuel -= wanted
|
||||
if(src)
|
||||
qdel(src)
|
||||
return
|
||||
stability -= 40
|
||||
if(3)
|
||||
stability -= 20
|
||||
//check_stability()
|
||||
return
|
||||
|
||||
/obj/item/weapon/am_containment/proc/usefuel(wanted)
|
||||
if(fuel < wanted)
|
||||
wanted = fuel
|
||||
fuel -= wanted
|
||||
return wanted
|
||||
@@ -1,362 +1,362 @@
|
||||
/obj/machinery/power/am_control_unit
|
||||
name = "antimatter control unit"
|
||||
desc = "This device injects antimatter into connected shielding units, the more antimatter injected the more power produced. Wrench the device to set it up."
|
||||
icon = 'icons/obj/machines/antimatter.dmi'
|
||||
icon_state = "control"
|
||||
anchored = 0
|
||||
density = 1
|
||||
/obj/machinery/power/am_control_unit
|
||||
name = "antimatter control unit"
|
||||
desc = "This device injects antimatter into connected shielding units, the more antimatter injected the more power produced. Wrench the device to set it up."
|
||||
icon = 'icons/obj/machines/antimatter.dmi'
|
||||
icon_state = "control"
|
||||
anchored = 0
|
||||
density = 1
|
||||
use_power = IDLE_POWER_USE
|
||||
idle_power_usage = 100
|
||||
active_power_usage = 1000
|
||||
|
||||
var/list/obj/machinery/am_shielding/linked_shielding
|
||||
var/list/obj/machinery/am_shielding/linked_cores
|
||||
var/obj/item/weapon/am_containment/fueljar
|
||||
var/update_shield_icons = 0
|
||||
var/stability = 100
|
||||
var/exploding = 0
|
||||
|
||||
var/active = 0//On or not
|
||||
var/fuel_injection = 2//How much fuel to inject
|
||||
var/shield_icon_delay = 0//delays resetting for a short time
|
||||
var/reported_core_efficiency = 0
|
||||
|
||||
var/power_cycle = 0
|
||||
var/power_cycle_delay = 4//How many ticks till produce_power is called
|
||||
var/stored_core_stability = 0
|
||||
var/stored_core_stability_delay = 0
|
||||
|
||||
var/stored_power = 0//Power to deploy per tick
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/New()
|
||||
..()
|
||||
linked_shielding = list()
|
||||
linked_cores = list()
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/Destroy()//Perhaps damage and run stability checks rather than just del on the others
|
||||
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
|
||||
AMS.control_unit = null
|
||||
qdel(AMS)
|
||||
qdel(fueljar)
|
||||
fueljar = null
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/process()
|
||||
if(exploding)
|
||||
idle_power_usage = 100
|
||||
active_power_usage = 1000
|
||||
|
||||
var/list/obj/machinery/am_shielding/linked_shielding
|
||||
var/list/obj/machinery/am_shielding/linked_cores
|
||||
var/obj/item/weapon/am_containment/fueljar
|
||||
var/update_shield_icons = 0
|
||||
var/stability = 100
|
||||
var/exploding = 0
|
||||
|
||||
var/active = 0//On or not
|
||||
var/fuel_injection = 2//How much fuel to inject
|
||||
var/shield_icon_delay = 0//delays resetting for a short time
|
||||
var/reported_core_efficiency = 0
|
||||
|
||||
var/power_cycle = 0
|
||||
var/power_cycle_delay = 4//How many ticks till produce_power is called
|
||||
var/stored_core_stability = 0
|
||||
var/stored_core_stability_delay = 0
|
||||
|
||||
var/stored_power = 0//Power to deploy per tick
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/New()
|
||||
..()
|
||||
linked_shielding = list()
|
||||
linked_cores = list()
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/Destroy()//Perhaps damage and run stability checks rather than just del on the others
|
||||
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
|
||||
AMS.control_unit = null
|
||||
qdel(AMS)
|
||||
qdel(fueljar)
|
||||
fueljar = null
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/process()
|
||||
if(exploding)
|
||||
explosion(get_turf(src),8,12,18,12)
|
||||
if(src)
|
||||
qdel(src)
|
||||
|
||||
if(update_shield_icons && !shield_icon_delay)
|
||||
check_shield_icons()
|
||||
update_shield_icons = 0
|
||||
|
||||
if(stat & (NOPOWER|BROKEN) || !active)//can update the icons even without power
|
||||
return
|
||||
|
||||
if(!fueljar)//No fuel but we are on, shutdown
|
||||
toggle_power()
|
||||
playsound(src.loc, 'sound/machines/buzz-two.ogg', 50, 0)
|
||||
return
|
||||
|
||||
add_avail(stored_power)
|
||||
|
||||
power_cycle++
|
||||
if(power_cycle >= power_cycle_delay)
|
||||
produce_power()
|
||||
power_cycle = 0
|
||||
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/produce_power()
|
||||
playsound(src.loc, 'sound/effects/bang.ogg', 25, 1)
|
||||
var/core_power = reported_core_efficiency//Effectively how much fuel we can safely deal with
|
||||
if(core_power <= 0)
|
||||
return 0//Something is wrong
|
||||
var/core_damage = 0
|
||||
var/fuel = fueljar.usefuel(fuel_injection)
|
||||
|
||||
stored_power = (fuel/core_power)*fuel*200000
|
||||
//Now check if the cores could deal with it safely, this is done after so you can overload for more power if needed, still a bad idea
|
||||
if(fuel > (2*core_power))//More fuel has been put in than the current cores can deal with
|
||||
if(prob(50))
|
||||
core_damage = 1//Small chance of damage
|
||||
if((fuel-core_power) > 5)
|
||||
core_damage = 5//Now its really starting to overload the cores
|
||||
if((fuel-core_power) > 10)
|
||||
core_damage = 20//Welp now you did it, they wont stand much of this
|
||||
if(core_damage == 0)
|
||||
return
|
||||
for(var/obj/machinery/am_shielding/AMS in linked_cores)
|
||||
AMS.stability -= core_damage
|
||||
AMS.check_stability(1)
|
||||
playsound(src.loc, 'sound/effects/bang.ogg', 50, 1)
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/emp_act(severity)
|
||||
switch(severity)
|
||||
if(1)
|
||||
if(active)
|
||||
toggle_power()
|
||||
stability -= rand(15,30)
|
||||
if(2)
|
||||
if(active)
|
||||
toggle_power()
|
||||
stability -= rand(10,20)
|
||||
..()
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/blob_act()
|
||||
stability -= 20
|
||||
if(prob(100-stability))//Might infect the rest of the machine
|
||||
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
|
||||
AMS.blob_act()
|
||||
qdel(src)
|
||||
return
|
||||
check_stability()
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/ex_act(severity, target)
|
||||
stability -= (80 - (severity * 20))
|
||||
check_stability()
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/bullet_act(obj/item/projectile/Proj)
|
||||
. = ..()
|
||||
if(Proj.flag != "bullet")
|
||||
stability -= Proj.force
|
||||
check_stability()
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/power_change()
|
||||
..()
|
||||
if(stat & NOPOWER)
|
||||
if(active)
|
||||
toggle_power(1)
|
||||
else
|
||||
if(src)
|
||||
qdel(src)
|
||||
|
||||
if(update_shield_icons && !shield_icon_delay)
|
||||
check_shield_icons()
|
||||
update_shield_icons = 0
|
||||
|
||||
if(stat & (NOPOWER|BROKEN) || !active)//can update the icons even without power
|
||||
return
|
||||
|
||||
if(!fueljar)//No fuel but we are on, shutdown
|
||||
toggle_power()
|
||||
playsound(src.loc, 'sound/machines/buzz-two.ogg', 50, 0)
|
||||
return
|
||||
|
||||
add_avail(stored_power)
|
||||
|
||||
power_cycle++
|
||||
if(power_cycle >= power_cycle_delay)
|
||||
produce_power()
|
||||
power_cycle = 0
|
||||
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/produce_power()
|
||||
playsound(src.loc, 'sound/effects/bang.ogg', 25, 1)
|
||||
var/core_power = reported_core_efficiency//Effectively how much fuel we can safely deal with
|
||||
if(core_power <= 0)
|
||||
return 0//Something is wrong
|
||||
var/core_damage = 0
|
||||
var/fuel = fueljar.usefuel(fuel_injection)
|
||||
|
||||
stored_power = (fuel/core_power)*fuel*200000
|
||||
//Now check if the cores could deal with it safely, this is done after so you can overload for more power if needed, still a bad idea
|
||||
if(fuel > (2*core_power))//More fuel has been put in than the current cores can deal with
|
||||
if(prob(50))
|
||||
core_damage = 1//Small chance of damage
|
||||
if((fuel-core_power) > 5)
|
||||
core_damage = 5//Now its really starting to overload the cores
|
||||
if((fuel-core_power) > 10)
|
||||
core_damage = 20//Welp now you did it, they wont stand much of this
|
||||
if(core_damage == 0)
|
||||
return
|
||||
for(var/obj/machinery/am_shielding/AMS in linked_cores)
|
||||
AMS.stability -= core_damage
|
||||
AMS.check_stability(1)
|
||||
playsound(src.loc, 'sound/effects/bang.ogg', 50, 1)
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/emp_act(severity)
|
||||
switch(severity)
|
||||
if(1)
|
||||
if(active)
|
||||
toggle_power()
|
||||
stability -= rand(15,30)
|
||||
if(2)
|
||||
if(active)
|
||||
toggle_power()
|
||||
stability -= rand(10,20)
|
||||
..()
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/blob_act()
|
||||
stability -= 20
|
||||
if(prob(100-stability))//Might infect the rest of the machine
|
||||
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
|
||||
AMS.blob_act()
|
||||
qdel(src)
|
||||
return
|
||||
check_stability()
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/ex_act(severity, target)
|
||||
stability -= (80 - (severity * 20))
|
||||
check_stability()
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/bullet_act(obj/item/projectile/Proj)
|
||||
. = ..()
|
||||
if(Proj.flag != "bullet")
|
||||
stability -= Proj.force
|
||||
check_stability()
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/power_change()
|
||||
..()
|
||||
if(stat & NOPOWER)
|
||||
if(active)
|
||||
toggle_power(1)
|
||||
else
|
||||
use_power = NO_POWER_USE
|
||||
|
||||
else if(!stat && anchored)
|
||||
|
||||
else if(!stat && anchored)
|
||||
use_power = IDLE_POWER_USE
|
||||
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/update_icon()
|
||||
if(active)
|
||||
icon_state = "control_on"
|
||||
else icon_state = "control"
|
||||
//No other icons for it atm
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/weapon/wrench))
|
||||
if(!anchored)
|
||||
playsound(src.loc, W.usesound, 75, 1)
|
||||
user.visible_message("[user.name] secures the [src.name] to the floor.", \
|
||||
"<span class='notice'>You secure the anchor bolts to the floor.</span>", \
|
||||
"<span class='italics'>You hear a ratchet.</span>")
|
||||
src.anchored = 1
|
||||
connect_to_network()
|
||||
else if(!linked_shielding.len > 0)
|
||||
playsound(src.loc, W.usesound, 75, 1)
|
||||
user.visible_message("[user.name] unsecures the [src.name].", \
|
||||
"<span class='notice'>You remove the anchor bolts.</span>", \
|
||||
"<span class='italics'>You hear a ratchet.</span>")
|
||||
src.anchored = 0
|
||||
disconnect_from_network()
|
||||
else
|
||||
to_chat(user, "<span class='warning'>Once bolted and linked to a shielding unit it the [src.name] is unable to be moved!</span>")
|
||||
|
||||
else if(istype(W, /obj/item/weapon/am_containment))
|
||||
if(fueljar)
|
||||
to_chat(user, "<span class='warning'>There is already a [fueljar] inside!</span>")
|
||||
return
|
||||
|
||||
if(!user.transferItemToLoc(W, src))
|
||||
return
|
||||
fueljar = W
|
||||
user.visible_message("[user.name] loads an [W.name] into the [src.name].", \
|
||||
"<span class='notice'>You load an [W.name].</span>", \
|
||||
"<span class='italics'>You hear a thunk.</span>")
|
||||
else
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/take_damage(damage, damage_type = BRUTE, sound_effect = 1)
|
||||
switch(damage_type)
|
||||
if(BRUTE)
|
||||
if(sound_effect)
|
||||
if(damage)
|
||||
playsound(loc, 'sound/weapons/smash.ogg', 50, 1)
|
||||
else
|
||||
playsound(loc, 'sound/weapons/tap.ogg', 50, 1)
|
||||
if(BURN)
|
||||
if(sound_effect)
|
||||
playsound(src.loc, 'sound/items/Welder.ogg', 100, 1)
|
||||
else
|
||||
return
|
||||
if(damage >= 20)
|
||||
stability -= damage/2
|
||||
check_stability()
|
||||
|
||||
/obj/machinery/power/am_control_unit/attack_hand(mob/user)
|
||||
if(anchored)
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/add_shielding(obj/machinery/am_shielding/AMS, AMS_linking = 0)
|
||||
if(!istype(AMS))
|
||||
return 0
|
||||
if(!anchored)
|
||||
return 0
|
||||
if(!AMS_linking && !AMS.link_control(src))
|
||||
return 0
|
||||
linked_shielding.Add(AMS)
|
||||
update_shield_icons = 1
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/remove_shielding(obj/machinery/am_shielding/AMS)
|
||||
if(!istype(AMS))
|
||||
return 0
|
||||
linked_shielding.Remove(AMS)
|
||||
update_shield_icons = 2
|
||||
if(active)
|
||||
toggle_power()
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/check_stability()//TODO: make it break when low also might want to add a way to fix it like a part or such that can be replaced
|
||||
if(stability <= 0)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/toggle_power(powerfail = 0)
|
||||
active = !active
|
||||
if(active)
|
||||
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/update_icon()
|
||||
if(active)
|
||||
icon_state = "control_on"
|
||||
else icon_state = "control"
|
||||
//No other icons for it atm
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/weapon/wrench))
|
||||
if(!anchored)
|
||||
playsound(src.loc, W.usesound, 75, 1)
|
||||
user.visible_message("[user.name] secures the [src.name] to the floor.", \
|
||||
"<span class='notice'>You secure the anchor bolts to the floor.</span>", \
|
||||
"<span class='italics'>You hear a ratchet.</span>")
|
||||
src.anchored = 1
|
||||
connect_to_network()
|
||||
else if(!linked_shielding.len > 0)
|
||||
playsound(src.loc, W.usesound, 75, 1)
|
||||
user.visible_message("[user.name] unsecures the [src.name].", \
|
||||
"<span class='notice'>You remove the anchor bolts.</span>", \
|
||||
"<span class='italics'>You hear a ratchet.</span>")
|
||||
src.anchored = 0
|
||||
disconnect_from_network()
|
||||
else
|
||||
to_chat(user, "<span class='warning'>Once bolted and linked to a shielding unit it the [src.name] is unable to be moved!</span>")
|
||||
|
||||
else if(istype(W, /obj/item/weapon/am_containment))
|
||||
if(fueljar)
|
||||
to_chat(user, "<span class='warning'>There is already a [fueljar] inside!</span>")
|
||||
return
|
||||
|
||||
if(!user.transferItemToLoc(W, src))
|
||||
return
|
||||
fueljar = W
|
||||
user.visible_message("[user.name] loads an [W.name] into the [src.name].", \
|
||||
"<span class='notice'>You load an [W.name].</span>", \
|
||||
"<span class='italics'>You hear a thunk.</span>")
|
||||
else
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/take_damage(damage, damage_type = BRUTE, sound_effect = 1)
|
||||
switch(damage_type)
|
||||
if(BRUTE)
|
||||
if(sound_effect)
|
||||
if(damage)
|
||||
playsound(loc, 'sound/weapons/smash.ogg', 50, 1)
|
||||
else
|
||||
playsound(loc, 'sound/weapons/tap.ogg', 50, 1)
|
||||
if(BURN)
|
||||
if(sound_effect)
|
||||
playsound(src.loc, 'sound/items/welder.ogg', 100, 1)
|
||||
else
|
||||
return
|
||||
if(damage >= 20)
|
||||
stability -= damage/2
|
||||
check_stability()
|
||||
|
||||
/obj/machinery/power/am_control_unit/attack_hand(mob/user)
|
||||
if(anchored)
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/add_shielding(obj/machinery/am_shielding/AMS, AMS_linking = 0)
|
||||
if(!istype(AMS))
|
||||
return 0
|
||||
if(!anchored)
|
||||
return 0
|
||||
if(!AMS_linking && !AMS.link_control(src))
|
||||
return 0
|
||||
linked_shielding.Add(AMS)
|
||||
update_shield_icons = 1
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/remove_shielding(obj/machinery/am_shielding/AMS)
|
||||
if(!istype(AMS))
|
||||
return 0
|
||||
linked_shielding.Remove(AMS)
|
||||
update_shield_icons = 2
|
||||
if(active)
|
||||
toggle_power()
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/check_stability()//TODO: make it break when low also might want to add a way to fix it like a part or such that can be replaced
|
||||
if(stability <= 0)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/toggle_power(powerfail = 0)
|
||||
active = !active
|
||||
if(active)
|
||||
use_power = ACTIVE_POWER_USE
|
||||
visible_message("The [src.name] starts up.")
|
||||
else
|
||||
use_power = !powerfail
|
||||
visible_message("The [src.name] shuts down.")
|
||||
update_icon()
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/check_shield_icons()//Forces icon_update for all shields
|
||||
if(shield_icon_delay)
|
||||
return
|
||||
shield_icon_delay = 1
|
||||
if(update_shield_icons == 2)//2 means to clear everything and rebuild
|
||||
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
|
||||
if(AMS.processing)
|
||||
AMS.shutdown_core()
|
||||
AMS.control_unit = null
|
||||
spawn(10)
|
||||
AMS.controllerscan()
|
||||
linked_shielding = list()
|
||||
|
||||
else
|
||||
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
|
||||
AMS.update_icon()
|
||||
spawn(20)
|
||||
shield_icon_delay = 0
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/check_core_stability()
|
||||
if(stored_core_stability_delay || linked_cores.len <= 0)
|
||||
return
|
||||
stored_core_stability_delay = 1
|
||||
stored_core_stability = 0
|
||||
for(var/obj/machinery/am_shielding/AMS in linked_cores)
|
||||
stored_core_stability += AMS.stability
|
||||
stored_core_stability/=linked_cores.len
|
||||
spawn(40)
|
||||
stored_core_stability_delay = 0
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/interact(mob/user)
|
||||
if((get_dist(src, user) > 1) || (stat & (BROKEN|NOPOWER)))
|
||||
if(!isAI(user))
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=AMcontrol")
|
||||
return
|
||||
user.set_machine(src)
|
||||
|
||||
var/dat = ""
|
||||
dat += "AntiMatter Control Panel<BR>"
|
||||
dat += "<A href='?src=\ref[src];close=1'>Close</A><BR>"
|
||||
dat += "<A href='?src=\ref[src];refresh=1'>Refresh</A><BR>"
|
||||
dat += "<A href='?src=\ref[src];refreshicons=1'>Force Shielding Update</A><BR><BR>"
|
||||
dat += "Status: [(active?"Injecting":"Standby")] <BR>"
|
||||
dat += "<A href='?src=\ref[src];togglestatus=1'>Toggle Status</A><BR>"
|
||||
|
||||
dat += "Stability: [stability]%<BR>"
|
||||
dat += "Reactor parts: [linked_shielding.len]<BR>"//TODO: perhaps add some sort of stability check
|
||||
dat += "Cores: [linked_cores.len]<BR><BR>"
|
||||
dat += "-Current Efficiency: [reported_core_efficiency]<BR>"
|
||||
dat += "-Average Stability: [stored_core_stability] <A href='?src=\ref[src];refreshstability=1'>(update)</A><BR>"
|
||||
dat += "Last Produced: [stored_power]<BR>"
|
||||
|
||||
dat += "Fuel: "
|
||||
if(!fueljar)
|
||||
dat += "<BR>No fuel receptacle detected."
|
||||
else
|
||||
dat += "<A href='?src=\ref[src];ejectjar=1'>Eject</A><BR>"
|
||||
dat += "- [fueljar.fuel]/[fueljar.fuel_max] Units<BR>"
|
||||
|
||||
dat += "- Injecting: [fuel_injection] units<BR>"
|
||||
dat += "- <A href='?src=\ref[src];strengthdown=1'>--</A>|<A href='?src=\ref[src];strengthup=1'>++</A><BR><BR>"
|
||||
|
||||
|
||||
user << browse(dat, "window=AMcontrol;size=420x500")
|
||||
onclose(user, "AMcontrol")
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/Topic(href, href_list)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(href_list["close"])
|
||||
usr << browse(null, "window=AMcontrol")
|
||||
usr.unset_machine()
|
||||
return
|
||||
|
||||
if(href_list["togglestatus"])
|
||||
toggle_power()
|
||||
|
||||
if(href_list["refreshicons"])
|
||||
update_shield_icons = 1
|
||||
|
||||
if(href_list["ejectjar"])
|
||||
if(fueljar)
|
||||
fueljar.loc = src.loc
|
||||
fueljar = null
|
||||
//fueljar.control_unit = null currently it does not care where it is
|
||||
//update_icon() when we have the icon for it
|
||||
|
||||
if(href_list["strengthup"])
|
||||
fuel_injection++
|
||||
|
||||
if(href_list["strengthdown"])
|
||||
fuel_injection--
|
||||
if(fuel_injection < 0)
|
||||
fuel_injection = 0
|
||||
|
||||
if(href_list["refreshstability"])
|
||||
check_core_stability()
|
||||
|
||||
updateDialog()
|
||||
return
|
||||
visible_message("The [src.name] starts up.")
|
||||
else
|
||||
use_power = !powerfail
|
||||
visible_message("The [src.name] shuts down.")
|
||||
update_icon()
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/check_shield_icons()//Forces icon_update for all shields
|
||||
if(shield_icon_delay)
|
||||
return
|
||||
shield_icon_delay = 1
|
||||
if(update_shield_icons == 2)//2 means to clear everything and rebuild
|
||||
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
|
||||
if(AMS.processing)
|
||||
AMS.shutdown_core()
|
||||
AMS.control_unit = null
|
||||
spawn(10)
|
||||
AMS.controllerscan()
|
||||
linked_shielding = list()
|
||||
|
||||
else
|
||||
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
|
||||
AMS.update_icon()
|
||||
spawn(20)
|
||||
shield_icon_delay = 0
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/proc/check_core_stability()
|
||||
if(stored_core_stability_delay || linked_cores.len <= 0)
|
||||
return
|
||||
stored_core_stability_delay = 1
|
||||
stored_core_stability = 0
|
||||
for(var/obj/machinery/am_shielding/AMS in linked_cores)
|
||||
stored_core_stability += AMS.stability
|
||||
stored_core_stability/=linked_cores.len
|
||||
spawn(40)
|
||||
stored_core_stability_delay = 0
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/interact(mob/user)
|
||||
if((get_dist(src, user) > 1) || (stat & (BROKEN|NOPOWER)))
|
||||
if(!isAI(user))
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=AMcontrol")
|
||||
return
|
||||
user.set_machine(src)
|
||||
|
||||
var/dat = ""
|
||||
dat += "AntiMatter Control Panel<BR>"
|
||||
dat += "<A href='?src=\ref[src];close=1'>Close</A><BR>"
|
||||
dat += "<A href='?src=\ref[src];refresh=1'>Refresh</A><BR>"
|
||||
dat += "<A href='?src=\ref[src];refreshicons=1'>Force Shielding Update</A><BR><BR>"
|
||||
dat += "Status: [(active?"Injecting":"Standby")] <BR>"
|
||||
dat += "<A href='?src=\ref[src];togglestatus=1'>Toggle Status</A><BR>"
|
||||
|
||||
dat += "Stability: [stability]%<BR>"
|
||||
dat += "Reactor parts: [linked_shielding.len]<BR>"//TODO: perhaps add some sort of stability check
|
||||
dat += "Cores: [linked_cores.len]<BR><BR>"
|
||||
dat += "-Current Efficiency: [reported_core_efficiency]<BR>"
|
||||
dat += "-Average Stability: [stored_core_stability] <A href='?src=\ref[src];refreshstability=1'>(update)</A><BR>"
|
||||
dat += "Last Produced: [stored_power]<BR>"
|
||||
|
||||
dat += "Fuel: "
|
||||
if(!fueljar)
|
||||
dat += "<BR>No fuel receptacle detected."
|
||||
else
|
||||
dat += "<A href='?src=\ref[src];ejectjar=1'>Eject</A><BR>"
|
||||
dat += "- [fueljar.fuel]/[fueljar.fuel_max] Units<BR>"
|
||||
|
||||
dat += "- Injecting: [fuel_injection] units<BR>"
|
||||
dat += "- <A href='?src=\ref[src];strengthdown=1'>--</A>|<A href='?src=\ref[src];strengthup=1'>++</A><BR><BR>"
|
||||
|
||||
|
||||
user << browse(dat, "window=AMcontrol;size=420x500")
|
||||
onclose(user, "AMcontrol")
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/power/am_control_unit/Topic(href, href_list)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(href_list["close"])
|
||||
usr << browse(null, "window=AMcontrol")
|
||||
usr.unset_machine()
|
||||
return
|
||||
|
||||
if(href_list["togglestatus"])
|
||||
toggle_power()
|
||||
|
||||
if(href_list["refreshicons"])
|
||||
update_shield_icons = 1
|
||||
|
||||
if(href_list["ejectjar"])
|
||||
if(fueljar)
|
||||
fueljar.loc = src.loc
|
||||
fueljar = null
|
||||
//fueljar.control_unit = null currently it does not care where it is
|
||||
//update_icon() when we have the icon for it
|
||||
|
||||
if(href_list["strengthup"])
|
||||
fuel_injection++
|
||||
|
||||
if(href_list["strengthdown"])
|
||||
fuel_injection--
|
||||
if(fuel_injection < 0)
|
||||
fuel_injection = 0
|
||||
|
||||
if(href_list["refreshstability"])
|
||||
check_core_stability()
|
||||
|
||||
updateDialog()
|
||||
return
|
||||
|
||||
@@ -1,247 +1,247 @@
|
||||
//like orange but only checks north/south/east/west for one step
|
||||
/proc/cardinalrange(var/center)
|
||||
var/list/things = list()
|
||||
for(var/direction in GLOB.cardinal)
|
||||
var/turf/T = get_step(center, direction)
|
||||
if(!T) continue
|
||||
things += T.contents
|
||||
return things
|
||||
|
||||
/obj/machinery/am_shielding
|
||||
name = "antimatter reactor section"
|
||||
desc = "This device was built using a plasma life-form that seems to increase plasma's natural ability to react with neutrinos while reducing the combustibility."
|
||||
|
||||
icon = 'icons/obj/machines/antimatter.dmi'
|
||||
icon_state = "shield"
|
||||
anchored = 1
|
||||
density = 1
|
||||
dir = NORTH
|
||||
//like orange but only checks north/south/east/west for one step
|
||||
/proc/cardinalrange(var/center)
|
||||
var/list/things = list()
|
||||
for(var/direction in GLOB.cardinal)
|
||||
var/turf/T = get_step(center, direction)
|
||||
if(!T) continue
|
||||
things += T.contents
|
||||
return things
|
||||
|
||||
/obj/machinery/am_shielding
|
||||
name = "antimatter reactor section"
|
||||
desc = "This device was built using a plasma life-form that seems to increase plasma's natural ability to react with neutrinos while reducing the combustibility."
|
||||
|
||||
icon = 'icons/obj/machines/antimatter.dmi'
|
||||
icon_state = "shield"
|
||||
anchored = 1
|
||||
density = 1
|
||||
dir = NORTH
|
||||
use_power = NO_POWER_USE//Living things generally dont use power
|
||||
idle_power_usage = 0
|
||||
active_power_usage = 0
|
||||
|
||||
var/obj/machinery/power/am_control_unit/control_unit = null
|
||||
var/processing = 0//To track if we are in the update list or not, we need to be when we are damaged and if we ever
|
||||
var/stability = 100//If this gets low bad things tend to happen
|
||||
var/efficiency = 1//How many cores this core counts for when doing power processing, plasma in the air and stability could affect this
|
||||
var/coredirs = 0
|
||||
var/dirs = 0
|
||||
|
||||
|
||||
idle_power_usage = 0
|
||||
active_power_usage = 0
|
||||
|
||||
var/obj/machinery/power/am_control_unit/control_unit = null
|
||||
var/processing = 0//To track if we are in the update list or not, we need to be when we are damaged and if we ever
|
||||
var/stability = 100//If this gets low bad things tend to happen
|
||||
var/efficiency = 1//How many cores this core counts for when doing power processing, plasma in the air and stability could affect this
|
||||
var/coredirs = 0
|
||||
var/dirs = 0
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/Initialize()
|
||||
. = ..()
|
||||
addtimer(CALLBACK(src, .proc/controllerscan), 10)
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/proc/controllerscan(priorscan = 0)
|
||||
//Make sure we are the only one here
|
||||
if(!istype(src.loc, /turf))
|
||||
qdel(src)
|
||||
return
|
||||
for(var/obj/machinery/am_shielding/AMS in loc.contents)
|
||||
if(AMS == src)
|
||||
continue
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
//Search for shielding first
|
||||
for(var/obj/machinery/am_shielding/AMS in cardinalrange(src))
|
||||
if(AMS && AMS.control_unit && link_control(AMS.control_unit))
|
||||
break
|
||||
|
||||
if(!control_unit)//No other guys nearby look for a control unit
|
||||
for(var/direction in GLOB.cardinal)
|
||||
for(var/obj/machinery/power/am_control_unit/AMC in cardinalrange(src))
|
||||
if(AMC.add_shielding(src))
|
||||
break
|
||||
|
||||
if(!control_unit)
|
||||
if(!priorscan)
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/proc/controllerscan(priorscan = 0)
|
||||
//Make sure we are the only one here
|
||||
if(!istype(src.loc, /turf))
|
||||
qdel(src)
|
||||
return
|
||||
for(var/obj/machinery/am_shielding/AMS in loc.contents)
|
||||
if(AMS == src)
|
||||
continue
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
//Search for shielding first
|
||||
for(var/obj/machinery/am_shielding/AMS in cardinalrange(src))
|
||||
if(AMS && AMS.control_unit && link_control(AMS.control_unit))
|
||||
break
|
||||
|
||||
if(!control_unit)//No other guys nearby look for a control unit
|
||||
for(var/direction in GLOB.cardinal)
|
||||
for(var/obj/machinery/power/am_control_unit/AMC in cardinalrange(src))
|
||||
if(AMC.add_shielding(src))
|
||||
break
|
||||
|
||||
if(!control_unit)
|
||||
if(!priorscan)
|
||||
addtimer(CALLBACK(src, .proc/controllerscan, 1), 20)
|
||||
return
|
||||
qdel(src)
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/Destroy()
|
||||
if(control_unit)
|
||||
control_unit.remove_shielding(src)
|
||||
if(processing)
|
||||
shutdown_core()
|
||||
visible_message("<span class='danger'>The [src.name] melts!</span>")
|
||||
//Might want to have it leave a mess on the floor but no sprites for now
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/CanPass(atom/movable/mover, turf/target, height=0)
|
||||
if(height==0)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/process()
|
||||
if(!processing)
|
||||
. = PROCESS_KILL
|
||||
//TODO: core functions and stability
|
||||
//TODO: think about checking the airmix for plasma and increasing power output
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/emp_act()//Immune due to not really much in the way of electronics.
|
||||
return 0
|
||||
|
||||
/obj/machinery/am_shielding/ex_act(severity, target)
|
||||
stability -= (80 - (severity * 20))
|
||||
check_stability()
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/bullet_act(obj/item/projectile/Proj)
|
||||
. = ..()
|
||||
if(Proj.flag != "bullet")
|
||||
stability -= Proj.force/2
|
||||
check_stability()
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/update_icon()
|
||||
dirs = 0
|
||||
coredirs = 0
|
||||
cut_overlays()
|
||||
for(var/direction in GLOB.alldirs)
|
||||
var/turf/T = get_step(loc, direction)
|
||||
for(var/obj/machinery/machine in T)
|
||||
if(istype(machine, /obj/machinery/am_shielding))
|
||||
var/obj/machinery/am_shielding/shield = machine
|
||||
if(shield.control_unit == control_unit)
|
||||
if(shield.processing)
|
||||
coredirs |= direction
|
||||
if(direction in GLOB.cardinal)
|
||||
dirs |= direction
|
||||
|
||||
else
|
||||
if(istype(machine, /obj/machinery/power/am_control_unit) && (direction in GLOB.cardinal))
|
||||
var/obj/machinery/power/am_control_unit/control = machine
|
||||
if(control == control_unit)
|
||||
dirs |= direction
|
||||
|
||||
|
||||
var/prefix = ""
|
||||
var/icondirs=dirs
|
||||
|
||||
if(coredirs)
|
||||
prefix="core"
|
||||
|
||||
icon_state = "[prefix]shield_[icondirs]"
|
||||
|
||||
if(core_check())
|
||||
add_overlay("core[control_unit && control_unit.active]")
|
||||
if(!processing)
|
||||
setup_core()
|
||||
else if(processing)
|
||||
shutdown_core()
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/take_damage(damage_amount, damage_type = BRUTE, damage_flag = 0, sound_effect = 1)
|
||||
switch(damage_type)
|
||||
if(BRUTE)
|
||||
if(sound_effect)
|
||||
if(damage_amount)
|
||||
playsound(loc, 'sound/weapons/smash.ogg', 50, 1)
|
||||
else
|
||||
playsound(loc, 'sound/weapons/tap.ogg', 50, 1)
|
||||
if(BURN)
|
||||
if(sound_effect)
|
||||
playsound(src.loc, 'sound/items/Welder.ogg', 100, 1)
|
||||
else
|
||||
return
|
||||
if(damage_amount >= 10)
|
||||
stability -= damage_amount/2
|
||||
check_stability()
|
||||
|
||||
|
||||
//Call this to link a detected shilding unit to the controller
|
||||
/obj/machinery/am_shielding/proc/link_control(obj/machinery/power/am_control_unit/AMC)
|
||||
if(!istype(AMC))
|
||||
return 0
|
||||
if(control_unit && control_unit != AMC)
|
||||
return 0//Already have one
|
||||
control_unit = AMC
|
||||
control_unit.add_shielding(src,1)
|
||||
return 1
|
||||
|
||||
|
||||
//Scans cards for shields or the control unit and if all there it
|
||||
/obj/machinery/am_shielding/proc/core_check()
|
||||
for(var/direction in GLOB.alldirs)
|
||||
var/found_am_device=0
|
||||
for(var/obj/machinery/machine in get_step(loc, direction))
|
||||
//var/machine = locate(/obj/machinery, get_step(loc, direction))
|
||||
if(!machine)
|
||||
continue//Need all for a core
|
||||
if(istype(machine, /obj/machinery/am_shielding) || istype(machine, /obj/machinery/power/am_control_unit))
|
||||
found_am_device = 1
|
||||
break
|
||||
if(!found_am_device)
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/proc/setup_core()
|
||||
processing = 1
|
||||
GLOB.machines |= src
|
||||
START_PROCESSING(SSmachines, src)
|
||||
if(!control_unit)
|
||||
return
|
||||
control_unit.linked_cores.Add(src)
|
||||
control_unit.reported_core_efficiency += efficiency
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/proc/shutdown_core()
|
||||
processing = 0
|
||||
if(!control_unit)
|
||||
return
|
||||
control_unit.linked_cores.Remove(src)
|
||||
control_unit.reported_core_efficiency -= efficiency
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/proc/check_stability(injecting_fuel = 0)
|
||||
if(stability > 0)
|
||||
return
|
||||
if(injecting_fuel && control_unit)
|
||||
control_unit.exploding = 1
|
||||
if(src)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/proc/recalc_efficiency(new_efficiency)//tbh still not 100% sure how I want to deal with efficiency so this is likely temp
|
||||
if(!control_unit || !processing)
|
||||
return
|
||||
if(stability < 50)
|
||||
new_efficiency /= 2
|
||||
control_unit.reported_core_efficiency += (new_efficiency - efficiency)
|
||||
efficiency = new_efficiency
|
||||
return
|
||||
|
||||
|
||||
|
||||
/obj/item/device/am_shielding_container
|
||||
name = "packaged antimatter reactor section"
|
||||
desc = "A small storage unit containing an antimatter reactor section. To use place near an antimatter control unit or deployed antimatter reactor section and use a multitool to activate this package."
|
||||
icon = 'icons/obj/machines/antimatter.dmi'
|
||||
icon_state = "box"
|
||||
item_state = "electronic"
|
||||
w_class = WEIGHT_CLASS_BULKY
|
||||
flags = CONDUCT
|
||||
throwforce = 5
|
||||
throw_speed = 1
|
||||
throw_range = 2
|
||||
materials = list(MAT_METAL=100)
|
||||
|
||||
/obj/item/device/am_shielding_container/attackby(obj/item/I, mob/user, params)
|
||||
if(istype(I, /obj/item/device/multitool) && istype(src.loc,/turf))
|
||||
new/obj/machinery/am_shielding(src.loc)
|
||||
qdel(src)
|
||||
else
|
||||
return ..()
|
||||
return
|
||||
qdel(src)
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/Destroy()
|
||||
if(control_unit)
|
||||
control_unit.remove_shielding(src)
|
||||
if(processing)
|
||||
shutdown_core()
|
||||
visible_message("<span class='danger'>The [src.name] melts!</span>")
|
||||
//Might want to have it leave a mess on the floor but no sprites for now
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/CanPass(atom/movable/mover, turf/target, height=0)
|
||||
if(height==0)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/process()
|
||||
if(!processing)
|
||||
. = PROCESS_KILL
|
||||
//TODO: core functions and stability
|
||||
//TODO: think about checking the airmix for plasma and increasing power output
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/emp_act()//Immune due to not really much in the way of electronics.
|
||||
return 0
|
||||
|
||||
/obj/machinery/am_shielding/ex_act(severity, target)
|
||||
stability -= (80 - (severity * 20))
|
||||
check_stability()
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/bullet_act(obj/item/projectile/Proj)
|
||||
. = ..()
|
||||
if(Proj.flag != "bullet")
|
||||
stability -= Proj.force/2
|
||||
check_stability()
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/update_icon()
|
||||
dirs = 0
|
||||
coredirs = 0
|
||||
cut_overlays()
|
||||
for(var/direction in GLOB.alldirs)
|
||||
var/turf/T = get_step(loc, direction)
|
||||
for(var/obj/machinery/machine in T)
|
||||
if(istype(machine, /obj/machinery/am_shielding))
|
||||
var/obj/machinery/am_shielding/shield = machine
|
||||
if(shield.control_unit == control_unit)
|
||||
if(shield.processing)
|
||||
coredirs |= direction
|
||||
if(direction in GLOB.cardinal)
|
||||
dirs |= direction
|
||||
|
||||
else
|
||||
if(istype(machine, /obj/machinery/power/am_control_unit) && (direction in GLOB.cardinal))
|
||||
var/obj/machinery/power/am_control_unit/control = machine
|
||||
if(control == control_unit)
|
||||
dirs |= direction
|
||||
|
||||
|
||||
var/prefix = ""
|
||||
var/icondirs=dirs
|
||||
|
||||
if(coredirs)
|
||||
prefix="core"
|
||||
|
||||
icon_state = "[prefix]shield_[icondirs]"
|
||||
|
||||
if(core_check())
|
||||
add_overlay("core[control_unit && control_unit.active]")
|
||||
if(!processing)
|
||||
setup_core()
|
||||
else if(processing)
|
||||
shutdown_core()
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/take_damage(damage_amount, damage_type = BRUTE, damage_flag = 0, sound_effect = 1)
|
||||
switch(damage_type)
|
||||
if(BRUTE)
|
||||
if(sound_effect)
|
||||
if(damage_amount)
|
||||
playsound(loc, 'sound/weapons/smash.ogg', 50, 1)
|
||||
else
|
||||
playsound(loc, 'sound/weapons/tap.ogg', 50, 1)
|
||||
if(BURN)
|
||||
if(sound_effect)
|
||||
playsound(src.loc, 'sound/items/welder.ogg', 100, 1)
|
||||
else
|
||||
return
|
||||
if(damage_amount >= 10)
|
||||
stability -= damage_amount/2
|
||||
check_stability()
|
||||
|
||||
|
||||
//Call this to link a detected shilding unit to the controller
|
||||
/obj/machinery/am_shielding/proc/link_control(obj/machinery/power/am_control_unit/AMC)
|
||||
if(!istype(AMC))
|
||||
return 0
|
||||
if(control_unit && control_unit != AMC)
|
||||
return 0//Already have one
|
||||
control_unit = AMC
|
||||
control_unit.add_shielding(src,1)
|
||||
return 1
|
||||
|
||||
|
||||
//Scans cards for shields or the control unit and if all there it
|
||||
/obj/machinery/am_shielding/proc/core_check()
|
||||
for(var/direction in GLOB.alldirs)
|
||||
var/found_am_device=0
|
||||
for(var/obj/machinery/machine in get_step(loc, direction))
|
||||
//var/machine = locate(/obj/machinery, get_step(loc, direction))
|
||||
if(!machine)
|
||||
continue//Need all for a core
|
||||
if(istype(machine, /obj/machinery/am_shielding) || istype(machine, /obj/machinery/power/am_control_unit))
|
||||
found_am_device = 1
|
||||
break
|
||||
if(!found_am_device)
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/proc/setup_core()
|
||||
processing = 1
|
||||
GLOB.machines |= src
|
||||
START_PROCESSING(SSmachines, src)
|
||||
if(!control_unit)
|
||||
return
|
||||
control_unit.linked_cores.Add(src)
|
||||
control_unit.reported_core_efficiency += efficiency
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/proc/shutdown_core()
|
||||
processing = 0
|
||||
if(!control_unit)
|
||||
return
|
||||
control_unit.linked_cores.Remove(src)
|
||||
control_unit.reported_core_efficiency -= efficiency
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/proc/check_stability(injecting_fuel = 0)
|
||||
if(stability > 0)
|
||||
return
|
||||
if(injecting_fuel && control_unit)
|
||||
control_unit.exploding = 1
|
||||
if(src)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/am_shielding/proc/recalc_efficiency(new_efficiency)//tbh still not 100% sure how I want to deal with efficiency so this is likely temp
|
||||
if(!control_unit || !processing)
|
||||
return
|
||||
if(stability < 50)
|
||||
new_efficiency /= 2
|
||||
control_unit.reported_core_efficiency += (new_efficiency - efficiency)
|
||||
efficiency = new_efficiency
|
||||
return
|
||||
|
||||
|
||||
|
||||
/obj/item/device/am_shielding_container
|
||||
name = "packaged antimatter reactor section"
|
||||
desc = "A small storage unit containing an antimatter reactor section. To use place near an antimatter control unit or deployed antimatter reactor section and use a multitool to activate this package."
|
||||
icon = 'icons/obj/machines/antimatter.dmi'
|
||||
icon_state = "box"
|
||||
item_state = "electronic"
|
||||
w_class = WEIGHT_CLASS_BULKY
|
||||
flags = CONDUCT
|
||||
throwforce = 5
|
||||
throw_speed = 1
|
||||
throw_range = 2
|
||||
materials = list(MAT_METAL=100)
|
||||
|
||||
/obj/item/device/am_shielding_container/attackby(obj/item/I, mob/user, params)
|
||||
if(istype(I, /obj/item/device/multitool) && istype(src.loc,/turf))
|
||||
new/obj/machinery/am_shielding(src.loc)
|
||||
qdel(src)
|
||||
else
|
||||
return ..()
|
||||
|
||||
Reference in New Issue
Block a user