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

[Solved] [Trigger]Spell not working as MPI

Status
Not open for further replies.
Level 2
Joined
Jun 13, 2020
Messages
16
Can someone help me to check my trigger?
Rich (BB code):
  • Blazing Pit
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Blazing Pit
    • Actions
      • Set Player = (Player number of (Owner of (Triggering unit)))
      • Set caster[Player] = (Triggering unit)
      • Set Location[Player] = (Target point of ability being cast)
      • Unit - Create 1 Location for (Owner of caster[Player]) at Location[Player] facing Default building facing degrees
      • Unit - Add a (7.00 + (1.00 x (Real((Level of Blazing Pit for caster[Player]))))) second Generic expiration timer to (Last created unit)
      • Unit Group - Add (Last created unit) to Locatio_group[Player]
      • Trigger - Turn on Blazing Pit Copy <gen>
  • Blazing Pit Copy
    • Events
      • Unit - A unit Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Killing unit)) Equal to |c00FF0000Flaming Sorceress|r
          • (Unit-type of (Killing unit)) Equal to Flaming warior (Level 1)
          • (Unit-type of (Killing unit)) Equal to Flaming warior (Level 2)
          • (Unit-type of (Killing unit)) Equal to Flaming warior (Level 3)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (All units of Locatio_group[Player] are dead) Equal to False
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (All units of Locatio_group[Player] are dead) Equal to False
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Blazing Pit for caster[Player]) Equal to 1
                  • (Number of living Flaming warior (Level 1) units owned by (Owner of caster[Player])) Less than or equal to 3
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Unit-type of (Dying unit)) Equal to Gargolyte(Lv.2)
                      • (Unit-type of (Dying unit)) Equal to Ghoul(Lv.2)
                      • (Unit-type of (Dying unit)) Equal to Skeleton Warrior(Lv.2)
                      • (Unit-type of (Dying unit)) Equal to Necromancer(Lv.3)
                      • (Unit-type of (Dying unit)) Equal to Chaos Flame(Lv.3)
                      • (Unit-type of (Dying unit)) Equal to Dead Spirit(Lv.3)
                      • (Unit-type of (Dying unit)) Equal to Dead Spirit(Lv.3)
                      • (Unit-type of (Dying unit)) Equal to Banshee(Lv.4)
                      • (Unit-type of (Dying unit)) Equal to Shadow Rider(Lv.4)
                      • (Unit-type of (Dying unit)) Equal to Lonely Ghost(Lv.4)
                      • (Unit-type of (Dying unit)) Equal to Shadow Destroyer(Lv.5)
                      • (Unit-type of (Dying unit)) Equal to Balnazzar(Lv.5)
                      • (Unit-type of (Dying unit)) Equal to Blazing Skeleton(Lv.5)
                      • (Unit-type of (Dying unit)) Equal to Frost Wyrm(Lv.5)
                • Then - Actions
                  • Unit Group - Pick every unit in Locatio_group[Player] and do (Actions)
                    • Loop - Actions
                      • Unit - Create 1 Flaming warior (Level 1) for (Owner of caster[Player]) at (Position of (Picked unit)) facing Default building facing degrees
                      • Special Effect - Create a special effect at (Position of (Last created unit)) using Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • Unit - Add a 10.00 second Generic expiration timer to (Last created unit)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • (Level of Blazing Pit for caster[Player]) Equal to 2
                      • (Number of living Flaming warior (Level 2) units owned by (Owner of caster[Player])) Less than or equal to 5
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Unit-type of (Dying unit)) Equal to Gargolyte(Lv.2)
                          • (Unit-type of (Dying unit)) Equal to Ghoul(Lv.2)
                          • (Unit-type of (Dying unit)) Equal to Skeleton Warrior(Lv.2)
                          • (Unit-type of (Dying unit)) Equal to Necromancer(Lv.3)
                          • (Unit-type of (Dying unit)) Equal to Chaos Flame(Lv.3)
                          • (Unit-type of (Dying unit)) Equal to Dead Spirit(Lv.3)
                          • (Unit-type of (Dying unit)) Equal to Dead Spirit(Lv.3)
                          • (Unit-type of (Dying unit)) Equal to Banshee(Lv.4)
                          • (Unit-type of (Dying unit)) Equal to Shadow Rider(Lv.4)
                          • (Unit-type of (Dying unit)) Equal to Lonely Ghost(Lv.4)
                          • (Unit-type of (Dying unit)) Equal to Shadow Destroyer(Lv.5)
                          • (Unit-type of (Dying unit)) Equal to Balnazzar(Lv.5)
                          • (Unit-type of (Dying unit)) Equal to Blazing Skeleton(Lv.5)
                          • (Unit-type of (Dying unit)) Equal to Frost Wyrm(Lv.5)
                • Then - Actions
                  • Unit Group - Pick every unit in Locatio_group[Player] and do (Actions)
                    • Loop - Actions
                      • Unit - Create 1 Flaming warior (Level 2) for (Owner of caster[Player]) at (Position of (Picked unit)) facing Default building facing degrees
                      • Special Effect - Create a special effect at (Position of (Last created unit)) using Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • Unit - Add a 16.00 second Generic expiration timer to (Last created unit)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • (Level of Blazing Pit for caster[Player]) Equal to 3
                      • (Number of living Flaming warior (Level 3) units owned by (Owner of caster[Player])) Less than or equal to 7
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Unit-type of (Dying unit)) Equal to Gargolyte(Lv.2)
                          • (Unit-type of (Dying unit)) Equal to Ghoul(Lv.2)
                          • (Unit-type of (Dying unit)) Equal to Skeleton Warrior(Lv.2)
                          • (Unit-type of (Dying unit)) Equal to Necromancer(Lv.3)
                          • (Unit-type of (Dying unit)) Equal to Chaos Flame(Lv.3)
                          • (Unit-type of (Dying unit)) Equal to Dead Spirit(Lv.3)
                          • (Unit-type of (Dying unit)) Equal to Banshee(Lv.4)
                          • (Unit-type of (Dying unit)) Equal to Shadow Rider(Lv.4)
                          • (Unit-type of (Dying unit)) Equal to Lonely Ghost(Lv.4)
                          • (Unit-type of (Dying unit)) Equal to Shadow Destroyer(Lv.5)
                          • (Unit-type of (Dying unit)) Equal to Balnazzar(Lv.5)
                          • (Unit-type of (Dying unit)) Equal to Blazing Skeleton(Lv.5)
                          • (Unit-type of (Dying unit)) Equal to Frost Wyrm(Lv.5)
                • Then - Actions
                  • Unit Group - Pick every unit in Locatio_group[Player] and do (Actions)
                    • Loop - Actions
                      • Unit - Create 1 Flaming warior (Level 3) for (Owner of caster[(Player number of (Owner of (Killing unit)))]) at (Position of (Picked unit)) facing Default building facing degrees
                      • Special Effect - Create a special effect at (Position of (Last created unit)) using Objects\Spawnmodels\Human\FragmentationShards\FragBoomSpawn.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • Unit - Add a 24.00 second Generic expiration timer to (Last created unit)
                • Else - Actions
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (All units of Locatio_group[Player] are dead) Equal to True
        • Then - Actions
          • Unit Group - Remove all units of Locatio_group[Player] from Locatio_group[Player]
          • Custom script: set udg_Player =0
          • Custom script: call DestroyGroup(udg_Locatio_group[udg_Player])
          • Custom script: call RemoveLocation(udg_Location[udg_Player])
          • Trigger - Turn off Blazing Pit Copy <gen>
        • Else - Actions

