• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How to add/give Random Abilities to a unit

Level 9
Joined
Oct 15, 2006
Messages
339
First action is to open WE and go to Module>Trigger Editor and click on the Golden "X" button in the toolbar menus to get to the game Variables.

You will need to create 2 variables. For the first one name it something like Unit_ability and this variable will be of the "Variable Type" - "Ability". To make this short, simple and sweet we'll give it an Array so check the box "Array". For now you can leave it "1", or 10, or whatever, but however many abilities you want given as random should be the number you enter into the "Array" field.

Now create another variable with a Variable Name something like "Random_ability", which refers to all of the abilities that will be random when we use it in a trigger. Give this the "Variable Type" of "Integer" because the Array we used before is like counting the number of abilities as opposed to identifying the ability itself.

The Integer, or number, varies, which is why it is a variable.

Now it's time to set the Ability Array with an array of abilities! It is best to set this up at the beginning of the game so as to keep your game going smoothly. If you keep setting the ability array with the same abilities periodically throughout the game for whatever reason, it may make your game suck (the short answer). (Long answer not needed).

Can it be beneficial at all to keep setting the ability array with abilities after Map Initialization? No. So don't do it. Make sure the following actions occur during a single event during the game. That means it could be at map initialization, or 5 seconds into the map, or even when a player options for random abilities 5 minutes into the game. However, it is just simple to work with knowing they are set and done with at the beginning of the game. Moving on.

It's time to set the abilities to the variable Ability "Array" by assigning each ability to the "Unit_ability" variable and assigning it a number, which thus comprises an "array". To do this open up "Trigger Editor", create a new Category and/or a new Trigger (Ctrl+T), or simply add the following in your "Initialization" folder or Map Initialization Trigger.

Right-Click on Actions and click "New Action". Scroll down 7 steps and click on "Set Variable". Click on "Variable" and find "Unit_ability". Click on it. Set the array number to "1". Then click on "Value" and set it to the Ability you want. Create as many of these triggers as you want random abilities.

NOTE, if you put the following in your "Map Initialization" trigger you do not need to add the Event shown.

  • Untitled Trigger 001
  • Events
    • Time - Elapsed game time is 0.00 seconds
  • Conditions
  • Actions
    • Set Unit_ability[1] = AOE damage upon death (Big Mine)
    • Set Unit_ability[2] = Abolish Magic (Neutral Hostile, second position)
    • Set Unit_ability[3] = Animate Dead (Neutral Hostile)
    • Set Unit_ability[4] = AOE damage upon death (Big Mine)
So we just set 4 abilities to the ability array variable. Now we want to make the abilities random by setting them to the second variable we created, "Random_ability".

Add this next function to the end of your trigger actions.

  • Set Random_ability = (Random integer number between 1 and 4)
I only used 1-4 for this example because we are only using 4 abilities. If you have 10 random abilities, or 30, add 10 and 30, respectively. So now it should look like this;

  • Untitled Trigger 001
  • Events
    • Time - Elapsed game time is 0.00 seconds
  • Conditions
  • Actions
    • Set Unit_ability[1] = AOE damage upon death (Big Mine)
    • Set Unit_ability[2] = Abolish Magic (Neutral Hostile, second position)
    • Set Unit_ability[3] = Animate Dead (Neutral Hostile)
    • Set Unit_ability[4] = AOE damage upon death (Big Mine)
    • Set Random_ability = (Random integer number between 1 and 4)
And finally we want an event that gives the Unit, or Hero, a random ability. Create a new Action in a new trigger and click on "Unit - Add Ability". Then click on "Variable" and find and select "Unit_ability". Because we gave it an array it thus has an "Index" for the array which we now must specify. Do we give it a value of 1? No, because there are 4 abilities. So we give it a value of 4.. Right?! NO! All we did was add a bunch of candy to a candy jar, now we need to say that we will pick a random candy each time, not the same candy every time. So click on "Index" and under "Variable" find and select "Random_ability". We are done with that action. Add an event and you are done with that trigger and it should look something like this.

  • Untitled Trigger 002
  • Events
    • Unit - A unit enters Rect 000 <gen>
  • Conditions
  • Actions
    • Unit - Add Unit_ability[Random_ability] to Unit
We set 1 Unit_ability to an array 4 times (= 4 abilities).
We set Random_ability to a random number between 1 and 4.
We set giving Unit_ability to giving it a Random_ability instead of picking a "value" of "4".

Unit_ability asks for the array, "Which number (1-4) do you want to give this ability to this unit? And we say, "Give it a "Random_ability" (random number 1-4)".

And finally, if your unit or hero needs more than one ability simply copy and paste the action trigger as many times as you need it, like so.


  • Untitled Trigger 002
  • Events
    • Unit - A unit enters Rect 000 <gen>
  • Conditions
  • Actions
    • Unit - Add Unit_ability[Random_ability] to Unit
    • Unit - Add Unit_ability[Random_ability] to Unit
    • Unit - Add Unit_ability[Random_ability] to Unit
Credit: http://www.thehelper.net/forums/showthread.php?t=124938&highlight=random+abilities


EDIT: To Mods, If you have an issue with my tutorial edit it yourself. I am not here for reputation or to make things "perfect" to your standards, i'm doing this to help others progress their maps and the quality of WC3 maps in general.
 
Level 9
Joined
Nov 4, 2007
Messages
931
Just bringing up more 3 month old tut. submissions that have been neither graveyarded nor approved, and this guy should have probably looked at the guidelines for submitting tutorials.
 
Top