• 🏆 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] Gaah!! Need help debugging, it's driving me insane!!

Status
Not open for further replies.
Level 12
Joined
May 20, 2009
Messages
822
EDIT: Everything that's "Draft" is a Non-Complete Trigger. (For Future references, use them at your own discretion!)
For complete triggers, go to Post #15

Ignore the mess of it, I haven't been able to clean it up yet because I can't even get it to function.

What this is suppose to do is:

When the unit casts Immolation, it's suppose to do the following

1. Index the unit.
2. Check the level of the ability.
3. Save the level of the ability, Create a unit that uses a modified version of Shadow Strike, one with a negative value of movement speed reduction so it increases movement speed.
4. That unit is then killed via expiration timer.
5. Add the Ghost ability to the unit, so it is permanently invisible. (Can attack, cast spells, etc, and stay invisible.)
6. Remove the initial buff the ability gives, and the ability.
7. Add a dummy ability that is the "Toggle Off" part of the spell.
8. Set the level of that dummy ability to the level that was saved.

Then, when the order is ManaShield:

1. Get the level of the dummy spell.
2. Remove the dummy spell.
3. Add the original spell back.
4. Set the level of the original spell to the saved level.
5. Remove the "Speed Bonus" given by the dummy unit.
6. Remove Ghost from the unit.
7. Deindex.


  • Cloaking Index
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(immolation))
        • Then - Actions
          • Set CloakLevelMaxIndex = (CloakLevelMaxIndex + 1)
          • Set CloakingUnit[CloakLevelMaxIndex] = (Triggering unit)
          • Trigger - Turn on Cloaking Calc <gen>
          • For each (Integer CloakLevelInit) from 1 to CloakLevelMaxIndex, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Issued order) Equal to (Order(immolation))
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Ordered unit) has buff Cloaking ) Equal to True
                      • (Ordered unit) Equal to CloakingUnit[CloakLevelInit]
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 1
                        • Then - Actions
                          • Set CloakLevel[CloakLevelInit] = 1
                          • Set SpeedBonusApplied[CloakLevelInit] = True
                          • Unit - Create 1 Dummy Ability Unit 1 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
                          • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakLevelInit]
                          • Unit - Add a 1.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
                              • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 2
                            • Then - Actions
                              • Set CloakLevel[CloakLevelInit] = 2
                              • Set SpeedBonusApplied[CloakLevelInit] = True
                              • Unit - Create 1 Dummy Ability Unit 2 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
                              • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakLevelInit]
                              • Unit - Add a 1.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
                                  • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 3
                                • Then - Actions
                                  • Set CloakLevel[CloakLevelInit] = 3
                                  • Set SpeedBonusApplied[CloakLevelInit] = True
                                  • Unit - Create 1 Dummy Ability Unit 3 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
                                  • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakLevelInit]
                                  • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                                • Else - Actions
                      • Game - Display to (All players) the text: (String(CloakSpeedBonus[CloakLevelInit]))
                    • Else - Actions
                  • Unit - Add Ghost to CloakingUnit[CloakLevelInit]
                  • Unit - Remove Cloak from CloakingUnit[CloakLevelInit]
                  • Unit - Remove Cloaking buff from CloakingUnit[CloakLevelInit]
                  • Unit - Add Deactivate Cloaking to CloakingUnit[CloakLevelInit]
                  • Unit - Set level of Deactivate Cloaking for CloakingUnit[CloakLevelInit] to CloakLevel[CloakLevelInit]
                  • Set SpeedBonusApplied[CloakLevelInit] = True
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Issued order) Equal to (Order(manashield))
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Triggering unit) Equal to CloakingUnit[CloakLevelInit]
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 1
                        • Then - Actions
                          • Set CloakLevel[CloakLevelInit] = 1
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 2
                            • Then - Actions
                              • Set CloakLevel[CloakLevelInit] = 2
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 3
                                • Then - Actions
                                  • Set CloakLevel[CloakLevelInit] = 3
                                • Else - Actions
                      • Unit - Remove Deactivate Cloaking from (Triggering unit)
                      • Unit - Add Cloak to (Triggering unit)
                      • Unit - Set level of Cloak for (Triggering unit) to CloakLevel[CloakLevelInit]
                      • Unit - Remove Speed Bonus (1) buff from (Triggering unit)
                      • Unit - Remove Ghost from CloakingUnit[CloakLevelInit]
                      • Set CloakingUnit[CloakLevelInit] = CloakingUnit[CloakLevelMaxIndex]
                      • Set CloakingUnit[CloakLevelMaxIndex] = No unit
                      • Set CloakSpeedBonus[CloakLevelInit] = CloakSpeedBonus[CloakLevelMaxIndex]
                      • Set CloakSpeedBonus[CloakLevelMaxIndex] = 0.00
                      • Set CloakLevelMaxIndex = (CloakLevelMaxIndex - 1)
                    • Else - Actions
                • Else - Actions
        • Else - Actions


It WILL NOT remove the ability and add the new ability!! It WON'T set the level of the new ability! And it WON'T apply Ghost!
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,381
I believe the problem lies in how messy it is.
You have this:
Code:
If (Conditions)
    Issued order == immolation
Then (Actions)
    For each integer from X to Y do (Actions)
        Loop - Actions
            If (Conditions)
                Issued order == immolation
            Then (Actions)
                *do something*
            Else (Actions)
                *empty*

            If (Conditions)
                Issued order == manashield
            Then (Actions)
                *do something*
            Else (Actions)
                *empty*
Else (Actions)
    *empty*
As you can see, the order "manashield" will never pass, since it won't go through the first ITE, because it won't pass the condition "issued order == immolation".


Edit:
Also, those 3 ITEs you have there can be removed.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 1
    • Then - Actions
      • Set CloakLevel[CloakLevelInit] = 1
    • Else - Actions
      • ...next ITE
this all can be changed into simple line:
  • Set CloakLevel[CloakLevelInit] = Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]
 
Level 12
Joined
May 20, 2009
Messages
822
The problem for the speed bonus not being applied had to do with
  • ((Ordered unit) has buff Cloaking ) Equal to True
Maybe that doesn't work in the loop?

I started working on this today finally, so I'll post back in maybe an hour or two if I still have problems. (I was dangerously tired last night)

EDIT: Okay, why the fuck is this not working...?


  • Ranger Init
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())
      • Unit Group - Pick every unit in (Units of type Ranger) and do (Actions)
        • Loop - Actions
          • Unit - Remove Deactivate Cloaking from (Picked unit)


EDIT2: Hm...It appears you cannot remove abilities that haven't been learned yet...? That's unfortunate. Every turn it just doesn't want to work...
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,381
You destroy that trigger after the first time... how do you expect the trigger to work if it has been destroyed?
Yes, you can't unlearn abilities that are not yet learned.

