• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Create a random unit of :.....?

Status
Not open for further replies.
Level 26
Joined
Mar 19, 2008
Messages
3,140
I dont get what is your 2nd question about, explain it futher if you can.
One of options to solve 1st one:
you can set level for units:footman, rifleman and knight to specific number, lets set to 15.
Make sure no other units in game have the same level (here 15)
and use action that creates random unit with level 15.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Actions
    • Set i1 = (Random integer number between 1 and 3)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • i1 Equal to 1
      • Then - Actions
        • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • i1 Equal to 2
          • Then - Actions
            • Unit - Create 1 Knight for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
          • Else - Actions
            • Unit - Create 1 Rifleman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
For the second issue, add the units into a unit group and the pic random units from the group.

Remember to clear leaks: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
To improve Maker's IFs efficiency, do it like this:

  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TypesOfUnit[1] = Footman
      • Set TypesOfUnit[2] = Knight
      • Set TypesOfUnit[3] = Rifleman
  • Create
    • Events
      • Your Event
    • Conditions
      • Your Condition(s)
    • Actions
      • Set RandomInteger = (Random integer number between 1 and 3)
      • Unit - Create 1 TypesOfUnit[RandomInteger] for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
In the setup trigger, you can set as many units as you want without having to do many IFs in the 2nd trigger
 
Ok thanks.Now what if at the end of the trigger i want to reset the variables?Is that possible(lol i know it is but how?)

  • Actions
    • Set i1 = (Random integer number between 1 and 3)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • i1 Equal to 1
      • Then - Actions
        • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • i1 Equal to 2
          • Then - Actions
            • Unit - Create 1 Knight for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
          • Else - Actions
            • Unit - Create 1 Rifleman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
For the second issue, add the units into a unit group and the pic random units from the group.

Remember to clear leaks: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/

Ok thanks a lot ^^!!Now what if at the end of the trigger i want to reset that variable(clear it) ???How can i do that>??
 
Status
Not open for further replies.
Top