How to make a custom projectiles for throwing weapons
Summary
Created by @manavortexUpdated October 05 2023
This page is a sub-page of Adding Weapons and tells you how to create a custom projectile for a throwing weapon.
To create a custom throwing weapon, check the parent guide and use knife as a base type.
Everything but the yaml works exactly like adding regular items (with a root or mesh entity, an .app file and your weapon's mesh). This example will use a root entity.
This process is about as finicky as the one for weapon additions. Make sure to test your changes after each step.
Step 0: the yaml
We now need to register our projectile. We already have a weapon, so let's define our projectile:
Now, we need to tell our weapon about it. Add the following lines to its definition:
Items.my_knife: # the rest of your weapon's definitionprojectileTemplateName:my_new_weapon_projectile_nameuseProjectileAppearance:trueattacks:-!appendKnifeAttacks.MyKnifeThrowAttackProjectile
If your weapon wasn't throwable before, it is now — but the projectile is still invisible. Time to change that.
Step 1: the entity file
A projectile needs an .ent file as the factory's entry point, not an .app.
You can find all projectile entities in base\gameplay\projectiles.
Ignore anything that has default in its name.
There are two kinds of .ent files: the ones that support multiple appearances, and the ones that don't. You can tell them apart by opening them and checking the appearances array (the first entry in the list).
Use e.g. this entity file if a single appearance is enough for you:
Add the file to your project, then rename it and (if you have one) move it to your weapon's folder.
Step 2: The factory
Now it's time to connect everything by registering the projectileTemplateName from your .yaml file in your factory.csv. As a reminder, this is the line we're talking about:
Make sure that the corresponding entry points at your projectile's entity file from step 1.
Your factory should have two entries: one for the projectile, one for the weapon itself.
From now on, your projectile will no longer be invisible. If it is, try setting your factory path to one of the game's original projectile entities - debugging time.
Step 3: the .app
If you're using a mesh entity (with an empty appearances array), you can skip this step.
Expand the appearances array
Select any of the appearances
Check the appearanceResource's depot path
Add this file to your project
Rename it and move it to your custom folder.
Open your root entity. For all of the appearances, change the appearanceResource path to that of your .app.
Step 4: The right mesh
If you are using a mesh entity (without an .app file), that's where you will find the components. Skip step 1 on the list below.
Open your .app file . For each of the appearances, do the following:
Expand the components array
For any components that have Mesh in their type name:
Change the mesh depotPath to your weapon's custom mesh
Change the meshAppearance to one of your weapon's appearances
Open resolvedDependencies and replace the path to the original mesh with your own.
Step 5: Test
If you did everything correctly, you should now have a custom projectile for thrown weapons.