Edit: There may be a small delay between "unit is issued order" and "unit has buff" - if that order (I guess it's immolation for this case) applies this buff. Maybe a 0.00 timer would solve this problem? It does with instant abilities that apply buff on other targets.
 
Level 12
Joined
May 20, 2009
Messages
822
You destroy that trigger after the first time... how do you expect the trigger to work if it has been destroyed?
Yes, you can't unlearn abilities that are not yet learned.

Edit: There may be a small delay between "unit is issued order" and "unit has buff" - if that order (I guess it's immolation for this case) applies this buff. Maybe a 0.00 timer would solve this problem? It does with instant abilities that apply buff on other targets.

There is a slight delay for the buff, but I don't think it'll matter for what I'm doing...Hopefully.

BTW, "Destroy Trigger" only removes the actual trigger from the map, but the instance of the trigger that did the destroying still runs.

DestroyTrigger is basically "Run once*, then remove"

*Can actually be however many times you want, but it will always be a finite amount. Say you have a variable that with each instance you set to +1, and then you do:

It's basically the same as Turn Off trigger, except the turning off is permanent.

If
Variable = 100
Then
call DestroyTrigger(GetTriggeringTrigger)
(Other stuff, probably other clean up stuff)

Also, I THINK I'm almost done. When I finish, or if I run into a problem, I'll edit this post.

EDIT:

NOTHING in the Else for the If/Than/Else in the Loop seems to be working...


  • Cloaking Index
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(immolation))
        • Then - Actions
          • Set CloakLevelMaxIndex = (CloakLevelMaxIndex + 1)
          • Set CloakingUnit[CloakLevelMaxIndex] = (Triggering unit)
          • Unit - Add Ghost to (Triggering unit)
          • Game - Display to (All players) the text: ((String((Name of (Triggering unit))) as Upper case) + ( IS SET TO INDEX + (String(CloakLevelMaxIndex))))
          • Trigger - Turn on Cloaking Calc <gen>
        • Else - Actions
      • For each (Integer CloakLevelInit) from 1 to CloakLevelMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ordered unit) Equal to CloakingUnit[CloakLevelInit]
              • (Issued order) Equal to (Order(immolation))
            • Then - Actions
              • Unit - Add Ghost to CloakingUnit[CloakLevelInit]
              • Unit - Add Cloak Toggle On Spell Book to CloakingUnit[CloakLevelInit]
              • Set CloakLevel[CloakLevelInit] = 1
              • Set SpeedBonusApplied[CloakLevelInit] = True
            • Else - Actions
              • Game - Display to (All players) the text: Bla
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Issued order) Equal to (Order(unimmolation))
                • Then - Actions
                  • Unit - Remove Cloak Toggle On Spell Book from CloakingUnit[CloakLevelInit]
                  • Unit - Remove Cloak Toggle On from CloakingUnit[CloakLevelInit]
                  • Unit - Remove Speed Bonus (1) buff from CloakingUnit[CloakLevelInit]
                  • Unit - Remove Ghost from CloakingUnit[CloakLevelInit]
                  • Set CloakingUnit[CloakLevelInit] = CloakingUnit[CloakLevelMaxIndex]
                  • Set CloakingUnit[CloakLevelMaxIndex] = No unit
                  • Set CloakSpeedBonus[CloakLevelInit] = CloakSpeedBonus[CloakLevelMaxIndex]
                  • Set CloakSpeedBonus[CloakLevelMaxIndex] = 0.00
                  • Set CloakLevelMaxIndex = (CloakLevelMaxIndex - 1)
                  • Else - Actions
                • Else - Actions
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,381
I know what call DestroyTrigger does and how it works, I just don't understand your reasoning for using perioding event if you destroy the trigger after the first run (and also why you turn it off if - as you wrote yourself - DestroyTrigger turns it off permanently). Also, what I wrote in my previous post was valid in that time, as I understood you wanted the trigger to run more than once to check the level.

Anyway, you wrote nothing wrong in the loop's ITE's else part... does it at least write the game message?
 
Level 12
Joined
May 20, 2009
Messages
822
I know what call DestroyTrigger does and how it works, I just don't understand your reasoning for using perioding event if you destroy the trigger after the first run (and also why you turn it off if - as you wrote yourself - DestroyTrigger turns it off permanently). Also, what I wrote in my previous post was valid in that time, as I understood you wanted the trigger to run more than once to check the level.

Anyway, you wrote nothing wrong in the loop's ITE's else part... does it at least write the game message?

It does not show the game message, that's why I'm so confused!! xD
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
try putting debug message as the first action in the loop trigger.
At best, make the message write the (issued order) - maybe it does change throughout the loop or you use incorrect order. Or maybe the loop doesn't fire at all.

Edit:
Further looking at the trigger, does "Cloaking Calc" trigger interfere in any way with this trigger?

Another thing is that your deindexing is faulty. If you show your conditions of the loop's first ITE as booleans, you get this:
Code:
Operation: A ^ B

A | B | result
---------------
0 | 0 |   0
0 | 1 |   0
1 | 0 |   0
1 | 1 |   1
A is first conditions, B is second condition, result 1 means conditions passed and the game goes to the "THEN" block, while 0 means it did not pass and game goes to the "ELSE" block.

This implies that if any of those two conditions is not true, it will get to the Else part.
So if the unit is incorrect, it gets into Else part. Since you loop through all units to find the correct one, it means that if you have N units, then N-1 units are incorrect units (since only one of those N units started the trigger).

This may or may not interferce with the problem at hand.
 
Last edited:
Level 12
Joined
May 20, 2009
Messages
822
Okay, so I figured out that it's my second trigger interfering somehow. I've fixed that, but there are still problems. Here's both the triggers:


  • Cloaking Index
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(immolation))
        • Then - Actions
          • Set CloakLevelMaxIndex = (CloakLevelMaxIndex + 1)
          • Set CloakingUnit[CloakLevelMaxIndex] = (Triggering unit)
          • Unit - Add Ghost to (Triggering unit)
          • Game - Display to (All players) the text: ((String((Name of (Triggering unit))) as Upper case) + ( IS SET TO INDEX + (String(CloakLevelMaxIndex))))
          • Trigger - Turn on Cloaking Calc <gen>
        • Else - Actions
      • For each (Integer CloakClockInit) from 1 to CloakLevelMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ordered unit) Equal to CloakingUnit[CloakClockInit]
              • (Issued order) Equal to (Order(immolation))
            • Then - Actions
              • Unit - Add Ghost to CloakingUnit[CloakClockInit]
              • Unit - Add Cloak Toggle On Spell Book to CloakingUnit[CloakClockInit]
              • Set CloakLevel[CloakClockInit] = 1
              • Set SpeedBonusApplied[CloakClockInit] = True
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Level of Cloak for CloakingUnit[CloakClockInit]) Equal to 1
                      • (Level of Deactivate Cloaking for CloakingUnit[CloakClockInit]) Equal to 1
                • Then - Actions
                  • Unit - Create 1 Dummy Ability Unit 1 for (Owner of CloakingUnit[CloakClockInit]) at (Position of CloakingUnit[CloakClockInit]) facing (Position of CloakingUnit[CloakClockInit])
                  • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakClockInit]
                  • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                  • Set CloakLevel[CloakClockInit] = 1
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Level of Cloak for CloakingUnit[CloakClockInit]) Equal to 2
                          • (Level of Deactivate Cloaking for CloakingUnit[CloakClockInit]) Equal to 2
                    • Then - Actions
                      • Unit - Create 1 Dummy Ability Unit 2 for (Owner of CloakingUnit[CloakClockInit]) at (Position of CloakingUnit[CloakClockInit]) facing (Position of CloakingUnit[CloakClockInit])
                      • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakClockInit]
                      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                      • Set CloakLevel[CloakClockInit] = 2
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (Level of Cloak for CloakingUnit[CloakClockInit]) Equal to 3
                              • (Level of Deactivate Cloaking for CloakingUnit[CloakClockInit]) Equal to 3
                        • Then - Actions
                          • Unit - Create 1 Dummy Ability Unit 3 for (Owner of CloakingUnit[CloakClockInit]) at (Position of CloakingUnit[CloakClockInit]) facing (Position of CloakingUnit[CloakClockInit])
                          • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakClockInit]
                          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                          • Set CloakLevel[CloakClockInit] = 3
                        • Else - Actions
            • Else - Actions
              • Game - Display to (All players) the text: Bla
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Issued order) Equal to (Order(unimmolation))
                  • (Ordered unit) Equal to CloakingUnit[CloakClockInit]
                • Then - Actions
                  • Unit - Remove Cloak Toggle On Spell Book from CloakingUnit[CloakClockInit]
                  • Unit - Remove Cloak Toggle On from CloakingUnit[CloakClockInit]
                  • Unit - Remove Speed Bonus (1) buff from CloakingUnit[CloakClockInit]
                  • Unit - Remove Ghost from CloakingUnit[CloakClockInit]
                  • Set CloakingUnit[CloakClockInit] = CloakingUnit[CloakLevelMaxIndex]
                  • Set CloakingUnit[CloakLevelMaxIndex] = No unit
                  • Set CloakLevelMaxIndex = (CloakLevelMaxIndex - 1)
                • Else - Actions
  • Cloaking Calc
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type Ranger) and do (Actions)
        • Loop - Actions
          • For each (Integer CloakLevelInit) from 1 to CloakLevelMaxIndex, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CloakingUnit[CloakLevelInit] has buff Speed Bonus (1) ) Equal to True
                  • SpeedBonusApplied[CloakLevelInit] Equal to False
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 1
                    • Then - Actions
                      • Unit - Create 1 Dummy Ability Unit 1 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
                      • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakLevelInit]
                      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                      • Set SpeedBonusApplied[CloakLevelInit] = True
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 2
                        • Then - Actions
                          • Unit - Create 1 Dummy Ability Unit 2 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
                          • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakLevelInit]
                          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                          • Set SpeedBonusApplied[CloakLevelInit] = True
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 3
                            • Then - Actions
                              • Unit - Create 1 Dummy Ability Unit 3 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
                              • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakLevelInit]
                              • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                              • Set SpeedBonusApplied[CloakLevelInit] = True
                            • Else - Actions
                  • Game - Display to (All players) the text: (String(CloakSpeedBonus[CloakLevelInit]))
                  • Unit - Create 1 Dummy Ability Unit 1 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
                  • Custom script: call DestroyGroup(GetLastCreatedGroup())
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of living Dummy Ability Unit 1 units owned by (Owner of CloakingUnit[CloakLevelInit])) Equal to 0
                  • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 1
                • Then - Actions
                  • Set SpeedBonusApplied[CloakLevelInit] = False
                  • Game - Display to (All players) the text: PRINT!
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of living Dummy Ability Unit 2 units owned by (Owner of CloakingUnit[CloakLevelInit])) Equal to 0
                      • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 2
                    • Then - Actions
                      • Set SpeedBonusApplied[CloakLevelInit] = False
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of living Dummy Ability Unit 3 units owned by (Owner of CloakingUnit[CloakLevelInit])) Equal to 0
                          • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 3
                        • Then - Actions
                          • Set SpeedBonusApplied[CloakLevelInit] = False
                        • Else - Actions


