• 0

    posted a message on [Data] Unit: Gain Energy While Attacking

    What We'll Be Doing

    The goal of this tutorial is to create a buff that can be attached to any unit that will make the unit gain energy while it is attacking. This achieves a WoW-Rogue like effect for your units, where they can spend energy on abilities the more they attack.

    This is a very simple tutorial and is useful for starting work with Buffs and Units.

    Creating Our Buff

    We'll create a new Buff Behavior called "Combo Energy". We basically want this buff to increase the unit's Energy Regeneration Rate while the unit is attacking.

    Open the Data Editor and set the Data Type to Behaviors. Buffs are a type of Behavior and they directly affect the unit they are attached to. Right click the list below and choose Add Object.... This will bring up a panel for creating a whole new behavior. Set the Name to Combo Energy. Click the Suggest button. Set the Behavior Type to Buff. The other options on this panel allow you to have the editor automatically fill in some fields based on previously created Behaviors. We're making one from scratch so leave everything else alone and click OK.

    On the right panel you'll now see a bunch of fields listed out. It may seem overwhelming at first, but you'll begin to notice the few important fields you'll normally be dealing with while mapping. Some very important fields, you'll notice, are those with a "+" on the end of them. This merely means that the field takes multiple values and generally has a special menu to fill in data, but these tend to be important because a lot of functionality is handled here.

    Our Buff is going to work by changing the unit's energy regeneration rate to a non-negative value. All of the important data for Buffs is tucked away in the Modification + field. Again, notice the "+". Go ahead and double click on the Modification + field. It may take a while, but a menu should pop up.

    Again, you're presented with a ton of fields and information. Remember, it will take time, but you'll soon begin to understand how to ignore fields that you don't care about and hone in on the important ones. This menu in particular has a lot of information because it shows every possible value we can change for a unit through this buff. That's a lot of stuff, but we're here for just one thing: Energy Regeneration Rate.

    Scroll down through the menu until you find Vital Regeneration Bonus. It's not too far down, just keep looking. You will see a list of the "vitals" which are just Energy, Shields, and Life. Clearly, we're going to want to change the Energy vital. Select the Energy item from the list and change the Selected Value(s) to 5.0. We're all done with this panel. Click OK.

    So, what we have just done is made our Buff modify the unit's Energy Regeneration Rate by increasing it by 5 points. It is important to note that this is not setting the rate to 5.0, but increasing it by 5.0.

    We still have a problem, though, this buff will always be active, and that won't do. We only want energy to increase so long as the unit is attacking something! This is where Validators come in. Validators are yet another element of the Data Editor. They basically allow for conditions to be checked before a Buff, Ability, or what have you is activated. So, we need a validator to check that the unit is attacking and have our buff only active while it is attacking.

    As you may have guessed, we'll be editing the Validators (Disable) field at the bottom of our buff. Notice there are two Validator types. Validators (Disable) is a list of validators, that, when one is not valid, will only disable the buff. That is, if conditions change and the validators are all valid, then the buff will become active again. The Validators (Remove) will remove the buff when something is invalid. Meaning, even if the validators are all valid later on, the buff has been removed from the unit and therefore won't affect the unit.

    So, inside of the Validators (Disable) field click the green X and in the popup find the CasterIsAttacking (Unnamed) Validator. Select it and click OK. This is the only validator we'll need for this buff, so click the OK button to close the field edit.

    Our buff will now be disabled anytime the "caster" isn't attacking. Caster is just basically the unit being affected by this buff.

    Buffing Up

    Ok, so now we have our neat Combo Energy buff. We need to give it to a unit so that the unit can enjoy the glory of energy gain.

    In the Data Editor, change the Data Type to Units. Find the Marine element. Right click the Marine and choose Duplicate Object.... In the popup, check the box next Marine under the Actors folder. Click OK.

    When we duplicated objects, there is a lot of data associated with the original object. This menu allows us to pick what associated data we would like to copy as well. Why are we only copying the Marine actor? Because Actors are objects which connect visuals to the units. There can only be one Actor per Unit. So, if we weren't to copy the Marine Actor, our new marine, when placed in the game, would appear as a transparent sphere since there is no visual data associated with the unit. So, we copy along the Actor with our new unit. If we wished change data about the Marine's Gauss Rifle, then we would copy this value too. But we're just messing around with energy for now. Again, this is something you'll get a feel for the more you play with the editor.

    So, when you clicked OK, it made a new object with the fields copied from the original Marine. At the moment there is no difference between the two units, except for the name. The editor assigns it, by default, to "[Origin Name] Copy". We'll go ahead and change this. Right click the Marine Copy and choose Modify Object....

    You'll see a familiar panel pop up. Change the name to Energy Marine and click Suggest. Leave the other options alone and click OK. There, our marine now has a proper name.

    With our new Energy Marine selected, look at the fields on the right. These are all of the options we can change for a Unit. We're going to give the Marine some Energy. Scroll down through fields and find and edit the Stats - Energy Maximum field. Change the value to 100. This gives the unit a maximum energy level of 100. Change the Energy Regeneration Rate to -1. This makes the energy level tick down. Note: the energy level will never go negative. Leave the Energy Starting Amount at 0. This way, our marine won't start with energy.

    Good, now our Marine will have an energy bar and will lose energy slowly if he ever has energy. If you wanted to give the Marine a standard energy feel, like the Ghost, just set the Regeneration Rate to something positive.

    Ok, we're almost done, we now need to actually give the Energy Marine our Combo Energy buff! Find the (None) - Behaviors + field and edit it. Notice there is already a Behavior in here: the Shield. You can remove or keep this. But let's add our Combo Energy buff. Click the green X to the right and, with the new blank line selected, change Behavior to Combo Energy. Click OK.

    There we have it. Our Energy Marine now has the Combo Energy buff. To test it out, place an Energy Marine on the map and give him some enemies to fight. Watch as his energy level increases as he attacks, and drops as he idles!

    Of course, the Energy Marine has no Abilities to spend energy on, as that is out of the scope of this tutorial, but see if maybe you can't figure it out. Remember, one of the best ways to figure out how to do something is to look at how previously created units already do it. For example, if you want to make your Energy Marine Blink, look at the Stalker Unit.

    Posted in: Tutorials
  • 0

    posted a message on [Data] Marine Protoss Shield Upgrades

    If you mean the outline seen around protoss units in the unit information panel, I believe you're going to have to make your own texture. But, it is definitely easy to set. Just set the Shield Layer field for your Ghost Actor to your new texture. Check out the zealot actor to see what I mean.

    Posted in: Tutorials
  • 0

    posted a message on [Data] WC3-Esque Hero Ability Training

    IMPORTANT NOTE - READ THIS IF YOU HAVE ISSUES WITH ABILITIES

    If, after following this tutorial, you decide to create your own learnable abilities to your hero (as you should) and you notice that the command card buttons are shown before the ability has been learned then you must change the Name of the Ability by right-clicking and using Modify Object... and remember to click Suggest. If you get this issue, first try assigning a random name to your ability such as "Blah" or "auofduj". This is a very annoying bug (feature?) that has given me problems.

    For example, I decided to add a new ability called Hero Cloak and I made it just like the Ghost - Personal Cloaking ability except without requirements. When I set everything up for the hero to learn this ability, I noticed that the cloaking button was already available before learning it! I toyed for hours with it, only to finally attempting to change the name to Hero Silly and lo-and-behold, the ability was not shown by default!

    I've narrowed down some ways to avoid this:

    1. Avoid using any word in the name of the effect or behavior the ability refers to. For example, the word "Cloak" was in the behavior's name for my "Hero Cloak" ability.

    2. Avoid using words related to the description of the effect or behavior the ability refers to. For example, I attempted using the name Hero Hide and it still wouldn't work.

    3. Use "Tele" instead of "Blink" for your new ability names.

    What We're Doing

    This tutorial will cover creating a WC3-esque ability training menu. This means, for every level you gain a point to spend on training a new ability for the hero. The work is fairly intensive but not so much that it should drive you away from creating your hero units. We're going to work with some of pre-existing abilities and modify them a bit to fit our needs.

    We're going to create a unit called Hero, who can level up and can learn new abilities with earned skill points. To keep things simple, we'll create a single ability called Hero Stimpack which will operate like the Marine Stimpack ability. But, it will require a skill point to purchase.

    So, fire up the SC2 Editor and get ready for some hero action.

    Changing the Past

    We'll begin by first preparing the Hero Stimpack ability so we don't have to fuss with it later on. In the Data Editor set the Data Type to Abilities. Find Marine - Stimpack and right click and select Duplicate Object. Check the box for the Actors folder. Click OK.

    We need to set the name to something easy to understand. Right click the newly created Marine - Stimpack Copy and select Modify Object.... In the popup menu, set the Name to Hero Stimpack. Click Suggest and click OK. With this object selected, change the (None) - Editor Prefix field to be empty instead of "Marine -".

    Edit the (None) - Cost + field. Select the item in the list at the top and scroll to the bottom of the menu and select the Life item from the Vital list and click the red x to delete it. Click OK. Now our stimpack will not harm our hero when we use it.

    At this point, be sure you have the Show Object Explorer button enabled. It is found just to the left of the Search bar for the Data Editor. This will show the associated objects to your currently selected object.

    The astute tutorialee will notice that there is a Requirements heading on the bottom left panel. We'll need to remove that because we don't want to have to research Stimpack before using it. The astute tutorialee may have also notice that right clicking on the requirement has an option Explain Link. This tells us where the relationship comes from. It says it's under the ability Hero Stimpack's (None) - Commands - Requirements field. Let's edit that field. Edit the (None) - Commands +

    In the list at the top of the new menu. Select the Execute command. You'll notice under the Requirements heading there is a requirement called "Use Stimpack". Ah-ha! We've found our link. Let's remove it by clicking the little red X to the bottom right. With that taken care of, click OK. Now that pesky requirement heading is gone for good! Stimpack is free to use.

    Makings of a Hero

    With our special hero stimpack ability, it's time to setup some important things to be able to actually make a levelable hero. First, we'll make a behavior that sets up a hero's experience required to level and the benefits of each level. This behavior type is known as a Veterancy

    Set the Data Type to Behaviors and add a new Object. Set the object's Name to Hero Leveling. Click Suggest and change the Behavior Type to Veterancy. Click OK.

    The only field we're interested in is the Verterancy Levels + field. This is a big one where we will setup every about each level. And I mean everything...

    If you've followed some of the other hero-based tutorials this should all seem familiar...

    In the Veterancy Levels + menu click the little green X 3 times to create 3 distinct levels. (For this tutorial our hero will only be able to reach level 3). Select Level 0 and set the Minimum Experience to 30. Select Level 1 and set the Minimum Experience to 60. Select Level 2 and set the Minimum Experience to 90. Obviously, this means when the unit gets 30 experience, he'll level to level 0 (first level), and once he gets 60 points, he'll reach level 1. Notice there are a TON of other settings you can change per level. Explore and play around. For our purposes we'll leave everything else alone. Click OK.

    Now, we can give a unit this behavior and it will be able to level up with these parameters. Pretty neat stuff.

    Learning Skills

    We now need to give our eventual hero unit the ability to teach himself new abilities. To make our eventual autodidactical hero, we will create a new Ability of the Learn type.

    Set the Data Type to Abilities and add a new Object. In the panel, set the Name to Hero Learn and click Suggest. Change the Ability Type to Learn. Click OK.

    With this new ability selected, edit the (None) - Points Per Level and set it to 1. This field sets the number of points that are earned per level gained. The (None) - Points field is for setting the initial point value for the hero. We'll leave this at 0 so we have to earn a level before getting a skill point.

    Now we need to set the abilities that this "Learn" ability can learn! Edit the (None) - Info + field. A rather large and cumbersome menu should appear. This is where we can set certain abilities that can be learned by the hero. Select the Learn1 item. Scroll down and enable the Hide Count option.

    The Hide Count makes the little number invisible for the button (try toggling it and you'll see what I mean in the game). Scroll down further until you find the Default Button field. Select Research Stimpack from the combo box. This is the button that we'll associate with in the hero's command panel to decide where to place the learnable abilities (you'll see in a bit). We are just using a default button as the visual for the ability. If you would like to make your own check out the "Buttons" data type in the editor.

    Scroll down to the bottom. Change the Alert field to something you like. I chose UpgradeComplete_Terr. This sound will be played when the ability is finished training. You can set the Time field to something other than 0 if you would like training to not be instant.

    Finally, set the Ability field to Hero Stimpack. This field specifies the ability to be taught to the unit. We're done with this. Click OK. Notice, if you would like to add more abilities to learn, you would just select a different "Learn Index" at the top. We'll stick with 1 for now.

    Building Our Hero

    Ok, we've setup all of the things we need to finally create our awesome hero unit. Set the Data Type to Units and find the Marine unit. Right click the unit and select Duplicate Object. In the window that pops up Check the Actors heading to select all subelements. Click OK.

    Now, right click the Marine Copy and select Modify Object.... Change the Name to Hero Marine, click Suggest. Change the Object Type to Hero. Click OK.

    We now need to give our hero some abilities. Edit the (None) - Abilities + field. First, let's remove the old, normal Stimpack ability. Select the Marine - Stimpack ability from the list and click the little red X to delete it. Click the little green X to add a new ability slot. Set the Ability to Hero Learn. Click the little green X again and set the Ability to Hero Stimpack. Click OK.

    Now, this may seem odd to immediately grant the unit the Hero Stimpack ability. But, lucky for us, the engine will realize that this ability is trainable in the Hero Learn ability so it will not grant access to the ability until it is learned through the Hero Learn ability. This is very nice for us as we don't have to set up requirements and all of that business.

    Edit the (None) - Attributes field and check the Heroic box. Click OK. This simply identifies the unit as a hero.

    We now need to make the unit have the hero abilities to level up. Edit the (None) - Behaviors + field and add using the little green X the Hero Leveling behavior. This allows our hero to level up according the parameters we set in the Hero Leveling behavior. So, it can reach level 3 with 30 experience point increments like we defined.

    It's time now to change the command panel to show a button for our "Hero Learn" ability. Edit the (None) - Command Card + field. Click the bottom rightmost cell and click the little green X to add a button to this cell. Select whatever button you would like. I personally chose the Lift Off (Terran Buildings). Again, this would be a good time to make a custom Button object because, as you'll soon notice, the button's tooltip will be incorrect. I'm just trying to save time. Now set the Command Type to Submenu. Set the Command Card to 2 and set the Learn Ability to Hero Learn. What we've just done is link this button to the Hero Learn ability. It will associate the Command Card 2 with this ability so that we may add buttons there to associate with learning abilities. This is just like in WC3 where you could press the button when you got a level and it would take you to another command card where you select the ability to train.

    Now, since we have our new Hero Stimpack ability we need to give it a use button. Lucky for us, there is already a button there for the old stimpack. Select the old Stimpack amd change the Ability to Hero Stimpack (found at the very top of the list). Make sure the Ability Command is set to Use Stimpack. Now, when we press this button, we can use the hero's Stimpack ability. Again, it seems as though we're granting immediate access to the Stimpack ability, but the Hero Learn ability will make sure this button doesn't appear until we "learn" the ability with a skill point!

    At the top of the menu, change the Command Card to 2. Select the bottom rightmost cell and add a new button. Select a button to represent Cancel (such as the "Cancel" button). Change its Command Type to Cancel Submenu. Now, select the top leftmost cell and add a new button. Select something that represents Hero Stimpack. I chose the Research Stimpack button. NOTE: Although the button is named "Research Stimpack" it has NOTHING to do with researching a stimpack. It is simply a visual button with a name. It has NO functionality besides serving as a button. You can set this to WHATEVER you want. Change the Command Type to Ability Command and change the ability to Hero Learn. Set the Ability Command to Research Stimpack OR whatever button name you selected for your cloaking ability. It's confusing that it makes us choose the button name and not the ability name that's associated with that button, but we'll have to deal with it for now. Now, when the user presses that button, the unit will learn the associated ability!

    Click OK to save your changes.

    Making Him Stronger

    To level up, our hero will need to kill units. To make this easier, with the Hero Marine unit selected, left click the Marine - Gauss Rifle object in the panel on the bottom left under the Weapons heading to edit its fields. Edit the (None) - Period field and set it to 0.001. This makes the fire rate of the weapon extremely fast. This will make our hero very powerful for testing purposes.

    If you would like to change the damage, see the "Marine - Gauss Rifle (Damage)" effect. Notice how weapons do not define the damage!

    Give it a Go

    Add your Hero Marine unit to the map and place a lot of zerglings to kill. Test the map go kill some zerglings with your hero until you gain a level, spend your ability point on Stimpack and you'll be able to use it!

    There you have it, trainable, WC3-esque abilities.

    Posted in: Tutorials
  • 0

    posted a message on [Data] Marine Protoss Shield Upgrades

    Race Confusion

    The Protoss get to have all the fun with their fancy shields and whatnot. It's time we give the Marines some fancy energy shields too. Not only just give them shields, but have the Protoss Shield Upgrades affect the Marines too.

    A Shielded Marine is a Happy Marine

    First, open the Data Editor and selected the Units datatype. We're going to just alter the existing Marine for this tutorial. Shield stats are handled within the Marine unit. So, use the search bar and select the Marine unit. The "Shield Armor" is the armor value of the shield itself, and this is the value that is increased for every Protoss Shield Upgrade. It reduces incoming damage while the shield is active. Leave the "Stats - Shield Armor Level" alone, this is simply a numeric representation of the shield level, it will not effect the unit, but it will be increased for every Protoss Shield Upgrade.

    Change the Stats - Shield Maximum and Stats - Shield Starting Amount to 40. Set the Stats - Shield Regeneration Rate to 2. Shield Maximum is, obviously, the maximum shield level. The Shield Starting Amount is the amount of shield the unit has when it is created. We are setting it to the maximum because we want the unit to have full shields at spawn. The regeneration rate is the speed at which the shield will recharge.

    Edit the Combat - Shield Armor Name and set the Text Key to "Unit/ShieldArmorName/TerranInfantryShields" (without quotes) and change the text to "Terran Plasma Shield". This is the text that will show up when the player hovers over the shield icon in the unit's information panel. Although it's not necessary, we set a "Text Key" so that we can use this same string for other units if we choose to add shields to other Terran units. This way we don't have to manually enter the "Terran Plasma Shield" for every single unit, we can just refer to it via the key "Unit/ShieldArmorName/TerranInfantryShields". Also, this key is now available in the Text Module so, if you change the value from there, the changes will be reflected across all units that refer to this Text Key. Now that's a handy tool. Also, the text editor allows you to change the color and style of the string itself.

    This is enough to give our boys some shielding, complete with a nice little shield effect when hit. But we still have to make the Protoss Shield Upgrades affect the Marine. We'll do that now.

    An Olive Branch

    Instead of having the Terrans develop their own shielding system, the Protoss are going to be kind enough to extend their shielding upgrades to affect Marines. This will keep things simple for this tutorial. If you wish to create a whole Terran line of shielding, you should be able to figure it out after following this tutorial.

    Back in the Data Editor Set the Data Type to Upgrades. Find (using the search bar) Protoss Shields Level 1. With it selected, edit the (NONE) - Affected Unit Array field. In the popup, click the green X button and in the popup select Marine and click OK. Click OK again to close the field menu.

    Step 1

    It is important to note that this is not enough to make the upgrade affect the Marine. We must specify how the upgrade will affect the Marine unit. To do this, click the (None) - Effects + field to edit it. Admittedly this menu is not as intuitive as the other list menus, but the trick is to right click and choose Add Effect. This will add a blank effect to the list. With this blank effect selected, change the Type to Unit. Now, change the Object to Marine. The Field tree below will populate with all of the settings you can modify or the unity. This is another place for lots of customization potential. You can have upgrades that change the unit's speed, or even it's name. But for us, we're going to copy what the good folks at Blizzard did and select the Shield Armor field. With that field selected change the Operation to Add and change the Value to 1. This means the unit's armor is increased by 1 when this upgrade is trained.

    Step 2

    Right click again and select Add Effect. Again, change the Type to Unit and the Object to Marine. This time, though, select the Shield Armor Level from the Field tree. Change the Operation to Add and set the Value to 1. This increase the Shield Armor Level. Although this value does not affect the unit's actual shield armor, it is a nice numerical representation of the current upgrade level of the shield.

    We now have one more effect to add. Right click again and select Add Effect. This type, change the Type to Actor. Change the Object to Marine. Select the Shield Armor Icon field from the tree below and click the Browse... button. This will bring up the texture browser. In the Search box type in shieldslevel1. Select the only texture that appears and click OK. Note: you may select whatever texture you would like. This is the texture that appears in the selected unit's info panel for the shield level. So, as you can see, Upgrades are able to even change visual data, such as an icon.

    Step 3

    To save time, I won't detail out changing other two upgrade levels, but it's exactly the same. So, repeat the previous process for the Protoss Shields Level 2 and Protoss Shields Level 3 upgrades as well. Just look at the data that is already in there to see what you need to change for your marine. They all do the same thing (Add 1 to Shield Armor, Add 1 to Shield Armor Level) but they each reference a different shield texture for the actor.

    If all was done correctly, any shield upgrades purchased through the Forge should now upgrade the Marine as well! Let's test it, but before we do, let's make the research fast and free so we don't have to sit around all day waiting for it to finish.

    Testing It Out

    Upgrade research is actually considered an ability. Since the Forge is where the Protoss Shield Upgrades are purchased, Blizzard dutifully named the research ability "Forge - Research (Forge)". So, set the Data Type in the Data Editor to Abilities and find (using Search) Forge - Research (Forge) ability.

    With the research ability selected, edit the (None) Info + field. This brings up a list of buttons and their corresponding upgrades. Hidden inside is also the cost of each upgrade. To change this right click on the Protoss Shields Level 1 and select Modify Command... Scroll down in the new menu until you find the heading Resource. This list shows the cost for this particular upgrade. Select the Minerals item and change the Selected Value to 0. Do the same for the Vespene.

    Step 4

    Scroll further down in this menu until you find the Time field. Change this value to 1. This is the build time for this upgrade.

    Click OK to save your changes.

    Repeat this process for the other 2 upgrade levels

    You should now be able to place some marines on your map, add a Forge (with a pylon!) and a Twilight Council (needed for level 2 and 3 upgrades) and purchase your shield upgrades. Take note of the marine's Shield Armor level as you buy the upgrades.

    Removing Research Requirements (Optional)

    Annoyingly, the level 2 and 3 shield upgrades require a Twilight Council to be built. If you would like to remove this requirement, follow along.

    Looking back at the Forge - Research (Forge) ability and the (None) Info + field therein, we were able to change the cost of the research using the Modify Command... menu. In this menu there was a list called Requirement that sets, obviously, a requirement for researching this upgrade. These requirements are defined in the Data Editor as well. This menu showed us that Protoss Shield Level 2 upgrade required the Learn Protoss Shield2 requirement. So, let's investigate.

    Set the Data Editor's Data Type to Requirements. Search for Learn Protoss Shield2. With this element selected, you'll notice an enticing field called Requirement +. Indeed, edit that field. In the menu that pops up we're presented with a tree that shows the various requirement nodes for this requirement. You'll notice that it's divided into Use and Show. These are fairly clear on their meaning: "Use" requirements are those that are required to be fulfilled before the player can use the upgrade (that is, research it). The "Show" requirements are those that are necessary before the option to upgrade will appear in the Forge's ability panel. Obviously we are going to remove the "Count Unit TwilightCouncil Completed" node. So, right click the Count Unit TwilightCouncil Completed node and select Remove Requirement Node. Poof, no longer do we need a Twilight Council to upgrade to level 2. Repeat this for level 3.

    You should now be able to train all three levels at a Forge without a Twilight Council.

    Posted in: Tutorials
  • 0

    posted a message on [Data] Time of Day Dependent Buffs

    Hello. I have recently been playing around with the SC2 editor and figured out how to make buffs which are only active during certain times of the "day" and I decided I should write a tutorial on it.

    In this tutorial we'll create a new unit called the "Night Templar" which cloaks only during the night. We'll go over creating Validators, Behaviors and new Units.

    The Validators

    We'll begin by creating the necessary validators. Validators allow behaviors to check for certain conditions before affecting a unit. In this way we will disable or enable cloaking based on the "Time of Day" in the game.

    Fire up the SC2 editor and open the Data Editor. Change the Data Type to Validators and then Add a New Object. Name this object IsBeforeSunrise, click Suggest and change the Validator Type to Time of Day. Click OK.

    Step 1

    With this newly created validator selected, change the field (None) - Compare to "Less Then Or Equal To" (Note the spelling error, should be 'than' just for your information). Now set the field (None) Value to 06:00:00. You can set this value to any time you'd like to have as the sunrise. I'm going to make night be from 6 PM to 6AM in this tutorial.

    Step 2

    Now Add another new Validator. Set the name to IsAfterSunset, click Suggest and change the Validator Type to Time of Day and click OK.

    With this validator selected, change the field (None) - Compare to "Greater Than or Equal To" and change the field (None) - Value to 18:00:00. Again, you may set this to whatever time you'd like to have the sunset.

    So what we've done is created two new validators that will help us determine whether or not it is day or night. The Compare field describes the type of test we will be performing. What these validators will do is take the current game's Time of Day and compare it with the value we specified. So, if it is 01:00:00 then it will be IsBeforeSunrise but it will not be IsAfterSunset. Now, we know it is night if either one of these validators are true. So, we'll make another validator to "Combine" these two together.

    Add another new Validator. Set the name to IsNight, click Suggest and set the Validator Type to Combine. Click OK.

    Step 3

    With this new validator selected, Click on the (None) - Combines field. A menu should pop up, Click the Green plus button to add a validator to the list. Select IsAfterSunset and click OK. Now, Click the Green Plus Button again and Select IsBeforeSunrise and Click OK. You should now have both Time of Day validators in your list. Click OK to close the menu.

    Step 4

    Your IsNight validator is now complete. Notice that, by default, the editor sets the field (None) - Type to "Or". This is a logical OR operator meaning if any of the validators in the (None) - Combines field are true, then this validator is also true. So, if it is after sunset OR before sunrise then we know it is night. If you want a validator for daytime, use the (None) Negate field and enable it to "flip" the value of the combination. If we were to enable the Negate field then this validator would be true if it is NOT after Sunset or before Sunrise, giving us Daytime.

    The Buff

    Ok, so we now have a way to test if it is nighttime, but how do we use this for our soon-to-be buff? First, it's time we create our buff.

    In the Data Editor, set the Data Type to Behaviors. Behaviors are elements which can modify units on the fly. Buffs fall under the heading of Behaviors. Add a new Object and set the name to Night Cloak, click Suggest. Change the Behavior Type to Buff, click OK

    Step 5

    With "Night Cloak" selected, we'll need to set some of its fields. First, change the Alignment to Positive meaning this behavior benefits the unit. If you wish, you may change the Icon field to some icon that you'd like to represent this buff. This Icon is the small one that will show on the unit's information panel at the bottom of the screen Now, the important field we need to look at for this, and basically all buffs is the "Modification +" field. This field allows us to actually set the way this buff will affect a unit. Double Click Modification + to bring up a new menu. At the top of the new menu, under the "Modify Flags" heading Click the little red X to delete ALL entries in this list. We do this to ensure this buff will not override the effects of another buff by messing with these flags. Then, under the State Flags list remove all BUT the CLOAK entry by clicking the little red X. Again, we don't want to affect any state besides the cloak state of the unit. Highlight the Cloak entry in the list and Check the box marked "Enabled" just below. Click OK.

    Step 6

    As you can see, the Modification + panel is where all of the dirty work for Buffs is handled. If you explored more, you noticed plenty of other options of things to affect such as move speed, damage, health etc. Many possibilities for Buffs. But for now, our simple buff will make the unit Cloaked.

    So, at the moment, our Night Cloak buff will ALWAYS cloak an object no matter what the time is. To fix this, we'll utilize our IsNight validator. If you look near the bottom of the Night Cloak fields you'll see a field called "Validators (Disable)". Click the Validators (Disable) field to open up a list. Click the little green X and add the IsNight Validator. Click OK.

    This makes our buff disable anytime the IsNight validator fails. So, if it's daytime, the buff will be disabled. Notice there is also a Validator (Remove) field. This does just as you'd expect and removes the buff from the unit if the validator fails.

    Finally, to make our buff more user friendly Change the Tooltip Field and set enter a message that will appear as the tooltip when the player hovers his mouse over the buff icon. I wrote "Cloaks the unit at night". The final fields of the Buff should be like the following:

    Step 7

    The Unit

    So we have our Buff ready to go and it uses our new IsNight validator. It's time now to create a unit that has Night Cloak as a buff.

    In the Data Editor, Change the Data Type to Units. Find the Dark Templar Unit. Right click it and Duplicate the Dark Templar. In the tree that pops up, all we need to copy are the Actors. So, Check the Actors Folder to select everything inside of it. Click OK. Note we are not copying everything else because we are not modifying anything besides some unit flags. We have to copy the actor because we need an Actor object to reference this unit so that it will be attached to a visual representation of the Dark Templar. Actor can only be associated with a single Unit.

    Step 8

    First things first, we certainly don't want this unit to be called "Dark Templar Copy". So Right Click the Dark Templar Copy on the left panel and click "Modify Object...". Change the name to "Night Templar" then click Suggest and Click OK.

    Step 9

    With Night Templar selected, we need to set some important fields. First, since the Night Templar has the same settings as the Dark Templar at the moment, it will be cloaked all the time automatically. To disable this we need to disable the Cloaked flag. Double click the Stats - Flags field and uncheck the Cloaked box. Now the unit will not be cloaked all the time.

    It's now time to add our Night Cloak buff to the Night Templar. Click the (None) Behaviors + field. A window should pop up, Click the green X and add the Night Cloak behavior After it is added Click OK.

    Step 10

    Now our unit has the Night Cloak buff! The buff will handle enabling or disabling the Night Templar's cloaking based on the Time of Day.

    Speeding Up the Time of Day

    With our Night Templar created, we probably would like to see our new Night Cloak buff in action. To do this, we need to setup a trigger to speed up the time of day progression a bit so that we can see the Cloaking enable and disable based on the time.

    Open the Trigger Editor and select the Map Initialization trigger. Delete all of the actions for the trigger. Now, with the Map Initialization trigger still selected Click the Add Action button and a new menu should pop up. With the "Environment" heading selected on the left select "Set Day Length" and click OK. We've now added an action that will set the length of the game day.

    With the Set Day Length action selected, click the linked 300.0 and change it to 30.0. This will make a "day" 30 seconds long.

    Use the editor to place a Night Templar on the map for Player 1, and test out the map. You should see the unit cloak and decloak as time goes on!

    Adding a Clock (Optional)

    Having this functionality of time based buffs is pretty neat, but it invites the question, how do we tell the player what time it is in the game? Luckily this isn't too difficult to setup using some trigger play. This part of the tutorial assumes you have used triggers before and are comfortable moving around the editor.

    Building the Dialog

    Our clock will use SC2's Dialog system to show a little UI clock at the top of the screen. Add a new global variable of type Dialog Item name ClockDisplay. Leave the default value as it is.

    One issue we need to address is conversion of the Time of Day variable type to a string for displaying purposes. Create a new Function called "TimeOfDayToString and set it as follows:

    Convert Time Of Day To String
        Options: Function
        Return Type: String
        Parameters
            Time Of Day = 00:00:00 <Time Of Day>
        Grammar Text: convert Time Of Day to string
        Hint Text: Converts a time of day value to a string.
        Custom Script Code
        Local Variables
        Actions
            General - Return lp_timeOfDay
    

    Thanks to Nevir for this function

    Now, select the Map Initialization trigger and add a Create Dialog action. Change it to "relative to Top of screen" and leave the other settings. Add a Show/Hide Dialog action. Change the action to Show instead of Hide. Add a Create Dialog Item (Label) action. Change the Text parameter to take a conversion from String to Text, and then change the string to be TimeOfDayToString function we added, and then pass in the function Get Current Time of Day function to that. The resulting action should be as follows:

    Dialog - Create a Label for Dialog (Last created dialog) with the dimensions (200, 50) anchored to Center with an offset of (50, 50) with the text (Text((TimeOfDayToString((Current game time of day))))) color set to White text writeout set to false with a writeout duration of 2.0
    

    Add a Set Variable action and change the variable to ClockDisplay and the value to Last Created Dialog Item. We now have a reference to this label.

    Add a Show/Hide Dialog Item action and set it to Show.

    Add a new Trigger and add an event Timer -> Periodic Event and set the period to 1.0 second. In the actions for this trigger add a Set Dialog Item Text action. Change the first parameter to ClockDisplay and change the Text parameter to the string-to-text, TimeOfDayToString, Current Time of Day setup that we used in the Label creation action. Now the label will be updated every second with the new time.

    You should now have an ingame clock that the player can use to figure out when buffs will be activated.

    Posted in: Tutorials
  • 0

    posted a message on Displaying Time of Day?

    Thank you, it works brilliantly. I didn't realize I could enter custom functions, you've opened up worlds for me!

    For those who need clarification on how to use the above description:

    In the Trigger editor, right click the tree panel on the left and choose New->New Function and then, using what Nevir wrote above, fill in the appropriate fields as described.

    One thing you may want to change is the "Grammar Text" entry. Just leave the "User Default Grammar Text" enabled and it will allow you to use the nice hyper-link method of inserting parameters in your triggers.

    Posted in: Miscellaneous Development
  • 0

    posted a message on Displaying Time of Day?

    Hello all,

    So, I've been searching around both the SC2 editor and the Internet for a while now and I've yet to find a solution for my problem. I have some abilities that depend on the in-game "Time of Day" for their functionality. For example, my hero will only cloak when it is nighttime in the game. This works really well, and now I need to be able to inform the player of the current time of day. There is a Time of Day variable type and I'm able to set it to the game's current time of day, but I cannot for the life of me figure out how to convert it to a string to be displayable on a dialog. I've attempted to simulate the time of day using timers, but they're not accurate enough. The cloaking disables before the "hour" is up and it gets more and more inaccurate as time goes on. I feel like there should be an easy way to convert the time of day into HH:MM:SS notation to be set as a label for a dialog, but I've found no such way to go about this.

    Thanks in advance for the help

    Posted in: Miscellaneous Development
  • To post a comment, please or register a new account.