Files
kiwistation/code/game/objects/items/weapons/handcuffs.dm
T
phil235 5f835bfc26 Obj damaging system, acid damage, and fire damage refactor (WIP) (#20793)
Please refer to #20867 and #20870 for a easier view of the changes. Those two PRs show all meaningful changes (hopefully) and doesn't show the files changed with just 3 lines changed.

This PR does three things:

    It makes all children of /obj/ use the same damage system.
    Previously to make your new machine/structure be destroyable you needed to give it a var/health, and its own version of many damage related proc such as bullet_act(), take_damage(), attacked_by(), attack_animal(), attack_hulk(), ex_act(), etc... But now, all /obj/ use the same version of those procs at the /obj/ level in code/game/obj_defense.dm. All these obj share the same necessary vars: obj_integrity (health), max_integrity, integrity_failure (optional, below that health level failure happens), and the armor list var which was previously only for items, as well as the resistance_flags bitfield. When you want your new object to be destroyable, you only have to give it a value for those vars and maybe override one proc if you want a special behavior but that's it. This reorganization removes a lot of copypasta (most bullet_act() version for each obj were nearly identical). Two new elements are added to the armor list var: fire and acid armor values.
    How much damage an obj take depends on the armor value for each damage category. But some objects are INDESTRUCTIBLE and simply never take any damage no matter the type.
    The armor categories are:
    -melee(punches, item attacks, xeno/animal/hulk attacks, blob attacks, thrown weapons)
    -bullet
    -laser
    -energy (used by projectiles like ionrifle, taser, and also by EMPs)
    -bio (unused for this, only here because clothes use them when worn)
    -rad (same)
    -bomb (self-explanatory)
    -fire (for fire damage, not for heat damage though)
    -acid
    For machines and structures, when their health reaches zero the object is not just deleted but gets somewhat forcedeconstructed (the proc used is shared with the actual deconstruction system) which can drops things. To not frustrates players most of these objects drop most of the elements necessary to rebuild them (think window dropping shards). Machines drop a machine frame and all components for example (but the frame can then be itself smashed to pieces).
    For clothes, when they are damaged, they get a "damaged" overlay, which can also be seen when worn, similar to the "bloody" overlay.

    It refactors acid. See #20537.
    Some objects are ACID_PROOF and take no damage from acid, while others take varying amounts
    of damage depending on their acid armor value. Some objects are even UNACIDABLE, no acid effect can even land on them. Acid on objects can be washed off using water.

    It changes some aspect of damage from fires.
    All /obj/ can now take fire damage and be flammable, instead of just items. And instead of having just FLAMMABLE objs that become ON_FIRE as soon as some fire touch them (paper), we now have objects that are non flammable but do take damage from fire and become ashes if their health reaches zero (only for items). The damage taken varies depending on the obj's fire armor value and total health. There's also still obj and items that are FIRE_PROOF (although some might still be melted by lava if they're not LAVA_PROOF).
    When a mob is on fire, its clothes now take fire damage and can turn to ashes. Similarly, when a mob takes melee damages, its clothes gets damaged a bit and can turn to shreds. You can repair clothes with cloth that is produceable by botany's biogenerator.

    It also does many minor things:
        Clicking a structure/machine with an item on help intent never results in an attack (so you don't destroy a structure while trying to figure out which tool to use).
        I moved a lot of objects away from /obj/effect, it should only be used for visual effects, decals and stuff, not for things you can hit and destroy.
        I tweaked a bit how clothes shredding from bombs work.
        I made a machine or structure un/anchorable with the wrench, I don't remember which object...
        Since I changed the meaning of the FIRE_PROOF bitflag to actually mean fire immune, I'm buffing the slime extract that you apply on items to make them fire proof. well now they're really 100% fire proof!
        animals with environment_smash = 1 no longer one-hit destroy tables and stuff, we give them a decent obj_damage value so they can destroy most obj relatively fast depending on the animal.
        Probably a million things I forgot.

If you want to know how the damage system works all you need is the three obj vars "obj_integrity", "max_integrity", "integrity_failure", as well as the armor list var and the resistance_flags bitfield, and read the file obj_defense.dm
2016-10-10 11:14:59 +13:00

364 lines
12 KiB
Plaintext

/obj/item/weapon/restraints
breakouttime = 600
//Handcuffs
/obj/item/weapon/restraints/handcuffs
name = "handcuffs"
desc = "Use this to keep prisoners in line."
gender = PLURAL
icon = 'icons/obj/items.dmi'
icon_state = "handcuff"
flags = CONDUCT
slot_flags = SLOT_BELT
throwforce = 0
w_class = 2
throw_speed = 3
throw_range = 5
materials = list(MAT_METAL=500)
origin_tech = "engineering=3;combat=3"
breakouttime = 600 //Deciseconds = 60s = 1 minute
armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0, fire = 50, acid = 50)
var/cuffsound = 'sound/weapons/handcuffs.ogg'
var/trashtype = null //for disposable cuffs
/obj/item/weapon/restraints/handcuffs/attack(mob/living/carbon/C, mob/living/carbon/human/user)
if(!istype(C))
return
if(user.disabilities & CLUMSY && prob(50))
user << "<span class='warning'>Uh... how do those things work?!</span>"
apply_cuffs(user,user)
return
if(!C.handcuffed)
if(C.get_num_arms() >= 2 || C.get_arm_ignore())
C.visible_message("<span class='danger'>[user] is trying to put [src.name] on [C]!</span>", \
"<span class='userdanger'>[user] is trying to put [src.name] on [C]!</span>")
playsound(loc, cuffsound, 30, 1, -2)
if(do_mob(user, C, 30) && (C.get_num_arms() >= 2 || C.get_arm_ignore()))
apply_cuffs(C,user)
user << "<span class='notice'>You handcuff [C].</span>"
if(istype(src, /obj/item/weapon/restraints/handcuffs/cable))
feedback_add_details("handcuffs","C")
else
feedback_add_details("handcuffs","H")
add_logs(user, C, "handcuffed")
else
user << "<span class='warning'>You fail to handcuff [C]!</span>"
else
user << "<span class='warning'>[C] doesn't have two hands...</span>"
/obj/item/weapon/restraints/handcuffs/proc/apply_cuffs(mob/living/carbon/target, mob/user, var/dispense = 0)
if(target.handcuffed)
return
if(!user.drop_item() && !dispense)
return
var/obj/item/weapon/restraints/handcuffs/cuffs = src
if(trashtype)
cuffs = new trashtype()
else if(dispense)
cuffs = new type()
cuffs.loc = target
target.handcuffed = cuffs
target.update_handcuffed()
if(trashtype && !dispense)
qdel(src)
return
/obj/item/weapon/restraints/handcuffs/sinew
name = "sinew restraints"
desc = "A pair of restraints fashioned from long strands of flesh."
icon = 'icons/obj/mining.dmi'
icon_state = "sinewcuff"
item_state = "sinewcuff"
breakouttime = 300 //Deciseconds = 30s
cuffsound = 'sound/weapons/cablecuff.ogg'
/obj/item/weapon/restraints/handcuffs/cable
name = "cable restraints"
desc = "Looks like some cables tied together. Could be used to tie something up."
icon_state = "cuff_red"
item_state = "coil_red"
materials = list(MAT_METAL=150, MAT_GLASS=75)
origin_tech = "engineering=2"
breakouttime = 300 //Deciseconds = 30s
cuffsound = 'sound/weapons/cablecuff.ogg'
var/datum/robot_energy_storage/wirestorage = null
/obj/item/weapon/restraints/handcuffs/cable/attack(mob/living/carbon/C, mob/living/carbon/human/user)
if(!istype(C))
return
if(wirestorage && wirestorage.energy < 15)
user << "<span class='warning'>You need at least 15 wire to restrain [C]!</span>"
return
return ..()
/obj/item/weapon/restraints/handcuffs/cable/apply_cuffs(mob/living/carbon/target, mob/user, var/dispense = 0)
if(wirestorage)
if(!wirestorage.use_charge(15))
user << "<span class='warning'>You need at least 15 wire to restrain [target]!</span>"
return
return ..(target, user, 1)
return ..()
/obj/item/weapon/restraints/handcuffs/cable/red
icon_state = "cuff_red"
item_state = "coil_red"
/obj/item/weapon/restraints/handcuffs/cable/yellow
icon_state = "cuff_yellow"
item_state = "coil_yellow"
/obj/item/weapon/restraints/handcuffs/cable/blue
icon_state = "cuff_blue"
item_state = "coil_blue"
/obj/item/weapon/restraints/handcuffs/cable/green
icon_state = "cuff_green"
item_state = "coil_green"
/obj/item/weapon/restraints/handcuffs/cable/pink
icon_state = "cuff_pink"
item_state = "coil_pink"
/obj/item/weapon/restraints/handcuffs/cable/orange
icon_state = "cuff_orange"
item_state = "coil_orange"
/obj/item/weapon/restraints/handcuffs/cable/cyan
icon_state = "cuff_cyan"
item_state = "coil_cyan"
/obj/item/weapon/restraints/handcuffs/cable/white
icon_state = "cuff_white"
item_state = "coil_white"
/obj/item/weapon/restraints/handcuffs/alien
icon_state = "handcuffAlien"
/obj/item/weapon/restraints/handcuffs/fake
name = "fake handcuffs"
desc = "Fake handcuffs meant for gag purposes."
breakouttime = 10 //Deciseconds = 1s
/obj/item/weapon/restraints/handcuffs/fake/kinky
name = "kinky handcuffs"
desc = "Fake handcuffs meant for erotic roleplay."
icon_state = "handcuffGag"
/obj/item/weapon/restraints/handcuffs/cable/attackby(obj/item/I, mob/user, params)
..()
if(istype(I, /obj/item/stack/rods))
var/obj/item/stack/rods/R = I
if (R.use(1))
var/obj/item/weapon/wirerod/W = new /obj/item/weapon/wirerod
if(!remove_item_from_storage(user))
user.unEquip(src)
user.put_in_hands(W)
user << "<span class='notice'>You wrap the cable restraint around the top of the rod.</span>"
qdel(src)
else
user << "<span class='warning'>You need one rod to make a wired rod!</span>"
return
else if(istype(I, /obj/item/stack/sheet/metal))
var/obj/item/stack/sheet/metal/M = I
if(M.get_amount() < 6)
user << "<span class='warning'>You need at least six metal sheets to make good enough weights!</span>"
return
user << "<span class='notice'>You begin to apply [I] to [src]...</span>"
if(do_after(user, 35, target = src))
if(M.get_amount() < 6 || !M)
return
var/obj/item/weapon/restraints/legcuffs/bola/S = new /obj/item/weapon/restraints/legcuffs/bola
M.use(6)
user.put_in_hands(S)
user << "<span class='notice'>You make some weights out of [I] and tie them to [src].</span>"
if(!remove_item_from_storage(user))
user.unEquip(src)
qdel(src)
else
return ..()
/obj/item/weapon/restraints/handcuffs/cable/zipties/cyborg/attack(mob/living/carbon/C, mob/user)
if(iscyborg(user))
if(!C.handcuffed)
playsound(loc, 'sound/weapons/cablecuff.ogg', 30, 1, -2)
C.visible_message("<span class='danger'>[user] is trying to put zipties on [C]!</span>", \
"<span class='userdanger'>[user] is trying to put zipties on [C]!</span>")
if(do_mob(user, C, 30))
if(!C.handcuffed)
C.handcuffed = new /obj/item/weapon/restraints/handcuffs/cable/zipties/used(C)
C.update_handcuffed()
user << "<span class='notice'>You handcuff [C].</span>"
add_logs(user, C, "handcuffed")
else
user << "<span class='warning'>You fail to handcuff [C]!</span>"
/obj/item/weapon/restraints/handcuffs/cable/zipties
name = "zipties"
desc = "Plastic, disposable zipties that can be used to restrain temporarily but are destroyed after use."
icon_state = "cuff_white"
item_state = "coil_white"
materials = list()
breakouttime = 450 //Deciseconds = 45s
trashtype = /obj/item/weapon/restraints/handcuffs/cable/zipties/used
/obj/item/weapon/restraints/handcuffs/cable/zipties/used
desc = "A pair of broken zipties."
icon_state = "cuff_white_used"
/obj/item/weapon/restraints/handcuffs/cable/zipties/used/attack()
return
//Legcuffs
/obj/item/weapon/restraints/legcuffs
name = "leg cuffs"
desc = "Use this to keep prisoners in line."
gender = PLURAL
icon = 'icons/obj/items.dmi'
icon_state = "handcuff"
flags = CONDUCT
throwforce = 0
w_class = 3
origin_tech = "engineering=3;combat=3"
slowdown = 7
breakouttime = 300 //Deciseconds = 30s = 0.5 minute
/obj/item/weapon/restraints/legcuffs/beartrap
name = "bear trap"
throw_speed = 1
throw_range = 1
icon_state = "beartrap"
desc = "A trap used to catch bears and other legged creatures."
origin_tech = "engineering=4"
var/armed = 0
var/trap_damage = 20
/obj/item/weapon/restraints/legcuffs/beartrap/New()
..()
icon_state = "[initial(icon_state)][armed]"
/obj/item/weapon/restraints/legcuffs/beartrap/suicide_act(mob/user)
user.visible_message("<span class='suicide'>[user] is sticking \his head in the [src.name]! It looks like \he's trying to commit suicide.</span>")
playsound(loc, 'sound/weapons/bladeslice.ogg', 50, 1, -1)
return (BRUTELOSS)
/obj/item/weapon/restraints/legcuffs/beartrap/attack_self(mob/user)
..()
if(ishuman(user) && !user.stat && !user.restrained())
armed = !armed
icon_state = "[initial(icon_state)][armed]"
user << "<span class='notice'>[src] is now [armed ? "armed" : "disarmed"]</span>"
/obj/item/weapon/restraints/legcuffs/beartrap/Crossed(AM as mob|obj)
if(armed && isturf(src.loc))
if(isliving(AM))
var/mob/living/L = AM
var/snap = 0
var/def_zone = "chest"
if(iscarbon(L))
var/mob/living/carbon/C = L
snap = 1
if(!C.lying)
def_zone = pick("l_leg", "r_leg")
if(!C.legcuffed && C.get_num_legs() >= 2) //beartrap can't cuff your leg if there's already a beartrap or legcuffs, or you don't have two legs.
C.legcuffed = src
src.loc = C
C.update_inv_legcuffed()
feedback_add_details("handcuffs","B") //Yes, I know they're legcuffs. Don't change this, no need for an extra variable. The "B" is used to tell them apart.
else if(isanimal(L))
var/mob/living/simple_animal/SA = L
if(!SA.flying && SA.mob_size > MOB_SIZE_TINY)
snap = 1
if(snap)
armed = 0
icon_state = "[initial(icon_state)][armed]"
playsound(src.loc, 'sound/effects/snap.ogg', 50, 1)
L.visible_message("<span class='danger'>[L] triggers \the [src].</span>", \
"<span class='userdanger'>You trigger \the [src]!</span>")
L.apply_damage(trap_damage,BRUTE, def_zone)
..()
/obj/item/weapon/restraints/legcuffs/beartrap/energy
name = "energy snare"
armed = 1
icon_state = "e_snare"
trap_damage = 0
flags = DROPDEL
/obj/item/weapon/restraints/legcuffs/beartrap/energy/New()
..()
addtimer(src, "dissipate", 100)
/obj/item/weapon/restraints/legcuffs/beartrap/energy/proc/dissipate()
if(!istype(loc, /mob))
var/datum/effect_system/spark_spread/sparks = new /datum/effect_system/spark_spread
sparks.set_up(1, 1, src)
sparks.start()
qdel(src)
/obj/item/weapon/restraints/legcuffs/beartrap/energy/attack_hand(mob/user)
Crossed(user) //honk
/obj/item/weapon/restraints/legcuffs/beartrap/energy/cyborg
breakouttime = 20 // Cyborgs shouldn't have a strong restraint
/obj/item/weapon/restraints/legcuffs/bola
name = "bola"
desc = "A restraining device designed to be thrown at the target. Upon connecting with said target, it will wrap around their legs, making it difficult for them to move quickly."
icon_state = "bola"
breakouttime = 35//easy to apply, easy to break out of
gender = NEUTER
origin_tech = "engineering=3;combat=1"
var/weaken = 0
/obj/item/weapon/restraints/legcuffs/bola/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0)
if(!..())
return
playsound(src.loc,'sound/weapons/bolathrow.ogg', 75, 1)
/obj/item/weapon/restraints/legcuffs/bola/throw_impact(atom/hit_atom)
if(..() || !iscarbon(hit_atom))//if it gets caught or the target can't be cuffed,
return//abort
var/mob/living/carbon/C = hit_atom
if(!C.legcuffed && C.get_num_legs() >= 2)
visible_message("<span class='danger'>\The [src] ensnares [C]!</span>")
C.legcuffed = src
src.loc = C
C.update_inv_legcuffed()
feedback_add_details("handcuffs","B")
C << "<span class='userdanger'>\The [src] ensnares you!</span>"
C.Weaken(weaken)
/obj/item/weapon/restraints/legcuffs/bola/tactical//traitor variant
name = "reinforced bola"
desc = "A strong bola, made with a long steel chain. It looks heavy, enough so that it could trip somebody."
icon_state = "bola_r"
breakouttime = 70
origin_tech = "engineering=4;combat=3"
weaken = 1
/obj/item/weapon/restraints/legcuffs/bola/energy //For Security
name = "energy bola"
desc = "A specialized hard-light bola designed to ensnare fleeing criminals and aid in arrests."
icon_state = "ebola"
hitsound = 'sound/weapons/taserhit.ogg'
w_class = 2
breakouttime = 60
/obj/item/weapon/restraints/legcuffs/bola/energy/throw_impact(atom/hit_atom)
if(iscarbon(hit_atom))
var/obj/item/weapon/restraints/legcuffs/beartrap/B = new /obj/item/weapon/restraints/legcuffs/beartrap/energy/cyborg(get_turf(hit_atom))
B.Crossed(hit_atom)
qdel(src)
..()