- Added a sprite "7" to the sd lighting file as it was used, even if it didn't exist.

- Piped 3.0.0 a bit.
- Standardized code/modules/power. 

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4242 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
baloh.matevz
2012-07-31 05:24:37 +00:00
parent 1134022744
commit a3d9123edd
25 changed files with 3655 additions and 3659 deletions

View File

@@ -17,127 +17,127 @@
var/locked = 0
var/drainratio = 1
process()
if(P)
if(P.air_contents.toxins <= 0)
investigate_log("<font color='red'>out of fuel</font>.","singulo")
P.air_contents.toxins = 0
eject()
else
P.air_contents.toxins -= 0.001*drainratio
return
attack_hand(mob/user as mob)
if(anchored)
if(!src.locked)
toggle_power()
user.visible_message("[user.name] turns the [src.name] [active? "on":"off"].", \
"You turn the [src.name] [active? "on":"off"].")
investigate_log("turned [active?"<font color='green'>on</font>":"<font color='red'>off</font>"] by [user.key]. [P?"Fuel: [round(P.air_contents.toxins/0.29)]%":"<font color='red'>It is empty</font>"].","singulo")
return
else
user << "\red The controls are locked!"
return
..()
attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/device/analyzer))
user << "\blue The [W.name] detects that [last_power]W were recently produced."
return 1
else if(istype(W, /obj/item/weapon/tank/plasma))
if(!src.anchored)
user << "\red The [src] needs to be secured to the floor first."
return 1
if(src.P)
user << "\red There's already a plasma tank loaded."
return 1
user.drop_item()
src.P = W
W.loc = src
updateicon()
else if(istype(W, /obj/item/weapon/crowbar))
if(P && !src.locked)
eject()
return 1
else if(istype(W, /obj/item/weapon/wrench))
if(P)
user << "\blue Remove the plasma tank first."
return 1
playsound(src.loc, 'Ratchet.ogg', 75, 1)
src.anchored = !src.anchored
user.visible_message("[user.name] [anchored? "secures":"unsecures"] the [src.name].", \
"You [anchored? "secure":"undo"] the external bolts.", \
"You hear a ratchet")
if(anchored)
connect_to_network()
else
disconnect_from_network()
else if(istype(W, /obj/item/weapon/card/id)||istype(W, /obj/item/device/pda))
if (src.allowed(user))
if(active)
src.locked = !src.locked
user << "The controls are now [src.locked ? "locked." : "unlocked."]"
else
src.locked = 0 //just in case it somehow gets locked
user << "\red The controls can only be locked when the [src] is active"
else
user << "\red Access denied!"
return 1
/obj/machinery/power/rad_collector/process()
if(P)
if(P.air_contents.toxins <= 0)
investigate_log("<font color='red'>out of fuel</font>.","singulo")
P.air_contents.toxins = 0
eject()
else
..()
return 1
P.air_contents.toxins -= 0.001*drainratio
return
ex_act(severity)
switch(severity)
if(2, 3)
eject()
return ..()
proc/eject()
locked = 0
var/obj/item/weapon/tank/plasma/Z = src.P
if (!Z)
return
Z.loc = get_turf(src)
Z.layer = initial(Z.layer)
src.P = null
if(active)
/obj/machinery/power/rad_collector/attack_hand(mob/user as mob)
if(anchored)
if(!src.locked)
toggle_power()
else
updateicon()
proc/receive_pulse(var/pulse_strength)
if(P && active)
var/power_produced = 0
power_produced = P.air_contents.toxins*pulse_strength*20
add_avail(power_produced)
last_power = power_produced
user.visible_message("[user.name] turns the [src.name] [active? "on":"off"].", \
"You turn the [src.name] [active? "on":"off"].")
investigate_log("turned [active?"<font color='green'>on</font>":"<font color='red'>off</font>"] by [user.key]. [P?"Fuel: [round(P.air_contents.toxins/0.29)]%":"<font color='red'>It is empty</font>"].","singulo")
return
return
proc/updateicon()
overlays = null
if(P)
overlays += image('icons/obj/singularity.dmi', "ptank")
if(stat & (NOPOWER|BROKEN))
return
if(active)
overlays += image('icons/obj/singularity.dmi', "on")
proc/toggle_power()
active = !active
if(active)
icon_state = "ca_on"
flick("ca_active", src)
else
icon_state = "ca"
flick("ca_deactive", src)
user << "\red The controls are locked!"
return
..()
/obj/machinery/power/rad_collector/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/device/analyzer))
user << "\blue The [W.name] detects that [last_power]W were recently produced."
return 1
else if(istype(W, /obj/item/weapon/tank/plasma))
if(!src.anchored)
user << "\red The [src] needs to be secured to the floor first."
return 1
if(src.P)
user << "\red There's already a plasma tank loaded."
return 1
user.drop_item()
src.P = W
W.loc = src
updateicon()
return
else if(istype(W, /obj/item/weapon/crowbar))
if(P && !src.locked)
eject()
return 1
else if(istype(W, /obj/item/weapon/wrench))
if(P)
user << "\blue Remove the plasma tank first."
return 1
playsound(src.loc, 'Ratchet.ogg', 75, 1)
src.anchored = !src.anchored
user.visible_message("[user.name] [anchored? "secures":"unsecures"] the [src.name].", \
"You [anchored? "secure":"undo"] the external bolts.", \
"You hear a ratchet")
if(anchored)
connect_to_network()
else
disconnect_from_network()
else if(istype(W, /obj/item/weapon/card/id)||istype(W, /obj/item/device/pda))
if (src.allowed(user))
if(active)
src.locked = !src.locked
user << "The controls are now [src.locked ? "locked." : "unlocked."]"
else
src.locked = 0 //just in case it somehow gets locked
user << "\red The controls can only be locked when the [src] is active"
else
user << "\red Access denied!"
return 1
else
..()
return 1
/obj/machinery/power/rad_collector/ex_act(severity)
switch(severity)
if(2, 3)
eject()
return ..()
/obj/machinery/power/rad_collector/proc/eject()
locked = 0
var/obj/item/weapon/tank/plasma/Z = src.P
if (!Z)
return
Z.loc = get_turf(src)
Z.layer = initial(Z.layer)
src.P = null
if(active)
toggle_power()
else
updateicon()
/obj/machinery/power/rad_collector/proc/receive_pulse(var/pulse_strength)
if(P && active)
var/power_produced = 0
power_produced = P.air_contents.toxins*pulse_strength*20
add_avail(power_produced)
last_power = power_produced
return
return
/obj/machinery/power/rad_collector/proc/updateicon()
overlays = null
if(P)
overlays += image('icons/obj/singularity.dmi', "ptank")
if(stat & (NOPOWER|BROKEN))
return
if(active)
overlays += image('icons/obj/singularity.dmi', "on")
/obj/machinery/power/rad_collector/proc/toggle_power()
active = !active
if(active)
icon_state = "ca_on"
flick("ca_active", src)
else
icon_state = "ca"
flick("ca_deactive", src)
updateicon()
return

View File

@@ -13,99 +13,99 @@
var/obj/machinery/field_generator/FG2 = null
var/hasShocked = 0 //Used to add a delay between shocks. In some cases this used to crash servers by spawning hundreds of sparks every second.
New()
spawn(1)
src.sd_SetLuminosity(5)
/obj/machinery/containment_field/New()
spawn(1)
src.sd_SetLuminosity(5)
Del()
if(FG1 && !FG1.clean_up)
FG1.cleanup()
if(FG2 && !FG2.clean_up)
FG2.cleanup()
..()
/obj/machinery/containment_field/Del()
if(FG1 && !FG1.clean_up)
FG1.cleanup()
if(FG2 && !FG2.clean_up)
FG2.cleanup()
..()
attack_hand(mob/user as mob)
if(get_dist(src, user) > 1)
return 0
else
shock(user)
return 1
blob_act()
/obj/machinery/containment_field/attack_hand(mob/user as mob)
if(get_dist(src, user) > 1)
return 0
else
shock(user)
return 1
ex_act(severity)
/obj/machinery/containment_field/blob_act()
return 0
/obj/machinery/containment_field/ex_act(severity)
return 0
/obj/machinery/containment_field/HasProximity(atom/movable/AM as mob|obj)
if(istype(AM,/mob/living/silicon) && prob(40))
shock(AM)
return 1
if(istype(AM,/mob/living/carbon) && prob(50))
shock(AM)
return 1
return 0
/obj/machinery/containment_field/proc/shock(mob/living/user as mob)
if(hasShocked)
return 0
HasProximity(atom/movable/AM as mob|obj)
if(istype(AM,/mob/living/silicon) && prob(40))
shock(AM)
return 1
if(istype(AM,/mob/living/carbon) && prob(50))
shock(AM)
return 1
if(!FG1 || !FG2)
del(src)
return 0
if(iscarbon(user))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, user.loc)
s.start()
hasShocked = 1
var/shock_damage = min(rand(30,40),rand(30,40))
user.burn_skin(shock_damage)
user.updatehealth()
user.visible_message("\red [user.name] was shocked by the [src.name]!", \
"\red <B>You feel a powerful shock course through your body sending you flying!</B>", \
"\red You hear a heavy electrical crack")
proc
shock(mob/living/user as mob)
if(hasShocked)
return 0
if(!FG1 || !FG2)
del(src)
return 0
if(iscarbon(user))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, user.loc)
s.start()
var/stun = min(shock_damage, 15)
user.Stun(stun)
user.Weaken(10)
hasShocked = 1
var/shock_damage = min(rand(30,40),rand(30,40))
user.burn_skin(shock_damage)
user.updatehealth()
user.visible_message("\red [user.name] was shocked by the [src.name]!", \
"\red <B>You feel a powerful shock course through your body sending you flying!</B>", \
"\red You hear a heavy electrical crack")
user.updatehealth()
var/atom/target = get_edge_target_turf(user, get_dir(src, get_step_away(user, src)))
user.throw_at(target, 200, 4)
var/stun = min(shock_damage, 15)
user.Stun(stun)
user.Weaken(10)
sleep(20)
hasShocked = 0
return
user.updatehealth()
var/atom/target = get_edge_target_turf(user, get_dir(src, get_step_away(user, src)))
user.throw_at(target, 200, 4)
else if(issilicon(user))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, user.loc)
s.start()
sleep(20)
hasShocked = 0
return
hasShocked = 1
var/shock_damage = rand(15,30)
user.take_overall_damage(0,shock_damage)
user.visible_message("\red [user.name] was shocked by the [src.name]!", \
"\red <B>Energy pulse detected, system damaged!</B>", \
"\red You hear an electrical crack")
if(prob(20))
user.Stun(2)
else if(issilicon(user))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, user.loc)
s.start()
sleep(20)
hasShocked = 0
return
hasShocked = 1
var/shock_damage = rand(15,30)
user.take_overall_damage(0,shock_damage)
user.visible_message("\red [user.name] was shocked by the [src.name]!", \
"\red <B>Energy pulse detected, system damaged!</B>", \
"\red You hear an electrical crack")
if(prob(20))
user.Stun(2)
return
sleep(20)
hasShocked = 0
return
return
set_master(var/master1,var/master2)
if(!master1 || !master2)
return 0
FG1 = master1
FG2 = master2
return 1
/obj/machinery/containment_field/proc/set_master(var/master1,var/master2)
if(!master1 || !master2)
return 0
FG1 = master1
FG2 = master2
return 1

View File