try putting debug message as the first action in the loop trigger.
At best, make the message write the (issued order) - maybe it does change throughout the loop or you use incorrect order. Or maybe the loop doesn't fire at all.

Edit:
Further looking at the trigger, does "Cloaking Calc" trigger interfere in any way with this trigger?

Another thing is that your deindexing is faulty. If you show your conditions of the loop's first ITE as booleans, you get this:
Code:
Operation: A ^ B

A | B | result
---------------
0 | 0 |   0
0 | 1 |   0
1 | 0 |   0
1 | 1 |   1
A is first conditions, B is second condition, result 1 means conditions passed and the game goes to the "THEN" block, while 0 means it did not pass and game goes to the "ELSE" block.

This implies that if any of those two conditions is not true, it will get to the Else part.
So if the unit is incorrect, it gets into Else part. Since you loop through all units to find the correct one, it means that if you have N units, then N-1 units are incorrect units (since only one of those N units started the trigger). So when any unit starts the trigger - even if the order is immolate, you deindex N-1 times.

This may or may not interferce with the problem at hand.

I still don't know if Calc is interfering with the Index, although I did fix a lot of the problem. I think the first issue was because I was using the same Integer Variable for the Loop in both triggers.

EDIT: Okay, so the first trigger is functioning flawlessly now with both of them on. Just need this fixed:


  • Cloaking Calc
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type Ranger) and do (Actions)
        • Loop - Actions
          • For each (Integer CloakLevelInit) from 1 to CloakLevelMaxIndex, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CloakingUnit[CloakLevelInit] has buff Speed Bonus (1) ) Equal to True
                  • SpeedBonusApplied[CloakLevelInit] Equal to False
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 1
                    • Then - Actions
                      • Unit - Create 1 Dummy Ability Unit 1 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
                      • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakLevelInit]
                      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                      • Set SpeedBonusApplied[CloakLevelInit] = True
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 2
                        • Then - Actions
                          • Unit - Create 1 Dummy Ability Unit 2 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
                          • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakLevelInit]
                          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                          • Set SpeedBonusApplied[CloakLevelInit] = True
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 3
                            • Then - Actions
                              • Unit - Create 1 Dummy Ability Unit 3 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
                              • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakLevelInit]
                              • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                              • Set SpeedBonusApplied[CloakLevelInit] = True
                            • Else - Actions
                  • Game - Display to (All players) the text: (String(CloakSpeedBonus[CloakLevelInit]))
                  • Unit - Create 1 Dummy Ability Unit 1 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
                  • Custom script: call DestroyGroup(GetLastCreatedGroup())
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of living Dummy Ability Unit 1 units owned by (Owner of CloakingUnit[CloakLevelInit])) Equal to 0
                  • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 1
                • Then - Actions
                  • Set SpeedBonusApplied[CloakLevelInit] = False
                  • Game - Display to (All players) the text: PRINT!
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of living Dummy Ability Unit 2 units owned by (Owner of CloakingUnit[CloakLevelInit])) Equal to 0
                      • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 2
                    • Then - Actions
                      • Set SpeedBonusApplied[CloakLevelInit] = False
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of living Dummy Ability Unit 3 units owned by (Owner of CloakingUnit[CloakLevelInit])) Equal to 0
                          • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 3
                        • Then - Actions
                          • Set SpeedBonusApplied[CloakLevelInit] = False
                        • Else - Actions
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,381
I believe the first trigger could be improved a bit and you've got location leaks there ( all those (position of *some unit*) leak if they're not destroyed).

Anyway, in the loop trigger, apart from location leaks and group leaks (Number of living Dummy Ability Unit 3 units owned by (Owner of CloakingUnit[CloakLevelInit]) leaks, since it first creates group, then it iterates through it to get the number of units. Also all unit groups "units of type" cause permanent leak. See http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/ the part "Things that always leak" in the hidden tab "Black-listed functions") and some thing that can be improved, I don't see much wrong there.

Also, unless I don't see what you destroy, the action:
  • Custom script: call DestroyGroup(GetLastCreatedGroup())
is useless, because the action
  • Custom script: set bj_wantDestroyGroup = true
already takes care of the memory leak created by the unit group.


Anyway, what doesn't work with the loop trigger? What did you expect it to do? I'm quite at loss here.
 
Level 12
Joined
May 20, 2009
Messages
822
I not done cleaning this up, yet! xD

