We pick up where we left off in the last tutorial and put everything together into a finished skill tree that the player can use.
Skill Level: Advanced
This is an advanced tutorial and is targeted toward experienced modders.
There is a lot of information in this tutorial. Please take your time working through it.
Setting Up The Tree
It’s time to lay out what our tree will look like in-game using Position References. This should be a familiar concept from previous tutorials.
Start by opening the _Camp_ModPerkTreeCell. You’ll be given an example to begin working with that looks like the following.
We’re going to avoid messing with the example. We’re instead going to make a copy of it and place it next to it.
Press Q, or select the “Snap to Grid” option in the toolbar(). Click and drag a square over all of the pieces to select them. Press Ctrl+C to copy them, and Ctrl+V to paste them. Drag your copy somewhere next to the original. Hold Z, X, or C while dragging to move on only one axis at a time. When your copy looks like the example below, we’re ready to move on.
The navigation bugs are useful to make sure you don’t accidentally place a node too close to them (making them difficult to select), but you can also delete them if you want. They aren’t important and are only for illustrative purposes. Campfire will automatically place them for you.
Let’s rename some things.
- Rename the campfire ring reference to Basket_CampfireBase_PosRef
- Rename the XMarker to Basket_PerkController_PosRef
- Rename the perk art plane to Basket_PerkArt_PosRef
Select Basket_PerkArt_PosRef in the render window and then select Edit, Search & Replace. We want to replace the example perk art plane with ours so we can tailor our star configuration to the image.
Starting to look good!
We’ll now start to develop our in-game tree.
Rename the bottom-most node Basket_PN_BasketBeginner_PosRef. Rename the one above it Basket_PN_RedBasketExpert_PosRef. Finally, rename the connecting line reference Basket_PL_1_2_PosRef.
Disable snapping to grid by pressing Q or by pressing the button. Move the stars to resemble our intended perk positions for nodes 1 and 2. Hold the Z key or X key to only move along the X-axis and Z-axis (in order to keep the tree flat in appearance).
Tip: to accurately position the perk lines, try the following:
- Move the perk line to the same position (X, Y, Z) as the node it originates from. For example, for a line that goes from node 1 to node 2, we would set the line’s X Y Z coordinates to the same as node 1’s.
- Rotate the line along the Z axis in order to make it point toward the next node.
- Scale the line up or down as appropriate in order to get it to span all the way from one node to the next. You may find it useful to set the scale step interval to 0.01, for accuracy.
WarningIt is very important that the perk line’s X and Y rotation remain at 90 and 0, respectively, or else strange behavior will occur in-game. Only rotate perk lines about the Z axis!
You should now have the following two nodes:
As a reminder, here is what the perk tree should look like:
Copy and paste the nodes and lines until you have completed the tree structure.
When you’ve finished, you should have something similar to the following:
Take the time now to rename your position references to help identify them later. Clear, consistent naming will help make your life easier. Rename your position references as such:
We’re done with arranging our tree! We can now hook everything together using the node controller.
The Node Controller
The node controller controls the appearance, placement, and removal behavior of your skill tree. In Campfire terms, the node controller is the actual “placeable object”. The stars, lines, perk art, and navigation bugs are placed relative to it. The campfire places the node controller when you select the Skills option from the menu, and then the node controller takes care of the rest.
Make a copy of _Camp_PerkNodeController_DefaultForModdersCOPYME and name it Basket_PerkNodeController.
Attached to our node controller is a script, CampPerkNodeControllerBehavior. Open its properties and configure them as shown below. This should be fairly similar to setting up a placeable object as in previous tutorials.
Note: The property names of the node controller start at 0! So, assign perk node 1 to 0, 2 to 1, 3 to 2, etc, as shown below.
Make sure to leave the following settings <<Default>>, or badness could occur:
Well done! We’ve now done everything it takes to build a fully functional Campfire Skill Tree. All that’s left is to register our tree when the game starts.
Registering the Skill Tree
We’ve created a skill tree, but Campfire won’t know about it unless we register it. There are two ways to register your skill tree:
- By attaching a pre-made script to a reference alias; your skill tree will get registered for you when the game starts automatically, and will unregister automatically if the user decides to uninstall your mod.
- By using the CampUtil API and calling RegisterPerkTree() or UnregisterPerkTree(). This can be handy if your mod requires the user to “start” it, and you don’t want your perk tree immediately available until they do. (The system will still unregister your tree automatically if the user uninstalls your mod, even if they don’t “stop” your mod and call UnregisterPerkTree() before they remove it.)
For now, we’ll cover the simple case, which is just attaching a pre-made script to a reference alias and letting the system take care of the rest.
- Create a new Quest named Basket_RegisterSkillTree. Leave everything as default. Press OK to close the Quest, and then re-open the quest. (If you don’t close and re-open it, a CK bug may cause the CK to crash.)
- Open the Quest Aliases tab.
- Right click and create a new Reference Alias named PlayerAlias.
- Select Fill Type: Specific Reference, and select Cell: (any), Ref: PlayerRef (‘Player’)
- Add the CampPerkSystemRegister script.
- Fill out the mod_name property with the name of your mod, or the name of your ESP file. This value is only used for debugging purposes.
- Fill out the required_node_controller property with the node controller you created.
- Press OK to exit all windows.
Testing The Skill Tree In-Game
We activate Basketweaving.esp in our mod manager and start the game up.
A few seconds after starting the game, we see the following message in our Papyrus log:
[02/17/2016 - 08:52:25PM] [Campfire] Registered Campfire Skill System mod: Basketweaving.esp
This lets us know that the skill system was successfully registered.
We build a campfire, and press the Next bug until we reach our skill tree. Success!
We can select nodes in our tree, and view the information about it. Selecting “About Basketweaving” displays the information about the skill.
Since this isn’t a “real” skill, and we haven’t hooked up any way to advance the skill globals, we can increase them through the console instead in order to test that the tree is functioning correctly.
Enter the following into the console:
set BasketweavingPerkPoints to 16 set BasketweavingPerkPointsEarned to 16
Now we can spend points in the skill tree. We verify that the nodes appear in the right order, we can advance (buy) the nodes, and the perk lines light up as we buy the next connected node.
If you’ve been doing this tutorial by hand, I applaud you for sticking it out this far. You should now have all the knowledge and tools to create a skill system of your own.
Continue on to the Appendix of this tutorial to learn more about advanced topics such as developing your own progression system code, registering a skill tree manually using CampUtil, and more.
Final Thoughts: You’ll notice that nodes 2 and 3 are very close to the navigation bugs in-game, which makes selecting these nodes difficult. This was a bit of an oversight and navigating the tree could be improved if they were moved away from the bugs. Something to watch out for when building your own tree.