• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Spell] Trigger ignores "Unit owned by Player X" condition

Status
Not open for further replies.
Level 1
Joined
Dec 12, 2019
Messages
3
Hey guys!

I Would like to ask for some help with a World Editor-related problem.
I have set up a trigger where you cast a spell on an allied or enemy hero. After you finish channeling the spell, the targeted hero will instantly teleport to his respective spawning area. I had quite some trouble with moving the hero itself, because "Move Unit" didn't do anything but stun the unit, but eventually figured out that with a quick global Blink item it can be solved, so now it works. (technically the spell might be ruined if target hero has already full inventory, but I could not come up with a better solution since I don't really know how SetUnitX and Y custom scripts should work.)

The only problem is that there is an "If" condition which checks which side the targeted hero is on, and blinks him/her to said location; however, for some reason the condition always ends with the "Else" branch fulfilled, so it always teleports to the Team 2 spawn location (HeroSpawnScourge), regardless of targeted hero's team.(Which results in Team 1 heroes slaughtered down in a second by Team 2 defenses but that's beside the point) I tried to set the condition as "Target unit of ability being cast is owned by an Ally/Enemy of Player 1/7, but that yielded the same result as Target unit of ability being cast is in Units owned by Player 1-6/7-12 (or Target unit of ability being cast is in Units playable map area owned by Player 1, as you can see in the first example, too).

Any ideas how can I make it work properly, with heroes from Team 1 blinking to Team 1 spawn properly?
(Team 2 works so it's half working at least, but that is not yet quite perfect for me :D )

See the trigger itself below.


Thanks for the help in advance!

J0zDC7P.jpg
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
Welcome!
  • So you don't have to screenshot triggers: How To Post Your Trigger
  • You have a few memory leaks, which you can learn how to fix here: Things That Leak
  • Don't use Waits if you can avoid it, they can break some event responses: Event Response Myths. Here I don't see any need to use waits; most things triggers can do are instantaneous.
  • Also the minimum wait duration is ~0.27s, any lower and it won't actually wait that short duration (you can put 0 to make it the minimum though).
  • Instead of checking "unit is in (units owned by player)" you can just check if the unit's owner is that player. In this case, though, you'll actually want to use "unit belongs to an ally of player".
  • Doing this with a blink item is creative but absolutely not the way you should do this (what if the unit gets stunned before issuing the blink command, what if it has a full inventory, etc.).
  • Save the spawn points at map init in some variables to reuse later (this also avoids point leaks).
  • Don't use the Map Init event, though; used elapsed game time events (see below). If you have too many things running off the init thread it can crash the thread and then nothing else that uses that event will be run.
  • Events
    • Time - Elapsed game time is 0.50 seconds
  • Conditions
  • Actions
    • Set TeamSpawn[1] = (Center of HeroSpawnSentinel <gen>)
    • Set TeamSpawn[2] = (Center of HeroSpawnScourge <gen>)
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) equal to Let Us Farm!
  • Actions
    • If (All conditions are true) then do (then actions) else do (else actions)
      • If - Conditions
        • ((Target Unit of ability being cast) belongs to an ally of Player 1 (Red)) equal to True
      • Then - Actions
        • Unit - Move (Target unit of ability being cast) instantly to TeamSpawn[1]
      • Else - Actions
        • Unit - Move (Target unit of ability being cast) instantly to TeamSpawn[2]
 
Status
Not open for further replies.
Top