Skip to content

Commit ccb9f33

Browse files
SECBATON-GRIFFONSECBATON-GRIFFON
andauthored
Smoother AI tracking (#36383)
* Improved AI mob tracking * Improved AI mob tracking * Improved AI mob tracking * Improved AI mob tracking * Improved AI mob tracking * Improved AI mob tracking * Improved AI mob tracking * Improved AI mob tracking * bit of an improvement * events on item equip and unequip * events on item equip and unequip * events on item equip and unequip * events on item equip and unequip * megaphones * better way? * file unchanged * have to track it like this * performance * performance * cutdown * unnecessary * nevermind * actually sets null * actually sets null * rewrite * relocates this * relocates this * updates to new syntax * documentation * possible help with this * this oughta do it * smooths this out too * updates this * fixes to new name * cuts this down and cleans up * cleaner system * Revert "cleaner system" This reverts commit e679a83. * removes controversial bit * restores something * clearer * extra line to be sure * fix * fixes requested * covers these cases too * more accurate * changes all of this * forgot this * unusable * makes unlocking work --------- Co-authored-by: SECBATON GRIFFON <sage> Co-authored-by: SECBATON-GRIFFON <kanef9x@protonmail.com> Co-authored-by: SECBATON-GRIFFON <>
1 parent b4fe2c3 commit ccb9f33

File tree

19 files changed

+101
-59
lines changed

19 files changed

+101
-59
lines changed

code/_hooks/events.dm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@
263263
// atom/movable/exiter: the movable exiting the area
264264
/event/area_exited
265265

266+
// Called by miscellaneous functions not covered by entered, equipped and unequipped events for cameranet updates
267+
// Arguments:
268+
// atom/movable/mover: the atom changing status on the cameranet
269+
/event/camera_sight_changed
270+
266271
// Called by both area/Entered and area/Exited if the atom changing areas is a mob
267272
// Arguments:
268273
// mob: the mob changing areas

code/datums/gamemode/powers/changeling.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@
226226
return
227227
var/mob/living/carbon/human/C = R.antag.current
228228
to_chat(C, "<span class='notice'>We distort our form to prevent AI-tracking.</span>")
229+
INVOKE_EVENT(C, /event/camera_sight_changed, "mover" = C)
229230
C.digitalcamo = 1
230231

231232
/datum/power/changeling/rapidregeneration

code/datums/gamemode/role/ninja.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ var/list/valid_ninja_suits = list(
289289
max_heat_protection_temperature = GLOVES_MAX_HEAT_PROTECTION_TEMPERATURE
290290
heat_conductivity = INS_GLOVES_HEAT_CONDUCTIVITY
291291
pressure_resistance = 200 * ONE_ATMOSPHERE
292+
blocks_tracking = TRUE
292293
var/cooldown = 0
293294
var/shuriken_icon = "radial_print"
294295
actions_types = list(

code/game/dna/genes/goon_powers.dm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@
2121
/datum/dna/gene/basic/psychic_resist/New()
2222
block = PSYRESISTBLOCK
2323

24+
/datum/dna/gene/basic/psychic_resist/activate(var/mob/M, var/connected, var/flags)
25+
..()
26+
INVOKE_EVENT(M, /event/camera_sight_changed, "mover" = M)
27+
return 1
28+
29+
/*/datum/dna/gene/basic/psychic_resist/deactivate(var/mob/M, var/connected, var/flags)
30+
if(!..())
31+
return 0
32+
INVOKE_EVENT(M, /event/camera_sight_changed, "mover" = M)
33+
return 1*/ // Allows retracking, uncomment to enable
34+
2435
/////////////////////////
2536
// Stealth Enhancers
2637
/////////////////////////

code/game/machinery/camera/tracking.dm

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/mob/living/silicon/ai
2+
var/atom/movable/currently_tracking = null
3+
14
/mob/living/silicon/ai/proc/get_camera_list()
25

36

@@ -111,7 +114,7 @@
111114
return
112115
spawn(0)
113116
if(!can_track_atom(target))
114-
to_chat(src, "Target is not near any active cameras.")
117+
to_chat(src, "Target is not trackable by any means.")
115118
return
116119
var/obj/machinery/door/airlock/tobeopened
117120
var/dist = -1
@@ -143,7 +146,7 @@
143146
return
144147

145148
/mob/living/silicon/ai/proc/can_track_atom(var/atom/target)
146-
if(target == src)
149+
if(!target || target.gcDestroyed || target == src)
147150
return FALSE
148151

149152
var/turf/T = get_turf(target)
@@ -159,18 +162,13 @@
159162
var/mob/target_mob = target
160163
if(target_mob.digitalcamo)
161164
return FALSE
162-
if(ishuman(target))
163-
var/mob/living/carbon/human/target_human = target
164-
if(target_human.wear_id && istype(target_human.wear_id.GetID(), /obj/item/weapon/card/id/syndicate))
165-
return FALSE
166-
if(target_human.is_wearing_item(/obj/item/clothing/mask/gas/voice))
167-
return FALSE
168-
if(target_human.is_wearing_item(/obj/item/clothing/gloves/ninja))
169-
return FALSE
170-
if(target_human.is_wearing_item(/obj/item/clothing/head/tinfoil))
171-
return FALSE
172-
if(target_human.is_holding_item(/obj/item/device/megaphone/madscientist))
173-
return FALSE
165+
for(var/obj/item/I in target_mob.get_all_slots())
166+
if(I.blocks_tracking)
167+
return FALSE
168+
if(target_mob.is_wearing_item(I,slot_wear_id))
169+
var/obj/item/ourID = I.GetID()
170+
if(ourID && ourID.blocks_tracking)
171+
return FALSE
174172

175173
if(isalien(target))
176174
return FALSE
@@ -183,34 +181,50 @@
183181

184182
return TRUE
185183

186-
/mob/living/silicon/ai/proc/ai_actual_track(var/atom/target)
187-
if(!istype(target))
184+
/mob/living/silicon/ai/proc/ai_actual_track(var/atom/movable/target)
185+
if(!istype(target) || !eyeobj)
188186
return
189187

190188
if(!can_track_atom(target))
191-
to_chat(src, "Target is not near any active camera.")
189+
to_chat(src, "Target is not trackable by any means.")
192190
return
193191

194-
cameraFollow = target
195-
196-
to_chat(src, "Now tracking [target.name] on camera.")
197-
198-
spawn (0)
199-
while (cameraFollow == target)
200-
if (cameraFollow == null)
201-
return
202-
203-
if(!can_track_atom(target))
204-
to_chat(src, "Target is not near any active camera.")
205-
sleep(10 SECONDS)
206-
continue
207-
208-
if(eyeobj)
209-
eyeobj.forceMove(get_turf(target))
210-
else
211-
view_core()
212-
return
213-
sleep(1 SECONDS)
192+
stop_ai_tracking()
193+
currently_tracking = target
194+
eyeobj.forceMove(get_turf(currently_tracking))
195+
currently_tracking.lock_atom(eyeobj,/datum/locking_category/ai_eye)
196+
197+
currently_tracking.register_event(/event/after_move,src,nameof(src::on_camera_change()))
198+
currently_tracking.register_event(/event/destroyed,src,nameof(src::stop_ai_tracking()))
199+
currently_tracking.register_event(/event/equipped,src,nameof(src::on_camera_change()))
200+
//currently_tracking.register_event(/event/unequipped,src,nameof(src::on_camera_change()))
201+
currently_tracking.register_event(/event/camera_sight_changed,src,nameof(src::on_camera_change()))
202+
to_chat(src, "Now tracking [currently_tracking.name] on camera.")
203+
204+
/datum/locking_category/ai_eye
205+
206+
/mob/living/silicon/ai/proc/on_camera_change()
207+
if(eyeobj && currently_tracking)
208+
var/cantrack = can_track_atom(currently_tracking)
209+
/*if(!eyeobj.locked_to && cantrack) // Retracking code
210+
to_chat(src, "Target is trackable again.")
211+
currently_tracking.lock_atom(eyeobj,/datum/locking_category/ai_eye)
212+
else */if(!cantrack && eyeobj.locked_to == currently_tracking)
213+
to_chat(src, "Target is no longer trackable.")
214+
//eyeobj.unlock_from()
215+
stop_ai_tracking() // remove this if you want retracking
216+
217+
/mob/living/silicon/ai/proc/stop_ai_tracking()
218+
if(currently_tracking)
219+
to_chat(src, "No longer tracking [currently_tracking.name] on camera.")
220+
currently_tracking.unregister_event(/event/after_move,src,nameof(src::on_camera_change()))
221+
currently_tracking.unregister_event(/event/destroyed,src,nameof(src::stop_ai_tracking()))
222+
currently_tracking.unregister_event(/event/equipped,src,nameof(src::on_camera_change()))
223+
//currently_tracking.unregister_event(/event/unequipped,src,nameof(src::on_camera_change()))
224+
currently_tracking.unregister_event(/event/camera_sight_changed,src,nameof(src::on_camera_change()))
225+
if(eyeobj?.locked_to == currently_tracking)
226+
eyeobj.unlock_from()
227+
currently_tracking = null
214228

215229
/proc/near_camera(var/mob/living/M)
216230
if (!isturf(M.loc))

code/game/machinery/hologram.dm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ var/list/holopads = list()
8181
/*There are pretty much only three ways to interact here.
8282
I don't need to check for client since they're clicking on an object.
8383
This may change in the future but for now will suffice.*/
84-
user.cameraFollow = null // Stops tracking
8584

8685
if(master && (master==user) && holo)//If there is a hologram, remove it. But only if the user is the master. Otherwise do nothing.
8786
clear_holo()

code/game/objects/items.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787

8888
var/is_cookvessel //If true, the item is a cooking vessel.
8989

90+
var/blocks_tracking = FALSE //Blocks mind and AI tracking
91+
9092
var/list/quick_equip_priority = list() //stuff to override the quick equip thing so it goes in this first
9193

9294
var/last_burn

code/game/objects/items/devices/megaphone.dm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
desc = "An ominous-sounding megaphone with a built-in radio transmitter and voice scrambler. Use in hand to fiddle with the controls."
3838
var/frequency = 0
3939
mask_voice = TRUE
40+
blocks_tracking = TRUE
4041
flags = FPRINT | HEAR
4142

4243
var/list/megaphone_channels = list("DISABLE" = 0) + stationchannels
@@ -54,6 +55,13 @@ var/list/megaphone_channels = list("DISABLE" = 0) + stationchannels
5455
to_chat(speech.speaker, "\The [src] [pick("creaks", "whines", "crackles", "whirrs", 1;"makes an odd static/popping noise that you kind of recognize as similar to a geiger counter", 1;"squeaks")] \
5556
as it transmits your voice into the set frequency...") //Since you may not be able to hear your own demands, some feedback that they're getting through
5657

58+
/obj/item/device/megaphone/madscientist/pickup(mob/user)
59+
INVOKE_EVENT(user, /event/camera_sight_changed, "mover" = user)
60+
61+
/*/obj/item/device/megaphone/madscientist/dropped(mob/user)
62+
..()
63+
INVOKE_EVENT(user, /event/camera_sight_changed, "mover" = user)*/ // Allows retracking, uncomment to enable
64+
5765
/obj/item/device/megaphone/madscientist/attack_self(mob/living/user as mob)
5866
show_ui(user)
5967

code/game/objects/items/weapons/cards_ids.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ var/list/global/id_cards = list()
441441
access = AGENT_CARD_DEFAULT_ACCESS
442442
base_access = list(access_syndicate)
443443
origin_tech = Tc_SYNDICATE + "=3"
444+
blocks_tracking = TRUE
444445
var/registered_user=null
445446
var/copy_appearance = FALSE
446447

code/modules/clothing/head/misc_special.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@
290290
item_state = "paper"
291291
siemens_coefficient = 2
292292
species_fit = list(GREY_SHAPED,VOX_SHAPED, INSECT_SHAPED)
293+
blocks_tracking = TRUE
293294

294295
/obj/item/clothing/head/celtic
295296
name = "\improper Celtic crown"

0 commit comments

Comments
 (0)