| 08-08-2007, 11:12 AM | #1 |
Which is, in your opinion, the best way to emulate a spell-interface-error? For instance, if you try to cast heal on a unit with full health, it will not even activate, but response with a "Must target damaged units" (or similar). I know that these messages can be produced with Vex's CS_Error function (which is quite accurate). However, how can I make the unit not cast the spell at all (or at least prevent its cooldown from restarting)? |
| 08-08-2007, 11:27 AM | #2 |
Prevent cooldown from restarting? Elaborate please. On the other note, if I am getting it correctly you should do this... JASS:function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing local unit u = GetTriggerUnit() if <Your Condition> then call IssueImmediateOrder(u, "stop") call CS_Error("You can't target that unit dipshit!") endif endfunction //=========================================================================== function InitTrig_Untitled_Trigger_001 takes nothing returns nothing set gg_trg_Untitled_Trigger_001 = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_SPELL_CAST ) call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions ) endfunction Event is A unit Begins Casting an Ability not Starts the Effect of the Ability |
| 08-08-2007, 12:06 PM | #3 |
Yeah, you're getting it =) If I get things correctly; the events are triggered like this:
|
| 08-08-2007, 01:04 PM | #4 |
Issueing an stop order duirng SPELL_CAST does not suffice for some reason, you either have to pause the unit or issue the order 0.0 seconds after the event (with a timer) |
| 08-08-2007, 01:53 PM | #5 |
That always works for me though |
| 08-08-2007, 01:54 PM | #6 |
It seems to me that it would be annoying to have your unit walk all the way up to the target (to get in range) only to find that he can't cast the spell. Is it possible to grab the spellorder before it's actually issued on the hero? If you cast a spell with a target, it will get a target order first.. which doesn't hold any information about which spell is being cast. I don't think this is possible. What you could do is set the healing spell's range to infinite so that the unit begins casting immediately. Then you can check the target's health and stop the order if necessary (with a message). If the target is damaged, you have to issue a target order manually and run an update function to see if the unit is within casting range of the target. If it is, set a boolean for "in range" so that the casting won't create a loop and manually issue the spell's order. Hmm this turns out to probably be more messy than I thought. It would work, but it's not a real graceful way of coding. Maybe you even want the hero to walk to the target before checking if its hp is too low? Anyways, just an idea. Edit: Toink, simultaneous orders don't work. Vexorian is right. |
| 08-09-2007, 08:18 AM | #7 | ||
Quote:
Thanks, setting a timer made it look better than just issuing the order. I never understood how to make it work by pausing the unit though; as soon as I unpaused it, it tried to cast the spell again... (which leads to a nice chain of effect events). Quote:
That's an interesting approach. I think that I understand :P On the other hand, wouldn't this cause some other problems? For instance if your order is interrupted when you are halfway to the unit... You'd have to check if the unit gets just about any order; and then abandon the spell... |
| 08-09-2007, 08:29 AM | #8 | ||
Quote:
Orders get carried over through pausing. If you just want an order to be cancelled (and you're not messing around with double-edged spells like immolation or mana shield) then a timed hold should be enough. (I personally prefer 'stop'. Quote:
You're right that you have to pause/destroy the timer whenever the unit gets another order. I have somewhat of a framework in my map for every event so that's not really a big problem for me, but it's a bit messy to code. Every move, target and immediate order (that is nót the spell itself) has to be checked with a boolean (the bool that's being set when the timer starts) and run some sort of cancelling function. I have to admit I don't recall what happens if you issue a spellorder which requires a target with IssueImmediateOrder(). If that doesn't work, you'll have to run the animations manually, store the spell's initial target and run the jass functions for healing when the spell is being cast in range. If it does work, yay! (btw, if you don't want the command card to disappear when casting a simple spell, you could also make a dummy caster cast a stormbolt with infinite duration and no overhead effect. You can then manually remove the stunbuff through jass. Catch: you'll see a buff icon on the unit, although you could make the icon something related to the spell being cast) |
| 08-09-2007, 08:59 AM | #9 |
Somehow, I feel that would be quite much work for a very minor improvement... =) I never really understood though; why isn't it possible to use the Event - Unit is issued order, instead of Unit - Unit begins casting ability ? |
| 08-09-2007, 09:23 AM | #10 | |
Quote:
Indeed. That is possible, but only for this kind of manual stuff. If you want the spell effect to be timed properly, you have to line it up with the OE.. that's the reason you're better off using unit begins casting. There are even some shortcomings with that one, since it's possible to issue an order between unit begins casting and spell takes effect. Fast players would be able to get the jass to run, but retain their cooldown/mana : < |
| 08-09-2007, 11:19 AM | #11 |
Ah, yes, I know that orders and begins casting can be abused; but what if I use them in combination with OE? JASS:function Issued_order takes nothing returns nothing // check if a CS_Error should be thrown // Interrupt the spell endfunction function Spell_Effect takes nothing returns nothing // Do the spell endfunction Wouldn't this solve the problem with range as well? |
| 08-09-2007, 11:37 AM | #12 |
I seem to recall that the problem with this is that the hero gets a target order first. The order to cast the spell is issued when he's in range, just like what I suggested to manually do. You could try it out, but I have discarded this method a long time ago for some reason. |
| 08-09-2007, 02:23 PM | #13 | |
Quote:
Begins casting an ability is very useful when the ability is not instant... |
| 08-10-2007, 01:05 AM | #14 |
A bug would be when this unit is running for its life and it tries to do a heal on a full-health ally. Then he stops. o.o |
