Creating an Inventory System

From HIVE
Revision as of 06:34, 26 March 2013 by DevliN (talk | contribs) (DevliN moved page Inventory to Creating an Inventory System without leaving a redirect)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

An inventory system can be created in StarCraft II in two ways: with the Data Editor or with Triggers. Creating the system with the Data Editor is much simpler and much less time consuming, but ultimately less customizable than doing it with Triggers. The purpose of an inventory is to give Items to a unit that will buff him/her. Items could be as simple as adding armor or a weapon, or as complex as adding new Effects to your unit. In this case, we'll keep it simple and make an inventory for a weapon and a piece of armor, and attach it to a Marine.

The Data Editor Method

In this section, we will only be using the Data Editor to create the inventory of our unit. Open up the Data Editor by going to "Modules > Data" (F7). Before we begin, make you have the "Show Table View" button pressed next to the right "Search" bar.

Creating the Item Classes

Before we can set up our inventory, we need to decide what types of items the unit can pick up. Item Classes are basically customized item types that will be attached to the item units. Under "Data Type:" select "Item Classes."

  1. In the box on the left, right-click and select "Add Object" (Ctrl+=). Name this new object "WeaponClass," click "Suggest" for the ID, and then click "OK" to close the window.
  2. Right-click and select "Add Object" (Ctrl+=) again. Name this new object "ArmorClass," click "Suggest" for the ID, and then click "OK" to close the window.

That's all you have to do here. If you wanted a more complex inventory system that had different types of armor or accessories, you would need to make an Item Class for each one as well. For now, we'll be fine with just two, though.

Creating the Item Container

The Item Container will contain all the items our unit will pick up. Under "Data Type:" select "Item Containers." In the box on the left, right-click and select "Add Object" (Ctrl+=). Name this new object "Hero Equipment," click "Suggest" for the ID, and then click "OK" to close the window.

The Column and Row values act as a grid when you open your Item Container. Both values start at "0" and at the top left of the in-game window.
  1. In the box on the right, find "Model" and change that to "Marine."
  2. Now change the "Model Height" and "Model Width" values to "300."
  3. Find "Slots+" and double-click the space to the right of it. This will open up an "Object Values" window that allows you to set the various slots that will display when you open up your Item Container.
    1. Click the green X on the right to add a line to the "Slots" box. With this line selected, click the green X under "Classes" to add a new line to that box as well. Select the new line under "Classes" and change that to "ArmorClass."
      1. Change the value under "Column" to "0."
      2. Change the value under "Row" to "2."
      3. Check the box next to "Enabled" under "Equip."
      4. Click "OK" to close the window.
    2. Click the green X on the right of the "Slots" box again to add a new line. With this new line selected, click the green X under "Classes" to add a new line to that box as well. Select the new line under "Classes" and change that to "WeaponClass."
      1. Change the value under "Column" to "5."
      2. Change the value under "Row" to "2."
      3. Check the box next to "Enabled" under "Equip."
      4. Click "OK" to close the window.

Creating the Inventory Button

We need a button to click to open the inventory window, so we should make a custom button for this purpose. Under "Data Type:" select "Buttons." In the box on the left, right-click and select "Add Object" (Ctrl+=). Name this new object "Hero Equipment," click "Suggest" for the ID, and then click "OK" to close the window.

  1. In the box on the right, find "Icon" and change that to "btn-techupgrade-terran-combatshield.dds." You can change this to whatever you would like, but I figured an image of a shield was appropriate.
  2. Find "Tooltip" and change that to something along the lines of "Contains the hero's gear."

Normally you would want to add a hotkey to a button, but in this case it isn't necessary as it wont be used.

Creating the Inventory Ability

In order to attach the Item Container to the unit, we need to create an ability that can be given to our unit. Under "Data Type:" select "Abilities." In the box on the left, right-click and select "Add Object" (Ctrl+=). Name this new object "Hero Equipment," set the "Type:" to "Inventory," click "Suggest" for the ID, and then click "OK" to close the window.

  1. In the box on the right, find "Ability - Info+" and double-click the space on the right of it to open an "Object Values" window.
    1. Click the green X on the right to add a line to the box under "Info."
    2. With this line selected, change the "Container" to "Hero Equipment."
    3. Change the "Empty Face" to our new inventory button, "Hero Equipment."
    4. Under "Classes" click the green X on the right of the box and add our two custom classes, "WeaponClass" and "ArmorClass."
    5. Change the "Alignment" to "Left" or "Right." Basically this manages where the in-game item container window displays above the default UI. In the screenshot below, this is set to "Left."
    6. Click "OK" to close the window.
  2. Now find "Maximum Drop Range" and set that value to "2."
  3. Also find "Minimum Drop Range" and set that value to "2" as well.

Attaching the Inventory to a Unit

Now all we need to do is attach the inventory ability to our unit. Under "Data Type:" select "Units," and find the "Marine."

  1. In the box on the right, find "Ability - Abilities+" and double-click the value next to it to open an "Object Values" window.
  2. Click the green X on the right to add a new line to the "Abilities" box. Select that line and change it to "Hero Equipment."
  3. Click "OK" to close the window.

Congratulations, your Marine can now equip items. In the future, you could add another "Item Container" to him as an all-purpose inventory as well. Then you would be able to drag items from that container to the "Hero Equipment" to equip them on the unit.

ItemInventorySS.png

See Also

Video Tutorial

Credits for this video goes to OneTwo. <youtube>0ZH8Bx9jtcs</youtube>