Npc Enemies - Treasure Hunt Build Jam

Package Name: (Vilva) NPC Enemies
Creator: Vilva#9953
Itch Page: NPC Enemies Package by Vilva for Crayta - $50,000 Build Jam - Theme: "Treasure Hunt" - itch.io

NPC Enemies is a package created for the “Treasure Hunt” Build Jam. It’s designed to help you add any type of enemy into your game.

🎥 SHOWCASE

I prepared a showcase game with some examples of what can be done with NPC Enemies. The showcase is remixable, so I advise you to open it in the Editor and take a look how everything is configured.

Showcase link: Crayta


💡 PACKAGE OVERVIEW

This package can be used in a variety of ways. For a “Treasure Hunt” you could have enemies that guard a treasure or ambush the player. Another idea would be to use it in RPG games to spawn different enemies across the world.

It includes a NPC Enemy template, which will attack any player or NPC they encounter. There are a lot of properties to allow you to configure the NPC to your needs. It supports melee or ranged attacks, and you can also use projectiles for attacks. Projectiles can be dodged by the player and could be used for example in action parkour games.

The package includes 3 ready to use weapon templates for NPCs. A Cutlass for melee attacks, an Assault Rifle for ranged attacks, and a Rocket Launcher as an example of a projectile weapon.

I also included scripts for NPC Health, Inventory, and Patrolling. They have been pre-configured to work seamlessly together.


🛠 INSTALLATION INSTRUCTIONS
  • Install the package: (Vilva) NPC Enemies
  • Drag the “NpcEnemy” template into your game
  • The NpcEnemy can only damage players if they have the official “Health” package installed and configured
  • To kill the NpcEnemy you can use other packages, like the official “Axe” or “Gun” packages

⚙️CONFIGURATION GUIDE

NpcEnemyNpcManager is the main script

  • The property tooltips should give you a rough idea how to use each property

In the following I will give you some basic configurations to help you get started

Configuration: Weapons

NPC weapons don’t need scripts for attacking. If you use packaged weapons, you should remove every script except “InventoryItemSpecScript”.

Weapon: Cutlass
  • The Cutlass is the default weapon
  • Melee weapons must set the attackActionName property to “Melee”
  • They should use a low attackRange
Weapon: Assault Rifle
  • Open the NpcInventory folder and set heldTemplate to “NpcEnemyWeaponAssaultRifle”
  • Ranged weapons must set the attackActionName property to “Fire”
  • They should use a high attackRange and a low attackCooldown
Weapon: Rocket Launcher
  • Open the NpcInventory folder and set heldTemplate to “NpcEnemyWeaponRocketLauncher”
  • Ranged weapons must set the attackActionName property to “Fire”
  • The Rocket Launcher should use a high attackRange and a very high attackCooldown
  • Install the official Crayta “Rocket Launcher” package to get the “Rocket” projectile template
  • Check the useAttackProjectile property and select “Rocket” for the projectile template

Configuration: VisionTrigger
  • Every NPC Enemy needs to reference a VisionTrigger
  • Triggers should be set to “Players Only”, since that also works for NPCs
  • Multiple NPCs can share one VisionTrigger
  • You can either place a VisionTrigger in the world, or set it as child of an NPC to move it with the NPC
  • Make sure that maxChaseDistance and attackRange are big enough to include the full area of the VisionTrigger
Configuration: Patrolling
  • NPCs can patrol between waypoints
  • Enable the property isPatrolling
  • Open the NpcPatrolling folder
  • Reference at least one locator entity as pathNode
  • PathNodes can have the “NpcEnemyPathNodeScript” attached to perform additional actions, like stopping and playing emotes

ℹ️ ADDITIONAL INFORMATION

Below is some information for advanced users. But my advice is to try out the package first

Info: Targeting and Chasing
  • NPC Enemies will only target someone if they enter the VisionTrigger, or if they damage the NPC
  • They do not constantly search for targets because that would have a big impact on performance
  • If the NPC has a target, it will start chasing the target
  • When the NPC is close enough to the target, it will execute an attack
  • NPCs will prioritize the closest target
  • The NPC will stop chasing if the target is further away than maxChaseDistance
  • After chasing, the NPC will return to the previous position. While retreating the NPC will ignore any damage. NPCs will also ignore damage if no enemy is within range. This is to prevent abuse by killing NPCs from far away distances
Info: Team system
  • NPCs will ignore players or NPCs if they have the same team id
  • If you want to assign a player or NPC to a team add a script to the template root and use a property named “team”
  • If this property is not set, it will default to “0”
Info: Cosmetic Meshes
  • This package supports adding Cosmetic Meshes to NPCs (optional)
  • You can use them by adding locators or meshes below the CosmeticMeshes locator
  • Use the “NpcEnemyAttachToSocketScript” to attach meshes to the correct character sockets
  • Supports two levels of depth. Everything under that will stay visible when the NPC dies
  • See the Showcase Game Skeletons as an example of how to configure it
Info: Script Hooks

NpcEnemyNpcManager sends the following Events. You can use them to add extra functionality

  • npc:OnNpcAttack(npcEntity, targetEntity) - This is used by “NpcEnemyWeaponAssaultRifleManager” to play a muzzleFlashEffect
  • projectile:InitProjectile(rayStart, rayDirection, projectileExitVelocity, weaponEntity, npcEntity) - This is used by the Rocket Launcher “ProjectileScript” to init the projectile
  • user:OnKilledNpc(npcEntity, xpReward)
  • user:SendChallengeEvent("killed-npc")
  • user:SendXPEvent("killed-npc-xp")

©️ CREDITS

Special thanks to the original authors.

Included Packages (Dependencies)

  • Crayta Inventory package
  • “NUI - Entity Health Bar” by Nomaki

Modified Scripts
This package includes scripts from other packages that have been modified to work seamlessly together.

  • NpcEnemyInventoryViewScript, NpcEnemyPatrollingScript, NpcEnemyPathNodeScript - modified versions of scripts from “NPC System” by Russ
  • NpcEnemyHealthScript - merged from “NPC System” by Russ and “NUI - Entity Health Bar” by Nomaki
  • NpcEnemyAttachToSocketScript - modified version of attachToSocketScript from “Skeleton Outfits Npc” by Tumbak7

Packages used in Showcase

  • “Skeleton Outfits Npc” by Tumbak7
  • “NUI - XP and Levelling” by Nomaki
  • “Damage Vignette” by Cereal
  • “Show Trigger” by Plasma
  • “Tutorial Modded” by Sinjin

If you have any questions or feedback, reach out to me (Vilva#5980) in the Crayta Discord :slight_smile:

Screenshots



5 Likes

I’ve been waiting for this package for so long :smiley: