Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[READY]Circuit balance #35931

Merged
merged 12 commits into from
Mar 2, 2018
5 changes: 3 additions & 2 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ Turf and target are separate in case you want to teleport some distance from a t
Gets all contents of contents and returns them all in a list.
*/

/atom/proc/GetAllContents()
/atom/proc/GetAllContents(var/T)
var/list/processing_list = list(src)
var/list/assembled = list()
while(processing_list.len)
Expand All @@ -527,7 +527,8 @@ Turf and target are separate in case you want to teleport some distance from a t
//Byond does not allow things to be in multiple contents, or double parent-child hierarchies, so only += is needed
//This is also why we don't need to check against assembled as we go along
processing_list += A.contents
assembled += A
if(!T || istype(A,T))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fairly performance-sensitive proc so I recommend making a different version like GetAllContentsOfType or something, alternatively put your if before the while and have a different loop based on whether you're looking for specific types only or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

assembled += A
return assembled

/atom/proc/GetAllContentsIgnoring(list/ignore_typecache)
Expand Down
6 changes: 6 additions & 0 deletions code/modules/integrated_electronics/core/assemblies.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

/obj/item/device/electronic_assembly
name = "electronic assembly"
obj_flags = CAN_BE_HIT
desc = "It's a case, for building small electronics with."
w_class = WEIGHT_CLASS_SMALL
icon = 'icons/obj/assemblies/electronic_setups.dmi'
Expand All @@ -20,6 +21,8 @@
var/charge_tick = FALSE
var/charge_delay = 4
var/use_cyborg_cell = TRUE
var/ext_next_use = 0
var/atom/movable/collw
var/allowed_circuit_action_flags = IC_ACTION_COMBAT | IC_ACTION_LONG_RANGE //which circuit flags are allowed
var/combat_circuits = 0 //number of combat cicuits in the assembly, used for diagnostic hud
var/long_range_circuits = 0 //number of long range cicuits in the assembly, used for diagnostic hud
Expand All @@ -31,6 +34,9 @@
/obj/item/device/electronic_assembly/proc/check_interactivity(mob/user)
return user.canUseTopic(src, BE_CLOSE)

/obj/item/device/electronic_assembly/CollidedWith(atom/movable/AM)
collw = AM
..()

/obj/item/device/electronic_assembly/Initialize()
.=..()
Expand Down
10 changes: 9 additions & 1 deletion code/modules/integrated_electronics/core/integrated_circuit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
var/next_use = 0 // Uses world.time
var/complexity = 1 // This acts as a limitation on building machines, more resource-intensive components cost more 'space'.
var/size = 1 // This acts as a limitation on building machines, bigger components cost more 'space'. -1 for size 0
var/cooldown_per_use = 9 // Circuits are limited in how many times they can be work()'d by this variable.
var/cooldown_per_use = 1 // Circuits are limited in how many times they can be work()'d by this variable.
var/ext_cooldown = 0 // Circuits are limited in how many times they can be work()'d with external world by this variable.
var/power_draw_per_use = 0 // How much power is drawn when work()'d.
var/power_draw_idle = 0 // How much power is drawn when doing nothing.
var/spawn_flags // Used for world initializing, see the #defines above.
Expand Down Expand Up @@ -212,6 +213,9 @@ a creative player the means to solve many problems. Circuits are held inside an
HTML += "</div>"

HTML += "<br><font color='0000AA'>Complexity: [complexity]</font>"
HTML += "<br><font color='0000AA'>Cooldown per use: [cooldown_per_use/10] sec</font>"
if(ext_cooldown)
HTML += "<br><font color='0000AA'>External manipulation cooldown: [ext_cooldown/10] sec</font>"
if(power_draw_idle)
HTML += "<br><font color='0000AA'>Power Draw: [power_draw_idle] W (Idle)</font>"
if(power_draw_per_use)
Expand Down Expand Up @@ -301,11 +305,15 @@ a creative player the means to solve many problems. Circuits are held inside an
/obj/item/integrated_circuit/proc/check_then_do_work(ord,var/ignore_power = FALSE)
if(world.time < next_use) // All intergrated circuits have an internal cooldown, to protect from spam.
return FALSE
if(assembly && ext_cooldown && (world.time < assembly.ext_next_use)) // Some circuits have external cooldown, to protect from spam.
return FALSE
if(power_draw_per_use && !ignore_power)
if(!check_power())
power_fail()
return FALSE
next_use = world.time + cooldown_per_use
if(assembly)
assembly.ext_next_use = world.time + ext_cooldown
do_work(ord)
return TRUE

