- Joined
- Dec 3, 2020
- Messages
- 971
As stated, is there a way to prevent workers from being targeted while repairing a unit or structure by the enemy AI?
Addng the suicidal tag doesn't work, they still get targeted but thank you so much!Since that target acquisition is usually passive, you would probably have to use the event specific unit acquires a target which would be annoying.
You could use a damage detection system to prevent attacks made against workers while repairing. Whenever such an attack is prevented or a unit is ordered to attack a worker that is repairing, order the attacker to either Stop or Attack something else directly.
Could make the workers invulnerable while repairing, but that has other gameplay implications for abuse.
The other solution I see is that maybe giving the worker units the Suicidal tag would cause them to be ignored, as the AI usually doesn’t attack units with that tag. I frankly cannot remember if adding tags dynamically is possible, so they might have to be flagged that way all the time even when not building.
In WC3 the AI doesn't attack your siege units if the siege units are attacking their buildings on Easy or Normal, but as far as my knowledge goes, this doesn't affect workers.Isn't worker targeting related to difficulty? I know it's the case in SC2, can't tell about WC3, although unless it's a campaign I don't think there's a way to change that in custom games
Thanks but the map where I need is basically a horizontal line where allied units attack enemy units to the death and giving invulnerability to the workers seems kind of brokenI think there are multiple things to consider. One workaround that I know of is used in maze-like TDs where "dumb" walls are given an 1-1 attack to force enemy units to attack and tear down walls rather than following a maze.
In your case if a building doesn't have an attack to trigger aggro, I think melee units will be prioritized (over buildings).
Another thing to consider is unit priority is afaik determined by their point value: Doc - GetUnitPointValue but it's possible other conditions are taken into consideration first. See if vastly different point values matter, because if yes, try to modify each unit's value at runtime using the Field natives (repair = low value, stopped repairing = high value).
Honestly idk what else to suggest. Redirecting orders is tricky and explotable like Pyro said. I'm not even sure if rewriting AI scripts will give you the flexibility, because a lot of functions are hardcoded for convenience.
What about a temporary invulnerability on workers with a really long cooldown, triggered by triggers? Just for the purpose of cancelling the current attack-targetting once per worker.
Click to expand...
Yeah! Resources won't matter since AI with infinite gold and lumber is using the workers to repair their stuff.Just a note, the repair speed is tied to a separate property in repair target's unit editor definition; it's not a flat HP/sec. The repair's resource cost can be easily emulated with triggers though.
As long as it doesn't repair/heal too fast I'm fineYeah it'll be hard to reproduce exactly the behavior of proper repair (although I suppose you could also trigger the HP restored but that's a bit much maybe), still at least the AI would leave your peasants alone ^^