I'm getting A LOT closer to finishing, here's the next changes:


  • Cloaking Index
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(immolation))
        • Then - Actions
          • Set CloakLevelMaxIndex = (CloakLevelMaxIndex + 1)
          • Set CloakingUnit[CloakLevelMaxIndex] = (Triggering unit)
          • Unit - Add Ghost to (Triggering unit)
          • Game - Display to (All players) the text: ((String((Name of (Triggering unit))) as Upper case) + ( IS SET TO INDEX + (String(CloakLevelMaxIndex))))
          • Trigger - Turn on Cloaking Calc <gen>
        • Else - Actions
      • For each (Integer CloakClockInit) from 1 to CloakLevelMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(immolation))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Ordered unit) Equal to CloakingUnit[CloakClockInit]
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Level of Cloak for CloakingUnit[CloakClockInit]) Equal to 1
                          • (Level of Deactivate Cloaking for CloakingUnit[CloakClockInit]) Equal to 1
                    • Then - Actions
                      • Set CloakLevel[CloakClockInit] = 1
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (Level of Cloak for CloakingUnit[CloakClockInit]) Equal to 2
                              • (Level of Deactivate Cloaking for CloakingUnit[CloakClockInit]) Equal to 2
                        • Then - Actions
                          • Set CloakLevel[CloakClockInit] = 2
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • Or - Any (Conditions) are true
                                • Conditions
                                  • (Level of Cloak for CloakingUnit[CloakClockInit]) Equal to 3
                                  • (Level of Deactivate Cloaking for CloakingUnit[CloakClockInit]) Equal to 3
                            • Then - Actions
                              • Set CloakLevel[CloakClockInit] = 3
                            • Else - Actions
                  • Unit - Add Ghost to CloakingUnit[CloakClockInit]
                  • Unit - Add Cloak Toggle On Spell Book to CloakingUnit[CloakClockInit]
                  • Unit - Create 1 Dummy Ability Unit 1 for (Owner of CloakingUnit[CloakClockInit]) at (Position of CloakingUnit[CloakClockInit]) facing (Position of CloakingUnit[CloakClockInit])
                  • Unit - Set level of Speed Bonus (Level 1) for (Last created unit) to CloakLevel[CloakLevelInit]
                  • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakClockInit]
                  • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                  • Set SpeedBonusApplied[CloakClockInit] = True
                • Else - Actions
            • Else - Actions
              • Game - Display to (All players) the text: Bla
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Issued order) Equal to (Order(unimmolation))
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Ordered unit) Equal to CloakingUnit[CloakClockInit]
                    • Then - Actions
                      • Unit - Remove Cloak Toggle On Spell Book from CloakingUnit[CloakClockInit]
                      • Unit - Remove Cloak Toggle On from CloakingUnit[CloakClockInit]
                      • Unit - Remove Speed Bonus (1) buff from CloakingUnit[CloakClockInit]
                      • Unit - Remove Ghost from CloakingUnit[CloakClockInit]
                      • Set CloakingUnit[CloakClockInit] = CloakingUnit[CloakLevelMaxIndex]
                      • Set CloakingUnit[CloakLevelMaxIndex] = No unit
                      • Set CloakLevelMaxIndex = (CloakLevelMaxIndex - 1)
                    • Else - Actions
                • Else - Actions


  • Cloaking Calc
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer CloakLevelInit) from 1 to CloakLevelMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (CloakingUnit[CloakLevelInit] has buff Speed Bonus (1) ) Equal to True
              • SpeedBonusApplied[CloakLevelInit] Equal to False
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 1
                      • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 1
                • Then - Actions
                  • Set CloakLevel[CloakLevelInit] = 1
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 2
                          • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 2
                    • Then - Actions
                      • Set CloakLevel[CloakLevelInit] = 2
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 3
                              • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 3
                        • Then - Actions
                          • Set CloakLevel[CloakLevelInit] = 3
                        • Else - Actions
              • Unit - Create 1 Dummy Ability Unit 2 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
              • Unit - Set level of Speed Bonus (Level 2) for (Last created unit) to CloakLevel[CloakLevelInit]
              • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakLevelInit]
              • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
              • Set SpeedBonusApplied[CloakLevelInit] = True
              • Unit - Create 1 Dummy Ability Unit 1 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
              • Custom script: call DestroyGroup(GetLastCreatedGroup())
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of living Dummy Ability Unit 1 units owned by (Owner of CloakingUnit[CloakLevelInit])) Equal to 0
              • Or - Any (Conditions) are true
                • Conditions
                  • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 1
                  • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 1
            • Then - Actions
              • Set SpeedBonusApplied[CloakLevelInit] = False
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of living Dummy Ability Unit 2 units owned by (Owner of CloakingUnit[CloakLevelInit])) Equal to 0
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 2
                      • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 2
                • Then - Actions
                  • Set SpeedBonusApplied[CloakLevelInit] = False
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of living units owned by (Owner of CloakingUnit[CloakLevelInit])) Equal to 0
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 3
                          • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 3
                    • Then - Actions
                      • Set SpeedBonusApplied[CloakLevelInit] = False
                    • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of CloakingUnit[CloakManaLoop]) Less than 1.00
            • Then - Actions
              • Unit - Remove Cloak Toggle On Spell Book from CloakingUnit[CloakClockInit]
              • Unit - Remove Cloak Toggle On from CloakingUnit[CloakClockInit]
              • Unit - Remove Speed Bonus (1) buff from CloakingUnit[CloakClockInit]
              • Unit - Remove Ghost from CloakingUnit[CloakClockInit]
              • Set CloakingUnit[CloakClockInit] = CloakingUnit[CloakLevelMaxIndex]
              • Set CloakingUnit[CloakLevelMaxIndex] = No unit
              • Set CloakLevelMaxIndex = (CloakLevelMaxIndex - 1)
            • Else - Actions
      • For each (Integer CloakManaLoop) from 1 to CloakLevelMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (CloakingUnit[CloakManaLoop] has buff Speed Bonus (1) ) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 1
                      • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 1
                • Then - Actions
                  • Set CloakCasterSustainCost[CloakManaLoop] = 5.00
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 2
                          • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 2
                    • Then - Actions
                      • Set CloakCasterSustainCost[CloakManaLoop] = 7.00
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 3
                              • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 3
                        • Then - Actions
                          • Set CloakCasterSustainCost[CloakManaLoop] = 9.00
                        • Else - Actions
              • Unit - Set mana of CloakingUnit[CloakManaLoop] to ((Mana of CloakingUnit[CloakManaLoop]) - CloakCasterSustainCost[CloakManaLoop])
            • Else - Actions


There's a VERY odd issue now that's really hard to explain...

It's not done quite yet, I still need to make a timer for the mana draining so it doesn't drain 5, 7, 9, mana 10 times a second...(Which would then be 50, 70, and 90 mana a second)
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,381
The Cloaking Index trigger:
There's no need to have the first ITE in the loop (where you create dummy, etc.) because what's the reason for that?
All that does is that it creates the dummy for the triggering unit and orders the dummy to cast spell on triggering unit... so why search the triggering unit through loop, when you know which unit is triggering unit?
So all those actions in the loop's first ITE can be put into the THEN block of the very first ITE at the top of the trigger, so all that's left in the loop is actually the block for deindexing.

Another thing to watch out for: Is there really only one unit-type that can cast ability with order id "immolation" or "unimmolation"?
If there are more units (e.g. you can have ingame the generic Demon Hunter hero), then if he switches his immolation on, he will be indexed by this trigger as well.
You may want to add a condition that unit-type of triggering unit is "your desired unit type".

Can abilities "Cloak" and "Deactivate Cloaking" even have different levels? Or do they have same level all the time?


In Cloaking Calc trigger:
You can basically get rid of CloakLevel and use a temp variable, as this doesn't really save any data for longer period than 1 trigger iteration (it doesn't mean that if you have a specific variable that it's wrong, however in the long run, using a temp variable instead of this will make your variable editor cleaner and you will also know immediately if something you save into some variable holds any meaningful data or it's just for that trigger iteration).

You base your SpeedBonusApplied boolean value on whether there are any Dummy Ability Unit 1 or 2 alive or not, yet "Dummy Ability Unit 2" has life set to 1 second, while "Dummy Ability Unit 1" has no duration at all (it will stay in the game forever).

In the ITEs, where you check the number of Dummy Ability Units and change boolean value for SpeedBonusApplied, the third level checks this:
  • Number of living units owned by (Owner of CloakingUnit[CloakLevelInit])
