Police tape overhaul

General purge of copypaste code

Framework for easier adding of new tape types
Now you only need two sprites of roll and sprites of tape length (H and V)
Define them in police_tape.dm

To show it off, engineering tape added, passable by engineers and atmos techs

Last but not least - ability to lift the tape, allowing passage for pretty much everything.
Done by those with access, attack by empty hand on help intent.
This commit is contained in:
unknown
2012-05-12 22:16:23 +03:00
parent 21f0783e90
commit 9efafd39bd
11 changed files with 134 additions and 171 deletions

View File

@@ -1,97 +1,89 @@
/obj/item/policetaperoll/attack_self(mob/user as mob)
if(icon_state == "rollstart")
tapestartx = src.loc.x
tapestarty = src.loc.y
tapestartz = src.loc.z
usr << "\blue You place the first end of the police tape."
icon_state = "rollstop"
/obj/item/taperoll/police
name = "police tape"
desc = "A roll of police tape used to block off crime scenes from the public."
icon_state = "police_start"
tape_type = /obj/item/tape/police
icon_base = "police"
/obj/item/tape/police
name = "police tape"
desc = "A length of police tape. Do not cross."
req_access = list(access_security)
icon_base = "police"
/obj/item/taperoll/engineering
name = "engineering tape"
desc = "A roll of engineering tape used to block off working areas from the public."
icon_state = "engineering_start"
tape_type = /obj/item/tape/engineering
icon_base = "engineering"
/obj/item/tape/engineering
name = "engineering tape"
desc = "A length of engineering tape. Better not cross it."
req_one_access = list(access_engine,access_atmospherics)
icon_base = "engineering"
/obj/item/taperoll/attack_self(mob/user as mob)
if(icon_state == "[icon_base]_start")
start = get_turf(src)
usr << "\blue You place the first end of the [src]."
icon_state = "[icon_base]_stop"
else
tapeendx = src.loc.x
tapeendy = src.loc.y
tapeendz = src.loc.z
icon_state = "[icon_base]_start"
end = get_turf(src)
if(start.y != end.y && start.x != end.x || start.z != end.z)
usr << "\blue [src] can only be laid horizontally or vertically."
var/turf/cur = start
var/dir
if (start.x == end.x)
var/d = end.y-start.y
if(d) d = d/abs(d)
end = get_turf(locate(end.x,end.y+d,end.z))
dir = "v"
else
var/d = end.x-start.x
if(d) d = d/abs(d)
end = get_turf(locate(end.x+d,end.y,end.z))
dir = "h"
while (cur!=end)
if(cur.density == 1)
usr << "\blue You can't run [src] through a wall!"
return
cur = get_step_towards(cur,end)
cur = start
var/tapetest = 0
if(tapestartx == tapeendx && tapestarty > tapeendy && tapestartz == tapeendz)
for(var/Y=tapestarty,Y>=tapeendy,Y--)
var/turf/T = get_turf(locate(tapestartx,Y,tapestartz))
if(T.density == 1)
usr << "\blue You can't run police tape through a wall!"
icon_state = "rollstart"
return
for(var/Y=tapestarty,Y>=tapeendy,Y--)
var/turf/T = get_turf(locate(tapestartx,Y,tapestartz))
for(var/obj/item/policetape/Ptest in T)
if(Ptest.icon_state == "vertical")
tapetest = 1
if(tapetest != 1)
var/obj/item/policetape/P = new/obj/item/policetape(tapestartx,Y,tapestartz)
P.loc = locate(tapestartx,Y,tapestartz)
P.icon_state = "vertical"
usr << "\blue You finish placing the police tape." //Git Test
while (cur!=end)
for(var/obj/item/tape/Ptest in cur)
if(Ptest.icon_state == "[Ptest.icon_base]_[dir]")
tapetest = 1
if(tapetest != 1)
var/obj/item/tape/P = new tape_type(cur)
P.icon_state = "[P.icon_base]_[dir]"
cur = get_step_towards(cur,end)
//is_blocked_turf(var/turf/T)
usr << "\blue You finish placing the [src]." //Git Test
if(tapestartx == tapeendx && tapestarty < tapeendy && tapestartz == tapeendz)
for(var/Y=tapestarty,Y<=tapeendy,Y++)
var/turf/T = get_turf(locate(tapestartx,Y,tapestartz))
if(T.density == 1)
usr << "\blue You can't run police tape through a wall!"
icon_state = "rollstart"
return
for(var/Y=tapestarty,Y<=tapeendy,Y++)
var/turf/T = get_turf(locate(tapestartx,Y,tapestartz))
for(var/obj/item/policetape/Ptest in T)
if(Ptest.icon_state == "vertical")
tapetest = 1
if(tapetest != 1)
var/obj/item/policetape/P = new/obj/item/policetape(tapestartx,Y,tapestartz)
P.loc = locate(tapestartx,Y,tapestartz)
P.icon_state = "vertical"
usr << "\blue You finish placing the police tape."
/obj/item/taperoll/police/afterattack(var/atom/A, mob/user as mob)
if (istype(A, /obj/machinery/door/airlock))
var/turf/T = get_turf(A)
var/obj/item/tape/P = new tape_type(T.x,T.y,T.z)
P.loc = locate(T.x,T.y,T.z)
P.icon_state = "door"
P.layer = 3.2
user << "\blue You finish placing the [src]."
if(tapestarty == tapeendy && tapestartx > tapeendx && tapestartz == tapeendz)
for(var/X=tapestartx,X>=tapeendx,X--)
var/turf/T = get_turf(locate(X,tapestarty,tapestartz))
if(T.density == 1)
usr << "\blue You can't run police tape through a wall!"
icon_state = "rollstart"
return
for(var/X=tapestartx,X>=tapeendx,X--)
var/turf/T = get_turf(locate(X,tapestarty,tapestartz))
for(var/obj/item/policetape/Ptest in T)
if(Ptest.icon_state == "horizontal")
tapetest = 1
if(tapetest != 1)
var/obj/item/policetape/P = new/obj/item/policetape(X,tapestarty,tapestartz)
P.loc = locate(X,tapestarty,tapestartz)
P.icon_state = "horizontal"
usr << "\blue You finish placing the police tape."
if(tapestarty == tapeendy && tapestartx < tapeendx && tapestartz == tapeendz)
for(var/X=tapestartx,X<=tapeendx,X++)
var/turf/T = get_turf(locate(X,tapestarty,tapestartz))
if(T.density == 1)
usr << "\blue You can't run police tape through a wall!"
icon_state = "rollstart"
return
for(var/X=tapestartx,X<=tapeendx,X++)
var/turf/T = get_turf(locate(X,tapestarty,tapestartz))
for(var/obj/item/policetape/Ptest in T)
if(Ptest.icon_state == "horizontal")
tapetest = 1
if(tapetest != 1)
var/obj/item/policetape/P = new/obj/item/policetape(X,tapestarty,tapestartz)
P.loc = locate(X,tapestarty,tapestartz)
P.icon_state = "horizontal"
usr << "\blue You finish placing the police tape."
if(tapestarty != tapeendy && tapestartx != tapeendx)
usr << "\blue Police tape can only be laid horizontally or vertically."
icon_state = "rollstart"
/obj/item/policetape/Bumped(M as mob)
/obj/item/tape/Bumped(M as mob)
if(src.allowed(M))
var/turf/T = get_turf(src)
M:loc = T
/obj/item/policetape/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
/obj/item/tape/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
if(!density) return 1
if(air_group || (height==0)) return 1
if ((mover.flags & 2 || istype(mover, /obj/effect/meteor) || mover.throwing == 1) )
@@ -99,78 +91,48 @@
else
return 0
/obj/item/policetape/attackby(obj/item/weapon/W as obj, mob/user as mob)
/obj/item/tape/attackby(obj/item/weapon/W as obj, mob/user as mob)
breaktape(W, user)
/obj/item/policetape/attack_hand(mob/user as mob)
breaktape(null, user)
/obj/item/tape/attack_hand(mob/user as mob)
if (user.a_intent == "help" && src.allowed(user))
user.show_viewers("\blue [user] lifts [src], allowing passage.")
src.density = 0
spawn(200)
src.density = 1
else
breaktape(null, user)
/obj/item/policetape/attack_paw(mob/user as mob)
/obj/item/tape/attack_paw(mob/user as mob)
breaktape(/obj/item/weapon/wirecutters,user)
/obj/item/policetape/proc/breaktape(obj/item/weapon/W as obj, mob/user as mob)
/obj/item/tape/proc/breaktape(obj/item/weapon/W as obj, mob/user as mob)
if(user.a_intent == "help" && ((!is_sharp(W) && src.allowed(user)) ||(!is_cut(W) && !src.allowed(user))))
user << "You can't break the tape with that!"
user << "You can't break the [src] with that!"
return
user.show_viewers(text("\blue [] breaks the police tape!", user))
var/OX = src.x
var/OY = src.y
if(src.icon_state == "horizontal")
user.show_viewers("\blue [user] breaks the [src]!")
var/dir[2]
var/icon_dir = src.icon_state
if(icon_dir == "[src.icon_base]_h")
dir[1] = EAST
dir[2] = WEST
if(icon_dir == "[src.icon_base]_v")
dir[1] = NORTH
dir[2] = SOUTH
for(var/i=1;i<3;i++)
var/N = 0
var/X = OX + 1
var/turf/T = src.loc
var/turf/cur = get_step(src,dir[i])
while(N != 1)
N = 1
T = locate(X,T.y,T.z)
for (var/obj/item/policetape/P in T)
N = 0
if(P.icon_state == "horizontal")
for (var/obj/item/tape/P in cur)
if(P.icon_state == icon_dir)
N = 0
del(P)
X += 1
X = OX - 1
N = 0
while(N != 1)
N = 1
T = locate(X,T.y,T.z)
for (var/obj/item/policetape/P in T)
N = 0
if(P.icon_state == "horizontal")
del(P)
X -= 1
if(src.icon_state == "vertical")
var/N = 0
var/Y = OY + 1
var/turf/T = src.loc
while(N != 1)
N = 1
T = locate(T.x,Y,T.z)
for (var/obj/item/policetape/P in T)
N = 0
if(P.icon_state == "vertical")
del(P)
Y += 1
Y = OY - 1
N = 0
while(N != 1)
N = 1
T = locate(T.x,Y,T.z)
for (var/obj/item/policetape/P in T)
N = 0
if(P.icon_state == "vertical")
del(P)
Y -= 1
cur = get_step(cur,dir[i])
del(src)
return
/obj/item/policetaperoll/afterattack(var/atom/A, mob/user as mob)
if (istype(A, /obj/machinery/door/airlock))
var/turf/T = get_turf(A)
var/obj/item/policetape/P = new/obj/item/policetape(T.x,T.y,T.z)
P.loc = locate(T.x,T.y,T.z)
P.icon_state = "door"
P.layer = 3.2
user << "\blue You finish placing the police tape."