Would this enemy system be efficient?

I am currently working on a souls like game, and I want to show y’all the run through on how an NPC will work.

each enemy would have a loop. depending on how advanced the enemy is, determines how fast the loop will go (super weak enemies get 1 seconds, moderate enemies get .5, bosses get .1). We will call this loop “update”.

Each type update passes we will check if they can see someone who is not on their team (players are on a different team than enemies), if they are close, instantly activate combat, if they are far, stare at them for a bit and if they are still in view after a bit, activate combat.

During combat, each enemy has “patience”. Patience determines how long they are willing to wait/stall during battle. Every update, the patience goes down by the respected amount (the wait time between updates). If the player Is close, the patience drops at double the speed. Once the patience runs out, they will attack based off of three values: distance, direction and player actions.

(Forgot to mention, but if the player is healing or casting a spell, patience instantly drops to 0)

Each attack has tags attached to it. For example:

["Lunge"] = {
    ["tags"] = {"FarRanged"}
    ["Function"]
}

Some attacks only need one tag to be true, whilst some need all tags to be true.

I would love your opinion and things I can achieve to make it better!

Also concerns, ways to code it well, and any feedback!

1 Like

Wouldn’t this be in

I think it would be reasonably efficient.

I thought that was for finished code.

It looks pretty good! I like it, although you may want to keep the same naming convention. I don’t think you need to do ["tags"]. You should be able to just do tags = {"FarRanged"} then do Lunge.tags.

For naming convention I would just keep every first letter capitalized.

1 Like