Locatio is the unit_group variables

In fact,my ability is not completely broken.But just my unit spawn in the wrong position.
For example,when player 1 and player 2 use the spell simultaneously, although the enemies is killed by player 1,but the unit spawn at the player 2 target point of ability being cast,but the summoned unit is still belongs to player 1
Sry if my English is bad
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,387
There are multiple issues in your trigger.
The main one is that the ability is not MPI, because in your "Blazing Pit Copy" trigger you use everywhere the Player variable as index for your arrays, but nowhere in that trigger do you set value to this variable. The value of the Player variable that is used in "Blazing Pit Copy" trigger will actually be the last value you assigned to this variable in "Blazing Pit" trigger - which is wrong.
Do something like the following at the start of your "Blazing Pit Copy" trigger:
  • Set Player = (Player number of (Owner of (Killing unit)))

Another issue is that at the end of the "Blazing Pit Copy" trigger, you do this:
  • Custom script: call DestroyGroup(udg_Locatio_group[udg_Player])

Nowhere in your two triggers are you creating the unit group that is assigned to Locatio_group[Player] - you only presume such group exists and add units to it.
So once the spell ends completely for some player (meaning: there are no living units in the unit group) and the group is destroyed, the next time the same player casts the spell it will not work.


Fixing the two things above should make the spell work. But there are some other parts worth looking at:
1. Can the caster at any point in the game cast this spell more often than once every "(7.00 + (1.00 x (Real((Level of Blazing Pit for caster[Player])))))" seconds? If so, then this spell should be MUI instead of MPI.

