• 🏆 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] Problem With Custom Spells And Gui

Status
Not open for further replies.
Level 2
Joined
Oct 30, 2009
Messages
20
[SOLVED] Problem With Custom Spells And Gui

alright, so here is my problem.

I have changed the siphon mana spell to siphon health. I have also changed the battle roar spell to add damage. The battle roar and siphon mana spells work fine on their own, but when i put them together in a single tower it becomes tricky. Now this is probably the dumb way to do it but here is what i have

(Please dont tell me about leaks and things, its a wip and beta code)

  • Reaper Tower
  • Events
  • Unit - A unit owned by Player 9 (Gray) Is attacked
  • Unit - A unit owned by Player 10 (Light Blue) Is attacked
  • Conditions
  • (Unit-type of (Attacking unit)) Equal to (==) Reaper Tower
  • Actions
  • Unit Group - Pick every unit in (Random 1 units from (Units within 700.00 of (Position of (Attacking unit)) matching (((Matching unit) is dead) Equal to (==) True))) and do (Actions)
    • Loop - Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Attacking unit)) Equal to (==) Reaper Tower
        • Then - Actions
          • Unit - Remove Invulnerable (Neutral) from (Attacking unit)
          • Unit - Set life of (Attacking unit) to 100.00
          • Unit - Set mana of (Attacking unit) to 1.00
          • Unit - Order (Attacking unit) to Human Blood Mage - Siphon Mana (Attacked unit)
          • Wait until ((Life of (Attacking unit)) Equal to (==) 600.00), checking every 1.00 seconds
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Life of (Attacking unit)) Equal to (==) 600.00
              • Then - Actions
                • Unit - Set level of Extract Soul for (Attacking unit) to 10
                • Unit - Set mana of (Attacking unit) to 1.00
                • Unit - Order (Attacking unit) to Special Rexxar - Battle Roar
                • Unit - Add Invulnerable (Neutral) to (Attacking unit)
              • Else - Actions
        • Else - Actions
And the Spell Can Target Air, Enemy, Ground, Not Self, Organic (the spell soul reap)

