YTread Logo
YTread Logo

How Doom's Enemy AI Works

Jun 05, 2021
Let's face it, monsters are primitive, they tried to get close to you and perform an attack, you shoot them, they might hurt you and they die behind their simplistic behavior, it's a pretty elegant system, let's take a look at how it

works

and also look at some others. We're already on this, first of all, let's see how monsters are defined. They are practically hard-coded into the engine in the form of a collection of data. Each data collection contains indexes of various

enemy

states. Spawn states where an

enemy

is inactive. sea ​​state where an enemy is chasing a target the pain state where the enemy will play a pain animation insult the mill a state that tells what to do when performing a melee attack the missile states that tells what to do when performing fixed the deck the death state will play the enemy's death animation and will play the ex death state of a team animation of played enemies and the race state will play the animation of a resurrected enemy.
how doom s enemy ai works
Let's take the returnee as an example. The build state uses the index skeleton. this huge area of ​​coded states go to the index we just selected here, you can see a collection of values ​​and functions, let's quickly go through all of them. The SPR scale is the base rate for the returned sprite, the zero after it means the frame compensates for this state. should last 10 ticks, one takes minus 135 of a second, so 10 ticks last about 0.29 seconds. This should call the Luke function, which we will see later, the next action should be s. The scale is: the line below the last two values ​​is unused, so they are always zero.
how doom s enemy ai works

More Interesting Facts About,

how doom s enemy ai works...

What we just described was the first action of the returnee's generation state. It consists of two actions where you cycle between two sprites, causing you to walk in place when you start the new level. Enemies are unloaded and placed in designated locations. Newly spawned enemies gain their health type status, etc. of the coded data collection we saw earlier. The positions and angles are based on how the cartographer places them. One interesting thing here is your reaction time. Address time always starts at eight, unless it's a nightmarish difficulty. Enemies never attack. When the reaction time is greater than zero, that means that enemies on any difficulty will not hesitate to attack you when they wake up.
how doom s enemy ai works
This is a key difference between nightmare fast bounces and normal fast monsters that retain the default reaction speed. Another mechanical art exclusive to fast nightmare monsters. arrow pinkies and demon projectiles Kaku and baron faster aim the duration of the pink is the Herr Haupt state and the speeds of the projectiles where the imps Cacodemons and barons go from 10 10 and 15 respectively to 20 20 20, interestingly, the near

doom

launch is like the BFG edition and the weird potestas unit built doesn't have turbo roses or faster projectiles anyway how exactly do you wake up enemies looking at the return spawn stat again where it circles between two sprites?
how doom s enemy ai works
They have caused a glance every 10 ticks. Let's see what this function does first. checks if a player made a sound in this sector when a player fires a shot the noise spreads through many sectors the sound continues to spread below it reaches a dead end either a wall a closed door or two sound blocking lines kills the sector then mark the player as a target or make a sound if a sound target exists check the enemy's ambush flag. The Doom community often incorrectly calls it the death flag, but the ambush flag causes the enemy to remain inactive even if they hurt a player.
It also extends their fuel field from 180 degrees to 360, so they will wake up even with their back to you if a certain target exists and the enemy doesn't have an ambush flag, then wake up and start chasing the player if the sector doesn't. has it. record any sounds and then call the P find players function. What this function does is search all players in the game for each player. Check if it is alive and visible if all conditions apply. Wake up and chase the player if the player is. is not in the enemy's field of vision, but is within sixty-four units of the enemy's presence, then wakes up regardless, now the enemy wakes up, it will play its wake-up sounds, imps and zombies in variations of a random play , fully awake, it's time to hunt. the player who returns to the returned states his sea state is skeleton, run one let's see what happens here, he has 12 actions and each action lasts two ticks, each sprite lasts four ticks in total and for each action he causes the chase function, let's check it.
Every time a chase is started, decrease enemies' reaction time and threshold by one. The threshold value is explained at the end of the fight video, so be sure to watch that video to fully understand how it

works

