I'm currently working on a building capture custom game, where you get to capture neutral buildings by having units stand near them, pretty much in the fashion of Xel'Naga towers. I used the behaviours and effects found in this map, which work like a charm. The only issue I'm having is that whenever the ownership of a building changes, its production queue gets reset, which is unwanted since stealing your opponent's production facilities at the last second, so that the unit produced is yours, is supposed to be a key feature.
My initial approach was to use the Xel'Naga tower's Tower Capture ability, with Share control enabled, but the problem here is that since buildings remain neutral, they spawn only neutral units. So my question is: is there a way to prevent a production facility's queue from getting reset when said building changes owners? Preferably without triggers to keep it all as dynamical as possible.
Also, while I'm there, I would like the game to issue an alert every time a building is captured/lost. I was able to create alerts for other stuff so I'm confident I know how to handle this part, however I couldn't get it to trigger wherever i would put it in the data editor (my best guess was on the 1test apply ownership effect, but to no avail). Again, do I have to resort to triggers to achieve this, or am I missing something in the edtior?
Trigger the entire capture system in a generic way. Before changing ownership with the trigger you store in a local the current progress. After ownership change you re-issue the train order and then advance its progress to what it was before ownership change. Without any form of correction this might lose 1-2 frames of productivity (1/8 of a game second, 1 frame to re-order and 1 frame to restore progress) which is acceptable seeing how it just changed ownership (a big event as far as game progress).
Do not be afraid to use triggers. They might be slower than data for some tasks however if you use them intelligently and for very specific purposes they give you great flexibility as well at acceptable performance.
I'm not. It's just that, if I understand correctly how triggers work, they lack the dynamism of the data editor approach. I would like to just lay my buildings on the map and have it all work with embedded behaviors, not being forced to manually include each and every building in the trigger's code, if I can help it. Now if there's no other way...
From my limited understanding triggers can be "dynamic", but this will usually be synonymous to "inefficient" because it will involve looping over all generic cases and then checking a condition, where data is bottom-up. You could try a dummy data setup to start up your trigger though:
unit receives ownership aura buff
check current owner
give ownership of "target unit" to player "owner of Caster Unit"
No idea how that would look in actual triggers, but you should be able to grab the scope of a dummy buff/effect somehow, and that's all you need to define the owner.
That said, have you tried messing with the Flags and "Link" options on the Train ability? Sadly neither Train nor Queue abilities seem to have the "abort on ownership change" flag...
There are also many (fairly work-intensive) workarounds if you don't need the build queue UI, using some combination of buffs to handle build time and ownership.
From my limited understanding triggers can be "dynamic", but this will usually be synonymous to "inefficient" because it will involve looping over all generic cases and then checking a condition, where data is bottom-up. You could try a dummy data setup to start up your trigger though:
unit receives ownership aura buff
check current owner
give ownership of "target unit" to player "owner of Caster Unit"
No idea how that would look in actual triggers, but you should be able to grab the scope of a dummy buff/effect somehow, and that's all you need to define the owner.
Thanks for the tip I'm going to try something out.
That said, have you tried messing with the Flags and "Link" options on the Train ability? Sadly neither Train nor Queue abilities seem to have the "abort on ownership change" flag...
I've tried to tweak every option I could think of, including flags. I did not mess with the link option but if I understand correctly I would not want to change it.
There are also many (fairly work-intensive) workarounds if you don't need the build queue UI, using some combination of buffs to handle build time and ownership.
I would be interested to know more about such workarounds if you don't mind. Indeed I don't need the build queue UI, however I would want the player to be able to change a building's production type.
I would be interested to know more about such workarounds if you don't mind. Indeed I don't need the build queue UI, however I would want the player to be able to change a building's production type.
Yeah, that's the work-intensive bit. For a very straightforward (but probably inefficient) setup, consider this:
"train" ability applies a buff to the structure upon completion instead of creating a unit
Units have an aura that applies to capturable structures, max 1 stack to prevent implicit multi-owner use. The on-structure buff pulses or checks BehaviorCount, activating if any of the "unit built" buffs is present (here you need a list of all trainable units, each with a unique dummy buff)
Upon activation, use a Create Unit effect to summon the "trained" unit. Since the owner of the effect chain is the unit that captured the structure you can use that as the owner reference.
For pulse-free activation you can try the Effect: Final field on the aura buff, use a validator to check for presence of a "unit completed" buff (Effect: Final also activates on expiration and structure death, amongst other things), and then remove the "unit completed" buff after the Create Unit went through.
There are many other ways though, you could probably also do Ability:Effect-Instant(cast time/delay=build time) -> Search (for capturing units) -> CreateUnit(Owner=Target of Search), which may cause less periodic checks but heavily relies on the effectiveness of the search at the instant of "unit completion", which may or may not be a problem. Depends on how many AoEs and teleports are being thrown around I guess.
I'm not. It's just that, if I understand correctly how triggers work, they lack the dynamism of the data editor approach. I would like to just lay my buildings on the map and have it all work with embedded behaviors, not being forced to manually include each and every building in the trigger's code, if I can help it. Now if there's no other way...
You use the same system for all buildings like I said, no need to include them individually (that is just kind of stupid...). You can either program up a data fed system and feed into it all buildings or you can call a function per building to set it up. Both approaches use a loop through all appropriate units which could even be a hard-coded group at map initialization.
Quote:
From my limited understanding triggers can be "dynamic", but this will usually be synonymous to "inefficient" because it will involve looping over all generic cases and then checking a condition, where data is bottom-up.
Which is why you use specific events when appropriate.
When I implemented a capture system I used a trigger enhanced effect to do the ownership change. That is when you would store the current progress and reconstruct it with the new unit.
Ok so I've had some success with manging ownership change with triggers. I can currently have a specific unit capture buildings, but how do I extend this to all units? I'm using the Any Unit enters a distance of X from... event. Sadly, I can't seem to be able to select Any Unit for the second part of the formula. I thought I would be able to find something like "all units controlled by player X" or something.
I'm currently working on a building capture custom game, where you get to capture neutral buildings by having units stand near them, pretty much in the fashion of Xel'Naga towers. I used the behaviours and effects found in this map, which work like a charm. The only issue I'm having is that whenever the ownership of a building changes, its production queue gets reset, which is unwanted since stealing your opponent's production facilities at the last second, so that the unit produced is yours, is supposed to be a key feature.
My initial approach was to use the Xel'Naga tower's Tower Capture ability, with Share control enabled, but the problem here is that since buildings remain neutral, they spawn only neutral units. So my question is: is there a way to prevent a production facility's queue from getting reset when said building changes owners? Preferably without triggers to keep it all as dynamical as possible.
Also, while I'm there, I would like the game to issue an alert every time a building is captured/lost. I was able to create alerts for other stuff so I'm confident I know how to handle this part, however I couldn't get it to trigger wherever i would put it in the data editor (my best guess was on the 1test apply ownership effect, but to no avail). Again, do I have to resort to triggers to achieve this, or am I missing something in the edtior?
Thanks in advance for your help. :)
Not a single clue?
Trigger the entire capture system in a generic way. Before changing ownership with the trigger you store in a local the current progress. After ownership change you re-issue the train order and then advance its progress to what it was before ownership change. Without any form of correction this might lose 1-2 frames of productivity (1/8 of a game second, 1 frame to re-order and 1 frame to restore progress) which is acceptable seeing how it just changed ownership (a big event as far as game progress).
Do not be afraid to use triggers. They might be slower than data for some tasks however if you use them intelligently and for very specific purposes they give you great flexibility as well at acceptable performance.
I'm not. It's just that, if I understand correctly how triggers work, they lack the dynamism of the data editor approach. I would like to just lay my buildings on the map and have it all work with embedded behaviors, not being forced to manually include each and every building in the trigger's code, if I can help it. Now if there's no other way...
From my limited understanding triggers can be "dynamic", but this will usually be synonymous to "inefficient" because it will involve looping over all generic cases and then checking a condition, where data is bottom-up. You could try a dummy data setup to start up your trigger though:
No idea how that would look in actual triggers, but you should be able to grab the scope of a dummy buff/effect somehow, and that's all you need to define the owner.
That said, have you tried messing with the Flags and "Link" options on the Train ability? Sadly neither Train nor Queue abilities seem to have the "abort on ownership change" flag...
There are also many (fairly work-intensive) workarounds if you don't need the build queue UI, using some combination of buffs to handle build time and ownership.
Thanks for the tip I'm going to try something out.
I've tried to tweak every option I could think of, including flags. I did not mess with the link option but if I understand correctly I would not want to change it.
I would be interested to know more about such workarounds if you don't mind. Indeed I don't need the build queue UI, however I would want the player to be able to change a building's production type.
Yeah, that's the work-intensive bit. For a very straightforward (but probably inefficient) setup, consider this:
There are many other ways though, you could probably also do Ability:Effect-Instant(cast time/delay=build time) -> Search (for capturing units) -> CreateUnit(Owner=Target of Search), which may cause less periodic checks but heavily relies on the effectiveness of the search at the instant of "unit completion", which may or may not be a problem. Depends on how many AoEs and teleports are being thrown around I guess.
You use the same system for all buildings like I said, no need to include them individually (that is just kind of stupid...). You can either program up a data fed system and feed into it all buildings or you can call a function per building to set it up. Both approaches use a loop through all appropriate units which could even be a hard-coded group at map initialization.
Which is why you use specific events when appropriate.
When I implemented a capture system I used a trigger enhanced effect to do the ownership change. That is when you would store the current progress and reconstruct it with the new unit.
Ok so I've had some success with manging ownership change with triggers. I can currently have a specific unit capture buildings, but how do I extend this to all units? I'm using the Any Unit enters a distance of X from... event. Sadly, I can't seem to be able to select Any Unit for the second part of the formula. I thought I would be able to find something like "all units controlled by player X" or something.