How could I create smarter swordfighting NPCs?

I would like to script my own “smart” swordfighter NPCs.
I could very easily script NPCs that just follow and attack the player, but I’d like to give them some sort of “intelligence”, like dodging attacks, jumping around, deciding when to approach or flee from the player, etc.

Here are two example games that have the kind of NPCs I want:

I don’t want scripts or uncopylocked places, I would simply like to know how I could learn to start scripting advanced NPCs like those in the example games above.

For this usually the strategy is to approach the side of the character that is not holding the sword like circle strafing, then you can add difficulty some bots do this while others don’t for “smartness”

I believe you can do something simple like detecting and running away from a lunge if the distance is far away then going back in to try for an attack, or instead of going straight to the enemy and attacking have a random chance to stay a radius away and wait for a chance to attack.

Also I believe you have seen this which seems to organize the if statement logic of “AI”, through a behavior tree.

1 Like