Expand Down
4 changes: 2 additions & 2 deletions code/modules/integrated_electronics/core/printer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
/obj/item/device/integrated_circuit_printer/debug //translation: "integrated_circuit_printer/local_server"
name = "debug circuit printer"
debug = TRUE
upgraded = TRUE
can_clone = TRUE
w_class = WEIGHT_CLASS_TINY

/obj/item/device/integrated_circuit_printer/Initialize()
Expand Down Expand Up @@ -56,7 +58,6 @@
return TRUE
to_chat(user, "<span class='notice'>You install [O] into [src]. </span>")
upgraded = TRUE
qdel(O)
interact(user)
return TRUE

Expand All @@ -66,7 +67,6 @@
return TRUE
to_chat(user, "<span class='notice'>You install [O] into [src]. Circuit cloning will now be instant. </span>")
fast_clone = TRUE
qdel(O)
interact(user)
return TRUE

Expand Down
23 changes: 21 additions & 2 deletions code/modules/integrated_electronics/passive/power.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,19 @@
activators = list()
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
var/volume = 60
var/list/fuel = list("plasma" = 10000, "welding_fuel" = 3000, "carbon" = 2000, "ethanol" = 2000, "nutriment" = 1600, "blood" = 1000)
var/list/fuel = list("plasma" = 50000, "welding_fuel" = 15000, "carbon" = 10000, "ethanol" = 10000, "nutriment" = 8000)
var/multi = 1
var/lfwb

/obj/item/integrated_circuit/passive/power/chemical_cell/New()
..()
create_reagents(volume)
var/p = text2path("/datum/config_entry/flag/disable_human_mood")
Copy link
Member

@AnturK AnturK Feb 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you trying to do here ? Why is this path a string and why are you not using the common config helpers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because there is no such flag in game yet.So it is error safe version of flag check.

if(p)
if(!global.config.Get(p))
lfwb = TRUE
extended_desc +="But no fuel can be compared with blood of living human."


/obj/item/integrated_circuit/passive/power/chemical_cell/interact(mob/user)
set_pin_data(IC_OUTPUT, 2, WEAKREF(src))
Expand All @@ -115,7 +123,18 @@
/obj/item/integrated_circuit/passive/power/chemical_cell/make_energy()
if(assembly)
if(assembly.battery)
var/bp = 5000
if(reagents.get_reagent_amount("blood")) //only blood is powerful enough to power the station(c)
var/datum/reagent/blood/B = locate() in reagents.reagent_list
if(lfwb)
if(B && B.data["cloneable"])
var/mob/M = B.data["donor"]
if(M && M.stat != DEAD && M.client)
bp = 500000
if((assembly.battery.maxcharge-assembly.battery.charge) / GLOB.CELLRATE > bp)
if(reagents.remove_reagent("blood", 1))
assembly.give_power(bp)
for(var/I in fuel)
if((assembly.battery.maxcharge-assembly.battery.charge) / GLOB.CELLRATE > fuel[I])
if(reagents.remove_reagent(I, 1))
assembly.give_power(fuel[I])
assembly.give_power(fuel[I]*multi)
8 changes: 4 additions & 4 deletions code/modules/integrated_electronics/subtypes/input.dm
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
power_draw_per_use = 30
var/radius = 1
cooldown_per_use = 10

/obj/item/integrated_circuit/input/advanced_locator_list/on_data_written()
var/rad = get_pin_data(IC_INPUT, 2)
Expand Down Expand Up @@ -526,7 +527,7 @@
action_flags = IC_ACTION_LONG_RANGE
power_draw_idle = 5
power_draw_per_use = 40

cooldown_per_use = 5
var/frequency = FREQ_SIGNALER
var/code = DEFAULT_SIGNALER_CODE
var/datum/radio_frequency/radio_connection
Expand Down Expand Up @@ -583,9 +584,7 @@
return 0

activate_pin(3)

for(var/mob/O in hearers(1, get_turf(src)))
audible_message("[icon2html(src, hearers(src))] *beep* *beep*", null, 1)
audible_message("[icon2html(src, hearers(src))] *beep* *beep*", null, 1)

/obj/item/integrated_circuit/input/ntnet_packet
name = "NTNet networking circuit"
Expand All @@ -596,6 +595,7 @@
can be send to multiple recepients. Addresses must be separated with ; symbol."
icon_state = "signal"
complexity = 4
cooldown_per_use = 5
inputs = list(
"target NTNet addresses"= IC_PINTYPE_STRING,
"data to send" = IC_PINTYPE_STRING,
Expand Down
8 changes: 7 additions & 1 deletion code/modules/integrated_electronics/subtypes/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
)
category_text = "Lists"
power_draw_per_use = 20
cooldown_per_use = 10

