• 🏆 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] Problem with Unit-type of (matching unit) Equal to X-Unit

Status
Not open for further replies.
Level 12
Joined
May 16, 2020
Messages
660
Hi all,

The following trigger should recognize if a specific unit is in range, and if yes, just extend the Timed Life of units within the group.

However, the created group which I use to check if someone is in range is always empty, even though the AA_Point[1] literally contains >100 units of this type. This results in the trigger creating 1 Spectral Dagger (Shadow) at AA_PointTemp[1] over and over.

I believe the problem is with the function "unit-type of matching unit equal to XXX". I do not see any mistake here, but maybe I'm handing the function wrong. Can anyone help please?

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (AA_GroupHitHero[AA_Integer] is empty) Equal to False
    • Then - Actions
      • Unit Group - Pick every unit in AA_GroupHitHero[AA_Integer] and do (Actions)
        • Loop - Actions
          • Set VariableSet AA_Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (AA_Unit is alive) Equal to True
            • Then - Actions
              • Set VariableSet AA_PointTemp[1] = (Position of AA_Unit)
              • Custom script: set udg_AA_GroupShadowCheck = CreateGroup()
              • Set VariableSet AA_GroupShadowCheck = (Units within 120.00 of AA_PointTemp[1] matching ((Unit-type of (Matching unit)) Equal to Spectral Dagger (Shadow)).)
              • Game - Display to (All players) the text: (String((Number of units in AA_GroupShadowCheck)))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in AA_GroupShadowCheck) Equal to 0
                • Then - Actions
                  • Game - Display to (All players) the text: Nothing found - Cre...
                  • Unit - Create 1 Spectral Dagger (Shadow) for (Owner of AA_Caster[AA_Integer]) at AA_PointTemp[1] facing Default building facing degrees
                  • Set VariableSet AA_Dummy = (Last created unit)
                  • Ability - Set Ability: (Unit: AA_Dummy's Ability with Ability Code: Spectral Dagger (Self))'s Real Level Field: Movement Speed Increase (%) ('Oae1') of Level: 0 to AA_Speed[AA_Integer]
                  • Ability - Set Ability: (Unit: AA_Dummy's Ability with Ability Code: Spectral Dagger (Enemies))'s Real Level Field: Movement Speed Factor ('Slo1') of Level: 0 to AA_Slow[AA_Integer]
                  • Unit - Add a 7.00 second Generic expiration timer to AA_Dummy
                • Else - Actions
                  • Unit Group - Pick every unit in AA_GroupShadowCheck and do (Actions)
                    • Loop - Actions
                      • Game - Display to (All players) the text: Found - extend life
                      • Set VariableSet AA_UnitTemp = (Picked unit)
                      • Unit - Cancel Timed Life for AA_UnitTemp
                      • Unit - Add a 7.00 second Generic expiration timer to AA_UnitTemp
              • Custom script: call RemoveLocation( udg_AA_PointTemp[1])
              • Custom script: call DestroyGroup(udg_AA_GroupShadowCheck)
            • Else - Actions
    • Else - Actions
 
Level 12
Joined
May 16, 2020
Messages
660
It's a quite a long trigger (possibly the longest I've ever done), but please see below. The skill I'm replicating is Spectra Dagger from Dota
Spectre

There are 3 main parts:
  1. Set up: The important part here is to distinguish if a unit or point has been selected
  2. The loop: Based on what was done in #1, two different pats are chosen. Here is also where my problem arises, within "CHECK IF MORE SHADOW PATHS NEEDED"
  3. Used to turn on / off the collision of the caster while in the Shadow Path


  • Spectral Dagger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spectral Dagger
    • Actions
      • Set VariableSet AA_Index = (AA_Index + 1)
      • Set VariableSet AA_Caster[AA_Index] = (Triggering unit)
      • Set VariableSet AA_Damage[AA_Index] = (20.00 + (55.00 x (Real((Level of Spectral Dagger for AA_Caster[AA_Index])))))
      • Set VariableSet AA_Speed[AA_Index] = (0.06 + (0.04 x (Real((Level of Spectral Dagger for AA_Caster[AA_Index])))))
      • Set VariableSet AA_Slow[AA_Index] = (-0.06 - (0.04 x (Real((Level of Spectral Dagger for AA_Caster[AA_Index])))))
      • Set VariableSet AA_Counter[AA_Index] = 0.00
      • Set VariableSet AA_CounterInteger[AA_Index] = 0
      • Set VariableSet AA_BooleanHit[AA_Index] = False
      • -------- --------
      • Set VariableSet AA_Point[AA_Index] = (Position of AA_Caster[AA_Index])
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Target unit of ability being cast) Equal to No unit
        • Then - Actions
          • Game - Display to (All players) the text: Point
          • Set VariableSet AA_BooleanTarget[AA_Index] = False
          • Set VariableSet AA_Boolean[AA_Index] = False
          • Set VariableSet AA_PointTemp[1] = (Target point of ability being cast)
          • Set VariableSet AA_Distance[AA_Index] = 0.00
        • Else - Actions
          • Game - Display to (All players) the text: Target Unit
          • Set VariableSet AA_BooleanTarget[AA_Index] = True
          • Set VariableSet AA_Target[AA_Index] = (Target unit of ability being cast)
          • Set VariableSet AA_PointTemp[1] = (Position of AA_Target[AA_Index])
      • -------- --------
      • Set VariableSet AA_Angle[AA_Index] = (Angle from AA_Point[AA_Index] to AA_PointTemp[1])
      • -------- --------
      • Unit - Create 1 Spectral Dagger (Shadow) for (Owner of AA_Caster[AA_Index]) at AA_Point[AA_Index] facing Default building facing degrees
      • Set VariableSet AA_Dummy = (Last created unit)
      • Unit - Add Marker (Main Shadow Path) to AA_Dummy
      • Ability - Set Ability: (Unit: AA_Dummy's Ability with Ability Code: Spectral Dagger (Self))'s Real Level Field: Movement Speed Increase (%) ('Oae1') of Level: 0 to AA_Speed[AA_Index]
      • Ability - Set Ability: (Unit: AA_Dummy's Ability with Ability Code: Spectral Dagger (Enemies))'s Real Level Field: Movement Speed Factor ('Slo1') of Level: 0 to AA_Slow[AA_Index]
      • Unit - Add a 12.00 second Generic expiration timer to AA_Dummy
      • Unit Group - Add AA_Dummy to SpectralDagger_Shadow_Group
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AA_BooleanTarget[AA_Index] Equal to True
        • Then - Actions
          • Unit - Create 1 Spectral Dagger (Projectile) for (Owner of AA_Caster[AA_Index]) at AA_Point[AA_Index] facing AA_Angle[AA_Index] degrees
          • Set VariableSet AA_MissileUnit[AA_Index] = (Last created unit)
          • Unit - Add Crow Form to AA_MissileUnit[AA_Index]
          • Unit - Remove Crow Form from AA_MissileUnit[AA_Index]
          • Animation - Change AA_MissileUnit[AA_Index] flying height to 125.00 at 0.00
          • Custom script: call RemoveLocation(udg_AA_Point[udg_AA_Index])
        • Else - Actions
          • Special Effect - Create a special effect at AA_Point[AA_Index] using war3mapImported\MeatHookHead.mdx
          • Set VariableSet AA_MissileSFX[AA_Index] = (Last created special effect)
          • Special Effect - Set Scale of AA_MissileSFX[AA_Index] to 1.40
          • Special Effect - Set Yaw of AA_MissileSFX[AA_Index] to: (Radians(AA_Angle[AA_Index]))
          • Special Effect - Set Height of AA_MissileSFX[AA_Index] to: ((Position - Z of AA_MissileSFX[AA_Index].) + 125.00)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (AA_Caster[AA_Index] is in SpectralDagger_Collision_Group.) Equal to False
        • Then - Actions
          • Unit - Turn collision for AA_Caster[AA_Index] Off.
          • Unit - Add Crow Form to AA_Caster[AA_Index]
          • Unit - Add Ghost (Visible) to AA_Caster[AA_Index]
          • Unit Group - Add AA_Caster[AA_Index] to SpectralDagger_Collision_Group
        • Else - Actions
      • -------- --------
      • Custom script: call RemoveLocation(udg_AA_PointTemp[1])
      • Custom script: set udg_AA_GroupHit[udg_AA_Index] = CreateGroup()
      • Custom script: set udg_AA_GroupHitHero[udg_AA_Index] = CreateGroup()
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AA_Index Equal to 1
        • Then - Actions
          • Game - Display to (All players) the text: ON
          • Countdown Timer - Start AA_Timer as a Repeating timer that will expire in 0.03 seconds
          • Trigger - Turn on Spectral Dagger Collision <gen>
          • Trigger - Turn on Spectral Dagger Loop <gen>
        • Else - Actions
  • Spectral Dagger Loop
    • Events
      • Time - AA_Timer expires
    • Conditions
    • Actions
      • For each (Integer AA_Integer) from 1 to AA_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AA_BooleanHit[AA_Integer] Equal to False
            • Then - Actions
              • -------- AS LONG AS NO HIT, MOVE THE DAGGER --------
              • -------- BASED ON TARGET CHOSEN, A DIFFERENT PATH IS TAKEN --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AA_BooleanTarget[AA_Integer] Equal to False
                • Then - Actions
                  • -------- --------
                  • -------- TARGET = POINT --------
                  • -------- --------
                  • Set VariableSet AA_Distance[AA_Integer] = (AA_Distance[AA_Integer] + 40.00)
                  • Set VariableSet AA_PointTemp[1] = (AA_Point[AA_Integer] offset by AA_Distance[AA_Integer] towards AA_Angle[AA_Integer] degrees.)
                  • Set VariableSet AA_Pos_X = (X of AA_PointTemp[1])
                  • Set VariableSet AA_Pos_Y = (Y of AA_PointTemp[1])
                  • Custom script: set udg_AA_Boolean_Map = IsPointInMap(udg_AA_Pos_X, udg_AA_Pos_Y)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • AA_Boolean_Map Equal to True
                    • Then - Actions
                      • Custom script: set udg_AA_Z = GetLocationZ(udg_AA_PointTemp[1])
                      • Special Effect - Set Position of AA_MissileSFX[AA_Integer] to x: (X of AA_PointTemp[1]), y: (Y of AA_PointTemp[1]), z: (AA_Z + 125.00)
                      • -------- --------
                      • Custom script: set bj_wantDestroyGroup = true
                      • Unit Group - Pick every unit in (Units within 125.00 of AA_PointTemp[1].) and do (Actions)
                        • Loop - Actions
                          • Set VariableSet AA_Unit = (Picked unit)
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (AA_Unit is alive) Equal to True
                              • (AA_Unit is A structure) Equal to False
                              • (AA_Unit is Magic Immune) Equal to False
                              • (AA_Unit belongs to an enemy of (Owner of AA_Caster[AA_Integer]).) Equal to True
                              • (AA_Unit is in AA_GroupHit[AA_Integer].) Equal to False
                            • Then - Actions
                              • Unit Group - Add AA_Unit to AA_GroupHit[AA_Integer]
                              • Sound - Play SpectralDagger <gen> at 100.00% volume, attached to AA_Unit
                              • Unit - Cause AA_Caster[AA_Integer] to damage AA_Unit, dealing AA_Damage[AA_Integer] damage of attack type Spells and damage type Magic
                              • -------- --------
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (AA_Unit is A Hero) Equal to True
                                • Then - Actions
                                  • Game - Display to (All players) the text: Hero Hit
                                  • Unit Group - Add AA_Unit to AA_GroupHitHero[AA_Integer]
                                • Else - Actions
                            • Else - Actions
                    • Else - Actions
                      • Set VariableSet AA_Boolean[AA_Integer] = True
                  • -------- --------
                  • Set VariableSet AA_CounterInteger[AA_Integer] = (AA_CounterInteger[AA_Integer] + 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (AA_CounterInteger[AA_Integer] mod 3) Equal to 0
                    • Then - Actions
                      • Unit - Create 1 Spectral Dagger (Shadow) for (Owner of AA_Caster[AA_Integer]) at AA_PointTemp[1] facing Default building facing degrees
                      • Set VariableSet AA_Dummy = (Last created unit)
                      • Unit - Add Marker (Main Shadow Path) to AA_Dummy
                      • Ability - Set Ability: (Unit: AA_Dummy's Ability with Ability Code: Spectral Dagger (Self))'s Real Level Field: Movement Speed Increase (%) ('Oae1') of Level: 0 to AA_Speed[AA_Integer]
                      • Ability - Set Ability: (Unit: AA_Dummy's Ability with Ability Code: Spectral Dagger (Enemies))'s Real Level Field: Movement Speed Factor ('Slo1') of Level: 0 to AA_Slow[AA_Integer]
                      • Unit - Add a 12.00 second Generic expiration timer to AA_Dummy
                      • Unit Group - Add AA_Dummy to SpectralDagger_Shadow_Group
                    • Else - Actions
                  • Custom script: call RemoveLocation( udg_AA_PointTemp[1])
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • AA_Distance[AA_Integer] Greater than or equal to 2000.00
                    • Then - Actions
                      • -------- HIT --------
                      • Game - Display to (All players) the text: End of Trail
                      • Set VariableSet AA_BooleanHit[AA_Integer] = True
                      • Special Effect - Destroy AA_MissileSFX[AA_Integer]
                      • Custom script: call RemoveLocation(udg_AA_Point[udg_AA_Integer])
                    • Else - Actions
                • Else - Actions
                  • -------- --------
                  • -------- TARGET = UNIT --------
                  • -------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • AA_BooleanTarget[AA_Integer] Equal to True
                    • Then - Actions
                      • Set VariableSet AA_PointTemp[1] = (Position of AA_MissileUnit[AA_Integer])
                      • Set VariableSet AA_PointTemp[2] = (Position of AA_Target[AA_Integer])
                      • Set VariableSet AA_Angle[AA_Integer] = (Angle from AA_PointTemp[1] to AA_PointTemp[2])
                      • Set VariableSet AA_PointTemp[3] = (AA_PointTemp[1] offset by 40.00 towards AA_Angle[AA_Integer] degrees.)
                      • Set VariableSet AA_Pos_X = (X of AA_PointTemp[3])
                      • Set VariableSet AA_Pos_Y = (Y of AA_PointTemp[3])
                      • Custom script: call SetUnitX(udg_AA_MissileUnit[udg_AA_Integer], udg_AA_Pos_X)
                      • Custom script: call SetUnitY(udg_AA_MissileUnit[udg_AA_Integer], udg_AA_Pos_Y)
                      • -------- --------
                      • Custom script: set bj_wantDestroyGroup = true
                      • Unit Group - Pick every unit in (Units within 125.00 of AA_PointTemp[3].) and do (Actions)
                        • Loop - Actions
                          • Set VariableSet AA_Unit = (Picked unit)
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (AA_Unit is alive) Equal to True
                              • (AA_Unit is A structure) Equal to False
                              • (AA_Unit is Magic Immune) Equal to False
                              • (AA_Unit belongs to an enemy of (Owner of AA_Caster[AA_Integer]).) Equal to True
                              • (AA_Unit is in AA_GroupHit[AA_Integer].) Equal to False
                            • Then - Actions
                              • Unit Group - Add AA_Unit to AA_GroupHit[AA_Integer]
                              • Sound - Play SpectralDagger <gen> at 100.00% volume, attached to AA_Unit
                              • Unit - Cause AA_Caster[AA_Integer] to damage AA_Unit, dealing AA_Damage[AA_Integer] damage of attack type Spells and damage type Magic
                              • -------- --------
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (AA_Unit is A Hero) Equal to True
                                • Then - Actions
                                  • Game - Display to (All players) the text: Hero Hit
                                  • Unit Group - Add AA_Unit to AA_GroupHitHero[AA_Integer]
                                • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • AA_Unit Equal to AA_Target[AA_Integer]
                                • Then - Actions
                                  • -------- HIT --------
                                  • Set VariableSet AA_BooleanHit[AA_Integer] = True
                                  • Unit - Kill AA_MissileUnit[AA_Integer]
                                • Else - Actions
                            • Else - Actions
                      • -------- --------
                      • Set VariableSet AA_CounterInteger[AA_Integer] = (AA_CounterInteger[AA_Integer] + 1)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (AA_CounterInteger[AA_Integer] mod 3) Equal to 0
                        • Then - Actions
                          • Unit - Create 1 Spectral Dagger (Shadow) for (Owner of AA_Caster[AA_Integer]) at AA_PointTemp[3] facing Default building facing degrees
                          • Set VariableSet AA_Dummy = (Last created unit)
                          • Unit - Add Marker (Main Shadow Path) to AA_Dummy
                          • Ability - Set Ability: (Unit: AA_Dummy's Ability with Ability Code: Spectral Dagger (Self))'s Real Level Field: Movement Speed Increase (%) ('Oae1') of Level: 0 to AA_Speed[AA_Integer]
                          • Ability - Set Ability: (Unit: AA_Dummy's Ability with Ability Code: Spectral Dagger (Enemies))'s Real Level Field: Movement Speed Factor ('Slo1') of Level: 0 to AA_Slow[AA_Integer]
                          • Unit - Add a 12.00 second Generic expiration timer to AA_Dummy
                          • Unit Group - Add AA_Dummy to SpectralDagger_Shadow_Group
                        • Else - Actions
                      • -------- --------
                      • Custom script: call RemoveLocation( udg_AA_PointTemp[1])
                      • Custom script: call RemoveLocation( udg_AA_PointTemp[2])
                      • Custom script: call RemoveLocation( udg_AA_PointTemp[3])
                    • Else - Actions
            • Else - Actions
              • Set VariableSet AA_Counter[AA_Integer] = (AA_Counter[AA_Integer] + 0.03)
          • -------- --------
          • -------- CHECK IF MORE SHADOW PATHS NEEDED --------
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (AA_GroupHitHero[AA_Integer] is empty) Equal to False
            • Then - Actions
              • Unit Group - Pick every unit in AA_GroupHitHero[AA_Integer] and do (Actions)
                • Loop - Actions
                  • Set VariableSet AA_Unit = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (AA_Unit is alive) Equal to True
                    • Then - Actions
                      • Set VariableSet AA_PointTemp[1] = (Position of AA_Unit)
                      • Custom script: set udg_AA_GroupShadowCheck = CreateGroup()
                      • Set VariableSet AA_GroupShadowCheck = (Units within 120.00 of AA_PointTemp[1] matching ((Unit-type of (Matching unit)) Equal to Spectral Dagger (Shadow)).)
                      • Game - Display to (All players) the text: (String((Number of units in AA_GroupShadowCheck)))
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (AA_GroupShadowCheck is empty) Equal to True
                        • Then - Actions
                          • Game - Display to (All players) the text: Nothing found - Cre...
                          • Unit - Create 1 Spectral Dagger (Shadow) for (Owner of AA_Caster[AA_Integer]) at AA_PointTemp[1] facing Default building facing degrees
                          • Set VariableSet AA_Dummy = (Last created unit)
                          • Ability - Set Ability: (Unit: AA_Dummy's Ability with Ability Code: Spectral Dagger (Self))'s Real Level Field: Movement Speed Increase (%) ('Oae1') of Level: 0 to AA_Speed[AA_Integer]
                          • Ability - Set Ability: (Unit: AA_Dummy's Ability with Ability Code: Spectral Dagger (Enemies))'s Real Level Field: Movement Speed Factor ('Slo1') of Level: 0 to AA_Slow[AA_Integer]
                          • Unit - Add a 7.00 second Generic expiration timer to AA_Dummy
                          • Unit Group - Add AA_Dummy to SpectralDagger_Shadow_Group
                        • Else - Actions
                          • Unit Group - Pick every unit in AA_GroupShadowCheck and do (Actions)
                            • Loop - Actions
                              • Game - Display to (All players) the text: Found - extend life
                              • Set VariableSet AA_UnitTemp = (Picked unit)
                              • Unit - Cancel Timed Life for AA_UnitTemp
                              • Unit - Add a 7.00 second Generic expiration timer to AA_UnitTemp
                      • Custom script: call RemoveLocation( udg_AA_PointTemp[1])
                      • Custom script: call DestroyGroup(udg_AA_GroupShadowCheck)
                    • Else - Actions
            • Else - Actions
          • -------- --------
          • -------- CHECK IF SPELL SHOULD BE ENDED --------
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • AA_Counter[AA_Integer] Greater than or equal to 7.00
                  • AA_Boolean[AA_Integer] Equal to True
            • Then - Actions
              • Custom script: call DestroyGroup(udg_AA_GroupHit[udg_AA_Integer])
              • Custom script: call DestroyGroup(udg_AA_GroupHitHero[udg_AA_Integer])
              • -------- --------
              • Set VariableSet AA_Caster[AA_Integer] = AA_Caster[AA_Index]
              • Set VariableSet AA_Damage[AA_Integer] = AA_Damage[AA_Index]
              • Set VariableSet AA_Slow[AA_Integer] = AA_Slow[AA_Index]
              • Set VariableSet AA_Counter[AA_Integer] = AA_Counter[AA_Index]
              • Set VariableSet AA_CounterInteger[AA_Integer] = AA_CounterInteger[AA_Index]
              • Set VariableSet AA_Point[AA_Integer] = AA_Point[AA_Index]
              • Set VariableSet AA_Boolean[AA_Integer] = AA_Boolean[AA_Index]
              • Set VariableSet AA_BooleanTarget[AA_Integer] = AA_BooleanTarget[AA_Index]
              • Set VariableSet AA_BooleanHit[AA_Integer] = AA_BooleanHit[AA_Index]
              • Set VariableSet AA_Target[AA_Integer] = AA_Target[AA_Index]
              • Set VariableSet AA_Angle[AA_Integer] = AA_Angle[AA_Index]
              • Set VariableSet AA_MissileUnit[AA_Integer] = AA_MissileUnit[AA_Index]
              • Set VariableSet AA_MissileSFX[AA_Integer] = AA_MissileSFX[AA_Index]
              • Set VariableSet AA_GroupHit[AA_Integer] = AA_GroupHit[AA_Index]
              • -------- --------
              • Set VariableSet AA_Index = (AA_Index - 1)
              • Set VariableSet AA_Integer = (AA_Integer - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AA_Index Equal to 0
                • Then - Actions
                  • Game - Display to (All players) the text: OFF
                  • Countdown Timer - Pause AA_Timer
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
  • Spectral Dagger Collision
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in SpectralDagger_Collision_Group) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in SpectralDagger_Collision_Group and do (Actions)
            • Loop - Actions
              • Set VariableSet AA_UnitTemp = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (AA_UnitTemp has buff Shadow Path (Self)) Equal to False
                • Then - Actions
                  • Unit - Turn collision for AA_UnitTemp On.
                  • Unit - Remove Ghost (Visible) from AA_UnitTemp
                  • Unit - Remove Crow Form from AA_UnitTemp
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of units in SpectralDagger_Shadow_Group) Equal to 0
                    • Then - Actions
                      • Unit Group - Remove AA_UnitTemp from SpectralDagger_Collision_Group.
                    • Else - Actions
                • Else - Actions
                  • Unit - Turn collision for AA_UnitTemp Off.
                  • Unit - Add Crow Form to AA_UnitTemp
                  • Unit - Add Ghost (Visible) to AA_UnitTemp
        • Else - Actions
          • Game - Display to (All players) the text: Collision OFF
          • Trigger - Turn off (This trigger)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Does Spectral Dagger (Shadow) have the locust ability? Or are they hidden by triggers? Both will prevent them from being detected by area searches like Units within 120.00 of AA_PointTemp[1] matching. Both the locust ability and hiding units by trigger will remove them from area search logic such as that function. They can still be detected by player unit searches, or if referenced directly.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
If the daggers are part of the ability (not coming from other sources) then you can track them as part of the ability state and then check their position using a standard distance between points checks. In theory you could do this for all units matching the appropriate type owned by the player but that suffers scaling issues, especially if the player owns a lot of units (should be fine if just a single hero like a MOBA or RPG).
 
Level 12
Joined
May 16, 2020
Messages
660
Thanks a lot, I adjusted it (can this be done more efficiently?). But there is a problem: I believe "Cancel Timed Life for Unit" is bugged...?

Instead of removing the timed life, it simply kills the unit. So currently, as soon as a Spectral Dagger (Shadow) matches the condition for being "within less than 120 range" (see below), it kills the Spectral Dagger (Shadow). Instead, I want such a unit to have its timed life reset to 7 seconds.



  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (AA_GroupHitHero[AA_Integer] is empty) Equal to False
    • Then - Actions
      • Unit Group - Pick every unit in AA_GroupHitHero[AA_Integer] and do (Actions)
        • Loop - Actions
          • Set VariableSet AA_Unit = (Picked unit)
          • Set VariableSet AA_DistanceCheck[1] = 120.00
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (AA_Unit is alive) Equal to True
            • Then - Actions
              • Set VariableSet AA_PointTemp[1] = (Position of AA_Unit)
              • Unit Group - Pick every unit in AA_GroupShadow and do (Actions)
                • Loop - Actions
                  • Set VariableSet AA_UnitTemp = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Owner of AA_UnitTemp) Equal to (Owner of AA_Caster[AA_Integer])
                    • Then - Actions
                      • Set VariableSet AA_PointTemp[2] = (Position of AA_UnitTemp)
                      • Set VariableSet AA_DistanceCheck[2] = (Distance between AA_PointTemp[1] and AA_PointTemp[2])
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • AA_DistanceCheck[2] Less than 120.00
                        • Then - Actions
                          • Game - Display to (All players) the text: Found - extend life
                          • Unit - Cancel Timed Life for AA_UnitTemp
                          • Unit - Add a 7.00 second Generic expiration timer to AA_UnitTemp
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • AA_DistanceCheck[2] Less than AA_DistanceCheck[1]
                        • Then - Actions
                          • Set VariableSet AA_DistanceCheck[1] = AA_Distance[2]
                        • Else - Actions
                      • Custom script: call RemoveLocation( udg_AA_PointTemp[2])
                    • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AA_DistanceCheck[1] Greater than or equal to 120.00
                • Then - Actions
                  • Game - Display to (All players) the text: Nothing found - Cre...
                  • Unit - Create 1 Spectral Dagger (Shadow) for (Owner of AA_Caster[AA_Integer]) at AA_PointTemp[1] facing Default building facing degrees
                  • Set VariableSet AA_Dummy = (Last created unit)
                  • Ability - Set Ability: (Unit: AA_Dummy's Ability with Ability Code: Spectral Dagger (Self))'s Real Level Field: Movement Speed Increase (%) ('Oae1') of Level: 0 to AA_Speed[AA_Integer]
                  • Ability - Set Ability: (Unit: AA_Dummy's Ability with Ability Code: Spectral Dagger (Enemies))'s Real Level Field: Movement Speed Factor ('Slo1') of Level: 0 to AA_Slow[AA_Integer]
                  • Unit - Add a 7.00 second Generic expiration timer to AA_Dummy
                  • Unit Group - Add AA_Dummy to AA_GroupShadow
                • Else - Actions
              • Custom script: call RemoveLocation( udg_AA_PointTemp[1])
            • Else - Actions
    • Else - Actions
 
Status
Not open for further replies.
Top