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

[Trigger] Spell - Unit Group selecting own units when conditioned not to

Status
Not open for further replies.
Level 7
Joined
Aug 5, 2010
Messages
147
The below trigger selects all units within an area and Changes the owner to the casting units owner, the issues is when there are units owned by the player within the radius and i presume allied/friendly units, that unit will still be selected despite there being conditions saying not to pick those units.

  • Void Charm
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Void Charm [Standard]
    • Actions
      • Set Charm_Group = (Units within 300.00 of (Target point of ability being cast) matching (((Picked unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))
      • Unit Group - Pick every unit in (Random Charm_Summon units from Charm_Group) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is A Hero) Equal to False
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Other\Charm\CharmTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Change ownership of (Picked unit) to (Owner of (Triggering unit)) and Change color
              • Unit - Add Charm_Health[(Level of Void Charm [Standard] for (Triggering unit))] to (Picked unit)
              • Unit - Add a 10.00 second Generic expiration timer to (Picked unit)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_Charm_Group)
Charm_Group is a group variable, Charm_Summon is an integer, Charm_Health is an Ability variable.
Ive tried like 6 solutions but none have worked.
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
It's:
  • Set temppoint = Target point of ability being cast
  • Set Charm_Group = (Units within 300.00 of temppoint matching (((MATCHING UNIT) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))
^"matching" instead of "picked" as it refers to the units that match the condition.
You can refer to them using picked unit as soon as you have defined the group.

Also, what is that (Random Charm_Summon units from Charm_Group)? I don't see it defined - did you do it somewhere else?

And don't forget to clean the location leak~
 
Level 7
Joined
Aug 5, 2010
Messages
147
Here is the Fixed trigger, with leak fixed.

  • Void Charm
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Void Charm [Standard]
    • Actions
      • Set Charm_Point = (Target point of ability being cast)
      • Set Charm_Group = (Units within 300.00 of Charm_Point matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))
      • Unit Group - Pick every unit in (Random Charm_Summon units from Charm_Group) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is A Hero) Equal to False
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Other\Charm\CharmTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Change ownership of (Picked unit) to (Owner of (Triggering unit)) and Change color
              • Unit - Add Charm_Health[(Level of Void Charm [Standard] for (Triggering unit))] to (Picked unit)
              • Unit - Add a 10.00 second Generic expiration timer to (Picked unit)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_Charm_Group)
      • Custom script: call RemoveLocation(udg_Charm_Point)


Also, what is that (Random Charm_Summon units from Charm_Group)? I don't see it defined - did you do it somewhere else?
It is defined in another trigger, it wasnt relavent to the issue i was having so i didnt post it.
 
Status
Not open for further replies.
Top