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

[Trigger] Problems with spell creating

Status
Not open for further replies.
Level 3
Joined
Apr 1, 2017
Messages
47
So I want to make this spell.

Mark of the Phoenix

Mark a unit, giving them partial characteristics of Phoenix. Marked units will be engulfed in flames, burning all nearby units, including themselves until they will meet their death. After that they will be reborn.|n|n|cffffcc00Level 1|r – can only target friendly, non-hero units; marked will be doing 6 damage to all nearby units each second and will be reborn with 50% of health and mana.|n|cffffcc00Level 2|r – can target any non-hero units; marked will be doing 8 damage to all nearby units each second and, if friendly will either be reborn with 75% or with 25% (if enemy) of health and mana.|n|cffffcc00Level 3|r – can target any non-hero units; marked will be doing 12 damage to all nearby units each second and will, be reborn with 100% of health and mana, if friendly; and with a Time Bomb that will deal 250 damage to all nearby units if casted on enemy unit.

I based it on Pitlord’s Doom ability (Probably not the best choice). After I started making triggers I faced many difficulties

  • Mark of The Phoenix Setup
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mark of the Phoenix
    • Actions
      • Set PhoenixCaster = (Casting unit)
      • Unit Group - Add (Target unit of ability being cast) to UnitsWithPhoenixMark
      • Hashtable - Save (Level of (Ability being cast) for (Triggering unit)) as 0 of (Key (Target unit of ability being cast)) in MarkOfPhoenixHash
      • Unit Group - Pick every unit in UnitsWithPhoenixMark and do (Set Loc3 = (Position of (Picked unit)))
  • Add to NearPhoenixMarked
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units within 600.00 of Loc3 matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is Mechanical) Equal to False))) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to NearPhoenixMarked
  • Mark of Phoenix main
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in NearPhoenixMarked and do (Actions)
        • Loop - Actions
          • Set Loc3 = (Position of (Picked unit))
          • Set LevelofMarkofPhoenix = (Load 0 of (Key (Picked unit)) from MarkOfPhoenixHash)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Picked unit) is alive) Equal to True
              • Then - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • LevelofMarkofPhoenix Equal to 1
                  • Then - Actions
                    • Unit - Cause (Picked unit) to damage circular area after 0.00 seconds of radius 1000.00 at Loc3, dealing 6.00 damage of attack type Normal and damage type Fire
                    • Game - Display to (All players) the text: 1
                  • Else - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • LevelofMarkofPhoenix Equal to 2
                      • Then - Actions
                        • Unit - Cause (Picked unit) to damage circular area after 0.00 seconds of radius 1000.00 at Loc3, dealing 8.00 damage of attack type Normal and damage type Fire
                        • Game - Display to (All players) the text: 2
                      • Else - Actions
                        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • LevelofMarkofPhoenix Equal to 3
                          • Then - Actions
                            • Unit - Cause (Picked unit) to damage circular area after 0.00 seconds of radius 1000.00 at Loc3, dealing 12.00 damage of attack type Normal and damage type Fire
                            • Game - Display to (All players) the text: 3
                          • Else - Actions
              • Else - Actions
                • Game - Display to (All players) the text: done
  • Phoenix reborn
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in UnitsWithPhoenixMark) Equal to True
    • Actions
      • Unit Group - Pick every unit in UnitsWithPhoenixMark and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LevelofMarkofPhoenix Equal to 1
            • Then - Actions
              • Game - Display to (All players) the text: Lvl1
                • Unit Group - Remove (Picked unit) from UnitsWithPhoenixMark
                • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in MarkOfPhoenixHash
                • Custom script: call RemoveLocation(udg_Loc3)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LevelofMarkofPhoenix Equal to 2
                • Then - Actions
                  • Game - Display to (All players) the text: Lvl 22
                  • Unit Group - Remove (Picked unit) from UnitsWithPhoenixMark
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in MarkOfPhoenixHash
                  • Custom script: call RemoveLocation(udg_Loc3)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LevelofMarkofPhoenix Equal to 3
                    • Then - Actions
                      • Game - Display to (All players) the text: Lvl 333
                      • Unit - Add a 7.00 second Generic expiration timer to (Picked unit)
                      • Unit - Create 1 Dummy Time Bomb Buff for (Owner of PhoenixCaster) at Loc3 facing Default building facing degrees
                      • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike (Picked unit)
                      • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
                    • Else - Actions
                      • Game - Display to (All players) the text: Broken :(
  • Phoenix Mark Time Bomb
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) has buff Time Bomb Buff) Equal to True
    • Actions
      • Unit Group - Pick every unit in (Units within 350.00 of Loc3 matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is Mechanical) Equal to False))) and do (Actions)
        • Loop - Actions
          • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 200.00)
          • Custom script: call RemoveLocation(udg_Loc3)
          • Unit Group - Remove (Picked unit) from UnitsWithPhoenixMark
          • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in MarkOfPhoenixHash

