HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Problem with Massive Trigger

07-20-2004, 05:28 PM#1
mosarani
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        (Level of Demi  for (Casting unit)) Equal to 1
    Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                BOOLEANARRAY[1] Equal to True
            Then - Actions
                Unit Group - Pick every unit in (Units within 290.00 of POINT[6] matching ((((Matching unit) belongs to an enemy of Player 1 (Red)) Equal to True) and (((Matching unit) is A structure) Equal to False))) and do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ((Picked unit) is A Hero) Equal to True
                            Then - Actions
                                Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - ((0.15 x (Life of (Picked unit))) x 0.75))
                                Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\Undead\DeathandDecay\DeathandDecayTarget.mdl
                                Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                            Else - Actions
                                Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - ((0.15 x (Life of (Picked unit))) x 1.00))
                                Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\Undead\DeathandDecay\DeathandDecayTarget.mdl
                                Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
            Else - Actions
        Unit Group - Pick every unit in (Units within 290.00 of POINT[6] matching ((((Matching unit) belongs to an enemy of Player 1 (Red)) Equal to True) and (((Matching unit) is A structure) Equal to False))) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Picked unit) is A Hero) Equal to True
                    Then - Actions
                        Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - ((0.10 x (Life of (Picked unit))) x 0.75))
                        Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\Undead\DeathandDecay\DeathandDecayTarget.mdl
                    Else - Actions
                        Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - ((0.10 x (Life of (Picked unit))) x 1.00))
                        Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\Undead\DeathandDecay\DeathandDecayTarget.mdl
    Else - Actions

Basically it just damages units in an area based on their current hitpoints. There are three other if/then/elses similar to that that just use casting level equal to 2, 3, 4, etc. Booleanarray[1] is a boolean that is equal to true when the casting unit has a buff that makes him do bonus damage with his magic. When this buff is on it also makes a little graphic on the target to show that it's powered up. The problem is when booleanarray[1] is true the 15% health reduction then the 10% health reduction are both run, ending the targets' health at 76% or so. I tried placing skip remaining actions at the bottom of the part which is run when booleanarray[1] = true but it still ran both functions. I had a similar spell that was just aoe damage that i changed in this way and putting a skip remaining actions worked fine. How can I make it acknowledge only the first function?
07-20-2004, 07:17 PM#2
Milkman
Try splitting the code up, make it two triggers or don't make the first If statement so long, do more statements instead. This way some weird miss that nobody will see may be cleared out. Also try doing it all again in a different manner, that usually works.
07-20-2004, 10:29 PM#3
Anitarf
From the code you pasted here, it seems that the actions that take place if the unit doesn't have the buff aren't under the "else - actions", but happen anyway.

Other than that, you really don't need an if/then/else for every level of the ability; you can instead just use the "level of the ability" function in your code where you determine the ammount of damage dealt. For example, if the damage dealt by the spell was 10%, 15%, 20%, 25%..., you would just put, when reducing life, a function "((Life of (Picked unit)) - ((0.05 x (1 + (level of ability for (casting unit))) x (Life of (Picked unit))) x 0.75))"
07-21-2004, 04:50 AM#4
mosarani
Quote:
Originally Posted by Anitarf
From the code you pasted here, it seems that the actions that take place if the unit doesn't have the buff aren't under the "else - actions", but happen anyway.

Other than that, you really don't need an if/then/else for every level of the ability; you can instead just use the "level of the ability" function in your code where you determine the ammount of damage dealt. For example, if the damage dealt by the spell was 10%, 15%, 20%, 25%..., you would just put, when reducing life, a function "((Life of (Picked unit)) - ((0.05 x (1 + (level of ability for (casting unit))) x (Life of (Picked unit))) x 0.75))"

good point -_-