@@ -21,192 +21,192 @@
var/locked = 0
verb/rotate()
set name = "Rotate"
set category = "Object"
set src in oview(1)
/obj/machinery/emitter/verb/rotate()
set name = "Rotate"
set category = "Object"
set src in oview(1)
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 90)
return 1
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 90)
return 1
New()
..()
return
/obj/machinery/emitter/New()
..()
return
Del()
investigate_log("<font color='red'>deleted</font> at ([x],[y],[z])","singulo")
..()
/obj/machinery/emitter/Del()
investigate_log("<font color='red'>deleted</font> at ([x],[y],[z])","singulo")
..()
update_icon()
if (active && !(stat & (NOPOWER|BROKEN)))
icon_state = "emitter_+a"
else
icon_state = "emitter"
/obj/machinery/emitter/update_icon()
if (active && !(stat & (NOPOWER|BROKEN)))
icon_state = "emitter_+a"
else
icon_state = "emitter"
attack_hand(mob/user as mob)
src.add_fingerprint(user)
if(state == 2)
if(!src.locked)
if(src.active==1)
src.active = 0
user << "You turn off the [src]."
src.use_power = 1
investigate_log("turned <font color='red'>off</font> by [user.key]","singulo")
else
src.active = 1
user << "You turn on the [src]."
src.shot_number = 0
src.fire_delay = 100
src.use_power = 2
investigate_log("turned <font color='green'>on</font> by [user.key]","singulo")
update_icon()
else
user << "\red The controls are locked!"
else
user << "\red The [src] needs to be firmly secured to the floor first."
return 1
emp_act(var/severity)//Emitters are hardened but still might have issues
use_power(50)
if((severity == 1)&&prob(1)&&prob(1))
if(src.active)
/obj/machinery/emitter/attack_hand(mob/user as mob)
src.add_fingerprint(user)
if(state == 2)
if(!src.locked)
if(src.active==1)
src.active = 0
user << "You turn off the [src]."
src.use_power = 1
investigate_log("turned <font color='red'>off</font> by [user.key]","singulo")
else
src.active = 1
user << "You turn on the [src]."
src.shot_number = 0
src.fire_delay = 100
src.use_power = 2
investigate_log("turned <font color='green'>on</font> by [user.key]","singulo")
update_icon()
else
user << "\red The controls are locked!"
else
user << "\red The [src] needs to be firmly secured to the floor first."
return 1
process()
if(stat & (NOPOWER|BROKEN))
return
if(src.state != 2)
/obj/machinery/emitter/emp_act(var/severity)//Emitters are hardened but still might have issues
use_power(50)
if((severity == 1)&&prob(1)&&prob(1))
if(src.active)
src.active = 0
src.use_power = 1
return 1
/obj/machinery/emitter/process()
if(stat & (NOPOWER|BROKEN))
return
if(src.state != 2)
src.active = 0
return
if(((src.last_shot + src.fire_delay) <= world.time) && (src.active == 1))
src.last_shot = world.time
if(src.shot_number < 3)
src.fire_delay = 2
src.shot_number ++
else
src.fire_delay = rand(20,100)
src.shot_number = 0
use_power(1000)
var/obj/item/projectile/beam/emitter/A = new /obj/item/projectile/beam/emitter( src.loc )
playsound(src.loc, 'emitter.ogg', 25, 1)
if(prob(35))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, src)
s.start()
A.dir = src.dir
if(src.dir == 1)//Up
A.yo = 20
A.xo = 0
else if(src.dir == 2)//Down
A.yo = -20
A.xo = 0
else if(src.dir == 4)//Right
A.yo = 0
A.xo = 20
else if(src.dir == 8)//Left
A.yo = 0
A.xo = -20
else // Any other
A.yo = -20
A.xo = 0
A.process()
/obj/machinery/emitter/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/weapon/wrench))
if(active)
user << "Turn off the [src] first."
return
if(((src.last_shot + src.fire_delay) <= world.time) && (src.active == 1))
src.last_shot = world.time
if(src.shot_number < 3)
src.fire_delay = 2
src.shot_number ++
else
src.fire_delay = rand(20,100)
src.shot_number = 0
use_power(1000)
var/obj/item/projectile/beam/emitter/A = new /obj/item/projectile/beam/emitter( src.loc )
playsound(src.loc, 'emitter.ogg', 25, 1)
if(prob(35))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, src)
s.start()
A.dir = src.dir
if(src.dir == 1)//Up
A.yo = 20
A.xo = 0
else if(src.dir == 2)//Down
A.yo = -20
A.xo = 0
else if(src.dir == 4)//Right
A.yo = 0
A.xo = 20
else if(src.dir == 8)//Left
A.yo = 0
A.xo = -20
else // Any other
A.yo = -20
A.xo = 0
A.process()
switch(state)
if(0)
state = 1
playsound(src.loc, 'Ratchet.ogg', 75, 1)
user.visible_message("[user.name] secures [src.name] to the floor.", \
"You secure the external reinforcing bolts to the floor.", \
"You hear a ratchet")
src.anchored = 1
if(1)
state = 0
playsound(src.loc, 'Ratchet.ogg', 75, 1)
user.visible_message("[user.name] unsecures [src.name] reinforcing bolts from the floor.", \
"You undo the external reinforcing bolts.", \
"You hear a ratchet")
src.anchored = 0
if(2)
user << "\red The [src.name] needs to be unwelded from the floor."
return
attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/weapon/wrench))
if(active)
user << "Turn off the [src] first."
return
switch(state)
if(0)
state = 1
playsound(src.loc, 'Ratchet.ogg', 75, 1)
user.visible_message("[user.name] secures [src.name] to the floor.", \
"You secure the external reinforcing bolts to the floor.", \
"You hear a ratchet")
src.anchored = 1
if(1)
state = 0
playsound(src.loc, 'Ratchet.ogg', 75, 1)
user.visible_message("[user.name] unsecures [src.name] reinforcing bolts from the floor.", \
"You undo the external reinforcing bolts.", \
"You hear a ratchet")
src.anchored = 0
if(2)
user << "\red The [src.name] needs to be unwelded from the floor."
if(istype(W, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = W
if(active)
user << "Turn off the [src] first."
return
if(istype(W, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = W
if(active)
user << "Turn off the [src] first."
return
switch(state)
if(0)
user << "\red The [src.name] needs to be wrenched to the floor."
if(1)
if (WT.remove_fuel(0,user))
playsound(src.loc, 'Welder2.ogg', 50, 1)
user.visible_message("[user.name] starts to weld the [src.name] to the floor.", \
"You start to weld the [src] to the floor.", \
"You hear welding")
if (do_after(user,20))
if(!src || !WT.isOn()) return
state = 2
user << "You weld the [src] to the floor."
else
user << "\red You need more welding fuel to complete this task."
if(2)
if (WT.remove_fuel(0,user))
playsound(src.loc, 'Welder2.ogg', 50, 1)
user.visible_message("[user.name] starts to cut the [src.name] free from the floor.", \
"You start to cut the [src] free from the floor.", \
"You hear welding")
if (do_after(user,20))
if(!src || !WT.isOn()) return
state = 1
user << "You cut the [src] free from the floor."
else
user << "\red You need more welding fuel to complete this task."
return
if(istype(W, /obj/item/weapon/card/id) || istype(W, /obj/item/device/pda))
if(emagged)
user << "\red The lock seems to be broken"
return
if(src.allowed(user))
if(active)
src.locked = !src.locked
user << "The controls are now [src.locked ? "locked." : "unlocked."]"
switch(state)
if(0)
user << "\red The [src.name] needs to be wrenched to the floor."
if(1)
if (WT.remove_fuel(0,user))
playsound(src.loc, 'Welder2.ogg', 50, 1)
user.visible_message("[user.name] starts to weld the [src.name] to the floor.", \
"You start to weld the [src] to the floor.", \
"You hear welding")
if (do_after(user,20))
if(!src || !WT.isOn()) return
state = 2
user << "You weld the [src] to the floor."
else
src.locked = 0 //just in case it somehow gets locked
user << "\red The controls can only be locked when the [src] is online"
user << "\red You need more welding fuel to complete this task."
if(2)
if (WT.remove_fuel(0,user))
playsound(src.loc, 'Welder2.ogg', 50, 1)
user.visible_message("[user.name] starts to cut the [src.name] free from the floor.", \
"You start to cut the [src] free from the floor.", \
"You hear welding")
if (do_after(user,20))
if(!src || !WT.isOn()) return
state = 1
user << "You cut the [src] free from the floor."
else
user << "\red You need more welding fuel to complete this task."
return
if(istype(W, /obj/item/weapon/card/id) || istype(W, /obj/item/device/pda))
if(emagged)
user << "\red The lock seems to be broken"
return
if(src.allowed(user))
if(active)
src.locked = !src.locked
user << "The controls are now [src.locked ? "locked." : "unlocked."]"
else
user << "\red Access denied."
return
if(istype(W, /obj/item/weapon/card/emag) && !emagged)
locked = 0
emagged = 1
user.visible_message("[user.name] emags the [src.name].","\red You short out the lock.")
return
..()
src.locked = 0 //just in case it somehow gets locked
user << "\red The controls can only be locked when the [src] is online"
else
user << "\red Access denied."
return
power_change()
..()
update_icon()
if(istype(W, /obj/item/weapon/card/emag) && !emagged)
locked = 0
emagged = 1
user.visible_message("[user.name] emags the [src.name].","\red You short out the lock.")
return
..()
return
/obj/machinery/emitter/power_change()
..()
update_icon()
return

View File

@@ -33,318 +33,318 @@ field_generator power level display
var/clean_up = 0
update_icon()
overlays = null
if(!active)
if(warming_up)
overlays += "+a[warming_up]"
if(fields.len)
overlays += "+on"
// Power level indicator
// Scale % power to % num_power_levels and truncate value
var/level = round(num_power_levels * power / field_generator_max_power)
// Clamp between 0 and num_power_levels for out of range power values
level = between(0, level, num_power_levels)
if(level)
overlays += "+p[level]"
/obj/machinery/field_generator/update_icon()
overlays = null
if(!active)
if(warming_up)
overlays += "+a[warming_up]"
if(fields.len)
overlays += "+on"
// Power level indicator
// Scale % power to % num_power_levels and truncate value
var/level = round(num_power_levels * power / field_generator_max_power)
// Clamp between 0 and num_power_levels for out of range power values
level = between(0, level, num_power_levels)
if(level)
overlays += "+p[level]"
return
return
New()
..()
fields = list()
connected_gens = list()
return
/obj/machinery/field_generator/New()
..()
fields = list()
connected_gens = list()
return
process()
if(Varedit_start == 1)
if(active == 0)
active = 1
state = 2
power = field_generator_max_power
anchored = 1
warming_up = 3
start_fields()
update_icon()
Varedit_start = 0
if(src.active == 2)
calc_power()
update_icon()
return
attack_hand(mob/user as mob)
if(state == 2)
if(get_dist(src, user) <= 1)//Need to actually touch the thing to turn it on
if(src.active >= 1)
user << "You are unable to turn off the [src.name] once it is online."
return 1
else
user.visible_message("[user.name] turns on the [src.name]", \
"You turn on the [src.name].", \
"You hear heavy droning")
turn_on()
investigate_log("<font color='green'>activated</font> by [user.key].","singulo")
src.add_fingerprint(user)
else
user << "The [src] needs to be firmly secured to the floor first."
return
attackby(obj/item/W, mob/user)
if(active)
user << "The [src] needs to be off."
return
else if(istype(W, /obj/item/weapon/wrench))
switch(state)
if(0)
state = 1
playsound(src.loc, 'Ratchet.ogg', 75, 1)
user.visible_message("[user.name] secures [src.name] to the floor.", \
"You secure the external reinforcing bolts to the floor.", \
"You hear ratchet")
src.anchored = 1
if(1)
state = 0
playsound(src.loc, 'Ratchet.ogg', 75, 1)
user.visible_message("[user.name] unsecures [src.name] reinforcing bolts from the floor.", \
"You undo the external reinforcing bolts.", \
"You hear ratchet")
src.anchored = 0
if(2)
user << "\red The [src.name] needs to be unwelded from the floor."
return
else if(istype(W, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = W
switch(state)
if(0)
user << "\red The [src.name] needs to be wrenched to the floor."
return
if(1)
if (WT.remove_fuel(0,user))
playsound(src.loc, 'Welder2.ogg', 50, 1)
user.visible_message("[user.name] starts to weld the [src.name] to the floor.", \
"You start to weld the [src] to the floor.", \
"You hear welding")
if (do_after(user,20))
if(!src || !WT.isOn()) return
state = 2
user << "You weld the field generator to the floor."
else
return
if(2)
if (WT.remove_fuel(0,user))
playsound(src.loc, 'Welder2.ogg', 50, 1)
user.visible_message("[user.name] starts to cut the [src.name] free from the floor.", \
"You start to cut the [src] free from the floor.", \
"You hear welding")
if (do_after(user,20))
if(!src || !WT.isOn()) return
state = 1
user << "You cut the [src] free from the floor."
else
return
else
..()
return
emp_act()
return 0
blob_act()
if(active)
return 0
else
..()
bullet_act(var/obj/item/projectile/Proj)
if(Proj.flag != "bullet")
power += Proj.damage
update_icon()
return 0
Del()
src.cleanup()
..()
proc
turn_off()
active = 0
spawn(1)
src.cleanup()
update_icon()
turn_on()
/obj/machinery/field_generator/process()
if(Varedit_start == 1)
if(active == 0)
active = 1
warming_up = 1
spawn(1)
while (warming_up<3 && active)
sleep(50)
warming_up++
update_icon()
if(warming_up >= 3)
start_fields()
state = 2
power = field_generator_max_power
anchored = 1
warming_up = 3
start_fields()
update_icon()
Varedit_start = 0
if(src.active == 2)
calc_power()
if(Varpower)
return 1
update_icon()
return
update_icon()
if(src.power > field_generator_max_power)
src.power = field_generator_max_power
var/power_draw = 2
for (var/obj/machinery/containment_field/F in fields)
if (isnull(F))
continue
power_draw++
if(draw_power(round(power_draw/2,1)))
/obj/machinery/field_generator/attack_hand(mob/user as mob)
if(state == 2)
if(get_dist(src, user) <= 1)//Need to actually touch the thing to turn it on
if(src.active >= 1)
user << "You are unable to turn off the [src.name] once it is online."
return 1
else
for(var/mob/M in viewers(src))
M.show_message("\red The [src.name] shuts down!")
turn_off()
investigate_log("ran out of power and <font color='red'>deactivated</font>","singulo")
src.power = 0
return 0
user.visible_message("[user.name] turns on the [src.name]", \
"You turn on the [src.name].", \
"You hear heavy droning")
turn_on()
investigate_log("<font color='green'>activated</font> by [user.key].","singulo")
src.add_fingerprint(user)
else
user << "The [src] needs to be firmly secured to the floor first."
return
/obj/machinery/field_generator/attackby(obj/item/W, mob/user)
if(active)
user << "The [src] needs to be off."
return
else if(istype(W, /obj/item/weapon/wrench))
switch(state)
if(0)
state = 1
playsound(src.loc, 'Ratchet.ogg', 75, 1)
user.visible_message("[user.name] secures [src.name] to the floor.", \
"You secure the external reinforcing bolts to the floor.", \
"You hear ratchet")
src.anchored = 1
if(1)
state = 0
playsound(src.loc, 'Ratchet.ogg', 75, 1)
user.visible_message("[user.name] unsecures [src.name] reinforcing bolts from the floor.", \
"You undo the external reinforcing bolts.", \
"You hear ratchet")
src.anchored = 0
if(2)
user << "\red The [src.name] needs to be unwelded from the floor."
return
else if(istype(W, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = W
switch(state)
if(0)
user << "\red The [src.name] needs to be wrenched to the floor."
return
if(1)
if (WT.remove_fuel(0,user))
playsound(src.loc, 'Welder2.ogg', 50, 1)
user.visible_message("[user.name] starts to weld the [src.name] to the floor.", \
"You start to weld the [src] to the floor.", \
"You hear welding")
if (do_after(user,20))
if(!src || !WT.isOn()) return
state = 2
user << "You weld the field generator to the floor."
else
return
if(2)
if (WT.remove_fuel(0,user))
playsound(src.loc, 'Welder2.ogg', 50, 1)
user.visible_message("[user.name] starts to cut the [src.name] free from the floor.", \
"You start to cut the [src] free from the floor.", \
"You hear welding")
if (do_after(user,20))
if(!src || !WT.isOn()) return
state = 1
user << "You cut the [src] free from the floor."
else
return
else
..()
return
/obj/machinery/field_generator/emp_act()
return 0
/obj/machinery/field_generator/blob_act()
if(active)
return 0
else
..()
/obj/machinery/field_generator/bullet_act(var/obj/item/projectile/Proj)
if(Proj.flag != "bullet")
power += Proj.damage
update_icon()
return 0
/obj/machinery/field_generator/Del()
src.cleanup()
..()
/obj/machinery/field_generator/proc/turn_off()
active = 0
spawn(1)
src.cleanup()
update_icon()
/obj/machinery/field_generator/proc/turn_on()
active = 1
warming_up = 1
spawn(1)
while (warming_up<3 && active)
sleep(50)
warming_up++
update_icon()
if(warming_up >= 3)
start_fields()
update_icon()
/obj/machinery/field_generator/proc/calc_power()
if(Varpower)
return 1
update_icon()
if(src.power > field_generator_max_power)
src.power = field_generator_max_power
var/power_draw = 2
for (var/obj/machinery/containment_field/F in fields)
if (isnull(F))
continue
power_draw++
if(draw_power(round(power_draw/2,1)))
return 1
else
for(var/mob/M in viewers(src))
M.show_message("\red The [src.name] shuts down!")
turn_off()
investigate_log("ran out of power and <font color='red'>deactivated</font>","singulo")
src.power = 0
return 0
//This could likely be better, it tends to start loopin if you have a complex generator loop setup. Still works well enough to run the engine fields will likely recode the field gens and fields sometime -Mport
draw_power(var/draw = 0, var/failsafe = 0, var/obj/machinery/field_generator/G = null, var/obj/machinery/field_generator/last = null)
if(Varpower)
return 1
if((G && G == src) || (failsafe >= 8))//Loopin, set fail
return 0
else
failsafe++
if(src.power >= draw)//We have enough power
src.power -= draw
return 1
else//Need more power
draw -= src.power
src.power = 0
for(var/obj/machinery/field_generator/FG in connected_gens)
if(isnull(FG))
continue
if(FG == last)//We just asked you
continue
if(G)//Another gen is askin for power and we dont have it
if(FG.draw_power(draw,failsafe,G,src))//Can you take the load
return 1
else
return 0
else//We are askin another for power
if(FG.draw_power(draw,failsafe,src,src))
return 1
else
return 0
start_fields()
if(!src.state == 2 || !anchored)
turn_off()
return
spawn(1)
setup_field(1)
spawn(2)
setup_field(2)
spawn(3)
setup_field(4)
spawn(4)
setup_field(8)
src.active = 2
setup_field(var/NSEW)
var/turf/T = src.loc
var/obj/machinery/field_generator/G
var/steps = 0
if(!NSEW)//Make sure its ran right
return
for(var/dist = 0, dist <= 9, dist += 1) // checks out to 8 tiles away for another generator
T = get_step(T, NSEW)
if(T.density)//We cant shoot a field though this
/obj/machinery/field_generator/proc/draw_power(var/draw = 0, var/failsafe = 0, var/obj/machinery/field_generator/G = null, var/obj/machinery/field_generator/last = null)
if(Varpower)
return 1
if((G && G == src) || (failsafe >= 8))//Loopin, set fail
return 0
else
failsafe++
if(src.power >= draw)//We have enough power
src.power -= draw
return 1
else//Need more power
draw -= src.power
src.power = 0
for(var/obj/machinery/field_generator/FG in connected_gens)
if(isnull(FG))
continue
if(FG == last)//We just asked you
continue
if(G)//Another gen is askin for power and we dont have it
if(FG.draw_power(draw,failsafe,G,src))//Can you take the load
return 1
else
return 0
else//We are askin another for power
if(FG.draw_power(draw,failsafe,src,src))
return 1
else
return 0
for(var/atom/A in T.contents)
if(ismob(A))
continue
if(!istype(A,/obj/machinery/field_generator))
if((istype(A,/obj/machinery/door)||istype(A,/obj/machinery/the_singularitygen))&&(A.density))
return 0
steps += 1
G = locate(/obj/machinery/field_generator) in T
if(!isnull(G))
steps -= 1
if(!G.active)
return 0
break
if(isnull(G))
return
T = src.loc
for(var/dist = 0, dist < steps, dist += 1) // creates each field tile
var/field_dir = get_dir(T,get_step(G.loc, NSEW))
T = get_step(T, NSEW)
if(!locate(/obj/machinery/containment_field) in T)
var/obj/machinery/containment_field/CF = new/obj/machinery/containment_field()
CF.set_master(src,G)
fields += CF
G.fields += CF
CF.loc = T
CF.dir = field_dir
var/listcheck = 0
for(var/obj/machinery/field_generator/FG in connected_gens)
if (isnull(FG))
continue
if(FG == G)
listcheck = 1
break
if(!listcheck)
connected_gens.Add(G)
listcheck = 0
for(var/obj/machinery/field_generator/FG2 in G.connected_gens)
if (isnull(FG2))
continue
if(FG2 == src)
listcheck = 1
break
if(!listcheck)
G.connected_gens.Add(src)
cleanup()
clean_up = 1
for (var/obj/machinery/containment_field/F in fields)
if (isnull(F))
continue
del(F)
fields = list()
for(var/obj/machinery/field_generator/FG in connected_gens)
if (isnull(FG))
continue
FG.connected_gens.Remove(src)
connected_gens.Remove(FG)
connected_gens = list()
clean_up = 0
/obj/machinery/field_generator/proc/start_fields()
if(!src.state == 2 || !anchored)
turn_off()
return
spawn(1)
setup_field(1)
spawn(2)
setup_field(2)
spawn(3)
setup_field(4)
spawn(4)
setup_field(8)
src.active = 2
//This is here to help fight the "hurr durr, release singulo cos nobody will notice before the
//singulo eats the evidence". It's not fool-proof but better than nothing.
//I want to avoid using global variables.
spawn(1)
var/temp = 1 //stops spam
for(var/obj/machinery/singularity/O in world)
if(O.last_warning && temp)
if((world.time - O.last_warning) > 50) //to stop message-spam
temp = 0
message_admins("A singulo exists and a containment field has failed.",1)
investigate_log("has <font color='red'>failed</font> whilst a singulo exists.","singulo")
O.last_warning = world.time
/obj/machinery/field_generator/proc/setup_field(var/NSEW)
var/turf/T = src.loc
var/obj/machinery/field_generator/G
var/steps = 0
if(!NSEW)//Make sure its ran right
return
for(var/dist = 0, dist <= 9, dist += 1) // checks out to 8 tiles away for another generator
T = get_step(T, NSEW)
if(T.density)//We cant shoot a field though this
return 0
for(var/atom/A in T.contents)
if(ismob(A))
continue
if(!istype(A,/obj/machinery/field_generator))
if((istype(A,/obj/machinery/door)||istype(A,/obj/machinery/the_singularitygen))&&(A.density))
return 0
steps += 1
G = locate(/obj/machinery/field_generator) in T
if(!isnull(G))
steps -= 1
if(!G.active)
return 0
break
if(isnull(G))
return
T = src.loc
for(var/dist = 0, dist < steps, dist += 1) // creates each field tile
var/field_dir = get_dir(T,get_step(G.loc, NSEW))
T = get_step(T, NSEW)
if(!locate(/obj/machinery/containment_field) in T)
var/obj/machinery/containment_field/CF = new/obj/machinery/containment_field()
CF.set_master(src,G)
fields += CF
G.fields += CF
CF.loc = T
CF.dir = field_dir
var/listcheck = 0
for(var/obj/machinery/field_generator/FG in connected_gens)
if (isnull(FG))
continue
if(FG == G)
listcheck = 1
break
if(!listcheck)
connected_gens.Add(G)
listcheck = 0
for(var/obj/machinery/field_generator/FG2 in G.connected_gens)
if (isnull(FG2))
continue
if(FG2 == src)
listcheck = 1
break
if(!listcheck)
G.connected_gens.Add(src)
/obj/machinery/field_generator/proc/cleanup()
clean_up = 1
for (var/obj/machinery/containment_field/F in fields)
if (isnull(F))
continue
del(F)
fields = list()
for(var/obj/machinery/field_generator/FG in connected_gens)
if (isnull(FG))
continue
FG.connected_gens.Remove(src)
connected_gens.Remove(FG)
connected_gens = list()
clean_up = 0
//This is here to help fight the "hurr durr, release singulo cos nobody will notice before the
//singulo eats the evidence". It's not fool-proof but better than nothing.
//I want to avoid using global variables.
spawn(1)
var/temp = 1 //stops spam
for(var/obj/machinery/singularity/O in world)
if(O.last_warning && temp)
if((world.time - O.last_warning) > 50) //to stop message-spam
temp = 0
message_admins("A singulo exists and a containment field has failed.",1)
investigate_log("has <font color='red'>failed</font> whilst a singulo exists.","singulo")
O.last_warning = world.time

View File

@@ -10,66 +10,66 @@
var/movement_range = 10
var/energy = 10
weak
movement_range = 8
energy = 5
/obj/effect/accelerated_particle/weak
movement_range = 8
energy = 5
strong
movement_range = 15
energy = 15
/obj/effect/accelerated_particle/strong
movement_range = 15
energy = 15
New(loc, dir = 2)
src.loc = loc
src.dir = dir
if(movement_range > 20)
movement_range = 20
spawn(0)
move(1)
return
/obj/effect/accelerated_particle/New(loc, dir = 2)
src.loc = loc
src.dir = dir
if(movement_range > 20)
movement_range = 20
spawn(0)
move(1)
return
Bump(atom/A)
if (A)
if(ismob(A))
toxmob(A)
if((istype(A,/obj/machinery/the_singularitygen))||(istype(A,/obj/machinery/singularity/)))
A:energy += energy
return
Bumped(atom/A)
/obj/effect/accelerated_particle/Bump(atom/A)
if (A)
if(ismob(A))
Bump(A)
return
toxmob(A)
if((istype(A,/obj/machinery/the_singularitygen))||(istype(A,/obj/machinery/singularity/)))
A:energy += energy
return
ex_act(severity)
del(src)
return
/obj/effect/accelerated_particle/Bumped(atom/A)
if(ismob(A))
Bump(A)
return
proc
toxmob(var/mob/living/M)
var/radiation = (energy*2)
/obj/effect/accelerated_particle/ex_act(severity)
del(src)
return
/obj/effect/accelerated_particle/proc/toxmob(var/mob/living/M)
var/radiation = (energy*2)
/* if(istype(M,/mob/living/carbon/human))
if(M:wear_suit) //TODO: check for radiation protection
radiation = round(radiation/2,1)
if(istype(M,/mob/living/carbon/monkey))
if(M:wear_suit) //TODO: check for radiation protection
radiation = round(radiation/2,1)*/
M.apply_effect((radiation*3),IRRADIATE,0)
M.updatehealth()
//M << "\red You feel odd."
return
if(M:wear_suit) //TODO: check for radiation protection
radiation = round(radiation/2,1)
if(istype(M,/mob/living/carbon/monkey))
if(M:wear_suit) //TODO: check for radiation protection
radiation = round(radiation/2,1)*/
M.apply_effect((radiation*3),IRRADIATE,0)
M.updatehealth()
//M << "\red You feel odd."
return
move(var/lag)
if(!step(src,dir))
src.loc = get_step(src,dir)
movement_range--
if(movement_range <= 0)
del(src)
else
sleep(lag)
move(lag)
/obj/effect/accelerated_particle/proc/move(var/lag)
if(!step(src,dir))
src.loc = get_step(src,dir)
movement_range--
if(movement_range <= 0)
del(src)
else
sleep(lag)
move(lag)

View File

@@ -71,212 +71,187 @@ So, hopefully this is helpful if any more icons are to be added/changed/wonderin
var/strength = null
var/desc_holder = null
end_cap
name = "Alpha Particle Generation Array"
desc_holder = "This is where Alpha particles are generated from \[REDACTED\]"
icon_state = "end_cap"
reference = "end_cap"
/obj/structure/particle_accelerator/end_cap
name = "Alpha Particle Generation Array"
desc_holder = "This is where Alpha particles are generated from \[REDACTED\]"
icon_state = "end_cap"
reference = "end_cap"
/* update_icon()
switch(construction_state)
if(0)
icon_state="[reference]"
if(1)
icon_state="[reference]"
if(2)
icon_state="[reference]w"
if(3)
if(powered)
switch(strength)
if(0)
icon_state="[reference]p0"
if(1)
icon_state="[reference]p1"
if(2)
icon_state="[reference]p2"
else
icon_state="[reference]p"
else
icon_state="[reference]c"
/obj/structure/particle_accelerator/update_icon()
..()
return
/obj/structure/particle_accelerator/verb/rotate()
set name = "Rotate Clockwise"
set category = "Object"
set src in oview(1)
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 270)
return 1
/obj/structure/particle_accelerator/verb/rotateccw()
set name = "Rotate Counter Clockwise"
set category = "Object"
set src in oview(1)
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 90)
return 1
/obj/structure/particle_accelerator/examine()
switch(src.construction_state)
if(0)
src.desc = text("A [name], looks like it's not attached to the flooring")
if(1)
src.desc = text("A [name], it is missing some cables")
if(2)
src.desc = text("A [name], the panel is open")
if(3)
src.desc = text("The [name] is assembled")
if(powered)
src.desc = src.desc_holder
..()
return
/obj/structure/particle_accelerator/attackby(obj/item/W, mob/user)
if(istool(W))
if(src.process_tool_hit(W,user))
return
*/
..()
return
update_icon()
..()
/obj/structure/particle_accelerator/Move()
..()
if(master && master.active)
master.toggle_power()
investigate_log("was moved whilst active; it <font color='red'>powered down</font>.","singulo")
/obj/structure/particle_accelerator/ex_act(severity)
switch(severity)
if(1.0)
del(src)
return
verb/rotate()
set name = "Rotate Clockwise"
set category = "Object"
set src in oview(1)
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 270)
return 1
verb/rotateccw()
set name = "Rotate Counter Clockwise"
set category = "Object"
set src in oview(1)
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 90)
return 1
examine()
switch(src.construction_state)
if(0)
src.desc = text("A [name], looks like it's not attached to the flooring")
if(1)
src.desc = text("A [name], it is missing some cables")
if(2)
src.desc = text("A [name], the panel is open")
if(3)
src.desc = text("The [name] is assembled")
if(powered)
src.desc = src.desc_holder
..()
return
attackby(obj/item/W, mob/user)
if(istool(W))
if(src.process_tool_hit(W,user))
return
..()
return
Move()
..()
if(master && master.active)
master.toggle_power()
investigate_log("was moved whilst active; it <font color='red'>powered down</font>.","singulo")
ex_act(severity)
switch(severity)
if(1.0)
if(2.0)
if (prob(50))
del(src)
return
if(2.0)
if (prob(50))
del(src)
return
if(3.0)
if (prob(25))
del(src)
return
if(3.0)
if (prob(25))
del(src)
return
else
return
/obj/structure/particle_accelerator/blob_act()
if(prob(50))
del(src)
return
/obj/structure/particle_accelerator/meteorhit()
if(prob(50))
del(src)
return
/obj/structure/particle_accelerator/update_icon()
switch(construction_state)
if(0,1)
icon_state="[reference]"
if(2)
icon_state="[reference]w"
if(3)
if(powered)
icon_state="[reference]p[strength]"
else
return
icon_state="[reference]c"
return
/obj/structure/particle_accelerator/proc/update_state()
if(master)
master.update_state()
return 0
blob_act()
if(prob(50))
del(src)
return
/obj/structure/particle_accelerator/proc/report_ready(var/obj/O)
if(O && (O == master))
if(construction_state >= 3)
return 1
return 0
meteorhit()
if(prob(50))
del(src)
return
update_icon()
switch(construction_state)
if(0,1)
icon_state="[reference]"
if(2)
icon_state="[reference]w"
if(3)
if(powered)
icon_state="[reference]p[strength]"
else
icon_state="[reference]c"
return
proc
update_state()
if(master)
master.update_state()
return 0
/obj/structure/particle_accelerator/proc/report_master()
if(master)
return master
return 0
report_ready(var/obj/O)
if(O && (O == master))
if(construction_state >= 3)
return 1
return 0
/obj/structure/particle_accelerator/proc/connect_master(var/obj/O)
if(O && istype(O,/obj/machinery/particle_accelerator/control_box))
if(O.dir == src.dir)
master = O
return 1
return 0
report_master()
if(master)
return master
return 0
/obj/structure/particle_accelerator/proc/process_tool_hit(var/obj/O, var/mob/user)
if(!(O) || !(user))
return 0
if(!ismob(user) || !isobj(O))
return 0
var/temp_state = src.construction_state
connect_master(var/obj/O)
if(O && istype(O,/obj/machinery/particle_accelerator/control_box))
if(O.dir == src.dir)
master = O
return 1
return 0
process_tool_hit(var/obj/O, var/mob/user)
if(!(O) || !(user))
return 0
if(!ismob(user) || !isobj(O))
return 0
var/temp_state = src.construction_state
switch(src.construction_state)//TODO:Might be more interesting to have it need several parts rather than a single list of steps
if(0)
if(iswrench(O))
playsound(src.loc, 'Ratchet.ogg', 75, 1)
src.anchored = 1
user.visible_message("[user.name] secures the [src.name] to the floor.", \
"You secure the external bolts.")
temp_state++
if(1)
if(iswrench(O))
playsound(src.loc, 'Ratchet.ogg', 75, 1)
src.anchored = 0
user.visible_message("[user.name] detaches the [src.name] from the floor.", \
"You remove the external bolts.")
temp_state--
else if(iscoil(O))
if(O:use(1,user))
user.visible_message("[user.name] adds wires to the [src.name].", \
"You add some wires.")
temp_state++
if(2)
if(iswirecutter(O))//TODO:Shock user if its on?
user.visible_message("[user.name] removes some wires from the [src.name].", \
"You remove some wires.")
temp_state--
else if(isscrewdriver(O))
user.visible_message("[user.name] closes the [src.name]'s access panel.", \
"You close the access panel.")
temp_state++
if(3)
if(isscrewdriver(O))
user.visible_message("[user.name] opens the [src.name]'s access panel.", \
"You open the access panel.")
temp_state--
if(temp_state == src.construction_state)//Nothing changed
return 0
else
src.construction_state = temp_state
if(src.construction_state < 3)//Was taken apart, update state
update_state()
update_icon()
return 1
return 0
switch(src.construction_state)//TODO:Might be more interesting to have it need several parts rather than a single list of steps
if(0)
if(iswrench(O))
playsound(src.loc, 'Ratchet.ogg', 75, 1)
src.anchored = 1
user.visible_message("[user.name] secures the [src.name] to the floor.", \
"You secure the external bolts.")
temp_state++
if(1)
if(iswrench(O))
playsound(src.loc, 'Ratchet.ogg', 75, 1)
src.anchored = 0
user.visible_message("[user.name] detaches the [src.name] from the floor.", \
"You remove the external bolts.")
temp_state--
else if(iscoil(O))
if(O:use(1,user))
user.visible_message("[user.name] adds wires to the [src.name].", \
"You add some wires.")
temp_state++
if(2)
if(iswirecutter(O))//TODO:Shock user if its on?
user.visible_message("[user.name] removes some wires from the [src.name].", \
"You remove some wires.")
temp_state--
else if(isscrewdriver(O))
user.visible_message("[user.name] closes the [src.name]'s access panel.", \
"You close the access panel.")
temp_state++
if(3)
if(isscrewdriver(O))
user.visible_message("[user.name] opens the [src.name]'s access panel.", \
"You open the access panel.")
temp_state--
if(temp_state == src.construction_state)//Nothing changed
return 0
else
src.construction_state = temp_state
if(src.construction_state < 3)//Was taken apart, update state
update_state()
update_icon()
return 1
return 0
@@ -298,138 +273,138 @@ So, hopefully this is helpful if any more icons are to be added/changed/wonderin
var/desc_holder = null
verb/rotate()
set name = "Rotate Clockwise"
set category = "Object"
set src in oview(1)
/obj/machinery/particle_accelerator/verb/rotate()
set name = "Rotate Clockwise"
set category = "Object"
set src in oview(1)
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 270)
return 1
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 270)
return 1
verb/rotateccw()
set name = "Rotate Counter-Clockwise"
set category = "Object"
set src in oview(1)
/obj/machinery/particle_accelerator/verb/rotateccw()
set name = "Rotate Counter-Clockwise"
set category = "Object"
set src in oview(1)
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 90)
return 1
if (src.anchored || usr:stat)
usr << "It is fastened to the floor!"
return 0
src.dir = turn(src.dir, 90)
return 1
update_icon()
return
/obj/machinery/particle_accelerator/update_icon()
return
examine()
switch(src.construction_state)
if(0)
src.desc = text("A [name], looks like it's not attached to the flooring")
if(1)
src.desc = text("A [name], it is missing some cables")
if(2)
src.desc = text("A [name], the panel is open")
if(3)
src.desc = text("The [name] is assembled")
if(powered)
src.desc = src.desc_holder
..()
return
/obj/machinery/particle_accelerator/examine()
switch(src.construction_state)
if(0)
src.desc = text("A [name], looks like it's not attached to the flooring")
if(1)
src.desc = text("A [name], it is missing some cables")
if(2)
src.desc = text("A [name], the panel is open")
if(3)
src.desc = text("The [name] is assembled")
if(powered)
src.desc = src.desc_holder
..()
return
attackby(obj/item/W, mob/user)
if(istool(W))
if(src.process_tool_hit(W,user))
return
..()
return
/obj/machinery/particle_accelerator/attackby(obj/item/W, mob/user)
if(istool(W))
if(src.process_tool_hit(W,user))
return
..()
return
ex_act(severity)
switch(severity)
if(1.0)
/obj/machinery/particle_accelerator/ex_act(severity)
switch(severity)
if(1.0)
del(src)
return
if(2.0)
if (prob(50))
del(src)
return
if(2.0)
if (prob(50))
del(src)
return
if(3.0)
if (prob(25))
del(src)
return
else
return
if(3.0)
if (prob(25))
del(src)
return
else
return
blob_act()
if(prob(50))
del(src)
return
/obj/machinery/particle_accelerator/blob_act()
if(prob(50))
del(src)
return
meteorhit()
if(prob(50))
del(src)
return
proc
update_state()
return 0
/obj/machinery/particle_accelerator/meteorhit()
if(prob(50))
del(src)
return
process_tool_hit(var/obj/O, var/mob/user)
if(!(O) || !(user))
return 0
if(!ismob(user) || !isobj(O))
return 0
var/temp_state = src.construction_state
switch(src.construction_state)//TODO:Might be more interesting to have it need several parts rather than a single list of steps
if(0)
if(iswrench(O))
playsound(src.loc, 'Ratchet.ogg', 75, 1)
src.anchored = 1
user.visible_message("[user.name] secures the [src.name] to the floor.", \
"You secure the external bolts.")
temp_state++
if(1)
if(iswrench(O))
playsound(src.loc, 'Ratchet.ogg', 75, 1)
src.anchored = 0
user.visible_message("[user.name] detaches the [src.name] from the floor.", \
"You remove the external bolts.")
temp_state--
else if(iscoil(O))
if(O:use(1))
user.visible_message("[user.name] adds wires to the [src.name].", \
"You add some wires.")
temp_state++
if(2)
if(iswirecutter(O))//TODO:Shock user if its on?
user.visible_message("[user.name] removes some wires from the [src.name].", \
"You remove some wires.")
temp_state--
else if(isscrewdriver(O))
user.visible_message("[user.name] closes the [src.name]'s access panel.", \
"You close the access panel.")
temp_state++
if(3)
if(isscrewdriver(O))
user.visible_message("[user.name] opens the [src.name]'s access panel.", \
"You open the access panel.")
temp_state--
active = 0
if(temp_state == src.construction_state)//Nothing changed
return 0
else
if(src.construction_state < 3)//Was taken apart, update state
update_state()
if(use_power)
use_power = 0
src.construction_state = temp_state
if(src.construction_state >= 3)
use_power = 1
update_icon()
return 1
return 0
/obj/machinery/particle_accelerator/proc/update_state()
return 0
/obj/machinery/particle_accelerator/proc/process_tool_hit(var/obj/O, var/mob/user)
if(!(O) || !(user))
return 0
if(!ismob(user) || !isobj(O))
return 0
var/temp_state = src.construction_state
switch(src.construction_state)//TODO:Might be more interesting to have it need several parts rather than a single list of steps
if(0)
if(iswrench(O))
playsound(src.loc, 'Ratchet.ogg', 75, 1)
src.anchored = 1
user.visible_message("[user.name] secures the [src.name] to the floor.", \
"You secure the external bolts.")
temp_state++
if(1)
if(iswrench(O))
playsound(src.loc, 'Ratchet.ogg', 75, 1)
src.anchored = 0
user.visible_message("[user.name] detaches the [src.name] from the floor.", \
"You remove the external bolts.")
temp_state--
else if(iscoil(O))
if(O:use(1))
user.visible_message("[user.name] adds wires to the [src.name].", \
"You add some wires.")
temp_state++
if(2)
if(iswirecutter(O))//TODO:Shock user if its on?
user.visible_message("[user.name] removes some wires from the [src.name].", \
"You remove some wires.")
temp_state--
else if(isscrewdriver(O))
user.visible_message("[user.name] closes the [src.name]'s access panel.", \
"You close the access panel.")
temp_state++
if(3)
if(isscrewdriver(O))
user.visible_message("[user.name] opens the [src.name]'s access panel.", \
"You open the access panel.")
temp_state--
active = 0
if(temp_state == src.construction_state)//Nothing changed
return 0
else
if(src.construction_state < 3)//Was taken apart, update state
update_state()
if(use_power)
use_power = 0
src.construction_state = temp_state
if(src.construction_state >= 3)
use_power = 1
update_icon()
return 1
return 0

View File

@@ -5,6 +5,6 @@
icon_state = "fuel_chamber"
reference = "fuel_chamber"
update_icon()
..()
return
/obj/structure/particle_accelerator/fuel_chamber/update_icon()
..()
return

View File

@@ -14,217 +14,215 @@
construction_state = 0
active = 0
dir = 1
var
list/obj/structure/particle_accelerator/connected_parts
var/list/obj/structure/particle_accelerator/connected_parts
var/assembled = 0
var/parts = null
/obj/machinery/particle_accelerator/control_box/New()
connected_parts = list()
..()
/obj/machinery/particle_accelerator/control_box/attack_hand(mob/user as mob)
if(construction_state >= 3)
interact(user)
/obj/machinery/particle_accelerator/control_box/update_state()
if(construction_state < 3)
use_power = 0
assembled = 0
parts = null
New()
active = 0
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = null
part.powered = 0
part.update_icon()
connected_parts = list()
..()
attack_hand(mob/user as mob)
if(construction_state >= 3)
interact(user)
update_state()
if(construction_state < 3)
use_power = 0
assembled = 0
active = 0
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = null
part.powered = 0
part.update_icon()
connected_parts = list()
return
if(!part_scan())
use_power = 1
active = 0
connected_parts = list()
return
if(!part_scan())
use_power = 1
active = 0
connected_parts = list()
update_icon()
if(active)
icon_state = "[reference]p1"
return
/obj/machinery/particle_accelerator/control_box/update_icon()
if(active)
icon_state = "[reference]p1"
else
if(use_power)
if(assembled)
icon_state = "[reference]p"
else
icon_state = "u[reference]p"
else
if(use_power)
if(assembled)
icon_state = "[reference]p"
switch(construction_state)
if(0)
icon_state = "[reference]"
if(1)
icon_state = "[reference]"
if(2)
icon_state = "[reference]w"
else
icon_state = "u[reference]p"
else
switch(construction_state)
if(0)
icon_state = "[reference]"
if(1)
icon_state = "[reference]"
if(2)
icon_state = "[reference]w"
else
icon_state = "[reference]c"
icon_state = "[reference]c"
return
/obj/machinery/particle_accelerator/control_box/Topic(href, href_list)
..()
//Ignore input if we are broken, !silicon guy cant touch us, or nonai controlling from super far away
if(stat & (BROKEN|NOPOWER) || (get_dist(src, usr) > 1 && !istype(usr, /mob/living/silicon)) || (get_dist(src, usr) > 8 && !istype(usr, /mob/living/silicon/ai)))
usr.machine = null
usr << browse(null, "window=pacontrol")
return
Topic(href, href_list)
..()
//Ignore input if we are broken, !silicon guy cant touch us, or nonai controlling from super far away
if(stat & (BROKEN|NOPOWER) || (get_dist(src, usr) > 1 && !istype(usr, /mob/living/silicon)) || (get_dist(src, usr) > 8 && !istype(usr, /mob/living/silicon/ai)))
usr.machine = null
usr << browse(null, "window=pacontrol")
return
if( href_list["close"] )
usr << browse(null, "window=pacontrol")
usr.machine = null
return
if(href_list["togglep"])
src.toggle_power()
investigate_log("turned [active?"<font color='red'>ON</font>":"<font color='green'>OFF</font>"] by [usr.key]","singulo")
else if(href_list["scan"])
src.part_scan()
else if(href_list["strengthup"])
strength++
if(strength > 2)
strength = 2
else
investigate_log("increased to <font color='red'>[strength]</font> by [usr.key]","singulo")
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = strength
part.update_icon()
if( href_list["close"] )
usr << browse(null, "window=pacontrol")
usr.machine = null
return
if(href_list["togglep"])
else if(href_list["strengthdown"])
strength--
if(strength < 0)
strength = 0
else
investigate_log("decreased to <font color='green'>[strength]</font> by [usr.key]","singulo")
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = strength
part.update_icon()
src.updateDialog()
src.update_icon()
return
/obj/machinery/particle_accelerator/control_box/power_change()
..()
if(stat & NOPOWER)
active = 0
use_power = 0
else if(!stat && construction_state == 3)
use_power = 1
return
/obj/machinery/particle_accelerator/control_box/process()
if(src.active)
//a part is missing!
if( length(connected_parts) < 6 )
investigate_log("lost a connected part; It <font color='red'>powered down</font>.","singulo")
src.toggle_power()
investigate_log("turned [active?"<font color='red'>ON</font>":"<font color='green'>OFF</font>"] by [usr.key]","singulo")
else if(href_list["scan"])
src.part_scan()
else if(href_list["strengthup"])
strength++
if(strength > 2)
strength = 2
else
investigate_log("increased to <font color='red'>[strength]</font> by [usr.key]","singulo")
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = strength
part.update_icon()
else if(href_list["strengthdown"])
strength--
if(strength < 0)
strength = 0
else
investigate_log("decreased to <font color='green'>[strength]</font> by [usr.key]","singulo")
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = strength
part.update_icon()
src.updateDialog()
src.update_icon()
return
return
//emit some particles
for(var/obj/structure/particle_accelerator/particle_emitter/PE in connected_parts)
if(PE)
PE.emit_particle(src.strength)
return
power_change()
..()
if(stat & NOPOWER)
active = 0
use_power = 0
else if(!stat && construction_state == 3)
use_power = 1
return
/obj/machinery/particle_accelerator/control_box/proc/part_scan()
for(var/obj/structure/particle_accelerator/fuel_chamber/F in orange(1,src))
src.dir = F.dir
connected_parts = list()
var/tally = 0
var/ldir = turn(dir,-90)
var/rdir = turn(dir,90)
var/odir = turn(dir,180)
var/turf/T = src.loc
T = get_step(T,rdir)
if(check_part(T,/obj/structure/particle_accelerator/fuel_chamber))
tally++
T = get_step(T,odir)
if(check_part(T,/obj/structure/particle_accelerator/end_cap))
tally++
T = get_step(T,dir)
T = get_step(T,dir)
if(check_part(T,/obj/structure/particle_accelerator/power_box))
tally++
T = get_step(T,dir)
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/center))
tally++
T = get_step(T,ldir)
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/left))
tally++
T = get_step(T,rdir)
T = get_step(T,rdir)
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/right))
tally++
if(tally >= 6)
assembled = 1
return 1
else
assembled = 0
return 0
process()
if(src.active)
//a part is missing!
if( length(connected_parts) < 6 )
investigate_log("lost a connected part; It <font color='red'>powered down</font>.","singulo")
src.toggle_power()
return
//emit some particles
for(var/obj/structure/particle_accelerator/particle_emitter/PE in connected_parts)
if(PE)
PE.emit_particle(src.strength)
return
proc
part_scan()
for(var/obj/structure/particle_accelerator/fuel_chamber/F in orange(1,src))
src.dir = F.dir
connected_parts = list()
var/tally = 0
var/ldir = turn(dir,-90)
var/rdir = turn(dir,90)
var/odir = turn(dir,180)
var/turf/T = src.loc
T = get_step(T,rdir)
if(check_part(T,/obj/structure/particle_accelerator/fuel_chamber))
tally++
T = get_step(T,odir)
if(check_part(T,/obj/structure/particle_accelerator/end_cap))
tally++
T = get_step(T,dir)
T = get_step(T,dir)
if(check_part(T,/obj/structure/particle_accelerator/power_box))
tally++
T = get_step(T,dir)
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/center))
tally++
T = get_step(T,ldir)
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/left))
tally++
T = get_step(T,rdir)
T = get_step(T,rdir)
if(check_part(T,/obj/structure/particle_accelerator/particle_emitter/right))
tally++
if(tally >= 6)
assembled = 1
/obj/machinery/particle_accelerator/control_box/proc/check_part(var/turf/T, var/type)
if(!(T)||!(type))
return 0
var/obj/structure/particle_accelerator/PA = locate(/obj/structure/particle_accelerator) in T
if(istype(PA, type))
if(PA.connect_master(src))
if(PA.report_ready(src))
src.connected_parts.Add(PA)
return 1
else
assembled = 0
return 0
return 0
check_part(var/turf/T, var/type)
if(!(T)||!(type))
return 0
var/obj/structure/particle_accelerator/PA = locate(/obj/structure/particle_accelerator) in T
if(istype(PA, type))
if(PA.connect_master(src))
if(PA.report_ready(src))
src.connected_parts.Add(PA)
return 1
return 0
/obj/machinery/particle_accelerator/control_box/proc/toggle_power()
src.active = !src.active
if(src.active)
src.use_power = 2
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = src.strength
part.powered = 1
part.update_icon()
else
src.use_power = 1
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = null
part.powered = 0
part.update_icon()
return 1
toggle_power()
src.active = !src.active
if(src.active)
src.use_power = 2
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = src.strength
part.powered = 1
part.update_icon()
else
src.use_power = 1
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = null
part.powered = 0
part.update_icon()
return 1
/obj/machinery/particle_accelerator/control_box/proc/interact(mob/user)
if((get_dist(src, user) > 1) || (stat & (BROKEN|NOPOWER)))
if(!istype(user, /mob/living/silicon))
user.machine = null
user << browse(null, "window=pacontrol")
return
user.machine = src
var/dat = ""
dat += "Particle Accelerator Control Panel<BR>"
dat += "<A href='?src=\ref[src];close=1'>Close</A><BR><BR>"
dat += "Status:<BR>"
if(!assembled)
dat += "Unable to detect all parts!<BR>"
dat += "<A href='?src=\ref[src];scan=1'>Run Scan</A><BR><BR>"
else
dat += "All parts in place.<BR><BR>"
dat += "Power:"
if(active)
dat += "On<BR>"
else
dat += "Off <BR>"
dat += "<A href='?src=\ref[src];togglep=1'>Toggle Power</A><BR><BR>"
dat += "Particle Strength: [src.strength] "
dat += "<A href='?src=\ref[src];strengthdown=1'>--</A>|<A href='?src=\ref[src];strengthup=1'>++</A><BR><BR>"
interact(mob/user)
if((get_dist(src, user) > 1) || (stat & (BROKEN|NOPOWER)))
if(!istype(user, /mob/living/silicon))
user.machine = null
user << browse(null, "window=pacontrol")
return
user.machine = src
var/dat = ""
dat += "Particle Accelerator Control Panel<BR>"
dat += "<A href='?src=\ref[src];close=1'>Close</A><BR><BR>"
dat += "Status:<BR>"
if(!assembled)
dat += "Unable to detect all parts!<BR>"
dat += "<A href='?src=\ref[src];scan=1'>Run Scan</A><BR><BR>"
else
dat += "All parts in place.<BR><BR>"
dat += "Power:"
if(active)
dat += "On<BR>"
else
dat += "Off <BR>"
dat += "<A href='?src=\ref[src];togglep=1'>Toggle Power</A><BR><BR>"
dat += "Particle Strength: [src.strength] "
dat += "<A href='?src=\ref[src];strengthdown=1'>--</A>|<A href='?src=\ref[src];strengthup=1'>++</A><BR><BR>"
user << browse(dat, "window=pacontrol;size=420x500")
onclose(user, "pacontrol")
return
user << browse(dat, "window=pacontrol;size=420x500")
onclose(user, "pacontrol")
return

