mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-25 22:12:58 +01:00
Refactoring and fixing bugs in animal traps (#6860)
refactor: "Traps have been refectored code-wise to work like chairs/beds. Hence eliminating craptons of bugs." Fixes #6667 spellcheck: "Fixed spelling in messages from traps."
This commit is contained in:
committed by
Erki
parent
7ecc8c7ce0
commit
c3382c9c14
@@ -143,6 +143,7 @@
|
||||
matter = list(DEFAULT_WALL_MATERIAL = 1750)
|
||||
deployed = 0
|
||||
time_to_escape = 3 // Minutes
|
||||
can_buckle = TRUE
|
||||
var/breakout = FALSE
|
||||
var/last_shake = 0
|
||||
var/list/allowed_mobs = list(/mob/living/simple_animal/rat, /mob/living/simple_animal/chick, /mob/living/simple_animal/lizard)
|
||||
@@ -152,26 +153,10 @@
|
||||
health = 100
|
||||
var/datum/weakref/captured = null
|
||||
|
||||
/obj/item/weapon/trap/animal/process()
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/trap/animal/update_icon()
|
||||
icon = initial(icon)
|
||||
icon_state = "[icon_base][deployed]"
|
||||
var/datum/L = captured ? captured.resolve() : null
|
||||
if (!L)
|
||||
deployed = FALSE
|
||||
captured = null
|
||||
release_time = world.time
|
||||
underlays.Cut()
|
||||
STOP_PROCESSING(SSprocessing, src)
|
||||
return
|
||||
if(isliving(L))
|
||||
var/mutable_appearance/MA = new(L)
|
||||
MA.layer = FLOAT_LAYER
|
||||
MA.plane = FLOAT_PLANE
|
||||
underlays.Cut()
|
||||
underlays += MA
|
||||
|
||||
/obj/item/weapon/trap/animal/examine(mob/user)
|
||||
..()
|
||||
@@ -179,23 +164,7 @@
|
||||
var/datum/L = captured.resolve()
|
||||
if (!L)
|
||||
return
|
||||
if (isliving(L))
|
||||
var/mob/living/ll = L
|
||||
var/message = "<span class='notice'>\The [src] has [ll] and it is "
|
||||
if(ll.stat == DEAD)
|
||||
message += "<span class='danger'>dead</span>"
|
||||
else if(ll == UNCONSCIOUS)
|
||||
message += "<span class='warning'>unconscious</span>"
|
||||
else if((ll.maxHealth / ll.health) == 1)
|
||||
message += "<span class='good'>healthy</span>"
|
||||
else
|
||||
message += "<span class='warning'>wounded</span>"
|
||||
message += ".</span>"
|
||||
to_chat(user, message)
|
||||
ll.examine(user)
|
||||
else if (istype(L, /obj/effect/spider/spiderling))
|
||||
var/obj/effect/spider/spiderling/S = L
|
||||
to_chat(user, "<span class='notice'>\The [src] has [S] and it is alive.</span>")
|
||||
to_chat(user, "<span class='notice'>\The [src] has [L].</span>")
|
||||
|
||||
else
|
||||
to_chat(user, "<span class='notice'>\The [src] is empty.</span>")
|
||||
@@ -215,26 +184,23 @@
|
||||
if(istype(AM, f))
|
||||
L.visible_message(
|
||||
"<span class='danger'>[L] enters \the [src], and it snaps shut with a clatter!</span>",
|
||||
"<span class='danger'>You enters \the [src], and it snaps shut with a clatter!</span>",
|
||||
"<span class='danger'>You enter \the [src], and it snaps shut with a clatter!</span>",
|
||||
"<b>You hear a loud metallic snap!</b>"
|
||||
)
|
||||
L.forceMove(src)
|
||||
captured = WEAKREF(L)
|
||||
playsound(src, 'sound/weapons/beartrap_shut.ogg', 100, 1)
|
||||
deployed = 1
|
||||
update_icon()
|
||||
buckle_mob(L)
|
||||
src.animate_shake()
|
||||
START_PROCESSING(SSprocessing, src)
|
||||
|
||||
else if(istype(AM, /obj/effect/spider/spiderling) && spider) // for spiderlings
|
||||
var/obj/effect/spider/spiderling/S = AM
|
||||
S.forceMove(src)
|
||||
captured = WEAKREF(S)
|
||||
STOP_PROCESSING(SSprocessing, S)
|
||||
playsound(src, 'sound/weapons/beartrap_shut.ogg', 100, 1)
|
||||
deployed = 1
|
||||
update_icon()
|
||||
buckle_mob(S)
|
||||
src.animate_shake()
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/trap/animal/proc/req_breakout()
|
||||
if(!deployed)
|
||||
@@ -255,13 +221,13 @@
|
||||
return TRUE
|
||||
|
||||
// If we are stuck, and need to get out
|
||||
/obj/item/weapon/trap/animal/proc/mob_breakout(var/mob/living/escapee)
|
||||
/obj/item/weapon/trap/animal/user_unbuckle_mob(var/mob/living/escapee)
|
||||
if (req_breakout() < 1)
|
||||
return
|
||||
|
||||
escapee.next_move = world.time + 100
|
||||
escapee.last_special = world.time + 100
|
||||
to_chat(escapee, "<span class='warning'>You to shake and bump the lock of \the [src]. (this will take about [time_to_escape] minutes).</span>")
|
||||
to_chat(escapee, "<span class='warning'>You begin to shake and bump the lock of \the [src]. (this will take about [time_to_escape] minutes).</span>")
|
||||
visible_message("<span class='danger'>\The [src] begins to shake violently! Something is attempting to escape it!</span>")
|
||||
|
||||
var/time = 360 * time_to_escape * 2
|
||||
@@ -275,8 +241,6 @@
|
||||
to_chat(escapee, "<span class='warning'>You successfully break out!</span>")
|
||||
visible_message("<span class='danger'>\the [escapee] successfully broke out of \the [src]!</span>")
|
||||
playsound(loc, "sound/effects/grillehit.ogg", 100, 1)
|
||||
if(!contents.len)
|
||||
return
|
||||
|
||||
release()
|
||||
|
||||
@@ -303,6 +267,8 @@
|
||||
if(!ishuman(usr))
|
||||
to_chat(usr, "<span class='warning'>This mob type can't use this verb.</span>")
|
||||
return
|
||||
|
||||
var/datum/M = captured ? captured.resolve() : null
|
||||
|
||||
if(deployed)
|
||||
var/open = alert("Do you want to open the cage and free what is inside?",,"No","Yes")
|
||||
@@ -314,13 +280,10 @@
|
||||
to_chat(usr, "<span class='warning'>You cannot use \the [src].</span>")
|
||||
return
|
||||
|
||||
if(usr in contents)
|
||||
if(usr == M)
|
||||
to_chat(usr, "<span class='warning'>You cannot open lock \the [src] from the inside. You would have to forcefully open it.</span>")
|
||||
return
|
||||
|
||||
if(!contents.len)
|
||||
return
|
||||
|
||||
var/turf/T_cage = get_turf(src)
|
||||
var/turf/T_user= get_turf(usr)
|
||||
|
||||
@@ -377,22 +340,17 @@
|
||||
deployed = FALSE
|
||||
captured = null
|
||||
release_time = world.time
|
||||
update_icon()
|
||||
STOP_PROCESSING(SSprocessing, src)
|
||||
return
|
||||
|
||||
var/msg
|
||||
if (isliving(L))
|
||||
var/mob/living/ll = L
|
||||
ll.forceMove(target)
|
||||
msg = "<span class='warning'>[ll] runs out of \the [src].</span>"
|
||||
STOP_PROCESSING(SSprocessing, src)
|
||||
else if (istype(L, /obj/effect/spider/spiderling))
|
||||
var/obj/effect/spider/spiderling/S = L
|
||||
S.forceMove(target)
|
||||
msg = "<span class='warning'>[S] jumps out of \the [src].</span>"
|
||||
START_PROCESSING(SSprocessing, L)
|
||||
|
||||
|
||||
unbuckle_mob()
|
||||
captured = null
|
||||
visible_message(msg)
|
||||
animate_shake()
|
||||
@@ -443,6 +401,20 @@
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/weapon/trap/animal/Move()
|
||||
..()
|
||||
if(captured)
|
||||
var/datum/M = captured.resolve()
|
||||
if(!M)
|
||||
captured = null
|
||||
return
|
||||
if(isliving(M))
|
||||
var/mob/living/L = M
|
||||
if(L && buckled_mob.buckled == src)
|
||||
L.forceMove(src.loc)
|
||||
else if(L)
|
||||
captured = null
|
||||
|
||||
/obj/item/weapon/trap/animal/attack_hand(mob/user as mob)
|
||||
|
||||
if (!user) return
|
||||
|
||||
@@ -660,9 +660,6 @@ default behaviour is:
|
||||
if( src.loc && istype(src.loc, /obj/structure/closet) )
|
||||
var/obj/structure/closet/C = loc
|
||||
spawn() C.mob_breakout(src)
|
||||
else if(src.loc && istype(src.loc, /obj/item/weapon/trap/animal))
|
||||
var/obj/item/weapon/trap/animal/A = loc
|
||||
spawn() A.mob_breakout(src)
|
||||
|
||||
/mob/living/proc/escape_inventory(obj/item/weapon/holder/H)
|
||||
if(H != src.loc) return
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
################################
|
||||
# Example Changelog File
|
||||
#
|
||||
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
|
||||
#
|
||||
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
|
||||
# When it is, any changes listed below will disappear.
|
||||
#
|
||||
# Valid Prefixes:
|
||||
# bugfix
|
||||
# wip (For works in progress)
|
||||
# tweak
|
||||
# soundadd
|
||||
# sounddel
|
||||
# rscadd (general adding of nice things)
|
||||
# rscdel (general deleting of nice things)
|
||||
# imageadd
|
||||
# imagedel
|
||||
# maptweak
|
||||
# spellcheck (typo fixes)
|
||||
# experiment
|
||||
# balance
|
||||
# admin
|
||||
# backend
|
||||
# security
|
||||
# refactor
|
||||
#################################
|
||||
|
||||
# Your name.
|
||||
author: PoZe
|
||||
|
||||
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
|
||||
delete-after: True
|
||||
|
||||
# Any changes you've made. See valid prefix list above.
|
||||
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
|
||||
# SCREW THIS UP AND IT WON'T WORK.
|
||||
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
|
||||
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
|
||||
changes:
|
||||
- refactor: "Traps have been refectored code-wise to work like chairs/beds. Hence eliminating craptons of bugs."
|
||||
- spellcheck: "Fixed spelling in messages from traps."
|
||||
Reference in New Issue
Block a user