while the previous two check only the specific Dummy Ability Unit 1 or 2.

What were you imagining to happen doing this?
When unit has specific buff and boolean is false, you make dummy unit cast Speed Bonus (2) on that unit and change boolean to true.
And once there's no dummy unit alive, the boolean is changed back to false?
Ain't there a simpler way to achieve whatever you want to do?

Next, the ITE where you check mana of unit:
  • (Mana of CloakingUnit[CloakManaLoop]) Less than 1.00
Why don't you simply order that unit to "unimmolation"? You already have the deindexing in other trigger.

Last, the second loop. Why don't you do all those actions in the first loop? While loop through all those units to do "Action A" and then loop through all the same units to do "Action B"? Why not simply loop through them once and do "Action A, Action B"?
Those ITEs in the second trigger can be removed I believe.
Just change the line into this:
  • CloakCasterSustainCost[CloakManaLoop] = 3.00 + (2.00 x Real((Level of Cloak for CloakingUnit[CloakLevelInit]))
You will achieve same results but faster.
 
Level 12
Joined
May 20, 2009
Messages
822

Nichilus said:
The Cloaking Index trigger:
There's no need to have the first ITE in the loop (where you create dummy, etc.) because what's the reason for that?
All that does is that it creates the dummy for the triggering unit and orders the dummy to cast spell on triggering unit... so why search the triggering unit through loop, when you know which unit is triggering unit?
So all those actions in the loop's first ITE can be put into the THEN block of the very first ITE at the top of the trigger, so all that's left in the loop is actually the block for deindexing.

Another thing to watch out for: Is there really only one unit-type that can cast ability with order id "immolation" or "unimmolation"?
If there are more units (e.g. you can have ingame the generic Demon Hunter hero), then if he switches his immolation on, he will be indexed by this trigger as well.
You may want to add a condition that unit-type of triggering unit is "your desired unit type".

Can abilities "Cloak" and "Deactivate Cloaking" even have different levels? Or do they have same level all the time?

1. You're right.
2. You're right.
3. You're right.

Cloak and Decloak will not have different levels because I am using Engineering Upgrade to swap them around. It's mainly just a precaution.

Although, the setting of the level is important because Cloak has a scaling speed bonus.

Cloak is similar to Wind Walk, with a few differences:

1. It can be turned off.
2. It stays on forever or until the unit no longer has mana.
3. No backstab damage.
3a. The speed increase is quite a lot less, however.

Nichilus [B said:
In Cloaking Calc trigger:[/B]
You can basically get rid of CloakLevel and use a temp variable, as this doesn't really save any data for longer period than 1 trigger iteration (it doesn't mean that if you have a specific variable that it's wrong, however in the long run, using a temp variable instead of this will make your variable editor cleaner and you will also know immediately if something you save into some variable holds any meaningful data or it's just for that trigger iteration).

You base your SpeedBonusApplied boolean value on whether there are any Dummy Ability Unit 1 or 2 alive or not, yet "Dummy Ability Unit 2" has life set to 1 second, while "Dummy Ability Unit 1" has no duration at all (it will stay in the game forever).

In the ITEs, where you check the number of Dummy Ability Units and change boolean value for SpeedBonusApplied, the third level checks this:
  • Number of living units owned by (Owner of CloakingUnit[CloakLevelInit])
while the previous two check only the specific Dummy Ability Unit 1 or 2.

What were you imagining to happen doing this?
When unit has specific buff and boolean is false, you make dummy unit cast Speed Bonus (2) on that unit and change boolean to true.
And once there's no dummy unit alive, the boolean is changed back to false?
Ain't there a simpler way to achieve whatever you want to do?

Next, the ITE where you check mana of unit:
  • (Mana of CloakingUnit[CloakManaLoop]) Less than 1.00
Why don't you simply order that unit to "unimmolation"? You already have the deindexing in other trigger.

Last, the second loop. Why don't you do all those actions in the first loop? While loop through all those units to do "Action A" and then loop through all the same units to do "Action B"? Why not simply loop through them once and do "Action A, Action B"?
Those ITEs in the second trigger can be removed I believe.
Just change the line into this:
  • CloakCasterSustainCost[CloakManaLoop] = 3.00 + (2.00 x Real((Level of Cloak for CloakingUnit[CloakLevelInit]))
You will achieve same results but faster.

1. ???
2. EDIT: Oh wait...I just had a second create unit in the trigger there somehow. Odd, I don't have that in the actual trigger in my editor...
3.

The point of that system is so 10 units aren't being created, spamming that ability, every second, and only 1 a second because the timer on the unit is 1 second.

4. Yeah, that's a good point...
5. I meant to put them in the same loop. I have no idea what I was doing. I was tired. xD

Nichilus said:
  • CloakCasterSustainCost[CloakManaLoop] = 3.00 + (2.00 x Real((Level of Cloak for CloakingUnit[CloakLevelInit]))

What...That would give it MORE mana, not subtract from it. o.o

I'll work on these changes and see if that fixes any of the problems I saw in-game.


Okay, here's the next draft of the triggers.

The only problems now is that the mana drain to sustain the cloak doesn't seem to happen...And a weird thing:

If Player 2 activates the spell first, then Player 1's spell won't activate at all. But if Player 1 does it first, then both players can use the spell...


  • Cloaking Index
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(immolation))
          • (Unit-type of (Triggering unit)) Equal to Ranger
        • Then - Actions
          • Set CloakLevelMaxIndex = (CloakLevelMaxIndex + 1)
          • Set CloakingUnit[CloakLevelMaxIndex] = (Triggering unit)
          • Game - Display to (All players) the text: ((String((Name of (Triggering unit))) as Upper case) + ( IS SET TO INDEX + (String(CloakLevelMaxIndex))))
          • Trigger - Turn on Cloaking Calc <gen>
        • Else - Actions
      • For each (Integer CloakClockInit) from 1 to CloakLevelMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(immolation))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Level of Cloak for CloakingUnit[CloakClockInit]) Equal to 1
                      • (Level of Unknown (A028) for CloakingUnit[CloakClockInit]) Equal to 1
                • Then - Actions
                  • Set CloakLevel[CloakClockInit] = 1
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Level of Cloak for CloakingUnit[CloakClockInit]) Equal to 2
                          • (Level of Unknown (A028) for CloakingUnit[CloakClockInit]) Equal to 2
                    • Then - Actions
                      • Set CloakLevel[CloakClockInit] = 2
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (Level of Cloak for CloakingUnit[CloakClockInit]) Equal to 3
                              • (Level of Unknown (A028) for CloakingUnit[CloakClockInit]) Equal to 3
                        • Then - Actions
                          • Set CloakLevel[CloakClockInit] = 3
                        • Else - Actions
              • Unit - Add Ghost to CloakingUnit[CloakClockInit]
              • Unit - Add Cloak Toggle On Spell Book to CloakingUnit[CloakClockInit]
              • Unit - Create 1 Dummy Ability Unit 1 for (Owner of CloakingUnit[CloakClockInit]) at (Position of CloakingUnit[CloakClockInit]) facing (Position of CloakingUnit[CloakClockInit])
              • Unit - Set level of Speed Bonus (Level 1) for (Last created unit) to CloakLevel[CloakClockInit]
              • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakClockInit]
              • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
              • Set SpeedBonusApplied[CloakClockInit] = True
            • Else - Actions
              • Game - Display to (All players) the text: Bla
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Issued order) Equal to (Order(unimmolation))
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Ordered unit) Equal to CloakingUnit[CloakClockInit]
                    • Then - Actions
                      • Unit - Remove Cloak Toggle On Spell Book from CloakingUnit[CloakClockInit]
                      • Unit - Remove Cloak Toggle On from CloakingUnit[CloakClockInit]
                      • Unit - Remove Speed Bonus (1) buff from CloakingUnit[CloakClockInit]
                      • Unit - Remove Ghost from CloakingUnit[CloakClockInit]
                      • Set CloakingUnit[CloakClockInit] = CloakingUnit[CloakLevelMaxIndex]
                      • Set CloakingUnit[CloakLevelMaxIndex] = No unit
                      • Set CloakManaTick[CloakClockInit] = CloakManaTick[CloakLevelMaxIndex]
                      • Set CloakManaTick[CloakLevelMaxIndex] = 0
                      • Set CloakCasterSustainCost[CloakClockInit] = CloakCasterSustainCost[CloakLevelMaxIndex]
                      • Set CloakCasterSustainCost[CloakLevelMaxIndex] = 0.00
                      • Set CloakLevel[CloakClockInit] = CloakLevel[CloakLevelMaxIndex]
                      • Set CloakLevel[CloakLevelMaxIndex] = 0
                      • Set CloakLevelMaxIndex = (CloakLevelMaxIndex - 1)
                    • Else - Actions
                • Else - Actions


  • Cloaking Calc
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer CloakLevelInit) from 1 to CloakLevelMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (CloakingUnit[CloakLevelInit] has buff Speed Bonus (1) ) Equal to True
              • SpeedBonusApplied[CloakLevelInit] Equal to False
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 1
                      • (Level of Unknown (A028) for CloakingUnit[CloakLevelInit]) Equal to 1
                • Then - Actions
                  • Set CloakLevel[CloakLevelInit] = 1
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 2
                          • (Level of Unknown (A028) for CloakingUnit[CloakLevelInit]) Equal to 2
                    • Then - Actions
                      • Set CloakLevel[CloakLevelInit] = 2
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 3
                              • (Level of Unknown (A028) for CloakingUnit[CloakLevelInit]) Equal to 3
                        • Then - Actions
                          • Set CloakLevel[CloakLevelInit] = 3
                        • Else - Actions
              • Unit - Create 1 Dummy Ability Unit 2 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
              • Unit - Set level of Speed Bonus (Level 2) for (Last created unit) to CloakLevel[CloakLevelInit]
              • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakLevelInit]
              • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
              • Set SpeedBonusApplied[CloakLevelInit] = True
              • Custom script: call DestroyGroup(GetLastCreatedGroup())
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of living Dummy Ability Unit 1 units owned by (Owner of CloakingUnit[CloakLevelInit])) Equal to 0
              • (Number of living Dummy Ability Unit 2 units owned by (Owner of CloakingUnit[CloakLevelInit])) Equal to 0
            • Then - Actions
              • Set SpeedBonusApplied[CloakLevelInit] = False
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of CloakingUnit[CloakLevelInit]) Less than 1.00
            • Then - Actions
              • Unit - Order CloakingUnit[CloakLevelInit] to Night Elf Demon Hunter - Deactivate Immolation
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (CloakingUnit[CloakLevelInit] has buff Speed Bonus (1) ) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 1
                      • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 1
                • Then - Actions
                  • Game - Display to (All players) the text: LEVEL 1!
                  • Set CloakCasterSustainCost[CloakLevelInit] = 5.00
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 2
                          • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 2
                    • Then - Actions
                      • Set CloakCasterSustainCost[CloakLevelInit] = 7.00
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (Level of Cloak for CloakingUnit[CloakLevelInit]) Equal to 3
                              • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 3
                        • Then - Actions
                          • Set CloakCasterSustainCost[CloakLevelInit] = 9.00
                        • Else - Actions
              • Set CloakManaTick[CloakLevelInit] = (CloakManaTick[CloakLevelInit] + 1)
              • Game - Display to (All players) the text: (MANA TICK SET TO + (String(CloakManaTick[CloakLevelInit])))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CloakManaTick[CloakLevelInit] Equal to 33
                • Then - Actions
                  • Unit - Set mana of CloakingUnit[CloakLevelInit] to ((Mana of CloakingUnit[CloakLevelInit]) - CloakCasterSustainCost[CloakLevelInit])
                  • Set CloakManaTick[CloakLevelInit] = 0
                • Else - Actions
            • Else - Actions