View File

@@ -8,43 +8,42 @@
var/fire_delay = 50
var/last_shot = 0
center
icon_state = "emitter_center"
reference = "emitter_center"
/obj/structure/particle_accelerator/particle_emitter/center
icon_state = "emitter_center"
reference = "emitter_center"
left
icon_state = "emitter_left"
reference = "emitter_left"
/obj/structure/particle_accelerator/particle_emitter/left
icon_state = "emitter_left"
reference = "emitter_left"
right
icon_state = "emitter_right"
reference = "emitter_right"
/obj/structure/particle_accelerator/particle_emitter/right
icon_state = "emitter_right"
reference = "emitter_right"
update_icon()
..()
return
/obj/structure/particle_accelerator/particle_emitter/update_icon()
..()
return
proc
set_delay(var/delay)
if(delay && delay >= 0)
src.fire_delay = delay
return 1
return 0
/obj/structure/particle_accelerator/particle_emitter/proc/set_delay(var/delay)
if(delay && delay >= 0)
src.fire_delay = delay
return 1
return 0
emit_particle(var/strength = 0)
if((src.last_shot + src.fire_delay) <= world.time)
src.last_shot = world.time
var/obj/effect/accelerated_particle/A = null
var/turf/T = get_step(src,dir)
switch(strength)
if(0)
A = new/obj/effect/accelerated_particle/weak(T, dir)
if(1)
A = new/obj/effect/accelerated_particle(T, dir)
if(2)
A = new/obj/effect/accelerated_particle/strong(T, dir)
if(A)
A.dir = src.dir
return 1
return 0
/obj/structure/particle_accelerator/particle_emitter/proc/emit_particle(var/strength = 0)
if((src.last_shot + src.fire_delay) <= world.time)
src.last_shot = world.time
var/obj/effect/accelerated_particle/A = null
var/turf/T = get_step(src,dir)
switch(strength)
if(0)
A = new/obj/effect/accelerated_particle/weak(T, dir)
if(1)
A = new/obj/effect/accelerated_particle(T, dir)
if(2)
A = new/obj/effect/accelerated_particle/strong(T, dir)
if(A)
A.dir = src.dir
return 1
return 0

