HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Custom Spell Conditions and Order to Stop

12-30-2007, 09:17 PM#1
EnderA
I have a spell used by a building that has custom conditions which I would like to check before it casts. Currently the two triggers (in GUI) are:

Trigger:
Collapse Events
Unit - A unit Begins casting an ability
Collapse Conditions
(Ability being cast) Equal to <My spell>
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Owner of (Triggering unit)) Current lumber) Greater than or equal to <lumber cost>
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Owner of (Target unit of ability being cast)) Equal to <Correct owner>
Then - Actions
Collapse Else - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: <Wrong owner error message>
Unit - Pause (Triggering unit)
Unit - Order (Triggering unit) to Stop
Unit - Unpause (Triggering unit)
Collapse Else - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: <Lacking lumber error message>
Unit - Pause (Triggering unit)
Unit - Order (Triggering unit) to Stop
Unit - Unpause (Triggering unit)

Trigger:
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to <My spell>
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Owner of (Triggering unit)) Current lumber) Greater than or equal to <lumber cost>
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Owner of (Target unit of ability being cast)) Equal to <Correct owner>
Collapse Then - Actions
<SPELL CODE>
Collapse Else - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: <Wrong owner error message>
Unit - Order (Triggering unit) to Stop
Collapse Else - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: <Lacking lumber error message>
Unit - Order (Triggering unit) to Stop

Now, besides the fact that they are both ugly, they don't work as expected. Specifically, the "begins casting the ability" trigger doesn't actually stop the building from casting the spell - I get two error messages (one from each trigger) instead of one if I cast it on a wrong owned unit, and it uses the cooldown. I originally had it simply order it to stop, but that didn't work so I looked around and I heard that I needed to pause the unit first, then unpause after ordering it to stop.

Anyways, my question is: How am I supposed to order a building to stop casting an ability before it casts the ability? Are buildings different from "normal" units, in that a stop order doesn't work? Should I use a timer instead of pause/unpause? If so, what's the best method to use a timer using GUI?
12-30-2007, 10:07 PM#2
Burning Rose
You may want to put the Event as it receiving the Order to use the ability. Since most abilities will give you an error message when you try to issue the wrong order anyways, not when they try to cast it, it would make sense. I used this for another ability that was giving me issues with ordering it to stop on cast, So I changed it to tell him to stop when the order is given. Then you just have another Trigger for the actual spell. As long as it isn't Auto-cast or you're not trying to make the Computer use it (Which may still work, I have no Idea how most AIs work), it won't cast the spell without the order, so it should do fine.
12-31-2007, 08:57 AM#3
Pyrogasm
The error may be with the second If/then/else statement. I think Warcraft has a problem with not having any "If" actions. Try switching the conditions to this:
Trigger:
If - Conditions
(Owner of (Target unit of ability being cast)) Not Equal to <Correct owner>
And then moving the "else" actions to the "then".
12-31-2007, 09:29 AM#4
Iron_Doors
My guess is that the problem is that buildings dont usually have the "stop" ability. Other way to stop the casting is to remove the ability and then give it back to the unit. http://www.wc3jass.com/viewtopic.php?t=82
12-31-2007, 05:11 PM#5
Burning Rose
Quote:
Originally Posted by Iron_Doors
My guess is that the problem is that buildings dont usually have the "stop" ability. Other way to stop the casting is to remove the ability and then give it back to the unit. http://www.wc3jass.com/viewtopic.php?t=82


Actually, All units have the stop ability, some just don't show it (If they can't attack or move). Easy way to show it is to add a Blizzard ability with no mana cost to a building that doesn't show it's stop ability (I.E. Barracks, War Mill, Any Altar, etc.). Then have a trigger like this:
Trigger:
Test
Collapse Events
Player - Player 1 (Red) types a chat message containing Stop as An exact match
Conditions
Collapse Actions
Unit - Order <Test Building> to Stop
If you order it to start blizzarding, and then set off the trigger in the middle of the spell, it will stop.
12-31-2007, 05:15 PM#6
TaintedReality
Burning Rose's first response would be the right way to go about this - detect when the order is issued, then issue the stop order. You still might have to Pause/Unpause first (I forget), but I've used this method before and it works correctly.

Quote:
Originally Posted by Burning Rose
You may want to put the Event as it receiving the Order to use the ability. Since most abilities will give you an error message when you try to issue the wrong order anyways, not when they try to cast it, it would make sense. I used this for another ability that was giving me issues with ordering it to stop on cast, So I changed it to tell him to stop when the order is given. Then you just have another Trigger for the actual spell. As long as it isn't Auto-cast or you're not trying to make the Computer use it (Which may still work, I have no Idea how most AIs work), it won't cast the spell without the order, so it should do fine.