EDIT: Updated Triggers again
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,381
I'm getting the feeling that you don't understand what I am writing and what you are doing :X

1.
Nichilus said:
  • CloakCasterSustainCost[CloakManaLoop] = 3.00 + (2.00 x Real((Level of Cloak for CloakingUnit[CloakLevelInit]))
What...That would give it MORE mana, not subtract from it. o.o
If you look at what I posted and what you had, you will see they both give same result. What you do with the result is up to you, but then the fault would be with your handling, not in anything else.

2.
You still didn't understand the stuff I wrote about with more unit-types using same order id for different spells, or you're not reading your own code.
This is what I wrote:
Another thing to watch out for: Is there really only one unit-type that can cast ability with order id "immolation" or "unimmolation"?
If there are more units (e.g. you can have ingame the generic Demon Hunter hero), then if he switches his immolation on, he will be indexed by this trigger as well.
You may want to add a condition that unit-type of triggering unit is "your desired unit type".

And this is what you basically have:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Ranger
          • (Issued order) Equal to (Order(immolation))
        • Then - Actions
        • Else - Actions
      • For each (Integer variable Loop from 1 to X, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(immolation))
            • Then - Actions
            • Else - Actions
As you can see in the trigger, you only check the unit type in the first ITE, however where you actually add those abilitites and stuff - which is in the loop - you don't check the unit type, so in the end, you bugged your spell more than it was previously, because previously, you at least properly indexed and deindexed unit - even if it was bad unit - but now, you only index good unit, but bad units are still add to this spell.

3.
Your usage of loops is very inefficient.
Firstly, as I wrote earlier, all those actions in the loop for the order "immolation" should be in the first ITE where you currently check the unit-type (Ranger) and order (immolation), because every unit you index, you always index it with the highest index number. Why, then, are you searching the unit in the loop? It doesn't make any sense.

Put in how it would actually work during game, then let's say that the current index number is 9 and some Ranger unit casts the spell we're fixing.
So when ranger casts the spell (thus he is issued the order "immolation"), then you want to index him. So you increase index number by 1 ... thus from 9 you increase index to 10 and then you save the unit as CloakingUnit[index] so currently, it would be CloakingUnit[10].
Why, then, are you searching for this triggering unit in loop "from 1 to index" -> thus in loop "from 1 to 10"? You know that the unit that you index is at the very end of the loop, because it will always have the highest index number, when you index it.

You only need loop for deindexing, because when unit switches off that ability, you don't know under which number it is saved in the CloakingUnit[] array.

However the wrong usage of the loop is in the inefficiency in your using it.
You loop from 1 to X -> then you check if the order is "unimmolation" or "immolation" and after that you check if the unit is the correct one.
The thing is - unit may not have the only order with no taget to be "immolation" and "unimmolation" - e.g. "stop" and "holdposition" are orders that every unit has, and you may actually have more spells that require no target.
So if unit is issued any of the other order that are unrelated to this spell, you loop through all those units for no reason.

4.
You don't even read your own code after yourself. You deleted one ability, which I presume was the Deactivate Cloaking ability, because in your triggers you have in conditions
  • (Level of Unknown (A028) for CloakingUnit[CloakLevelInit]) Equal to 2
This means it will not only check the level, it will also cause bugs when you create another ability that will get this ability ID, because your spell (= this trigger) will suddenly check completely different ability without you knowing such a thing happened.

5.
Similar problem as with point 3, but this time for the mana drain.
You make calculations for mana drain 33 times per second, only to actually use the calculation only the 33rd time, thus making those 32 previous calculations for no purpose.

6.
  • Custom script: call DestroyGroup(GetLastCreatedGroup())
serves no purpose in your trigger and will actually lead only to bugs in your whole map.

7.
In the deindexing you remove more abilities from the unit than you add when you indexed them.

------
I recreated the spell to what is in the hidden tabs. Try to recreate it into your map and see if it will help fix your issues or not.
First, here's list of what needs to be created before you even trigger the spell:
Abilities:
All those you use in your spell.
Change the Speed Bonus (1) ability's duration to 0.00 - that should make the duration permanent.

Dummy:
1 generic dummy unit.

Important Variables
These variables all start with capital letter. They are important for the spell.
  • CloakHasSpeed - boolean variable array
  • CloakIndex - integer variable
  • CloakTick - integer variable array
  • CloakUnit - unit variable array
Temporal Variables
These don't start with capital letter, they can be changed for other temporal variables you already have in your map. They are needed only to store some calculation or point where dummy is created.
  • bool - boolean variable
  • dummy - unit variable
  • int - integer variable
  • loc - point variable
  • loopInt - integer variable
  • mana - real variable
  • unit - unit variable
Do note, if you change name for point variable, don't forget to change it also in custom script.
  • Custom script: call RemoveLocation(udg_YourVariableName)
e.g. for loc variable it is:
  • Custom script: call RemoveLocation(udg_loc)
First trigger where you (de)index units:
  • Cloak StartEnd
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Paladin
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(immolation))
        • Then - Actions
          • Set CloakIndex = (CloakIndex + 1)
          • Set CloakUnit[CloakIndex] = (Triggering unit)
          • Set CloakTick[CloakIndex] = 0
          • Set CloakHasSpeed[CloakIndex] = False
          • -------- ------------------------------------------------------------------ --------
          • Unit - Add Ghost to CloakUnit[CloakIndex]
          • Unit - Add Cloak Toggle On Spell Book to CloakUnit[CloakIndex]
          • -------- ------------------------------------------------------------------ --------
          • Set int = (Max((Level of Cloak for CloakUnit[CloakIndex]), (Level of Deactivate Cloaking for CloakUnit[CloakIndex])))
          • Set loc = (Position of CloakUnit[CloakIndex])
          • -------- ------------------------------------------------------------------ --------
          • Unit - Create 1 Dummy for (Owner of CloakUnit[CloakIndex]) at loc facing Default building facing degrees
          • Set dummy = (Last created unit)
          • Unit - Add Speed Bonus (Level 1) to dummy
          • Unit - Set level of Speed Bonus (Level 1) for dummy to int
          • Unit - Order dummy to Night Elf Warden - Shadow Strike CloakUnit[CloakIndex]
          • Unit - Remove dummy from the game
          • -------- ------------------------------------------------------------------ --------
          • Custom script: call RemoveLocation(udg_loc)
          • -------- ------------------------------------------------------------------ --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Cloak Loop <gen> is on) Equal to False
            • Then - Actions
              • Trigger - Turn on Cloak Loop <gen>
            • Else - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(unimmolation))
            • Then - Actions
              • Set unit = (Triggering unit)
              • For each (Integer loopInt) from 1 to CloakIndex, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • unit Equal to CloakUnit[loopInt]
                    • Then - Actions
                      • Unit - Remove Ghost from CloakUnit[loopInt]
                      • Unit - Remove Deactivate Cloaking from CloakUnit[loopInt]
                      • Unit - Remove Speed Bonus (1) buff from CloakUnit[loopInt]
                      • -------- ------------------------------------------------------------------ --------
                      • Set CloakUnit[loopInt] = CloakUnit[CloakIndex]
                      • Set CloakTick[loopInt] = CloakTick[CloakIndex]
                      • Set CloakHasSpeed[loopInt] = CloakHasSpeed[CloakIndex]
                      • -------- ------------------------------------------------------------------ --------
                      • Set CloakIndex = (CloakIndex - 1)
                      • Set loopInt = CloakIndex
                      • -------- ------------------------------------------------------------------ --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • CloakIndex Equal to 0
                        • Then - Actions
                          • Trigger - Turn off Cloak Loop <gen>
                        • Else - Actions
                    • Else - Actions
            • Else - Actions
