Hello everyone! This is my first topic ever and I am a fairly new scripter.
I’m trying to make a custom boss with custom moves for a “defend the statue” type game.
I’ve made custom moves for a boss’ attacks using TweenService and CFrame.
I made it where it fires an event on key. Instead of making it on key, I want to know how I can implement the moves onto an npc/boss so they use it when they see a player.
The goal of this book is simple. We want to take a look at something that naturally occurs in our physical world, then determine how we can write code to simulate that occurrence.
The essence of building an AI is recognizing how the NPC wants to act given a situation.
What is its goal? Killing the player, obviously.
This can optionally include attempting to avoid dying.
How can the NPC achieve this goal? Whatever attacks you programmed for him, evidently. And probably movement.
When should these tools be used? Optimally, whenever it helps the NPC get closer to achieving his goal. So if the player is within range for an attack, the NPC should start attacking. If the NPC wants to get closer, help him move closer.
As soon as you can answer these questions, you should be prepared to write a script for it.
The only way I have ever written an fighting AI is with a few tuning variables and an infinite while loop. This can be impractical in most situations, however. For me, coding a swordfighting AI with rather complex movement using a while loop took me around 3 weeks’ worth of work and fine-tuning. That may be normal though, I truly don’t know.
There are plenty of other much more practical ways to create AIs, like neural networks or behavior trees:
I am the furthest from an expert on this topic, I just know I will have to make AIs some time in the future, which makes this a valuable research topic.