Triggering Question

Status
Not open for further replies.
Level 12
Joined
Jun 10, 2008
Messages
1,043
Hello, Hive. I have yet another question about triggering...

I was wondering how to make a trigger where it randomly chooses a player and makes him a Predator (Like in Metastasis and Parasite) using GUI and Custom Scripts. Also, would the same trigger work if the game mode sets 2 or 3 Predators instead of one with minor edits? Or would I have to completely recreate it?
 
Level 7
Joined
Jun 8, 2010
Messages
283
You could achieve this by using the following GUI trigger when Red presses a Dialog:
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Clicked dialog button) Equal to Dialog_OnePredator
      • Then - Actions
        • Set playervariable = (Player((Random integer number between 1 and 12)))
        • Unit - Create 1 Footman for playervariable at (Center of (Playable map area)) facing Default building facing degrees
      • Else - Actions
If you want multiple Predators you will have to store an integer to remove those players already selected predators from the potential predator's list. If you want to do minor edits to each predator such as Abilities, then you will have to make multiple units by copying your current predator.
 
Level 12
Joined
Jun 10, 2008
Messages
1,043
Thanks for the help. Also, would you happen to know how to make it generate a random name for you from a bunch of preset names I create?
 
Level 7
Joined
Jun 8, 2010
Messages
283
Well if the unit is a Hero you could list all the possible names. Upon creating the unit, the game will randomly select one of those names you enlist.

Its should be somewhere called "Proper Name" when editing a hero in the Object Editor.
 
Level 7
Joined
Jun 8, 2010
Messages
283
Youll need two triggers one to set the strings of the name, and another to randomly assign a string to a player.
  • Set name
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set stringname[1] = Captain Crunch
      • Set stringname[2] = Mr. Frosted Fakes
      • Set stringname[3] = Silly Rabbit
      • Set stringname[4] = Honeynut Cheerios
      • Set stringname[5] = Im a Tiger Mighty Mighty Tiger
  • assign random names
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Set name of (Player((Integer A))) to stringname[(Random integer number between 1 and 5)]
 
Level 12
Joined
Jun 10, 2008
Messages
1,043
Thanks again. Also, will this work for the Predator randoming?

  • One Predator
    • Events
      • Player - Player 1 (Red) types a chat message containing -P1 as An exact match
    • Conditions
    • Actions
      • Set PredatorPlayerGroup = (All players controlled by a User player)
      • Dialog - Change the title of DialogPredator to Choose Your Predato...
      • Dialog - Create a dialog button for DialogPredator labelled |cffff0000Hunter|r
      • Set Hunter = (Last created dialog Button)
      • Dialog - Create a dialog button for DialogPredator labelled |cff00ffffPredator|r
      • Set Predator = (Last created dialog Button)
      • Dialog - Show DialogPredator for (Random player from PredatorPlayerGroup)

  • Hunter
    • Events
      • Dialog - A dialog button is clicked for DialogPredator
    • Conditions
      • (Clicked dialog button) Equal to Hunter
    • Actions
      • Unit - Create 1 Hunter for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees



  • Predator
    • Events
      • Dialog - A dialog button is clicked for DialogPredator
    • Conditions
      • (Clicked dialog button) Equal to Predator
    • Actions
      • Unit - Create 1 Predator for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
 
Level 7
Joined
Jun 8, 2010
Messages
283
Thanks again. Also, will this work for the Predator randoming?

Yes it will work, just do this.
  • Set name for Predator and Hunter
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Hunter_name[1] = Alpha Hunter
      • Set Hunter_name[2] = Support Hunter
      • Set Hunter_name[3] = Defense Hunter
      • Set Predator_name[1] = Alpha Predator
      • Set Predator_name[2] = Support Predator
      • Set Predator_name[2] = Defense Predator


  • One Predator
    • Events
      • Player - Player 1 (Red) types a chat message containing -P1 as An exact match
    • Conditions
    • Actions
      • Set PredatorPlayerGroup = (All players controlled by a User player)
      • Dialog - Change the title of DialogPredator to Choose Your Predato...
      • Dialog - Create a dialog button for DialogPredator labelled |cffff0000Hunter|r
      • Set Hunter = (Last created dialog Button)
      • Dialog - Create a dialog button for DialogPredator labelled |cff00ffffPredator|r
      • Set Predator = (Last created dialog Button)
      • Dialog - Show DialogPredator for (Random player from PredatorPlayerGroup)

  • Hunter
    • Events
      • Dialog - A dialog button is clicked for DialogPredator
    • Conditions
      • (Clicked dialog button) Equal to Hunter
    • Actions
      • Unit - Create 1 Hunter for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
      • Player - Set name of (Triggering player) to Hunter_name[(Random integer number between 1 and 3)]



  • Predator
    • Events
      • Dialog - A dialog button is clicked for DialogPredator
    • Conditions
      • (Clicked dialog button) Equal to Predator
    • Actions
      • Unit - Create 1 Predator for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
      • Player - Set name of (Triggering player) to Predator_name[(Random integer number between 1 and 3)]
 
