Files
CHOMPStation2/code/game/machinery/deployable.dm
Andrew e4deaa6478 Combat Mechs Can Punch More Things (#6303)
* Combat Mechs Can Punch More Things

Removes the var to check for the 5 things it can attack, instead it can punch anything (but not everything will take damage).

Gives punching objects a check so you don't accidently smash something without meaning to.

Gives closets and canisters a proc to take_damage so they'll actually get smashed by the mechs.

* Take_Damage Boogaloo

* More take_damage Stuff

Adds click delay on attacking barriers.
Proper noises when attacking material doors and barricades.

More stuff can be broken by mech punch and simple mobs.

* Adds changelong

* usr to user
2019-07-24 17:00:24 -04:00

251 lines
7.3 KiB
Plaintext

/*
CONTAINS:
Deployable items
Barricades
*/
//Barricades!
/obj/structure/barricade
name = "barricade"
desc = "This space is blocked off by a barricade."
icon = 'icons/obj/structures.dmi'
icon_state = "barricade"
anchored = 1.0
density = 1.0
var/health = 100
var/maxhealth = 100
var/material/material
/obj/structure/barricade/New(var/newloc, var/material_name)
..(newloc)
if(!material_name)
material_name = "wood"
material = get_material_by_name("[material_name]")
if(!material)
qdel(src)
return
name = "[material.display_name] barricade"
desc = "This space is blocked off by a barricade made of [material.display_name]."
color = material.icon_colour
maxhealth = material.integrity
health = maxhealth
/obj/structure/barricade/get_material()
return material
/obj/structure/barricade/attackby(obj/item/W as obj, mob/user as mob)
user.setClickCooldown(user.get_attack_speed(W))
if(istype(W, /obj/item/stack))
var/obj/item/stack/D = W
if(D.get_material_name() != material.name)
return //hitting things with the wrong type of stack usually doesn't produce messages, and probably doesn't need to.
if(health < maxhealth)
if(D.get_amount() < 1)
to_chat(user, "<span class='warning'>You need one sheet of [material.display_name] to repair \the [src].</span>")
return
visible_message("<span class='notice'>[user] begins to repair \the [src].</span>")
if(do_after(user,20) && health < maxhealth)
if(D.use(1))
health = maxhealth
visible_message("<span class='notice'>[user] repairs \the [src].</span>")
return
return
else
switch(W.damtype)
if("fire")
health -= W.force * 1
if("brute")
health -= W.force * 0.75
if(material == (get_material_by_name(MAT_WOOD) || get_material_by_name(MAT_SIFWOOD)))
playsound(loc, 'sound/effects/woodcutting.ogg', 100, 1)
else
playsound(src, 'sound/weapons/smash.ogg', 50, 1)
CheckHealth()
..()
/obj/structure/barricade/proc/CheckHealth()
if(health <= 0)
dismantle()
return
/obj/structure/barricade/take_damage(var/damage)
health -= damage
CheckHealth()
return
/obj/structure/barricade/attack_generic(var/mob/user, var/damage, var/attack_verb)
visible_message("<span class='danger'>[user] [attack_verb] the [src]!</span>")
if(material == get_material_by_name("resin"))
playsound(loc, 'sound/effects/attackblob.ogg', 100, 1)
else if(material == (get_material_by_name(MAT_WOOD) || get_material_by_name(MAT_SIFWOOD)))
playsound(loc, 'sound/effects/woodcutting.ogg', 100, 1)
else
playsound(src, 'sound/weapons/smash.ogg', 50, 1)
user.do_attack_animation(src)
health -= damage
CheckHealth()
return
/obj/structure/barricade/proc/dismantle()
material.place_dismantled_product(get_turf(src))
visible_message("<span class='danger'>\The [src] falls apart!</span>")
qdel(src)
return
/obj/structure/barricade/ex_act(severity)
switch(severity)
if(1.0)
dismantle()
if(2.0)
health -= 25
CheckHealth()
/obj/structure/barricade/CanPass(atom/movable/mover, turf/target)//So bullets will fly over and stuff.
if(istype(mover) && mover.checkpass(PASSTABLE))
return TRUE
return FALSE
//Actual Deployable machinery stuff
/obj/machinery/deployable
name = "deployable"
desc = "deployable"
icon = 'icons/obj/objects.dmi'
req_access = list(access_security)//I'm changing this until these are properly tested./N
/obj/machinery/deployable/barrier
name = "deployable barrier"
desc = "A deployable barrier. Swipe your ID card to lock/unlock it."
icon = 'icons/obj/objects.dmi'
anchored = 0.0
density = 1.0
icon_state = "barrier0"
var/health = 100.0
var/maxhealth = 100.0
var/locked = 0.0
// req_access = list(access_maint_tunnels)
/obj/machinery/deployable/barrier/New()
..()
icon_state = "barrier[locked]"
/obj/machinery/deployable/barrier/attackby(obj/item/weapon/W as obj, mob/user as mob)
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
if(istype(W, /obj/item/weapon/card/id/))
if(allowed(user))
if (emagged < 2.0)
locked = !locked
anchored = !anchored
icon_state = "barrier[locked]"
if((locked == 1.0) && (emagged < 2.0))
to_chat(user, "Barrier lock toggled on.")
return
else if((locked == 0.0) && (emagged < 2.0))
to_chat(user, "Barrier lock toggled off.")
return
else
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(2, 1, src)
s.start()
visible_message("<span class='warning'>BZZzZZzZZzZT</span>")
return
return
else if(W.is_wrench())
if(health < maxhealth)
health = maxhealth
emagged = 0
req_access = list(access_security)
visible_message("<span class='warning'>[user] repairs \the [src]!</span>")
return
else if(emagged > 0)
emagged = 0
req_access = list(access_security)
visible_message("<span class='warning'>[user] repairs \the [src]!</span>")
return
return
else
switch(W.damtype)
if("fire")
health -= W.force * 0.75
if("brute")
health -= W.force * 0.5
playsound(src, 'sound/weapons/smash.ogg', 50, 1)
CheckHealth()
..()
/obj/machinery/deployable/barrier/proc/CheckHealth()
if(health <= 0)
explode()
return
/obj/machinery/deployable/barrier/attack_generic(var/mob/user, var/damage, var/attack_verb)
visible_message("<span class='danger'>[user] [attack_verb] the [src]!</span>")
playsound(src, 'sound/weapons/smash.ogg', 50, 1)
user.do_attack_animation(src)
health -= damage
CheckHealth()
return
/obj/machinery/deployable/barrier/take_damage(var/damage)
health -= damage
CheckHealth()
return
/obj/machinery/deployable/barrier/ex_act(severity)
switch(severity)
if(1.0)
explode()
return
if(2.0)
health -= 25
CheckHealth()
return
/obj/machinery/deployable/barrier/emp_act(severity)
if(stat & (BROKEN|NOPOWER))
return
if(prob(50/severity))
locked = !locked
anchored = !anchored
icon_state = "barrier[locked]"
/obj/machinery/deployable/barrier/CanPass(atom/movable/mover, turf/target)//So bullets will fly over and stuff.
if(istype(mover) && mover.checkpass(PASSTABLE))
return TRUE
return FALSE
/obj/machinery/deployable/barrier/proc/explode()
visible_message("<span class='danger'>[src] blows apart!</span>")
var/turf/Tsec = get_turf(src)
/* var/obj/item/stack/rods/ =*/
new /obj/item/stack/rods(Tsec)
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(3, 1, src)
s.start()
explosion(src.loc,-1,-1,0)
if(src)
qdel(src)
/obj/machinery/deployable/barrier/emag_act(var/remaining_charges, var/mob/user)
if(emagged == 0)
emagged = 1
req_access.Cut()
req_one_access.Cut()
to_chat(user, "You break the ID authentication lock on \the [src].")
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(2, 1, src)
s.start()
visible_message("<span class='warning'>BZZzZZzZZzZT</span>")
return 1
else if(emagged == 1)
emagged = 2
to_chat(user, "You short out the anchoring mechanism on \the [src].")
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(2, 1, src)
s.start()
visible_message("<span class='warning'>BZZzZZzZZzZT</span>")
return 1