- Joined
- Nov 25, 2014
- Messages
- 24
A Working Unit Rank System
~ A Tutorial ~
~ A Tutorial ~
I have completed a unit rank system that I intend to use for my SciFi mod (Title: Dubious But Forthcoming). I wish to share the rank systems' functionality because I don't think anyone else has done it quite the same way as I have, and I, of course, believe someone may find this useful!
What Makes a Unit Rank System?
Of course, when one sets out to make a system such as this, he or she inevitably wants to do everything done in other popular games out there. The ex-Command & Conquer series (because 4 killed it) is a good example of this. Some of the common characteristics these unit rank systems have are:
-A visible kill count
-A visible rank GUI
-Unit perks per rank (less common)
-Multible Unit Instanceability (every unit ranks up)
-A visible rank GUI
-Unit perks per rank (less common)
-Multible Unit Instanceability (every unit ranks up)
Some Immediate Ideas:
At first, one might think of remaking their faction entirely out of heroes and simply setting the stats like "Stats - Hero - Hide Hero Death Message" to true. That way you don't have to be berated by something reminiscent of Bungie's old Myth series... "Casualties." (You're real old if you know what I'm talking about.) Other people tend towards using abilities to display rank and kills. And still others will use hashtables or JASS which, although useful, are more complicated than we need for this task!
The problem with the hero system is that it doesn't adequately show kill count, and I suspect there could be errors in the game's engine if you started creating armies of over a hundred units that were technically heroes. You could set experience gained for every unit to 1, but then you have a giant loading bar displaying kill count; that wouldn't really look appealing. Plus, what if you wanted actual heroes in your game anyways? Abilities are a viable option but are a hassle because of the 100 tooltips you'd have to program- not to mention the fact that you could only tally 100 kills.
So what's the optimal choice? Glad you asked! Attached are some files you may download and follow along with. I recommend you import Rank_Color.blp, Rank_Corporal.mdx, DISPASBTN_Rank_Corporal.tga, DISPASBTN_Rank_Conscript.tga, PASBTN_Rank_Corporal.tga, and PASBTN_Rank_Conscript.tga into a map if you wish to do so.
Set the directories for the image files as so:
Rank_Color.blp
ReplaceableTextures\PassiveButtons\PASBTN_Rank_Conscript.tga
ReplaceableTextures\PassiveButtons\PASBTN_Rank_Corporal.tga
ReplaceableTextures\CommandButtonsDisabled\DISPASBTN_Rank_Conscript.tga
ReplaceableTextures\CommandButtonsDisabled\DISPASBTN_Rank_Corporal.tga
Using an Item for kill count:
The other option is to use an item and tally charges on it. Here you need one tooltip and can tally more kills (up to 1000). First, create a new item and choose an icon to represent your kill count.
I personally like using the "Ankh of Reincarnation" icon because I'm going for a cyberpunk feel in my mod. In this item's table of defined values, set everything that can be set to False to False. For example, set "Stats - Can Be Dropped" to false. We don't want the user dropping or using the item in any sort of way.
From here on, we're going to be placing (through triggers) this item into each unit's inventory in slot 1 as they're trained, so the next step is to go through the object editor and give any units you want to be able to level up an inventory- in "Abilities - Normal" give them "Inventory (Hero)" for example.Displaying Rank GUI
The next problem is showing the rank! Here we could effectively use an ability or an item. It really doesn't matter thanks to the spellbook ability which can condense space tremendously. For the sake of this tutorial, I'll use an item. I also went one step further and developed a model to be used as an attachment.

Using an Item for rank:
Now, create another item and choose an icon for it. For me, I used the "PASBTN_Rank_Conscript.tga" to represent the lack of rank at the start.
I developed my own TGAs using Gimp based on the entire military E series and O series. You can use whatever images you want really. For example, the Scrin faction in C&C 3 have an entirely different icon for each level than GDI. Once again, set this item's values to false.
This item (as far as this tutorial goes) will rest solely in slot 2. Next, create a trigger that gives units these items as they're created. It should go something like this...
-
Events
-
Unit - A unit Finishes training a unit
-
-
Conditions
-
(Item carried by (Triggering unit) in slot 1) Equal to No item
-
(Item carried by (Triggering unit) in slot 2) Equal to No item
-
(Level of Inventory (Hero) for (Triggering unit)) Greater than 0
-
-
Actions
-
Set tempUnit = (Triggering unit)
-
Hero - Create [Item For Kill Count - The Ankh] and give it to tempUnit
-
Hero - Create [Item Showing Initial Rank - Conscript] and give it to tempUnit
-
Creating the Next Rank
Now, before we proceed, we'll need to create one more item. Once more, turn all the stats for this item to false. Call this item "Corporal." For the sake of this tutorial, set its "Art - Icon - Game Interface" to the imported "PASBTN_Corporal.tga."
I included the model attachment just in case you wished to include that in your rank GUI. To attach it, you'll need to create an ability... call it "Rank Corporal" ... then in "Art - Target" use "Corporal.mdx" and in "Art - Attachment Point 1" enter in "overhead." Then return to your Corporal item and under its "Abilities - Abilities" give it the new ability "Rank Corporal" that you just created.
Play Warcraft, Rank Up, Get Pig!
Handling the kills and ranking up is straightforward from here.

