• 0

    posted a message on Trigger for anyone to activate?

    @Booleeas: Go

    First of, you can right click on the trigger root node in the right window and click on "copy as text" and post the trigger in the forums without having to take an image.
    I also recommend switching back to the simple view because its easier to understand for beginners.

    Second, the solution to your specific problem is a loop. Whenever you want to repeat a specific task for multiple players on a global level, you should use a "for each player" or "pick each player" loop. I recommend using a "for each player" loop because you will run into problems using "pick each player" only (This is beyond the scope of this question though).

    To understand how this works we need to remember some facts:

    - Players are just integers (Numbers between 0 and 15 in this case)
    - A player based loop will take a player group as parameter (a player group is a container storing players/integers) and loop through all entries of the container one by one
    - There a native function returning various defined player groups, such as "Active Players", "All Players" and so forth, but you can also create your own groups and add specific players to them.

    For your specific problem, a solution using player groups and loops could look approximately like this:

    mineral income
        Events
            Timer - Every 0.1 seconds of Real Time
        Local Variables
            current player = 0 <Integer>
        Conditions
        Actions
            Player Group - For each player current player in (Active Players) do (Actions)
                Actions
                    General - If (Conditions) then do (Actions) else do (Actions)
                        If
                            Player Kills[current player] <= 50
                        Then
                            Player - Modify player current player Minerals: Add 50
                        Else
    

    So, lets say there are 2 players in the game currently playing (Slots 5 and 8). The "Active Players" function will then return a player group in the following form: (5,8)

    The loop will now use the specified loop variable (current player in the above example) and set it to the first player of the player group (current player = 5).
    Then we check our conditions normally, using 5 as player index.
    After that, the loop will set current player to 8 and run the checks again. Once it looped through all entries of the group it will exit.

    Posted in: General Chat
  • 0

    posted a message on Trigger for anyone to activate?

    Please post your exact code causing the problem. It will be easier to explain the concept of multiplayer programming with a specific example.

    In most simple cases, you can use the (Triggering Player) function to retrieve the player who caused the event to fire.

    Example for a trigger displaying a greeting message for the player who entered "hello" in the chat:

    greeting
        Events
            Game - Player Any Player types a chat message containing "hello", matching Exactly
        Local Variables
        Conditions
        Actions
            Debug - Display (Combine ("hello and welcome ", (Name of player (Triggering player)))) as debug output using Type 01, and Do display it in the game window
    

    ^ If player 1 types "hello", Triggering Player will return 1 and therefore the game will display "hello and welcome <name of player 1>. If player 3 enters the chat message, Triggering Player will return 3 and so forth.

    Posted in: General Chat
  • 0

    posted a message on Blizz Contest - 79 Entries got through

    Good luck to everyone who made it!

    Posted in: General Chat
  • 0

    posted a message on Regions Stop Working After Merging Too Many Shapes?

    Im not aware of any limitations regarding region count, that said I also wasnt aware of the unit enters region event breaking with too many shapes, so...

    If you are using a ridiculously high region count then it might be a good idea to think of a better concept for solving the problem anyways.

    Posted in: Triggers
  • 0

    posted a message on Common Sense 101 (Triggering Edition)

    It really depends on what part of code you are currently working on. Even the old for loops were perfectly fine for about 95% of code at least, but for performance intensive code one should still prefer while loops and also always look at the generated galaxy output.

    Still, the GUI to Galaxy "compiler" would really benefit from some additional intelligence, such as removing empty else {} clauses and automatically inserting the < or > check for for loops depending on the increment. It could also support inlining for very short functions and remove all not used variables, functions and triggers automatically.

    Posted in: Triggers
  • 0

    posted a message on Regions Stop Working After Merging Too Many Shapes?

    Its not about the total number of regions, but the number of shapes defining a region.

    Posted in: Triggers
  • 0

    posted a message on Blizz Contest - 79 Entries got through

    Looking forward to the voting period, really excited to see who makes it! :D

    Posted in: General Chat
  • 0

    posted a message on Access to player specific options.

    Interresting find, but I would not rely on such code since it will most likely be fixed by Blizzard. They have stated various times that they do not want maps to be able to access graphics settings directly to make sure people with lower end hardware can not be excluded from games or other stuff like that.

    Since your code appearantly can even set specific settings for players and enforce them it seems to be a pretty big violation of Blizzards principles.

    Posted in: Galaxy Editor Bugs and Feedback
  • 0

    posted a message on AddEventUnitRegion - Variable Unit

    You need to enter the event dynamically to the trigger to work for non-preplaced units. It is important to set the unit variable BEFORE adding the event. The event itself is static and will not poll the newest value of the variables it uses.

    The easiest way to achieve this is to create a new action definition (function) with default parameters and the following content:

    add region enter event
        Options: Action
        Return Type: (None)
        Parameters
            trigger = No Trigger <Trigger>
            unit = No Unit <Unit>
            region = No Region <Region>
            enter = False <Boolean>
        Grammar Text: add region enter event(trigger, unit, region, enter)
        Hint Text: (None)
        Custom Script Code
        Local Variables
        Actions
            General - Custom Script: TriggerAddEventUnitRegion(lp_trigger, UnitRefFromUnit(lp_unit), lp_region, lp_enter);
    

    This function can then be used as follows:

    init
        Events
            Game - Map initialization
        Local Variables
            u = No Unit <Unit>
        Conditions
        Actions
            ------- create a non-preplaced unit.
            Unit - Create 1 Critter - Urubu for player 1 at (Position of Marine [63.74, 63.00]) facing (Position of Marine [63.74, 63.00]) (No Options)
            Variable - Set u = (Last created unit)
            ------- make region enter react to created unit and preplaced zergling
            add region enter event(unit enters region, u, Region 001, True)
            add region enter event(unit enters region, Zergling [63.80, 64.94], Region 001, True)
    
    unit enters region
        Events
            ------- dynamically added
        Local Variables
        Conditions
        Actions
            Debug - Display "hello world" as debug output using Type 01, and Do display it in the game window
    
    Posted in: Triggers
  • 0

    posted a message on Regions Stop Working After Merging Too Many Shapes?

    Merging too many regions should be avoided because the resulting shapes will get more and more complex.

    As an example, the random point in region function has a certain chance to fail and return 0,0 if the region shape is too complex. I dont have any experience with the unit enters region event and region merging, but I didnt notice any issues with it myself yet. That said, I cant remember combining 50 regions into one, ever.

    If you can clearly reproduce the issue and prove that its related only to the amount of regions merged (or the complexity of the resulting shape) then I would suggest writing a detailed bug report for Blizzard.

    Posted in: Triggers
  • 0

    posted a message on What does the "Custom Script" Option mean?

    It appears to inline the custom script code entered in the function. The function itself doesnt even exist in Galaxy when checking that flag. The implementation is a little bit weird though (just says custom script: (none) when using it and allows typing in the custom script, but without any effect) and it doesnt seem to be possible to pass any parameters.

    Posted in: Triggers
  • 0

    posted a message on Herostorm Info Dump

    Well, nevermind, there was just another patch.

    Anyways, thanks for this data. Im especially happy to see some useful new natives. The new CameraGetDistance will allow us to finally switch from Numpad + / - back to mouse wheel for camera zoom. :) There are also other neat features such as DialogItemRequestFocus.

    Posted in: General Chat
  • 0

    posted a message on Herostorm Info Dump

    Thanks! :D

    Is this from the latest build (30829) ?

    Posted in: General Chat
  • 0

    posted a message on Apparently the Mozared thread!

    Scary.

    Posted in: Off-Topic
  • 0

    posted a message on Mouse move trigger

    You can use a player group to figure out if any player is still holding down the left mouse button. Simply add the triggering player to the group when he pressed the left mouse button down and remove him once he releases the button. If the player group is empty you can disable the global mouse moved trigger, otherwise it needs to remain on.

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