Creating an Equipping System
What is An Equipping System?
An equipping system is a system that allows the player to select various items of certain categories to fill a specific “slot”: For example, allowing a player to choose whether to use a sword or an ax as their primary weapon, or allowing the player to select between chain armor or plate armor. These choices then affect the player’s statistics, which you will use in your game to determine the outcome of actions and combat.
The benefits of this system is that it greatly simplifies the amount of coding necessary to give a player lots of options for which weapon/armor to use. Rather than coding in each item’s specific effect on each page, you only need to code in the item’s effect on a single link, and it will be tracked until the player decides to change it. The downside is that this system is heavily reliant on using variables as player statistics, and does not work as well if you want to base your outcomes on something other than statistics.
How to build an equipping system
1) Create an item called “Manage Equipment”. In the item’s script, paste this code: “%LASTPAGE := $PAGEID”. This will keep track of the player’s current page so that they don’t lose their place in the game when they manage their equipment. Having the equipment management as an item will allow them to alter their equipment choices at any time.
2) Have the item’s general effect take you to a page titled “Manage Equipment.” On this page, you may want to give a general explanation of the different categories you are using in your game, such as weaponry, or armor.
3) Create a link leading to a separate page for each of your different categories. To keep things simple, in this explanation we’re only going to focus on a “weapons” category, though the category can be anything, such as armor, food rations, footgear, etc.
4) Create a link titled “Exit Equipment Management.” Paste this code in the script for the link: “$DEST := “@P” + %LASTPAGE”. This will return the player to wherever they last were in the game.
5) You may want to include a section on this main page telling the player what item they currently have equipped in each category. If so, for the weapons category, paste “Weapons: %%WEAPONSLOT%=%0%None%%%%WEAPONSLOT%=%1%Sword%%%%WEAPONSLOT%=%2%Ax%%%%WEAPONSLOT%=%3%Dagger%%”. After you code in the different types of weapons described in the next section, this string of code will cause the page to tell the player which weapon is currently equipped. You would then repeat this process for each of the other equipment categories you are using.
You now have completed the main equipment management page. The next set of instructions focuses on how to code a specific equipment slot, in this case, the player’s weapon.
1) Create a list of all the items players will have access to for this category. For weaponry, that might be something like a sword, an ax, and a dagger. Create an item for each of these.
2) Create a “Manage Weapons” page, with a link leading to it from the “Manage Equipment” page. Create two links on this page for each item: “Equip (item)”, and “Unequip (item).” Create a final link saying “Return to equipment management” that takes the player back to the main page.
3) Create a variable called WEAPONSLOT. This will be used to keep track of which item the player currently has equipped. Assign each item a variable. For example, the sword would be WEAPONSLOT = 1, the ax would be WEAPONSLOT = 2, and the daggar would be WEAPONSLOT = 3. WEAPONSLOT = 0 is the default setting, and indicates that the player does not currently have any weapon equipped.
4) Open the script box for the “Equip sword” link, and paste in “%WEAPONSLOT := 1”. Paste in “%WEAPONSLOT := 2” and “%WEAPONSLOT := 3” for the links for the ax and the dagger. For each of the “Unequip (item)” links, paste “%WEAPONSLOT := 0” into the link script.
5) Open the variable restriction box for the “Equip (item)” links, and make them visible only when WEAPONSLOT = 0, and only when the player has that item in their inventory.
6) Open the link restriction box for the “Unequip (item)” links, and make them visible only when that specific item is equipped. For example, “Unequip sword” would only be visible when WEAPONSLOT = 1, and “Unequip ax” would only be visible when WEAPONSLOT = 2.
7) Decide what effect you want equipping an item to have on the player’s stats, and then paste that modification into the “Equip (item)” link script. For example, if you want equipping the sword to increase the player’s attack value by 5, paste “%ATTACK := %ATTACK + 5” into the script. This causes equipping the sword to increase the attack value by five. This value will stay raised by 5 until the player unequips the sword, as described in the next step.
8) Whatever variable modifications you cause when the player clicks “Equip sword” need to be undone when they click “Unequip sword”. For the above example, you would paste “%ATTACK := %ATTACK - 5” into the script box for “Unequip sword”.
You’ve now done all the coding necessary for the variable changes for the equipment system. Now, you need to create an interface on the page that the player can easily interact with.
1) At the top of the page, paste the following line of text: “Current weapon: %%WEAPONSLOT%=%0%None%%%%WEAPONSLOT%=%1%Sword: +5 Attack%%”, and add similar on-page variable descriptions for the ax and the dagger. This will cause whichever weapon the player currently has equipped to show up as their current weapon, as well as providing a description of what effect that weapon has on their stats.
2) You may also want to include a list of the effects of the items the player has in their inventory. The best way to do this is using the page script and the $PAGETEXT commands. At the bottom of your “Manage Weapons” page, write: “Other available weapons:”. Then, paste the following code in the page script for each item you want to display: “IF ITEMSTATE(sword) = 1 THEN $PAGETEXT := $PAGETEXT + “<br>Sword: +5 Attack””. Include a similar line of code for the ax and the dagger. This will cause the description of the items the player has in their inventory to list themselves at the bottom of the page, each one on a new line.
3) You may also want to show the effect on the player’s relevant stats. At the top or the middle of the page, paste “Attack: %%ATTACK%%”, and any other relevant variables that weapons effect, such as health points or a defense statistic. This way, the player can see how their stats change as they equip and unequip items.
Next, you would repeat this process for each other equipment slot in your game, such as armor, or ranged weaponry.
Here are some suggested ways you can use this system to add to your game:
1) Left and right hand. If you’re willing to do some more intensive coding, you can have each of the player’s hand be its own weapon slot. Some large weapons, such as the ax, might only become equippable when both hands are open, while other weapons can be mixed-and-matched between the hands, allowing the player to customize their attack even further.
2) Armor types. Why stop at a single category for armor? With this system, you can allow players to customize their chest plate, helmet, footgear, anything. You can cause certain types of armor to increase their defense statistics, or their health points, or cause heavier armor to decrease their speed and reflexes. The sky’s the limit.
3) Ranged weaponry. If you have both melee and ranged combat in your game, you can include a separate category for an equipped ranged weapon.