2. If the spell should be MPI (and not MUI), then the only unit ever added to Locatio_group[Player] is the "Location" unit created in "Blazing Pit" trigger. If that is so, then there is no need to have Locatio_group[] array to be of type Unit Group. What you actually need is to make it a Unit array.

3. You do this in your first trigger:
  • Set Location[Player] = (Target point of ability being cast)
, but you don't use it anywhere, except when creating the Location unit, thus you should destroy the location in the first trigger

4. When creating Flaming Warrior in your second trigger, instead of setting the owner the flaming warrior like this: "Owner of caster[(Player number of (Owner of (Killing unit)))]" you can simplify it to only to "(Owner of (Killing unit))"

5. The spell will work incorrectly if an instance of the spell is active for the player and he levels up the spell. That is because you do not store in any variable the level of the spell when a unit casts it. The time between cast of the ability and its end can last up to 17 seconds (at least if max level is 10). In that 17 seconds interval the caster is free to level up the ability.

6. You should think about re-arranging your conditions in the second trigger. The list of OR conditions, where you check the unit-type of (Dying unit) seems to be same for every level of the ability. Therefore it makes sense and also makes your life easier if you check the type of (Dying unit) only once and if the condition is true, you then check the level and number of Flaming warrior units in nested IF/Then/Else blocks.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Dying unit)) Equal to Gargolyte(Lv.2)
          • ... etc.
    • Then - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Blazing Pit for caster[Player]) Equal to 1
          • (Number of living Flaming warior (Level 1) units owned by (Owner of caster[Player])) Less than or equal to 3
        • Then - Actions
          • ... do actions for level 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blazing Pit for caster[Player]) Equal to 2
              • (Number of living Flaming warior (Level 1) units owned by (Owner of caster[Player])) Less than or equal to 5
            • Then - Actions
              • ... do actions for level 2
            • Else - Actions
              • ... etc

Further going along with that, you don't actually need these conditions for each level:
  • (Level of Blazing Pit for caster[Player]) Equal to 2
  • (Number of living Flaming warior (Level 1) units owned by (Owner of caster[Player])) Less than or equal to 5

You can actually create an initialization trigger that will configure your spell / populate constant variables like this:
  • Blazing Pit Initialization
    • Events
      • Map initalization
    • Conditions
    • Actions
      • // this is unit-type array. Note that the index in the array matches the intended spell level for which the unit should be used:
      • Set BlazingPitUnitType[1] = Flaming warior (Level 1)
      • Set BlazingPitUnitType[2] = Flaming warior (Level 2)
      • Set BlazingPitUnitType[3] = Flaming warior (Level 3)
      • //this is real array
      • Set BlazingPitExpirationTimer[1] = 10.00
      • Set BlazingPitExpirationTimer[2] = 16.00
      • Set BlazingPitExpirationTimer[3] = 24.00
      • //this is int
      • Set MaxUnitsPerLevel = 2

