| 09-02-2002, 08:56 PM | #1 |
Guest | I want to be able to change a unit's attack range with triggers. Example below: Event(s): Unit enters region Condition(s): (none) Action(s): ??? What is the action to set a unit's attack range. Like change it from the default. I looked but I couldn't find it... I'm not sure if it is possible. |
| 09-02-2002, 09:01 PM | #2 |
Guest | well currenty there is no way.only way u can do this is by replacing unit:( |
| 09-02-2002, 10:50 PM | #3 |
You can try this - I've gotten it to work most of the time, but some units are too fast for the ^&*$ triggers: first, create a unit whose range is the *maximum* value you're looking for. Next, you need to create a range variable that's initialized at the start for each unit you want this trick to apply to. Finally, do the following: event - [unit attacks another unit] action 1) set variable x to the distance between attaker and target. 2) if distance is greater than [whatever lesser range you'd like it to be] order unit to stop else enable the attack. Only problem is that some units get their attack away before the trigger has a chance to run. Play around with it - this setup may be perfect for you, it may not be. Let me know if you have any questions about what I said. |
| 09-03-2002, 03:33 AM | #4 | |
Guest | Quote:
The problem is I want it so that the units range increases so they can shoot longer range when in that place, then when they leave their range goes back to default. I don't think the thing you said above would work. |
| 09-03-2002, 04:30 AM | #5 |
Depending on what exactly you're trying to do and how you're trying to do it, it could still work (with the original caveat, of course). Imagine you want a unit with a range of 1000 to have a range of 1500 in a particular region (quick aside, btw, are you creating a hill?). Go into the unit editor and give your archer (say) a range (and acquistion range) of 1500. Now have the following trigger: event - archer is given order targeting unit condition - order = "smart" or "attack" actions: if archer is in region [hill] then do nothing else if distance between archer and [target unit of issued order] > 1000 then run trigger "stop attack" stop attack: order archer to stop text display - unit is out of range and if you want to be nice: order archer to move towards target and if you want to be super nice: for a = 1 to 10 if distance between target and archer < 1000 then attack, else wait .5 seconds. not the prettiest thing in the world, I'll grant you, but it's the only way I can immediately think of besides replacing the unit with a longer ranged one when on the hill (which would also probably work, maybe even better than this). To be sure though, I'm designing a turn based game, where the unit in question never thinks for itself or acts without user approval. If you're pictuing something melee style, each unit would *always* try to attack at the edge of it's maximum range, and I have no idea how that would work. Worse, units would be too stupid to climb the hill to attack from even if they could retreat to hit a target otherwise out of range (though that's true no matter how you solve this problem on a melee map). In theory, it is possible though. |
| 09-03-2002, 05:03 AM | #6 |
Hmmmm, just realized that you can set acquisition range with triggers. In the example I have above (1000 range on ground, 1500 in the region) you can use the unit editor to set acquisition range of the archer to 1000 and the *range* to 1500 and then have the following two events: event - archer enters region action - set acquisition range of archer to 1500 event - archer leaves region action - set acquisition range of archer to 1000 if many different units are being used, you need an array of original acquisition ranges for each one so the trigger can reset the right one. In terms of behavior, no matter what the range of a unit it will only fire from within its acquisition range (witness the number of posts on the board asking why a unit with 10000 range isn't firing properly), so even a 1500 range unit will function like a 1000 range unit if its acquisition range is 1000. I think this is a waaaaaay better way to try implementing this than what I mentioned above. |
