| 10-23-2004, 04:00 PM | #1 |
How can you prevent a unit from casting an ability, unless he is actually in range to do it. What I mean, is, to not allow him to move in range to cast it. If there was a way to get the range of an ability, I could just compare it to the range of the target, but, as it is, there is not. |
| 10-23-2004, 09:23 PM | #2 |
Well, if it is only a point ability such as flamestrike, create a trigger that has a unit issued order targetting a point. Have the conditions be an order comparison, let's say, order equal to order(flamestrike), and Real - Distance between triggering unit and target point of ability being cast is greater than (the cast range of your custom ability) then actions, order triggering unit to stop. In other words, if the issued range is longer than the max casting range of the spell, the unit will stop itself from casting, thus keeping a unit from moving to meet the range's requirements. |
| 10-23-2004, 10:15 PM | #3 |
I was looking for a solution that wouldnt require hardcoding the distance. That's a real pain in the ass to update, especially when different levels have different ranges. |
| 10-24-2004, 05:00 AM | #4 |
If you're talking about preventing a unit from actually moving into range to cast his spell, then you have to hardcode that. If you want to be able to say, fire a range 1000 shockwave from only 200 range, then set the cast range of the spell to 200. |
| 10-24-2004, 05:27 AM | #5 |
Guest | Here's just an example I made up. I just made this to help you, and maybe give you ideas. Code:
Begin cast
Events
Unit - Priest 0000 <gen> Begins casting an ability
Conditions
(Ability being cast) Equal to Acid Bomb
Actions
Trigger - Turn on Finish notify <gen>
Wait 0.20 seconds
Trigger - Turn off Finish notify <gen>
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
castrange_didcast[(Player number of (Owner of (Casting unit)))] Equal to True
Then - Actions
-------- He was close enough to cast it. --------
Game - Display to (All players matching ((Matching player) Equal to (Owner of (Casting unit)))) the text: I was close enough ...
Else - Actions
-------- He was too far, still hasn't cast it. --------
Unit - Order (Casting unit) to Move To ((Position of (Casting unit)) offset by 1.00 towards (Facing of (Casting unit)) degrees)
Game - Display to (All players matching ((Matching player) Equal to (Owner of (Casting unit)))) the text: I was too far away.Code:
Finish notify
Events
Unit - Priest 0000 <gen> Finishes casting an ability
Conditions
(Ability being cast) Equal to Acid Bomb
Actions
Set castrange_didcast[(Player number of (Owner of (Casting unit)))] = TrueP.S. I just discovered how to copy whole triggers! ^_^ |
| 10-24-2004, 12:40 PM | #6 |
Thanks, Alchoholic, I'll probally use something similar to that; with a few modificatioins. Rep'd. [edit] The bloody rep window wont open, sorry. :\ |
| 10-24-2004, 06:13 PM | #7 | |
Quote:
Your first trigger must have "is issued an order" type event, not a "begins casting" event. With the event you have now, the first trigger will only run once the unit already comes into range. |
| 10-24-2004, 07:50 PM | #8 |
Guest | Oh yeah that's right, to begin casting the ability you have to already be in range. :o Well it should give a general idea of what I'm going at. ;) |
