• 0

    posted a message on Trigger with unit loop executes multiple times.
    Quote from Windexglow: Go

    The easiest way is to..

    GLOBAL boolean b = false

    conditions: if b == true than don't run this trigger

    set b = true kill unit u set b = false

    Untested but this worked in wc3.

    That's too hackish for my tastes.

    • Kept this first bit here for posterity, possible reason/solution starts at ...Hmm*

    Try printing out the name of the "Triggering Unit" every time (Convert Game Link to String to Text) the trigger executes (keeping your condition in there). (outside of the loop)

    Is the name of the "Triggering Unit" the same every time? IE. does it print out "Special Building" each iteration, or something different.

    If it is always "Special Building" I would suspect that the game sees the building dies, runs the trigger. It then runs the loop looking for all of your units. Technically the *dead* building is still one of "your" units as far as the game is concerned, so it sends it a "kill" command again and the loop processes again. (Although why it wouldn't run this infinitely if this were the case, I'm not sure).

    If the name of the "Triggering unit" is different everytime, something is goofy with the trigger. Or you have a conflicting trigger elsewhere and the root of the problem isn't here.

    ... Hmm, after reading this I see that in your loop you're *already* excluding the dead units in your filter!

    There's another possibility. It's looping through "units in x owned by y matching z" and setting the variable U. The first iteration works fine, it sets U to, say, unit1, and kills it.

    On the second iteration it has to look for the 2nd unit. It performs the check again (This is conjecture, and would be a poorly-coded loop, but it may be what you're experiencing) for units in x owned by y matching z (where 'z' is now *excluding* the dead unit1)

    Since the loop is looking for the 2nd unit, but unit 1 is no longer in the array, it actually finds unit 3 - and kills it.

    Let's say our array starts out like this:

    • [0] = Unit1
    • [1] = Unit2
    • [2] = Unit3
    • [3] = Unit4

    Since we're in a loop, we have an iterator 'i'.

    i = 0

    Now, we kill index [i] = Unit1, and our array looks like this:

    • [0] = Unit2
    • [1] = Unit3
    • [2] = Unit4

    i = 1

    Now, we kill index [i] = Unit3, and our array looks like this:

    • [0] = Unit2
    • [1] = Unit4

    i = 2

    Now, we kill index[i] = ARRAY OUT OF BOUNDS ERROR

    Taking your comments and your trigger in isolation - I would expect that this is what is happening.

    There may be other conflicting triggers still though. There are two things you can try to do to fix this problem.

    1) Change "for each unit" to "pick each unit" and use "Picked Unit" instead of "U". See if this works, if not, go onto #2

    2) Where your loop reads Units in X owned by Y matching Z, use a local variable instead. Set the local variable *before* the loop runs to this unit group. Then iterate over the pre-populated unit group so that it isn't performing the filter check every time the loop iterates. (This is more efficient computationally anyway). This way it won't be removing items from your array in the middle of the loop.

    Let me know if any of this helps, I can't be certain this is what you're experiencing, but I suspect it is

    Posted in: Miscellaneous Development
  • 0

    posted a message on Giving a unit an ability using a trigger...?

    I know how to give a unit an ability via the data editor, but in this specific case I need to be able to give a unit an ability in a trigger action.

    I can't find a decent action that will let me add an ability, or that will let me put an ability in a specific command card slot. Is there something I should do in the data editor (like add an ability that starts out 'hidden' somehow) so that the trigger "Enable" ability and/or "Show" ability actions actually do something?

    This was a pretty simple task in the wc3 editor, so I think it should be possible here too - what am I missing?

    Posted in: Miscellaneous Development
  • 0

    posted a message on # of units

    @JnAkers

    Event - Unit is created

    Conditions -
    Unit type - unit type of [created unit] == probe
    (Unit count for player [Unit = Probe], [Player = Owner of created unit], [Count type = complete]) == 8

    Actions -
    Do stuff

    Note that for the above poster, I don't know if "Unit construction is completed" fires for training a unit.  But I do know that "Unit is created" does.  

    That condition of his would work though.

    Posted in: Miscellaneous Development
  • 0

    posted a message on F-f-fre-freezing an unit through an ability?
    Quote from Docablo: Go

    Another way would be to give the ability an Apply Behavior Effect that gives the target unit a Behavior that using Modifications+ suppresses its movement, and attack.

    This is the preferred method of doing it over using triggers. More reliable.

    Posted in: Miscellaneous Development
  • 0

    posted a message on Effect [type='Create Unit'] - Follow rally point?

    In the data editor I have an effect to "Create Unit".

    Is there a way (using the data editor) to make the unit follow the rally point of it's parent building every time one is spawned? I can't quite figure this one out :<

    I do see the "Effects - Effect - Spawned" option in my Create Unit effect, which applies an effect to the spawned unit. But I can't seem to make a good effect that will force the unit to follow a rally point of the building that made it. There is the "Issue Order" effect type, but that doesn't (seem to) have any kind of "Follow rally point" type of options.

    Anyone have ideas? Thanks!

    Posted in: Miscellaneous Development
  • 0

    posted a message on Assign newly created units an ability order?
    Quote from Nothing5: Go

    @nZifnab: Go

    I just applied this new behavior using the data editor.

    First I created a new Behavior in the behavior tab (lol) and set it as a buff.

    Named it "Auto-Explode", Effect - Periodic: Baneling - Explode, Period: 0.1, and gave the behavior to the Baneling unit.

    Thanks for your codes by the way, they may come in handy pretty soon :D

    Oh...obviously. Giving the behavior to the unit will make it start with that.

    I'm half-retarded sometimes.

    Posted in: Miscellaneous Development
  • 0

    posted a message on Noob Question: How do I call a function that doesn't return anything

    When you create the function there should be that "Options" section in the function definitions.

    Click on it, and see that a dropdown will be there for it, with a bunch of checkboxes under it. In the dropdown, select "Action" - this causes the function to show up in the actions list when adding actions to a trigger, and makes it so that a return value will do nothing.

    Depending on your action, you can also look at "Create Thread" in the checkboxes. If you want the calling trigger to *wait* for the function to finish before continuing with it's actions, keep this unchecked - but if you want to call the action asynchronously (At the same time as the calling trigger), then check this and it will be ran in it's own thread.

    Hope this helped!

    Posted in: Miscellaneous Development
  • 0

    posted a message on Assign newly created units an ability order?
    Quote from Nothing5: Go

    EDIT: Never mind! I got it working! I just had to give the Baneling a new behavior that explodes automatically once created. Thanks for your help though!

    Did you make it so the baneling gets this new behavior from the data editor, or a trigger?

    If you did it in the data editor.... how? i'd like to know :) It would help me out some :p

    Posted in: Miscellaneous Development
  • 0

    posted a message on Assign newly created units an ability order?
    <<pre>>
    Event:  "Unit is created"
        Unit - Any Unit creates a unit with Zergling - Morph Unit (Zergling -> Baneling) or Zergling (Burrowed) - Morph Unit (Zergling -> Baneling)
    Note that if you've edited how a baneling is 'created' from the data editor, choose the appropriate ability from the options
    
    Action:  "Issue order"
        Unit - Order (Created Unit()) to (Baneling - Explode) (Replace Existing Orders)
    <</pre>>
    Posted in: Miscellaneous Development
  • 0

    posted a message on [Bug] Event - Unit Construction Progress

    Maybe I was too quick to judge there ;)

    The event "Unit is created" may be what I was looking for (Triggering unit is the creator, Created Unit is the unit being created - and it fires when a building construction begins)

    But going along with that, maybe for the Unit Construction Progress there should be a "Constructing Unit" in addition to the "Triggering Unit"? Because it's still difficult to capture the unit during other parts of it's construction lifecycle (for instance: Complete).

    Posted in: Galaxy Editor Bugs and Feedback
  • 0

    posted a message on [Bug] Event - Unit Construction Progress

    This event doesn't seem to send a very sane unit to the [Triggering Unit] function. observe:

        Events
            Unit - Any Unit construction is Started
        Local Variables
        Conditions
        Actions
            Unit - Remove (Triggering unit) from the game
    

    This (in my mind) would preferably have the *building* that is being constructed as the "Triggering unit". But alas, the triggering unit is actually the builder. So if I want to have a condition in there to disallow the building from constructing, I can't just say Remove (Triggering unit) because then my builder gets removed (which I really don't want).

    If I change the event to "Unit - Any Unit construction is Resumed", or "Completed" or any other options, nothing at all will happen. Outputting a message in the actions will show that for "Started" the triggering unit is builder, but for "Resumed" the event occurs at the same time as "Started", but has no Trigger Unit, and for "Completed" the triggering unit is empty as well (And gives me errors when I try to do other things with the 'triggering' unit, like refund the cost to the player, for instance).

    What's a good way for me to conditionally prevent a structure from being built? (No, I can't just add it to the data editor in Requirements - this is a region-specific requirement. IE. "Does this region already have a structure of type X in it? - can't build anymore!"). This is somewhat annoying :(

    Posted in: Galaxy Editor Bugs and Feedback
  • 0

    posted a message on Issue order sequence/order unit to follow rally points

    There should be an easy way in the trigger editor to issue an order-sequence for a unit (simulate the shift key + sequence of orders), including the ability to make a unit follow the rally point of another unit.

    IE. I have structure_x, and I have a trigger that spawns a unit near structure_x because of some event. I should then be able to, using the trigger editor, give the spawned unit an 'order sequence' to attack-follow the points of the rally point just as if the structure had created the unit itself.

    I can easily make the unit go to one of the points on the rally point - but there's not really a clean/easy way that I can see to follow a multi-point rally.

    Anyone have suggestions?

    Posted in: Galaxy Editor Bugs and Feedback
  • 0

    posted a message on Extreme terrain height issues.

    If you look at the building in the data editor (I don't have it in front of me right now - but I think the actor for the building) at it's events you will see that it has things like "OnConstructionStart: FlattenTerrain" (not verbatim, but that's the gist). I wasn't sure what this was doing, but now I suspect it's what you're experiencing.

    You might get "undocumented" behavior if you remove the flatten terrain events - If you'll notice raising and lowing the terrain without specifically using cliffs never blocks line of sight either. I suspect that terrain height changes is meant specifically for aesthetics at ground-level, but not to change gameplay in any way whatsoever.

    Posted in: Galaxy Editor Bugs and Feedback
  • 0

    posted a message on [Bug]? No 'Player' data type

    In the trigger editor I don't see a way to set a 'Player' type variable or parameter. It's got "Player Group" and "Player Color" but no "Player". Pretty annoying. i guess for now I'll make the function return "Player Group" and just make the calling trigger use the first (and only) player from the returned group.... Or maybe Integer is synonymous to Player? It does seem to use them interchangeably in the 'Player' triggers (ie. you can use "player (1)" or you can use "player (owner of (unit_a))"...

    If I have the method return integer I guess that'll work. Weird that there's no Player type!

    Posted in: Galaxy Editor Bugs and Feedback
  • 0

    posted a message on Tutorial Request

    @vjeux: Go

    There really should be a tutorial on how to 'graft' units to other units (think: Uberlisk). I realize there's that XML tutorial for the uberlisk - but it would be great if someone could translate that into how to do it in GE. I spent a couple of hours messing around in the data editor but still can't figure out how to attach models to each other and make them be able to attack.

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