by AFADoomer » Mon Nov 19, 2018 7:01 pm
In Blade of Agony the standard Nazi-type actors have rudimentary handling for something like this...
They don't really intelligently take cover, they just dodge left or right. The dodging is initiated during the See state when certain conditions are met (a timer countdown between dodges, an optional cap on the total number of dodges allowed, and a random number check). When the conditions are met, an internal function checks to see which side (the actor's left or right) has a farther valid movement distance available, then the actor changes to a state that looks like they are rolling sideways and moves in that direction. They're also invulnerable during the "roll" sequence, so that they actually can get away from you (plus then we don't have to make rolling death sprites...).
A second feature that I recently implemented (it's not in the Chapter 2 release version) is that enemies will actively run away from thrown grenades. Every 10-15 ticks (it's randomized so they don't all check at once), the actor checks to see if it's in range of any grenade actors (for performance reasons, the base grenade actor that is inherited from by every grenade in game is set up with a specific STATNUM). If so, the actor turns frightened and increases its move speed by 1-2 (and the custom chase function makes them run away without firing if they're running from a grenade). Once the grenade explodes, the actor's behavior returns to normal.
You can see all of the code for this
here. There's a lot of other code there, too, though (stealth/visibility handling, medic corpse finding and healing, goal seeking, etc.). *I* think the code is relatively logical, but I wrote most of it, so... Feel free to ask if you have questions.
In Blade of Agony the standard Nazi-type actors have rudimentary handling for something like this...
They don't really intelligently take cover, they just dodge left or right. The dodging is initiated during the See state when certain conditions are met (a timer countdown between dodges, an optional cap on the total number of dodges allowed, and a random number check). When the conditions are met, an internal function checks to see which side (the actor's left or right) has a farther valid movement distance available, then the actor changes to a state that looks like they are rolling sideways and moves in that direction. They're also invulnerable during the "roll" sequence, so that they actually can get away from you (plus then we don't have to make rolling death sprites...).
A second feature that I recently implemented (it's not in the Chapter 2 release version) is that enemies will actively run away from thrown grenades. Every 10-15 ticks (it's randomized so they don't all check at once), the actor checks to see if it's in range of any grenade actors (for performance reasons, the base grenade actor that is inherited from by every grenade in game is set up with a specific STATNUM). If so, the actor turns frightened and increases its move speed by 1-2 (and the custom chase function makes them run away without firing if they're running from a grenade). Once the grenade explodes, the actor's behavior returns to normal.
You can see all of the code for this [url=https://github.com/Realm667/WolfenDoom/blob/master/scripts/actors/enemies/base.txt]here[/url]. There's a lot of other code there, too, though (stealth/visibility handling, medic corpse finding and healing, goal seeking, etc.). *I* think the code is relatively logical, but I wrote most of it, so... Feel free to ask if you have questions.