View File

@@ -5,6 +5,6 @@
icon_state = "power_box"
reference = "power_box"
update_icon()
..()
return
/obj/structure/particle_accelerator/power_box/update_icon()
..()
return

View File

@@ -32,507 +32,508 @@ var/global/list/uneatable = list(
var/teleport_del = 0
var/last_warning
New(loc, var/starting_energy = 50, var/temp = 0)
//CARN: admin-alert for chuckle-fuckery.
last_warning = world.time
var/count = 0
for(var/obj/machinery/containment_field/CF in world)
count = 1
/obj/machinery/singularity/New(loc, var/starting_energy = 50, var/temp = 0)
//CARN: admin-alert for chuckle-fuckery.
last_warning = world.time
var/count = 0
for(var/obj/machinery/containment_field/CF in world)
count = 1
break
if(!count) message_admins("A singulo has been created without containment fields active ([x],[y],[z])",1)
investigate_log("was created. [count?"":"<font color='red'>No containment fields were active</font>"]","singulo")
src.energy = starting_energy
if(temp)
spawn(temp)
del(src)
..()
for(var/obj/machinery/singularity_beacon/singubeacon in world)
if(singubeacon.active)
target = singubeacon
break
if(!count) message_admins("A singulo has been created without containment fields active ([x],[y],[z])",1)
investigate_log("was created. [count?"":"<font color='red'>No containment fields were active</font>"]","singulo")
src.energy = starting_energy
if(temp)
spawn(temp)
del(src)
..()
for(var/obj/machinery/singularity_beacon/singubeacon in world)
if(singubeacon.active)
target = singubeacon
break
return
return
Del()
//Could have it do something bad when this happens, explode/implode or something
..()
/obj/machinery/singularity/Del()
//Could have it do something bad when this happens, explode/implode or something
..()
attack_hand(mob/user as mob)
consume(user)
return 1
/obj/machinery/singularity/attack_hand(mob/user as mob)
consume(user)
return 1
blob_act(severity)
return
/obj/machinery/singularity/blob_act(severity)
return
ex_act(severity)
switch(severity)
if(1.0)
if(prob(25))
del(src)
return
else
energy += 50
if(2.0 to 3.0)
energy += round((rand(20,60)/2),1)
return
return
Bump(atom/A)
consume(A)
return
Bumped(atom/A)
consume(A)
return
process()
eat()
dissipate()
check_energy()
if(current_size >= 3)
move()
if(current_size <= 7)
pulse()
if(current_size >= 5)
if(prob(event_chance))//Chance for it to run a special event TODO:Come up with one or two more that fit
event()
return
attack_ai() //to prevent ais from gibbing themselves when they click on one.
return
proc
dissipate()
if(!dissipate)
return
if(dissipate_track >= dissipate_delay)
src.energy -= dissipate_strength
dissipate_track = 0
else
dissipate_track++
expand(var/force_size = 0)
var/temp_allowed_size = src.allowed_size
if(force_size)
temp_allowed_size = force_size
switch(temp_allowed_size)
if(1)
current_size = 1
icon = 'icons/obj/singularity.dmi'
icon_state = "singularity_s1"
pixel_x = 0
pixel_y = 0
grav_pull = 4
consume_range = 0
dissipate_delay = 10
dissipate_track = 0
dissipate_strength = 1
if(3)//1 to 3 does not check for the turfs if you put the gens right next to a 1x1 then its going to eat them
current_size = 3
icon = 'icons/effects/96x96.dmi'
icon_state = "singularity_s3"
pixel_x = -32
pixel_y = -32
grav_pull = 6
consume_range = 1
dissipate_delay = 5
dissipate_track = 0
dissipate_strength = 5
if(5)
if((check_turfs_in(1,2))&&(check_turfs_in(2,2))&&(check_turfs_in(4,2))&&(check_turfs_in(8,2)))
current_size = 5
icon = 'icons/effects/160x160.dmi'
icon_state = "singularity_s5"
pixel_x = -64
pixel_y = -64
grav_pull = 8
consume_range = 2
dissipate_delay = 4
dissipate_track = 0
dissipate_strength = 20
if(7)
if((check_turfs_in(1,3))&&(check_turfs_in(2,3))&&(check_turfs_in(4,3))&&(check_turfs_in(8,3)))
current_size = 7
icon = 'icons/effects/224x224.dmi'
icon_state = "singularity_s7"
pixel_x = -96
pixel_y = -96
grav_pull = 10
consume_range = 3
dissipate_delay = 10
dissipate_track = 0
dissipate_strength = 10
if(9)//this one also lacks a check for gens because it eats everything
current_size = 9
icon = 'icons/effects/288x288.dmi'
icon_state = "singularity_s9"
pixel_x = -128
pixel_y = -128
grav_pull = 10
consume_range = 4
dissipate = 0 //It cant go smaller due to e loss
if(current_size == allowed_size)
investigate_log("<font color='red'>grew to size [current_size]</font>","singulo")
return 1
else if(current_size < (--temp_allowed_size))
expand(temp_allowed_size)
else
return 0
check_energy()
if(energy <= 0)
del(src)
return 0
switch(energy)//Some of these numbers might need to be changed up later -Mport
if(1 to 199)
allowed_size = 1
if(200 to 499)
allowed_size = 3
if(500 to 999)
allowed_size = 5
if(1000 to 1999)
allowed_size = 7
if(2000 to INFINITY)
allowed_size = 9
if(current_size != allowed_size)
expand()
return 1
eat()
set background = 1
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 1
for(var/atom/movable/X in orange(consume_range,src))
consume(X)
for(var/turf/X in orange(consume_range,src))
consume(X)
for(var/atom/movable/X in orange(grav_pull,src))
if(is_type_in_list(X, uneatable)) continue
if(((X) &&(!X:anchored) && (!istype(X,/mob/living/carbon/human)))|| (src.current_size >= 9))
step_towards(X,src)
else if(istype(X,/mob/living/carbon/human))
var/mob/living/carbon/human/H = X
if(istype(H.shoes,/obj/item/clothing/shoes/magboots))
var/obj/item/clothing/shoes/magboots/M = H.shoes
if(M.magpulse)
continue
step_towards(H,src)
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 0
return
consume(var/atom/A)
var/gain = 0
if(is_type_in_list(A, uneatable))
return 0
if (istype(A,/mob/living))//Mobs get gibbed
gain = 20
if(istype(A,/mob/living/carbon/human))
if(A:mind)
if((A:mind:assigned_role == "Station Engineer") || (A:mind:assigned_role == "Chief Engineer") )
gain = 100
spawn()
A:gib()
sleep(1)
else if(istype(A,/obj/))
if (istype(A,/obj/item/weapon/storage/backpack/holding))
var/dist = max((current_size - 2),1)
explosion(src.loc,(dist),(dist*2),(dist*4))
return
if(istype(A, /obj/machinery/singularity))//Welp now you did it
var/obj/machinery/singularity/S = A
src.energy += (S.energy/2)//Absorb most of it
del(S)
var/dist = max((current_size - 2),1)
explosion(src.loc,(dist),(dist*2),(dist*4))
return//Quits here, the obj should be gone, hell we might be
if((teleport_del) && (!istype(A, /obj/machinery)))//Going to see if it does not lag less to tele items over to Z 2
var/obj/O = A
O.x = 2
O.y = 2
O.z = 2
else
A:ex_act(1.0)
if(A) del(A)
gain = 2
else if(isturf(A))
var/turf/T = A
if(T.intact)
for(var/obj/O in T.contents)
if(O.level != 1)
continue
if(O.invisibility == 101)
src.consume(O)
A:ReplaceWithSpace()
gain = 2
src.energy += gain
return
move(var/movement_dir = 0)
if(!move_self)
return 0
if(target && prob(60))
movement_dir = get_dir(src,target) //moves to a singulo beacon, if there is one
else if(!(movement_dir in cardinal))
movement_dir = pick(NORTH, SOUTH, EAST, WEST)
if(movement_dir == last_failed_movement)
var/list/L = new/list(NORTH, SOUTH, EAST, WEST)
L.Remove(last_failed_movement)
movement_dir = pick(L)
if(current_size >= 9)//The superlarge one does not care about things in its way
spawn(0)
step(src, movement_dir)
spawn(1)
step(src, movement_dir)
return 1
else if(check_turfs_in(movement_dir))
last_failed_movement = 0//Reset this because we moved
spawn(0)
step(src, movement_dir)
return 1
else
last_failed_movement = movement_dir
return 0
check_turfs_in(var/direction = 0, var/step = 0)
if(!direction)
return 0
var/steps = 0
if(!step)
switch(current_size)
if(1)
steps = 1
if(3)
steps = 3//Yes this is right
if(5)
steps = 3
if(7)
steps = 4
if(9)
steps = 5
else
steps = step
var/list/turfs = list()
var/turf/T = src.loc
for(var/i = 1 to steps)
T = get_step(T,direction)
if(!isturf(T))
return 0
turfs.Add(T)
var/dir2 = 0
var/dir3 = 0
switch(direction)
if(NORTH||SOUTH)
dir2 = 4
dir3 = 8
if(EAST||WEST)
dir2 = 1
dir3 = 2
var/turf/T2 = T
for(var/j = 1 to steps)
T2 = get_step(T2,dir2)
if(!isturf(T2))
return 0
turfs.Add(T2)
for(var/k = 1 to steps)
T = get_step(T,dir3)
if(!isturf(T))
return 0
turfs.Add(T)
for(var/turf/T3 in turfs)
if(isnull(T3))
continue
if(!can_move(T3))
return 0
return 1
can_move(var/turf/T)
if(!T)
return 0
if((locate(/obj/machinery/containment_field) in T)||(locate(/obj/machinery/shieldwall) in T))
return 0
else if(locate(/obj/machinery/field_generator) in T)
var/obj/machinery/field_generator/G = locate(/obj/machinery/field_generator) in T
if(G && G.active)
return 0
else if(locate(/obj/machinery/shieldwallgen) in T)
var/obj/machinery/shieldwallgen/S = locate(/obj/machinery/shieldwallgen) in T
if(S && S.active)
return 0
return 1
event()
var/numb = pick(1,2,3,4,5,6)
switch(numb)
if(1)//EMP
emp_area()
if(2,3)//tox damage all carbon mobs in area
toxmob()
if(4)//Stun mobs who lack optic scanners
mezzer()
else
return 0
return 1
toxmob()
var/toxrange = 10
var/toxdamage = 4
var/radiation = 15
var/radiationmin = 3
if (src.energy>200)
toxdamage = round(((src.energy-150)/50)*4,1)
radiation = round(((src.energy-150)/50)*5,1)
radiationmin = round((radiation/5),1)//
for(var/mob/living/M in view(toxrange, src.loc))
if(istype(M,/mob/living/))
M.apply_effect(rand(radiationmin,radiation), IRRADIATE)
toxdamage = (toxdamage - (toxdamage*M.getarmor(null, "rad")))
M.apply_effect(toxdamage, TOX)
return
mezzer()
for(var/mob/living/carbon/M in oviewers(8, src))
if(istype(M,/mob/living/carbon/human))
if(istype(M:glasses,/obj/item/clothing/glasses/meson))
M << "\blue You look directly into The [src.name], good thing you had your protective eyewear on!"
return
M << "\red You look directly into The [src.name] and feel weak."
M.apply_effect(3, STUN)
for(var/mob/O in viewers(M, null))
O.show_message(text("\red <B>[] stares blankly at The []!</B>", M, src), 1)
return
emp_area()
empulse(src, 8, 10)
return
pulse()
for(var/obj/machinery/power/rad_collector/R in orange(15,src))
if(istype(R,/obj/machinery/power/rad_collector))
R.receive_pulse(energy)
return
narsie //Moving narsie to a child object of the singularity so it can be made to function differently. --NEO
name = "Tear in the Fabric of Reality"
desc = "Your mind begins to bubble and ooze as it tries to comprehend what it sees."
icon = 'icons/obj/magic_terror.dmi'
pixel_x = -89
pixel_y = -85
current_size = 9 //It moves/eats like a max-size singulo, aside from range. --NEO
contained = 0 //Are we going to move around?
dissipate = 0 //Do we lose energy over time?
move_self = 1 //Do we move on our own?
grav_pull = 10 //How many tiles out do we pull?
consume_range = 3 //How many tiles out do we eat
process()
eat()
if(!target || prob(5))
pickcultist()
move()
/obj/machinery/singularity/ex_act(severity)
switch(severity)
if(1.0)
if(prob(25))
mezzer()
consume(var/atom/A) //Has its own consume proc because it doesn't need energy and I don't want BoHs to explode it. --NEO
if(is_type_in_list(A, uneatable))
return 0
if (istype(A,/mob/living))//Mobs get gibbed
A:gib()
else if(istype(A,/obj/))
A:ex_act(1.0)
if(A) del(A)
else if(isturf(A))
var/turf/T = A
if(T.intact)
for(var/obj/O in T.contents)
if(O.level != 1)
continue
if(O.invisibility == 101)
src.consume(O)
A:ReplaceWithSpace()
return
ex_act() //No throwing bombs at it either. --NEO
return
proc/pickcultist() //Narsie rewards his cultists with being devoured first, then picks a ghost to follow. --NEO
var/list/cultists = list()
for(var/datum/mind/cult_nh_mind in ticker.mode.cult)
if(!cult_nh_mind.current)
continue
if(cult_nh_mind.current.stat)
continue
cultists += cult_nh_mind.current
if(cultists.len)
acquire(pick(cultists))
del(src)
return
//If there was living cultists, it picks one to follow.
for(var/mob/living/carbon/human/food in living_mob_list)
if(food.stat)
continue
cultists += food
if(cultists.len)
acquire(pick(cultists))
return
//no living cultists, pick a living human instead.
for(var/mob/dead/observer/ghost in player_list)
if(!ghost.client)
continue
cultists += ghost
if(cultists.len)
acquire(pick(cultists))
return
//no living humans, follow a ghost instead.
proc/acquire(var/mob/food)
target << "\blue <b>NAR-SIE HAS LOST INTEREST IN YOU</b>"
target = food
if(ishuman(target))
target << "\red <b>NAR-SIE HUNGERS FOR YOUR SOUL</b>"
else
target << "\red <b>NAR-SIE HAS CHOSEN YOU TO LEAD HIM TO HIS NEXT MEAL</b>"
energy += 50
if(2.0 to 3.0)
energy += round((rand(20,60)/2),1)
return
return
/obj/machinery/singularity/Bump(atom/A)
consume(A)
return
/obj/machinery/singularity/Bumped(atom/A)
consume(A)
return
/obj/machinery/singularity/process()
eat()
dissipate()
check_energy()
if(current_size >= 3)
move()
if(current_size <= 7)
pulse()
if(current_size >= 5)
if(prob(event_chance))//Chance for it to run a special event TODO:Come up with one or two more that fit
event()
return
/obj/machinery/singularity/attack_ai() //to prevent ais from gibbing themselves when they click on one.
return
/obj/machinery/singularity/proc/dissipate()
if(!dissipate)
return
if(dissipate_track >= dissipate_delay)
src.energy -= dissipate_strength
dissipate_track = 0
else
dissipate_track++
/obj/machinery/singularity/proc/expand(var/force_size = 0)
var/temp_allowed_size = src.allowed_size
if(force_size)
temp_allowed_size = force_size
switch(temp_allowed_size)
if(1)
current_size = 1
icon = 'icons/obj/singularity.dmi'
icon_state = "singularity_s1"
pixel_x = 0
pixel_y = 0
grav_pull = 4
consume_range = 0
dissipate_delay = 10
dissipate_track = 0
dissipate_strength = 1
if(3)//1 to 3 does not check for the turfs if you put the gens right next to a 1x1 then its going to eat them
current_size = 3
icon = 'icons/effects/96x96.dmi'
icon_state = "singularity_s3"
pixel_x = -32
pixel_y = -32
grav_pull = 6
consume_range = 1
dissipate_delay = 5
dissipate_track = 0
dissipate_strength = 5
if(5)
if((check_turfs_in(1,2))&&(check_turfs_in(2,2))&&(check_turfs_in(4,2))&&(check_turfs_in(8,2)))
current_size = 5
icon = 'icons/effects/160x160.dmi'
icon_state = "singularity_s5"
pixel_x = -64
pixel_y = -64
grav_pull = 8
consume_range = 2
dissipate_delay = 4
dissipate_track = 0
dissipate_strength = 20
if(7)
if((check_turfs_in(1,3))&&(check_turfs_in(2,3))&&(check_turfs_in(4,3))&&(check_turfs_in(8,3)))
current_size = 7
icon = 'icons/effects/224x224.dmi'
icon_state = "singularity_s7"
pixel_x = -96
pixel_y = -96
grav_pull = 10
consume_range = 3
dissipate_delay = 10
dissipate_track = 0
dissipate_strength = 10
if(9)//this one also lacks a check for gens because it eats everything
current_size = 9
icon = 'icons/effects/288x288.dmi'
icon_state = "singularity_s9"
pixel_x = -128
pixel_y = -128
grav_pull = 10
consume_range = 4
dissipate = 0 //It cant go smaller due to e loss
if(current_size == allowed_size)
investigate_log("<font color='red'>grew to size [current_size]</font>","singulo")
return 1
else if(current_size < (--temp_allowed_size))
expand(temp_allowed_size)
else
return 0
/obj/machinery/singularity/proc/check_energy()
if(energy <= 0)
del(src)
return 0
switch(energy)//Some of these numbers might need to be changed up later -Mport
if(1 to 199)
allowed_size = 1
if(200 to 499)
allowed_size = 3
if(500 to 999)
allowed_size = 5
if(1000 to 1999)
allowed_size = 7
if(2000 to INFINITY)
allowed_size = 9
if(current_size != allowed_size)
expand()
return 1
/obj/machinery/singularity/proc/eat()
set background = 1
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 1
for(var/atom/movable/X in orange(consume_range,src))
consume(X)
for(var/turf/X in orange(consume_range,src))
consume(X)
for(var/atom/movable/X in orange(grav_pull,src))
if(is_type_in_list(X, uneatable)) continue
if(((X) &&(!X:anchored) && (!istype(X,/mob/living/carbon/human)))|| (src.current_size >= 9))
step_towards(X,src)
else if(istype(X,/mob/living/carbon/human))
var/mob/living/carbon/human/H = X
if(istype(H.shoes,/obj/item/clothing/shoes/magboots))
var/obj/item/clothing/shoes/magboots/M = H.shoes
if(M.magpulse)
continue
step_towards(H,src)
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 0
return
/obj/machinery/singularity/proc/consume(var/atom/A)
var/gain = 0
if(is_type_in_list(A, uneatable))
return 0
if (istype(A,/mob/living))//Mobs get gibbed
gain = 20
if(istype(A,/mob/living/carbon/human))
if(A:mind)
if((A:mind:assigned_role == "Station Engineer") || (A:mind:assigned_role == "Chief Engineer") )
gain = 100
spawn()
A:gib()
sleep(1)
else if(istype(A,/obj/))
if (istype(A,/obj/item/weapon/storage/backpack/holding))
var/dist = max((current_size - 2),1)
explosion(src.loc,(dist),(dist*2),(dist*4))
return
if(istype(A, /obj/machinery/singularity))//Welp now you did it
var/obj/machinery/singularity/S = A
src.energy += (S.energy/2)//Absorb most of it
del(S)
var/dist = max((current_size - 2),1)
explosion(src.loc,(dist),(dist*2),(dist*4))
return//Quits here, the obj should be gone, hell we might be
if((teleport_del) && (!istype(A, /obj/machinery)))//Going to see if it does not lag less to tele items over to Z 2
var/obj/O = A
O.x = 2
O.y = 2
O.z = 2
else
A:ex_act(1.0)
if(A) del(A)
gain = 2
else if(isturf(A))
var/turf/T = A
if(T.intact)
for(var/obj/O in T.contents)
if(O.level != 1)
continue
if(O.invisibility == 101)
src.consume(O)
A:ReplaceWithSpace()
gain = 2
src.energy += gain
return
/obj/machinery/singularity/proc/move(var/movement_dir = 0)
if(!move_self)
return 0
if(target && prob(60))
movement_dir = get_dir(src,target) //moves to a singulo beacon, if there is one
else if(!(movement_dir in cardinal))
movement_dir = pick(NORTH, SOUTH, EAST, WEST)
if(movement_dir == last_failed_movement)
var/list/L = new/list(NORTH, SOUTH, EAST, WEST)
L.Remove(last_failed_movement)
movement_dir = pick(L)
if(current_size >= 9)//The superlarge one does not care about things in its way
spawn(0)
step(src, movement_dir)
spawn(1)
step(src, movement_dir)
return 1
else if(check_turfs_in(movement_dir))
last_failed_movement = 0//Reset this because we moved
spawn(0)
step(src, movement_dir)
return 1
else
last_failed_movement = movement_dir
return 0
/obj/machinery/singularity/proc/check_turfs_in(var/direction = 0, var/step = 0)
if(!direction)
return 0
var/steps = 0
if(!step)
switch(current_size)
if(1)
steps = 1
if(3)
steps = 3//Yes this is right
if(5)
steps = 3
if(7)
steps = 4
if(9)
steps = 5
else
steps = step
var/list/turfs = list()
var/turf/T = src.loc
for(var/i = 1 to steps)
T = get_step(T,direction)
if(!isturf(T))
return 0
turfs.Add(T)
var/dir2 = 0
var/dir3 = 0
switch(direction)
if(NORTH||SOUTH)
dir2 = 4
dir3 = 8
if(EAST||WEST)
dir2 = 1
dir3 = 2
var/turf/T2 = T
for(var/j = 1 to steps)
T2 = get_step(T2,dir2)
if(!isturf(T2))
return 0
turfs.Add(T2)
for(var/k = 1 to steps)
T = get_step(T,dir3)
if(!isturf(T))
return 0
turfs.Add(T)
for(var/turf/T3 in turfs)
if(isnull(T3))
continue
if(!can_move(T3))
return 0
return 1
/obj/machinery/singularity/proc/can_move(var/turf/T)
if(!T)
return 0
if((locate(/obj/machinery/containment_field) in T)||(locate(/obj/machinery/shieldwall) in T))
return 0
else if(locate(/obj/machinery/field_generator) in T)
var/obj/machinery/field_generator/G = locate(/obj/machinery/field_generator) in T
if(G && G.active)
return 0
else if(locate(/obj/machinery/shieldwallgen) in T)
var/obj/machinery/shieldwallgen/S = locate(/obj/machinery/shieldwallgen) in T
if(S && S.active)
return 0
return 1
/obj/machinery/singularity/proc/event()
var/numb = pick(1,2,3,4,5,6)
switch(numb)
if(1)//EMP
emp_area()
if(2,3)//tox damage all carbon mobs in area
toxmob()
if(4)//Stun mobs who lack optic scanners
mezzer()
else
return 0
return 1
/obj/machinery/singularity/proc/toxmob()
var/toxrange = 10
var/toxdamage = 4
var/radiation = 15
var/radiationmin = 3
if (src.energy>200)
toxdamage = round(((src.energy-150)/50)*4,1)
radiation = round(((src.energy-150)/50)*5,1)
radiationmin = round((radiation/5),1)//
for(var/mob/living/M in view(toxrange, src.loc))
if(istype(M,/mob/living/))
M.apply_effect(rand(radiationmin,radiation), IRRADIATE)
toxdamage = (toxdamage - (toxdamage*M.getarmor(null, "rad")))
M.apply_effect(toxdamage, TOX)
return
/obj/machinery/singularity/proc/mezzer()
for(var/mob/living/carbon/M in oviewers(8, src))
if(istype(M,/mob/living/carbon/human))
if(istype(M:glasses,/obj/item/clothing/glasses/meson))
M << "\blue You look directly into The [src.name], good thing you had your protective eyewear on!"
return
M << "\red You look directly into The [src.name] and feel weak."
M.apply_effect(3, STUN)
for(var/mob/O in viewers(M, null))
O.show_message(text("\red <B>[] stares blankly at The []!</B>", M, src), 1)
return
/obj/machinery/singularity/proc/emp_area()
empulse(src, 8, 10)
return
/obj/machinery/singularity/proc/pulse()
for(var/obj/machinery/power/rad_collector/R in orange(15,src))
if(istype(R,/obj/machinery/power/rad_collector))
R.receive_pulse(energy)
return
/obj/machinery/singularity/narsie //Moving narsie to a child object of the singularity so it can be made to function differently. --NEO
name = "Tear in the Fabric of Reality"
desc = "Your mind begins to bubble and ooze as it tries to comprehend what it sees."
icon = 'icons/obj/magic_terror.dmi'
pixel_x = -89
pixel_y = -85
current_size = 9 //It moves/eats like a max-size singulo, aside from range. --NEO
contained = 0 //Are we going to move around?
dissipate = 0 //Do we lose energy over time?
move_self = 1 //Do we move on our own?
grav_pull = 10 //How many tiles out do we pull?
consume_range = 3 //How many tiles out do we eat
/obj/machinery/singularity/narsie/process()
eat()
if(!target || prob(5))
pickcultist()
move()
if(prob(25))
mezzer()
/obj/machinery/singularity/narsie/consume(var/atom/A) //Has its own consume proc because it doesn't need energy and I don't want BoHs to explode it. --NEO
if(is_type_in_list(A, uneatable))
return 0
if (istype(A,/mob/living))//Mobs get gibbed
A:gib()
else if(istype(A,/obj/))
A:ex_act(1.0)
if(A) del(A)
else if(isturf(A))
var/turf/T = A
if(T.intact)
for(var/obj/O in T.contents)
if(O.level != 1)
continue
if(O.invisibility == 101)
src.consume(O)
A:ReplaceWithSpace()
return
/obj/machinery/singularity/narsie/ex_act() //No throwing bombs at it either. --NEO
return
/obj/machinery/singularity/narsie/proc/pickcultist() //Narsie rewards his cultists with being devoured first, then picks a ghost to follow. --NEO
var/list/cultists = list()
for(var/datum/mind/cult_nh_mind in ticker.mode.cult)
if(!cult_nh_mind.current)
continue
if(cult_nh_mind.current.stat)
continue
cultists += cult_nh_mind.current
if(cultists.len)
acquire(pick(cultists))
return
//If there was living cultists, it picks one to follow.
for(var/mob/living/carbon/human/food in living_mob_list)
if(food.stat)
continue
cultists += food
if(cultists.len)
acquire(pick(cultists))
return
//no living cultists, pick a living human instead.
for(var/mob/dead/observer/ghost in player_list)
if(!ghost.client)
continue
cultists += ghost
if(cultists.len)
acquire(pick(cultists))
return
//no living humans, follow a ghost instead.
/obj/machinery/singularity/narsie/proc/acquire(var/mob/food)
target << "\blue <b>NAR-SIE HAS LOST INTEREST IN YOU</b>"
target = food
if(ishuman(target))
target << "\red <b>NAR-SIE HUNGERS FOR YOUR SOUL</b>"
else
target << "\red <b>NAR-SIE HAS CHOSEN YOU TO LEAD HIM TO HIS NEXT MEAL</b>"
//Wizard narsie
/obj/machinery/singularity/narsie/wizard
grav_pull = 0
eat()
set background = 1
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 1
for(var/atom/movable/X in orange(consume_range,src))
consume(X)
for(var/turf/X in orange(consume_range,src))
consume(X)
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 0
return
/obj/machinery/singularity/narsie/wizard/eat()
set background = 1
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 1
for(var/atom/movable/X in orange(consume_range,src))
consume(X)
for(var/turf/X in orange(consume_range,src))
consume(X)
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 0
return