• 🏆 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] is spell target/no target/point

Status
Not open for further replies.
Level 3
Joined
Nov 18, 2007
Messages
48
I made this but I'm not sure if it's 100% correct, is there an easier way to check if a skill is target/no target/point ?
for some reason thunder clap has a target unit but invalid point while some other no target skills don't have either target or point, the target skills I tested have both target and point so I arranged the triggers this way so that it's more correct. I only tested a few abilities though. I also could check with orders but it seems a bit too excessive.
I know that the location leaks, I'm gonna turn it into jass later so if there is a relevant jass only function please tell me.
  • Starting Trigger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set p = (Target point of ability being cast)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (X of p) Not equal to 0.00
          • (Y of p) Not equal to 0.00
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target unit of ability being cast) Not equal to No unit
            • Then - Actions
              • Game - Display to (All players) the text: target
            • Else - Actions
              • Game - Display to (All players) the text: point
        • Else - Actions
          • Game - Display to (All players) the text: not point
 
Level 10
Joined
Oct 5, 2008
Messages
355
A little trick, if you want to check for a unit targeted spell only is to check if the target unit of ability being cast is alive. It will return false in that case. But if you want to differentiate between point casted/no target spell, i would stick to bribe's approach.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
A little trick, if you want to check for a unit targeted spell only is to check if the target unit of ability being cast is alive. It will return false in that case. But if you want to differentiate between point casted/no target spell, i would stick to bribe's approach.


That's completely unnecessary to check if the target is alive and, under the hood, creates more work for the game engine. Checking if the spell target is equal to "no unit" is best and even more accurate.
 
Level 3
Joined
Nov 18, 2007
Messages
48
there is a problem with GetSpellTargetLoc, sometimes it returns even if it's "null" (xy = 0,0) so I'm using getLocationX/Y and it works. also some no target spells like thunderclap return a target unit but target spells always have a non xy 0,0 location so my conclusion is:
valid X/Y+unit = target
0,0 XY+unit = no target
point+nounit = point
 
Status
Not open for further replies.
Top