Level 12
Joined
Jun 10, 2008
Messages
1,043
One more question, lol. How would you make this work for 2 or 3 predatorsa. I'm guessing I would have to remove the "Random Player" from the Player Group then run the actions again, but i can't figure out how to remove him...

EDIT: *sigh* also another problem came up. When aliens are enabled, the pedator has a small chance to become a Predalien. HOWEVER the predators are set that if one of them dies, the humans win. How would I kill the Predator and make him replaced by a Predalien without the marines winning?
 
Level 7
Joined
Jun 8, 2010
Messages
283
Well for the first part I cant really help you since I dont have WE open at the moment but yes something like that, removing the Player whose unit has been created from a Player Group.

To be honest I never really worked with Player Group triggers for those leak a lot and I just avoided them, ill try to see what I can do for your part.

For the second part, you would have to modify the Win conditions for each team. It would help if you posted the victory triggers here
 
Level 12
Joined
Jun 10, 2008
Messages
1,043
Well I can't really access the WE right now, so 'll just describe them and see if it helps.

Predator Win
When all the marines are dead, the predator will win. If aliens are still alive, it depends on a game mode.

Human Win
(This is the part I need help on)
When ONE of the predators dies, the humans will win. However, there is a small chance the predator will be an alien aswell, resulting in a Predalien and joining the alien team. This is where the problem occurds as I want to kill the predator and create a Predalien instead. However the win conditions are that when the Predator dies, the humans will win.

Alien Win
This depends on the game mode. Aliens can have victory conditions, or just be there to help turn the tides of the game and cannot win. Their victory condition would be when both marines and predators are dead.
 
Last edited:
Level 8
Joined
Jun 26, 2010
Messages
530
Well, i don't have your trigger so i will give you a "generic" solution

  • Events
    • Unit - a unit dies
  • Conditions
    • Unit-type of triggering unit equal-predator
  • Actions
    • If-Then-Else
      • If - Conditions
        • -------- 50% chances --------
        • [ random integer between 1 and 100] is greater than 50
      • Then - Actions
        • Unit - Create a predalien for alien team bla bla etc
        • Skip Remaining Actions
      • Else - Actions
        • Your original actions that would defeat the predators.
 
Level 12
Joined
Jun 10, 2008
Messages
1,043
No, I don't mean that when he dies he has a chance to become predalien. I mean that if aliens are enabled there is a very small chance that the alien cosen will also be the predator and this will result in the Predalien, anyways I think I figured this part out. Also since it chooses a random player from the Player Group... how would I remove that player? I can't figure this out...
 
Level 8
Joined
Jun 26, 2010
Messages
530
I really hoped i wouldn't had to do that, but it's the only way. As an A math studant i simply can't accept that. Especially because that's just too simple.

1 26 --- 51 76
2 27 --- 52 77
3 28 --- 53 78
4 29 --- 54 79
5 30 --- 55 80
6 31 --- 56 81
7 32 --- 57 82
8 33 --- 58 83
9 34 --- 59 84
10 35 --- 60 85
11 36 --- 61 86
12 37 --- 62 87
13 38 --- 63 88
14 39 --- 64 89
15 40 --- 65 90
16 41 --- 66 91
17 42 --- 67 92
18 43 --- 68 93
19 44 --- 69 94
20 45 --- 70 95
21 46 --- 71 96
22 47 --- 72 97
23 48 --- 73 98
24 49 --- 74 99
25 50 --- 75 100

As you can see, only by looking at it you see that the left group (between 1 and 50) and the right group (greater than 50) have the same number of integers. But you can always count one by one if you want. =)
 
Level 8
Joined
Jun 26, 2010
Messages
530
wrong its not 50% chance :D its 49 you have to make equal or greater. It will work with lesser than or equal too.

If that is your "trigger", that would be "[randon integer between 1 and 100] is equal or greater 50". So, chances are 51%. For 50% you would have to use "equal or greater 51" or "greater than 50" as i used.
 
Status
Not open for further replies.
Top