[Video] Enemy NPCs & AI

GUIDE TITLE: Enemy NPCs & AI - Series
ESTIMATED COMPLETION TIME: 10-30 Minutes per video
CORE VERSION: 1.0.150-prod-s

SUGGESTED PREREQUISITES: All other basic tutorials. The more you know about Core the more you will learn with this series.

TUTORIAL SUMMARY:
Learn about the NPC AI Kit from Community Content. This is a multi-video series that covers all the fundamental knowledge necessary to build games with enemy NPCs.

EXPECT TO LEARN:

  • How to add the NPC Kit to a game
  • Setup combat and customize weapons to work correctly with NPCs
  • Enemies, but also allied NPCs
  • Create custom NPCs that are unique to your game
  • Design levels using NPC spawn camps
  • Drop loot when NPCs are defeated and setup custom loot for your game with the Loot Drop Factory
  • Edit Navigational Mesh for NPCs to function indoors.

Note: The videos below were shot with version 0.9 of the Kit, which is now at version 1.0. While many of the template structures have changed, the videos are still informative as to the general functionalities and workflows, which have not changed much. The exception being weapons, which are now compatible off-the-shelf, without the need to edit them.

VIDEO:

PART 2:

PART 3:

PART 4:

15 Likes

Definitely looking forward to this video and any future videos on the topic of NPC & AI. I can't wait to dig into it as soon as I have a little bit of extra time. Definitely hoping to see more tutorials being posted on the forum. :slight_smile:

1 Like

Just added Part 2 above.
Cheers!

3 Likes

Part 3 has been added above!
More to come.

2 Likes

Ah thats you... Wonderfull - I followed all 3 tutorials... just awesome.

1 Like

Part 4 added above! See ya later

2 Likes

This is "the standard" for creating in Core. Thank you Sir! :fire: :fire: :fire:

Release Notes - v0.11.2

Highlights

  • Added headshots.
  • Improved animation controller.
  • Breaking changes to Combat Wrapper.
  • NavMesh Zones, a new component that allows level designs to be hybrid, with Nav Mesh in some areas and terrain in others.
  • Reduced network objects by a third.

General Improvements

  • NPC templates have been restructured, reducing the amount of networked objects per NPC from 6 to 4.
  • Added support for headshot damage to dragons, skeletons and raptor.
  • The NPCAIServer script now has an optional "EngageEffect" custom property. Assign a template to be spawned when the NPC finds a target and engages it.
  • NPCs now abandon a chase after a certain distance.
  • NPCs now have an optional "PatrolSpeed" custom property, resulting in more complex behavior when they are not engaged in combat. If not defined, the default patrol speed is 1/3 the movement speed.
  • NPCs now have a SetTarget() function that can be used for a variety of custom interactions.
  • NPCs now switch target if they are damaged by an enemy that is much closer than their current target.
  • Added NavMesh Zones to help NPCs distinguish between outdoor and indoor pathing logic in games with hybrid environments.
  • NPCs can now look at and engage projectiles (used with Zombie Bait, in Survival Kit).
  • New NPCKitKillFeedAdapter and SetObjectName scripts allow NPC names to appear in the kill feed when they kill a player. To use this, add the Adapter to the hierarchy and a copy of SetObjectName to each NPC template's server context.
  • Added new enemy RPG Skeleton - Unarmed.
  • Added engage sound effect to dragons.
  • Added optional property Attack Min Angle that can be used to constrain NPCs from attacking while the target is behind them.
  • Added a new health bar with minimalistic design, as an alternate version to the larger one. Now used by the skeletons.
  • Added HomingTarget custom property so each NPC can specify where on their body homing shots will hit.

Combat Wrapper

  • Breaking change: The ApplyDamage() function has been refactored. It now takes a single table parameter. This allows much more flexibility and power in implementing auxilary systems that react to combat events. E.g. damage types, defensive moves, quest progress, etc.
  • Added GetVelocity()
  • Added GetMaxHitPoints()
  • Optional parameters for FindInSphere() are now implemented to match those of Player API.

Animation Controller

  • Added new animation controller AnimControllerZombie, a versatile humanoid controller.
  • The NPCAIClient script no longer has custom properties for each of the states. If your NPCs have different visual pieces that should turn on/off according to state, set those up with an additional animation controller script.
  • Skeleton Marksman arrow now hides/shows its crossbow by using the new AnimControllerHideAttackProp script.
  • Skeletons now use the AnimControllerZombie.
  • Added new animation controller StateBasedAnimController for use with NPCs that don't have an animated mesh. E.g. Minions in the MOBA example.

