-Brain radio MMIs were fixed, they wouldn't broadcast the MMI's message.

-Fixed a bug where you couldn't talk into intercoms while it is dark.
-AIs can now type in the "track with camera" verb and get a list of names to show up. This can save time if the AI needs to track an individual.
-Deleted the old AI move.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4910 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
giacomand@gmail.com
2012-10-18 16:16:29 +00:00
parent ecad5024c3
commit 2f68d2cd48
9 changed files with 364 additions and 131 deletions
+64 -50
View File
@@ -1,25 +1,56 @@
/mob/living/silicon/ai/proc/ai_camera_list()
/mob/living/silicon/ai/proc/get_camera_list()
if(src.stat == 2)
return
var/list/L = list()
for (var/obj/machinery/camera/C in cameranet.cameras)
L.Add(C)
camera_sort(L)
var/list/T = list()
T["Cancel"] = "Cancel"
for (var/obj/machinery/camera/C in L)
if (C.network == src.network)
T[text("[][]", C.c_tag, (C.can_use() ? null : " (Deactivated)"))] = C
track = new()
track.cameras = T
return T
/mob/living/silicon/ai/proc/ai_camera_list(var/camera in get_camera_list())
set category = "AI Commands"
set name = "Show Camera List"
if(usr.stat == 2)
usr << "You can't track with camera because you are dead!"
if(src.stat == 2)
src << "You can't list the cameras because you are dead!"
return
attack_ai(src)
if (!camera || camera == "Cancel")
return 0
/mob/living/silicon/ai/proc/ai_camera_track()
set category = "AI Commands"
set name = "Track With Camera"
if(usr.stat == 2)
usr << "You can't track with camera because you are dead!"
return
var/obj/machinery/camera/C = track.cameras[camera]
track = null
src.eyeobj.setLoc(C)
return
// Used to allow the AI is write in mob names/camera name from the CMD line.
/datum/trackable
var/list/names = list()
var/list/namecounts = list()
var/list/humans = list()
var/list/others = list()
var/list/cameras = list()
/mob/living/silicon/ai/proc/trackable_mobs()
if(usr.stat == 2)
return list()
var/datum/trackable/TB = new()
for(var/mob/living/M in mob_list)
// Easy checks first.
// Don't detect mobs on Centcom. Since the wizard den is on Centcomm, we only need this.
@@ -55,25 +86,34 @@
continue
var/name = M.name
if (name in names)
namecounts[name]++
name = text("[] ([])", name, namecounts[name])
if (name in TB.names)
TB.namecounts[name]++
name = text("[] ([])", name, TB.namecounts[name])
else
names.Add(name)
namecounts[name] = 1
TB.names.Add(name)
TB.namecounts[name] = 1
if(human)
humans[name] = M
TB.humans[name] = M
else
others[name] = M
TB.others[name] = M
var/list/targets = sortList(humans) + sortList(others)
var/target_name = input(usr, "Which creature should you track?") as null|anything in targets
var/list/targets = sortList(TB.humans) + sortList(TB.others)
src.track = TB
return targets
if (!target_name)
usr:cameraFollow = null
/mob/living/silicon/ai/proc/ai_camera_track(var/target_name in trackable_mobs())
set category = "AI Commands"
set name = "Track With Camera"
set desc = "Select who you would like to track."
if(src.stat == 2)
src << "You can't track with camera because you are dead!"
return
if(!target_name)
src.cameraFollow = null
var/mob/target = (isnull(humans[target_name]) ? others[target_name] : humans[target_name])
var/mob/target = (isnull(track.humans[target_name]) ? track.others[target_name] : track.humans[target_name])
src.track = null
ai_actual_track(target)
/mob/living/silicon/ai/proc/ai_actual_track(mob/living/target as mob)
@@ -121,7 +161,7 @@
return
sleep(10)
/proc/near_camera(var/mob/M)
/proc/near_camera(var/mob/living/M)
if (!isturf(M.loc))
return 0
if(isrobot(M))
@@ -141,33 +181,7 @@
/mob/living/silicon/ai/attack_ai(var/mob/user as mob)
if (user != src)
return
if (stat == 2)
return
var/list/L = list()
for (var/obj/machinery/camera/C in cameranet.cameras)
L.Add(C)
camera_sort(L)
var/list/D = list()
D["Cancel"] = "Cancel"
for (var/obj/machinery/camera/C in L)
if (C.network == src.network)
D[text("[][]", C.c_tag, (C.can_use() ? null : " (Deactivated)"))] = C
var/t = input(user, "Which camera should you change to?") as null|anything in D
if (!t || t == "Cancel")
return 0
var/obj/machinery/camera/C = D[t]
src.eyeobj.setLoc(C)
return
ai_camera_list()
/proc/camera_sort(list/L)
var/obj/machinery/camera/a
+5 -3
View File
@@ -10,6 +10,8 @@
return
else
message = Gibberish(message, (emp_damage*6))//scrambles the message, gets worse when emp_damage is higher
..()
else
..()
if(istype(container, /obj/item/device/mmi/radio_enabled))
var/obj/item/device/mmi/radio_enabled/R = container
if(R.radio)
spawn(0) R.radio.hear_talk(src, message)
..()
+4 -3
View File
@@ -280,7 +280,7 @@ var/list/department_radio_keys = list(
listening|=M
var/turf/T = get_turf(src)
var/list/W = view(message_range, T)
var/list/W = hear(message_range, T)
for (var/obj/O in ((W | contents)-used_radios))
W |= O
@@ -311,12 +311,13 @@ var/list/department_radio_keys = list(
if (O)
O.hear_talk(src, message)
*/
if(isbrain(src))//For brains to properly talk if they are in an MMI..or in a brain. Could be extended to other mobs I guess.
/* if(isbrain(src))//For brains to properly talk if they are in an MMI..or in a brain. Could be extended to other mobs I guess.
for(var/obj/O in loc)//Kinda ugly but whatever.
if(O)
spawn(0)
O.hear_talk(src, message)
*/
var/list/heard_a = list() // understood us
+1
View File
@@ -41,6 +41,7 @@
var/mob/living/silicon/ai/parent = null
var/camera_light_on = 0 //Defines if the AI toggled the light on the camera it's looking through.
var/datum/trackable/track = null
/mob/living/silicon/ai/New(loc, var/datum/ai_laws/L, var/obj/item/device/mmi/B, var/safety = 0)
var/list/possibleNames = ai_names
@@ -124,8 +124,6 @@
/datum/camerachunk/New(loc, x, y, z)
set background = 1
// 0xf = 15
x &= ~0xf
y &= ~0xf
@@ -94,7 +94,7 @@
// This will move the AIEye. It will also cause lights near the eye to light up, if toggled.
// This is handled in the proc below this one.
/client/AIMove(n, direct, var/mob/living/silicon/ai/user)
/client/proc/AIMove(n, direct, var/mob/living/silicon/ai/user)
var/initial = initial(user.sprint)
var/max_sprint = 50
@@ -1,71 +0,0 @@
/var/const/SHARED_TYPES_WEIGHT = 5
/var/const/CAMERA_PROXIMITY_PREFERENCE = 0.2
// the smaller this is, the more a straight line will be preferred over a closer camera when changing cameras
// if you set this to 0 the game will crash. don't do that.
// if you set it to be negative the algorithm will do completely nonsensical things (like choosing the camera that's
// the farthest away). don't do that.
/client/proc/AIMove(n,direct,var/mob/living/silicon/ai/user)
if(!user) return
if(user.control_disabled) return
var/min_dist = 1e8
var/obj/machinery/camera/closest = null
var/atom/old = (user.current?user.current : user.loc)
if(!old) return
var/dx = 0
var/dy = 0
if(direct & NORTH)
dy = 1
else if(direct & SOUTH)
dy = -1
if(direct & EAST)
dx = 1
else if(direct & WEST)
dx = -1
var/area/A = get_area(old)
var/list/old_types = dd_text2list("[A.type]", "/")
for(var/obj/machinery/camera/current in cameranet.cameras)
if(user.network != current.network) continue
if(!current.status) continue // ignore disabled cameras
//make sure it's the right direction
if(dx && (current.x * dx <= old.x * dx))
continue
if(dy && (current.y * dy <= old.y * dy))
continue
var/shared_types = 0 //how many levels deep the old camera and the closest camera's areas share
//for instance, /area/A and /area/B would have shared_types = 2 (because of how dd_text2list works)
//whereas area/A/B and /area/A/C would have it as 3
var/area/cur_area = get_area(current)
if(!cur_area) continue
var/list/new_types = dd_text2list("[cur_area.type]", "/")
for(var/i = 1; i <= old_types.len && i <= new_types.len; i++)
if(old_types[i] == new_types[i])
shared_types++
else
break
//don't let it be too far from the current one in the axis perpindicular to the direction of travel,
//but let it be farther from that if it's in the same area
//something in the same hallway but farther away beats something in the same hallway
var/distance = abs((current.y - old.y)/(CAMERA_PROXIMITY_PREFERENCE + abs(dy))) + abs((current.x - old.x)/(CAMERA_PROXIMITY_PREFERENCE + abs(dx)))
distance -= SHARED_TYPES_WEIGHT * shared_types
//weight things in the same area as this so they count as being closer - makes you stay in the same area
//when possible
if(distance < min_dist)
//closer, or this is in the same area and the current closest isn't
min_dist = distance
closest = current
if(!closest)
return
user.switchCamera(closest)