From 516b71ed7e9cb53d5c1a6d4412824c44328964fb Mon Sep 17 00:00:00 2001 From: Ghommie Date: Wed, 12 Jun 2019 20:13:08 +0200 Subject: [PATCH 01/10] fixing stunbatons. --- code/game/objects/items/stunbaton.dm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index bf7c71dddb..54e5bf033a 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -46,14 +46,15 @@ /obj/item/melee/baton/loaded //this one starts with a cell pre-installed. preload_cell_type = /obj/item/stock_parts/cell/high -/obj/item/melee/baton/proc/deductcharge(chrgdeductamt, chargecheck = TRUE) - if(!cell) +/obj/item/melee/baton/proc/deductcharge(chrgdeductamt, chargecheck = TRUE, obj/item/stock_parts/cell/external_cell) + if(!cell && !external_cell) switch_status(FALSE, TRUE) return FALSE + var/obj/item/stock_parts/cell/copper_top = external_cell ? external_cell : cell //Note this value returned is significant, as it will determine //if a stun is applied or not - . = cell.use(chrgdeductamt) - if(status && (!. || (chargecheck && cell.charge < hitcost * STUNBATON_CHARGE_LENIENCY))) + . = copper_top.use(chrgdeductamt) + if(status && (!. || (chargecheck && copper_top.charge < hitcost * STUNBATON_CHARGE_LENIENCY))) //we're below minimum, turn off switch_status(FALSE) @@ -164,16 +165,15 @@ playsound(L, 'sound/weapons/genhit.ogg', 50, 1) return FALSE var/stunpwr = stunforce + var/stuncharge = cell.charge + var/obj/item/stock_parts/cell/external_cell if(iscyborg(loc)) var/mob/living/silicon/robot/R = loc - if(!istype(R) || !R.cell || !R.cell.use(hitcost)) + external_cell = R.cell + if(!deductcharge(hitcost, FALSE, external_cell)) + stunpwr *= round(stuncharge/hitcost, 0.1) + if(stunpwr < stunforce * STUNBATON_CHARGE_LENIENCY) return FALSE - else - var/stuncharge = cell.charge - if(!deductcharge(hitcost, FALSE)) - stunpwr *= round(stuncharge/hitcost) - if(stunpwr < stunforce * STUNBATON_CHARGE_LENIENCY) - return FALSE L.Knockdown(stunpwr) L.adjustStaminaLoss(stunpwr*0.1, affected_zone = (istype(user) ? user.zone_selected : BODY_ZONE_CHEST))//CIT CHANGE - makes stunbatons deal extra staminaloss. Todo: make this also deal pain when pain gets implemented. From 368267f53d8dba78da4582a777f38fefc541af2a Mon Sep 17 00:00:00 2001 From: Ghommie Date: Wed, 12 Jun 2019 20:31:24 +0200 Subject: [PATCH 02/10] dddddd --- code/game/objects/items/stunbaton.dm | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 54e5bf033a..f21d69fcfb 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -46,11 +46,14 @@ /obj/item/melee/baton/loaded //this one starts with a cell pre-installed. preload_cell_type = /obj/item/stock_parts/cell/high -/obj/item/melee/baton/proc/deductcharge(chrgdeductamt, chargecheck = TRUE, obj/item/stock_parts/cell/external_cell) - if(!cell && !external_cell) +/obj/item/melee/baton/proc/deductcharge(chrgdeductamt, chargecheck = TRUE) + var/obj/item/stock_parts/cell/copper_top = cell + if(iscyborg(loc)) + var/mob/living/silicon/robot/R = loc + copper_top = R.cell + if(!copper_top) switch_status(FALSE, TRUE) return FALSE - var/obj/item/stock_parts/cell/copper_top = external_cell ? external_cell : cell //Note this value returned is significant, as it will determine //if a stun is applied or not . = copper_top.use(chrgdeductamt) @@ -165,15 +168,21 @@ playsound(L, 'sound/weapons/genhit.ogg', 50, 1) return FALSE var/stunpwr = stunforce - var/stuncharge = cell.charge - var/obj/item/stock_parts/cell/external_cell + var/obj/item/stock_parts/cell/our_cell = cell if(iscyborg(loc)) var/mob/living/silicon/robot/R = loc - external_cell = R.cell - if(!deductcharge(hitcost, FALSE, external_cell)) - stunpwr *= round(stuncharge/hitcost, 0.1) - if(stunpwr < stunforce * STUNBATON_CHARGE_LENIENCY) + our_cell = R.cell + if(!our_cell) + return FALSE + var/stuncharge = our_cell.charge + deductcharge(hitcost, FALSE) + if(stuncharge < hitcost) + if(stuncharge < hitcost * STUNBATON_CHARGE_LENIENCY) + L.visible_message("[user] has prodded [L] with [src]. Luckily it din't have enough charge left.", \ + "[user] has prodded you with [src]. Luckily it din't have enough charge left.") return FALSE + stunpwr *= round(stuncharge/hitcost, 0.1) + L.Knockdown(stunpwr) L.adjustStaminaLoss(stunpwr*0.1, affected_zone = (istype(user) ? user.zone_selected : BODY_ZONE_CHEST))//CIT CHANGE - makes stunbatons deal extra staminaloss. Todo: make this also deal pain when pain gets implemented. From 4cc7636da13562d8ca8c71e0e640040d817be82c Mon Sep 17 00:00:00 2001 From: Ghommie Date: Wed, 12 Jun 2019 22:50:09 +0200 Subject: [PATCH 03/10] fixing more. --- code/game/objects/items/stunbaton.dm | 36 +++++++++++++++++----------- code/modules/power/cell.dm | 4 ++-- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index f21d69fcfb..8a7a638539 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -46,7 +46,7 @@ /obj/item/melee/baton/loaded //this one starts with a cell pre-installed. preload_cell_type = /obj/item/stock_parts/cell/high -/obj/item/melee/baton/proc/deductcharge(chrgdeductamt, chargecheck = TRUE) +/obj/item/melee/baton/proc/deductcharge(chrgdeductamt, chargecheck = TRUE, explode = TRUE) var/obj/item/stock_parts/cell/copper_top = cell if(iscyborg(loc)) var/mob/living/silicon/robot/R = loc @@ -56,8 +56,9 @@ return FALSE //Note this value returned is significant, as it will determine //if a stun is applied or not - . = copper_top.use(chrgdeductamt) - if(status && (!. || (chargecheck && copper_top.charge < hitcost * STUNBATON_CHARGE_LENIENCY))) + + copper_top.use(min(chrgdeductamt, copper_top.charge), explode) + if(status && (!copper_top.charge || (chargecheck && copper_top.charge < (hitcost * STUNBATON_CHARGE_LENIENCY)))) //we're below minimum, turn off switch_status(FALSE) @@ -73,7 +74,8 @@ update_icon() /obj/item/melee/baton/process() - deductcharge(hitcost * 0.004, FALSE) + . = ..() + deductcharge(hitcost * 0.004, FALSE, FALSE) /obj/item/melee/baton/update_icon() if(status) @@ -96,7 +98,7 @@ if(cell) to_chat(user, "[src] already has a cell.") else - if(C.maxcharge < hitcost * STUNBATON_CHARGE_LENIENCY) + if(C.maxcharge < (hitcost * STUNBATON_CHARGE_LENIENCY)) to_chat(user, "[src] requires a higher capacity cell.") return if(!user.transferItemToLoc(W, src)) @@ -116,15 +118,19 @@ return ..() /obj/item/melee/baton/attack_self(mob/user) - if(cell && cell.charge > hitcost * STUNBATON_CHARGE_LENIENCY) - switch_status(!status) - to_chat(user, "[src] is now [status ? "on" : "off"].") - else + var/obj/item/stock_parts/cell/copper_top = cell + if(iscyborg(loc)) + var/mob/living/silicon/robot/R = loc + copper_top = R.cell + if(!copper_top || copper_top.charge < (hitcost * STUNBATON_CHARGE_LENIENCY)) switch_status(FALSE, TRUE) - if(!cell) + if(!copper_top) to_chat(user, "[src] does not have a power source!") else to_chat(user, "[src] is out of charge.") + else + switch_status(!status) + to_chat(user, "[src] is now [status ? "on" : "off"].") add_fingerprint(user) /obj/item/melee/baton/attack(mob/M, mob/living/carbon/human/user) @@ -176,10 +182,12 @@ return FALSE var/stuncharge = our_cell.charge deductcharge(hitcost, FALSE) + if(QDELETED(src)) //it was rigged + return if(stuncharge < hitcost) - if(stuncharge < hitcost * STUNBATON_CHARGE_LENIENCY) - L.visible_message("[user] has prodded [L] with [src]. Luckily it din't have enough charge left.", \ - "[user] has prodded you with [src]. Luckily it din't have enough charge left.") + if(stuncharge < (hitcost * STUNBATON_CHARGE_LENIENCY)) + L.visible_message("[user] has prodded [L] with [src]. Luckily it is out of charge.", \ + "[user] has prodded you with [src]. Luckily it is out of charge.") return FALSE stunpwr *= round(stuncharge/hitcost, 0.1) @@ -214,7 +222,7 @@ . = ..() if (!(. & EMP_PROTECT_SELF)) switch_status(FALSE) - deductcharge(1000 / severity) + deductcharge(1000 / severity, TRUE, FALSE) //Makeshift stun baton. Replacement for stun gloves. /obj/item/melee/baton/cattleprod diff --git a/code/modules/power/cell.dm b/code/modules/power/cell.dm index b6473b8913..5c1df573b3 100644 --- a/code/modules/power/cell.dm +++ b/code/modules/power/cell.dm @@ -69,8 +69,8 @@ return 100*charge/maxcharge // use power from a cell -/obj/item/stock_parts/cell/use(amount) - if(rigged && amount > 0) +/obj/item/stock_parts/cell/use(amount, can_explode = TRUE) + if(rigged && amount > 0 && can_explode) explode() return 0 if(charge < amount) From 5a35e95735f6a680f53bb7fdb6ca70601463b2ac Mon Sep 17 00:00:00 2001 From: Ghommie Date: Wed, 12 Jun 2019 22:52:05 +0200 Subject: [PATCH 04/10] . --- code/game/objects/items/stunbaton.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 8a7a638539..8c51cbb717 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -182,7 +182,7 @@ return FALSE var/stuncharge = our_cell.charge deductcharge(hitcost, FALSE) - if(QDELETED(src)) //it was rigged + if(QDELETED(src) || QDELETED(our_cell)) //it was rigged return if(stuncharge < hitcost) if(stuncharge < (hitcost * STUNBATON_CHARGE_LENIENCY)) From a29095cbe1a01043b1d7fb7a2de457ed0577ca0a Mon Sep 17 00:00:00 2001 From: Ghommie Date: Wed, 12 Jun 2019 23:06:09 +0200 Subject: [PATCH 05/10] Penitence for the awful mistakes I have done in the refactor. --- code/game/objects/items/stunbaton.dm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 8c51cbb717..6dcda74aaa 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -22,7 +22,11 @@ var/preload_cell_type //if not empty the baton starts with this type of cell /obj/item/melee/baton/get_cell() - return cell + var/obj/item/stock_parts/cell/our_cell = cell + if(iscyborg(loc)) + var/mob/living/silicon/robot/R = loc + our_cell = R.get_cell() + return our_cell /obj/item/melee/baton/suicide_act(mob/user) user.visible_message("[user] is putting the live [name] in [user.p_their()] mouth! It looks like [user.p_theyre()] trying to commit suicide!") @@ -47,10 +51,7 @@ preload_cell_type = /obj/item/stock_parts/cell/high /obj/item/melee/baton/proc/deductcharge(chrgdeductamt, chargecheck = TRUE, explode = TRUE) - var/obj/item/stock_parts/cell/copper_top = cell - if(iscyborg(loc)) - var/mob/living/silicon/robot/R = loc - copper_top = R.cell + var/obj/item/stock_parts/cell/copper_top = get_cell() if(!copper_top) switch_status(FALSE, TRUE) return FALSE @@ -86,9 +87,10 @@ icon_state = "[initial(name)]" /obj/item/melee/baton/examine(mob/user) - ..() - if(cell) - to_chat(user, "\The [src] is [round(cell.percent())]% charged.") + . = ..() + var/obj/item/stock_parts/cell/copper_top = get_cell() + if(copper_top) + to_chat(user, "\The [src] is [round(copper_top.percent())]% charged.") else to_chat(user, "\The [src] does not have a power source installed.") @@ -118,10 +120,7 @@ return ..() /obj/item/melee/baton/attack_self(mob/user) - var/obj/item/stock_parts/cell/copper_top = cell - if(iscyborg(loc)) - var/mob/living/silicon/robot/R = loc - copper_top = R.cell + var/obj/item/stock_parts/cell/copper_top = get_cell() if(!copper_top || copper_top.charge < (hitcost * STUNBATON_CHARGE_LENIENCY)) switch_status(FALSE, TRUE) if(!copper_top) @@ -222,7 +221,8 @@ . = ..() if (!(. & EMP_PROTECT_SELF)) switch_status(FALSE) - deductcharge(1000 / severity, TRUE, FALSE) + if(!iscyborg(loc)) + deductcharge(1000 / severity, TRUE, FALSE) //Makeshift stun baton. Replacement for stun gloves. /obj/item/melee/baton/cattleprod From 2edef99b0861e3649d12da5752db2c3d5a2a90d4 Mon Sep 17 00:00:00 2001 From: Ghommie Date: Wed, 12 Jun 2019 23:16:27 +0200 Subject: [PATCH 06/10] . --- code/game/objects/items/stunbaton.dm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 6dcda74aaa..dae9545fbb 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -22,11 +22,10 @@ var/preload_cell_type //if not empty the baton starts with this type of cell /obj/item/melee/baton/get_cell() - var/obj/item/stock_parts/cell/our_cell = cell + . = cell if(iscyborg(loc)) var/mob/living/silicon/robot/R = loc - our_cell = R.get_cell() - return our_cell + . = R.get_cell() /obj/item/melee/baton/suicide_act(mob/user) user.visible_message("[user] is putting the live [name] in [user.p_their()] mouth! It looks like [user.p_theyre()] trying to commit suicide!") From 5ba46eb51755a591027429afe49316a70ed4120f Mon Sep 17 00:00:00 2001 From: Ghommie Date: Wed, 12 Jun 2019 23:20:34 +0200 Subject: [PATCH 07/10] Avoid runtiming. --- code/game/objects/items/stunbaton.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index dae9545fbb..d85295377c 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -58,7 +58,7 @@ //if a stun is applied or not copper_top.use(min(chrgdeductamt, copper_top.charge), explode) - if(status && (!copper_top.charge || (chargecheck && copper_top.charge < (hitcost * STUNBATON_CHARGE_LENIENCY)))) + if(status && (!(copper_top?.charge) || (chargecheck && copper_top.charge < (hitcost * STUNBATON_CHARGE_LENIENCY)))) //we're below minimum, turn off switch_status(FALSE) From 7a8eaf41acf611cf5c64dfa58e94874794bfae8e Mon Sep 17 00:00:00 2001 From: Ghommie Date: Wed, 12 Jun 2019 23:21:42 +0200 Subject: [PATCH 08/10] another get_cell() --- code/game/objects/items/stunbaton.dm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index d85295377c..bc5429da54 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -172,10 +172,7 @@ playsound(L, 'sound/weapons/genhit.ogg', 50, 1) return FALSE var/stunpwr = stunforce - var/obj/item/stock_parts/cell/our_cell = cell - if(iscyborg(loc)) - var/mob/living/silicon/robot/R = loc - our_cell = R.cell + var/obj/item/stock_parts/cell/our_cell = get_cell() if(!our_cell) return FALSE var/stuncharge = our_cell.charge From e2bf5b73fda098f298b4925022fe718ffba19688 Mon Sep 17 00:00:00 2001 From: Ghommie Date: Wed, 12 Jun 2019 23:22:31 +0200 Subject: [PATCH 09/10] I'm being too careless, sorry for the many commits. --- code/game/objects/items/stunbaton.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index bc5429da54..2a22ab8c27 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -178,7 +178,7 @@ var/stuncharge = our_cell.charge deductcharge(hitcost, FALSE) if(QDELETED(src) || QDELETED(our_cell)) //it was rigged - return + return FALSE if(stuncharge < hitcost) if(stuncharge < (hitcost * STUNBATON_CHARGE_LENIENCY)) L.visible_message("[user] has prodded [L] with [src]. Luckily it is out of charge.", \ From a3c2ed0b5259af5ee4030d56df693f0caccb7e24 Mon Sep 17 00:00:00 2001 From: Ghommie Date: Sat, 15 Jun 2019 02:19:57 +0200 Subject: [PATCH 10/10] fixes. --- code/game/objects/items/stunbaton.dm | 12 ++++++++---- code/game/objects/items/teleprod.dm | 5 ++--- code/modules/power/cell.dm | 6 +++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 2a22ab8c27..bfe630ba01 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -58,7 +58,9 @@ //if a stun is applied or not copper_top.use(min(chrgdeductamt, copper_top.charge), explode) - if(status && (!(copper_top?.charge) || (chargecheck && copper_top.charge < (hitcost * STUNBATON_CHARGE_LENIENCY)))) + if(QDELETED(src)) + return FALSE + if(status && (!copper_top || !copper_top.charge || (chargecheck && copper_top.charge < (hitcost * STUNBATON_CHARGE_LENIENCY)))) //we're below minimum, turn off switch_status(FALSE) @@ -74,7 +76,6 @@ update_icon() /obj/item/melee/baton/process() - . = ..() deductcharge(hitcost * 0.004, FALSE, FALSE) /obj/item/melee/baton/update_icon() @@ -174,6 +175,7 @@ var/stunpwr = stunforce var/obj/item/stock_parts/cell/our_cell = get_cell() if(!our_cell) + switch_status(FALSE) return FALSE var/stuncharge = our_cell.charge deductcharge(hitcost, FALSE) @@ -181,8 +183,8 @@ return FALSE if(stuncharge < hitcost) if(stuncharge < (hitcost * STUNBATON_CHARGE_LENIENCY)) - L.visible_message("[user] has prodded [L] with [src]. Luckily it is out of charge.", \ - "[user] has prodded you with [src]. Luckily it is out of charge.") + L.visible_message("[user] has prodded [L] with [src]. Luckily it was out of charge.", \ + "[user] has prodded you with [src]. Luckily it was out of charge.") return FALSE stunpwr *= round(stuncharge/hitcost, 0.1) @@ -210,7 +212,9 @@ /obj/item/melee/baton/proc/clowning_around(mob/living/user) user.visible_message("[user] accidentally hits [user.p_them()]self with [src]!", \ "You accidentally hit yourself with [src]!") + SEND_SIGNAL(user, COMSIG_LIVING_MINOR_SHOCK) user.Knockdown(stunforce*3) + playsound(loc, 'sound/weapons/egloves.ogg', 50, 1, -1) deductcharge(hitcost) /obj/item/melee/baton/emp_act(severity) diff --git a/code/game/objects/items/teleprod.dm b/code/game/objects/items/teleprod.dm index c514e5e926..341c85fa1c 100644 --- a/code/game/objects/items/teleprod.dm +++ b/code/game/objects/items/teleprod.dm @@ -10,15 +10,14 @@ . = ..() if(!. || !istype(M) || M.anchored) return - else - SEND_SIGNAL(M, COMSIG_LIVING_MINOR_SHOCK) - do_teleport(M, get_turf(M), 15) + do_teleport(M, get_turf(M), 15) /obj/item/melee/baton/cattleprod/teleprod/clowning_around(mob/living/user) user.visible_message("[user] accidentally hits [user.p_them()]self with [src]!", \ "You accidentally hit yourself with [src]!") SEND_SIGNAL(user, COMSIG_LIVING_MINOR_SHOCK) user.Knockdown(stunforce*3) + playsound(loc, 'sound/weapons/egloves.ogg', 50, 1, -1) if(do_teleport(user, get_turf(user), 50)) deductcharge(hitcost) else diff --git a/code/modules/power/cell.dm b/code/modules/power/cell.dm index 5c1df573b3..3e93d9f42b 100644 --- a/code/modules/power/cell.dm +++ b/code/modules/power/cell.dm @@ -26,7 +26,8 @@ /obj/item/stock_parts/cell/Initialize(mapload, override_maxcharge) . = ..() - START_PROCESSING(SSobj, src) + if(self_recharge) + START_PROCESSING(SSobj, src) create_reagents(5, INJECTABLE | DRAINABLE) if (override_maxcharge) maxcharge = override_maxcharge @@ -103,9 +104,8 @@ return (FIRELOSS) /obj/item/stock_parts/cell/on_reagent_change(changetype) - rigged = !isnull(reagents.has_reagent("plasma", 5)) //has_reagent returns the reagent datum ..() - + rigged = reagents?.has_reagent("plasma", 5) ? TRUE : FALSE //has_reagent returns the reagent datum /obj/item/stock_parts/cell/proc/explode() var/turf/T = get_turf(src.loc)