Turrets now need to be linked to built turret controls using multiool. Map-placed ones autolink as before

Changes multitool buffer type to better reflect the use
This commit is contained in:
AnturK
2015-11-18 21:23:32 +01:00
parent 6c2cb63ff0
commit e93fc3c6d2
3 changed files with 50 additions and 29 deletions

View File

@@ -312,7 +312,10 @@
user << "<span class='notice'>Controls are now [locked ? "locked" : "unlocked"].</span>" user << "<span class='notice'>Controls are now [locked ? "locked" : "unlocked"].</span>"
else else
user << "<span class='notice'>Access denied.</span>" user << "<span class='notice'>Access denied.</span>"
else if(istype(I,/obj/item/device/multitool) && !locked)
var/obj/item/device/multitool/M = I
M.buffer = src
user << "<span class='notice'>You add [src] to multitool buffer.</span>"
else else
//if the turret was attacked with the intention of harming it: //if the turret was attacked with the intention of harming it:
user.changeNext_move(CLICK_CD_MELEE) user.changeNext_move(CLICK_CD_MELEE)
@@ -924,7 +927,10 @@
updateUsrDialog() updateUsrDialog()
else else
user << "<span class='notice'>Access denied.</span>" user << "<span class='notice'>Access denied.</span>"
else if(istype(I,/obj/item/device/multitool) && !Parent_Turret.locked)
var/obj/item/device/multitool/M = I
M.buffer = Parent_Turret
user << "<span class='notice'>You add [Parent_Turret] to multitool buffer.</span>"
else else
user.changeNext_move(CLICK_CD_MELEE) user.changeNext_move(CLICK_CD_MELEE)
Parent_Turret.health -= I.force * 0.5 Parent_Turret.health -= I.force * 0.5
@@ -992,38 +998,52 @@
var/enabled = 1 var/enabled = 1
var/lethal = 0 var/lethal = 0
var/locked = 1 var/locked = 1
var/control_area //can be area name, path or nothing. var/control_area = null //can be area name, path or nothing.
var/ailock = 0 // AI cannot use this var/ailock = 0 // AI cannot use this
req_access = list(access_ai_upload) req_access = list(access_ai_upload)
var/list/obj/machinery/porta_turret/turrets = list()
/obj/machinery/turretid/New(loc, ndir = 0, built = 0) /obj/machinery/turretid/New(loc, ndir = 0, built = 0)
..() ..()
if(!control_area)
var/area/CA = get_area(src)
if(CA.master && CA.master != CA)
control_area = CA.master
else
control_area = CA
else if(istext(control_area))
for(var/area/A in world)
if(A.name && A.name==control_area)
control_area = A
break
if(built) if(built)
dir = ndir dir = ndir
locked = 0 locked = 0
pixel_x = (dir & 3)? 0 : (dir == 4 ? -24 : 24) pixel_x = (dir & 3)? 0 : (dir == 4 ? -24 : 24)
pixel_y = (dir & 3)? (dir ==1 ? -24 : 24) : 0 pixel_y = (dir & 3)? (dir ==1 ? -24 : 24) : 0
power_change() //Checks power and initial settings power_change() //Checks power and initial settings
//don't have to check if control_area is path, since get_area_all_atoms can take path.
return return
/obj/machinery/turretid/attackby(obj/item/weapon/W, mob/user, params) /obj/machinery/turretid/initialize() //map-placed turrets autolink turrets
if(control_area && istext(control_area))
for(var/area/A in world)
if(A.name && A.name==control_area)
control_area = A
break
if(!control_area)
var/area/CA = get_area(src)
if(CA.master && CA.master != CA)
control_area = CA.master
else
control_area = CA
for(var/obj/machinery/porta_turret/T in get_area_all_atoms(control_area))
turrets |= T
/obj/machinery/turretid/attackby(obj/item/I, mob/user, params)
if(stat & BROKEN) return if(stat & BROKEN) return
if (istype(I,/obj/item/device/multitool))
var/obj/item/device/multitool/M = I
if(M.buffer && istype(M.buffer,/obj/machinery/porta_turret))
turrets |= M.buffer
user << "You link [M.buffer] with [src]"
return
if (istype(user, /mob/living/silicon)) if (istype(user, /mob/living/silicon))
return src.attack_hand(user) return src.attack_hand(user)
else if( get_dist(src, user) == 0 ) // trying to unlock the interface if( get_dist(src, user) == 0 ) // trying to unlock the interface
if (src.allowed(usr)) if (src.allowed(usr))
if(emagged) if(emagged)
user << "<span class='notice'>The turret control is unresponsive.</span>" user << "<span class='notice'>The turret control is unresponsive.</span>"
@@ -1110,9 +1130,8 @@
updateTurrets() updateTurrets()
/obj/machinery/turretid/proc/updateTurrets() /obj/machinery/turretid/proc/updateTurrets()
if(control_area) for (var/obj/machinery/porta_turret/aTurret in turrets)
for (var/obj/machinery/porta_turret/aTurret in get_area_all_atoms(control_area)) aTurret.setState(enabled, lethal)
aTurret.setState(enabled, lethal)
src.update_icon() src.update_icon()
/obj/machinery/turretid/power_change() /obj/machinery/turretid/power_change()

View File

@@ -94,8 +94,9 @@
dat += "<hr>" dat += "<hr>"
if(P) if(P)
if(P.buffer) var/obj/machinery/telecomms/T = P.buffer
dat += "<br><br>MULTITOOL BUFFER: [P.buffer] ([P.buffer.id]) <a href='?src=\ref[src];link=1'>\[Link\]</a> <a href='?src=\ref[src];flush=1'>\[Flush\]" if(T && istype(T))
dat += "<br><br>MULTITOOL BUFFER: [T] ([T.id]) <a href='?src=\ref[src];link=1'>\[Link\]</a> <a href='?src=\ref[src];flush=1'>\[Flush\]"
else else
dat += "<br><br>MULTITOOL BUFFER: <a href='?src=\ref[src];buffer=1'>\[Add Machine\]</a>" dat += "<br><br>MULTITOOL BUFFER: <a href='?src=\ref[src];buffer=1'>\[Add Machine\]</a>"
@@ -284,14 +285,15 @@
if(href_list["link"]) if(href_list["link"])
if(P) if(P)
if(P.buffer && P.buffer != src) var/obj/machinery/telecomms/T = P.buffer
if(!(src in P.buffer.links)) if(T && istype(T) && T != src)
P.buffer.links.Add(src) if(!(src in T.links))
T.links.Add(src)
if(!(P.buffer in src.links)) if(!(T in src.links))
src.links.Add(P.buffer) src.links.Add(T)
temp = "<font color = #666633>-% Successfully linked with \ref[P.buffer] [P.buffer.name] %-</font color>" temp = "<font color = #666633>-% Successfully linked with \ref[T] [T.name] %-</font color>"
else else
temp = "<font color = #666633>-% Unable to acquire buffer %-</font color>" temp = "<font color = #666633>-% Unable to acquire buffer %-</font color>"

View File

@@ -15,7 +15,7 @@
throw_speed = 3 throw_speed = 3
materials = list(MAT_METAL=50, MAT_GLASS=20) materials = list(MAT_METAL=50, MAT_GLASS=20)
origin_tech = "magnets=1;engineering=1" origin_tech = "magnets=1;engineering=1"
var/obj/machinery/telecomms/buffer // simple machine buffer for device linkage var/obj/machinery/buffer // simple machine buffer for device linkage
hitsound = 'sound/weapons/tap.ogg' hitsound = 'sound/weapons/tap.ogg'