The Second Trigger (For Battle roar)
  • Bones Tower
  • Events
  • Unit - A unit owned by Player 9 (Gray) Is attacked
  • Unit - A unit owned by Player 10 (Light Blue) Is attacked
  • Conditions
    • Multiple ConditionsOr - Any (Conditions) are true
      • Conditions
        • (Unit-type of (Attacking unit)) Equal to (==) Bones Tower
        • (Unit-type of (Attacking unit)) Equal to (==) Reaper Tower
  • Unit Group - Pick every unit in (Random 1 units from (Units within 700.00 of (Position of (Attacking unit)) matching (((Matching unit) is dead) Equal to (==) True))) and do (Actions)
    • Loop - Actions
      • Unit - Set the custom value of (Attacking unit) to ((Custom value of (Attacking unit)) + 1)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Custom value of (Attacking unit)) Equal to (==) 2
          • Then - Actions
            • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\NightElf\BattleRoar\RoarCaster.mdl
            • Special Effect - Destroy (Last created special effect)
            • Unit - Remove (Picked unit) from the game
            • Unit - Set level of Extract Soul for (Attacking unit) to ((Level of Extract Soul for (Attacking unit)) + 1)
            • Unit - Set mana of (Attacking unit) to 1.00
            • Unit - Order (Attacking unit) to Special Rexxar - Battle Roar
          • Else - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Custom value of (Attacking unit)) Equal to (==) 4
              • Then - Actions
                • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\NightElf\BattleRoar\RoarCaster.mdl
                • Special Effect - Destroy (Last created special effect)
                • Unit - Remove (Picked unit) from the game
                • Unit - Set level of Extract Soul for (Attacking unit) to ((Level of Extract Soul for (Attacking unit)) + 1)
                • Unit - Set mana of (Attacking unit) to 1.00
                • Unit - Order (Attacking unit) to Special Rexxar - Battle Roar
              • Else - Actions
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Custom value of (Attacking unit)) Equal to (==) 6
                  • Then - Actions
                    • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\NightElf\BattleRoar\RoarCaster.mdl
                    • Special Effect - Destroy (Last created special effect)
                    • Unit - Remove (Picked unit) from the game
                    • Unit - Set level of Extract Soul for (Attacking unit) to ((Level of Extract Soul for (Attacking unit)) + 1)
                    • Unit - Set mana of (Attacking unit) to 1.00
                    • Unit - Order (Attacking unit) to Special Rexxar - Battle Roar
                  • Else - Actions
                    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (Custom value of (Attacking unit)) Equal to (==) 8
                      • Then - Actions
                        • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\NightElf\BattleRoar\RoarCaster.mdl
                        • Special Effect - Destroy (Last created special effect)
                        • Unit - Remove (Picked unit) from the game
                        • Unit - Set level of Extract Soul for (Attacking unit) to ((Level of Extract Soul for (Attacking unit)) + 1)
                        • Unit - Set mana of (Attacking unit) to 1.00
                        • Unit - Order (Attacking unit) to Special Rexxar - Battle Roar
                      • Else - Actions
                        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • (Custom value of (Attacking unit)) Equal to (==) 10
                          • Then - Actions
                            • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\NightElf\BattleRoar\RoarCaster.mdl
                            • Special Effect - Destroy (Last created special effect)
                            • Unit - Remove (Picked unit) from the game
                            • Unit - Set level of Extract Soul for (Attacking unit) to ((Level of Extract Soul for (Attacking unit)) + 1)
                            • Unit - Set mana of (Attacking unit) to 1.00
                            • Unit - Order (Attacking unit) to Special Rexxar - Battle Roar
                          • Else - Actions
                            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                              • If - Conditions
                                • (Custom value of (Attacking unit)) Equal to (==) 12
                                • (Unit-type of (Attacking unit)) Equal to (==) Reaper Tower
                              • Then - Actions
                                • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\NightElf\BattleRoar\RoarCaster.mdl
                                • Special Effect - Destroy (Last created special effect)
                                • Unit - Remove (Picked unit) from the game
                                • Unit - Set level of Extract Soul for (Attacking unit) to ((Level of Extract Soul for (Attacking unit)) + 1)
                                • Unit - Set mana of (Attacking unit) to 1.00
                                • Unit - Order (Attacking unit) to Special Rexxar - Battle Roar
                              • Else - Actions
                                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                  • If - Conditions
                                    • (Custom value of (Attacking unit)) Equal to (==) 14
                                    • (Unit-type of (Attacking unit)) Equal to (==) Reaper Tower
                                  • Then - Actions
                                    • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\NightElf\BattleRoar\RoarCaster.mdl
                                    • Special Effect - Destroy (Last created special effect)
                                    • Unit - Remove (Picked unit) from the game
                                    • Unit - Set level of Extract Soul for (Attacking unit) to ((Level of Extract Soul for (Attacking unit)) + 1)
                                    • Unit - Set mana of (Attacking unit) to 1.00
                                    • Unit - Order (Attacking unit) to Special Rexxar - Battle Roar
                                  • Else - Actions
                                    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                      • If - Conditions
                                        • (Custom value of (Attacking unit)) Equal to (==) 16
                                        • (Unit-type of (Attacking unit)) Equal to (==) Reaper Tower
                                      • Then - Actions
                                        • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\NightElf\BattleRoar\RoarCaster.mdl
                                        • Special Effect - Destroy (Last created special effect)
                                        • Unit - Remove (Picked unit) from the game
                                        • Unit - Set level of Extract Soul for (Attacking unit) to ((Level of Extract Soul for (Attacking unit)) + 1)
                                        • Unit - Set mana of (Attacking unit) to 1.00
                                        • Unit - Order (Attacking unit) to Special Rexxar - Battle Roar
                                      • Else - Actions
                                        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                          • If - Conditions
                                            • (Custom value of (Attacking unit)) Equal to (==) 18
                                            • (Unit-type of (Attacking unit)) Equal to (==) Reaper Tower
                                          • Then - Actions
                                            • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\NightElf\BattleRoar\RoarCaster.mdl
                                            • Special Effect - Destroy (Last created special effect)
                                            • Unit - Remove (Picked unit) from the game
                                            • Unit - Set level of Extract Soul for (Attacking unit) to ((Level of Extract Soul for (Attacking unit)) + 1)
                                            • Unit - Set mana of (Attacking unit) to 1.00
                                            • Unit - Order (Attacking unit) to Special Rexxar - Battle Roar
                                          • Else - Actions
                                            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                              • If - Conditions
                                                • (Custom value of (Attacking unit)) Equal to (==) 20
                                                • (Unit-type of (Attacking unit)) Equal to (==) Reaper Tower
                                              • Then - Actions
                                                • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\NightElf\BattleRoar\RoarCaster.mdl
                                                • Special Effect - Destroy (Last created special effect)
                                                • Unit - Remove (Picked unit) from the game
                                                • Unit - Set level of Extract Soul for (Attacking unit) to ((Level of Extract Soul for (Attacking unit)) + 1)
                                                • Unit - Set mana of (Attacking unit) to 1.00
                                                • Unit - Order (Attacking unit) to Special Rexxar - Battle Roar
                                              • Else - Actions
