• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

A unit comes within 100.00 of A unit

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2010
Messages
950
When trying to refer to the unit that you come within 100 of what is that?
  • Unit - A unit comes within 100.00 of No unit
I know the unit coming within 100 is the triggering unit.. but whats the unit your getting close to called.. :/










Also this trigger only works for me like 50ish % of the time no idea why.. it should work 100% from the looks of it.
  • Hero Select
    • Events
      • Unit - A unit enters Hero 1 <gen>
      • Unit - A unit enters Hero 2 <gen>
      • Unit - A unit enters Hero 3 <gen>
      • Unit - A unit enters Hero 4 <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Wisp Hero Picker
    • Actions
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero_PickRegion[(Integer A)] contains (Triggering unit)) Equal to True
            • Then - Actions
              • Unit - Remove Hero_Unit[(Integer A)] from the game
              • Unit - Create 1 Hero_Pick[(Integer A)] for (Owner of (Triggering unit)) at (Center of Hero_StartArea[(Integer A)]) facing Default building facing degrees
            • Else - Actions
theres other stuff it does but removed it for simplicity.

I have everything set right and the regions are a fair size. Why in the world doesnt this work 100% of the time..
 
Level 5
Joined
Oct 14, 2010
Messages
100
1) You can't retrieve that unit. What you must do is store it in a variable.

  • Events
    • Unit - A unit comes within 100.00 of Preplaced_Unit_0001
  • Actions
    • Unit - Kill Preplaced_Unit_0001
Where Preplaced_Unit_0001 is a unit selected on the map.

2) What exactly doesn't work? Everything looks correct except that you can still pick a hero when another player already took him?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
There is no event response for the unit you are getting close to. Just create an individual trigger for each unit you want to have an event for and attach the unit to its trigger. You can use GetTriggeringTrigger() to get the current trigger instance and exert GetHandleId on it to have a key you can use in a hashtable or such. But as you may have seen, this requires jass, you cannot create triggers during runtime in normal GUI.

When you want to know the reason why a trigger does not work, always describe what it should supposedly do. Since your code already does not achieve it, it may not be obvious to us as well.

I can state that the trigger actually does not run when a unit enters your GUI region (rect) but there is a jass type (region) that is instantiated and this one gets the cells (32*32) your specified rect provides, so it's kind of mirrored. Anyway, when this event fires, you think that the unit is already within the rect but from normal movement, that's not always the case. It's a border case because right before or right after the event strikes, the unit's coordinates become within. I know that it will only work when entering from two of the four sides. The other two sides will fire before the coordinates are updated.
 
Level 13
Joined
Mar 24, 2010
Messages
950
Im not sure it will work that way, or i may just be overlooking it..
What i want to do is have a unit event all in 1 and check if the unit comes within a close area. and if so remove that unit and create a unit for that player thats being approached lol. I need to have it set to a var array, not sure how to refer to that unit correctly tho.




well yeah i took care of that also but as i said i deleted alot of extra stuff below just to make it simple. for some reason i think the event and then checking action all happens too fast, so the unit is being checked for maybe before its even fully in the region maybe?

Edit:
we posted close to the same time, i kinda figured that might have to put a small delay in i guess
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
  • Unit
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Trigger - Add to Kill <gen> the event (Unit - A unit comes within 300.00 of (Last created unit))
  • Kill
    • Events
    • Conditions
    • Actions
      • Unit - Kill (Triggering unit)
You can use Trigger - Add New Event action to use the Units within range Event in the second trigger
 
Level 9
Joined
May 27, 2006
Messages
498
2.
  • (Hero_PickRegion[(Integer A)] contains (Triggering unit)) Equal to True
Sometimes the above condition doesn't pick the unit in the rect, even tho it fired the event. I've no idea why it happens so, but putting a small wait before the loop, like 0.01-0.05 sec, usually fixes the issue. Your trigger will still be MUI.

Edit;
Bond0090 said:
i kinda figured that might have to put a small delay in i guess
Oh, nvm
 
Status
Not open for further replies.
Top