Bugs

  • Fixed a bug where NPC colliders could pitch up or down when searching or returning to their spawn points.
  • Dragon NPCs have been adjusted so the vertical position of their animated mesh during edit mode coincides with how it will behave at runtime.
  • Decreased the size of Easy RPG Dragon's collider.
  • Changed the shape of RPG Raptor's collider.
  • Fixed an error when NPCs collide with an object that is in the process of being destroyed.
  • Health bars no longer cast shadows.
  • Fixed a bug where NPCs could be dealt damage and drop multiple loot after they were already dead, if damaged with AOE.
  • Fixed usability isses when swapping the artwork on an NPC, such as jitter from not assigning some custom properties correctly.

Combat Dependencies - v1.1.1

  • Combat Wrap API - v0.11.2
  • Includes the new NPCKitKillFeedAdapter - v1.0

Leaping Staff - v2.2

  • Compatible with Combat Wrapper v0.11.2.
  • Now deals 50 headshot damage.
  • Replaced a deprecated call to .isVisible with .visibility

The Carlos Blade - v2.4.0

  • Compatible with Combat Wrapper v0.11.2.
  • Now supports different damage values for players and NPCs.
  • Now supports headshot damage.
5 Likes

I have added an auxiliary script that implements a "Leash" behavior. When NPCs exit a designated area (such as being pulled by a player) they retreat to their spawn location or resume patrol. While retreating they block all damage. See details in this other thread:

2 Likes

Your tutorials definetly inspired me to share my knowledge and post a tutorial on creating a custom npc using the NPC AI Kit. Thank you a lot for the most useful CC on Core!

1 Like

That's great. Share a link to your tutorial here!

2 Likes

Sure, I just didn't want to be rude and promote it without your approvement. Here is the link if anyone wants to check it out:

2 Likes

Top shelf!

1 Like

Release Notes - v0.12.0

This update moves the NPC Kit closer to v1.0. It's designed for forward-compatibility, while mostly compatible with the prevalent v0.11. Featured are large improvements to network efficiency, plus a new tag system.

**NOTE: ** Before releasing all components to CC (difficult to revert) I am releasing this update first in "Community Projects". Clone it from there to access it. Feedback welcome.

Additions

  • New NPCs: Spider and Wolf Skeleton
  • Tag system, for advanced combat design.
  • Tags added to all NPCs.
  • Relevancy settings now reduce networking and client CPU usage.

Changes

  • Networked object count per NPC reduced from 4 to 2 (half!)
  • Off-the-shelf weapons (e.g. Core Content) now work with NPCs, without changes.
  • Restructured all NPCs to use damageable objects.
  • NPC custom properties now organized by category.
  • Cleanup. Removed the Destructible Manager and the old "RPG Enemy" template.
  • Fly-up numbers moved to a component in Combat Dependencies, instead of each weapon implementing their own damage feedback.

Bugs

  • Fixed bug where the NavMesh could fail to initialize correctly.
  • Fixed all script deprecation warnings.

Tag System
Easily add depth and combat complexity with tags. There were already elements of a tag system in v0.11, but it was never complete. Now, in v0.12 tags come in full effect.

Add tags to NPCs and weapons as custom properties at the root of the templates. Implement your custom interactions between tags-- as an example, the Waypoints template demonstrates how to amplify magic damage against undead NPCs with an extra script.

With tags you can easily:

  • Make weapons that deal bonus damage against specific NPC types.
  • Make rings that give players protection against some NPCs.
  • Make NPCs that have resistance against specific types of NPCs or weapons.

Combat Dependencies v1.2

  • Added damage feedback component for global fly-up numbers.
  • Added tags utility.

Destructible Rifle - v1.1

  • Set headshot damage to 20.
  • Removed inherent fly-up damage numbers.

The Carlos Blade - v2.5

  • Reduced network object count from 8 to 6.
  • Now works in games without the NPC Kit.
  • Supports new tag system.
  • Tags: Physical, Melee.
  • Removed inherent fly-up damage numbers.

Leaping Staff - v2.3

  • Reduced network object count from 15 to 9.
  • Now works in games without the NPC Kit.
  • Supports new tag system.
  • Tags: Magic, Light, Ranged.
  • Secondary ability tags: Magic, Fire.
  • Removed inherent fly-up damage numbers.
  • Simplified and revised all components.
  • Optimized the Leap VFX.

Release Notes - v0.13.0

This update builds on the strengths of v0.12 and moves another step towards v1.0. I've incorporated feedback from the community, added new features and fixed bugs. Thanks for everyone who tested it and reported!

**NOTE: ** Before heading to CC, this update is released as early-access in "Community Projects". Clone it from there to access. Feedback welcome.

