• 🏆 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!

[Trigger] Create a specific hero at start-up

Status
Not open for further replies.
Level 10
Joined
Nov 5, 2008
Messages
536
I have these triggers.
I have also created 2 regions.

For some reason, player A always spawns at Location 1 and player B always spawns at location 2. (It is supposed to be random spawn)

What am I doing wrong with these triggers?


  • Select Race
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Dialog - Clear DialogSelectRace
      • Dialog - Change the title of DialogSelectRace to Select your race:
      • Dialog - Create a dialog button for DialogSelectRace labelled Goblins
      • Set DialogButton[1] = (Last created dialog Button)
      • Dialog - Create a dialog button for DialogSelectRace labelled Elves
      • Set DialogButton[2] = (Last created dialog Button)
      • Dialog - Show DialogSelectRace for Player 1 (Red)
      • Dialog - Show DialogSelectRace for Player 2 (Blue)


  • Selected Goblin
    • Events
      • Dialog - A dialog button is clicked for DialogSelectRace
    • Conditions
      • (Clicked dialog button) Equal to DialogButton[1]
    • Actions
      • Set DialogInteger = (Random integer number between 1 and 2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DialogInteger Equal to 2
        • Then - Actions
          • Set StartPoint2 = (Center of StartRegion2 <gen>)
          • Unit - Create 1 Goblin Fortress for (Triggering player) at StartPoint2 facing Default building facing degrees
          • Unit - Create 5 Worker for (Triggering player) at StartPoint2 facing Default building facing degrees
          • Unit - Create 1 Unit for (Triggering player) at StartPoint2 facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DialogInteger Equal to 1
        • Then - Actions
          • Set StartPoint1 = (Center of StartRegion1 <gen>)
          • Unit - Create 1 Goblin Fortress for (Triggering player) at StartPoint1 facing Default building facing degrees
          • Unit - Create 5 Worker for (Triggering player) at StartPoint1 facing Default building facing degrees
          • Unit - Create 1 Unit for (Triggering player) at StartPoint1 facing Default building facing degrees
        • Else - Actions
  • Selected Elves
    • Events
      • Dialog - A dialog button is clicked for DialogSelectRace
    • Conditions
      • (Clicked dialog button) Equal to DialogButton[2]
    • Actions
      • Set DialogInteger = (Random integer number between 1 and 2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DialogInteger Equal to 2
        • Then - Actions
          • Set StartPoint2 = (Center of StartRegion2 <gen>)
          • Unit - Create 1 Elven Roost for (Triggering player) at StartPoint2 facing Default building facing degrees
          • Unit - Create 5 Sprite for (Triggering player) at StartPoint2 facing Default building facing degrees
          • Unit - Create 1 Unit for (Triggering player) at StartPoint2 facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DialogInteger Equal to 1
        • Then - Actions
          • Set StartPoint1 = (Center of StartRegion1 <gen>)
          • Unit - Create 1 Elven Roost for (Triggering player) at StartPoint1 facing Default building facing degrees
          • Unit - Create 5 Sprite for (Triggering player) at StartPoint1 facing Default building facing degrees
          • Unit - Create 1 Unit for (Triggering player) at StartPoint1 facing Default building facing degrees
        • Else - Actions
I would rather have 2 start-locations instead of 2 regions, and once the race is selected ingame, the appropriate units for the race spawns at a start-location. Can this be made?
 
Last edited:
Level 16
Joined
Jul 21, 2008
Messages
1,121
You can also make it like this:
  • Set TempPlayerGroup = (All players)
  • Set TempPlayer = (Random player from TempPlayerGroup)
  • Set TempPoint = (TempPlayer start location)
  • -------- Starting Unit Creation Functions --------
  • Player Group - Remove TempPlayer from TempPlayerGroup
  • Custom script: call RemoveLocation(udg_TempPoint)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I believe it has nothing to do with the trigger

Inside the World Editor, go to File --> Preferences --> Test Map and uncheck the box that says "Use Fixed Random Seed"
That option (when enabled) will always return the same 'random' integer when you use "Test Map", that's why you always start at the same location.

If this works, changing the trigger is a bit pointless, since you already made it.
 
Level 10
Joined
Nov 5, 2008
Messages
536
There is one problem that I create all starting units and buildings in this way.
I have an ability based on the Staff of Preservation, which allows the hero to teleport an unit to it's town hall. When I create the starting units like this, the spell does not detect any town hall.

Thats why I need to have the races spawn like "normal start-up" at their start location, and not at regions.
But that means that players must select their race in the pre-game lobby and they can not select it ingame via my triggers..

How shall I do? : /
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set loc[1] = (Player 1 (Red) start location)
      • Unit - Create 1 Town Hall for Player 1 (Red) at loc[1] facing Default building facing degrees
      • For each (Integer i) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set loc[2] = (loc[1] offset by 150.00 towards (22.50 x (Real((i))) degrees)
          • Unit - Create 1 Peasant for Player 1 (Red) at loc[2] facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_loc[2])
      • Custom script: call RemoveLocation(udg_loc[1])
This should work perfectly... I've tested it myself ;)
 
Last edited:
Level 10
Joined
Nov 5, 2008
Messages
536
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set loc[1] = (Player 1 (Red) start location)
      • Unit - Create 1 Town Hall for Player 1 (Red) at loc[1] facing Default building facing degrees
      • For each (Integer i) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set loc[2] = (loc[1] offset by 150.00 towards (22.50 x (Real((Integer A)))) degrees)
          • Unit - Create 1 Peasant for Player 1 (Red) at loc[2] facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_loc[2])
      • Custom script: call RemoveLocation(udg_loc[1])
This should work perfectly... I've tested it myself ;)

This sounds very interesting! How do I do so this trigger work for all players?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
This sounds very interesting! How do I do so this trigger work for all players?

It's not really hard, just create anoter loop for the actions from 1 to [#players]

Something like this:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer I) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set loc[1] = (Player(I)) start location)
          • Unit - Create 1 Town Hall for Player(I) at loc[1] facing Default building facing degrees
          • For each (Integer i) from 1 to 5, do (Actions)
            • Loop - Actions
              • Set loc[2] = (loc[1] offset by 150.00 towards (22.50 x (Real(i)) degrees)
              • Unit - Create 1 Peasant for Player(I) at loc[2] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_loc[2])
          • Custom script: call RemoveLocation(udg_loc[1])
