mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Merge pull request #5940 from mwerezak/power-net
Update for shield generator power use and power net fixes
This commit is contained in:
@@ -276,15 +276,15 @@
|
||||
del(src)
|
||||
|
||||
/obj/machinery/computer/scan_consolenew/power_change()
|
||||
..()
|
||||
if(stat & BROKEN)
|
||||
icon_state = "broken"
|
||||
else if(powered())
|
||||
icon_state = initial(icon_state)
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
spawn(rand(0, 15))
|
||||
src.icon_state = "c_unpowered"
|
||||
stat |= NOPOWER
|
||||
if (stat & NOPOWER)
|
||||
spawn(rand(0, 15))
|
||||
src.icon_state = "c_unpowered"
|
||||
else
|
||||
icon_state = initial(icon_state)
|
||||
|
||||
/obj/machinery/computer/scan_consolenew/New()
|
||||
..()
|
||||
|
||||
@@ -1031,8 +1031,7 @@ ________________________________________________________________________________
|
||||
drain = rand(G.mindrain,G.maxdrain)
|
||||
var/drained = 0
|
||||
if(PN&&do_after(U,10))
|
||||
drained = min(drain, PN.avail)
|
||||
PN.newload += drained
|
||||
drained = PN.draw_power(drain)
|
||||
if(drained < drain)//if no power on net, drain apcs
|
||||
for(var/obj/machinery/power/terminal/T in PN.nodes)
|
||||
if(istype(T.master, /obj/machinery/power/apc))
|
||||
@@ -1083,8 +1082,7 @@ ________________________________________________________________________________
|
||||
drain = (round((rand(G.mindrain,G.maxdrain))/2))
|
||||
var/drained = 0
|
||||
if(PN&&do_after(U,10))
|
||||
drained = min(drain, PN.avail)
|
||||
PN.newload += drained
|
||||
drained = PN.draw_power(drain)
|
||||
if(drained < drain)//if no power on net, drain apcs
|
||||
for(var/obj/machinery/power/terminal/T in PN.nodes)
|
||||
if(istype(T.master, /obj/machinery/power/apc))
|
||||
|
||||
@@ -142,9 +142,6 @@
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/sleep_console/power_change()
|
||||
return
|
||||
// no change - sleeper works without power (you just can't inject more)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -159,15 +159,15 @@
|
||||
del(src)
|
||||
|
||||
/obj/machinery/body_scanconsole/power_change()
|
||||
..()
|
||||
if(stat & BROKEN)
|
||||
icon_state = "body_scannerconsole-p"
|
||||
else if(powered())
|
||||
icon_state = initial(icon_state)
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
spawn(rand(0, 15))
|
||||
src.icon_state = "body_scannerconsole-p"
|
||||
stat |= NOPOWER
|
||||
if (stat & NOPOWER)
|
||||
spawn(rand(0, 15))
|
||||
src.icon_state = "body_scannerconsole-p"
|
||||
else
|
||||
icon_state = initial(icon_state)
|
||||
|
||||
/obj/machinery/body_scanconsole
|
||||
var/obj/machinery/bodyscanner/connected
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
req_access = list(access_ai_upload)
|
||||
|
||||
/obj/machinery/ai_slipper/power_change()
|
||||
..()
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
else
|
||||
if( powered() )
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
if (stat & NOPOWER)
|
||||
icon_state = "motion0"
|
||||
stat |= NOPOWER
|
||||
else
|
||||
icon_state = initial(icon_state)
|
||||
|
||||
/obj/machinery/ai_slipper/proc/setState(var/enabled, var/uses)
|
||||
src.disabled = disabled
|
||||
|
||||
@@ -1156,10 +1156,7 @@ table tr:first-child th:first-child { border: none;}
|
||||
return ..()
|
||||
|
||||
/obj/machinery/alarm/power_change()
|
||||
if(powered(power_channel))
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
stat |= NOPOWER
|
||||
..()
|
||||
spawn(rand(0,15))
|
||||
update_icon()
|
||||
|
||||
@@ -1367,13 +1364,9 @@ FIRE ALARM
|
||||
return
|
||||
|
||||
/obj/machinery/firealarm/power_change()
|
||||
if(powered(ENVIRON))
|
||||
stat &= ~NOPOWER
|
||||
..()
|
||||
spawn(rand(0,15))
|
||||
update_icon()
|
||||
else
|
||||
spawn(rand(0,15))
|
||||
stat |= NOPOWER
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/firealarm/attack_hand(mob/user as mob)
|
||||
if(user.stat || stat & (NOPOWER|BROKEN))
|
||||
|
||||
@@ -127,15 +127,14 @@
|
||||
|
||||
|
||||
/obj/machinery/power/monitor/power_change()
|
||||
|
||||
..()
|
||||
if(stat & BROKEN)
|
||||
icon_state = "broken"
|
||||
else
|
||||
if( powered() )
|
||||
icon_state = initial(icon_state)
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
if (stat & NOPOWER)
|
||||
spawn(rand(0, 15))
|
||||
src.icon_state = "c_unpowered"
|
||||
stat |= NOPOWER
|
||||
else
|
||||
icon_state = initial(icon_state)
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
var/net_id
|
||||
var/list/areas_added
|
||||
var/list/users_to_open
|
||||
|
||||
power_channel = ENVIRON
|
||||
use_power = 1
|
||||
idle_power_usage = 5
|
||||
|
||||
/obj/machinery/door/firedoor/New()
|
||||
. = ..()
|
||||
@@ -66,15 +70,6 @@
|
||||
attack_hand(M)
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/door/firedoor/power_change()
|
||||
if(powered(ENVIRON))
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
stat |= NOPOWER
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/door/firedoor/attack_hand(mob/user as mob)
|
||||
add_fingerprint(user)
|
||||
if(operating)
|
||||
@@ -101,6 +96,9 @@
|
||||
if(user.stat || user.stunned || user.weakened || user.paralysis || (!user.canmove && !isAI(user)) || (get_dist(src, user) > 1 && !isAI(user)))
|
||||
user << "Sorry, you must remain able bodied and close to \the [src] in order to use it."
|
||||
return
|
||||
if(density && (stat & (BROKEN|NOPOWER))) //can still close without power
|
||||
user << "\The [src] is not functioning, you'll have to force it open manually."
|
||||
return
|
||||
|
||||
var/needs_to_close = 0
|
||||
if(density)
|
||||
@@ -163,10 +161,10 @@
|
||||
else
|
||||
user.visible_message("\red \The [user] forces \the [ blocked ? "welded" : "" ] [src] [density ? "open" : "closed"] with \a [C]!",\
|
||||
"You force \the [ blocked ? "welded" : "" ] [src] [density ? "open" : "closed"] with \the [C]!",\
|
||||
"You hear metal strain and groan, and a door [density ? "open" : "close"].")
|
||||
"You hear metal strain and groan, and a door [density ? "opening" : "closing"].")
|
||||
if(density)
|
||||
spawn(0)
|
||||
open()
|
||||
open(1)
|
||||
else
|
||||
spawn(0)
|
||||
close()
|
||||
@@ -175,7 +173,7 @@
|
||||
|
||||
|
||||
/obj/machinery/door/firedoor/proc/latetoggle()
|
||||
if(operating || stat & NOPOWER || !nextstate)
|
||||
if(operating || !nextstate)
|
||||
return
|
||||
switch(nextstate)
|
||||
if(OPEN)
|
||||
@@ -190,7 +188,12 @@
|
||||
latetoggle()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/door/firedoor/open()
|
||||
/obj/machinery/door/firedoor/open(var/forced = 0)
|
||||
if (!forced)
|
||||
if (stat & BROKEN|NOPOWER)
|
||||
return //needs power to open unless it was forced
|
||||
else
|
||||
use_power(360)
|
||||
latetoggle()
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -44,12 +44,11 @@ var/list/doppler_arrays = list()
|
||||
|
||||
|
||||
/obj/machinery/doppler_array/power_change()
|
||||
..()
|
||||
if(stat & BROKEN)
|
||||
icon_state = "[initial(icon_state)]-broken"
|
||||
else
|
||||
if( powered() )
|
||||
if( !(stat & NOPOWER) )
|
||||
icon_state = initial(icon_state)
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
icon_state = "[initial(icon_state)]-off"
|
||||
stat |= NOPOWER
|
||||
icon_state = "[initial(icon_state)]-off"
|
||||
@@ -28,12 +28,11 @@
|
||||
src.sd_SetLuminosity(2)
|
||||
*/
|
||||
/obj/machinery/flasher/power_change()
|
||||
if ( powered() )
|
||||
stat &= ~NOPOWER
|
||||
..()
|
||||
if ( !(stat & NOPOWER) )
|
||||
icon_state = "[base_state]1"
|
||||
// src.sd_SetLuminosity(2)
|
||||
else
|
||||
stat |= ~NOPOWER
|
||||
icon_state = "[base_state]1-p"
|
||||
// src.sd_SetLuminosity(0)
|
||||
|
||||
|
||||
@@ -153,12 +153,6 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/
|
||||
active_power_usage = 100
|
||||
var/obj/effect/overlay/hologram//The projection itself. If there is one, the instrument is on, off otherwise.
|
||||
|
||||
/obj/machinery/hologram/power_change()
|
||||
if (powered())
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
stat |= ~NOPOWER
|
||||
|
||||
//Destruction procs.
|
||||
/obj/machinery/hologram/ex_act(severity)
|
||||
switch(severity)
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
icon_state = "igniter[on]"
|
||||
|
||||
/obj/machinery/igniter/power_change()
|
||||
..()
|
||||
if(!( stat & NOPOWER) )
|
||||
icon_state = "igniter[src.on]"
|
||||
else
|
||||
@@ -60,12 +61,12 @@
|
||||
..()
|
||||
|
||||
/obj/machinery/sparker/power_change()
|
||||
if ( powered() && disable == 0 )
|
||||
stat &= ~NOPOWER
|
||||
..()
|
||||
if ( !(stat & NOPOWER) && disable == 0 )
|
||||
|
||||
icon_state = "[base_state]"
|
||||
// src.sd_SetLuminosity(2)
|
||||
else
|
||||
stat |= ~NOPOWER
|
||||
icon_state = "[base_state]-p"
|
||||
// src.sd_SetLuminosity(0)
|
||||
|
||||
|
||||
@@ -118,17 +118,16 @@
|
||||
src.throw_item()
|
||||
|
||||
/obj/machinery/smartfridge/power_change()
|
||||
if( powered() )
|
||||
..()
|
||||
if( !(stat & NOPOWER) )
|
||||
src.ispowered = 1
|
||||
stat &= ~NOPOWER
|
||||
if(!isbroken)
|
||||
icon_state = icon_on
|
||||
else
|
||||
spawn(rand(0, 15))
|
||||
src.ispowered = 0
|
||||
stat |= NOPOWER
|
||||
if(!isbroken)
|
||||
icon_state = icon_off
|
||||
src.ispowered = 0
|
||||
if(!isbroken)
|
||||
icon_state = icon_off
|
||||
|
||||
/*******************
|
||||
* Item Adding
|
||||
|
||||
@@ -138,14 +138,13 @@ var/list/obj/machinery/newscaster/allCasters = list() //Global list that will co
|
||||
/obj/machinery/newscaster/power_change()
|
||||
if(isbroken) //Broken shit can't be powered.
|
||||
return
|
||||
if( src.powered() )
|
||||
..()
|
||||
if( !(stat & NOPOWER) )
|
||||
src.ispowered = 1
|
||||
stat &= ~NOPOWER
|
||||
src.update_icon()
|
||||
else
|
||||
spawn(rand(0, 15))
|
||||
src.ispowered = 0
|
||||
stat |= NOPOWER
|
||||
src.update_icon()
|
||||
|
||||
|
||||
|
||||
@@ -264,10 +264,12 @@ Status: []<BR>"},
|
||||
if(!anchored)
|
||||
icon_state = "turretCover"
|
||||
return
|
||||
|
||||
..()
|
||||
if(stat & BROKEN)
|
||||
icon_state = "[lasercolor]destroyed_target_prism"
|
||||
else
|
||||
if( powered() )
|
||||
if( !(stat & NOPOWER) )
|
||||
if (on)
|
||||
if (installation == /obj/item/weapon/gun/energy/laser || installation == /obj/item/weapon/gun/energy/pulse_rifle)
|
||||
// laser guns and pulse rifles have an orange icon
|
||||
@@ -277,11 +279,9 @@ Status: []<BR>"},
|
||||
icon_state = "[lasercolor]target_prism"
|
||||
else
|
||||
icon_state = "[lasercolor]grey_target_prism"
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
spawn(rand(0, 15))
|
||||
src.icon_state = "[lasercolor]grey_target_prism"
|
||||
stat |= NOPOWER
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,13 +28,12 @@ obj/machinery/scanner/New()
|
||||
use_power(50)
|
||||
|
||||
/obj/machinery/scanner/power_change()
|
||||
if(!powered())
|
||||
..()
|
||||
if(stat & NOPOWER)
|
||||
spawn(rand(0, 15))
|
||||
icon_state = "scanner_off"
|
||||
stat |= NOPOWER
|
||||
else
|
||||
icon_state = "scanner_idle"
|
||||
stat &= ~NOPOWER
|
||||
|
||||
obj/machinery/scanner/attack_hand(mob/living/carbon/human/user)
|
||||
if(stat & NOPOWER)
|
||||
|
||||
@@ -34,12 +34,6 @@
|
||||
else
|
||||
user << "The robot part maker is full. Please remove metal from the robot part maker in order to insert more."
|
||||
|
||||
/obj/machinery/robotic_fabricator/power_change()
|
||||
if (powered())
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
stat |= NOPOWER
|
||||
|
||||
/obj/machinery/robotic_fabricator/attack_paw(user as mob)
|
||||
return src.attack_hand(user)
|
||||
|
||||
|
||||
@@ -1,630 +0,0 @@
|
||||
/obj/machinery/shield
|
||||
name = "Emergency energy shield"
|
||||
desc = "An energy shield used to contain hull breaches."
|
||||
icon = 'icons/effects/effects.dmi'
|
||||
icon_state = "shield-old"
|
||||
density = 1
|
||||
opacity = 0
|
||||
anchored = 1
|
||||
unacidable = 1
|
||||
var/const/max_health = 200
|
||||
var/health = max_health //The shield can only take so much beating (prevents perma-prisons)
|
||||
|
||||
/obj/machinery/shield/New()
|
||||
src.dir = pick(1,2,3,4)
|
||||
..()
|
||||
update_nearby_tiles(need_rebuild=1)
|
||||
|
||||
/obj/machinery/shield/Del()
|
||||
opacity = 0
|
||||
density = 0
|
||||
update_nearby_tiles()
|
||||
..()
|
||||
|
||||
/obj/machinery/shield/CanPass(atom/movable/mover, turf/target, height, air_group)
|
||||
if(!height || air_group) return 0
|
||||
else return ..()
|
||||
|
||||
//Looks like copy/pasted code... I doubt 'need_rebuild' is even used here - Nodrak
|
||||
/obj/machinery/shield/proc/update_nearby_tiles(need_rebuild)
|
||||
if(!air_master)
|
||||
return 0
|
||||
|
||||
air_master.mark_for_update(get_turf(src))
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/shield/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
if(!istype(W)) return
|
||||
|
||||
//Calculate damage
|
||||
var/aforce = W.force
|
||||
if(W.damtype == BRUTE || W.damtype == BURN)
|
||||
src.health -= aforce
|
||||
|
||||
//Play a fitting sound
|
||||
playsound(src.loc, 'sound/effects/EMPulse.ogg', 75, 1)
|
||||
|
||||
|
||||
if (src.health <= 0)
|
||||
visible_message("\blue The [src] dissipates!")
|
||||
del(src)
|
||||
return
|
||||
|
||||
opacity = 1
|
||||
spawn(20) if(src) opacity = 0
|
||||
|
||||
..()
|
||||
|
||||
/obj/machinery/shield/meteorhit()
|
||||
src.health -= max_health*0.75 //3/4 health as damage
|
||||
|
||||
if(src.health <= 0)
|
||||
visible_message("\blue The [src] dissipates!")
|
||||
del(src)
|
||||
return
|
||||
|
||||
opacity = 1
|
||||
spawn(20) if(src) opacity = 0
|
||||
return
|
||||
|
||||
/obj/machinery/shield/bullet_act(var/obj/item/projectile/Proj)
|
||||
health -= Proj.damage
|
||||
..()
|
||||
if(health <=0)
|
||||
visible_message("\blue The [src] dissipates!")
|
||||
del(src)
|
||||
return
|
||||
opacity = 1
|
||||
spawn(20) if(src) opacity = 0
|
||||
|
||||
/obj/machinery/shield/ex_act(severity)
|
||||
switch(severity)
|
||||
if(1.0)
|
||||
if (prob(75))
|
||||
del(src)
|
||||
if(2.0)
|
||||
if (prob(50))
|
||||
del(src)
|
||||
if(3.0)
|
||||
if (prob(25))
|
||||
del(src)
|
||||
return
|
||||
|
||||
/obj/machinery/shield/emp_act(severity)
|
||||
switch(severity)
|
||||
if(1)
|
||||
del(src)
|
||||
if(2)
|
||||
if(prob(50))
|
||||
del(src)
|
||||
|
||||
/obj/machinery/shield/blob_act()
|
||||
del(src)
|
||||
|
||||
|
||||
/obj/machinery/shield/hitby(AM as mob|obj)
|
||||
//Let everyone know we've been hit!
|
||||
visible_message("\red <B>[src] was hit by [AM].</B>")
|
||||
|
||||
//Super realistic, resource-intensive, real-time damage calculations.
|
||||
var/tforce = 0
|
||||
if(ismob(AM))
|
||||
tforce = 40
|
||||
else
|
||||
tforce = AM:throwforce
|
||||
|
||||
src.health -= tforce
|
||||
|
||||
//This seemed to be the best sound for hitting a force field.
|
||||
playsound(src.loc, 'sound/effects/EMPulse.ogg', 100, 1)
|
||||
|
||||
//Handle the destruction of the shield
|
||||
if (src.health <= 0)
|
||||
visible_message("\blue The [src] dissipates!")
|
||||
del(src)
|
||||
return
|
||||
|
||||
//The shield becomes dense to absorb the blow.. purely asthetic.
|
||||
opacity = 1
|
||||
spawn(20) if(src) opacity = 0
|
||||
|
||||
..()
|
||||
return
|
||||
|
||||
|
||||
|
||||
/obj/machinery/shieldgen
|
||||
name = "Emergency shield projector"
|
||||
desc = "Used to seal minor hull breaches."
|
||||
icon = 'icons/obj/objects.dmi'
|
||||
icon_state = "shieldoff"
|
||||
density = 1
|
||||
opacity = 0
|
||||
anchored = 0
|
||||
pressure_resistance = 2*ONE_ATMOSPHERE
|
||||
req_access = list(access_engine)
|
||||
var/const/max_health = 100
|
||||
var/health = max_health
|
||||
var/active = 0
|
||||
var/malfunction = 0 //Malfunction causes parts of the shield to slowly dissapate
|
||||
var/list/deployed_shields = list()
|
||||
var/is_open = 0 //Whether or not the wires are exposed
|
||||
var/locked = 0
|
||||
|
||||
/obj/machinery/shieldgen/Del()
|
||||
for(var/obj/machinery/shield/shield_tile in deployed_shields)
|
||||
del(shield_tile)
|
||||
..()
|
||||
|
||||
|
||||
/obj/machinery/shieldgen/proc/shields_up()
|
||||
if(active) return 0 //If it's already turned on, how did this get called?
|
||||
|
||||
src.active = 1
|
||||
update_icon()
|
||||
|
||||
for(var/turf/target_tile in range(2, src))
|
||||
if (istype(target_tile,/turf/space) && !(locate(/obj/machinery/shield) in target_tile))
|
||||
if (malfunction && prob(33) || !malfunction)
|
||||
deployed_shields += new /obj/machinery/shield(target_tile)
|
||||
|
||||
/obj/machinery/shieldgen/proc/shields_down()
|
||||
if(!active) return 0 //If it's already off, how did this get called?
|
||||
|
||||
src.active = 0
|
||||
update_icon()
|
||||
|
||||
for(var/obj/machinery/shield/shield_tile in deployed_shields)
|
||||
del(shield_tile)
|
||||
|
||||
/obj/machinery/shieldgen/process()
|
||||
if(malfunction && active)
|
||||
if(deployed_shields.len && prob(5))
|
||||
del(pick(deployed_shields))
|
||||
|
||||
return
|
||||
|
||||
/obj/machinery/shieldgen/proc/checkhp()
|
||||
if(health <= 30)
|
||||
src.malfunction = 1
|
||||
if(health <= 0)
|
||||
del(src)
|
||||
update_icon()
|
||||
return
|
||||
|
||||
/obj/machinery/shieldgen/meteorhit(obj/O as obj)
|
||||
src.health -= max_health*0.25 //A quarter of the machine's health
|
||||
if (prob(5))
|
||||
src.malfunction = 1
|
||||
src.checkhp()
|
||||
return
|
||||
|
||||
/obj/machinery/shieldgen/ex_act(severity)
|
||||
switch(severity)
|
||||
if(1.0)
|
||||
src.health -= 75
|
||||
src.checkhp()
|
||||
if(2.0)
|
||||
src.health -= 30
|
||||
if (prob(15))
|
||||
src.malfunction = 1
|
||||
src.checkhp()
|
||||
if(3.0)
|
||||
src.health -= 10
|
||||
src.checkhp()
|
||||
return
|
||||
|
||||
/obj/machinery/shieldgen/emp_act(severity)
|
||||
switch(severity)
|
||||
if(1)
|
||||
src.health /= 2 //cut health in half
|
||||
malfunction = 1
|
||||
locked = pick(0,1)
|
||||
if(2)
|
||||
if(prob(50))
|
||||
src.health *= 0.3 //chop off a third of the health
|
||||
malfunction = 1
|
||||
checkhp()
|
||||
|
||||
/obj/machinery/shieldgen/attack_hand(mob/user as mob)
|
||||
if(locked)
|
||||
user << "The machine is locked, you are unable to use it."
|
||||
return
|
||||
if(is_open)
|
||||
user << "The panel must be closed before operating this machine."
|
||||
return
|
||||
|
||||
if (src.active)
|
||||
user.visible_message("\blue \icon[src] [user] deactivated the shield generator.", \
|
||||
"\blue \icon[src] You deactivate the shield generator.", \
|
||||
"You hear heavy droning fade out.")
|
||||
src.shields_down()
|
||||
else
|
||||
if(anchored)
|
||||
user.visible_message("\blue \icon[src] [user] activated the shield generator.", \
|
||||
"\blue \icon[src] You activate the shield generator.", \
|
||||
"You hear heavy droning.")
|
||||
src.shields_up()
|
||||
else
|
||||
user << "The device must first be secured to the floor."
|
||||
return
|
||||
|
||||
/obj/machinery/shieldgen/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
if(istype(W, /obj/item/weapon/card/emag))
|
||||
malfunction = 1
|
||||
update_icon()
|
||||
|
||||
else if(istype(W, /obj/item/weapon/screwdriver))
|
||||
playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1)
|
||||
if(is_open)
|
||||
user << "\blue You close the panel."
|
||||
is_open = 0
|
||||
else
|
||||
user << "\blue You open the panel and expose the wiring."
|
||||
is_open = 1
|
||||
|
||||
else if(istype(W, /obj/item/weapon/cable_coil) && malfunction && is_open)
|
||||
var/obj/item/weapon/cable_coil/coil = W
|
||||
user << "\blue You begin to replace the wires."
|
||||
//if(do_after(user, min(60, round( ((maxhealth/health)*10)+(malfunction*10) ))) //Take longer to repair heavier damage
|
||||
if(do_after(user, 30))
|
||||
if(!src || !coil) return
|
||||
coil.use(1)
|
||||
health = max_health
|
||||
malfunction = 0
|
||||
user << "\blue You repair the [src]!"
|
||||
update_icon()
|
||||
|
||||
else if(istype(W, /obj/item/weapon/wrench))
|
||||
if(locked)
|
||||
user << "The bolts are covered, unlocking this would retract the covers."
|
||||
return
|
||||
if(anchored)
|
||||
playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
|
||||
user << "\blue You unsecure the [src] from the floor!"
|
||||
if(active)
|
||||
user << "\blue The [src] shuts off!"
|
||||
src.shields_down()
|
||||
anchored = 0
|
||||
else
|
||||
if(istype(get_turf(src), /turf/space)) return //No wrenching these in space!
|
||||
playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
|
||||
user << "\blue You secure the [src] to the floor!"
|
||||
anchored = 1
|
||||
|
||||
|
||||
else if(istype(W, /obj/item/weapon/card/id) || istype(W, /obj/item/device/pda))
|
||||
if(src.allowed(user))
|
||||
src.locked = !src.locked
|
||||
user << "The controls are now [src.locked ? "locked." : "unlocked."]"
|
||||
else
|
||||
user << "\red Access denied."
|
||||
|
||||
else
|
||||
..()
|
||||
|
||||
|
||||
/obj/machinery/shieldgen/update_icon()
|
||||
if(active)
|
||||
src.icon_state = malfunction ? "shieldonbr":"shieldon"
|
||||
else
|
||||
src.icon_state = malfunction ? "shieldoffbr":"shieldoff"
|
||||
return
|
||||
|
||||
////FIELD GEN START //shameless copypasta from fieldgen, powersink, and grille
|
||||
#define maxstoredpower 500
|
||||
/obj/machinery/shieldwallgen
|
||||
name = "Shield Generator"
|
||||
desc = "A shield generator."
|
||||
icon = 'icons/obj/stationobjs.dmi'
|
||||
icon_state = "Shield_Gen"
|
||||
anchored = 0
|
||||
density = 1
|
||||
req_access = list(access_teleporter)
|
||||
var/active = 0
|
||||
var/power = 0
|
||||
var/state = 0
|
||||
var/steps = 0
|
||||
var/last_check = 0
|
||||
var/check_delay = 10
|
||||
var/recalc = 0
|
||||
var/locked = 1
|
||||
var/destroyed = 0
|
||||
var/directwired = 1
|
||||
// var/maxshieldload = 200
|
||||
var/obj/structure/cable/attached // the attached cable
|
||||
var/storedpower = 0
|
||||
flags = FPRINT | CONDUCT
|
||||
use_power = 0
|
||||
|
||||
/obj/machinery/shieldwallgen/proc/power()
|
||||
if(!anchored)
|
||||
power = 0
|
||||
return 0
|
||||
var/turf/T = src.loc
|
||||
|
||||
var/obj/structure/cable/C = T.get_cable_node()
|
||||
var/datum/powernet/PN
|
||||
if(C) PN = C.powernet // find the powernet of the connected cable
|
||||
|
||||
if(!PN)
|
||||
power = 0
|
||||
return 0
|
||||
|
||||
var/surplus = max(PN.avail-PN.load, 0)
|
||||
var/shieldload = min(rand(50,200), surplus)
|
||||
if(shieldload==0 && !storedpower) // no cable or no power, and no power stored
|
||||
power = 0
|
||||
return 0
|
||||
else
|
||||
power = 1 // IVE GOT THE POWER!
|
||||
if(PN) //runtime errors fixer. They were caused by PN.newload trying to access missing network in case of working on stored power.
|
||||
storedpower += shieldload
|
||||
PN.newload += shieldload //uses powernet power.
|
||||
// message_admins("[PN.load]", 1)
|
||||
// use_power(250) //uses APC power
|
||||
|
||||
/obj/machinery/shieldwallgen/attack_hand(mob/user as mob)
|
||||
if(state != 1)
|
||||
user << "\red The shield generator needs to be firmly secured to the floor first."
|
||||
return 1
|
||||
if(src.locked && !istype(user, /mob/living/silicon))
|
||||
user << "\red The controls are locked!"
|
||||
return 1
|
||||
if(power != 1)
|
||||
user << "\red The shield generator needs to be powered by wire underneath."
|
||||
return 1
|
||||
|
||||
if(src.active >= 1)
|
||||
src.active = 0
|
||||
icon_state = "Shield_Gen"
|
||||
|
||||
user.visible_message("[user] turned the shield generator off.", \
|
||||
"You turn off the shield generator.", \
|
||||
"You hear heavy droning fade out.")
|
||||
for(var/dir in list(1,2,4,8)) src.cleanup(dir)
|
||||
else
|
||||
src.active = 1
|
||||
icon_state = "Shield_Gen +a"
|
||||
user.visible_message("[user] turned the shield generator on.", \
|
||||
"You turn on the shield generator.", \
|
||||
"You hear heavy droning.")
|
||||
src.add_fingerprint(user)
|
||||
|
||||
/obj/machinery/shieldwallgen/process()
|
||||
spawn(100)
|
||||
power()
|
||||
if(power)
|
||||
storedpower -= 50 //this way it can survive longer and survive at all
|
||||
if(storedpower >= maxstoredpower)
|
||||
storedpower = maxstoredpower
|
||||
if(storedpower <= 0)
|
||||
storedpower = 0
|
||||
// if(shieldload >= maxshieldload) //there was a loop caused by specifics of process(), so this was needed.
|
||||
// shieldload = maxshieldload
|
||||
|
||||
if(src.active == 1)
|
||||
if(!src.state == 1)
|
||||
src.active = 0
|
||||
return
|
||||
spawn(1)
|
||||
setup_field(1)
|
||||
spawn(2)
|
||||
setup_field(2)
|
||||
spawn(3)
|
||||
setup_field(4)
|
||||
spawn(4)
|
||||
setup_field(8)
|
||||
src.active = 2
|
||||
if(src.active >= 1)
|
||||
if(src.power == 0)
|
||||
src.visible_message("\red The [src.name] shuts down due to lack of power!", \
|
||||
"You hear heavy droning fade out")
|
||||
icon_state = "Shield_Gen"
|
||||
src.active = 0
|
||||
for(var/dir in list(1,2,4,8)) src.cleanup(dir)
|
||||
|
||||
/obj/machinery/shieldwallgen/proc/setup_field(var/NSEW = 0)
|
||||
var/turf/T = src.loc
|
||||
var/turf/T2 = src.loc
|
||||
var/obj/machinery/shieldwallgen/G
|
||||
var/steps = 0
|
||||
var/oNSEW = 0
|
||||
|
||||
if(!NSEW)//Make sure its ran right
|
||||
return
|
||||
|
||||
if(NSEW == 1)
|
||||
oNSEW = 2
|
||||
else if(NSEW == 2)
|
||||
oNSEW = 1
|
||||
else if(NSEW == 4)
|
||||
oNSEW = 8
|
||||
else if(NSEW == 8)
|
||||
oNSEW = 4
|
||||
|
||||
for(var/dist = 0, dist <= 9, dist += 1) // checks out to 8 tiles away for another generator
|
||||
T = get_step(T2, NSEW)
|
||||
T2 = T
|
||||
steps += 1
|
||||
if(locate(/obj/machinery/shieldwallgen) in T)
|
||||
G = (locate(/obj/machinery/shieldwallgen) in T)
|
||||
steps -= 1
|
||||
if(!G.active)
|
||||
return
|
||||
G.cleanup(oNSEW)
|
||||
break
|
||||
|
||||
if(isnull(G))
|
||||
return
|
||||
|
||||
T2 = src.loc
|
||||
|
||||
for(var/dist = 0, dist < steps, dist += 1) // creates each field tile
|
||||
var/field_dir = get_dir(T2,get_step(T2, NSEW))
|
||||
T = get_step(T2, NSEW)
|
||||
T2 = T
|
||||
var/obj/machinery/shieldwall/CF = new/obj/machinery/shieldwall/(src, G) //(ref to this gen, ref to connected gen)
|
||||
CF.loc = T
|
||||
CF.dir = field_dir
|
||||
|
||||
|
||||
/obj/machinery/shieldwallgen/attackby(obj/item/W, mob/user)
|
||||
if(istype(W, /obj/item/weapon/wrench))
|
||||
if(active)
|
||||
user << "Turn off the field generator first."
|
||||
return
|
||||
|
||||
else if(state == 0)
|
||||
state = 1
|
||||
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
|
||||
user << "You secure the external reinforcing bolts to the floor."
|
||||
src.anchored = 1
|
||||
return
|
||||
|
||||
else if(state == 1)
|
||||
state = 0
|
||||
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
|
||||
user << "You undo the external reinforcing bolts."
|
||||
src.anchored = 0
|
||||
return
|
||||
|
||||
if(istype(W, /obj/item/weapon/card/id)||istype(W, /obj/item/device/pda))
|
||||
if (src.allowed(user))
|
||||
src.locked = !src.locked
|
||||
user << "Controls are now [src.locked ? "locked." : "unlocked."]"
|
||||
else
|
||||
user << "\red Access denied."
|
||||
|
||||
else
|
||||
src.add_fingerprint(user)
|
||||
visible_message("\red The [src.name] has been hit with \the [W.name] by [user.name]!")
|
||||
|
||||
/obj/machinery/shieldwallgen/proc/cleanup(var/NSEW)
|
||||
var/obj/machinery/shieldwall/F
|
||||
var/obj/machinery/shieldwallgen/G
|
||||
var/turf/T = src.loc
|
||||
var/turf/T2 = src.loc
|
||||
|
||||
for(var/dist = 0, dist <= 9, dist += 1) // checks out to 8 tiles away for fields
|
||||
T = get_step(T2, NSEW)
|
||||
T2 = T
|
||||
if(locate(/obj/machinery/shieldwall) in T)
|
||||
F = (locate(/obj/machinery/shieldwall) in T)
|
||||
del(F)
|
||||
|
||||
if(locate(/obj/machinery/shieldwallgen) in T)
|
||||
G = (locate(/obj/machinery/shieldwallgen) in T)
|
||||
if(!G.active)
|
||||
break
|
||||
|
||||
/obj/machinery/shieldwallgen/Del()
|
||||
src.cleanup(1)
|
||||
src.cleanup(2)
|
||||
src.cleanup(4)
|
||||
src.cleanup(8)
|
||||
..()
|
||||
|
||||
/obj/machinery/shieldwallgen/bullet_act(var/obj/item/projectile/Proj)
|
||||
storedpower -= Proj.damage
|
||||
..()
|
||||
return
|
||||
|
||||
|
||||
//////////////Containment Field START
|
||||
/obj/machinery/shieldwall
|
||||
name = "Shield"
|
||||
desc = "An energy shield."
|
||||
icon = 'icons/effects/effects.dmi'
|
||||
icon_state = "shieldwall"
|
||||
anchored = 1
|
||||
density = 1
|
||||
unacidable = 1
|
||||
luminosity = 3
|
||||
var/needs_power = 0
|
||||
var/active = 1
|
||||
// var/power = 10
|
||||
var/delay = 5
|
||||
var/last_active
|
||||
var/mob/U
|
||||
var/obj/machinery/shieldwallgen/gen_primary
|
||||
var/obj/machinery/shieldwallgen/gen_secondary
|
||||
|
||||
/obj/machinery/shieldwall/New(var/obj/machinery/shieldwallgen/A, var/obj/machinery/shieldwallgen/B)
|
||||
..()
|
||||
src.gen_primary = A
|
||||
src.gen_secondary = B
|
||||
if(A && B)
|
||||
needs_power = 1
|
||||
|
||||
/obj/machinery/shieldwall/attack_hand(mob/user as mob)
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/shieldwall/process()
|
||||
if(needs_power)
|
||||
if(isnull(gen_primary)||isnull(gen_secondary))
|
||||
del(src)
|
||||
return
|
||||
|
||||
if(!(gen_primary.active)||!(gen_secondary.active))
|
||||
del(src)
|
||||
return
|
||||
//
|
||||
if(prob(50))
|
||||
gen_primary.storedpower -= 10
|
||||
else
|
||||
gen_secondary.storedpower -=10
|
||||
|
||||
|
||||
/obj/machinery/shieldwall/bullet_act(var/obj/item/projectile/Proj)
|
||||
if(needs_power)
|
||||
var/obj/machinery/shieldwallgen/G
|
||||
if(prob(50))
|
||||
G = gen_primary
|
||||
else
|
||||
G = gen_secondary
|
||||
G.storedpower -= Proj.damage
|
||||
..()
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/shieldwall/ex_act(severity)
|
||||
if(needs_power)
|
||||
var/obj/machinery/shieldwallgen/G
|
||||
switch(severity)
|
||||
if(1.0) //big boom
|
||||
if(prob(50))
|
||||
G = gen_primary
|
||||
else
|
||||
G = gen_secondary
|
||||
G.storedpower -= 200
|
||||
|
||||
if(2.0) //medium boom
|
||||
if(prob(50))
|
||||
G = gen_primary
|
||||
else
|
||||
G = gen_secondary
|
||||
G.storedpower -= 50
|
||||
|
||||
if(3.0) //lil boom
|
||||
if(prob(50))
|
||||
G = gen_primary
|
||||
else
|
||||
G = gen_secondary
|
||||
G.storedpower -= 20
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/shieldwall/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
|
||||
if(air_group || (height==0)) return 1
|
||||
|
||||
if(istype(mover) && mover.checkpass(PASSGLASS))
|
||||
return prob(20)
|
||||
else
|
||||
if (istype(mover, /obj/item/projectile))
|
||||
return prob(10)
|
||||
else
|
||||
return !src.density
|
||||
@@ -59,14 +59,13 @@
|
||||
|
||||
|
||||
/obj/machinery/suit_storage_unit/power_change()
|
||||
if( powered() )
|
||||
..()
|
||||
if( !(stat & NOPOWER) )
|
||||
src.ispowered = 1
|
||||
stat &= ~NOPOWER
|
||||
src.update_icon()
|
||||
else
|
||||
spawn(rand(0, 15))
|
||||
src.ispowered = 0
|
||||
stat |= NOPOWER
|
||||
src.islocked = 0
|
||||
src.isopen = 1
|
||||
src.dump_everything()
|
||||
|
||||
@@ -93,10 +93,11 @@
|
||||
return (popping!=0)
|
||||
|
||||
/obj/machinery/turret/power_change()
|
||||
..()
|
||||
if(stat & BROKEN)
|
||||
icon_state = "grey_target_prism"
|
||||
else
|
||||
if( powered() )
|
||||
if( !(stat & NOPOWER) )
|
||||
if (src.enabled)
|
||||
if (src.lasers)
|
||||
icon_state = "orange_target_prism"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
use_power = 1
|
||||
idle_power_usage = 10
|
||||
var/vend_power_usage = 150 //actuators and stuff
|
||||
|
||||
var/active = 1 //No sales pitches if off!
|
||||
var/delay_product_spawn // If set, uses sleep() in product spawn proc (mostly for seeds to retrieve correct names).
|
||||
@@ -511,7 +512,7 @@
|
||||
src.speak(src.vend_reply)
|
||||
src.last_reply = world.time
|
||||
|
||||
use_power(150) //actuators and stuff
|
||||
use_power(vend_power_usage) //actuators and stuff
|
||||
if (src.icon_vend) //Show the vending animation if needed
|
||||
flick(src.icon_vend,src)
|
||||
spawn(src.vend_delay)
|
||||
@@ -561,16 +562,15 @@
|
||||
return
|
||||
|
||||
/obj/machinery/vending/power_change()
|
||||
..()
|
||||
if(stat & BROKEN)
|
||||
icon_state = "[initial(icon_state)]-broken"
|
||||
else
|
||||
if( powered() )
|
||||
if( !(stat & NOPOWER) )
|
||||
icon_state = initial(icon_state)
|
||||
stat &= ~NOPOWER
|
||||
else
|
||||
spawn(rand(0, 15))
|
||||
src.icon_state = "[initial(icon_state)]-off"
|
||||
stat |= NOPOWER
|
||||
|
||||
//Oh no we're malfunctioning! Dump out some product and break.
|
||||
/obj/machinery/vending/proc/malfunction()
|
||||
@@ -708,6 +708,7 @@
|
||||
/obj/item/weapon/reagent_containers/food/drinks/bottle/absinthe = 2,/obj/item/weapon/reagent_containers/food/drinks/bottle/grenadine = 5)
|
||||
contraband = list(/obj/item/weapon/reagent_containers/food/drinks/tea = 10)
|
||||
vend_delay = 15
|
||||
idle_power_usage = 211 //refrigerator - believe it or not, this is actually the average power consumption of a refrigerated vending machine according to NRCan.
|
||||
product_slogans = "I hope nobody asks me for a bloody cup o' tea...;Alcohol is humanity's friend. Would you abandon a friend?;Quite delighted to serve you!;Is nobody thirsty on this station?"
|
||||
product_ads = "Drink up!;Booze is good for you!;Alcohol is humanity's best friend.;Quite delighted to serve you!;Care for a nice, cold beer?;Nothing cures you like booze!;Have a sip!;Have a drink!;Have a beer!;Beer is good for you!;Only the finest alcohol!;Best quality booze since 2053!;Award-winning wine!;Maximum alcohol!;Man loves beer.;A toast for progress!"
|
||||
req_access_txt = "25"
|
||||
@@ -725,6 +726,8 @@
|
||||
icon_state = "coffee"
|
||||
icon_vend = "coffee-vend"
|
||||
vend_delay = 34
|
||||
idle_power_usage = 211 //refrigerator - believe it or not, this is actually the average power consumption of a refrigerated vending machine according to NRCan.
|
||||
vend_power_usage = 85000 //85 kJ to heat a 250 mL cup of coffee
|
||||
products = list(/obj/item/weapon/reagent_containers/food/drinks/coffee = 25,/obj/item/weapon/reagent_containers/food/drinks/tea = 25,/obj/item/weapon/reagent_containers/food/drinks/h_chocolate = 25)
|
||||
contraband = list(/obj/item/weapon/reagent_containers/food/drinks/ice = 10)
|
||||
prices = list(/obj/item/weapon/reagent_containers/food/drinks/coffee = 25, /obj/item/weapon/reagent_containers/food/drinks/tea = 25, /obj/item/weapon/reagent_containers/food/drinks/h_chocolate = 25)
|
||||
@@ -763,6 +766,7 @@
|
||||
/obj/item/weapon/reagent_containers/food/drinks/cans/dr_gibb = 1,/obj/item/weapon/reagent_containers/food/drinks/cans/starkist = 1,
|
||||
/obj/item/weapon/reagent_containers/food/drinks/cans/waterbottle = 2,/obj/item/weapon/reagent_containers/food/drinks/cans/space_up = 1,
|
||||
/obj/item/weapon/reagent_containers/food/drinks/cans/iced_tea = 1,/obj/item/weapon/reagent_containers/food/drinks/cans/grape_juice = 1)
|
||||
idle_power_usage = 211 //refrigerator - believe it or not, this is actually the average power consumption of a refrigerated vending machine according to NRCan.
|
||||
|
||||
//This one's from bay12
|
||||
/obj/machinery/vending/cart
|
||||
@@ -802,6 +806,7 @@
|
||||
/obj/item/device/healthanalyzer = 5,/obj/item/weapon/reagent_containers/glass/beaker = 4, /obj/item/weapon/reagent_containers/dropper = 2,
|
||||
/obj/item/stack/medical/advanced/bruise_pack = 3, /obj/item/stack/medical/advanced/ointment = 3, /obj/item/stack/medical/splint = 2)
|
||||
contraband = list(/obj/item/weapon/reagent_containers/pill/tox = 3,/obj/item/weapon/reagent_containers/pill/stox = 4,/obj/item/weapon/reagent_containers/pill/antitox = 6)
|
||||
idle_power_usage = 211 //refrigerator - believe it or not, this is actually the average power consumption of a refrigerated vending machine according to NRCan.
|
||||
|
||||
|
||||
//This one's from bay12
|
||||
@@ -855,6 +860,7 @@
|
||||
products = list(/obj/item/weapon/reagent_containers/glass/fertilizer/ez = 35,/obj/item/weapon/reagent_containers/glass/fertilizer/l4z = 25,/obj/item/weapon/reagent_containers/glass/fertilizer/rh = 15,/obj/item/weapon/plantspray/pests = 20,
|
||||
/obj/item/weapon/reagent_containers/syringe = 5,/obj/item/weapon/storage/bag/plants = 5)
|
||||
premium = list(/obj/item/weapon/reagent_containers/glass/bottle/ammonia = 10,/obj/item/weapon/reagent_containers/glass/bottle/diethylamine = 5)
|
||||
idle_power_usage = 211 //refrigerator - believe it or not, this is actually the average power consumption of a refrigerated vending machine according to NRCan.
|
||||
|
||||
/obj/machinery/vending/hydroseeds
|
||||
name = "MegaSeed Servitor"
|
||||
@@ -901,6 +907,7 @@
|
||||
product_ads = "For Tsar and Country.;Have you fulfilled your nutrition quota today?;Very nice!;We are simple people, for this is all we eat.;If there is a person, there is a problem. If there is no person, then there is no problem."
|
||||
products = list(/obj/item/weapon/reagent_containers/food/drinks/drinkingglass/soda = 30)
|
||||
contraband = list(/obj/item/weapon/reagent_containers/food/drinks/drinkingglass/cola = 20)
|
||||
idle_power_usage = 211 //refrigerator - believe it or not, this is actually the average power consumption of a refrigerated vending machine according to NRCan.
|
||||
|
||||
/obj/machinery/vending/tool
|
||||
name = "YouTool"
|
||||
|
||||
Reference in New Issue
Block a user