• 0

    posted a message on What to use in place of "switches"?

    There are global variables and local variables. Global variables are defined in the same place triggers are defined (the tree view at the left of the trigger editor) and local variables are defined within a trigger. All triggers have access to global variables (read and write), but to local variables only the instance of a trigger where the variable was defined has access to it.

    If you set a global boolean variable to True, it's True to all triggers until it's changed to False.

    Posted in: Miscellaneous Development
  • 0

    posted a message on Is there a condition along the lines of "Last Unit Killed" ...?

    "Unit dies" event also returns "Triggering unit".

    Posted in: Miscellaneous Development
  • 0

    posted a message on Could this be done?

    On the other hand, you could just issue the order to the units as a queued order (like you do in-game by holding shift). Though there's a limit of how long the order queue can be... Anyway just order the first move and then the next move with the setting "After existing orders" instead of "Replace existing orders".

    Posted in: Miscellaneous Development
  • 0

    posted a message on Could this be done?

    It doesn't matter which one is more efficient because they are both efficient enough. Also instead of doing six different ifs, it would be clearer to use a Switch. Of course it's more "efficient" to use six different ifs because you don't need to do the variable increase, but there's just no point optimizing something like this especially if you have like 100 regions and you'd need to do 100 different ifs. What if you later have to change something? You'd have to change it in all the 100 ifs. With the for loop, you'd only need to do it once.

    "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." —Donald Knuth

    Maul2's method is simply just one trigger for each region.

    Posted in: Miscellaneous Development
  • 0

    posted a message on Training units that spawn in bunker

    Ah, why didn't you say so! The bunker is not being trained, it's being constructed.

        Events
            Unit - Any Unit construction is Completed
        Local Variables
        Conditions
            (Unit type of (Triggering progress unit)) == Bunker
        Actions
            Unit - Create 4 Marine as cargo in (Triggering progress unit)
    
    Posted in: Miscellaneous Development
  • 0

    posted a message on Could this be done?

    Something like this? I didn't test it but the idea is there.

    Global variables

    RegionArray = No Region <Region[6]>
    Wave = (Empty unit group) <Unit Group>
    

    Triggers

    Initialize Regions
        Events
            Game - Map initialization
        Local Variables
        Conditions
        Actions
            Variable - Set RegionArray[0] = Region 001
            Variable - Set RegionArray[1] = Region 002
            Variable - Set RegionArray[2] = Region 003
            Variable - Set RegionArray[3] = Region 004
            Variable - Set RegionArray[4] = Region 005
            Variable - Set RegionArray[5] = Region 006
    
    Enter Region
        Events
            Unit - Any Unit Enters Region 001
            Unit - Any Unit Enters Region 002
            Unit - Any Unit Enters Region 003
            Unit - Any Unit Enters Region 004
            Unit - Any Unit Enters Region 005
            Unit - Any Unit Enters Region 006
        Local Variables
            RegionIndex = 0 <Integer>
        Conditions
        Actions
            General - For each integer RegionIndex from 0 to 5 with increment 1, do (Actions)
                Actions
                    General - If (Conditions) then do (Actions) else do (Actions)
                        If
                            (Triggering region) == RegionArray[RegionIndex]
                        Then
                            General - Break
                        Else
            General - If (Conditions) then do (Actions) else do (Actions)
                If
                    RegionIndex < 5
                Then
                    Unit - Order all units in Wave to ( Move targeting (
                      Center of RegionArray[(RegionIndex + 1)])) (Replace Existing Orders)
                Else
    
    Posted in: Miscellaneous Development
  • 0

    posted a message on Training units that spawn in bunker

    Are you sure you are actually training the units from the Bunker? Because when I tested it with Barracks, the trigger works just fine.

    This trigger displays "Training complete." when a unit is trained from Barracks. "Triggering unit" refers to the Barracks and "Triggering progress unit" refers to the unit that was trained (I tested this too).

        Events
            Unit - Any Unit training is Completed
        Local Variables
        Conditions
            (Unit type of (Triggering unit)) == Barracks
        Actions
            UI - Display "Training complete." for (All players) to Subtitle area
    
    Posted in: Miscellaneous Development
  • 0

    posted a message on Threat/Aggro System

    No, you would have the thread stored in the NPC units per player, not in the player units. For example:

    When player 1 builds 100 threat on NPC unit A, you add 100 to unit A's custom value 1. When player 2 builds 100 threat on NPC unit A, you add 100 to unit A's custom value 2. Same for 3 and 4. Then when they attack unit B, you add the threat to unit B's custom values 1, 2, 3 or 4 depending on which player attacked it. The point is to store each player's threat separately to the NPC unit they built it on.

    And each time a unit gets added threat, you go through that unit's threat table (custom values 1, 2, 3, and 4), check which is highest, and order to attack that player. For example if NPC unit A has 100 threat in custom value 1, 105 threat in custom value 2, 0 threat in custom value 3 and 50 threat in custom value 4, you go through the values and notice that 105 is the highest, and order the unit to attack player 2.

    If you want to avoid "threat bouncing", you check if 105 is let's say 10% higher than the threat of the unit it is currently attacking. For example if the unit was attacking player 1 who has 100 threat, and then player 2 builds 105 threat on the NPC, you check if 105 is higher than 100*10% = 110, and it's not, so don't switch target yet. But when player 2 reaches 111 threat, it becomes higher than 100*10% (assuming player 1 still has only 100 threat on the unit) and the unit switches its target to player 2.

    Posted in: Project Workplace
  • 0

    posted a message on Training units that spawn in bunker

    Try "Triggering progress unit". It works for construction so I guess it's the same for training. Triggering unit probably refers to the unit that is being trained, not the unit that is training.

    Posted in: Miscellaneous Development
  • 0

    posted a message on How to get a single unit to move?

    I didn't realize this at first either. It's easier to double click it in the tree view instead of clicking the parenthesis. Here's a pic to make it easier for anyone else with the same problem.

    Posted in: Miscellaneous Development
  • 0

    posted a message on Threat/Aggro System

    Well you need a threat table for each unit that can have threat, and using the custom values of units seems like the simplest way to do this. If there's a limited number of units that can cause threat, just make a global array of those units and then set the enemy's custom value of the corresponding index to indicate how much threat it has. Or instead of a global array, you can store the index of each player unit to one of that unit's custom values.

    For example, if you have 5 players which each have 5 units, the array would have indexes 0-4 for the units of the first player, 5-9 for the units of the second player, 10-14 for the third, 15-19 for the fourth and 20-24 for the fifth. When one of those units cause threat to an enemy, set that enemy's custom value X to the amount of threat caused by unit X (where X is that unit's index in that array). Each time an enemy takes damage, go through the enemy's custom values and find the highest one. Then make the enemy attack the unit of the corresponding index.

    Posted in: Project Workplace
  • 0

    posted a message on Setting shared control values easily???

    I think you're looking for the "Set Alliance For Player Group" action.

    Local Variables
        AffectedPlayers = (Empty player group) <Player Group>
        X = 0 <Integer>
    Conditions
    Actions
        General - For each integer X from 3 to 10 with increment 1, do (Actions)
            Actions
                Player Group - Add player X to AffectedPlayers
        Player - Make all players in AffectedPlayers treat each other as Ally With Shared Vision
    
    Posted in: Miscellaneous Development
  • 0

    posted a message on Problem with Attack

    Make them first attack the front of the ramp and then add an attack that goes to the base.

    Unit - Order (Unit) to ( Attack targeting Front of the Ramp) (Replace Existing Orders)

    Unit - Order (Unit) to ( Attack targeting Base Behind the Ramp) (After Existing Orders)

    Then the units will first go to the front of the ramp, attack anything they find there, and then attack the base.

    Posted in: Miscellaneous Development
  • 0

    posted a message on displaying text?

    If you want to display text on the UI, use the "Text Message" action. If you want to display text in the 3D world, for example above an unit, use the "Text Tag" actions (there are several, categorized under that label).

    Posted in: Miscellaneous Development
  • 0

    posted a message on Unit construction Completed ?

    Your condition fails. You should be using "(Unit type of (Triggering progress unit)) == Pylon" instead. Tested and works.

    Posted in: Miscellaneous Development
  • To post a comment, please or register a new account.