The biggest of them is that I don’t know a good way to resurrect a specific unit and also I don’t think that this spell is MUI and is leaking :\
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Doom also silences the target. You can add a hidden reincaranate ability, but then the unit won't really die (no death event, no experience).
Good thing about it is, that unit variables will still work for the revived unit. If you create a new unit, all your unit variables pointing to the dying unit would not point towards the new unit.
 
You can revive non-Hero units by using an Paladin ulti with 1 range, 1 target and an dummie unit which is teleported onto the dead unit and then cast it, the unit will remain its handleId and all custom stuff.
Beaware that the death type has to inlcude can be revived in object editor.

It's sadly not 100% safe:
there are some problems if you have large units and small ones which die inside the corpse of the big ones (collison size).
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
You can revive non-Hero units by using an Paladin ulti with 1 range, 1 target and an dummie unit which is teleported onto the dead unit and then cast it, the unit will remain its handleId and all custom stuff.
Beaware that the death type has to inlcude can be revived in object editor.

It's sadly not 100% safe:
there are some problems if you have large units and small ones which die inside the corpse of the big ones (collison size).
Also if the unit is exploded it cannot be revived as it is instantly removed.
 
Level 3
Joined
Apr 1, 2017
Messages
47
You can revive non-Hero units by using an Paladin ulti with 1 range, 1 target and an dummie unit which is teleported onto the dead unit and then cast it, the unit will remain its handleId and all custom stuff.
Beaware that the death type has to inlcude can be revived in object editor.

It's sadly not 100% safe:
there are some problems if you have large units and small ones which die inside the corpse of the big ones (collison size).

Is it possible to save the variable of dying unit type and just create a unit from it?
 
Last edited:
Level 8
Joined
Jan 28, 2016
Messages
486
There's this native that can get the unit type but I'm pretty sure it can only be accessed as a boolean when using GUI (unless you use custom script, obviously).

JASS:
constant native GetUnitTypeId       takes unit whichUnit returns integer

  • Test
    • Events
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
 