Then in your "Blazing Pit Copy" trigger you can create Flaming warrior like this:
  • Set abilityLevel = (Level of Blazing Pit for caster[Player])
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Number of living BlazingPitUnitType[abilityLevel] units owned by (Owner of caster[Player])) Less than or equal to (1 + (MaxUnitsPerLevel * abilityLevel))
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Dying unit)) Equal to Gargolyte(Lv.2)
          • ... etc.
    • Then - Actions
      • Unit - Create 1 BlazingPitUnitType[abilityLevel] for (Owner of caster[Player]) at (Position of (Picked unit)) facing Default building facing degrees
      • Special Effect - Create a special effect at (Position of (Last created unit)) using Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Add a BlazingPitExpirationTimer[abilityLevel] second Generic expiration timer to (Last created unit)
    • Else - Actions

This has the benefit that you don't need to copy'n'paste the same code over and over and if you ever decide to add 4th level to this ability, all you need to do is add the following in the initialization trigger
  • Set BlazingPitUnitType[4] = some unit for level 4
  • Set BlazingPitExpirationTimer[4] = duration of the level 4 unit

7. Instead of having multiple conditions where you check if unit group has/has not only dead units via (All units of Locatio_group[Player] are dead) Equal to False it is always better to have another trigger which fires when a unit of type "Location" has died. You can then perform the following actions in that trigger
  • Unit Group - Remove all units of Locatio_group[Player] from Locatio_group[Player]
  • Unit Group - Remove all units of Locatio_group[Player] from Locatio_group[Player]
  • Custom script: set udg_Player =0
  • Custom script: call DestroyGroup(udg_Locatio_group[udg_Player])
  • Custom script: call RemoveLocation(udg_Location[udg_Player])
  • Trigger - Turn off Blazing Pit Copy <gen>

Since you also seem to be trying to clean up memory leaks, the following actions will still leak:
this leaks a unit group:
  • (Number of living Flaming warior (Level 1) units owned by (Owner of caster[Player])) Less than or equal to 3

these leak a location:
  • Unit - Create 1 Flaming warior (Level 1) for (Owner of caster[Player]) at (Position of (Picked unit)) facing Default building facing degrees
  • Special Effect - Create a special effect at (Position of (Last created unit)) using Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
 
Last edited:
Level 2
Joined
Jun 13, 2020
Messages
16
There are multiple issues in your trigger.
The main one is that the ability is not MPI, because in your "Blazing Pit Copy" trigger you use everywhere the Player variable as index for your arrays, but nowhere in that trigger do you set value to this variable. The value of the Player variable that is used in "Blazing Pit Copy" trigger will actually be the last value you assigned to this variable in "Blazing Pit" trigger - which is wrong.
Do something like the following at the start of your "Blazing Pit Copy" trigger:
  • Set Player = (Player number of (Owner of (Killing unit)))

Another issue is that at the end of the "Blazing Pit Copy" trigger, you do this:
  • Custom script: call DestroyGroup(udg_Locatio_group[udg_Player])

Nowhere in your two triggers are you creating the unit group that is assigned to Locatio_group[Player] - you only presume such group exists and add units to it.
So once the spell ends completely for some player (meaning: there are no living units in the unit group) and the group is destroyed, the next time the same player casts the spell it will not work.


Fixing the two things above should make the spell work. But there are some other parts worth looking at:
1. Can the caster at any point in the game cast this spell more often than once every "(7.00 + (1.00 x (Real((Level of Blazing Pit for caster[Player])))))" seconds? If so, then this spell should be MUI instead of MPI.

2. If the spell should be MPI (and not MUI), then the only unit ever added to Locatio_group[Player] is the "Location" unit created in "Blazing Pit" trigger. If that is so, then there is no need to have Locatio_group[] array to be of type Unit Group. What you actually need is to make it a Unit array.

3. You do this in your first trigger:
  • Set Location[Player] = (Target point of ability being cast)
