• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] A minor system, help is needed!

Status
Not open for further replies.
Level 37
Joined
Aug 14, 2006
Messages
7,610
Hey there.

I'm creating Gladiator Arena for chapter 7 in The Chosen Ones - Campaign. However, when something new comes, I'm always confused. I'm asking for your little help. Perhaps you could make a little test map or just paste the triggers here.

When the player enters the Gladiator Arena, a trigger will choose a random enemy character to the fight against the player. This happens many times in the game, but I don't want player to fight against same enemy characters. This is the problem.

I need a little system that randomly selects from 1 to X(depends how many characters I will add to the Gladiator Arena) a number to integer variable. Each time a number is chosen, there must be some kind of checker that checks that if the number is already used, it won't be taken. I don't know how to do this, so help is needed. Rep is of course given.
 
You basically just need a unit array and a simple trigger to do this.

You need something that replaces the unit chosen with the unit TOP. So if you get Unit[23] chosen, and the max Unit[] is Unit[40], then after spawning Unit[23], you swap their positions and remove 1 from the MAX_RANDOM. So then there are 39 units and they are all in place.

I use something like this for my randomized hero selection script.
 
Simple:

You need two triggers. One setup trigger and one action trigger.

  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set UNITS[1] = Warrior1
      • Set UNITS[2] = 2
      • Set UNITS[3] = 3
      • Set UNITS[4] = etc..
      • Set UNITS[5] =
      • Set UNITS[6] =
      • Set UNITS[7] =
      • Set UNITS[8] =
      • Set UNITS[9] =
      • Set UNITS[10] =
UNITS is an variable of type "Unit" or "Unit Type"

  • Trigger
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set RANDOM = (Random integer number between 1 and 10)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UNITS[RANDOM] Equal to No unit
        • Then - Actions
          • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
          • Set UNITS[RANDOM] = No unit
          • Unit - Move (YOURUNIT) instantly to (Center of (Playable map area))
RANDOM is an integer.

Or what Vegavak said. He's method is a more simple aproach.
 
Also if it's suitable for you you can spawn all types of enemies somewhere in unseen region (if you don't have too many) and randomly pick-teleport them one at a time to a playable area once you need them.
 
As Vega stated, the stack suggestion is the way to go.

Uses an integer NumHeroes, an integer TempInt, and a Unit array (or Unit-Type array depending on whether you have to create them or not) Heroes.

  • Blah
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Heroes[0] = Astral Wizard
      • Set Heroes[1] = Blademaster
      • Set Heroes[2] = Fallen Angel
      • ...
      • Set Heroes[N] = Joe the Plumber
      • Set NumHeroes = N
  • Bleh
    • Events
      • ?
    • Conditions
      • ?
    • Actions
      • Set TempInt = (Random Number between 0 and NumHeroes)
      • -------- Do stuff with Heroes[TempInt] --------
      • Set Heroes[TempInt] = Heroes[NumHeroes]
      • Set NumHeroes = NumHeroes - 1
 
Aha... Well I guess the system is too hard for me because I don't understand you guys.

Hmm... Well... Perhaps someone could make a test map with this system? That's the best way to test it also...

add units in the arena in unit group when your unit enter in the arena move random unit from the unit group to fight with it if the unit is killed remove the unit from unit group if not don't
It's so easy but maybe u don't know where 2 read about WC tutorials. If u can't find them they are at very bottom at forum menu try to scroll with your mouse it may take you few minutes but i am sure you can make it :thumbs_up:
 
Put all enemy units is a group. You can do this with a variable or directly by triggers, depending if those units are featured on the map before the hero enters the arena or not.
If units are not on map use variable, then when hero enters region "arena" use create 1 random level "variable-group" creep unit-type at position of etc...

This should work.
If not you would need a 2 step triggers.
1 for randomly selecting enemy units and another one for creating them.
 
Status
Not open for further replies.
Back
Top