• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Channel spell ignoring Condition

Status
Not open for further replies.
Level 4
Joined
Aug 12, 2014
Messages
48
I am fairly confident I know why this is not working properly but here is the issue and trigger:

  • Create Health Potions
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Health Potion
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type Empty Vial) Equal to True
        • Then - Actions
          • Item - Remove (Item carried by (Triggering unit) of type Empty Vial)
          • Set Temp_Point = (Position of (Triggering unit))
          • Special Effect - Create a special effect at Temp_Point using Abilities\Spells\Human\Invisibility\InvisibilityTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation (udg_Temp_Point)
          • Hero - Create Health Potion and give it to (Triggering unit)
        • Else - Actions
          • Game - Display to (All players controlled by a ((Owner of (Triggering unit)) controller) player) the text: I am missing reagen...
From what I understand, "channel," which this spell I based this trigger off of, works instantly, before conditions can be run/applied. A second trigger is needed to detect the cast and "stop" the unit if conditions are not met. Something like that, I think...

I have tried various ways, but no matter what I do, it always casts the spell and it does not properly check to see if I have the required item or creates a whole new problem.

The biggest problem thought, is that it always casts the spell, deducts the mana, and puts it on cool down.

THANK YOU FOR ANY HELP.


I never know what to base custom spells off of and I keep using channel for everything. That usually works but Is/Has created various issues. All the guides I see tell you how to make X, or make X do X etc. They never really tell you what to use as the base spell, or what spell to use for what situation. Any guides that specifically cover this or can anyone offer some answers. Specifically, I need DoT's, item related spells, single tick heals (like in MMO's, cast heal - heal gives 300 health / cast greater heal - heal gives 800 health) and so on.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Just ran a test and everything seems to work on my end. Do you mind posting the map or the object editor data?

As for your second question, you base the spell off that's going to be similar to your custom spell (ex: I want an instant cast spell that will deal damage around the caster and stun them. The best spell in this situation would be Thunder Clap).
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
When you start the effect of an ability, you have to stop the unit if he is not allowed to cast the ability.
So in the Else block, you order the unit to stop.

This will make your unit start casting the spell (starting animation, stopping current orders, etc, etc, etc) so to optimize user friendlyness (for players), you create another trigger that runs when a unit is issued an order (with the same targeting as your ability).
Check if the triggering unit has your ability and if the order is the same as the base order id from the object editor.
Then you also check for the conditions and order the unit to stop... because he wont be able to cast that spell anyway.

However, keeping the check inside the effect trigger is necessary.
Imagine that when I order the unit to cast the spell and it matches the conditions but by the time he starts the effect, he somehow dropped the item (or all enemy units are out of range or whatever condition you might have).
You can see why double checking in this case is the only way to do it good.

There is one problem though.
Ordering a unit to do something runs the event, but you can re-order the unit to do something else but that wont work because the event is fired before the actual order is given, so at the end of that event, the unit will overwrite the stop order with the normal ability cast order that it had.

Maker showed one of the two ways to do it, by pausing the unit, giving the new order and unpausing the unit.
I prefer a slightly different method by running a 0 second timer and ordering the unit to do your evil bidding when it expires.
Ofcourse my method would require a custom script so I just suggest you to do it Makers way. (However I dont guarantee you with 100% desired results.)
 
What Maker said. The problem is that instant cast no-target channel will fire the cooldown and subtract the mana, even if you stop on effect.
Pausing and unpausing the unit will prevent that for some odd reason nobody understands. It's one of those magic bugs in WC3 that we just learned to deal with.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
I prefer a slightly different method by running a 0 second timer and ordering the unit to do your evil bidding when it expires.

I usualy do that like this in GUI

Add unit to unit group
Start timer with 0.00 expiration (group is emtpy check can be excluded IMO)

Timer expires -> order all units in group to stop and empty group

Pausing and unpausing the unit will prevent that for some odd reason nobody understands. It's one of those magic bugs in WC3 that we just learned to deal with.

I vaguely remember reading that pausing a unit clears the order queue. When the unit is unpaused, it only has the stop command in the queue. I'm not 100% sure on this.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I use my own DelayedOrder snippet.
I then use "call IssueImmediateOrderDelayed(whichUnit, "stop", 0)" which leads to a function that starts a 0 (in this case) timer that orders <whichUnit> to <"stop">.
It is quite nice, but I recreated it into my Order system so I can manupulate orders and order queues.
For example, I order a unit to move to location (..., ...) and give another order which makes him cast an ability and place that order in the queue.
It is amazing to make AI with, but for normal stuff, it doesnt really add much stuff to it.
 
Level 4
Joined
Aug 12, 2014
Messages
48
Just ran a test and everything seems to work on my end. Do you mind posting the map or the object editor data?
Clap).

It works just fine alone but in conjunction with other units, spells, and the rest of the map, things start to break pretty quick. The map I am making is based off an old, dead MMO, that's not around anymore (EverQuest Online Adventures for the PS2). I just started it a few days ago and it has a long way to go before I am ready to share it.

Unit is issued an order
Order == your ability order

If condition is not met then
-Pause unit
-Order unit to stop
-Un-pause unit

I did this for one of the many test I tried but I cant use this method either as it REALLY breaks things in my map. I a weird movement system that's a combination of 2 existing systems plus my own ideas. In short, the Hero you play as is an avatar (dummy unit) of the actual Hero (non dummy unit) and pausing ruins the system.

I prefer a slightly different method by running a 0 second timer and ordering the unit to do your evil bidding when it expires.
Of course my method would require a custom script so I just suggest you to do it Makers way. (However I don't guarantee you with 100% desired results.)

That actually sounds like a really good idea and I will have to try that the next time I need it. As for scripting, your suggestion is correct. I am just starting to get a handle on GUI/Triggering down and fixing anything that leaks. I am not ready to tackle full-blown JASS just yet. Also, thanks for some really in depth explanations in your post!

Anyways, I fixed my problem in a totally different method that actually works really well for the Hero (An alchemist class in the map) by using additional triggers to disable/enable the abilities. Most of the spells the Hero has requires an item to be in the units inventory so I pretty much turned most of the spells into crafting recipe like abilities. Its working really great so far and more realistic.
 
Status
Not open for further replies.
Top