HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Multiple Player slot conditions

06-02-2006, 11:38 AM#1
darkwulfv
I'm sure this requires JASS (and that's ok, I can check Vex's tutorial to see how to do this) but I need either a JASS or GUI trigger that checks to see how many players are in the game, and then do things to the map, like destroy starting gold mines at the empty areas. Any way I could do this?
06-02-2006, 11:48 AM#2
The)TideHunter(
Well, to check how many players are here, use this trigger:

Trigger:
Count Players
Collapse Events
Map initialization
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 12, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Player((Integer A))) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Else - Actions

And with gold mines, you will have to destroy them manually, but with triggers ofc :)

Trigger:
Actions
Unit - Remove Gold Mine 0000 <gen> from the game
06-02-2006, 07:32 PM#3
darkwulfv
... Im confused. If, then, else, and, or, etc. triggers make my brain itch *itches brain* Ok. Much better. How do you make an action within an action like you did? This trigger really makes my brain itch badly. I'm not a very advnced trigger maker. Just tell me how to set up action, followed by the if, else stuff and ill fill in the blanks. Basically, I need you to do this for me please. Tell me where & how to make action 1 (for each integer.....), the loop, and the if else conditions. GAHHH! so much trigger stuff, so little brain space. I'm gonna fiddle around a bit, see what I can find out on my own. Thanks for the tigger. So how do I connect the destroy gold mine to the trigger? O wait...

Event: Map Init.
Condition: Player one slot status equal to not playing
Action: Destory gold mine 0000 ( or whatever it may be)
And just make a trigger for each player (8)
Sorry for rambling on and on

EDIT: I cannot find the "loop-actions"
Also, I cannot find the condition "((Player((Integer A))) slot status) Equal to is playing" I know where all but the Integer A part is. How do you make the player into an integer? Do I need to set the integer to something?((Integer A)))
Last, what action do I do for the first action? "For each integer A, do actions"?
06-02-2006, 08:26 PM#4
The)TideHunter(
Ok, give me a moment, il write it up.

Write up:

Ok, so we have:

Trigger:
Number of Players
Collapse Events
Map initialization
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 12, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Player((Integer A))) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Else - Actions

Firstly.
On the events, click new event then select Map Init (this should be default)

Secondly, to get For each Integer A, first create a new action, were it says - All. Change to General. Look for a "For each Integer A, Do multiple Actions.
By default, it will say from 1 - 10, change this to 1 - 12, the first player being 1, and the last being 12.

Now you have the integer loop set up.
Go back to general were you found the For each integer a, and look for If / then / else, multiple functions. Add it to your integer a loop. (Make sure its in the loop and not outside of it, i normally rightclick the loop and add the action from there)

Once you have your if then else, right click If and click add condition, go to the tab that says "Player slot status Comparison". then click the text that says Player 1 Slot status. then another window will pop up, click Player 1, then another window will pop up, where it says Picked Player, change that too Conversion - Convert Player index to Player. click the 1 thats inside Player().
Then another window will come up, look on the tab for something that says For Loop Inteter A (it should be the second 1 down).

Now press ok to all the windows.
You should now have:

Trigger:
Number of Players
Collapse Events
Map initialization
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 12, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Player((Integer A))) slot status) Equal to Is playing
Then - Actions
Else - Actions

Now make a variable (Cntl + b) as a integer, call it something like NumberOfPlayers.

In the actions under your If, where it says Then, add the action:
Go to general again, click Set Variable, and then select the NumberOfPlayers variable, and set it to NumberOfPlayers = NumbersOfPlayers + 1, to do this click where it says value, and click the integer from the top. then press ok, it should then say in the box: "NumberOfPlayers + 1"

Press ok a few times, and your done, you should have:

Trigger:
Number of Players
Collapse Events
Map initialization
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 12, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Player((Integer A))) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Else - Actions

If not, post what you have
06-02-2006, 08:27 PM#5
darkwulfv
K thx : ) OMG I don't know how to repay you here. Thank you so fricken much. I'm glad you walked me throughh it too so I could learn. I've got exactly what youve got, except the 12 is an 8 because ive only got 8 players. So how does this trigger work, and what do I do with it?
06-02-2006, 08:54 PM#6
The)TideHunter(
Yes.

If you had 8 players, it would simply as you said be:

Trigger:
Number of Players
Collapse Events
Map initialization
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 8, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Player((Integer A))) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Else - Actions
06-02-2006, 08:54 PM#7
moyack
Quote:
Originally Posted by The)TideHunter(
Well, to check how many players are here, use this trigger:

Trigger:
Count Players
Collapse Events
Map initialization
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 12, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Player((Integer A))) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Else - Actions