that can target friend, invulnerable, self

The problem is when the tower has to become invulnerable to siphon mana correctely. If i have the tower targeted as Invulnerable the siphon mana spell works but the battle roar does not. if i have it set as structure it gets attacked when its invulnerable. i dont usually have problems but this one is a toughy. Also before the Soul Reaper tower their is bones tower which shares the battle roar spell. if you need anymore info let me know ;)
 
Last edited:
I didn't fully understand your problem; what I understood is that, after the casting of Siphon Life, it doesn't apply the buff and the actual effect of Battle Roar. Since your unit becomes invulnerable with the ability Invulnerable (Neutral), go to Battle Roar ability and scroll to Targets Allowed. Include "Vulnerable" and "Invulnerable". What is more, you don't need to add the Invulnerable ability to the tower; you can use Unit - Make Unit Invulnerable action instead.
 
Level 2
Joined
Oct 30, 2009
Messages
20
ok so, i set the battle roar to invulnerable, vulnerable. it works now, but the siphon mana doesn't work anymore. I think it has to do with the hp, because invulnerable doesn't have hit points. any ideas?
 
Level 2
Joined
Oct 30, 2009
Messages
20
but thats not the problem. I have to remove the invulnerable for the Siphon life spell to work, because the wait is based on the health, it has to wait until it has full health which is siphoned. the problem is when the invulnerable is removed the units attack the tower while its siphoning health.
 
Level 2
Joined
Oct 30, 2009
Messages
20
i dont think you guys understand the problem, its not the time or wait thats the issue, i removed the pick unit since its not needed in that trigger anymore. The thing is that i have to remove the invulnerable while siphoning mana, and the tower gets atttacked.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
I'll be honest all I did was read Anachron's post and then yours. I hate reading GUI scripts. Also there's very little that I can do without having to copy your entire script back into GUI, since copying and pasting GUI code isn't possible.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Perhaps there's something wrong with how I'm testing it, but giving the Dark Ranger the Divine Shield ability does not halt the functionality of Life Drain in any way. I also tried emitting the invulnerability using Big Bad Voodoo, and Life Drain still worked fine.
 
Level 2
Joined
Oct 30, 2009
Messages
20
hmm fair enough. but i have a trigger after that, if the unit reaches full health after life drain it casts another ability
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Not sure. Your code seems unnecessarily long though, which could partially contribute to why I do not even want to start reading it. There are like 8 nested if-statements which makes it seem like there is redundancy. I've never really seen code that required that many nested if-statements in order to remain logical.

chanyman said:
  • Reaper Tower
  • Events
  • Unit - A unit owned by Player 9 (Gray) Is attacked
  • Unit - A unit owned by Player 10 (Light Blue) Is attacked
  • Conditions
  • (Unit-type of (Attacking unit)) Equal to (==) Reaper Tower
  • Actions
  • Unit Group - Pick every unit in (Random 1 units from (Units within 700.00 of (Position of (Attacking unit)) matching (((Matching unit) is dead) Equal to (==) True))) and do (Actions)
    • Loop - Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Attacking unit)) Equal to (==) Reaper Tower
        • Then - Actions
          • Unit - Remove Invulnerable (Neutral) from (Attacking unit)
          • Unit - Set life of (Attacking unit) to 100.00
          • Unit - Set mana of (Attacking unit) to 1.00
          • Unit - Order (Attacking unit) to Human Blood Mage - Siphon Mana (Attacked unit)
          • Wait until ((Life of (Attacking unit)) Equal to (==) 600.00), checking every 1.00 seconds
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Life of (Attacking unit)) Equal to (==) 600.00
              • Then - Actions
                • Unit - Set level of Extract Soul for (Attacking unit) to 10
                • Unit - Set mana of (Attacking unit) to 1.00
                • Unit - Order (Attacking unit) to Special Rexxar - Battle Roar
                • Unit - Add Invulnerable (Neutral) to (Attacking unit)
              • Else - Actions
        • Else - Actions

After a wait you cannot reference event responses such as (Attacking unit). Wait is converted to TriggerSleepAction, which kills whatever thread it is called in. Since event responses are specific to an individual thread, they cannot be referenced after that thread is destroyed (via TriggerSleepAction). What happens if you try setting those values to variables before the wait so that they can be referenced after?
 
Level 2
Joined
Oct 30, 2009
Messages
20
Thanks to those of you who helped me! I finally worked it out, if anyone should want to know how I did it. let me know ;). Even though you guys didnt directly give me the answer, you got me thinking on the right track! plus rep for you :)
 
Status
Not open for further replies.
Top