I need to implement a way to order a structure to train a specified type of unit without selecting the structure; ideally, the player never unselects his or her hero unit, and is able to issue the order to train either from the hero's own command card or from a custom-built UI dialogue with buttons and labels.
I can do the latter through triggers, but I'm more interested in the former approach. I think one way I might be able to do it is to give the hero unit a specific ability for each unit that can be trained, that applies a mapwide search effect for the training structure and then puts an appropriate Issue Order effect on the found structure. Is this an efficient approach, or is there a better way to do this? I haven't actually tried implementing this yet, so I don't even know if it's possible, but I'd be interested in hearing any other ideas how to do this.
Use a Specialize ability that uses an array of Search Area effects that use an Issue Order with the correct Ability - Ability Command integer.
An alternative is to have the structure use a periodic effect from a Buff that uses a Set effect which uses the Issue Order effects. Each Issue Order is validated by an Enumerate Area validator that looks for units of the player with a counter buff. Your hero then has a Specialize ability that uses Apply Behavior effects to apply the counter buffs which have a short duration.
Or the command building does one global search that puts a buff on the hero (with the command center known as the caster of it) which is disabled unless the hero has a counter buff in which case it activates and uses a periodic set which removes the appropriate counter buff and uses an issue order.
Thanks, got it working through your first suggestion, this is much cleaner than doing it through triggers!
Is there a way to craft a Requirement such that it prevents the hero from using the specialize skill if the player doesn't have enough supply? I realize I can block the actual train command on the structure through a supply check but I'm pretty sure the specialize command will still deduct the mineral cost of training in that case.
edit: to clarify, the player does not actually own the structure the order is being issued to, nor the unit produced, so the built-in supply check doesn't really apply to the specialize command.
I guess I should be completely transparent as to the nature of the problem, as I haven't been accurate in describing it.
Basically, I have a computer-controlled structure that trains units, which are then loaded into its cargo through an Issue Order effect on unit completion. The Train Unit ability for the structure has a Requirement that the unit has no more than 2 units Queued or Better at the unit; thus, it can hold up to 2 units in its cargo, and once this is true the train unit buttons are greyed out until the structure unloads at least 1 of the units. This all works fine, but the problem is with the specialize command.
The hero unit I was describing has a specialize ability as you described; it has a command for each of the units the structure can train, and the effect associated with each command is a Search Area effect that finds the allied nearest training structure and issues an order to train a unit. This works appropriately as well, but the problem is that the train unit command buttons can still be pressed when the training structure has a full cargo, which, while not training another unit, will still deduct the resources associated with the specialize command from the player. I'd like to make some sort of Requirement for each command that works similarly to the structure's Requirement so that the button is greyed out on the hero unit as well, but I'm not sure how to do this.
I've thought about creating a buff on each structure that has a periodic Search Area effect that is validated similarly to the Requirement for the structure. The buff would look for the hero unit and applies a brief buff that can be examined through a Requirement, thus allowing the buttons to be greyed out. The problem I see with this approach is that it'd need to search the entire map extremely frequently to create the quickest response for when the hero is allowed to issue another train unit order, and that doesn't strike me as the most efficient way to do things.
Should I just bite the bullet and try that approach, or is there anything else I can do? What I'd really like to do is just be able to make a Requirement for the specialize commands that checks if the found structure meets its own Requirement, but I don't see a way to do this.
Hmm in that case you will need some kind of feedback mechanism for button use via a Unit Compare Cargo validator or a refund mechanism done with a Switch effect. The Unit Compare Order Queue validator can perform some of the functions of that requirement fo yours (the queued part). Get your Search Area effect to apply a Set effect, you can then use the effect field above the values field to specify that unit for alot of validations as the target of that set effect. All you need is the set to apply a buff back to the caster that the validated unit does not have 2 ordered, 1 build and one ordered or two built which requirements on the Specialize ability use.
Thanks to your help, I've got it almost entirely working!
This is the design I used:
The Training Structure has a constant Buff behavior called Stop Build Orders, which has a disable Validator that only enables the behavior when there's at least 1 slot free in the cargo. Every 0.05 seconds, this behavior has a periodic effect Search for Hero and Suppress, which searches a range of 500 for units matching the hero's traits and applies the effect Apply Build Order Suppression.
The Hero Unit receives this effect, which in turn gives it the Buff behavior Can't Issue Build Orders, which has a duration of 0.04 seconds. This behavior's stack count is examined by the requirement Can Issue Build Orders, which checks to see if the stack count is 0. The unit's aforementioned specialize ability now checks this requirement for each train command, and successfully disables commands if it's not met.
Fantastic! The only real problem left is that I need a much more sophisticated Validator tree to deal with the cases of unit queues, which are: one unit in cargo and one queued, or two units queued. I looked at the Unit Compare Order Count and Unit Order Queue types but they both require a specific unit type for validation, which makes me think I'm going to need to make two Validators for every unit that can be trained to deal with all cases. While I admittedly don't have very many units and this could be done through some braindead copypasting, it'd probably result in a huge Validator tree at the end of the day and I don't want to waste too much processor time on it, especially considering this check is made every 0.05 seconds by at least two structures on the map. Am I worrying too much about the perceived inefficiency here, or should I look into other ways of validating training queues?
Some fields if you leave blank or have -1 it checks all values. Else have the mother of all combine validators.
Also you do not need a search 25x per second when 2 is more than enough, also you can reduce demand by having it default to disabled unless told otherwise so at the start it finds your hero and applies a buff as a once off that is disabled unless told otherwise which then sends the second buff back to the caster which is disabled unless otherwise. This will allow all the feedback you need in that the buff applied to the hero can validate the caster via the effect field and the one applied to the caster acts as a redundancy to prevent bugging. This will prevent the need for a constant global search effect 25x per second (laggy).
In the case of unit death you can always apply a death response to reset the system.
I was able to have it validate generic queued units by leaving it blank. With that, I'll consider the problem solved, unless I need to optimize it further to speed up the map. Things are pretty smooth right now, though, so I'll leave it at this. Thanks!
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hello again!
I need to implement a way to order a structure to train a specified type of unit without selecting the structure; ideally, the player never unselects his or her hero unit, and is able to issue the order to train either from the hero's own command card or from a custom-built UI dialogue with buttons and labels.
I can do the latter through triggers, but I'm more interested in the former approach. I think one way I might be able to do it is to give the hero unit a specific ability for each unit that can be trained, that applies a mapwide search effect for the training structure and then puts an appropriate Issue Order effect on the found structure. Is this an efficient approach, or is there a better way to do this? I haven't actually tried implementing this yet, so I don't even know if it's possible, but I'd be interested in hearing any other ideas how to do this.
Use a Specialize ability that uses an array of Search Area effects that use an Issue Order with the correct Ability - Ability Command integer.
An alternative is to have the structure use a periodic effect from a Buff that uses a Set effect which uses the Issue Order effects. Each Issue Order is validated by an Enumerate Area validator that looks for units of the player with a counter buff. Your hero then has a Specialize ability that uses Apply Behavior effects to apply the counter buffs which have a short duration.
Or the command building does one global search that puts a buff on the hero (with the command center known as the caster of it) which is disabled unless the hero has a counter buff in which case it activates and uses a periodic set which removes the appropriate counter buff and uses an issue order.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
Thanks, got it working through your first suggestion, this is much cleaner than doing it through triggers!
Is there a way to craft a Requirement such that it prevents the hero from using the specialize skill if the player doesn't have enough supply? I realize I can block the actual train command on the structure through a supply check but I'm pretty sure the specialize command will still deduct the mineral cost of training in that case.
edit: to clarify, the player does not actually own the structure the order is being issued to, nor the unit produced, so the built-in supply check doesn't really apply to the specialize command.
Just have a refund system using the Player Food Available validator and a Modify Player effect.
Or to be more complex if there will not be enough supply for a further unit it adds a buff back to the hero unit that requirements look for.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
I guess I should be completely transparent as to the nature of the problem, as I haven't been accurate in describing it.
Basically, I have a computer-controlled structure that trains units, which are then loaded into its cargo through an Issue Order effect on unit completion. The Train Unit ability for the structure has a Requirement that the unit has no more than 2 units Queued or Better at the unit; thus, it can hold up to 2 units in its cargo, and once this is true the train unit buttons are greyed out until the structure unloads at least 1 of the units. This all works fine, but the problem is with the specialize command.
The hero unit I was describing has a specialize ability as you described; it has a command for each of the units the structure can train, and the effect associated with each command is a Search Area effect that finds the allied nearest training structure and issues an order to train a unit. This works appropriately as well, but the problem is that the train unit command buttons can still be pressed when the training structure has a full cargo, which, while not training another unit, will still deduct the resources associated with the specialize command from the player. I'd like to make some sort of Requirement for each command that works similarly to the structure's Requirement so that the button is greyed out on the hero unit as well, but I'm not sure how to do this.
I've thought about creating a buff on each structure that has a periodic Search Area effect that is validated similarly to the Requirement for the structure. The buff would look for the hero unit and applies a brief buff that can be examined through a Requirement, thus allowing the buttons to be greyed out. The problem I see with this approach is that it'd need to search the entire map extremely frequently to create the quickest response for when the hero is allowed to issue another train unit order, and that doesn't strike me as the most efficient way to do things.
Should I just bite the bullet and try that approach, or is there anything else I can do? What I'd really like to do is just be able to make a Requirement for the specialize commands that checks if the found structure meets its own Requirement, but I don't see a way to do this.
Hmm in that case you will need some kind of feedback mechanism for button use via a Unit Compare Cargo validator or a refund mechanism done with a Switch effect. The Unit Compare Order Queue validator can perform some of the functions of that requirement fo yours (the queued part). Get your Search Area effect to apply a Set effect, you can then use the effect field above the values field to specify that unit for alot of validations as the target of that set effect. All you need is the set to apply a buff back to the caster that the validated unit does not have 2 ordered, 1 build and one ordered or two built which requirements on the Specialize ability use.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
Thanks to your help, I've got it almost entirely working!
This is the design I used:
The Training Structure has a constant Buff behavior called Stop Build Orders, which has a disable Validator that only enables the behavior when there's at least 1 slot free in the cargo. Every 0.05 seconds, this behavior has a periodic effect Search for Hero and Suppress, which searches a range of 500 for units matching the hero's traits and applies the effect Apply Build Order Suppression.
The Hero Unit receives this effect, which in turn gives it the Buff behavior Can't Issue Build Orders, which has a duration of 0.04 seconds. This behavior's stack count is examined by the requirement Can Issue Build Orders, which checks to see if the stack count is 0. The unit's aforementioned specialize ability now checks this requirement for each train command, and successfully disables commands if it's not met.
Fantastic! The only real problem left is that I need a much more sophisticated Validator tree to deal with the cases of unit queues, which are: one unit in cargo and one queued, or two units queued. I looked at the Unit Compare Order Count and Unit Order Queue types but they both require a specific unit type for validation, which makes me think I'm going to need to make two Validators for every unit that can be trained to deal with all cases. While I admittedly don't have very many units and this could be done through some braindead copypasting, it'd probably result in a huge Validator tree at the end of the day and I don't want to waste too much processor time on it, especially considering this check is made every 0.05 seconds by at least two structures on the map. Am I worrying too much about the perceived inefficiency here, or should I look into other ways of validating training queues?
Some fields if you leave blank or have -1 it checks all values. Else have the mother of all combine validators.
Also you do not need a search 25x per second when 2 is more than enough, also you can reduce demand by having it default to disabled unless told otherwise so at the start it finds your hero and applies a buff as a once off that is disabled unless told otherwise which then sends the second buff back to the caster which is disabled unless otherwise. This will allow all the feedback you need in that the buff applied to the hero can validate the caster via the effect field and the one applied to the caster acts as a redundancy to prevent bugging. This will prevent the need for a constant global search effect 25x per second (laggy).
In the case of unit death you can always apply a death response to reset the system.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
I was able to have it validate generic queued units by leaving it blank. With that, I'll consider the problem solved, unless I need to optimize it further to speed up the map. Things are pretty smooth right now, though, so I'll leave it at this. Thanks!