/obj/item/integrated_circuit/lists/pick
name = "pick circuit"
Expand All @@ -28,6 +29,7 @@
"on failure" = IC_PINTYPE_PULSE_OUT,
)
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
cooldown_per_use = 1

/obj/item/integrated_circuit/lists/pick/do_work()
var/list/input_list = get_pin_data(IC_INPUT, 1) // List pins guarantee that there is a list inside, even if just an empty one.
Expand Down Expand Up @@ -83,6 +85,7 @@
)
icon_state = "addition"
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
cooldown_per_use = 1

/obj/item/integrated_circuit/lists/search/do_work()
var/list/input_list = get_pin_data(IC_INPUT, 1)
Expand Down Expand Up @@ -115,6 +118,7 @@
)
icon_state = "addition"
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
cooldown_per_use = 1

/obj/item/integrated_circuit/lists/at/do_work()
var/list/input_list = get_pin_data(IC_INPUT, 1)
Expand Down Expand Up @@ -218,6 +222,7 @@
set_pin_data(IC_OUTPUT, 1, input_list.len)
push_data()
activate_pin(2)
cooldown_per_use = 1


/obj/item/integrated_circuit/lists/jointext
Expand All @@ -240,6 +245,7 @@
)
icon_state = "addition"
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
cooldown_per_use = 1

/obj/item/integrated_circuit/lists/jointext/do_work()
var/list/input_list = get_pin_data(IC_INPUT, 1)
Expand Down Expand Up @@ -312,7 +318,7 @@
)
outputs = list()
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
var/number_of_pins = 4
var/number_of_pins = 16

/obj/item/integrated_circuit/lists/deconstructor/Initialize()
for(var/i = 1 to number_of_pins)
Expand Down
17 changes: 13 additions & 4 deletions code/modules/integrated_electronics/subtypes/manipulation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
spawn_flags = IC_SPAWN_RESEARCH
action_flags = IC_ACTION_COMBAT
power_draw_per_use = 0
ext_cooldown = 1
var/mode = FALSE

var/stun_projectile = null //stun mode projectile type
Expand Down Expand Up @@ -57,7 +58,7 @@
if(gun_properties["shot_delay"])
cooldown_per_use = gun_properties["shot_delay"]*10
if(cooldown_per_use<30)
cooldown_per_use = 40
cooldown_per_use = 30
if(gun_properties["reqpower"])
power_draw_per_use = gun_properties["reqpower"]
set_pin_data(IC_OUTPUT, 1, WEAKREF(installed_gun))
Expand Down Expand Up @@ -139,8 +140,10 @@
being held, or anchored in some way. It should be noted that the ability to move is dependant on the type of assembly that this circuit inhabits."
w_class = WEIGHT_CLASS_SMALL
complexity = 20
cooldown_per_use = 8
ext_cooldown = 1
inputs = list("direction" = IC_PINTYPE_DIR)
outputs = list()
outputs = list("obstacle" = IC_PINTYPE_REF)
activators = list("step towards dir" = IC_PINTYPE_PULSE_IN,"on step"=IC_PINTYPE_PULSE_OUT,"blocked"=IC_PINTYPE_PULSE_OUT)
spawn_flags = IC_SPAWN_RESEARCH
action_flags = IC_ACTION_MOVEMENT
Expand All @@ -159,6 +162,7 @@
activate_pin(2)
return
else
set_pin_data(IC_OUTPUT, 1, WEAKREF(assembly.collw))
activate_pin(3)
return FALSE
return FALSE
Expand All @@ -171,6 +175,7 @@
Beware: Once primed there is no aborting the process!"
icon_state = "grenade"
complexity = 30
cooldown_per_use = 10
inputs = list("detonation time" = IC_PINTYPE_NUMBER)
outputs = list()
activators = list("prime grenade" = IC_PINTYPE_PULSE_IN)
Expand Down Expand Up @@ -241,6 +246,7 @@
icon_state = "plant_m"
extended_desc = "The circuit accepts a reference to a hydroponic tray in an adjacent tile. \
Mode(0- harvest, 1-uproot weeds, 2-uproot plant) determinies action."
cooldown_per_use = 10
w_class = WEIGHT_CLASS_TINY
complexity = 10
inputs = list("target" = IC_PINTYPE_REF,"mode" = IC_PINTYPE_NUMBER)
Expand Down Expand Up @@ -300,7 +306,7 @@
extended_desc = "The circuit accepts a reference to an object to be grabbed and can store up to 10 objects. Modes: 1 to grab, 0 to eject the first object, and -1 to eject all objects."
w_class = WEIGHT_CLASS_SMALL
size = 3