And with gold mines, you will have to destroy them manually, but with triggers ofc :)

Trigger:
Actions
Unit - Remove Gold Mine 0000 <gen> from the game
Don't worry, it's just to get used to the system. If-then-else action loads automatically the conditional and the "subactions" slots. this action is one of the first in the list action ans is called "if then else multiple actions". The loop action creates the subsections too, it's called "for each integerA do loop" in the action list.

One thing that you must take in accout with triggering is to be very efficient, I mean, as less triggers you use, your map will run better. It can be simplified with the trigger suggested by The)TideHunter(. I suggest to add in the else part of the conditional the action to remove the unused gold mine, something like that:
Trigger:
Count Players
Collapse Events
Map initialization
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 12, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Player((Integer A))) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Collapse Else - Actions
Unit - Remove (Random unit from (Units in region (Region centered in (Player(Integer A)) Start location with size 1500,1500) Matching (Unit type of Matching unit equal to Gold mine)))
Sorry if I wrote wrong the else condition, I don't have WC intalled in this computer. but you can get the idea, The)TideHunter( can check this.
06-02-2006, 09:07 PM#8
darkwulfv
Thx for the else action moyack. From what I've seen before, I think your trigger will work fine. Course, I could be terribly wrong. I may have to ask about how to do the else action, but I'll try my best to do it before asking.
@TideHunter I actually had gotten pretty close to what you had been doing. I had used the wrong for each action, integer A thingy, and was a little close in that a variable had to be used. I'm really starting to learn. I can't wait to show you guys my map when it's all done. (but that won't be for a while. I've still got tons of units to make, along with the terrain, triggers, etc.
Ok Tide, heres a question for you, seeing as how your really good with triggers and JASS. I need a spell that will make a damging ligtning bolt, and I think I know how to do it. I;ve got a couple of theorys. I'll post them as I make them. If I run into any problems I'll lket you know : )

OK!!!! YAY I managed to complete my FIRST Trigger spell and I feel very proud of myself. Here is the trigger. Actually I don't know how to put triggers into messages. All i could find ar the trigger tags, and I don;t know how that works... Help plz!
06-03-2006, 01:17 PM#9
The)TideHunter(
Right ok i will explain what the trigger actually does.

The map init event, pretty obvious, it runs when the loading screen finishes loading.

The first action is For Each Integer A from 1 - 8
This just means, it will run all the actions you put in it that amount of times.
They are called Loops, because it loops the actions, it starts as 1, does all the actions, then goes to 2, until it reaches 8, then after 8 it will exit the loop.

Now, i refered to Player(For Loop Integer A) because, when the loop is on 1, that will actually say (Player 1), until it gets to player 8, so it checks if the players are ingame, then if 1 of them are, it will set NumberOfPlayers to +1, and because it loops, it is possible to set NumberOfPlayers to +8, depending on if the condition was correct.

This is a longer version of what i wrote:

Trigger:
Number of Players
Collapse Events
Map initialization
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 1 (Red) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 2 (Blue) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 3 (Teal) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 4 (Purple) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 5 (Yellow) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 6 (Orange) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 7 (Green) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 8 (Pink) slot status) Equal to Is playing
Collapse Then - Actions
Set NumberOfPlayers = (NumberOfPlayers + 1)
Else - Actions

If you changed the For Loop to 1 - 2, it will loop the actions 2 times, if you set it to -5 - -3, it will run it twie, if you set to 1 - 100, it will run it 100 times.
Notice the, it will check if player 1 is ingame, if player 2 is, until it gets to player 100, which dosent exsist, this might cause a crash im not sure.

All the For Loop does it optimize your code and make it run slightly faster.

EDIT: To put triggers into a wc3c thread, click the Trigger Tag button, then go to your trigger, above the word Event, is your triggers name, right click the triggers name and click Copy as Text, then paste the text in between the [T RIGGER] and [/T RIGGER], so it would show 'and' in my case
06-03-2006, 02:36 PM#10
darkwulfv
Thx again Tide. To see the spells I made, go to triggers and scripts and look for "My first trigger spell : )" That's mine. I posted the lightning bolt spell there, along with a fire spell at the end. Hope you like them! (yes, I know they leak. I'm going to get around to that as soon as I feel like learning custom scripts)