diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index bf7c71dddb..bfe630ba01 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -22,7 +22,10 @@ var/preload_cell_type //if not empty the baton starts with this type of cell /obj/item/melee/baton/get_cell() - return cell + . = cell + if(iscyborg(loc)) + var/mob/living/silicon/robot/R = loc + . = 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!") @@ -46,14 +49,18 @@ /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, explode = TRUE) + var/obj/item/stock_parts/cell/copper_top = get_cell() + if(!copper_top) switch_status(FALSE, TRUE) return FALSE //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(min(chrgdeductamt, copper_top.charge), explode) + 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) @@ -69,7 +76,7 @@ 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) @@ -80,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.") @@ -92,7 +100,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)) @@ -112,15 +120,16 @@ 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 = get_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) @@ -164,16 +173,21 @@ playsound(L, 'sound/weapons/genhit.ogg', 50, 1) return FALSE var/stunpwr = stunforce - if(iscyborg(loc)) - var/mob/living/silicon/robot/R = loc - if(!istype(R) || !R.cell || !R.cell.use(hitcost)) + 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) + if(QDELETED(src) || QDELETED(our_cell)) //it was rigged + return FALSE + if(stuncharge < hitcost) + if(stuncharge < (hitcost * STUNBATON_CHARGE_LENIENCY)) + 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 - else - var/stuncharge = cell.charge - if(!deductcharge(hitcost, FALSE)) - stunpwr *= round(stuncharge/hitcost) - if(stunpwr < stunforce * STUNBATON_CHARGE_LENIENCY) - 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. @@ -198,14 +212,17 @@ /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) . = ..() if (!(. & EMP_PROTECT_SELF)) switch_status(FALSE) - deductcharge(1000 / severity) + if(!iscyborg(loc)) + deductcharge(1000 / severity, TRUE, FALSE) //Makeshift stun baton. Replacement for stun gloves. /obj/item/melee/baton/cattleprod 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 b6473b8913..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 @@ -69,8 +70,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) @@ -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)