, but you don't use it anywhere, except when creating the Location unit, thus you should destroy the location in the first trigger

4. When creating Flaming Warrior in your second trigger, instead of setting the owner the flaming warrior like this: "Owner of caster[(Player number of (Owner of (Killing unit)))]" you can simplify it to only to "(Owner of (Killing unit))"

5. The spell will work incorrectly if an instance of the spell is active for the player and he levels up the spell. That is because you do not store in any variable the level of the spell when a unit casts it. The time between cast of the ability and its end can last up to 17 seconds (at least if max level is 10). In that 17 seconds interval the caster is free to level up the ability.

6. You should think about re-arranging your conditions in the second trigger. The list of OR conditions, where you check the unit-type of (Dying unit) seems to be same for every level of the ability. Therefore it makes sense and also makes your life easier if you check the type of (Dying unit) only once and if the condition is true, you then check the level and number of Flaming warrior units in nested IF/Then/Else blocks.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Dying unit)) Equal to Gargolyte(Lv.2)
          • ... etc.
    • Then - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Blazing Pit for caster[Player]) Equal to 1
          • (Number of living Flaming warior (Level 1) units owned by (Owner of caster[Player])) Less than or equal to 3
        • Then - Actions
          • ... do actions for level 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blazing Pit for caster[Player]) Equal to 2
              • (Number of living Flaming warior (Level 1) units owned by (Owner of caster[Player])) Less than or equal to 5
            • Then - Actions
              • ... do actions for level 2
            • Else - Actions
              • ... etc

Further going along with that, you don't actually need these conditions for each level:
  • (Level of Blazing Pit for caster[Player]) Equal to 2
  • (Number of living Flaming warior (Level 1) units owned by (Owner of caster[Player])) Less than or equal to 5

You can actually create an initialization trigger that will configure your spell / populate constant variables like this:
  • Blazing Pit Initialization
    • Events
      • Map initalization
    • Conditions
    • Actions
      • // this is unit-type array. Note that the index in the array matches the intended spell level for which the unit should be used:
      • Set BlazingPitUnitType[1] = Flaming warior (Level 1)
      • Set BlazingPitUnitType[2] = Flaming warior (Level 2)
      • Set BlazingPitUnitType[3] = Flaming warior (Level 3)
      • //this is real array
      • Set BlazingPitExpirationTimer[1] = 10.00
      • Set BlazingPitExpirationTimer[2] = 16.00
      • Set BlazingPitExpirationTimer[3] = 24.00
      • //this is int
      • Set MaxUnitsPerLevel = 2

Then in your "Blazing Pit Copy" trigger you can create Flaming warrior like this:
  • Set abilityLevel = (Level of Blazing Pit for caster[Player])
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Number of living BlazingPitUnitType[abilityLevel] units owned by (Owner of caster[Player])) Less than or equal to (1 + (MaxUnitsPerLevel * abilityLevel))
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Dying unit)) Equal to Gargolyte(Lv.2)
          • ... etc.
    • Then - Actions
      • Unit - Create 1 BlazingPitUnitType[abilityLevel] for (Owner of caster[Player]) at (Position of (Picked unit)) facing Default building facing degrees
      • Special Effect - Create a special effect at (Position of (Last created unit)) using Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Add a BlazingPitExpirationTimer[abilityLevel] second Generic expiration timer to (Last created unit)
    • Else - Actions

This has the benefit that you don't need to copy'n'paste the same code over and over and if you ever decide to add 4th level to this ability, all you need to do is add the following in the initialization trigger
  • Set BlazingPitUnitType[4] = some unit for level 4
  • Set BlazingPitExpirationTimer[4] = duration of the level 4 unit

7. Instead of having multiple conditions where you check if unit group has/has not only dead units via (All units of Locatio_group[Player] are dead) Equal to False it is always better to have another trigger which fires when a unit of type "Location" has died. You can then perform the following actions in that trigger
  • Unit Group - Remove all units of Locatio_group[Player] from Locatio_group[Player]
  • Unit Group - Remove all units of Locatio_group[Player] from Locatio_group[Player]
  • Custom script: set udg_Player =0
  • Custom script: call DestroyGroup(udg_Locatio_group[udg_Player])
  • Custom script: call RemoveLocation(udg_Location[udg_Player])
  • Trigger - Turn off Blazing Pit Copy <gen>

