I'm using the "Unit-Create" create command 4 different times for 4 different players, since I am making a 4 person multiplayer map. The idea here is I want the difficulty to ramp up (AKA, more units in waves) depending on how many people are playing. I've got a variable system set up, but I just want to make sure that the unit-create code isn't making units for players that arent playing. plz help, thanks.
Here's the basic script I'm using:
Variable
Difficulty = No Camera Object <Integer>
Melee Initialization
Events
Game - Map initialization
Actions
Unit - Create 1 Defender for player 1 at Player 1 spawn using point facing (No Options)
Unit - Create 1 Defender for player 2 at Player 2 spawn using point facing (No Options)
Unit - Create 1 Defender for player 3 at Player 3 spawn using point facing (No Options)
Unit - Create 1 Defender for player 4 at Player 4 spawn using point facing (No Options)
Player 1 Difficulty Check
Events
Unit - Any Unit Enters (Entire map)
Local Variables
Conditions
(Owner of (Triggering unit)) == 1
Actions
Variable - Modify Difficulty: + 1
Player 2 Difficulty Check
Events
Unit - Any Unit Enters (Entire map)
Conditions
(Owner of (Triggering unit)) == 2
Actions
Variable - Modify Difficulty: + 1
Player 3 Difficulty Check
Events
Unit - Any Unit Enters (Entire map)
Conditions
(Owner of (Triggering unit)) == 3
Actions
Variable - Modify Difficulty: + 1
Player 4 Difficulty Check
Events
Unit - Any Unit Enters (Entire map)
Conditions
(Owner of (Triggering unit)) == 4
Actions
Variable - Modify Difficulty: + 1
Difficulty System
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
Difficulty == 1
Then
Trigger - Run Trigger (Ignore Conditions, Don't Wait until it finishes)
Difficulty System 2
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
Difficulty == 2
Then
Trigger - Run Trigger (Ignore Conditions, Don't Wait until it finishes)
Difficulty System 3
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
Difficulty == 3
Then
Trigger - Run Trigger (Ignore Conditions, Don't Wait until it finishes)
Difficulty System 4
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
Difficulty == 4
Then
Trigger - Run Trigger (Ignore Conditions, Don't Wait until it finishes)
Then I've got 4 different triggers, each one corresponding with an attack wave, for example: first one sends a wave of 1 unit, next one 2, ect.
Also, if I'm playing with 4 people, it adds up the enemy units like this: 1+2+3+4 and then it send that number to attack.
There's probably an easier way to do this, but I'm a programming NEWB. :D
Now, any time you spawn units, multiply it with "Active Players". (You could insert the function "Number of players in (Active Players)" any time you spawn units, but it's way easier to just refer to a variable.)
When you initalize the map you need a few things changed. First, I'd suggest the 'pick each player' loop. This will allow you to create the unit, set the difficulty variable, and eliminate ur difficulty check all together. Also you can cut down your trigger count by using an action definition. Let me explain.
Make a variable for difficulty. I would also suggest creating a unit variable with an array of 4 so that you can call on ur players defender unit throughout the map, but only If the players only get that one unit. Then have pick each player contain this..
Create 1 defender unit for (picked player) at point. if the spawn points differ then create a point/region array defining each location to each players number and make unit created at spawnPoint[picked player]
then modify variable difficulty + 1. this will only fire when there is a player that is picked
Now for the fun part, the action definition.
Right click in the trigger name area of the trigger window and select new action definition. When this is created click on the options portion of the action def. And at the bottom click the first box that says run this thread independantly or w/e.
Now is the parameter value create a new element, make it of integer type with no value( or 0)
in this action definition you should define what you want your spawn trigger to do. Since you have 4 different occurances, I'd suggest creating a switch. With a switch make the dependancy the parameter value. This is your difficulty, I'll explain how it is in a bit.
So now that ur switch depends on difficulty then create a new case element. Define the case with a value of 1. Then in the newly created action section just make it do what u want with a difficulty of one player. Follow this step for case 2, 3, and 4.
Now go back to map initialization.
Since your action definition is defined you can call on it. So after your pick each player loop, create a new action and in the general section of trigger(at the top) you'll find your newly created trigger. This will look like <action definition name(0)>.
Make the zero value your difficulty variable.
Tada u are through. The parameter you made is a variable that has to be defined when you call the action. So putting the difficulty variable into that position defines it in the action definition. Bah..
Thanks for the response, but now I'm even more confused. I added a new action to melee initialization:
EDIT: I FIGURED THAT PROBLEM OUT: I was selecting ALL players instead of ACTIVE players, so it spawned the default player count of 16. Stupid mistake.
Also, I have absolutely no idea what you're talking about when you say "case element"
My spawn points are fixed, by the way. It is a 4 player game where every player has a predesignated spawning spot where one defender unit appears.
I would do a couple things to clean up and fix your code...
Variable(type:Region, array[4]):RegionArrayPlayerStartingPoint = (Stick your 4 player regions in here)
Actions
Pick Each Player in Player Group (Active Players)
Spawn a defender at RegionArrayPlayerStartingPoint[(arithmetic: Picked Player - 1)]
Switch (Number of Players in Player Group (Active Players))
Case (1)
Set up what ever sort of stuff you want for one player
Case(2)
Set up what ever sort of stuff you want for two players
Case(3) etc...
Default
Debug Msg("ERROR, Invalid number of Players",blah, blah)
Dammit, I'm so close, I can taste it. Your instructions are clean and easy to read, but I don't understand a few things. For one thing, how do I "stick my 4 player regions" in the variable? It's only letting me put one in. Are you saying I should make 4 of these with each player spawn region?
Also, I can't seem to get the arithmitic to work for Pick Each Player in Player Group. I'm not getting the option for that. I just need a tiny bit more help! Thanks! :D
I think what he means is create the variable as an array. then set variable to region 1,2,3,4 etc.
Then when you call that variable it will ask for which integer(player). integer 1 = player 1 and at the spot in the array for player 1 is also the region 1.
It makes more sense in practice.
I created a an 8 player map that spawns a new unit every 150 kills for 22 units all in one trigger as well as lots of other stuff. If you need help go to the sc2mapster IRC and when i'm online i'll help you
My name on there is mattavich
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I'm using the "Unit-Create" create command 4 different times for 4 different players, since I am making a 4 person multiplayer map. The idea here is I want the difficulty to ramp up (AKA, more units in waves) depending on how many people are playing. I've got a variable system set up, but I just want to make sure that the unit-create code isn't making units for players that arent playing. plz help, thanks.
Here's the basic script I'm using:
Variable
Difficulty = No Camera Object <Integer>
Melee Initialization Events Game - Map initialization Actions Unit - Create 1 Defender for player 1 at Player 1 spawn using point facing (No Options) Unit - Create 1 Defender for player 2 at Player 2 spawn using point facing (No Options) Unit - Create 1 Defender for player 3 at Player 3 spawn using point facing (No Options) Unit - Create 1 Defender for player 4 at Player 4 spawn using point facing (No Options)
Player 1 Difficulty Check Events Unit - Any Unit Enters (Entire map) Local Variables Conditions (Owner of (Triggering unit)) == 1 Actions Variable - Modify Difficulty: + 1
Player 2 Difficulty Check Events Unit - Any Unit Enters (Entire map) Conditions (Owner of (Triggering unit)) == 2 Actions Variable - Modify Difficulty: + 1
Player 3 Difficulty Check Events Unit - Any Unit Enters (Entire map) Conditions (Owner of (Triggering unit)) == 3 Actions Variable - Modify Difficulty: + 1
Player 4 Difficulty Check Events Unit - Any Unit Enters (Entire map) Conditions (Owner of (Triggering unit)) == 4 Actions Variable - Modify Difficulty: + 1
Difficulty System Actions General - If (Conditions) then do (Actions) else do (Actions) If Difficulty == 1 Then Trigger - Run Trigger (Ignore Conditions, Don't Wait until it finishes)
Difficulty System 2 Actions General - If (Conditions) then do (Actions) else do (Actions) If Difficulty == 2 Then Trigger - Run Trigger (Ignore Conditions, Don't Wait until it finishes)
Difficulty System 3 Actions General - If (Conditions) then do (Actions) else do (Actions) If Difficulty == 3 Then Trigger - Run Trigger (Ignore Conditions, Don't Wait until it finishes)
Difficulty System 4 Actions General - If (Conditions) then do (Actions) else do (Actions) If Difficulty == 4 Then Trigger - Run Trigger (Ignore Conditions, Don't Wait until it finishes)
Then I've got 4 different triggers, each one corresponding with an attack wave, for example: first one sends a wave of 1 unit, next one 2, ect.
Also, if I'm playing with 4 people, it adds up the enemy units like this: 1+2+3+4 and then it send that number to attack.
There's probably an easier way to do this, but I'm a programming NEWB. :D
You'll want a variable that you keep updated with the number of active playes:
Active Players = 0 <Integer>
Now, any time you spawn units, multiply it with "Active Players". (You could insert the function "Number of players in (Active Players)" any time you spawn units, but it's way easier to just refer to a variable.)
If you need to spawn the units at different places, just add a condition instead before you spawn any units:
When you initalize the map you need a few things changed. First, I'd suggest the 'pick each player' loop. This will allow you to create the unit, set the difficulty variable, and eliminate ur difficulty check all together. Also you can cut down your trigger count by using an action definition. Let me explain.
Make a variable for difficulty. I would also suggest creating a unit variable with an array of 4 so that you can call on ur players defender unit throughout the map, but only If the players only get that one unit. Then have pick each player contain this..
Create 1 defender unit for (picked player) at point. if the spawn points differ then create a point/region array defining each location to each players number and make unit created at spawnPoint[picked player]
then modify variable difficulty + 1. this will only fire when there is a player that is picked
Now for the fun part, the action definition. Right click in the trigger name area of the trigger window and select new action definition. When this is created click on the options portion of the action def. And at the bottom click the first box that says run this thread independantly or w/e.
Now is the parameter value create a new element, make it of integer type with no value( or 0)
in this action definition you should define what you want your spawn trigger to do. Since you have 4 different occurances, I'd suggest creating a switch. With a switch make the dependancy the parameter value. This is your difficulty, I'll explain how it is in a bit.
So now that ur switch depends on difficulty then create a new case element. Define the case with a value of 1. Then in the newly created action section just make it do what u want with a difficulty of one player. Follow this step for case 2, 3, and 4.
Now go back to map initialization.
Since your action definition is defined you can call on it. So after your pick each player loop, create a new action and in the general section of trigger(at the top) you'll find your newly created trigger. This will look like <action definition name(0)>.
Make the zero value your difficulty variable.
Tada u are through. The parameter you made is a variable that has to be defined when you call the action. So putting the difficulty variable into that position defines it in the action definition. Bah..
I hope u got all that, hope I helped, gl Hf
To clarify on what I meant about a unit variable..
In pick each player, after you create the unit, add..
playerHero[picked player] = (last created unit)
this will give you player 1's defender in slot 1 and so on, so later you can call apon their unit easily.
@BasicGear: Go
@BasicGear: Go
Thanks for the response, but now I'm even more confused. I added a new action to melee initialization: EDIT: I FIGURED THAT PROBLEM OUT: I was selecting ALL players instead of ACTIVE players, so it spawned the default player count of 16. Stupid mistake.
Also, I have absolutely no idea what you're talking about when you say "case element"
My spawn points are fixed, by the way. It is a 4 player game where every player has a predesignated spawning spot where one defender unit appears.
I would do a couple things to clean up and fix your code...
Variable(type:Region, array[4]):RegionArrayPlayerStartingPoint = (Stick your 4 player regions in here)
You can also make a hidden unit spawn those units using the data editor, and when the player leaves the game, simply kill the hidden unit(spawner).
Dammit, I'm so close, I can taste it. Your instructions are clean and easy to read, but I don't understand a few things. For one thing, how do I "stick my 4 player regions" in the variable? It's only letting me put one in. Are you saying I should make 4 of these with each player spawn region?
Also, I can't seem to get the arithmitic to work for Pick Each Player in Player Group. I'm not getting the option for that. I just need a tiny bit more help! Thanks! :D
I think what he means is create the variable as an array. then set variable to region 1,2,3,4 etc.
Then when you call that variable it will ask for which integer(player). integer 1 = player 1 and at the spot in the array for player 1 is also the region 1.
It makes more sense in practice.
I created a an 8 player map that spawns a new unit every 150 kills for 22 units all in one trigger as well as lots of other stuff. If you need help go to the sc2mapster IRC and when i'm online i'll help you
My name on there is mattavich