How to create npcs that use your combat system?

So I’m trying to figure out how to make npcs that make use of my combat system. I have no experience using or making NPCs so I have no idea what im doing. My combat system is pretty simple in that it fires a remote function from the client to the server from one local script, and the server does a number of checks, and then initiates whatever action is firing. I just dont know how id fire remotes from a non player. If anyone has any resources for making npcs please let me know

1 Like

You don’t have to fire remote events from client to server because your NPC works on the server. Initiate the checks and action without firing to server.

That makes sense, though it is going to be incredibly difficult to do considering Ill have to rewrite like 3k+ lines of code on my local script to fit the server :sob:

Guess ive got my work cut out for me, i just need to figure out how to actually write npc logic

1 Like

An easier way you can use right now, is using the same animations and just randomizing what move they do.

1 Like

you can make your combat script and turn it into a module script so its a function both NPC and player can run
Client

  • PlayerAttackInput
  • CombatHandler:Attack()

CombatHandler

  • typically you’d create a class for Combat
    and define Weapon & Character

NPC
–RandomAttackInput

  • CombatHandler:Attack()
1 Like

Beginner here.

Why don’t you make a module that holds all movement actions and combat/abilities of a player for an NPC? Place a folder holding the NPCS and add values (weapon, abilities, state) in them. Require the module and folder in a script. Do pathfinding in the script (I suggest using or creating a pathfinding module, depends on you.) and you need to predict player’s actions for NPC action by checking values. Let’s say player is blocking, set player’s blocking value to true so the NPC knows to attack the player.

1 Like

Attributes instead of values works fine, but I would say you should do a mix of both

It would help to design the modules combat system where the attacks can be “used” by any Humanoid and then have a separate module for Player-specific functions.

In order for the NPC to understand which moves to use and when, I recommend using this awesome plugin and module called BTrees which lets you create logic trees for your NPCs to follow as behavior.