Change the "10" with the amount of players your map has.
"Player(I)" can be found under: "Conversion - Convert Player Index To Player"
 
Last edited:
Level 10
Joined
Nov 5, 2008
Messages
536
I have these triggers.
I have also created 2 regions.

For some reason, the players always spawns at the same location.
I have tried many times in multiplayer and player A and B always spawns at the same location, Location1 or Location2.

What can I do to prevent that?


  • Select Race
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Dialog - Clear DialogSelectRace
      • Dialog - Change the title of DialogSelectRace to Select your race:
      • Dialog - Create a dialog button for DialogSelectRace labelled Goblins
      • Set DialogButton[1] = (Last created dialog Button)
      • Dialog - Create a dialog button for DialogSelectRace labelled Elves
      • Set DialogButton[2] = (Last created dialog Button)
      • Dialog - Show DialogSelectRace for Player 1 (Red)
      • Dialog - Show DialogSelectRace for Player 2 (Blue)


  • Selected Goblin
    • Events
      • Dialog - A dialog button is clicked for DialogSelectRace
    • Conditions
      • (Clicked dialog button) Equal to DialogButton[1]
    • Actions
      • Set DialogInteger = (Random integer number between 1 and 2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DialogInteger Equal to 2
        • Then - Actions
          • Set StartPoint2 = (Center of StartRegion2 <gen>)
          • Unit - Create 1 Goblin Fortress for (Triggering player) at StartPoint2 facing Default building facing degrees
          • Unit - Create 5 Worker for (Triggering player) at StartPoint2 facing Default building facing degrees
          • Unit - Create 1 Unit for (Triggering player) at StartPoint2 facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DialogInteger Equal to 1
        • Then - Actions
          • Set StartPoint1 = (Center of StartRegion1 <gen>)
          • Unit - Create 1 Goblin Fortress for (Triggering player) at StartPoint1 facing Default building facing degrees
          • Unit - Create 5 Worker for (Triggering player) at StartPoint1 facing Default building facing degrees
          • Unit - Create 1 Unit for (Triggering player) at StartPoint1 facing Default building facing degrees
        • Else - Actions
  • Selected Elves
    • Events
      • Dialog - A dialog button is clicked for DialogSelectRace
    • Conditions
      • (Clicked dialog button) Equal to DialogButton[2]
    • Actions
      • Set DialogInteger = (Random integer number between 1 and 2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DialogInteger Equal to 2
        • Then - Actions
          • Set StartPoint2 = (Center of StartRegion2 <gen>)
          • Unit - Create 1 Elven Roost for (Triggering player) at StartPoint2 facing Default building facing degrees
          • Unit - Create 5 Sprite for (Triggering player) at StartPoint2 facing Default building facing degrees
          • Unit - Create 1 Unit for (Triggering player) at StartPoint2 facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DialogInteger Equal to 1
        • Then - Actions
          • Set StartPoint1 = (Center of StartRegion1 <gen>)
          • Unit - Create 1 Elven Roost for (Triggering player) at StartPoint1 facing Default building facing degrees
          • Unit - Create 5 Sprite for (Triggering player) at StartPoint1 facing Default building facing degrees
          • Unit - Create 1 Unit for (Triggering player) at StartPoint1 facing Default building facing degrees
        • Else - Actions
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Inside the World Editor, go to File --> Preferences --> Test Map and uncheck the box that says "Use Fixed Random Seed"
That option (when enabled) will always return the same 'random' integer when you use "Test Map", that's why you always start at the same location.

(I've already said this before >.>)
 
Level 10
Joined
Nov 5, 2008
Messages
536
Inside the World Editor, go to File --> Preferences --> Test Map and uncheck the box that says "Use Fixed Random Seed"
That option (when enabled) will always return the same 'random' integer when you use "Test Map", that's why you always start at the same location.

(I've already said this before >.>)


But when I play multiplayer with people, they always starts at the same location. I wonder how to get rid of the fact that both can be unlucky and get the same spawning location?
 
Status
Not open for further replies.
Top