• 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.

[Trigger] A minor system, help is needed!

Status
Not open for further replies.
Level 37
Joined
Aug 14, 2006
Messages
7,602
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.
 
Level 12
Joined
Mar 16, 2006
Messages
992
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.
 
Level 15
Joined
Feb 9, 2006
Messages
1,598
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.
 
Level 12
Joined
Feb 13, 2009
Messages
388
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.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
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
 
Level 9
Joined
May 30, 2008
Messages
430
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:
 
Level 5
Joined
Jan 25, 2006
Messages
103
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.
Top