• 0

    posted a message on Critter spawning

    Assign all units spawned at each point to a unit group (add them to the group). Before spawning new units, check if there is space in the unit group (number of living units in unit group < X where X is the number of units you want). This why no more than X can exist at a time.

    You may need to flush dead units from the groups from time to time, I am uncertain if SC2 does this automatically and if not it could possibly be a leak of sorts.

    You could also assign an integer to each spawn point to buffer "over spawns" so that you can spawn them at a later time if you wanted but that could change the dynamics of your game.

    Ultimately making it some form of data driven system would be great. That way all spawns could be run from the same triggers and new spawns or spawn removal would be as easy as setting some variables. One approach for such a system would be an array of structs (forget what they are called in GUI) which each index represents a spawner. You set all indicies up at map initialization and then periodically check through each one spawning when appropriate. To spawn all you need is a location (where the spawn is), a group (the number of currently alive spawns) and possibly an integer (how many ticks until spawn) and another integer (how many ticks until respawn, the period). For over spawn support you would need an integer (how many spawns could not be spawned but wanted to).

    Posted in: Triggers
  • 0

    posted a message on Unit Orders Trigger

    The teleport effect does the actual moving. You can trigger enhance it to obtain what you want.

    A trigger responding to an effect event can fetch various units and points similar to how the data editor does. Using these it can resolve certain units such as the origin or target (if TriggeringUnit is not sufficient). Once you have the unit that was teleported you can order it to do whatever you want.

    You could order it back to the nearest lane waypoint using a minimum search. You could order it back to it's last waypoint by keeping track of its progress unit custom values (assign each lane node a unique identifier so you can always tell where it has to go next). The choice is really yours to make how you want it to resume orders.

    Of note would be that the unit may have paused after the effect is run for a few seconds so orders are lost. In that case make the trigger thread wait a number of frames (such as a second or two) until it is unpaused and then issue the order. If you assign all values needed to locals at the time of effect fire then there is no chance they will be lost by the wait (although I think SC2 preserves those values much better than WC3). Never be afraid to Wait in trigger threads as SC2 waits are precise to 1 deterministic frame (there are 16 frames per second) which is the smallest resolvable deterministic time used by everything.

    This approach is a lot more efficient than the above suggested polling approach. However if you want to use that rather I would suggest you stagger it just in case a large number of units some how manage to exist so that it does not consume enough resources to drop frames or cause a thread crash due to hitting the operation limit. Staggering would be done using some kind of swap group approach.

    Posted in: Triggers
  • 0

    posted a message on create units for a region to other region

    Your trigger does not make any sense for the reason I mentioned before. You never attach any regions to any units so trying to get the unit a region is attached to will always return null. I think you misunderstood the mechanics of the function.

    I do not understand clearly what you want done but I tried to make a trigger that seemed logical and could be what you want. When the unit enters the big region I look for which sub-region it is in. Units appear to spawn in a reasonable way but I am not sure if that is intended.

    Posted in: Galaxy Scripting
  • 0

    posted a message on create units for a region to other region

    You might need to post more of your triggers, such as the triggers responsible for attaching units to regions. RegionGetAttachUnit will only return a unit if you attach the region to one using the following native.

    native void RegionAttachToUnit (region r, unit u, point offset);
    

    Without attaching a unit to the region it will likely return null. Getting the unit type of null might return a null string. This would explain why it either evaluates true for all regions or no regions.

    If the Bmarine is stationary you could attach the appropriate region to it. Then the trigger may work.

    Otherwise those natives might not be what you are after using.

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