The trigger looks like this...
-
Events
-
Unit - A unit Dies
-
-
Conditions
-
(Level of Inventory (Hero) for (Killing unit)) Greater than 0
-
-
Actions
-
Item - Set charges remaining in (Item carried by (Killing unit) in slot 1) to ((Charges remaining in (Item carried by (Killing unit) in slot 1)) + 1) //Remember slot 1 is our Kill Count item
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Charges remaining in (Item carried by (Killing unit) in slot 1)) Equal to Rank_Kills[0] //An array that has a predefined number of kills for the first rank.
-
-
Then - Actions
-
Set Random_Needed = (Charges remaining in (Item carried by (Killing unit) in slot 2)) //A random integer that temporarily stores the number of perk point (charges) before the item is removed
-
Item - Remove (Item carried by (Killing unit) in slot 2)
-
Hero - Create (First Rank Item) and give it to (Killing unit)
-
Item - Set charges remaining in (Item carried by (Killing unit) in slot 2) to (Random_Needed + 2) //This tallies the points the unit has to spend on perks like increased HP
-
-
Else - Actions
-
Do nothing
-
-
-
Perk Points
Unit Perks are handled in an ability based on spellbook for me. This is relatively straightforward to set up from here. Just choose which abilities you want and put them into your spellbook ability.
I simply re-purposed the "manual of health," "gold coins" and the item which permanently increases attack whose name I forgot...
The slightly tricky part for these perks is the triggering which I handled like below. Please note, that I created three separate ability objects based on the "Channel" ability. It is strongly recommended by many on these forums to use "Channel" whenever creating a custom ability which is what's going on here.
-
Events
-
Unit - A unit Begins channeling an ability
-
-
Conditions
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Ability being cast) Equal to Upgrade Health (rank points) //Upgrade Health is the name I gave one of my perk abilities
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Charges remaining in (Item carried by (Triggering unit) in slot 2)) Greater than 0
-
-
Then - Actions
-
Item - Set charges remaining in (Item carried by (Triggering unit) in slot 2) to ((Charges remaining in (Item carried by (Triggering unit) in slot 2)) - 1)
-
Hero - Create (Health Item) and give it to (Triggering unit) //In this case, my Health Item was simply "Manual of Health" which gives +50 HP bonus permanently
-
-
Else - Actions
-
Game - Display to (All players matching ((Owner of (Casting unit)) Equal to (Matching player))) the text: This unit has no points to spend //No Free Perks!
-
Unit - Order (Triggering unit) to Stop //Would look silly if the unit played an animation whenever it wanted to
-
-
-
-
Else - Actions
-
Do Nothing
-
-
-
Some of you may be thinking... well what if I want to carry more items? This system will be taking away two of my six slots! This is true. The fortunate thing here is that there is a way to carry nearly unlimited items with JASS or even use the spellbook ability to "pseudo-carry" items saved as abilities, but alas that is another tutorial found elsewhere.
The Ups
-We can track kill counts with little stress on the system.
-We have two sources of visible rank GUI
-Our units can acquire perks
-Each trigger is generic (meaning it will target any unit regardless of race or color)
-We can easily limit or expand upon the functionality of this system
Well... this sums up my first tutorial. Hope it was helpful to someone! +1 to rep if you liked.
Attachments
-
Oink.jpg770.8 KB · Views: 535
-
RankUp!.jpg743.6 KB · Views: 520
-
Points!.jpg736 KB · Views: 485
-
Rank_Color.blp2.4 KB · Views: 141
-
Rank_Corporal.mdx5.1 KB · Views: 128
-
DISPASBTN_Rank_Corporal.tga5.5 KB · Views: 128
-
PASBTN_Rank_Corporal.tga5.5 KB · Views: 130
-
DISPASBTN_Rank_Conscript.tga364 bytes · Views: 134
-
PASBTN_Rank_Conscript.tga364 bytes · Views: 127
Last edited by a moderator: