Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Tutorial] StarCraft 2 Amphibious System

Discussion in 'StarCraft II Tutorials' started by FockeWulf, Apr 25, 2012.

  1. FockeWulf

    FockeWulf

    Joined:
    Apr 16, 2012
    Messages:
    45
    Resources:
    4
    Tutorials:
    4
    Resources:
    4
    Ever wondered why StarCraft 2 has no water? Well we all know the answer to that (traditional human stupidity) but here is the best workaround for this problem.

    Note: This guide assumes you have basic knowledge of how to create units, behaviors, actors, effects, validators. This is merely to give you a clever way to combine a few things to fake a water system. So far none of the non-modder fans realised it wasn't actually water unless I told them.

    The StarCraft 2 Amphibious System

    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 compair 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. Imagion 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 abilites.

    Now make your amphibous unit. Perhaps port over a WarCraft 3 model (guide on how to do this later). Use some flag to make it different from ground units. In WW2 Diplo I reserved the flag "massive" for naval units only. I used "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

    Then I made another actor of type Model:Modeladdition. Set the host to the basic amphibious unit you just created.

    In there I put:

    Behavior.In Water.Enable
    -Create
    Behavior.In Water.Disable
    -Destroy (Imediate)

    You want the "Imediate" 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 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 the 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 "Collossus" 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 whos come up with any workable amphibious system for StarCraft 2) its fair to say that there is no other way.

    2. There is a noticable "dip" when a unit moves in and out of the water. I cannot elimate this.

    3. You can "unload" into the water. Fortunatly 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 whever 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.

    Got any feedback or corrections? I did this off the top of my head so its easy to get things backwards. For instace I always forget whether the "Validator:Disable" and "Validator:Remove" field activates when the validator is false or when it is true.

    Hope it helps!
     
  2. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,131
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    You need to make it clear that it will only be water if you make it look like water. It is equally possible to make it look like Lava or to have the units appear to fly.

    There might be a better trigger alternative where you forcefully reload the unit back into the transport. Much more polished than killing the units for an action that should not be allowed.

    It might be a good idea to make amphibious units use a reaper based jump rather than the colossus walk. This also gives you a transition period which can be good for visuals (such as converting to amphibious mode or unloading from a transport).
     
  3. FockeWulf

    FockeWulf

    Joined:
    Apr 16, 2012
    Messages:
    45
    Resources:
    4
    Tutorials:
    4
    Resources:
    4
    Those are perfectly viable alterations. Depends on what you are after.

    I am wary of adding more trigger load to WW2 Diplo but in other maps it will probably be ok.

    I don't think the reaper jump will be a better idea. You want it as smooth as possible not a "leap".
     
  4. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,131
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Depends on how optimized they are. Trigger content only uses processor time when it executes something. It only executes something when an event socket runs a trigger.
     
  5. FockeWulf

    FockeWulf

    Joined:
    Apr 16, 2012
    Messages:
    45
    Resources:
    4
    Tutorials:
    4
    Resources:
    4
    Ok then add 300+ units on the map at any given time plus 2 major battles.

    Graphical lag leads to trigger lag.
     
  6. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,131
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    There is no lag... It performs very poorly (low frame rate) but response times remain the same.

    Also the low frame rate is almost always the result of a CPU bottleneck. Modern GPUs are mostly idle when running StarCraft II. The trigger would only run if someone tries to unload their troops which seldom occurs and will probably have an unnoticeable time overhead. If someone was repeatedly unloading into the water then it might run up a large time overhead but I do not think many big battles could occur against people doing that (and everyone would have to for it to make any difference) and your ships would make short work of their armies (they are too busy trying to drown their troops).
     
  7. FockeWulf

    FockeWulf

    Joined:
    Apr 16, 2012
    Messages:
    45
    Resources:
    4
    Tutorials:
    4
    Resources:
    4
    So.....

    Any idea if this tutorial is approved or not?
     
  8. Silverfish423

    Silverfish423

    Joined:
    Dec 13, 2008
    Messages:
    912
    Resources:
    0
    Resources:
    0
    I am wondering the same thing