mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-20 07:02:30 +00:00
Adds support for the AI to store multiple camera locations, up to a given maximum
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
/mob/living/silicon/ai/var/stored_location = null // The last stored camera location
|
/mob/living/silicon/ai/var/max_locations = 5
|
||||||
|
/mob/living/silicon/ai/var/stored_locations[0]
|
||||||
|
|
||||||
/mob/living/silicon/ai/proc/InvalidTurf(turf/T as turf)
|
/mob/living/silicon/ai/proc/InvalidTurf(turf/T as turf)
|
||||||
if(!T)
|
if(!T)
|
||||||
@@ -49,29 +50,58 @@
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
/mob/living/silicon/ai/proc/ai_store_location()
|
/mob/living/silicon/ai/proc/ai_store_location(loc as text)
|
||||||
set category = "AI Commands"
|
set category = "AI Commands"
|
||||||
set name = "Store Camera Location"
|
set name = "Store Camera Location"
|
||||||
set desc = "Stores your current camera location"
|
set desc = "Stores your current camera location by the given name"
|
||||||
|
|
||||||
|
if(stored_locations.len >= max_locations)
|
||||||
|
src << "\red Cannot store additional locations. Remove one first"
|
||||||
|
return
|
||||||
|
|
||||||
|
loc = trim(loc)
|
||||||
|
if(!loc)
|
||||||
|
src << "\red Must supply a location name"
|
||||||
|
return
|
||||||
|
|
||||||
|
if(loc in stored_locations)
|
||||||
|
src << "\red There is already a stored location by this name"
|
||||||
|
return
|
||||||
|
|
||||||
var/L = src.eyeobj.getLoc()
|
var/L = src.eyeobj.getLoc()
|
||||||
if (InvalidTurf(get_turf(L)))
|
if (InvalidTurf(get_turf(L)))
|
||||||
src << "\red Unable to store this location"
|
src << "\red Unable to store this location"
|
||||||
return
|
return
|
||||||
|
|
||||||
stored_location = L
|
stored_locations[loc] = L
|
||||||
src << "Location stored"
|
src << "Location '[loc]' stored"
|
||||||
|
|
||||||
/mob/living/silicon/ai/proc/ai_goto_location()
|
/mob/living/silicon/ai/proc/sorted_stored_locations()
|
||||||
|
return sortList(stored_locations)
|
||||||
|
|
||||||
|
/mob/living/silicon/ai/proc/ai_goto_location(loc in sorted_stored_locations())
|
||||||
set category = "AI Commands"
|
set category = "AI Commands"
|
||||||
set name = "Goto Camera Location"
|
set name = "Goto Camera Location"
|
||||||
set desc = "Returns to your last stored camera location"
|
set desc = "Returns to the selected camera location"
|
||||||
|
|
||||||
if (stored_location == null)
|
if (!(loc in stored_locations))
|
||||||
src << "\red No location stored"
|
src << "\red Location [loc] not found"
|
||||||
return
|
return
|
||||||
|
|
||||||
src.eyeobj.setLoc(stored_location)
|
var/L = stored_locations[loc]
|
||||||
|
src.eyeobj.setLoc(L)
|
||||||
|
|
||||||
|
/mob/living/silicon/ai/proc/ai_remove_location(loc in sorted_stored_locations())
|
||||||
|
set category = "AI Commands"
|
||||||
|
set name = "Remove Camera Location"
|
||||||
|
set desc = "Removes the selected camera location"
|
||||||
|
|
||||||
|
if (!(loc in stored_locations))
|
||||||
|
src << "\red Location [loc] not found"
|
||||||
|
return
|
||||||
|
|
||||||
|
stored_locations.Remove(loc)
|
||||||
|
src << "Location [loc] removed"
|
||||||
|
|
||||||
// Used to allow the AI is write in mob names/camera name from the CMD line.
|
// Used to allow the AI is write in mob names/camera name from the CMD line.
|
||||||
/datum/trackable
|
/datum/trackable
|
||||||
|
|||||||
@@ -129,6 +129,7 @@
|
|||||||
O.verbs += /mob/living/silicon/ai/proc/ai_roster
|
O.verbs += /mob/living/silicon/ai/proc/ai_roster
|
||||||
O.verbs += /mob/living/silicon/ai/proc/ai_store_location
|
O.verbs += /mob/living/silicon/ai/proc/ai_store_location
|
||||||
O.verbs += /mob/living/silicon/ai/proc/ai_goto_location
|
O.verbs += /mob/living/silicon/ai/proc/ai_goto_location
|
||||||
|
O.verbs += /mob/living/silicon/ai/proc/ai_remove_location
|
||||||
|
|
||||||
O.job = "AI"
|
O.job = "AI"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user