NokiMo
Dorumeka
Dorumeka

patreon


Improved AI detection

I made some improvements to my detection code. I'll do a rundown of how it works.

The AI has two ways of acquiring targets. The first is by using its vision. Simply, when you are inside an NPC's field and range of vision, you will be detected. The second way is more complex, and is hearing. Each time you shoot, a message will be sent to all AI agents in range. When each receives that message, they will perform a series of checks.

First, if the sound source is inside a minimum detection radius it will try to get a line of sight (ignoring where it's facing). If those two checks pass, then a target will be acquired. Line of sight is necessary for this, because if you shoot inside that minimum radius, but there's a big wall between you and the agent, then the target cannot be immediately acquired. If there's no line of sight, the agent will try to determine if there's a path towards the sound source that isn't too long. If a path is found, an investigation will be triggered. When an AI agent investigates, it moves towards a point where it thinks there might be a target. If it sees a target a any moment, it will then acquire it.

Second, if the sound source is outside the minimum detection radius, but inside an investigation radius, then an investigation will be triggered, but only if there is a path towards that sound source that isn't too long. This is to prevent NPCs hearing shots through adjacent walls and going investigating a long way, even if they have to go through the entire map.

Third, if the sound source if very far, but there's an unobstructed line of sight, then the NPC will see its target and acquire it immediately. If you shoot in the direction of an enemy, or an ally shoots at an enemy that is far away, that enemy will see the shooter and set it as its target.

These different checks will help isolating battles when going through a complex map such as the one shown in the example video. Instead of having many NPCs going after you as soon as you shoot, only the ones that are reasonably close and in hearing range will.

When an NPC is following you there are also some other detection methods implemented. This happens when you summon reinforcements from your stored characters by throwing a doru ball with G. Followers will periodically act as radars, every X seconds, just checking their very immediate surroundings for possible targets. They also will react to your shots, triggering a bigger "radar pulse" to help them get a target and assist you in fighting. 

I will keep working and improving the AI with time. As the development progresses, there are new scenarios that show me how I can do things better. I'm very thankful to the community for the awesome maps submitted. They showed me where I needed to fix things with the AI. But the work is still not done. Expect to see more changes and improvements.

PS- the player's bullet tracers go through walls, but that is only a cosmetic effect. For performance reasons I'm not making them detect walls, so that's why you see them going through everything. This does not mean that bullets can damage through walls. From the player perspective you'll never see them doing so.

Improved AI detection

Comments

Interesting

Yiduo Zhong


Related Creators