• 🏆 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!

[Solved] Unit enters region centered at all destructibles of a type event

Status
Not open for further replies.
Level 15
Joined
Sep 6, 2015
Messages
576
Basically, I need a trigger like this:

  • Untitled Trigger 001
    • Events
      • Unit - A unit enters (Region centered at (Position of Pine 6325 <gen>) with size (100.00, 100.00))
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Owner of (Entering unit)) controller) Equal to Computer
          • (Unit-type of (Entering unit)) Not equal to Woodcutter
          • (Unit-type of (Entering unit)) Not equal to Mutant Woodcutter
          • (Unit-type of (Entering unit)) Not equal to Woodcutter (Gnoll)
          • (Unit-type of (Entering unit)) Not equal to Goblin Shredder
    • Actions
      • Unit - Order (Entering unit) to Attack Pine 6325 <gen>
But that the "A unit enters region" event happens at every destructible of the type Pine on the map, and not only at one destructible Pine. There are 6000 trees (Pines) on my map, so making a trigger for each of them is not an option.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Using Jass you can achieve what you are asking for. In Jass you can use loops when you specify which events are registered.
I have attached a map. You can configure:
- Range of the region to enter
- Range of the region to search for the destructible to attack

A trigger Condition Register:

Allows you to specify which destructibles should be used.
Use the custom variable MatchingDestructible to refer to the destructible. Set ReturnBoolean accordingly.

A trigger Condition Attack:

Allows you to specify if a destructibles should be attacked when entered.
Use the custom variable MatchingDestructible to refer to the destructible.
Use the custom variable EnteringUnit to refer to the unit.
Set ReturnBoolean accordingly.
 

Attachments

  • PineTrees.w3x
    19.2 KB · Views: 34
Level 15
Joined
Sep 6, 2015
Messages
576
Using Jass you can achieve what you are asking for. In Jass you can use loops when you specify which events are registered.
I have attached a map. You can configure:
- Range of the region to enter
- Range of the region to search for the destructible to attack

A trigger Condition Register:

Allows you to specify which destructibles should be used.
Use the custom variable MatchingDestructible to refer to the destructible. Set ReturnBoolean accordingly.

A trigger Condition Attack:

Allows you to specify if a destructibles should be attacked when entered.
Use the custom variable MatchingDestructible to refer to the destructible.
Use the custom variable EnteringUnit to refer to the unit.
Set ReturnBoolean accordingly.
Wow, it works perfectly. I am finally being able to make the AI work properly on my map.
Thanks both for help.
 
Status
Not open for further replies.
Top