Merge pull request #8634 from Ghommie/Ghommie-cit46

fixes low-charge stunbatons & co.
This commit is contained in:
deathride58
2019-06-14 20:44:19 -04:00
committed by GitHub
3 changed files with 49 additions and 33 deletions
+42 -25
View File
@@ -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("<span class='suicide'>[user] is putting the live [name] in [user.p_their()] mouth! It looks like [user.p_theyre()] trying to commit suicide!</span>")
@@ -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, "<span class='notice'>\The [src] is [round(cell.percent())]% charged.</span>")
. = ..()
var/obj/item/stock_parts/cell/copper_top = get_cell()
if(copper_top)
to_chat(user, "<span class='notice'>\The [src] is [round(copper_top.percent())]% charged.</span>")
else
to_chat(user, "<span class='warning'>\The [src] does not have a power source installed.</span>")
@@ -92,7 +100,7 @@
if(cell)
to_chat(user, "<span class='notice'>[src] already has a cell.</span>")
else
if(C.maxcharge < hitcost * STUNBATON_CHARGE_LENIENCY)
if(C.maxcharge < (hitcost * STUNBATON_CHARGE_LENIENCY))
to_chat(user, "<span class='notice'>[src] requires a higher capacity cell.</span>")
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, "<span class='notice'>[src] is now [status ? "on" : "off"].</span>")
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, "<span class='warning'>[src] does not have a power source!</span>")
else
to_chat(user, "<span class='warning'>[src] is out of charge.</span>")
else
switch_status(!status)
to_chat(user, "<span class='notice'>[src] is now [status ? "on" : "off"].</span>")
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("<span class='warning'>[user] has prodded [L] with [src]. Luckily it was out of charge.</span>", \
"<span class='warning'>[user] has prodded you with [src]. Luckily it was out of charge.</span>")
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("<span class='danger'>[user] accidentally hits [user.p_them()]self with [src]!</span>", \
"<span class='userdanger'>You accidentally hit yourself with [src]!</span>")
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
+2 -3
View File
@@ -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("<span class='danger'>[user] accidentally hits [user.p_them()]self with [src]!</span>", \
"<span class='userdanger'>You accidentally hit yourself with [src]!</span>")
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
+5 -5
View File
@@ -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)