Additions

  • Added armor script: NPCKitArmor.lua
  • Added crit damage script: NPCKitCriticalChance.lua
  • Added script for respawning in-place NPCs that are added manually to a game, without spawn points: NPCKitRespawnDamageablesInPlace.lua

Changes

  • Scripts are now in a sub-folder "NPC Kit".
  • Default damage color changed from red to white.
  • Damage Feedback: Type of damage now represented by the color of fly-up numbers.
  • Damage Feedback: Now supports crits, headshots, blocked and armor types. Can be customized to support more types.
  • The attackData table passed to Combat Wrap accepts a new parameter "item" (optional) to indicate the source equipment or NPC attack script that created the damage and is attacking.
  • Tags: Reworked API to encapsulate the structure of the tag data table. This makes everything more scalable, with less code changes into the future.
  • Adjusted the relevance of networking and render cull for each sub-component across all NPCs.

Bugs

  • Fixed a bug where damage fly-up numbers would sometimes appear at (0, 0, 0).
1 Like

great content. Thanks for sharing, enjoying it as a totally beginner. I have question: Can one change the "damage effect" (i.e. when NCP or player are hit). Currently it shows "blood" (kind of) but I would like to add something else . Can this be easily changed ? if yes, how ?

Definitely looking forward to this video and any future videos on the topic of NPC & AI. I can't wait to dig into it as soon as I have a little bit of extra time. Definitely hoping to see more tutorials being posted on the forum. :slight_smile: alight motion on computer

Hey almugabo, It's not very difficult to change, but for a total beginner it could be, I don't know. Basically, there is a template that is spawned with those effects. This template can be replaced. You need to make a new one, with the desired effects, and assign it to the correct slots in the NPCs. There's a slot for when the NPC is damaged and one for when players are damaged. Try adding the NPC's template to the hierarchy, expanding it to examine the "Attack" script-- look at the properties view for custom properties. Sometimes there's also custom properties on the root of a template. After you make the modifications you need to "update" the template based on the changed one (right-click and Update). A lot of the steps in this process are common Core workflow steps and are not specific to the NPC kit.

Release Notes - v1.0.0

This version 1.0 is intended to be forwards-compatible. It also is mostly compatible with v0.11 and later.

Additions

  • Added the release notes file you are reading now.
  • New Bandit NPC with four rarity levels.
  • EnemyHealthBarTopUI: Shows the current enemy you are fighting in the top HUD.
  • Enemy data table: Provides additional metadata about NPCs, such as display name.
  • Targeting system: Press Tab (or PageUp) to focus on a nearby enemy.
  • Added the optional TargetRegister script to NPC templates.
  • NPCs can now be stunned by calling NPCAIServer::GoToStunState(). Call GoToSleepState() to un-stun them. Note: Kit does not include any ability or item that applies stuns.
  • Added support for Loot Drop Factory 3.0.
  • The NPCManager has two new functions: GetNpcs() and GetDamageables().
  • Added support for an optional "Level" property on NPCs, with rudimentary hitpoint and damage scaling.
  • NPCs now broadcast a server event "NPC.TargetChanged" when they acquire a target.
  • Health bars now support additional properties: Name, Rarity and Level.
  • Added a healing color to the feedback fly-up numbers.

Changes

  • In NPC templates, the engage SFX and damage properties have moved from scripts to the template root.
  • Health bars changed to the minimalist version for the dragons, raptor and spider.
  • Changed dragon attacks to not be homing projectiles.
  • Improved the VFX on dragon attacks.
  • The Leash script is now configured to heal by default.
  • Waypoints are now much easier to edit due to a new hierarchy structure.
  • Optimized rendering and networking across all objects.

Bugs

  • Fixed an error in CombatWrapNPC when melee weapons hit NPC projectiles.
  • Fixed a bug where some of the animation controllers would replay the death animation in case a disabled NPC kept taking damage.
  • Fixed deprecation warnings.

Combat Dependencies v1.3

  • New: Combat Events script. Builds upon the events from CombatWrapAPI, with the addition of priority order for listeners.
  • New: Combat Accountant. Keeps track of who damaged what, for rewards and assists.

CombatWrapAPI v1.0

  • Added GetAll()
  • Added GetMaxWalkSpeed() and SetMaxWalkSpeed()

Tags v1.2

  • Now more flexible. Tags can be added to a variety of object types.

Known issue: While this version is compatible with Loot Drop Factory 2.0, expect non-critical errors due to new LootID on some NPCs. Those can be fixed by either A) Change the LootID on NPCs, B) Add the required IDs to the Factory, or C) Use Loot Drop Factory 3.0.