Since you also seem to be trying to clean up memory leaks, the following actions will still leak:
this leaks a unit group:
  • (Number of living Flaming warior (Level 1) units owned by (Owner of caster[Player])) Less than or equal to 3

these leak a location:
  • Unit - Create 1 Flaming warior (Level 1) for (Owner of caster[Player]) at (Position of (Picked unit)) facing Default building facing degrees
  • Special Effect - Create a special effect at (Position of (Last created unit)) using Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
Erm thk for ur suggestions.After some modifications,my trigger still does not work well,can you give more suggestions?


Rich (BB code):
  • Ability Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Blazing Pit --------
      • Set Unit_Type[1] = Fire hound (Level 1)
      • Set Unit_Type[2] = Fire hound (Level 2)
      • Set Unit_Type[3] = Fire hound (Level 3)
      • Set UnitDuration[1] = 10.00
      • Set UnitDuration[2] = 16.00
      • Set UnitDuration[1] = 24.00
      • Set MaxUnitPerLevel = 2
  • Blazing Pit
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Blazing Pit
    • Actions
      • Set Player = (Player number of (Owner of (Killing unit)))
      • Set caster[Player] = (Triggering unit)
      • Set Location[Player] = (Target point of ability being cast)
      • Set AbilityLevel = (Level of Blazing Pit for caster[Player])
      • Unit - Create 1 Location for (Owner of caster[Player]) at Location[Player] facing Default building facing degrees
      • Unit - Add a (7.00 + (1.00 x (Real(AbilityLevel)))) second Generic expiration timer to (Last created unit)
      • Trigger - Turn on Blazing Pit Copy <gen>
  • Blazing Pit Copy
    • Events
      • Unit - A unit Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Killing unit)) Equal to |c00FF0000Flaming Sorceress|r
          • (Unit-type of (Killing unit)) Equal to Fire hound (Level 1)
          • (Unit-type of (Killing unit)) Equal to Fire hound (Level 2)
          • (Unit-type of (Killing unit)) Equal to Fire hound (Level 3)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of living Unit_Type[AbilityLevel] units owned by (Owner of caster[Player])) Less than (1 + (AbilityLevel x 2))
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Dying unit)) Equal to Gargolyte(Lv.2)
              • (Unit-type of (Dying unit)) Equal to Ghoul(Lv.2)
              • (Unit-type of (Dying unit)) Equal to Skeleton Warrior(Lv.2)
              • (Unit-type of (Dying unit)) Equal to Necromancer(Lv.3)
              • (Unit-type of (Dying unit)) Equal to Chaos Flame(Lv.3)
              • (Unit-type of (Dying unit)) Equal to Dead Spirit(Lv.3)
              • (Unit-type of (Dying unit)) Equal to Dead Spirit(Lv.3)
              • (Unit-type of (Dying unit)) Equal to Banshee(Lv.4)
              • (Unit-type of (Dying unit)) Equal to Shadow Rider(Lv.4)
              • (Unit-type of (Dying unit)) Equal to Lonely Ghost(Lv.4)
              • (Unit-type of (Dying unit)) Equal to Shadow Destroyer(Lv.5)
              • (Unit-type of (Dying unit)) Equal to Balnazzar(Lv.5)
              • (Unit-type of (Dying unit)) Equal to Blazing Skeleton(Lv.5)
              • (Unit-type of (Dying unit)) Equal to Frost Wyrm(Lv.5)
        • Then - Actions
          • Unit - Create 1 Unit_Type[AbilityLevel] for (Owner of caster[Player]) at Location[Player] facing Default building facing degrees
          • Unit - Add a UnitDuration[AbilityLevel] second Raise Dead expiration timer to (Last created unit)
          • Special Effect - Create a special effect at Location[Player] using Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
  • Blazing Pit turn off
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Location
      • (Dying unit) Equal to LocationUnit[Player]
    • Actions
      • Custom script: set udg_Player =0
      • Custom script: call RemoveLocation(udg_Location[udg_Player])
      • Trigger - Turn off Blazing Pit Copy <gen>
 
