I'm trying to make a water-based map and I found a method that would work best for my map but I am confused at how it is done.
Make a unit group and add all of your naval units to it.
Create a trigger that goes off whenever a naval unit moves.
In that trigger, check the World Height (the height of the actual walkable terrain) against the height of the water. If the terrain at the place they're trying to move is higher than the water, don't let them move there.
So I have a unit group and I made a trigger that has the event "Unit - Any Unit uses Move at Generic1 - Any stage (Ignore shared abilities)"
The conditions of the trigger are that the target point is higher than the water's height and the action is to replace orders with stop.
But it is returning an error. I don't know if I have made a mistake along the way.
I didn't want to necro the very old naval unit threads, some people knew what they were talking about but I don't understand triggers very well so they didn't help me.
Just took a little more time reviewing how I set it up. I figured it out and decided against using that method. I'm using data alone for restricting units to be boats, using the colossus mover.
My next goals are sorting out unit spawns, attack orders, and victory conditions.
I assume you mean flying transports like medivac? There is a "No-flyzone" pathing too :D!
If you mean that a ground transport can target outside the pathing and bypass it then make the deploy range shorter or the pathing wider or have a trigger to check the texture (i dont have the editor so i cant check exactly what atm) and if its outside the water then stop his order
Make holes in the pathing where they are supposed to travel? Where is the problem else :P
EDIT: i mean, if transports are supposed to work then pathing is the solution, if its supposed to be like chokepoints that are walkable then pathing is still the solution :p
EDIT2: force to open the editor, added screencap. I have not worked with no flyzone pathing yet so im not really sure if it works but see how i left a hole that is passable by both air and ground.
My guess is medivacs are supposed to work, However if he does just pathing then he will be ale to drop unit into the water that aren't supposed to be there..
Oh, when you put it that way.. well.. i would have used a different texture for water areas then and have a trigger periodically check the texture and then drown the unit if its not supposed to be there.
Edit: I thought it was the other way around but i guess fish wont be travelling with medivacs anyway
Naturally one if for when you are in the water and one is for when you are out of the water.
Validators
A. Create a Validator of type "Location compare cliff level". Set this validator to "equals" and the value to "1".
B. Create a second one, same type. Except in this case set it for "greater than or equal to" and the value to "2".
Go back to the behaviors.
For the "In Water" behavior go to: Validators (Disable) and add the cliff level 1 validator.
For the "Out Water" behavior go to: Validators (Disable) and add the cliff level 2 validator.
Ok now a quick little explanation of how this actually works
-There is no "water" in StarCraft 2. And attempts do use doodads to define an "edge" run into the issue of water and land units trying to path through the tiny little gaps between each doodad. Not to mention the lag induced by having 500+ extra objects on your map. And I know they lag because I've tried it.
-Therefore in order for pathing to not be an issue we must be clever. Imagine a normal melee map in StarCraft 2. You know the base is on a higher cliff level than where most of the action takes place. Now imagine that this base has no ramp. There are 4 ways down. Some sort of teleport, air, reaper or colossus. This last unit is our preferred method. Now imagine that this colossus carries units like the medivac does. Starting to get the idea?
-Now you cannot use what I call "cliff level zero". This is that cliff level StarCraft 2 has that just down to the center of the planet. You cannot path ground down there. Only air pathing. Naval units in StarCraft 2 are in fact ground units. The reason why "naval" stays that way and "ground" stays that way is a difference in unit flags and also no ramps. Ground units will path around the cliffs if there is no way up.
-The behaviors are used to detect whether your are in or out of water so you can trigger relevant abilities.
Now make your amphibious unit.
Use some flag to make it different from ground units. I reserve the flag "massive" for naval units only. I use "robotic" for the amphibious transports.
One of the things I did is had another model be created and the "default" model opacity go to zero depending on whether it was in or out of the water.
So in the actor events for the base unit I put:
Behavior.In Water.Enable
-Set Opacity to 0
Behavior.In Water.Disable
-Set Opacity to 100
<<color red>>Then I made another actor of type Model:Modeladdition. Set the host to the basic amphibious unit you just created.
You want the "Immediate" in there to prevent the model from playing a death animation if it has one. "Destroy" by default triggers a the "death" animation of the model.
Now it will create your "boat" when you are in the water and be a "ground" unit when you are out of the water. This is very similar to the old "Rise of Nations" system and you can in fact make that system if you want to tolerate the lag of 50 models turning into boats in the space of 2 seconds. In this case you want your amphibious transport to carry units so you don't have this issue. Trust me I ran into it myself.
Add your "In Water" and "Out Water" behaviors to the unit.
Terrain
Ok so you want to create your terrain such that the "water" level or "sea bed" is cliff level 1 and the "ground" is cliff level 2 or higher. Adjust water height to be as close to the "ground" level for appearances sake. Make sure there are no ramps between cliff levels 1 and 2.
Height
May seem a bit odd why I called it this but its very important for a player to believe that its actually naval.
The "sea floor" is the ground level. In order to appear that its actually a boat you must go to this field:
Units Tab - UI:Height >> Set this such that your "boats" (NOT the amphibious transports) look like they are in the water.
Ok now for transports we need to do something a bit more tricky.
1. Go back to our "In Water" Behavior.
2. Go to Behavior:Modifications
3. Go to the "Unit" tab.
4. Go to the "Height" field.
5. Set that so that when the amphibious transport is in the water it "adds" the amount of extra height above to terrain to make it appear that its in the water.
Movers
We need to add the colossus mover to the amphibious transport.
Units tab >> Movement:Movers >> Set to "Colossus" mover.
Units tab >> Movement:Plane Array >> Set to "ground".
Flaws
-This isn't a perfect workaround. There are 3 major flaws with it.
1. This will not emulate WarCraft 3's "shallow water". In fact there is no way to emulate it that I or anyone else has found. And I think (since I'm the only one who's come up with any workable amphibious system for StarCraft 2) its fair to say that there is no other way.
2. There is a noticeable "dip" when a unit moves in and out of the water. I cannot eliminate this.
3. You can "unload" into the water. Fortunately there is a workaround for this.
Duplicated your "In Water" Behavior. You can use the same validator.
Now make an Effect type "damage". Set the "amount" field to 99999 (highest).
Then just add the effect to the "periodic effect" field of the behavior.
Add it to all of your ground units.
Now whenever the ground units are in the "water" they will take 99999 damage every loop and die quickly. You tell your players that they "drowned".
I'm trying to make a water-based map and I found a method that would work best for my map but I am confused at how it is done.
Make a unit group and add all of your naval units to it. Create a trigger that goes off whenever a naval unit moves. In that trigger, check the World Height (the height of the actual walkable terrain) against the height of the water. If the terrain at the place they're trying to move is higher than the water, don't let them move there.
So I have a unit group and I made a trigger that has the event "Unit - Any Unit uses Move at Generic1 - Any stage (Ignore shared abilities)" The conditions of the trigger are that the target point is higher than the water's height and the action is to replace orders with stop. But it is returning an error. I don't know if I have made a mistake along the way.
I didn't want to necro the very old naval unit threads, some people knew what they were talking about but I don't understand triggers very well so they didn't help me.
@Alchemist43: Go
What error are you getting? You may want to post your actual triggers.
@BasharTeg: Go
Just took a little more time reviewing how I set it up. I figured it out and decided against using that method. I'm using data alone for restricting units to be boats, using the colossus mover. My next goals are sorting out unit spawns, attack orders, and victory conditions.
Use pathing? (H)
Edit: attached screencap. Hydras inside cannot go out and marauders outside cannot get in
@user_874412: Go Transports can still drop them where they shouldnt be.
@SoulFilcher: Go
I assume you mean flying transports like medivac? There is a "No-flyzone" pathing too :D!
If you mean that a ground transport can target outside the pathing and bypass it then make the deploy range shorter or the pathing wider or have a trigger to check the texture (i dont have the editor so i cant check exactly what atm) and if its outside the water then stop his order
@user_874412: Go
How will he transport units across the water then?! XD
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
@willuwontu: Go
Make holes in the pathing where they are supposed to travel? Where is the problem else :P
EDIT: i mean, if transports are supposed to work then pathing is the solution, if its supposed to be like chokepoints that are walkable then pathing is still the solution :p
EDIT2: force to open the editor, added screencap. I have not worked with no flyzone pathing yet so im not really sure if it works but see how i left a hole that is passable by both air and ground.
@user_874412: Go
My guess is medivacs are supposed to work, However if he does just pathing then he will be ale to drop unit into the water that aren't supposed to be there..
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
@willuwontu: Go
Oh, when you put it that way.. well.. i would have used a different texture for water areas then and have a trigger periodically check the texture and then drown the unit if its not supposed to be there.
Edit: I thought it was the other way around but i guess fish wont be travelling with medivacs anyway
@willuwontu: Go
He could disable the medivac's unload ability... >.>
Ok here is what you will need.
Behaviors
A. Make a behavior, call it "In Water".
B. Make a second one. Call it "Out Water".
Naturally one if for when you are in the water and one is for when you are out of the water.
Validators
A. Create a Validator of type "Location compare cliff level". Set this validator to "equals" and the value to "1".
B. Create a second one, same type. Except in this case set it for "greater than or equal to" and the value to "2".
Go back to the behaviors.
For the "In Water" behavior go to: Validators (Disable) and add the cliff level 1 validator.
For the "Out Water" behavior go to: Validators (Disable) and add the cliff level 2 validator.
Ok now a quick little explanation of how this actually works -There is no "water" in StarCraft 2. And attempts do use doodads to define an "edge" run into the issue of water and land units trying to path through the tiny little gaps between each doodad. Not to mention the lag induced by having 500+ extra objects on your map. And I know they lag because I've tried it.
-Therefore in order for pathing to not be an issue we must be clever. Imagine a normal melee map in StarCraft 2. You know the base is on a higher cliff level than where most of the action takes place. Now imagine that this base has no ramp. There are 4 ways down. Some sort of teleport, air, reaper or colossus. This last unit is our preferred method. Now imagine that this colossus carries units like the medivac does. Starting to get the idea?
-Now you cannot use what I call "cliff level zero". This is that cliff level StarCraft 2 has that just down to the center of the planet. You cannot path ground down there. Only air pathing. Naval units in StarCraft 2 are in fact ground units. The reason why "naval" stays that way and "ground" stays that way is a difference in unit flags and also no ramps. Ground units will path around the cliffs if there is no way up.
-The behaviors are used to detect whether your are in or out of water so you can trigger relevant abilities.
Now make your amphibious unit.
Use some flag to make it different from ground units. I reserve the flag "massive" for naval units only. I use "robotic" for the amphibious transports.
One of the things I did is had another model be created and the "default" model opacity go to zero depending on whether it was in or out of the water.
So in the actor events for the base unit I put:
Behavior.In Water.Enable -Set Opacity to 0 Behavior.In Water.Disable -Set Opacity to 100
<<color red>>
Then I made another actor of type Model:Modeladdition. Set the host to the basic amphibious unit you just created.In there I put:<</color>>
Behavior.In Water.Enable -Create Behavior.In Water.Disable -Destroy (Immediate)
You want the "Immediate" in there to prevent the model from playing a death animation if it has one. "Destroy" by default triggers a the "death" animation of the model.
Now it will create your "boat" when you are in the water and be a "ground" unit when you are out of the water. This is very similar to the old "Rise of Nations" system and you can in fact make that system if you want to tolerate the lag of 50 models turning into boats in the space of 2 seconds. In this case you want your amphibious transport to carry units so you don't have this issue. Trust me I ran into it myself.
Add your "In Water" and "Out Water" behaviors to the unit.
Terrain
Ok so you want to create your terrain such that the "water" level or "sea bed" is cliff level 1 and the "ground" is cliff level 2 or higher. Adjust water height to be as close to the "ground" level for appearances sake. Make sure there are no ramps between cliff levels 1 and 2.
Height
May seem a bit odd why I called it this but its very important for a player to believe that its actually naval.
The "sea floor" is the ground level. In order to appear that its actually a boat you must go to this field:
Units Tab - UI:Height >> Set this such that your "boats" (NOT the amphibious transports) look like they are in the water.
Ok now for transports we need to do something a bit more tricky.
1. Go back to our "In Water" Behavior.
2. Go to Behavior:Modifications
3. Go to the "Unit" tab.
4. Go to the "Height" field.
5. Set that so that when the amphibious transport is in the water it "adds" the amount of extra height above to terrain to make it appear that its in the water.
Movers
We need to add the colossus mover to the amphibious transport.
Units tab >> Movement:Movers >> Set to "Colossus" mover.
Units tab >> Movement:Plane Array >> Set to "ground".
Flaws
-This isn't a perfect workaround. There are 3 major flaws with it.
1. This will not emulate WarCraft 3's "shallow water". In fact there is no way to emulate it that I or anyone else has found. And I think (since I'm the only one who's come up with any workable amphibious system for StarCraft 2) its fair to say that there is no other way.
2. There is a noticeable "dip" when a unit moves in and out of the water. I cannot eliminate this.
3. You can "unload" into the water. Fortunately there is a workaround for this.
Duplicated your "In Water" Behavior. You can use the same validator.
Now make an Effect type "damage". Set the "amount" field to 99999 (highest).
Then just add the effect to the "periodic effect" field of the behavior.
Add it to all of your ground units.
Now whenever the ground units are in the "water" they will take 99999 damage every loop and die quickly. You tell your players that they "drowned".
And thats about it.
nice one