From 0d957161fb4f59aa9c89285abd753ea69f8444ff Mon Sep 17 00:00:00 2001 From: zjm7891 Date: Thu, 24 Jul 2008 01:17:55 +0000 Subject: [PATCH] Added the patch ai_area_selection.patch by both Stephen001 and Kurper --- Code/ai_area_selection.dm | 36 ++++++++++++++++++++++++++++++++++++ spacestation13.dme | 3 +-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 Code/ai_area_selection.dm diff --git a/Code/ai_area_selection.dm b/Code/ai_area_selection.dm new file mode 100644 index 0000000..29a6338 --- /dev/null +++ b/Code/ai_area_selection.dm @@ -0,0 +1,36 @@ +/proc/get_area(area/A) + while(!istype(A, /area) && A) + A = A.loc + return A + + +/var/const/INFINITY = 1e20 //close enough + +/turf/DblClick() + if(usr.stat || !istype(usr, /mob/ai)) + return ..() + if (world.time <= usr:lastDblClick+2) + return ..() + + //try to find the closest working camera in the same area, switch to it + var/area/A = get_area(src) + var/best_dist = INFINITY + var/best_cam = null + for(var/obj/machinery/camera/C in A) + if(usr:network != C.network) + continue // different network (syndicate) + if(C.z != usr.z) + continue // different viewing plane + if(!C.status) + continue // ignore disabled cameras + var/dist = get_dist(src, C) + if(dist < best_dist) + best_dist = dist + best_cam = C + + if(!best_cam) + return ..() + usr:lastDblClick = world.time + usr:current = best_cam + usr:reset_view(best_cam) + usr:cameraFollow = null diff --git a/spacestation13.dme b/spacestation13.dme index 5de6e7a..7f398bf 100644 --- a/spacestation13.dme +++ b/spacestation13.dme @@ -6,7 +6,6 @@ /* FILE: ss13h_new.dmp DIR: Code Code\Effects Code\Item Code\Item\Weapon Code\Machinery Code\Machinery\Computer -UPDATE_OBJ_TREE: ON MAP_ICON_TYPE: 0 AUTO_FILE_DIR: ON */ @@ -14,7 +13,6 @@ AUTO_FILE_DIR: ON // BEGIN_FILE_DIR #define FILE_DIR . #define FILE_DIR "Code" -#define FILE_DIR "Code/Admin" #define FILE_DIR "Code/CTF" #define FILE_DIR "Code/Effects" #define FILE_DIR "Code/Item" @@ -37,6 +35,7 @@ AUTO_FILE_DIR: ON #include "ss13h_new.dmp" #include "Code\!atoms.dm" #include "Code\aaaDefines.dm" +#include "Code\ai_area_selection.dm" #include "Code\airtunnel.dm" #include "Code\areas.dm" #include "Code\blob.dm"