Last edited:
Level 2
Joined
Jun 13, 2020
Messages
16
Erm,just now I realised that I miss type the 3 into 1 and this cause my trigger fail to work properly
set.gif
Set UnitDuration[1] = 24.00
So I think my trigger is working fine now but I don't know my trigger got any memory leak or not?
 
Level 25
Joined
Sep 26, 2009
Messages
2,387
Add this:
  • Set Player = (Player number of (Owner of (Killing unit)))
  • Set AbilityLevel = (Level of Blazing Pit for caster[Player])
to the start of your "Blazing Pit Copy" trigger


In your "Blazing Pit" trigger change this:
  • Set Player = (Player number of (Owner of (Killing unit)))

to this:
  • Set Player = (Player number of (Owner of (Triggering unit)))

In your "Blazing Pit turn off" this condition:
  • (Dying unit) Equal to LocationUnit[Player]
May not work correctly (the Player variable may have different value than you expected).
You want something like this:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Location
    • Actions
      • For each (Integer A) from 1 to 28, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to LocationUnit[(Integer A)]
            • Then - Actions
              • Custom script: set udg_Player =0
              • Custom script: call RemoveLocation(udg_Location[udg_Player])
            • Else - Actions
The loop goes from 1 to 28 to check each player (including neutrals). If you don't want neutrals, you can set the loop to go only from 1 to 24.
Notice the following action is missing:
  • Trigger - Turn off Blazing Pit Copy <gen>
That is because this only breaks things (if one instance of the spell ends while another instance is active, you would still globally turn off the trigger, so your second active instance would no longer create any skeletons)
 
Level 2
Joined
Jun 13, 2020
Messages
16
Add this:
  • Set Player = (Player number of (Owner of (Killing unit)))
  • Set AbilityLevel = (Level of Blazing Pit for caster[Player])
to the start of your "Blazing Pit Copy" trigger


In your "Blazing Pit" trigger change this:
  • Set Player = (Player number of (Owner of (Killing unit)))

to this:
  • Set Player = (Player number of (Owner of (Triggering unit)))

In your "Blazing Pit turn off" this condition:
  • (Dying unit) Equal to LocationUnit[Player]
May not work correctly (the Player variable may have different value than you expected).
You want something like this:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Location
    • Actions
      • For each (Integer A) from 1 to 28, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to LocationUnit[(Integer A)]
            • Then - Actions
              • Custom script: set udg_Player =0
              • Custom script: call RemoveLocation(udg_Location[udg_Player])
            • Else - Actions
The loop goes from 1 to 28 to check each player (including neutrals). If you don't want neutrals, you can set the loop to go only from 1 to 24.
Notice the following action is missing:
  • Trigger - Turn off Blazing Pit Copy <gen>
That is because this only breaks things (if one instance of the spell ends while another instance is active, you would still globally turn off the trigger, so your second active instance would no longer create any skeletons)
Thk alot,my trigger finally working correctly.😀😀😀
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
That For Loop from 1 to 28 is super overkill. You can simply do this:
  • Events
  • Unit - A unit Dies
  • Conditions
  • (Unit-type of (Triggering unit)) Equal to Location
  • Actions
  • Set Player = (Player number of (Owner of (Triggering unit)))
  • Custom script: call RemoveLocation(udg_Location[udg_Player])
Also, there's no reason for setting Player back to 0. It's value will always be Set before it's used, so it's not like it will have the wrong value or something.

Additionally, this trigger will break (and leak a Point) if a Player is able to create more than one Location unit at a time. So make sure the cooldown of the ability is longer than the duration and that you a player only ever has 1 of these units at a time.
 
Last edited:
Status
Not open for further replies.
Top