/vg/ AME port (#1831)

changes:

Ported /vg/'s anti-matter engine.
Anti-matter engine is now orderable from cargo.
Anti-matter fuel is now orderable from cargo.
Using 1 of each AM crate from Cargo, you can get 240 kW.

Note: We already have this engine in our code, this is just an update to it.
This commit is contained in:
Lohikar
2017-03-05 22:05:57 +02:00
committed by skull132
parent fd217ec773
commit f8e808f617
11 changed files with 458 additions and 227 deletions
+4 -3
View File
@@ -18,10 +18,10 @@
/obj/machinery/computer/am_engine/New()
..()
spawn( 24 )
for(var/obj/machinery/power/am_engine/engine/E in world)
for(var/obj/machinery/power/am_engine/engine/E in machines)
if(E.engine_id == src.engine_id)
src.connected_E = E
for(var/obj/machinery/power/am_engine/injector/I in world)
for(var/obj/machinery/power/am_engine/injector/I in machines)
if(I.engine_id == src.engine_id)
src.connected_I = I
return
@@ -45,7 +45,7 @@
src.state = STATE_DEFAULT
if("login")
var/mob/M = usr
var/obj/item/weapon/card/id/I = M.get_active_hand()
var/obj/item/weapon/card/id/I = M.equipped()
if (I && istype(I))
if(src.check_access(I))
authenticated = 1
@@ -57,6 +57,7 @@
src.updateUsrDialog()
/obj/machinery/computer/am_engine/attack_ai(var/mob/user as mob)
src.add_hiddenprint(user)
return src.attack_hand(user)
/obj/machinery/computer/am_engine/attack_paw(var/mob/user as mob)
@@ -1,6 +1,7 @@
/obj/item/weapon/am_containment
name = "antimatter containment jar"
desc = "Holds antimatter."
desc = "Holds antimatter. Warranty void if exposed to matter."
description_antag = "Antimatter is extremely volatile, and containment jars are not particularly strong. Weak explosions will reduce the container's integrity, and larger ones will cause it to explode immediately."
icon = 'icons/obj/machines/antimatter.dmi'
icon_state = "jar"
density = 0
@@ -10,24 +11,28 @@
throw_speed = 1
throw_range = 2
var/fuel = 10000
var/fuel_max = 10000//Lets try this for now
var/fuel = 1000 // WAS ORIGINALLY 10000
var/fuel_max = 1000//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
var/exploded = 0
/obj/item/weapon/am_containment/proc/boom()
var/percent = 0
if(fuel)
percent = (fuel / fuel_max) * 100
if(!exploded && percent >= 10)
explosion(get_turf(src), 1, 2, 3, 5)//Should likely be larger but this works fine for now I guess
exploded=1
if(src)
qdel(src)
/obj/item/weapon/am_containment/ex_act(severity)
switch(severity)
if(1.0)
explosion(get_turf(src), 1, 2, 3, 5)//Should likely be larger but this works fine for now I guess
if(src)
qdel(src)
return
boom()
if(2.0)
if(prob((fuel/10)-stability))
explosion(get_turf(src), 1, 2, 3, 5)
if(src)
qdel(src)
return
boom()
stability -= 40
if(3.0)
stability -= 20
@@ -38,4 +43,4 @@
if(fuel < wanted)
wanted = fuel
fuel -= wanted
return wanted
return wanted
+171 -109
View File
@@ -1,9 +1,13 @@
/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'
desc = "The control unit for an antimatter reactor. Probably safe."
description_info = "Use a wrench to attach the control unit to the ground, then arrange the reactor sections nearby. Reactor sections can only be activated if they are near the control unit, but otherwise are not restricted in how they must be placed."
description_antag = "The antimatter engine will quickly destabilize if the fuel injection rate is set too high, causing a large explosion."
icon = 'icons/obj/machines/new_ame.dmi'
icon_state = "control"
anchored = 1
var/icon_mod = "on" // on, critical, or fuck
var/old_icon_mod = "on"
anchored = 0
density = 1
use_power = 1
idle_power_usage = 100
@@ -15,18 +19,19 @@
var/update_shield_icons = 0
var/stability = 100
var/exploding = 0
var/exploded = 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/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/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
var/stored_power = 0 //Power to deploy per tick
/obj/machinery/power/am_control_unit/New()
@@ -34,17 +39,25 @@
linked_shielding = list()
linked_cores = list()
/obj/machinery/power/am_control_unit/Destroy()//Perhaps damage and run stability checks rather than just qdel on the others
/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)
for(var/obj/machinery/am_shielding/AMS in linked_cores)
AMS.control_unit = null
qdel(AMS)
qdel(fueljar)
fueljar = null
..()
/obj/machinery/power/am_control_unit/process()
if(exploding)
explosion(get_turf(src),8,12,18,12)
if(src) qdel(src)
if(exploding && !exploded)
message_admins("AME explosion at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>) - Last touched by [fingerprintslast]",0,1)
exploded=1
explosion(get_turf(src),8,10,12,15)
if(src)
qdel(src)
if(update_shield_icons && !shield_icon_delay)
check_shield_icons()
@@ -58,6 +71,8 @@
//Angry buzz or such here
return
check_core_stability()
add_avail(stored_power)
power_cycle++
@@ -65,41 +80,43 @@
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
playsound(get_turf(src), 'sound/effects/bang.ogg', 25, 1)
for (var/thing in linked_cores)
flick("core2", thing)
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
stored_power = (fuel / core_power) * fuel * AM_POWER_FACTOR // Was 200000, was too much. New value run past Aurx. - N3X
//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
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
playsound(get_turf(src), 'sound/effects/bang.ogg', 50, 1)
/obj/machinery/power/am_control_unit/emp_act(severity)
switch(severity)
if(1)
if(active) toggle_power()
if(active)
toggle_power()
stability -= rand(15,30)
if(2)
if(active) toggle_power()
if(active)
toggle_power()
stability -= rand(10,20)
..()
return 0
/obj/machinery/power/am_control_unit/ex_act(severity)
switch(severity)
@@ -112,55 +129,50 @@
check_stability()
return
/obj/machinery/power/am_control_unit/bullet_act(var/obj/item/projectile/Proj)
if(Proj.check_armour != "bullet")
stability -= Proj.force
return 0
/obj/machinery/power/am_control_unit/power_change()
..()
if(stat & NOPOWER && active)
toggle_power()
return
/obj/machinery/power/am_control_unit/update_icon()
if(active) icon_state = "control_on"
else icon_state = "control"
if(active)
icon_state = "control_[icon_mod]"
else
icon_state = "control"
//No other icons for it atm
/obj/machinery/power/am_control_unit/attackby(obj/item/W, mob/user)
if(!istype(W) || !user) return
if(istype(W, /obj/item/weapon/wrench))
if(!istype(W) || !user)
return
if(iswrench(W))
if(!anchored)
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
playsound(get_turf(src), 'sound/items/Ratchet.ogg', 75, 1)
user.visible_message("[user.name] secures the [src.name] to the floor.", \
"You secure the anchor bolts to the floor.", \
"You hear a ratchet")
src.anchored = 1
update_shield_icons = 2
check_shield_icons()
connect_to_network()
else if(!linked_shielding.len > 0)
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
playsound(get_turf(src), 'sound/items/Ratchet.ogg', 75, 1)
user.visible_message("[user.name] unsecures the [src.name].", \
"You remove the anchor bolts.", \
"You hear a ratchet")
src.anchored = 0
disconnect_from_network()
else
user << "\red Once bolted and linked to a shielding unit it the [src.name] is unable to be moved!"
to_chat(user, "<span class='warning'>Once bolted and linked to a shielding unit it the [src.name] is unable to be moved!</span>")
return
if(istype(W, /obj/item/weapon/am_containment))
if(fueljar)
user << "\red There is already a [fueljar] inside!"
to_chat(user, "<span class='warning'>There is already a [fueljar] inside!</span>")
return
fueljar = W
user.remove_from_mob(W)
W.loc = src
user.update_icons()
user.drop_from_inventory(W, src)
message_admins("AME loaded with fuel by [user.real_name] ([user.key]) at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
user.visible_message("[user.name] loads an [W.name] into the [src.name].", \
"You load an [W.name].", \
"You hear a thunk.")
@@ -180,19 +192,25 @@
/obj/machinery/power/am_control_unit/proc/add_shielding(var/obj/machinery/am_shielding/AMS, var/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)
if(!istype(AMS))
return 0
if(!anchored)
return 0
if(!AMS_linking && !AMS.link_control(src))
return 0
if(!(AMS in linked_shielding))
linked_shielding.Add(AMS)
update_shield_icons = 1
return 1
/obj/machinery/power/am_control_unit/proc/remove_shielding(var/obj/machinery/am_shielding/AMS)
if(!istype(AMS)) return 0
if(!istype(AMS))
return 0
linked_shielding.Remove(AMS)
update_shield_icons = 2
if(active) toggle_power()
if(active)
toggle_power()
return 1
@@ -210,40 +228,63 @@
else
use_power = 1
visible_message("The [src.name] shuts down.")
for(var/obj/machinery/am_shielding/AMS in linked_cores)
AMS.update_icon()
update_icon()
return
/obj/machinery/power/am_control_unit/proc/check_shield_icons()//Forces icon_update for all shields
if(shield_icon_delay) return
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/neighbor in cardinalrange(loc))
if(!neighbor.control_unit)
linked_shielding += neighbor
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
if(AMS.processing) AMS.shutdown_core()
if(AMS.processing)
AMS.shutdown_core()
AMS.control_unit = null
spawn(10)
AMS.controllerscan()
AMS.assimilate()
linked_shielding = list()
else
for(var/obj/machinery/am_shielding/AMS in linked_shielding)
AMS.update_icon()
spawn(20)
shield_icon_delay = 0
return
sleep(20)
shield_icon_delay = 0
/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
//if(stored_core_stability_delay || linked_cores.len <= 0) return
if(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
for(var/thing in linked_cores)
var/obj/machinery/am_shielding/AMS = thing
if (!AMS || AMS.gcDestroyed)
continue
stored_core_stability += AMS.stability
stored_core_stability /= linked_cores.len
switch(stored_core_stability)
if(0 to 24)
icon_mod = "fuck"
if(25 to 49)
icon_mod = "critical"
if(50 to INFINITY)
icon_mod = "on"
if(icon_mod != old_icon_mod)
old_icon_mod = icon_mod
update_icon()
//spawn(40)
// stored_core_stability_delay = 0
/obj/machinery/power/am_control_unit/interact(mob/user)
if((get_dist(src, user) > 1) || (stat & (BROKEN|NOPOWER)))
@@ -251,43 +292,56 @@
user.unset_machine()
user << browse(null, "window=AMcontrol")
return
user.set_machine(src)
return ui_interact(user)
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>"
/obj/machinery/power/am_control_unit/ui_interact(mob/user, ui_key = "main")
if(!user)
return
dat += "Instability: [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>"
var/list/fueljar_data=null
if(fueljar)
fueljar_data=list(
"fuel"=fueljar.fuel,
"fuel_max"=fueljar.fuel_max,
"injecting"=fuel_injection
)
dat += "Fuel: "
if(!fueljar)
dat += "<BR>No fuel receptacle detected."
var/list/data = list(
"active" = active,
//"stability" = stability,
"linked_shields" = linked_shielding.len,
"linked_cores" = linked_cores.len,
"efficiency" = reported_core_efficiency,
"stability" = stored_core_stability,
"stored_power" = stored_power,
"fueljar" = fueljar_data,
"siliconUser" = istype(user, /mob/living/silicon)
)
var/datum/nanoui/ui = nanomanager.get_open_ui(user, src, ui_key)
if (!ui)
// the ui does not exist, so we'll create a new one
ui = new(user, src, ui_key, "ame.tmpl", "Antimatter Control Unit", 500, data["siliconUser"] ? 465 : 390)
// When the UI is first opened this is the data it will use
ui.set_initial_data(data)
ui.open()
// Auto update every Master Controller tick
ui.set_auto_update(1)
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
// The UI is already open so push the new data to it
ui.push_data(data)
return
/obj/machinery/power/am_control_unit/Topic(href, href_list)
..()
if(..())
return 1
if(href_list["close"])
if(usr.machine == src)
usr.unset_machine()
return 1
//Ignore input if we are broken or guy is not touching us, AI can control from a ways away
if(stat & (BROKEN|NOPOWER) || (get_dist(src, usr) > 1 && !istype(usr, /mob/living/silicon/ai)))
if(stat & (BROKEN|NOPOWER))
usr.unset_machine()
usr << browse(null, "window=AMcontrol")
return
@@ -299,26 +353,34 @@
if(href_list["togglestatus"])
toggle_power()
message_admins("AME toggled [active?"on":"off"] by [usr.real_name] ([usr.key]) at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
return 1
if(href_list["refreshicons"])
update_shield_icons = 1
update_shield_icons = 2 // Fuck it
return 1
if(href_list["ejectjar"])
if(fueljar)
fueljar.loc = src.loc
message_admins("AME fuel jar ejected by [usr.real_name] ([usr.key]) at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
fueljar.forceMove(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
return 1
if(href_list["strengthup"])
fuel_injection++
if(href_list["strengthdown"])
fuel_injection--
if(fuel_injection < 0) fuel_injection = 0
if(href_list["set_strength"])
var/newval = input("Enter new injection strength") as num|null
if(isnull(newval))
return
fuel_injection=newval
fuel_injection=max(1,fuel_injection)
message_admins("AME injection strength set to [fuel_injection] by [usr.real_name] ([usr.key]) at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
return 1
if(href_list["refreshstability"])
check_core_stability()
return 1
updateDialog()
return
return 1
+14 -9
View File
@@ -38,16 +38,18 @@
/obj/machinery/power/am_engine/injector/attackby(obj/item/weapon/fuel/F, mob/user)
if( (stat & BROKEN) || !connected) return
if( (stat & BROKEN) || !connected)
return
if(istype(F, /obj/item/weapon/fuel/H))
if(injecting)
user << "Theres already a fuel rod in the injector!"
to_chat(user, "There's already a fuel rod in the injector!")
return
user << "You insert the rod into the injector"
to_chat(user, "You insert the rod into the injector.")
injecting = 1
var/fuel = F.fuel
qdel(F)
F = null
spawn( 300 )
injecting = 0
new/obj/item/weapon/fuel(src.loc)
@@ -55,12 +57,13 @@
if(istype(F, /obj/item/weapon/fuel/antiH))
if(injecting)
user << "Theres already a fuel rod in the injector!"
to_chat(user, "There's already a fuel rod in the injector!")
return
user << "You insert the rod into the injector"
to_chat(user, "You insert the rod into the injector.")
injecting = 1
var/fuel = F.fuel
qdel(F)
F = null
spawn( 300 )
injecting = 0
new /obj/item/weapon/fuel(src.loc)
@@ -83,6 +86,7 @@
/obj/machinery/power/am_engine/engine/proc/engine_go()
if( (!src.connected) || (stat & BROKEN) )
return
@@ -109,7 +113,7 @@
antiH_fuel = residual_matter
for(var/mob/M in hearers(src, null))
M.show_message(text("\red You hear a loud bang!"))
M.show_message(text("<span class='warning'>You hear a loud bang!</span>"))
//Q = k x (delta T)
@@ -123,6 +127,7 @@
/obj/machinery/power/am_engine/engine/proc/engine_process()
do
if( (!src.connected) || (stat & BROKEN) )
return
@@ -161,7 +166,7 @@
if(energy > convert2energy(8e-12)) //TOO MUCH ENERGY
for(var/mob/M in hearers(src, null))
M.show_message(text("\red You hear a loud whirring!"))
M.show_message(text("<span class='warning'>You hear a loud whirring!</span>"))
sleep(20)
//Q = k x (delta T)
@@ -180,7 +185,7 @@
if(energy > convert2energy(8e-12)) //FAR TOO MUCH ENERGY STILL
for(var/mob/M in hearers(src, null))
M.show_message(text("\red <big>BANG!</big>"))
M.show_message(text("<span class='warning'><big>BANG!</big></span>"))
new /obj/effect/bhole(src.loc)
else //this amount of energy is okay so it does the proper output thing
@@ -204,4 +209,4 @@
stopping = 0
return
return
+14 -10
View File
@@ -1,5 +1,5 @@
/obj/item/weapon/fuel
name = "Magnetic Storage Ring"
name = "nagnetic storage ring"
desc = "A magnetic storage ring."
icon = 'icons/obj/items.dmi'
icon_state = "rcdammo"
@@ -11,12 +11,12 @@
var/content = null
/obj/item/weapon/fuel/H
name = "Hydrogen storage ring"
name = "hydrogen storage ring"
content = "Hydrogen"
fuel = 1e-12 //pico-kilogram
/obj/item/weapon/fuel/antiH
name = "Anti-Hydrogen storage ring"
name = "anti-hydrogen storage ring"
content = "Anti-Hydrogen"
fuel = 1e-12 //pico-kilogram
@@ -26,16 +26,17 @@
if(istype(F, /obj/item/weapon/fuel/antiH))
src.fuel += F.fuel
F.fuel = 0
user << "You have added the anti-Hydrogen to the storage ring, it now contains [src.fuel]kg"
to_chat(user, "You add the anti-Hydrogen to the storage ring. It now contains [src.fuel]kg.")
if(istype(F, /obj/item/weapon/fuel/H))
src.fuel += F.fuel
qdel(F)
F = null
src:annihilation(src.fuel)
if(istype(src, /obj/item/weapon/fuel/H))
if(istype(F, /obj/item/weapon/fuel/H))
src.fuel += F.fuel
F.fuel = 0
user << "You have added the Hydrogen to the storage ring, it now contains [src.fuel]kg"
to_chat(user, "You add the Hydrogen to the storage ring. It now contains [src.fuel]kg")
if(istype(F, /obj/item/weapon/fuel/antiH))
src.fuel += F.fuel
qdel(src)
@@ -43,6 +44,7 @@
/obj/item/weapon/fuel/antiH/proc/annihilation(var/mass)
var/strength = convert2energy(mass)
if (strength < 773.0)
@@ -67,21 +69,23 @@
return
/obj/item/weapon/fuel/examine(mob/user)
if(get_dist(src, user) <= 1)
user << "A magnetic storage ring, it contains [fuel]kg of [content ? content : "nothing"]."
/obj/item/weapon/fuel/examine()
..()
to_chat(user, "<span class='info'>A magnetic storage ring containing [fuel]kg of [content ? content : "nothing"].</span>")
/obj/item/weapon/fuel/proc/injest(mob/M as mob)
switch(content)
if("Anti-Hydrogen")
mob << span("notice", "That was not a very bright idea.")
M.gib()
if("Hydrogen")
M << "\blue You feel very light, as if you might just float away..."
to_chat(M, "<span class='notice'>You feel very light, as if you might just float away...</span>")
qdel(src)
return
/obj/item/weapon/fuel/attack(mob/M as mob, mob/user as mob)
if (user != M)
//If you come from the distant future and happen to find this unincluded and derelict file, you may be wondering what this is. In truth, it's better that you don't know.
var/obj/effect/equip_e/human/O = new /obj/effect/equip_e/human( )
O.source = user
O.target = M
@@ -95,5 +99,5 @@
return
else
for(var/mob/O in viewers(M, null))
O.show_message(text("\red [M] ate the [content ? content : "empty canister"]!"), 1)
O.show_message(text("<span class='warning'>\The [M] eats the [content ? content : "empty canister"]!</span>"), 1)
src.injest(M)
+132 -84
View File
@@ -3,15 +3,19 @@ proc/cardinalrange(var/center)
var/list/things = list()
for(var/direction in cardinal)
var/turf/T = get_step(center, direction)
if(!T) continue
if(!T)
continue
things += T.contents
return things
/obj/machinery/am_shielding
name = "antimatter reactor section"
desc = "This device was built using a phoron life-form that seems to increase phoron's natural ability to react with neutrinos while reducing the combustibility."
desc = "A shielding component for an antimatter reactor. Looks delicate."
description_info = "Antimatter shielding sections must be beside an anchored control unit or another shielding section. If either are destroyed, the section will disappear."
description_antag = "Antimatter shielding sections are delicate. Attacking the shielding unit with a damaging object will reduce its stability, as will explosions. If the stability hits zero, the reactor may explode."
icon = 'icons/obj/machines/antimatter.dmi'
//icon = 'icons/obj/machines/antimatter.dmi'
icon = 'icons/obj/machines/new_ame.dmi'
icon_state = "shield"
anchored = 1
density = 1
@@ -24,14 +28,42 @@ proc/cardinalrange(var/center)
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, phoron in the air and stability could affect this
var/coredirs = 0
var/dirs = 0
var/mapped = 0 //Set to 1 to ignore usual suicide if it doesn't immediately find a control_unit
// Stupidly easy way to use it in maps
/obj/machinery/am_shielding/map
mapped = 1
/obj/machinery/am_shielding/New(loc)
..(loc)
spawn(10)
/obj/machinery/am_shielding/New(loc, var/obj/machinery/power/am_control_unit/AMC)
..()
if(!AMC)
if (!mapped)
WARNING("AME sector somehow created without a parent control unit!")
controllerscan()
return
return
link_control(AMC)
remove_machine(src)
spawn (10)
update_icon()
/obj/machinery/am_shielding/proc/link_control(var/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
return control_unit.add_shielding(src,1)
/obj/machinery/am_shielding/Destroy()
if(control_unit)
control_unit.remove_shielding(src)
if(processing)
shutdown_core()
visible_message("<span class='warning'>\The [src.name] melts!</span>")
//Might want to have it leave a mess on the floor but no sprites for now
..()
/obj/machinery/am_shielding/proc/controllerscan(var/priorscan = 0)
//Make sure we are the only one here
@@ -39,9 +71,9 @@ proc/cardinalrange(var/center)
qdel(src)
return
for(var/obj/machinery/am_shielding/AMS in loc.contents)
if(AMS == src) continue
spawn(0)
qdel(src)
if(AMS == src)
continue
qdel(src)
return
//Search for shielding first
@@ -49,41 +81,37 @@ proc/cardinalrange(var/center)
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 cardinal)
if(!control_unit)//No other guys nearby, look for a control unit
for(var/obj/machinery/power/am_control_unit/AMC in cardinalrange(src))
if(AMC.add_shielding(src))
break
if(!control_unit)
if(!priorscan)
spawn(20)
if(!mapped) // Prevent rescanning and suicide if it's part of the map
if(!priorscan)
sleep(20)
controllerscan(1)//Last chance
return
spawn(0)
return
qdel(src)
return
// Find surrounding unconnected shielding and add them to our controller
/obj/machinery/am_shielding/proc/assimilate()
if(!control_unit)
return // nothing to share :'^(
for(var/obj/machinery/am_shielding/neighbor in cardinalrange(src))
if(neighbor && !neighbor.control_unit)
neighbor.link_control(control_unit)
neighbor.assimilate() // recursion is fun, right?
/obj/machinery/am_shielding/Destroy()
if(control_unit) control_unit.remove_shielding(src)
if(processing) shutdown_core()
visible_message("\red The [src.name] melts!")
//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, air_group=0)
if(air_group || (height==0)) return 1
/obj/machinery/am_shielding/Cross(atom/movable/mover, turf/target, height=1.5, air_group = 0)
if(air_group || (height==0))
return 1
return 0
/obj/machinery/am_shielding/process()
if(!processing) . = PROCESS_KILL
if(!processing)
. = PROCESS_KILL
//TODO: core functions and stability
//TODO: think about checking the airmix for phoron and increasing power output
return
/obj/machinery/am_shielding/emp_act()//Immune due to not really much in the way of electronics.
@@ -98,110 +126,130 @@ proc/cardinalrange(var/center)
stability -= 40
if(3.0)
stability -= 20
check_stability()
return
/obj/machinery/am_shielding/bullet_act(var/obj/item/projectile/Proj)
if(Proj.check_armour != "bullet")
stability -= Proj.force/2
return 0
/obj/machinery/am_shielding/update_icon()
overlays.Cut()
overlays.len = 0
coredirs = 0
dirs = 0
for(var/direction in alldirs)
var/machine = locate(/obj/machinery, get_step(loc, direction))
if((istype(machine, /obj/machinery/am_shielding) && machine:control_unit == control_unit)||(istype(machine, /obj/machinery/power/am_control_unit) && machine == control_unit))
overlays += "shield_[direction]"
var/turf/T = get_step(loc, direction)
for(var/obj/machinery/machine in T)
// Detect cores
if((istype(machine, /obj/machinery/am_shielding) && machine:control_unit == control_unit && machine:processing))
coredirs |= direction
// Detect cores, shielding, and control boxen.
if(direction in cardinal)
if((istype(machine, /obj/machinery/am_shielding) && machine:control_unit == control_unit) || (istype(machine, /obj/machinery/power/am_control_unit) && machine == control_unit))
dirs |= direction
// If we're next to a core, set the prefix.
var/prefix = ""
var/icondirs = dirs
if(coredirs)
prefix="core"
// Set our overlay
icon_state = "[prefix]shield_[icondirs]"
if(core_check())
overlays += "core"
if(!processing) setup_core()
else if(processing) shutdown_core()
icon_state = "core[control_unit && control_unit.active]"
if(!processing)
setup_core()
else if(processing)
shutdown_core()
/obj/machinery/am_shielding/attackby(obj/item/W, mob/user)
if(!istype(W) || !user) return
if(!istype(W) || !user)
return
if(W.force > 10)
stability -= W.force/2
check_stability()
..()
return
//Call this to link a detected shilding unit to the controller
/obj/machinery/am_shielding/proc/link_control(var/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 alldirs)
var/machine = locate(/obj/machinery, get_step(loc, direction))
if(!machine) return 0//Need all for a core
if(!istype(machine, /obj/machinery/am_shielding) && !istype(machine, /obj/machinery/power/am_control_unit)) return 0
var/found_am_device=0
for(var/obj/machinery/machine in get_step(loc, direction))
if(!machine)
continue
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
machines.Add(src)
if(!control_unit) return
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
if(!control_unit)
return
control_unit.linked_cores.Remove(src)
control_unit.reported_core_efficiency -= efficiency
return
/obj/machinery/am_shielding/proc/check_stability(var/injecting_fuel = 0)
if(stability > 0) return
if(stability > 0)
return
if(injecting_fuel && control_unit)
control_unit.exploding = 1
if(src)
qdel(src)
return
qdel(src)
/obj/machinery/am_shielding/proc/recalc_efficiency(var/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(!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."
desc = "A section of antimatter reactor shielding. Do not eat."
description_info = "To deploy, drop near an antimatter control unit or an existing deployed section and use your multitool on it."
icon = 'icons/obj/machines/antimatter.dmi'
icon_state = "box"
item_state = "electronic"
w_class = 4.0
flags = CONDUCT
siemens_coefficient = 1
throwforce = 5
throw_speed = 1
throw_range = 2
matter = list(DEFAULT_WALL_MATERIAL = 100, "waste" = 2000)
/obj/item/device/am_shielding_container/attackby(var/obj/item/I, var/mob/user)
if(istype(I, /obj/item/device/multitool) && istype(src.loc,/turf))
new/obj/machinery/am_shielding(src.loc)
qdel(src)
return
if(ismultitool(I) && isturf(loc))
if(locate(/obj/machinery/am_shielding/) in loc)
to_chat(user, "<span class='warning'>\icon[src]There is already an antimatter reactor section there.</span>")
return
//Search for shielding first
for(var/obj/machinery/am_shielding/AMS in cardinalrange(src))
if(AMS.control_unit)
new/obj/machinery/am_shielding(src.loc, AMS.control_unit)
qdel(src)
return
//No other guys nearby, look for a control unit
var/obj/machinery/power/am_control_unit/AMC = locate() in cardinalrange(src)
if(AMC && AMC.anchored)
new/obj/machinery/am_shielding(src.loc, AMC)
qdel(src)
else //Stranded & Alone
to_chat(user, "<span class='warning'>\icon[src]Couldn't connect to an Antimatter Control Unit.</span>")
return
..()
return