In this tutorial we’ll continue our equipment setup.
With all equipment for this game set up, we’ll now add a loot table to get it dropped by enemies, set up the player’s start equipment and add an Equipment Viewer to the player’s prefab.
We’ll set up:
- loot
- available and start equipment for the player
- equipment viewer on the combatant prefab
Let’s get to it!
Loot #
We’ll add more loot to get random equipment from harder enemies (we’ll add them later).
We’ve already set up loot before, so let’s jump right into it.
Open the Makinom editor, navigate to Combatants > Loot and add a new loot setup.
Random Weapon #
We’ll give a random weapon, but this time we’ll use a different setup.
- Name
Set to: Random Weapon
Loot Table 0 #
Click on Add Loot Table.
- Get Random
Enable this setting. - Use Chance Selection
Enable this setting.
Instead of selecting an item randomly and using it’s chance check, this’ll calculate a chance and check the added items one after the other, adding their chance.
E.g. random chance is 30:
First item has 5% chance and fails.
2nd item has 15% chance – 5+15=20, still fails.
3rd item has 20% chance – 20+20=40, success!
Click on Add Item.
- Type
Select Equipment. - Equipment
Select Sword. - Quantity
Select Value > Value.
Set the value to 1. - Chance
Select Value > Value.
Set the value to 15.
Copy the Sword item.
- Equipment
Select Axe. - Chance
Set the value to 10.
Copy the Axe item.
- Equipment
Select Staff. - Chance
Set the value to 5.
Random Armor #
We’ll give a random armor.
Add a new loot setup.
- Name
Set to: Random Armor
Loot Table 0 #
Click on Add Loot Table.
- Get Random
Enable this setting. - Use Chance Selection
Enable this setting.
Click on Add Item.
- Type
Select Equipment. - Equipment
Select Leather Armor. - Quantity
Select Value > Value.
Set the value to 1. - Chance
Select Value > Value.
Set the value to 15.
Copy the Leather Armor item.
- Equipment
Select Cloth Vest. - Chance
Set the value to 10.
Random Accessory #
We’ll give a random accessory.
Add a new loot setup.
- Name
Set to: Random Accessory
Loot Table 0 #
Click on Add Loot Table.
- Get Random
Enable this setting. - Use Chance Selection
Enable this setting.
Click on Add Item.
- Type
Select Equipment. - Equipment
Select Poison Charm. - Quantity
Select Value > Value.
Set the value to 1. - Chance
Select Value > Value.
Set the value to 5.
Copy the Poison Charm item.
- Equipment
Select Stun Charm.
Copy the Stun Charm item.
- Equipment
Select Elemental Brooch.
Player Equipment #
We’ll set up which equipment the player can equip and the start equipment.
Navigate to Combatants > Combatants and select the Fighter combatant.
Inventory & Equipment > Available Equipment #
By default, combatants will have all equipment slots and can equip all equipment – we’ll change that for our player.
- Available Equipment
Select Custom.
Available Equipment Slots #
Defines the equipment slots that are available to the combatant (at the start – they can be added and removed during the game, e.g. by bonuses from other equipment, status effects or via schematics).
- All Equipment Slots
Enable this setting.
The combatant will have all slots.
Available Equipment #
We’ll allow all equipment except the Staff.
- Exclude Equipment
Enable this setting.
The equipment defined here will be excluded from the combatant, i.e. it can’t be equipped.
Click on Add Equipment.
- Equipment
Select Staff.
Available Item Types #
You can also allow/exclude equipment by it’s item type.
In larger projects with many different equipment, it’s recommended to use this method for an easier setup. E.g. using different sub item types to organize your equipment, using different types for swords, axes, staves or light and heavy armor.
Inventory & Equipment > Start Equipment #
We’ll now set up the start equipment of the player – we’ll just have a sword equipped.
Start equipment can be set up for different level ranges via the Start Level and Maximum Level settings. E.g. when enemy combatants with status development can spawn with different levels in your game, you might want them to give different equipment based on that.
Click on Add Start Equipment.
- Start Level
Set to 1. - Maximum Level
Set to 10.
Click on Add Equipment Slot.
- Equipment Slot
Select Weapon. - Equipment
Select Sword.
Save Changes #
That’s it for the editor setup.
Save the changes using the Save Settings button at the bottom of the editor.
Equipment Viewer #
We’ll now add an Equipment Viewer component to our player’s prefab.
If you remember, all our (player) combatant prefabs are variants of a base prefab, so we only need to make changes to the base prefab.
Open the CombatantBase prefab for editing, you can find it in Assets/Tutorial Assets/Prefabs/Combatants/. The structure is like this:
Select the CombatantBase > Mount > Weapon child object – that’s where the weapon will be displayed.
Add an Equipment Viewer component using the component menu.
Equipment Viewer Settings #
- Equipment Slot
Select Weapon.
Display Conditions #
We’re using the bool variable showWeapon stored in a combatant’s object variables to show the weapon during attacks.
For this, we need to set up a display condition checking that variable.
Click on Add Condition.
- Condition Type
Select Variable.
Click on Add Variable.
- Condition Type
Select Variable. - Variable Key
Set to: showWeapon - Variable Origin
Select Object.
We’ll use the combatant’s variables. - Game Object
Select User.
This’ll use the combatant. - Is Valid
Enable this setting.
The check needs to be valid. - Type
Select Bool.
And that’s it for the prefab – save the changes and close editing the prefab.
Testing #
Hit play and start a battle.
The weapon is displayed when the player attacks – and we’re doing more damage due to the ATK bonus of the sword.
The positioning of the weapon could be a bit better, feel free to adjust that either in the combatant’s prefab or using the equipment’s prefab settings (there’s a Position Offset setting for that).
Next, we’ll add magic and support abilities that’ll be used by our 2nd player and harder enemies.