From ecedb9f78ab48ce8821831e10f142e0fe3aba699 Mon Sep 17 00:00:00 2001 From: Exxion Date: Thu, 30 Apr 2015 19:08:35 -0400 Subject: [PATCH 1/2] Tool speed framework whop whop --- code/datums/helper_datums/construction_datum.dm | 11 +++++++++-- code/game/objects/items/weapons/tools.dm | 11 ++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/code/datums/helper_datums/construction_datum.dm b/code/datums/helper_datums/construction_datum.dm index 2b99f79a1aa..46fd3b2e863 100644 --- a/code/datums/helper_datums/construction_datum.dm +++ b/code/datums/helper_datums/construction_datum.dm @@ -130,13 +130,17 @@ return /datum/construction/proc/try_consume(mob/user as mob, atom/movable/used_atom, given_step) + if(!used_atom.construction_delay_mult[1]) + user << "This tool only works for deconstruction!" //It doesn't technically have to be a tool to cause this message, but it wouldn't make sense for anything else to do so. + return 0 + if(!(Co_AMOUNT in given_step) && !(Co_DELAY in given_step)) return 1 var/delay = 0 if(Co_DELAY in given_step) - delay = given_step[Co_DELAY] + delay = given_step[Co_DELAY] * used_atom.construction_delay_mult[1] //I know, I know. Magic numbers bad. See tools.dm. if(delay > 0) start_construct_message(given_step, user, used_atom) if(!do_after(user, delay, needhand = 1)) @@ -282,6 +286,9 @@ /datum/construction/reversible/try_consume(mob/user as mob, atom/movable/used_atom, given_step, index, diff) //if we've made some progress on a step, we want to drop it var/current_step = (diff == BACKWARD ? get_forward_step(index) : get_backward_step(index)) + if(!used_atom.construction_delay_mult[(diff > 0) + 1]) + user << "This tool only works for [diff == FORWARD ? "de" : ""]construction!" //It doesn't technically have to be a tool to cause this message, but it wouldn't make sense for anything else to do so. + return 0 if(current_step && (Co_AMOUNT in current_step) && (Co_MAX_AMOUNT in current_step) && (current_step[Co_AMOUNT] < current_step[Co_MAX_AMOUNT])) var/obj/item/stack/S if(used_atoms["[index][diff == FORWARD ? "+" : "-"]"]) @@ -301,7 +308,7 @@ var/delay = 0 if(Co_DELAY in given_step) - delay = given_step[Co_DELAY] + delay = given_step[Co_DELAY] * used_atom.construction_delay_mult[(diff > 0) + 1] //Yay for loose typing. The part in the brackets converts -1 to 1 and 1 to 2. See tools.dm for why. if(delay > 0) start_construct_message(given_step, user, used_atom) if(!do_after(user, delay, needhand = 1)) diff --git a/code/game/objects/items/weapons/tools.dm b/code/game/objects/items/weapons/tools.dm index 37300587d6b..b413abcd183 100644 --- a/code/game/objects/items/weapons/tools.dm +++ b/code/game/objects/items/weapons/tools.dm @@ -12,6 +12,15 @@ * Revolver Conversion Kit(made sense) */ +/* + * Used for fancy tool subtypes that are faster or slower than the standard tool. + * The number in the first slot is the multiplier for time to construct, the one in the second slot is the multiplier for time to deconstruct. + * If one is zero, the tool cannot be used in that direction. If you want to adminbus an instant tool, use .0001 or something, not 0. + * Don't set either to a negative number. It will probably break, though I'm not really sure in what way. + */ +/atom + var/list/construction_delay_mult = list(1, 1) + /* * Wrench */ @@ -486,7 +495,7 @@ /obj/item/weapon/weldingtool/experimental/proc/fuel_gen()//Proc to make the experimental welder generate fuel, optimized as fuck -Sieve - var/gen_amount = ((world.time-last_gen)/25) + var/gen_amount = ((world.time-last_gen)/25) //Too bad it's not actually implemented reagents += (gen_amount) if(reagents > max_fuel) reagents = max_fuel From 7e137d1ab05405f896b9ce1dc28b93d06c6a5f5d Mon Sep 17 00:00:00 2001 From: Exxion Date: Fri, 1 May 2015 18:07:15 -0400 Subject: [PATCH 2/2] What they said --- code/datums/helper_datums/construction_datum.dm | 11 +++++++---- code/game/objects/items/weapons/tools.dm | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/code/datums/helper_datums/construction_datum.dm b/code/datums/helper_datums/construction_datum.dm index 46fd3b2e863..66fb618c690 100644 --- a/code/datums/helper_datums/construction_datum.dm +++ b/code/datums/helper_datums/construction_datum.dm @@ -14,6 +14,9 @@ #define Co_NEXTSTEP "nextstep" #define Co_BACKSTEP "backstep" +#define Co_CON_SPEED "construct" //For tools. See tools.dm +#define Co_DECON_SPEED "deconstruct" //For tools. See tools.dm + /datum/construction var/list/steps var/atom/holder @@ -130,7 +133,7 @@ return /datum/construction/proc/try_consume(mob/user as mob, atom/movable/used_atom, given_step) - if(!used_atom.construction_delay_mult[1]) + if(!used_atom.construction_delay_mult[Co_CON_SPEED]) user << "This tool only works for deconstruction!" //It doesn't technically have to be a tool to cause this message, but it wouldn't make sense for anything else to do so. return 0 @@ -140,7 +143,7 @@ var/delay = 0 if(Co_DELAY in given_step) - delay = given_step[Co_DELAY] * used_atom.construction_delay_mult[1] //I know, I know. Magic numbers bad. See tools.dm. + delay = given_step[Co_DELAY] * used_atom.construction_delay_mult[Co_CON_SPEED] if(delay > 0) start_construct_message(given_step, user, used_atom) if(!do_after(user, delay, needhand = 1)) @@ -286,7 +289,7 @@ /datum/construction/reversible/try_consume(mob/user as mob, atom/movable/used_atom, given_step, index, diff) //if we've made some progress on a step, we want to drop it var/current_step = (diff == BACKWARD ? get_forward_step(index) : get_backward_step(index)) - if(!used_atom.construction_delay_mult[(diff > 0) + 1]) + if(!used_atom.construction_delay_mult[diff == FORWARD ? Co_CON_SPEED : Co_DECON_SPEED]) user << "This tool only works for [diff == FORWARD ? "de" : ""]construction!" //It doesn't technically have to be a tool to cause this message, but it wouldn't make sense for anything else to do so. return 0 if(current_step && (Co_AMOUNT in current_step) && (Co_MAX_AMOUNT in current_step) && (current_step[Co_AMOUNT] < current_step[Co_MAX_AMOUNT])) @@ -308,7 +311,7 @@ var/delay = 0 if(Co_DELAY in given_step) - delay = given_step[Co_DELAY] * used_atom.construction_delay_mult[(diff > 0) + 1] //Yay for loose typing. The part in the brackets converts -1 to 1 and 1 to 2. See tools.dm for why. + delay = given_step[Co_DELAY] * used_atom.construction_delay_mult[diff == FORWARD ? Co_CON_SPEED : Co_DECON_SPEED] if(delay > 0) start_construct_message(given_step, user, used_atom) if(!do_after(user, delay, needhand = 1)) diff --git a/code/game/objects/items/weapons/tools.dm b/code/game/objects/items/weapons/tools.dm index b413abcd183..2178b18fc0e 100644 --- a/code/game/objects/items/weapons/tools.dm +++ b/code/game/objects/items/weapons/tools.dm @@ -12,14 +12,17 @@ * Revolver Conversion Kit(made sense) */ -/* - * Used for fancy tool subtypes that are faster or slower than the standard tool. - * The number in the first slot is the multiplier for time to construct, the one in the second slot is the multiplier for time to deconstruct. +/* Used for fancy tool subtypes that are faster or slower than the standard tool. + * The value for the key "construct" (or Co_CON_SPEED) is the multiplier for construction delay. + * The value for the key "deconstruct" (or Co_DECON_SPEED) is the multiplier for deconstruction delay, in case you hadn't guessed. * If one is zero, the tool cannot be used in that direction. If you want to adminbus an instant tool, use .0001 or something, not 0. * Don't set either to a negative number. It will probably break, though I'm not really sure in what way. + * Since this is a variable of /atom, it can technically be applied to any item used in construction, as long as the construction is based on construction datums. + * Yes, this allows for hyperspeed building stacks, but I wouldn't recommend that, as it doesn't carry over too well when stacks are merged or separated. + * Might work for borg stack modules, though. Worth looking into. */ /atom - var/list/construction_delay_mult = list(1, 1) + var/list/construction_delay_mult = list(Co_CON_SPEED = 1, Co_DECON_SPEED = 1) /* * Wrench