Second trigger - periodically lowers mana, checks mana level and also checks all situations if the speed buff was for some reasons dispelled.
  • Cloak Loop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer loopInt) from 1 to CloakIndex, do (Actions)
        • Loop - Actions
          • Set CloakTick[loopInt] = (CloakTick[loopInt] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CloakTick[loopInt] Equal to 10
            • Then - Actions
              • Set CloakTick[loopInt] = 0
              • Set mana = (3.00 + (2.00 x (Real((Max((Level of Cloak for CloakUnit[loopInt]), (Level of Deactivate Cloaking for CloakUnit[loopInt])))))))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Mana of CloakUnit[loopInt]) - mana) Less than 1.00
                • Then - Actions
                  • Unit - Order CloakUnit[loopInt] to Night Elf Demon Hunter - Deactivate Immolation
                  • Set bool = False
                • Else - Actions
                  • Unit - Set mana of CloakUnit[loopInt] to ((Mana of CloakUnit[loopInt]) - mana)
                  • Set bool = True
            • Else - Actions
          • -------- //////////////////////////////////////////////////////////////////////// --------
          • -------- BELOW I CHECK ALL POSSIBILITIES TO THE SPEED RELATED STUFF --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • bool Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CloakUnit[loopInt] has buff Speed Bonus (1) ) Equal to True
                  • CloakHasSpeed[loopInt] Equal to False
                • Then - Actions
                  • Set CloakHasSpeed[loopInt] = True
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (CloakUnit[loopInt] has buff Speed Bonus (1) ) Equal to False
                      • CloakHasSpeed[loopInt] Equal to True
                    • Then - Actions
                      • Set int = (Max((Level of Cloak for CloakUnit[loopInt]), (Level of Deactivate Cloaking for CloakUnit[loopInt])))
                      • Set loc = (Position of CloakUnit[loopInt])
                      • -------- ------------------------------------------------------------------ --------
                      • Unit - Create 1 Dummy for (Owner of CloakUnit[loopInt]) at loc facing Default building facing degrees
                      • Set dummy = (Last created unit)
                      • Unit - Add Speed Bonus (Level 1) to dummy
                      • Unit - Set level of Speed Bonus (Level 1) for dummy to int
                      • Unit - Order dummy to Night Elf Warden - Shadow Strike CloakUnit[loopInt]
                      • Unit - Remove dummy from the game
                      • -------- ------------------------------------------------------------------ --------
                      • Set CloakHasSpeed[loopInt] = False
                      • -------- ------------------------------------------------------------------ --------
                      • Custom script: call RemoveLocation(udg_loc)
                    • Else - Actions
            • Else - Actions
IMPORTANT
It is quite important to correctly set up your dummy unit. For that reason I attached the map with the triggers and the dummy below.
However since I don't know what abilities you use, all those abilities in the attached map are just dummy abilities that don't do anything. They're used only for the triggers to show what ability I used where.

For the dummy unit - all those fields that are changed from default are important to be changed. If you change all those things, you will end up with a dummy that instantly casts spells without the need for turning, etc.

About the speed bonus: You could simplify the spell a lot if you actually used hidden ability that increases movement speed. I mean the "Item Move Speed Bonus" ability. I think it works quite well and you don't have to worry about some random enemy unit dispelling the buff speed buff from your hero... although the downside is that there will be no buff to begin with (but the speed would be increased still).

Most temporal variables are used for better efficiency. If you use function calls all the time (e.g. (Triggering unit) is a function call), the spell will be inefficient, but should still work..

Attached map:
 

