This tutorial will show how to create inventories, different types of items, powerups, item containers, and behaviors to mention a few. It is expected of the reader to have some basic understanding of how the maps works and that you know how to edit XML files and add them again (or use a base folder, I guess that works too).
Also take note on the fact that I will not explain every part of the map I have done. All my findings will however be available on the Wiki / API Docs. I will also explain certain parts like the weapons in closer detail in Part 2 since they required editing a few more files then your common item. I will try to keep Part 1 somewhat simple and I will repeat myself on stuff like facebuttons ALOT, at least for this one.
The basemap used for this tutorial is the Tutorial Map by vjeux with a modified add.mpq2k-script so that it will also add the Item*.xml-files. You will find the map, the datafiles and the modified addscript under resources.
You can also see the map in action (recorded by vjeux).
If you have any questions, additions or clarifications, feel free to send me a PM me here on the boards or [[irc://chat.freenode.net/sc2mapster|catch me on IRC]] (PM Arthas, not HP-X|Arthas).
Now, lets begin shall we!
Table of contents
Items marked with Italics have yet to be written and added
The New XML tags
CAbilInventory
CItemContainer
CItemClass
CItem
CItemEffectInstant
CItemEffectTarget
CAbilPawn
CUnit (Explains items and powerups)
Adding the relevant GameStrings
Part 2 Contents
Resources & Links
Thanks to
The New XML tags
Please take note that these are not all of the new tags. Some of the tags used will be explained during the tutorial, and some will probably be left out in order to maintain a somewhat reasonable length. All data is however available in the map & data files. Of these, not all have been commented, but they will be available in the API XML Docs when I get them in there. If you have questions regarding these, just PM here on the boards or on IRC.
This tag is used in AbilData.xml and sets the pickup and drop range for items. CAbilInventory also utilizes InfoArray children where each InfoArray represents one inventory. The InfoArray themselves have children tags aswell, namely; EmptyFace, Alignment, Container and Hotkey.
The code below will create two inventories for this CAbilInventory (HeroInventory), one for the equipment and one for storage. Here is an example of how it will look (Click here for full picture):
A picture showing the game screen with all the items in the equipment inventory.
Optional tag The distance at which items can be picked up (Default value is 0)
<MaxDropRangevalue="5"/>
Optional tag The distance at which items can be dropped (Default value is 0)
<InfoArray> [ . . . ] </InfoArray>
The block containing the inventory panels information, border text, container etc
<EmptyFacevalue="InventoryEquipment"/>
Sets the border text and icon. value is a reference to any element in ButtonData.xml
<Alignmentvalue="Left"/>
Optional tag Alignment of the inventory panel, valid values are Left and Right (Default value is Right)
<Containervalue="ContainerStorage"/>
Which Container to use in the inventory. Reference to any element in ItemContainerData.xml
<Hotkeyvalue="Button/Hotkey/InventoryStorage"/>
Optional tag The Hotkey to use in order to open the inventory. Reference to any String in GameStrings.txt (Default value is no hotkey)
This is your basic inventory ability, and it doesn't really use any more posts. Hotkey and Alignment for example, are optional. Same with MaxDropRange and Range. The default behaviors for these are, no hotkey at all, Aligntment to the Right and 0 for both droprange and range. Instead of using blocks you can also use a tag line aswell as this:
The CItemContainer tag is the part which tells the game how the slots should be placed inside the inventories, which itemclass that can be used for the slots and whether or not we want the equipmentbehavior of the items to be active or not.
Here is a picture of the inventory which will hopefully help you understand what this code does and what the explanations below means.
On this pic: Four accessory slots to the left, four miscellaneous slots to the right, four storage slots on the bottom, one armor and one weapon slot placed over the model.
Here is a snippet of the CItemContainer, for full code refer to ItemContainerData.xml inside the DataFiles archive at the bottom of the page.
Optional tag This defines that we want a model preview in the inventory, in this case a Ghost.
<ModelWidthvalue="800"/>
Optional tag Width of the model box.
<ModelHeightvalue="800"/>
Optional tag Height of the model box.
<Slots> [ . . . ] </Slots>
These blocks each represent one slot each.
<Classesvalue="WeaponClass"/>
Optional tag The Classes tag have one attribute which refers to an ItemClass in ItemClassData.xml. You can have several instances of this tag in order to allow more than one item class in one slot.
<Equipvalue="1"/>
Optional tag If set to 1 it enables behaviors on items with EquipWeaponArray or EquipBehaviorArray set. Default value if not used is 0
<Rowvalue="2"/>
Slot row placement in the container.
<Columnvalue="5"/>
Slot column placement in the container.
I suppose you are all still with me on this one! As you can see, this is the Container we referred to earlier in the CAbilInventory section for our Equipment Inventory. We have a Model tag with the Ghost as in the screenshot. Then some trial & error for finding the right spot where you want to place the slot. Take your time and look how I placed the boxes above and compare to the screenshot. I'm leaving the Item Storage out, but its the same principal, only simpler.
Finally, there are three ways to use the Slots tag. The one explained above, one tag line variation and finally a semi-line semi-block one. Yet again the one you choose depends on your coding style. However, take note on the fact that Classes can not be used in the tag line and must be placed inside a block. Due to this we have three ways of writing slots. Here is the tag line variation:
<SlotsEquip="1"Row="2"Column="5"/>
Nothing special with this one, except this one can't use the Classes attribute. I used this variation with Equip set to 0 or left it out (same result if you leave tag out or set it to 0) when creating the item storage since that one didn't require any Classes attribute.
Here is a combination of the line variation with the Classes included. This would work just fine if you want to re-write the sample above. This slot would also allow items of the armor class to be placed in this slot.
The CItemClass use is really just to have categories for certain item types. In the example map I have four classes, WeaponClass, ArmorClass, AccessoryClass and MiscClass. Then I bound the armor slot to ArmorClass items only (using the Classes attribute in the slot), Weapons to the Weapon slot and finally Accessories to the four Accessory slots to the left and Misc items to the Misc slots to the right.
CItem is the tag used for creating passive items. The CItem block (not the containers showed on the map though, they are defined in a CUnit field inside UnitData.xml More on that later.) contains info like effects, icons, names etc. Let's have a look.... after having a peek at this example item + description screen.
Top left: The inventory again! The top item in the accessory slots to the left is the charm. Bottom left: A nice mspaint arrow showing you the status icon when wearing the Ancient Charm (yes, I'm aware of the fact it's a slow icon) Top right: The name & description of the item. Bottom right: The dark void if Blizzard don't add the chat gem to SC2.
YARBD (Yet Another Reference to ButtonData.xml) to set the icon, name and tooltip.
<Flagsindex="CanDrop"value="1"/>
Optional tag Your good ole flags tag! The value you set here decides if you can drop items or not.
<Classvalue="AccessoriesClass"/>
Optional tag Binds the item to a certain ItemClass, if Equip is set to 1 you can only place the item in an Accessory class slots or slots without a class set.
<Levelvalue="1"/>
Optional tag Sets the item level for this perticular item. No known use for this tag is known.
<EquipBehaviorArrayvalue="ItemOcularImplants"/>
Optional tag This sets the Behavior (from BehaviorData.xml) we want to use if the item is placed in a slot with Equip set to 1.
I think that the CItem is pretty much straight forward and therefor won't go in very deep to explain what has been done. I will however mention four tags that can be used to apply Behaviors and WeaponArrays and the difference between them.
There are a total of four known item modifiers for this type of item, these types are:
<CarryBehaviorArrayvalue="ItemOcularImplants"/>
Optional tag This sets the Behavior from BehaviorData.xml and is active as long as it's in your inventory, be it Equip 0 or 1.
<CarryWeaponArrayLink="Ghost"/>
Optional tag Will Link to a weapon from WeaponData.xml and is active as long as it's in your inventory, be it Equip 0 or 1.
<EquipBehaviorArrayvalue="ItemOcularImplants"/>
Optional tag This sets the Behavior from BehaviorData.xml we want to use if the item is placed in a slot with Equip set to 1.
<EquipWeaponArrayLink="Ghost"/>
Optional tag Will Link to a weapon from WeaponData.xml we want to use if the item is placed in a slot with Equip set to 1.
Note that the WeaponArray's use Link and not value when defined
Now it's time to move onto something a little more interesting. Active items without targets such as heal, stimpacks and blink. This skill takes all children from CItem and have a few additions of it's own. Let's move on with some more code again!
You know what this is by this time (right???), a reference to a button in ButtonData.xml.
<Flagsindex="CanDrop"value="1"/>
Optional tag Your good ole flags tag! The value you set here decides if you can drop items or not.
<Flagsindex="KillWhenDepleted"value="1"/>
Optional tag Another Flags index. If set to 1, the item will be removed when you have used all the charges.
<Classvalue="MiscClass"/>
Optional tag Binds the item to a certain ItemClass, if Equip is set to 1 you can only place the item in a Misc class slots or slots without a class set.
<Levelvalue="2"/>
Optional tag Sets the item level for this perticular item. No known use for this tag is known.
<Effectvalue="ItemFirstaid"/>
Uses an Effect from EffectData.xml, in this case a custom made for heal
<EffectCost> [ . . . ] </EffectCost>
Optional tagThis block has children that sets life drain, energy drain and holds the charge block.
<Vitalindex="Life"value="-50"/>
Optional tag This line WOULD increase the life by 50 points if not commented out. You can also use Energy instead of Life
<Charge> [ . . . ] </Charge>
Optional tag This block has children that sets charges.
<CountMaxvalue="5"/>
The max amount of charges
<CountStartvalue="5"/>
The number of charges for this item to have when you pick it up.
<CountUsevalue="1"/>
Amount of charges to deduct once you use the item.
<EffectFlagsindex="Transient"value="0"/>
Sets whether or not this item is transient or not. Doesnt seem to have any effect on CItemEffectInstant though
This is one of the tags I feel is not yet fully explored. For example, I do not know how to use cooldown here, the items will not stack properly (see the bug report on this forum) among other things.
But let's start from the top with the changes I've done. I wanted this ability to be a self heal spell. At first I tried the commented line (Vital tag) and realized that used the item even if you were already at full health. Worth mentioning is that when negative, this property will add points instead of removing.
Anyway, since I wanted a proper Heal that won't use a charge & heal if im already at full health I made my own Effect which increased the health after a validation that checked my health. I will cover this later on in another chapter. If you want to explore how I did it yourself, refer to the datafiles for now.
The last part I want to discuss here is the following code block taken from Renees example which I feels need some coverage although the uses / utilizations are unknown:
I won't bother using a list for this one. Anyway, it seems like the CoolDown goes in there if this is correct. The RefundFraction for Resource is supposedly there for adding a refund in case you cancel the item use. I havent found anyway to utilize this since when an item is used, it's always instant.
Identical to CItemEffectInstant with three exceptions, the Effect tag should point on a usable ability like CalldownMULE, not a passive ability.
The next thing, the EffectFlags index="Transient" tag. When you point the try to use an ability on the map you expect the unit to move there if not within range. This however, won't happen IF the flag is set to 1. I can't figure out why you wouldn't want that but thats what the flag does, thus having no effect on CItemEffectInstant due to the range being 0.
And finally, the Range tag, which obviously sets the distance from the unit you can place target.
This blocks contains the information for this pawn ability. Note that the index is important here and has to be Pawn1 as this is the default pawn infoarray.
<ButtonDefaultButtonFace="Salvage"/>
Look, a button. Take a guess on what file it refers to! You guessed it right again, darn it. :(
<Displayindex="Minerals"value="1"/>
If set to 1 it is supposed to show the mineral refund for the item you are about to sell. This is not yet implemented according to Renee
<Displayindex="Gas"value="1"/>
If set to 1 it is supposed to show the gas refund for the item you are about to sell. This is not yet implemented according to Renee
<RefundFractionindex="Minerals"value="1"/>
This tag will act as a multiplier (Item cost * value) for the amount of minerals to be returned when selling. So say you want this ability, Pawn1 to return just 50% of the minerals. Then you simply set the value to 0.5.
<RefundFractionindex="Vespene"value="1"/>
This tag will act as a multiplier (Item cost * value) for the amount of espene to be returned when selling. So say you want this ability, Pawn1 to return just 50% of the minerals. Then you simply set the value to 0.5.
<RefundFractionindex="Terrazine"value="1"/>
This tag will act as a multiplier (Item cost * value) for the amount of terrazine to be returned when selling. So say you want this ability, Pawn1 to return just 50% of the minerals. Then you simply set the value to 0.5.
<RefundFractionindex="Custom"value="1"/>
This tag will act as a multiplier (Item cost * value) for the amount of ustom to be returned when selling. So say you want this ability, Pawn1 to return just 50% of the minerals. Then you simply set the value to 0.5.
<TargetFiltersvalue="-;-"/>
This will decide which target filters the infoarray will apply to. If you only want heroes to be able to sell stuff, this is the place to Make it so!<</color>>)
<ValidatorArrayvalue=""/>
The value here is supposed to point to a validator in ValidatorData.xml if you want some kind of check for sellings items
As you can see in the code above there are a secondary InfoArray, this one can be used if for say, creating a skill that will sell items. Then you can set different RefundFractions for that one. There is a possibility there are more uses for having Pawn2-20 (Yeah, the ones known to be available are Pawn1 to Pawn20).
The item cost mentioned in the RefundFraction tags are set as a child of CUnit which is the to be explained in the next part. And a final note on the indexes of RefundFraction, you might know minerals and vespene as I did. I did not know what Terrazine and custom was though. But these are apparently 2 extra resource types we may use in our maps. Nifty eh?
Time to put the last few pieces together so that we have a completely working inventory, but first a short explanation on what we are about to do. If you have already checked my tutorial map and looked close on UnitData.xml, ModelData.xml and ActorData.xml you will realize that I created a "new" unit for the items and the powerups. You might also realize what a pain it is to add strings for the units and the items and the effects used (I probably missed one, I hade to make tons of strings for tons of stuff). But as this first chapter of the tutorial is to be somewhat comprehensible and easy to understand. The first code block will instead show you how to Modify the SCV unit to act as a container for one item and the Probe for the powerup.
At the moment I doubt you can have more than one item bound to one unit unless you clone them. This will be a lot easier with the editor as it might probably create everything from just editing CItem or so where you get to choose model for the container etc. I will cover making unit & powerup containers in the next chapter.
This is a modification of the already existant SCV units block in UnitData.xml and not a new section at the top.
Here we have it, the SCV with one minor modification, the parent attribute, in this case set to ITEM. This will tell the game we have an item and not a regular unit.
<Itemvalue="ItemOcularImplants"/>
This binds to the item we created in the CItem earlier.
<CostResourceindex="Minerals"value="200"/>
Here is the cost attribute we talked about previously on CAbilPawn. This is the itemcost / value of the item.
<FlagArrayindex="Pawnable"value="1"/>
Now, we also want this item to be PawnAble so we can sell it to a a unit / building with the ability attached.
Note that I removed all other data from the SCV and replaced it with the above lines. The same will be done now that we move to the powerup which we base of the Probe.
The probe with parent set to POWERUP so the game knows what we are dealing with.
<Heightvalue="0.1"/>
This raises the unit a bit from the ground.
<PowerupEffectvalue="PowerupEnergy"/>
And now a new tag, PowerUpEffect where the value is a reference to an effect in EffectData.xml, in this case an effect which raises the energy
<PowerupCost> [ . . . ] </PowerupCost>
Optional tag This block contains the Charge block used for Charges.
<Charge> [ . . . ] </Charge>
Optional tag This tag contains the same children as in CItemEffectInstant and CItemEffectTarget and the only difference is that this sets how many times you can use the powerup before it vanishes. Normally one would leave this and the PowerupCost blocks out.
<CountMaxvalue="5"/>
The max amount of uses
<CountStartvalue="5"/>
The number of uses for this powerup when game is initialized or the item is placed / dropped.
<CountUsevalue="1"/>
Amount of uses to deduct once you use the powerup.
Now, that wasn't too advanced, was it. :) Now for one the final part of CUnit for now, making a building able to Pawn items!
For this you just add the line below to the observatory for example, that will make it possible to drop items with the FlagArray index Pawnable set to 1.
<AbilArrayLink="PawnItems"/>
That's about it. Now we have only one thing left, adding strings!
Before we begin, why in the world would anyone want to use a file such as GameStrings.txt? Well, simple really. Localization, having GameStrings.txt will make it much easier when translating all the strings. GameStrings.txt also allows you to format the strings with color and certain arithmetic values. If typing the strings directly in the Name tag below, it will show, but you are unable to format them using colors or arithmetic functions.
Now, lets have a quick look at what a button looks like.
I think most of the tags above are self explanatory. But as you can see on the Name and Tooltip fields, they refer to Button/Name/ItemOcularImplants and Button/Tooltip/ItemOcularImplants.
The first field tells us that its a Button, the second which type of string, name or tooltip and the last part which Button it is.
Now, this is what we would add to the GameStrings.txt for this button.
Button name:
Button/Name/ItemOcularImplants=Ocular Implants
Not much to say here, the same string as used in the value field above followed by a = and a string.
Button tooltip:
Button/Tooltip/ItemOcularImplants=<c val="ffe303">Class:</c> <c val="00daff">Accessory</c><n/>The ocular implants increases your sight range by 5.<n/>It is however NOT recommended to take these in and out as it may cause permanent damange to your eyes (mentioned in case you didn't figure that out yourself).
The tooltip string is a little longer and here and contains colorization as seen in the screenshots earlier. This by using the c tag and val attribute.
Now, there are ofcourse other strings, for example the ones used for naming Behaviors and their tooltips (the small icons that appears to the left in the info panel). The string for ItemOcularImplants (the Behavior) for example looks like this:
Behavior/Name/ItemOcularImplants=Ocular Implants
Then we also have the hotkeys which is worth mentioning since we used them in the beginning when looking at CAbilInventory. This is how you set a hotkey.
Button/Hotkey/InventoryEquipment=I
Button/Hotkey/InventoryStorage=O
With this, I thank you for reading the first chapter of my tutorial. I hope you enjoyed reading it, or at least learned something while doing so (both is fine with me). If you have any questions, dont hesitate to contact me using any of the methods mentioned in the beginning of the tutorial. Now read down for resources and personal thanks to the people who helped me while writing this tutorial. Until next time!
Part 2 Contents
What you will see in Part 2:
Creating new item containers (units) in XML
Detailed description of creating the Weapons
Detailed description of creating the First Aid skill
Renee and chilled at bbs.islga.org for their work that made it possible to start playing around with inventories, powerups and pawnshops.
vjeux, for his tutorial map which made me actually test stuff. The for the scripts which I loaned to the InventoryMap and the help and feedback he have provided.
Alevice for helping with figuring the Inventory out and his feedback
gregv21 for the first working PawnShop map.
Hati for helping with models and actordata
SC2Mapster & crew for being here
And everyone else I forgot, I'm pretty sure it's not a little bunch that disappeared here. For the next tutorial Ill make sure to note you all properly. :)
Omg ... i just started working with the editor (i know how to make a couple abilities, missiles, but all with data ...)
Is there a tutorial somewhere to understand xml or that stuff he is using, because this is chinese for me 3: Or if there would be an easier way or a normal tutorial on it ?
Help please because i would really like to add this inventory to my map :)
I dont know xml well enough to do coding by it, but from the looks of it, its a basic inventory.
You have 1 inventory ability, and 2 containers.
container 1 is your "bag". Add however many slots you want (64 cap)
container 2 is your "equipment".
When you add slots to your equipment bag, make sure you check "equip". This should make your hero automatically equip the items when theyre moved. Also be sure to set the specific class you want. Ex. Wrists, Armor, Weapon, etc
container 2 is the same as container 1 with a couple of differences.
1. Set the model you want and the size. The model is usually the unit thats selected (I think)
2. Strategic positioning: Note the locations of the item slots in the "equipment" bag. This is simply row and column positioning. In this case, he has the bag item slots (column,row) at locations 2,3; 3,4; 4,0; 4,7; 5,0; 5,7; 5,0; 5,8; 7,0; 7,2,;7,3; 7,4; 7,5; and 7,7
Thx for the help, but i understand what the inventory is ... i would like to know how to addict to my map, because i have no idea what to do with those chinese writings in colors ;D
Ok ... until now, i was making abilities with behaviors, effects, requirements etc ... using the data editor.
I used trigger too once to make a hero selector.
I've followed many tutorials, but this is the first that is not a Data/Trigger one ... all the green, red and other color writings, i don't know how to use them; and i would really like to add this inventory to my map. Can you explain me what to do with the color sentences and values ?
Thats XML. When you use the GUI, its adding XML. The GUI is just a interface. When in the data module, you can press ctrl+3 to view the xml. The answer I gave you earlier is basically the GUI version of what that XML does. (press ctrl+1 to switch back to table view)
Ok ok ok ... i know it seems noob, but what is the GUI ? Is it an interface where i just copy paste all the codes that are in color, and that will magically do my inventory like as shown ?
For the XML view, i knew we could see it, i just didn't know where to add those codes ...
I would really appreciate if you could explain to me like i'm 5 how to use these codes.
Actually, I plan on doing an in-depth tutorial soon which will (sadly) cause all previous inventory tutorials (including this one) to be outdated and obsolete in regards to the way items are bought. Give me some time and Ill pm you a link when Im done.
Inventory, items, powerups and more - Part 1
Introduction
This tutorial will show how to create inventories, different types of items, powerups, item containers, and behaviors to mention a few. It is expected of the reader to have some basic understanding of how the maps works and that you know how to edit XML files and add them again (or use a base folder, I guess that works too).
Also take note on the fact that I will not explain every part of the map I have done. All my findings will however be available on the Wiki / API Docs. I will also explain certain parts like the weapons in closer detail in Part 2 since they required editing a few more files then your common item. I will try to keep Part 1 somewhat simple and I will repeat myself on stuff like facebuttons ALOT, at least for this one.
The basemap used for this tutorial is the Tutorial Map by vjeux with a modified add.mpq2k-script so that it will also add the Item*.xml-files. You will find the map, the datafiles and the modified addscript under resources.
You can also see the map in action (recorded by vjeux).
If you have any questions, additions or clarifications, feel free to send me a PM me here on the boards or [[irc://chat.freenode.net/sc2mapster|catch me on IRC]] (PM Arthas, not HP-X|Arthas).
Now, lets begin shall we!
Table of contents
Items marked with Italics have yet to be written and added
The New XML tags
Please take note that these are not all of the new tags. Some of the tags used will be explained during the tutorial, and some will probably be left out in order to maintain a somewhat reasonable length. All data is however available in the map & data files. Of these, not all have been commented, but they will be available in the API XML Docs when I get them in there. If you have questions regarding these, just PM here on the boards or on IRC.
CAbilInventory
Resource: CAbilInventory at AbilData.xml wikipage
Hotkey no longer works in retail
This tag is used in AbilData.xml and sets the pickup and drop range for items. CAbilInventory also utilizes InfoArray children where each InfoArray represents one inventory. The InfoArray themselves have children tags aswell, namely; EmptyFace, Alignment, Container and Hotkey.
The code below will create two inventories for this CAbilInventory (HeroInventory), one for the equipment and one for storage. Here is an example of how it will look (Click here for full picture):
A picture showing the game screen with all the items in the equipment inventory.
This is your basic inventory ability, and it doesn't really use any more posts. Hotkey and Alignment for example, are optional. Same with MaxDropRange and Range. The default behaviors for these are, no hotkey at all, Aligntment to the Right and 0 for both droprange and range. Instead of using blocks you can also use a tag line aswell as this:
In the end you will probably end up picking the method that fits your coding style.
Now, let's move on with the Container tag.
CItemContainer
Resource: ItemContainerData.xml wikipage
The CItemContainer tag is the part which tells the game how the slots should be placed inside the inventories, which itemclass that can be used for the slots and whether or not we want the equipmentbehavior of the items to be active or not.
Here is a picture of the inventory which will hopefully help you understand what this code does and what the explanations below means.
On this pic: Four accessory slots to the left, four miscellaneous slots to the right, four storage slots on the bottom, one armor and one weapon slot placed over the model.
Here is a snippet of the CItemContainer, for full code refer to ItemContainerData.xml inside the DataFiles archive at the bottom of the page.
I suppose you are all still with me on this one! As you can see, this is the Container we referred to earlier in the CAbilInventory section for our Equipment Inventory. We have a Model tag with the Ghost as in the screenshot. Then some trial & error for finding the right spot where you want to place the slot. Take your time and look how I placed the boxes above and compare to the screenshot. I'm leaving the Item Storage out, but its the same principal, only simpler.
Finally, there are three ways to use the Slots tag. The one explained above, one tag line variation and finally a semi-line semi-block one. Yet again the one you choose depends on your coding style. However, take note on the fact that Classes can not be used in the tag line and must be placed inside a block. Due to this we have three ways of writing slots. Here is the tag line variation:
Nothing special with this one, except this one can't use the Classes attribute. I used this variation with Equip set to 0 or left it out (same result if you leave tag out or set it to 0) when creating the item storage since that one didn't require any Classes attribute.
Here is a combination of the line variation with the Classes included. This would work just fine if you want to re-write the sample above. This slot would also allow items of the armor class to be placed in this slot.
CItemClass
Resource: ItemClassData.xml wikipage
The CItemClass use is really just to have categories for certain item types. In the example map I have four classes, WeaponClass, ArmorClass, AccessoryClass and MiscClass. Then I bound the armor slot to ArmorClass items only (using the Classes attribute in the slot), Weapons to the Weapon slot and finally Accessories to the four Accessory slots to the left and Misc items to the Misc slots to the right.
An example class in the map for Accessories
CItem
Resource: CItem at ItemData.xml wikipage
CItem is the tag used for creating passive items. The CItem block (not the containers showed on the map though, they are defined in a CUnit field inside UnitData.xml More on that later.) contains info like effects, icons, names etc. Let's have a look.... after having a peek at this example item + description screen.
Top left: The inventory again! The top item in the accessory slots to the left is the charm.
Bottom left: A nice mspaint arrow showing you the status icon when wearing the Ancient Charm (yes, I'm aware of the fact it's a slow icon)
Top right: The name & description of the item.
Bottom right: The dark void if Blizzard don't add the chat gem to SC2.
And now for the code:
I think that the CItem is pretty much straight forward and therefor won't go in very deep to explain what has been done. I will however mention four tags that can be used to apply Behaviors and WeaponArrays and the difference between them.
There are a total of four known item modifiers for this type of item, these types are:
Note that the WeaponArray's use Link and not value when defined
CItemEffectInstant
Resource: CItemEffectInstant at ItemData.xml wikipage
Now it's time to move onto something a little more interesting. Active items without targets such as heal, stimpacks and blink. This skill takes all children from CItem and have a few additions of it's own. Let's move on with some more code again!
This is one of the tags I feel is not yet fully explored. For example, I do not know how to use cooldown here, the items will not stack properly (see the bug report on this forum) among other things.
But let's start from the top with the changes I've done. I wanted this ability to be a self heal spell. At first I tried the commented line (Vital tag) and realized that used the item even if you were already at full health. Worth mentioning is that when negative, this property will add points instead of removing.
Anyway, since I wanted a proper Heal that won't use a charge & heal if im already at full health I made my own Effect which increased the health after a validation that checked my health. I will cover this later on in another chapter. If you want to explore how I did it yourself, refer to the datafiles for now.
The last part I want to discuss here is the following code block taken from Renees example which I feels need some coverage although the uses / utilizations are unknown:
I won't bother using a list for this one. Anyway, it seems like the CoolDown goes in there if this is correct. The RefundFraction for Resource is supposedly there for adding a refund in case you cancel the item use. I havent found anyway to utilize this since when an item is used, it's always instant.
CItemEffectTarget
Resource: CItemEffectTarget at ItemData.xml wikipage
Identical to CItemEffectInstant with three exceptions, the Effect tag should point on a usable ability like CalldownMULE, not a passive ability.
The next thing, the EffectFlags index="Transient" tag. When you point the try to use an ability on the map you expect the unit to move there if not within range. This however, won't happen IF the flag is set to 1. I can't figure out why you wouldn't want that but thats what the flag does, thus having no effect on CItemEffectInstant due to the range being 0.
And finally, the Range tag, which obviously sets the distance from the unit you can place target.
CAbilPawn
Resource: CAbilPawn at AbilData.xml wikipage
Now for the CAbilPawn tag which is just that, a pawn ability that let's us sell items to the units and buildings with this ability attached.
As you can see in the code above there are a secondary InfoArray, this one can be used if for say, creating a skill that will sell items. Then you can set different RefundFractions for that one. There is a possibility there are more uses for having Pawn2-20 (Yeah, the ones known to be available are Pawn1 to Pawn20).
The item cost mentioned in the RefundFraction tags are set as a child of CUnit which is the to be explained in the next part. And a final note on the indexes of RefundFraction, you might know minerals and vespene as I did. I did not know what Terrazine and custom was though. But these are apparently 2 extra resource types we may use in our maps. Nifty eh?
CUnit (Explains items and powerups)
Resource: CUnit at UnitData.xml wikipage
Time to put the last few pieces together so that we have a completely working inventory, but first a short explanation on what we are about to do. If you have already checked my tutorial map and looked close on UnitData.xml, ModelData.xml and ActorData.xml you will realize that I created a "new" unit for the items and the powerups. You might also realize what a pain it is to add strings for the units and the items and the effects used (I probably missed one, I hade to make tons of strings for tons of stuff). But as this first chapter of the tutorial is to be somewhat comprehensible and easy to understand. The first code block will instead show you how to Modify the SCV unit to act as a container for one item and the Probe for the powerup.
At the moment I doubt you can have more than one item bound to one unit unless you clone them. This will be a lot easier with the editor as it might probably create everything from just editing CItem or so where you get to choose model for the container etc. I will cover making unit & powerup containers in the next chapter.
This is a modification of the already existant SCV units block in UnitData.xml and not a new section at the top.
It's not much code, but lets dig!
Note that I removed all other data from the SCV and replaced it with the above lines. The same will be done now that we move to the powerup which we base of the Probe.
Now, that wasn't too advanced, was it. :) Now for one the final part of CUnit for now, making a building able to Pawn items!
For this you just add the line below to the observatory for example, that will make it possible to drop items with the FlagArray index Pawnable set to 1.
That's about it. Now we have only one thing left, adding strings!
Adding the relevant GameStrings
Resource: Color constants at Constants wikipage
Before we begin, why in the world would anyone want to use a file such as GameStrings.txt? Well, simple really. Localization, having GameStrings.txt will make it much easier when translating all the strings. GameStrings.txt also allows you to format the strings with color and certain arithmetic values. If typing the strings directly in the Name tag below, it will show, but you are unable to format them using colors or arithmetic functions.
Now, lets have a quick look at what a button looks like.
I think most of the tags above are self explanatory. But as you can see on the Name and Tooltip fields, they refer to Button/Name/ItemOcularImplants and Button/Tooltip/ItemOcularImplants.
The first field tells us that its a Button, the second which type of string, name or tooltip and the last part which Button it is.
Now, this is what we would add to the GameStrings.txt for this button.
Button name:
Button/Name/ItemOcularImplants=Ocular Implants
Not much to say here, the same string as used in the value field above followed by a = and a string.
Button tooltip:
Button/Tooltip/ItemOcularImplants=<c val="ffe303">Class:</c> <c val="00daff">Accessory</c><n/>The ocular implants increases your sight range by 5.<n/>It is however NOT recommended to take these in and out as it may cause permanent damange to your eyes (mentioned in case you didn't figure that out yourself).
The tooltip string is a little longer and here and contains colorization as seen in the screenshots earlier. This by using the c tag and val attribute.
Now, there are ofcourse other strings, for example the ones used for naming Behaviors and their tooltips (the small icons that appears to the left in the info panel). The string for ItemOcularImplants (the Behavior) for example looks like this:
Behavior/Name/ItemOcularImplants=Ocular Implants
Then we also have the hotkeys which is worth mentioning since we used them in the beginning when looking at CAbilInventory. This is how you set a hotkey. Button/Hotkey/InventoryEquipment=I Button/Hotkey/InventoryStorage=O
With this, I thank you for reading the first chapter of my tutorial. I hope you enjoyed reading it, or at least learned something while doing so (both is fine with me). If you have any questions, dont hesitate to contact me using any of the methods mentioned in the beginning of the tutorial. Now read down for resources and personal thanks to the people who helped me while writing this tutorial. Until next time!
Part 2 Contents
What you will see in Part 2:
What you MIGHT see in Part 2:
Resources & Links
Files
The Inventory tutorial map file
The XML files edited to create this map + GameStrings.txt
Updated add.mpq2k script which also adds the Item*.xml files
Information and documentation
XML data files documentation
These forums
Tutorial Map by vjeux (thread with information)
Item*.xml documentation by chilled (in chinese)
CItem* information by Renee (in chinese)
Powerup information by Renee (in chinese)
CAbilPawn information (in chinese)
Thanks to
Renee and chilled at bbs.islga.org for their work that made it possible to start playing around with inventories, powerups and pawnshops.
vjeux, for his tutorial map which made me actually test stuff. The for the scripts which I loaned to the InventoryMap and the help and feedback he have provided.
Alevice for helping with figuring the Inventory out and his feedback
gregv21 for the first working PawnShop map.
Hati for helping with models and actordata
SC2Mapster & crew for being here
And everyone else I forgot, I'm pretty sure it's not a little bunch that disappeared here. For the next tutorial Ill make sure to note you all properly. :)
@HPX: Go
Is there a way I can get those files in .zip format? Thanks.
@WraithChaser: Go
Sure.
This zip is mapfile, datafiles and script in one.
This is sexy - I wish I knew your personally HPX I want to be your groupie
Omg ... i just started working with the editor (i know how to make a couple abilities, missiles, but all with data ...)
Is there a tutorial somewhere to understand xml or that stuff he is using, because this is chinese for me 3: Or if there would be an easier way or a normal tutorial on it ?
Help please because i would really like to add this inventory to my map :)
@MacSC2: Go
I dont know xml well enough to do coding by it, but from the looks of it, its a basic inventory.
You have 1 inventory ability, and 2 containers. container 1 is your "bag". Add however many slots you want (64 cap) container 2 is your "equipment". When you add slots to your equipment bag, make sure you check "equip". This should make your hero automatically equip the items when theyre moved. Also be sure to set the specific class you want. Ex. Wrists, Armor, Weapon, etc
container 2 is the same as container 1 with a couple of differences. 1. Set the model you want and the size. The model is usually the unit thats selected (I think) 2. Strategic positioning: Note the locations of the item slots in the "equipment" bag. This is simply row and column positioning. In this case, he has the bag item slots (column,row) at locations 2,3; 3,4; 4,0; 4,7; 5,0; 5,7; 5,0; 5,8; 7,0; 7,2,;7,3; 7,4; 7,5; and 7,7
@ckSynergy: Go
Thx for the help, but i understand what the inventory is ... i would like to know how to addict to my map, because i have no idea what to do with those chinese writings in colors ;D
@MacSC2: Go
I'm not sure I understand the question?
@ckSynergy: Go
Ok ... until now, i was making abilities with behaviors, effects, requirements etc ... using the data editor. I used trigger too once to make a hero selector.
I've followed many tutorials, but this is the first that is not a Data/Trigger one ... all the green, red and other color writings, i don't know how to use them; and i would really like to add this inventory to my map. Can you explain me what to do with the color sentences and values ?
@MacSC2:
Thats XML. When you use the GUI, its adding XML. The GUI is just a interface. When in the data module, you can press ctrl+3 to view the xml. The answer I gave you earlier is basically the GUI version of what that XML does. (press ctrl+1 to switch back to table view)
@ckSynergy: Go
Ok ok ok ... i know it seems noob, but what is the GUI ? Is it an interface where i just copy paste all the codes that are in color, and that will magically do my inventory like as shown ?
For the XML view, i knew we could see it, i just didn't know where to add those codes ...
I would really appreciate if you could explain to me like i'm 5 how to use these codes.
Thanks alot for your help so far,
Mac
@MacSC2:
Actually, I plan on doing an in-depth tutorial soon which will (sadly) cause all previous inventory tutorials (including this one) to be outdated and obsolete in regards to the way items are bought. Give me some time and Ill pm you a link when Im done.
@ckSynergy: Go
thx alot bro !
@MacSC2: Go
Actually I may not have time to write the inventory for awhile. If you have skype, pm me with your contact information and I can help you out.