Level 3
Joined
Apr 1, 2017
Messages
47
Here, Mark of Phoenix spell basically done

  • Mark of The Phoenix Setup
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mark of the Phoenix based on slow (still bad ability :D)
    • Actions
      • Set PhoenixCaster = (Casting unit)
      • Unit Group - Add (Target unit of ability being cast) to UnitsWithPhoenixMark
      • Hashtable - Save (Level of (Ability being cast) for (Triggering unit)) as 0 of (Key (Target unit of ability being cast)) in ZMarkOfPhoenixHash
      • Unit Group - Pick every unit in UnitsWithPhoenixMark and do (Set Loc3 = (Position of (Picked unit)))
  • Add to NearPhoenixMarked
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units within 600.00 of Loc3 matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is Mechanical) Equal to False))) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to NearPhoenixMarked
  • Mark of Phoenix main
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in NearPhoenixMarked and do (Actions)
        • Loop - Actions
          • Set Loc3 = (Position of (Picked unit))
          • Set LevelofMarkofPhoenix = (Load 0 of (Key (Picked unit)) from ZMarkOfPhoenixHash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LevelofMarkofPhoenix Equal to 1
                • Then - Actions
                  • Unit - Cause (Picked unit) to damage circular area after 0.00 seconds of radius 1000.00 at Loc3, dealing 6.00 damage of attack type Normal and damage type Fire
                  • Game - Display to (All players) the text: 1
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LevelofMarkofPhoenix Equal to 2
                    • Then - Actions
                      • Unit - Cause (Picked unit) to damage circular area after 0.00 seconds of radius 1000.00 at Loc3, dealing 8.00 damage of attack type Normal and damage type Fire
                      • Game - Display to (All players) the text: 2
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • LevelofMarkofPhoenix Equal to 3
                        • Then - Actions
                          • Unit - Cause (Picked unit) to damage circular area after 0.00 seconds of radius 1000.00 at Loc3, dealing 12.00 damage of attack type Normal and damage type Fire
                          • Game - Display to (All players) the text: 3
                        • Else - Actions
            • Else - Actions
  • Phoenix reborn
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in UnitsWithPhoenixMark) Equal to True
    • Actions
      • Unit Group - Pick every unit in UnitsWithPhoenixMark and do (Actions)
        • Loop - Actions
          • Set PhoenixDie = (Unit-type of (Picked unit))
          • Set Loc4 = (Position of (Picked unit))
          • Set LevelofMarkofPhoenix = (Load 0 of (Key (Picked unit)) from ZMarkOfPhoenixHash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LevelofMarkofPhoenix Equal to 1
            • Then - Actions
              • Unit Group - Add (Picked unit) to PhoenixCorpse
              • Unit Group - Remove (Picked unit) from UnitsWithPhoenixMark
              • Unit - Create 1 PhoenixDie for (Owner of (Picked unit)) at Loc4 facing Default building facing degrees
              • Unit - Set life of (Last created unit) to 50.00%
              • Unit - Set mana of (Last created unit) to 50.00%
              • Unit - Hide (Last created unit)
              • Unit Group - Add (Last created unit) to PhoenixReborning
              • Hashtable - Save 7 as 1 of (Key (Last created unit)) in ZMarkOfPhoenixHash
              • Game - Display to (All players) the text: Lvl1
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in ZMarkOfPhoenixHash
              • Custom script: call RemoveLocation(udg_Loc3)
              • Custom script: call RemoveLocation(udg_Loc4)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LevelofMarkofPhoenix Equal to 2
                • Then - Actions
                  • Unit Group - Add (Picked unit) to PhoenixCorpse
                  • Unit Group - Remove (Picked unit) from UnitsWithPhoenixMark
                  • Unit - Create 1 PhoenixDie for (Owner of (Picked unit)) at Loc4 facing Default building facing degrees
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Owner of (Last created unit)) Equal to (Owner of PhoenixCaster)
                    • Then - Actions
                      • Unit - Set life of (Last created unit) to 75.00%
                      • Unit - Set mana of (Last created unit) to 75.00%
                    • Else - Actions
                      • Unit - Set life of (Last created unit) to 25.00%
                      • Unit - Set mana of (Last created unit) to 25.00%
                  • Unit - Hide (Last created unit)
                  • Unit Group - Add (Last created unit) to PhoenixReborning
                  • Hashtable - Save 7 as 1 of (Key (Last created unit)) in ZMarkOfPhoenixHash
                  • Unit Group - Add (Picked unit) to PhoenixReborning
                  • Game - Display to (All players) the text: Lvl 22
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in ZMarkOfPhoenixHash
                  • Custom script: call RemoveLocation(udg_Loc3)
                  • Custom script: call RemoveLocation(udg_Loc4)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LevelofMarkofPhoenix Equal to 3
                      • ((Owner of (Picked unit)) is an ally of Player 1 (Red)) Equal to False
                    • Then - Actions
                      • Unit Group - Add (Picked unit) to PhoenixCorpse
                      • Unit Group - Remove (Picked unit) from UnitsWithPhoenixMark
                      • Unit - Create 1 PhoenixDie for (Owner of (Picked unit)) at Loc4 facing Default building facing degrees
                      • Set PhoenixLastCreatedTimebomb = (Last created unit)
                      • Hashtable - Save Handle OfPhoenixLastCreatedTimebomb as 3 of (Key (Last created unit)) in ZMarkOfPhoenixHash
                      • Unit - Hide PhoenixLastCreatedTimebomb
                      • Unit Group - Add PhoenixLastCreatedTimebomb to PhoenixReborning
                      • Hashtable - Save 7 as 1 of (Key (Last created unit)) in ZMarkOfPhoenixHash
                      • Hashtable - Save 1 as 2 of (Key (Last created unit)) in ZMarkOfPhoenixHash
                        • Game - Display to (All players) the text: Enemy
                    • Else - Actions
                      • Unit Group - Add (Picked unit) to PhoenixCorpse
                        • Unit Group - Remove (Picked unit) from UnitsWithPhoenixMark
                        • Unit - Create 1 PhoenixDie for (Owner of (Picked unit)) at Loc4 facing Default building facing degrees
                        • Unit - Hide (Last created unit)
                        • Unit Group - Add (Last created unit) to PhoenixReborning
                        • Hashtable - Save 7 as 1 of (Key (Last created unit)) in ZMarkOfPhoenixHash
                        • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in ZMarkOfPhoenixHash
                        • Custom script: call RemoveLocation(udg_Loc3)
                        • Custom script: call RemoveLocation(udg_Loc4)
                        • Game - Display to (All players) the text: Ally
  • PhoenixTimer
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in PhoenixReborning and do (Actions)
        • Loop - Actions
          • Set PhoenixTimeBeforeReborn = (Load 1 of (Key (Picked unit)) from ZMarkOfPhoenixHash)
          • Set PhoenixPlayerCheck = (Load 2 of (Key (Picked unit)) from ZMarkOfPhoenixHash)
          • Set PhoenixTimeBombLoaded = (Load 3 of (Key (Picked unit)) in ZMarkOfPhoenixHash)
          • Game - Display to (All players) the text: (String(PhoenixPlayerCheck))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PhoenixPlayerCheck Not equal to 1
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • PhoenixTimeBeforeReborn Greater than 0
                • Then - Actions
                  • Game - Display to (All players) the text: (String(PhoenixTimeBeforeReborn))
                  • Hashtable - Save (PhoenixTimeBeforeReborn - 1) as 1 of (Key (Picked unit)) in ZMarkOfPhoenixHash
                • Else - Actions
                  • Unit - Unhide (Picked unit)
                  • Unit Group - Remove (Picked unit) from PhoenixReborning
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in ZMarkOfPhoenixHash
                  • Unit Group - Pick every unit in PhoenixCorpse and do (Actions)
                    • Loop - Actions
                      • Unit - Remove (Picked unit) from the game
                      • Unit Group - Remove (Picked unit) from PhoenixCorpse
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • PhoenixTimeBeforeReborn Greater than 0
                • Then - Actions
                  • Game - Display to (All players) the text: (String(PhoenixTimeBeforeReborn))
                  • Hashtable - Save (PhoenixTimeBeforeReborn - 1) as 1 of (Key (Picked unit)) in ZMarkOfPhoenixHash
                • Else - Actions
                  • Unit - Unhide PhoenixTimeBombLoaded
                  • Unit - Add a 7.00 second Generic expiration timer to PhoenixTimeBombLoaded
                  • Unit - Make PhoenixTimeBombLoaded Explode on death
                  • Unit - Create 1 Dummy Time Bomb Buff for (Owner of PhoenixCaster) at (Position of PhoenixTimeBombLoaded) facing Default building facing degrees
                  • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike PhoenixTimeBombLoaded
                  • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                  • Unit Group - Remove (Picked unit) from PhoenixReborning
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in ZMarkOfPhoenixHash
                  • Unit Group - Pick every unit in PhoenixCorpse and do (Actions)
                    • Loop - Actions
                      • Unit - Remove (Picked unit) from the game
                      • Unit Group - Remove (Picked unit) from PhoenixCorpse
  • Phoenix Mark Time Bomb
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) has buff Time Bomb Buff) Equal to True
    • Actions
      • Unit Group - Pick every unit in (Units within 350.00 of Loc4 matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is Mechanical) Equal to False))) and do (Actions)
        • Loop - Actions
          • Special Effect - Create a special effect at Loc4 using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
          • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 200.00)
          • Custom script: call RemoveLocation(udg_Loc3)
          • Custom script: call RemoveLocation(udg_Loc4)
          • Unit Group - Remove (Picked unit) from UnitsWithPhoenixMark
          • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in ZMarkOfPhoenixHash


Now I need you help me remove all leaks and make this spell in MUI. I’m still pretty new to hashstables :(
Also unit with mark still damages every unit despite matching unit type condition

And yes, you can save unit type of dying unit
 
Status
Not open for further replies.
Top