Attachments

  • CloakSpell.w3x
    20.3 KB · Views: 44
Level 12
Joined
May 20, 2009
Messages
822
1. Okay, I see what that's doing now. Would be nice for getting rid of a variable, but unimportant at the moment.

2. I'll reorganize this sometime later, I've mainly just been trying to get it to function which I can do without having to do this...

3. Well, I'm so damn exhausted with this spell by now that I'm rushing things a lot. This is like, the 4th time I've COMPLETELY re-scripted this spell. So excuse me if I'm making some mistakes.

4. When I posted these triggers, that function was actually disabled. Now, it's replaced. I'm gonna clean this thread up later today and update this post with the newest triggers.

5. The reason I drain the Mana on the 33rd time is so the mana is drained ONCE per (As close as possible to) second. When it +1s that variable, it's doing it ~33.33 times a second. 5, 7, 9, mana drained 33.33 times a second would end up draining all the heroes mana in like 2-3 seconds. There's definitely a better way to do this, like maybe setting the drain amount to .15, .21, and .27, but I'd rather do this.

6. I haven't cleaned ANYTHING up yet from the old triggers (The ones I had before I started this wonderous adventure of completely re-scripting it for the 4th time) that is still left-over.

7. In the Indexing, I add Ghost and a Spell Book. In the Deindexing, I remove Ghost, the Spell Book, and the Spell the Spell Book has. I don't actually know if removing a Spell Book from a unit removes all the spell that Spell Book has...If it does then yeah there's no point in that.

"Important": My Dummy-Units are set up correctly and I have my spells set up right. Thanks, though. =p

EDIT: Okay, everything that's "Draft" is a Non-Complete Trigger. (For Future references, use them at your own discretion!)

Here are the next versions of the trigger. These triggers are FUNCTIONAL, and have no bugs, but could still probably use some touch-up!


  • Cloaking Index
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(immolation))
          • (Unit-type of (Triggering unit)) Equal to Ranger
        • Then - Actions
          • Set CloakLevelMaxIndex = (CloakLevelMaxIndex + 1)
          • Set CloakingUnit[CloakLevelMaxIndex] = (Triggering unit)
          • Game - Display to (All players) the text: ((String((Name of (Triggering unit))) as Upper case) + ( IS SET TO INDEX + (String(CloakLevelMaxIndex))))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelMaxIndex]) Equal to 1
            • Then - Actions
              • Set CloakLevel[CloakClockInit] = 1
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelMaxIndex]) Equal to 2
                • Then - Actions
                  • Set CloakLevel[CloakClockInit] = 2
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelMaxIndex]) Equal to 3
                    • Then - Actions
                      • Set CloakLevel[CloakClockInit] = 3
                    • Else - Actions
          • Unit - Add Ghost to CloakingUnit[CloakLevelMaxIndex]
          • Unit - Add Cloak Toggle On Spell Book to CloakingUnit[CloakLevelMaxIndex]
          • Unit - Create 1 Dummy Ability Unit 1 for (Owner of CloakingUnit[CloakLevelMaxIndex]) at (Position of CloakingUnit[CloakLevelMaxIndex]) facing (Position of CloakingUnit[CloakLevelMaxIndex])
          • Unit - Set level of Speed Bonus (Level 1) for (Last created unit) to CloakLevel[CloakLevelMaxIndex]
          • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakLevelMaxIndex]
          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
          • Set SpeedBonusApplied[CloakLevelMaxIndex] = True
          • Trigger - Turn on Cloaking Calc <gen>
        • Else - Actions
      • For each (Integer CloakClockInit) from 1 to CloakLevelMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(unimmolation))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Ordered unit) Equal to CloakingUnit[CloakClockInit]
                • Then - Actions
                  • Unit - Remove Cloak Toggle On Spell Book from CloakingUnit[CloakClockInit]
                  • Unit - Remove Cloak Toggle On from CloakingUnit[CloakClockInit]
                  • Unit - Remove Speed Bonus (1) buff from CloakingUnit[CloakClockInit]
                  • Unit - Remove Ghost from CloakingUnit[CloakClockInit]
                  • Set CloakingUnit[CloakClockInit] = CloakingUnit[CloakLevelMaxIndex]
                  • Set CloakingUnit[CloakLevelMaxIndex] = No unit
                  • Set CloakManaTick[CloakClockInit] = CloakManaTick[CloakLevelMaxIndex]
                  • Set CloakManaTick[CloakLevelMaxIndex] = 0
                  • Set CloakCasterSustainCost[CloakClockInit] = CloakCasterSustainCost[CloakLevelMaxIndex]
                  • Set CloakCasterSustainCost[CloakLevelMaxIndex] = 0.00
                  • Set CloakLevel[CloakClockInit] = CloakLevel[CloakLevelMaxIndex]
                  • Set CloakLevel[CloakLevelMaxIndex] = 0
                  • Set CloakLevelMaxIndex = (CloakLevelMaxIndex - 1)
                • Else - Actions
            • Else - Actions


  • Cloaking Calc
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer CloakLevelInit) from 1 to CloakLevelMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (CloakingUnit[CloakLevelInit] has buff Speed Bonus (1) ) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SpeedBonusApplied[CloakLevelInit] Equal to False
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 1
                    • Then - Actions
                      • Set CloakLevel[CloakLevelInit] = 1
                      • Set CloakCasterSustainCost[CloakLevelInit] = 5.00
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 2
                        • Then - Actions
                          • Set CloakLevel[CloakLevelInit] = 2
                          • Set CloakCasterSustainCost[CloakLevelInit] = 7.00
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Level of Deactivate Cloaking for CloakingUnit[CloakLevelInit]) Equal to 3
                            • Then - Actions
                              • Set CloakLevel[CloakLevelInit] = 3
                              • Set CloakCasterSustainCost[CloakLevelInit] = 9.00
                            • Else - Actions
                • Else - Actions
              • Set CloakManaTick[CloakLevelInit] = (CloakManaTick[CloakLevelInit] + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CloakManaTick[CloakLevelInit] Equal to 33
                • Then - Actions
                  • Unit - Set mana of CloakingUnit[CloakLevelInit] to ((Mana of CloakingUnit[CloakLevelInit]) - CloakCasterSustainCost[CloakLevelInit])
                  • Set CloakManaTick[CloakLevelInit] = 0
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SpeedBonusApplied[CloakLevelInit] Equal to False
                • Then - Actions
                  • Unit - Create 1 Dummy Ability Unit 2 for (Owner of CloakingUnit[CloakLevelInit]) at (Position of CloakingUnit[CloakLevelInit]) facing (Position of CloakingUnit[CloakLevelInit])
                  • Unit - Set level of Speed Bonus (Level 2) for (Last created unit) to CloakLevel[CloakLevelInit]
                  • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike CloakingUnit[CloakLevelInit]
                  • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                • Else - Actions
              • Set SpeedBonusApplied[CloakLevelInit] = True
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of living Dummy Ability Unit 1 units owned by (Owner of CloakingUnit[CloakLevelInit])) Equal to 0
              • (Number of living Dummy Ability Unit 2 units owned by (Owner of CloakingUnit[CloakLevelInit])) Equal to 0
            • Then - Actions
              • Set SpeedBonusApplied[CloakLevelInit] = False
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of CloakingUnit[CloakLevelInit]) Less than 1.00
            • Then - Actions
              • Unit - Order CloakingUnit[CloakLevelInit] to Night Elf Demon Hunter - Deactivate Immolation
            • Else - Actions


The Culprit of all this frustration? The speed bonus. =|

Just Cloaking, without the speed bonus, doesn't warrant ANY of this functionality...Just getting the speed bonus to show properly like normal speed bonuses. =o
 
Last edited:
Status
Not open for further replies.
Top