as we move. Make sure to update the Enemies lean towards the direction they are moving if the enemy no longer has a target because they died or logged out, look for a new one, found none, then return to the spawn state and show that if we just attack, don't attack again unless Nightmare difficulty or fast months are enabled instead of attacking, so soon try to find a new direction to move using P, new chase, dear, check out this feature in a moment.
Next, we check if we can perform a melee attack if the enemy has a melee status and is within 64 units of the player and the players in the enemy's line of sight then take out the living bejesus on him using to the returned as an example again, this state contains four actions, there are the objectives and then the next frame. played a woosh sound effect advance to the next pride engage a target again and then play the punch sound effects if within melee range if the enemy has a projectile attack and their movement counters are not yet zero, then don't attack unless it's a nightmare or fast monsters are enabled then don't give a shit and go crazy explain what the move counter is in just one minute before the enemy performs a successful projectile attack you must first meet many conditions if the target is not in sight. then don't fire the projectile if the enemy just played our pain animation then he always attacks again, that's why the revenants always get those annoying missile attacks and also get a super shotgun blast to the face even if they don't are within a range, here is the reaction time. value again, as long as it is not zero, do not attack, this value is always zero in the nightmares explained above.
The game then calculates the distance between the enemy and the player and then subtracts 64 units from that number if the enemy lacks melee attack. decrease the distance value by 128 units if the enemy is a foul arc and the distance is greater than 896 units then never start an attack if the enemy is a returner and the distance is within 196 units then do not shoot missiles, this creates a bit of a dead zone for the revenant where he will not perform stink attacks or missile attacks unless he is injured, of course if the revenant took the player's distance is greater than 196 units then half the value from the distance if the enemy is a cyberdemon spider demon or is lost. soul and also got the distance value halved now limits the distance value to 200 unless the cyberdemon enemies limit it to 160 generate and run a number between 0 and 255 and if this value is less than the distance then no you fire the projectile and a slightly misleading name says that the missiles, since their scanners are suitable for ranged attacks, speaking of what enemy hits can, the attacks are limited to 2048 units in length, but they will still attack from much greater distances that that one.
Additionally, most enemies call out a phase star between attacks. he makes sure enemies engage the player when he attacks, but he and Barents will announce this as an oversight. There is technology that never calls face targets to change targets just before the attack. They will launch a fireball from their backs after making a successful move. missile attack run the enemy's missile status and mark the enemy as a setting effect, let's see how the returner does it. This state contains four actions, the first two will face the target and why does the frame shift so large suddenly?
That is due to the rendering of the sprite. The code masks the index value 32767 or 8000 with the set frame, if masked correctly then the sprite should be relative. Fulbright's back to the chase code if it is a cooperative game, the enemies threshold has been reduced to zero and can be seen. Your current targets then search for new players if the weapon movement decreased to zero or the head hits an obstacle then change the direction of the chase and also randomly play a search side while chasing the player anyway it's time to board the new deer chasing P feature.
The feature will determine how the enemy should get to the player and is caught whenever the move counter is zero so to keep it simple it starts by taking the shortest path towards the player either ordinal or straight forward if the player ends up behind you, turn around and move. towards the player again, the enemy will continue traversing this path until the move counter equals zero, then it will calculate the shortest path again and set the new random move counter value. That's why enemies zigzag when they try to get close to you if the enemy can't reach the player and walks past them and stays in this direction after the game allows you to turn if possible turn turn clockwise clockwise or counterclockwise, if all else fails then it will be a pretty bone and will most likely get stuck before the game progresses.
Enemy movement is called Function called Pete, it tries to walk where it calculates the next position of the enemy, if it detects an obstacle it will move and it will not move the enemy there if the movement was successful. Sets the new random value of the wolf counter, so that when the movement is not balanced, it will obviously hit a warmer object stops the enemies' movements also when the height difference between two sectors is 24 units or more, a Unless it's a flying enemy, of course, but we'll get to them in a moment. The stairs are also a bit tricky considering the sheer weight of the enemies. the difference between the highest and lowest nut within this width cannot exceed 24 units, either because the enemies are thinner and walk stairs, now this cannot, unless you increase the width of the steps, the game also checks if the enemy is not too tall for the other sector while the enemies move they will always try to interact with the doors if the enemy collision box crosses with the door then the door will open the doors can open our doors with special IDs 1 32 33 and 34 there is a bit of carelessness if the doors are thin and a fast enemy crashes into the door.
Some doors are marked for players only on one side, so if the enemy coalition box touches that side, the door will open. A well-known example was Barney, the fallen bow from Doom 2. Now 27 normally requires a red key to open the exit door, but the other side of the door is marked to be opened by non-players as well. Another oddity of enemies tends to get stuck in doors when they are inside the door sector and are angled towards and touching the door tracks, they still register the special line that is inside the sector they are stuck in, but due to Because the game sets your movement direction to none during this process, the condition here fails and you are stuck.
Flying enemies don't check their slopes or too steep or crazy, they don't change their height unless they collide with something and then hit an obstacle which were descents or ascents depending on what the new fluorides value is, they have also flowed down if the The target is getting too close and our enemies move around the level quite simply, but it works and isn't too taxing on the system. Now is the time to fight back. What happens when you damage an enemy? When you damage an enemy, the P damage and item function is called let's go. See what happens here if the enemy you hurt was a Lost Soul that charges and resets all momentum to zero.
If the enemy is a lightweight relative to the damage you have dealt him, he is 64 units above you and dies, then you have a 50% chance. If the enemy falls forward, this is also because lost souls are often throwntowards you and die if the enemy's health, and the damage dealt falls below zero, call P kill and the items will come to the function at the moment if the damage does not go to the enemy. generates a random number and compared to the enemy's pain shots, each enemy has a coded paint that reaches one or is sent to search for lost souls and only 3% or one arc drops if the render number is lower that the probability of painting and you are not a lost soul that charges and executes the pain states of the enemy.
A flag indicating that the enemy has just been hit. This is also set as explained above. This flag is used to launch enemies to counterattack with a projectile attack. What does a state of pain look like? What's really interesting? using the returner is an example again, it contains two actions, both use the same sprites, the last five ticks each and one costs the paint function, all this function does is play the enemies paint sounds after receiving damage. Address time is set to zero the next piece of code handles things spent fighting if an enemy is in their spawn states and takes damage on the first idle frame and then immediately retaliates; however, damaging the enemy in the second idle frame will do nothing, normally shooting an IO enemy will wake them up due to the sound. spread, but let's say there's a sunblock-wearing madman in the kill line and an enemy has his back to you, you could potentially kill him without the enemy fighting back, as long as she only damages the enemy on the second idle frame, he it will not. retaliate, that is of course as long as the chance to paint is a traitor because he was in the enemy state in the sea state anyway, we mentioned earlier that dropping the enemy's house below zero will call the P function of killing and objects if the dying enemy is not a lost soul, then enable gravity, this will make the stones and pictorial metals fall like the sex of potatoes, the height of the enemies will also be reduced by quarters.
Now check what kind of death state to play as mentioned in the chips video if the damage exceeds the negative of the enemies appear and then execute the exdeath states, the example of the returner has done it, who plays normal death is dead ? What does the baseline death status look like? It consists of six actions. The first two don't do much. The third action triggered a screw feature where you play your children of death if dying enemies have a target. for any of the three zombies and randomize the sons of death, if the dying enemies aim to dominate the cyberdemon Mighdal, they have played a loud death sound, regardless of their position in the level, again to the reverend, the fourth action caused a fall that sets Enemies of non-solids, some enemies call a special boss death function at the end of the death animation.
This function checks a list of conditions if the dying animals had the baron of hell and all the barons are debt and the map is e1 and eight and then lower. all the walls that are marked with tax 666 the same with psy ready, wasn't it on American Eve or six when all the mermaid events are dead on those maps? So therefore the network also inspired the masterminds III of AIDS and E for the man condemned to Alcestis of f7 kill all the manky for one lower all the walls mark with the text 666 kill all the erica trans will increase the steps mark with the text 667 the letter smith is faulty and the enemies that respond are enabled every time the last rocket launch dies, the step will run again self-locking long enough for this It will also happen without enemies that respond if you kill more of one, a rocket launch simultaneously, the function will be called more than once, stepping up too often now that we're not done yet, we're not even dead and he's still thinking on light difficulty, every corpse will respond. each game checks, the game checks if this corpse is close to the kill percentage, if it doesn't respond, then it checks the difficulty or the response parameter, if it is neither difficulty nor response, the power meters are not set, it doesn't respond if the corpse has not been dead for these 30 seconds does not respond, so every 31 ticks or 0.88 seconds there is a 1.5 percent chance that the enemy will respond there is one more state to go through the NIST array state when a archenemy resurrects a corpse the height of the enemy will be restored by quadruplet and its half will be sent to spawn health the enemy corpse will then run the sprint state let's take a look at our revenant example once again, it pretty much just plays its animation of death backwards and that's it, arc fell resurrection is quite complicated, so I recommend watching this channel.
Auto analysis video for more information and this is how enemies behave in Doom. There is an enemy, however, he is a bit marginalized. Yes, lost souls are rare, let's take a look at why they are lacking in the first place. an awakening and second, can be generated by the paint elemental because of this, probably to prevent your old PC from overloading, there is a loss or limit of 21 and the pain elemental tried to generate a twenty second loss so that it does not pass nothing when they attack. the flags of the game, all skins fly with this flag near the physics is modified, so when charged, it crashes into a water object, the momentum is set to zero, even the items lose blood, salt acts when loss, everything crashes into a floor, breaks, the omentum is reversed making them bounce when they hit something, the game sets their states to their spawn state, this will draw a look, which means if there is a target sound, then the law saw immediately wakes up and starts chasing the player again;
However, if there is no sound target, then it falls asleep to make a sound or enter its line of sight, but yeah, that's it, there's a lot to say about enemy AI quotas, so it was easy to do. understand, thanks for watching and a huge thank you to Andrew Koval and his really clean art. Cox Austin has been Filkins Brian C kappa Chris owns Tony Cyprian rusyn Curtis Carter e wolf de Guiche auto team Jeff Russell Joseph Coleman Joseph Jones Joshua Scoggins alone in a kuba book Lloyd Lin statistics wicked Moe built Mattias siberts Michael Dunn water sir steal me man Nolan Boyer earthquake player 6 3 2 richard Foster Roman era hope Sean Juan Sebastian Radcliffe Steven bone Steven holistic Ted Roddy this man Trevor Whelan turbine 2k v dot Thomas P Diddy xenia and liquid fusion I will always be grateful for your support until next time you

If you have any copyright issue, please Contact