How can I make my AI notice that something is missing?

My game is simple, Nerf darts. There is a limited supply of darts, so the players must run around and pick up previously shot darts. Because of this the AI can’t use the usual cheats, like camp a known ammo spawn, have a perfect respawn timer in their head, or just manafest ammo from nothing. Instead the AI must perceive darts around the playspace as it chases and runs from the player, record those darts’ locations, and return to get them when they need ammo.

The problem I have is that my AI have an array of spots (location vectors) where they’ve seen darts at some point in their adventures, but the player may have taken the dart since the last time the AI saw them, which leads to the AI running to where they remember a dart being, and only failing to find a dart when they reach down to pick it up and it’s not there. This causes the AI characters to spend big chunks of time looking dumb as they run back and forth between meaningless empty spaces in the level.

How I’d like it to work is, if the AI can see any spot which they think a dart was in, and the dart is gone, they wipe the dart location from their array of memorized locations. If they had been going to pick up the dart when they see it’s missing, update the Blackboard so the behavior tree can try something else. I’d also like them to do this as smooth as they perceive the dart in the first place. Such that, just as they ran through the playspace taking note of the location of any dart they perceived, they also take note whenever they perceive darts are missing. That way when they’re running off to get a dart their list of dart locations is full of viable targets, at least as far as they should be aware.

I feel like the solutions that have come to mind so far could be really expensive. This seems to be a job for the Perception system, but I haven’t used it too much, and I’m not sure how to “perceive an absence”. Any ideas?

What if you save to AI’s memory not the locations, but objects (ammo actors that are placed in the level). Then, when AI selects a spot to go to, you check if it’s still available, and if not, select another spot.

Easiest way is the use EQS. Ever since EQS is enabled by default, I barely use anything else.
Environment Query System Node Reference in Unreal Engine | Unreal Engine Documentation

Make a EQS context of the darts actor array. It will find all darts in the level when ran from EQS generator
You can create an EQS Generator with a distance test. Note: a distance of -1 means closet distance.
In Behavior Tree, use Run EQSQuery to find the nearest dart, then “move to” to have the AI move to it.
Have a collision trigger around the dart that does logic when the AI or player overlaps it and remove it from play.

That should work. PM me if you want to debug this.

It might be time for me to dive into the EQS system, but, I’m not sure it’s any better at achieving the result I want for this problem. It’s a bit of an over correction, I don’t want my NPC to be omniscient. I want the player to be able to fool the AI. I’m planning to add traps next, and I want to keep the idea that you can lure the AI with false promises. So I want to keep the AI working on a “to the best of my knowledge” model, rather than an “adult deciding when to let a child win” model.

Is there a way to perceive that a location is in view, and trigger an event (through perception or EQS)? I could then simply wipe that location from the list to check. If there is a dart there, the perception system would just add the location back to the list on the next tick. [Edit: on second thought, that might not work if the AI is going toward a dart and the perception is constantly forgetting and remembering it’s location…]

If you are talking about basic stealth, you need to use the AI Controller’s OnPerception Event.
You can still use the the EQS, but use the Stimulus Struct on the OnPerception Event’s boolean to select actions based on whether it sees the player or not.
I used to use that before, but now, I only use it to trigger actions when the AI sees the player.