cooldown_per_use = 5
complexity = 10
inputs = list("target" = IC_PINTYPE_REF,"mode" = IC_PINTYPE_NUMBER)
outputs = list("first" = IC_PINTYPE_REF, "last" = IC_PINTYPE_REF, "amount" = IC_PINTYPE_NUMBER,"contents" = IC_PINTYPE_LIST)
Expand Down Expand Up @@ -362,13 +368,14 @@
extended_desc = "The circuit accepts a reference to thing to be pulled. Modes: 0 for release. 1 for pull."
w_class = WEIGHT_CLASS_SMALL
size = 3

cooldown_per_use = 5
complexity = 10
inputs = list("target" = IC_PINTYPE_REF,"mode" = IC_PINTYPE_INDEX)
outputs = list("is pulling" = IC_PINTYPE_BOOLEAN)
activators = list("pulse in" = IC_PINTYPE_PULSE_IN,"pulse out" = IC_PINTYPE_PULSE_OUT,"released" = IC_PINTYPE_PULSE_OUT)
spawn_flags = IC_SPAWN_RESEARCH
power_draw_per_use = 50
ext_cooldown = 1
var/max_grab = GRAB_PASSIVE

/obj/item/integrated_circuit/manipulation/claw/do_work()
Expand Down Expand Up @@ -403,6 +410,8 @@
complexity = 15
w_class = WEIGHT_CLASS_SMALL
size = 2
cooldown_per_use = 10
ext_cooldown = 1
inputs = list(
"target X rel" = IC_PINTYPE_NUMBER,
"target Y rel" = IC_PINTYPE_NUMBER,
Expand Down
6 changes: 5 additions & 1 deletion code/modules/integrated_electronics/subtypes/output.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

/obj/item/integrated_circuit/output/screen
name = "small screen"
extended_desc = " use &lt;br&gt; to start a new line"
desc = "Takes any data type as an input, and displays it to the user upon examining."
icon_state = "screen"
inputs = list("displayed data" = IC_PINTYPE_ANY)
outputs = list()
activators = list("load data" = IC_PINTYPE_PULSE_IN)
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
power_draw_per_use = 10
cooldown_per_use = 10
var/eol = "&lt;br&gt;"
var/stuff_to_display = null

/obj/item/integrated_circuit/output/screen/disconnect_all()
Expand All @@ -30,7 +33,7 @@
if(d)
stuff_to_display = "[d]"
else
stuff_to_display = I.data
stuff_to_display = replacetext("[I.data]", eol , "<br>")

/obj/item/integrated_circuit/output/screen/medium
name = "screen"
Expand Down Expand Up @@ -219,6 +222,7 @@
desc = "Takes any string as an input and will make the device say the string when pulsed."
extended_desc = "This unit is more advanced than the plain speaker circuit, able to transpose any valid text to speech."
icon_state = "speaker"
ext_cooldown = 2
complexity = 12
inputs = list("text" = IC_PINTYPE_STRING)
outputs = list()
Expand Down
6 changes: 4 additions & 2 deletions code/modules/integrated_electronics/subtypes/power.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
extended_desc = "This circuit transmits 20 kJ of electricity every time the activator pin is pulsed. The input pin must be \
a reference to a machine to send electricity to. This can be a battery, or anything containing a battery. The machine can exist \
inside the assembly, or adjacent to it. The power is sourced from the assembly's power cell. If the target is outside of the assembly, \
some power is lost due to ineffiency."
some power is lost due to ineffiency.Warning!Don't stack more than 1 power transmittors.it becomes less efficient for every other \
transmission circuit in its own assembly and other nearby ones. "
w_class = WEIGHT_CLASS_BULKY
complexity = 32
power_draw_per_use = 2000
Expand All @@ -49,6 +50,8 @@
if(A.Adjacent(B))
if(AM.loc != assembly)
transfer_amount *= 0.8 // Losses due to distance.
var/list/U=A.GetAllContents(/obj/item/integrated_circuit/power/transmitter)
transfer_amount *= 1 / U.len
set_pin_data(IC_OUTPUT, 1, cell.charge)
set_pin_data(IC_OUTPUT, 2, cell.maxcharge)
set_pin_data(IC_OUTPUT, 3, cell.percent())
Expand All @@ -61,7 +64,6 @@
if(istype(AM, /obj/item))
var/obj/item/I = AM
I.update_icon()

return TRUE
else
set_pin_data(IC_OUTPUT, 1, null)
Expand Down