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

[Solved] What's wrong with this trigger?

Status
Not open for further replies.
Level 21
Joined
May 29, 2013
Messages
1,567
I'm making a point target Hero ability with unlimited casting range that sends out an invisible unselectable flying unit to scout the map.

The unit travels in a straight line, starting from the position of the casting Hero (until it expires or reaches the map boundary), leaving behind a trail of expiring dummy units that provide vision and reveal invisible units.

Does anyone know why the last 25-ish created dummies always appear to have the level 3 duration and sight range?
  • Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Firefly
    • Actions
      • Set Firefly_Caster = (Triggering unit)
      • Set Firefly_SpellLevel = (Level of Firefly for Firefly_Caster)
      • -------- Duration of missle (distance covered/speed) --------
      • Set Firefly_A_Duration = (4.00 + ((Real(Firefly_SpellLevel)) x 4.00))
      • -------- Unit type of missle --------
      • Set Firefly_A_UType = Missile (Firefly)
      • Set Firefly_TempPoint = (Position of Firefly_Caster)
      • Set Firefly_TempPoint2 = (Target point of ability being cast)
      • Unit - Create 1 Firefly_A_UType for (Owner of Firefly_Caster) at Firefly_TempPoint facing Firefly_TempPoint2
      • Unit - Add a Firefly_A_Duration second Generic expiration timer to (Last created unit)
      • If (Firefly_SpellLevel Equal to 1) then do (Animation - Change (Last created unit)'s size to (100.00%, 100.00%, 100.00%) of its original size) else do (If (Firefly_SpellLevel Equal to 2) then do (Animation - Change (Last created unit)'s size to (133.00%, 133.00%, 100.00%) of its original size) else do (Animation - Change (Last created unit)'s size to (166.00%, 166.00%, 100.00%) of its original size))
      • Unit - Set life of (Last created unit) to (Real(Firefly_SpellLevel))
      • Unit Group - Add (Last created unit) to Firefly_Dummy
      • Custom script: call RemoveLocation(udg_Firefly_TempPoint)
      • Custom script: call RemoveLocation(udg_Firefly_TempPoint2)
      • Trigger - Turn on Move <gen>
  • Move
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Firefly_Dummy) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in Firefly_Dummy and do (Actions)
            • Loop - Actions
              • Set Firefly_TempUnit = (Picked unit)
              • Set Firefly_SpellLevel = (Integer((Life of Firefly_TempUnit)))
              • -------- Speed of missle (per second) --------
              • Set Firefly_A_Real = 1000.00
              • Set Firefly_TempPoint = (Position of Firefly_TempUnit)
              • Set Firefly_TempPoint2 = (Firefly_TempPoint offset by (Firefly_A_Real / 25.00) towards (Facing of Firefly_TempUnit) degrees)
              • If (Firefly_SpellLevel Equal to 1) then do (Unit - Add Sight Range Firefly Level 1 to Firefly_TempUnit) else do (If (Firefly_SpellLevel Equal to 2) then do (Unit - Add Sight Range Firefly Level 2 to Firefly_TempUnit) else do (Unit - Add Sight Range Firefly Level 3 to Firefly_TempUnit))
              • If (Firefly_SpellLevel Equal to 1) then do (Unit - Add True Sight Firefly Level 1 to Firefly_TempUnit) else do (If (Firefly_SpellLevel Equal to 2) then do (Unit - Add True Sight Firefly Level 2 to Firefly_TempUnit) else do (Unit - Add True Sight Firefly Level 3 to Firefly_TempUnit))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (PlayableArea <gen> contains Firefly_TempPoint2) Equal to True
                • Then - Actions
                  • Unit - Move Firefly_TempUnit instantly to Firefly_TempPoint2
                  • Unit - Create 1 Trail (Firefly) for (Owner of Firefly_TempUnit) at Firefly_TempPoint2 facing Default building facing degrees
                  • Set Firefly_TempUnit2 = (Last created unit)
                  • If (Firefly_SpellLevel Equal to 1) then do (Unit - Add Sight Range Firefly Level 1 to Firefly_TempUnit2) else do (If (Firefly_SpellLevel Equal to 2) then do (Unit - Add Sight Range Firefly Level 2 to Firefly_TempUnit2) else do (Unit - Add Sight Range Firefly Level 3 to Firefly_TempUnit2))
                  • If (Firefly_SpellLevel Equal to 1) then do (Unit - Add True Sight Firefly Level 1 to Firefly_TempUnit2) else do (If (Firefly_SpellLevel Equal to 2) then do (Unit - Add True Sight Firefly Level 2 to Firefly_TempUnit2) else do (Unit - Add True Sight Firefly Level 3 to Firefly_TempUnit2))
                  • If (Firefly_SpellLevel Equal to 1) then do (Unit - Add a 30.00 second Generic expiration timer to (Last created unit)) else do (If (Firefly_SpellLevel Equal to 2) then do (Unit - Add a 45.00 second Generic expiration timer to (Last created unit)) else do (Unit - Add a 60.00 second Generic expiration timer to (Last created unit)))
                  • Custom script: call RemoveLocation (udg_Firefly_TempPoint)
                  • Custom script: call RemoveLocation (udg_Firefly_TempPoint2)
                  • Set Firefly_TempUnit = No unit
                  • Set Firefly_TempUnit2 = No unit
                • Else - Actions
                  • Unit - Remove Firefly_TempUnit from the game
                  • Custom script: call RemoveLocation (udg_Firefly_TempPoint)
                  • Custom script: call RemoveLocation (udg_Firefly_TempPoint2)
                  • Set Firefly_TempUnit = No unit
                  • Set Firefly_TempUnit2 = No unit
        • Else - Actions
          • Custom script: call RemoveLocation (udg_Firefly_TempPoint)
          • Custom script: call RemoveLocation (udg_Firefly_TempPoint2)
          • Set Firefly_TempUnit = No unit
          • Set Firefly_TempUnit2 = No unit
          • Trigger - Turn off (This trigger)
 
Last edited:
Level 20
Joined
Aug 13, 2013
Messages
1,696
The mistake:
Set Firefly_SpellLevel = (Integer((Life of Firefly_TempUnit))) should be Set Firefly_SpellLevel = (Level of Firefly for Firefly_Caster)

The problem:
It's not MUI. The caster will be replaced by a new referenced caster. Just a warning that the level value can be messed up.

EDIT:

It looks like you're managing to make it MUI by relying on a unit's life to save the level of the ability :xxd:

Anyway to debug things up, you should un-locust the missile firefly and check if its life properly changes.
Or else remove the invulnerability as it may interfere.
Make sure the hit points regeneration is 0 or else it will always go up which will screw levels over.

(I didn't bother to mention the inefficiency doings inside the script)

Although, if it works. I see that this is a bizarre way just to store such ability level based on unit's life.
 
Last edited:
Level 21
Joined
May 29, 2013
Messages
1,567
It looks like you're managing to make it MUI by relying on a unit's life to save the level of the ability :xxd:
Yep, but I can't take the credit for that idea since the triggers were not made by me; I just edited a spell that's kinda similar to what I'm trying to make.
Anyway to debug things up, you should un-locust the missile firefly and check if its life properly changes.
Or else remove the invulnerability as it may interfere.
Make sure the hit points regeneration is 0 or else it will always go up which will screw levels over.
The regeneration is set to 0 and the HP doesn't change. Now I noticed the level 3 dummies actually always spawn after the missile expires.
(I didn't bother to mention the inefficiency doings inside the script)
I don't know much about triggers, so I'd appreciate your advice on how I can make it more efficient, as long as it's not too complicated.
 

Wrda

Spell Reviewer
Level 25
Joined
Nov 18, 2012
Messages
1,870
Apparently, when Firefly_TempUnit gets removed from game you aren't removing it from the group, which...logically you shouldn't need but you know wc3's peculiar stuff, better be safe than sorry. Those simple if-blocks are a little triggering, you're spamming those 5 times and could be reduced to twice instead. Right now, they're evaluted unnecessarily 5 times.
Pick Every Unit in the group won't run anything if the group is empty already, no need to check number of units in it.
 
Level 21
Joined
May 29, 2013
Messages
1,567
Apparently, when Firefly_TempUnit gets removed from game you aren't removing it from the group, which...logically you shouldn't need but you know wc3's peculiar stuff, better be safe than sorry.
Firefly_TempUnit only gets removed from the game if it leaves the playable map area region and when that happens no level 3 dummy unit are left behind. However, Firefly_TempUnit is usually killed by an expiration timer. Do I need to somehow detect when the expiration timer kills it and then remove it from the unit group?
Those simple if-blocks are a little triggering, you're spamming those 5 times and could be reduced to twice instead. Right now, they're evaluted unnecessarily 5 times.
What do you mean?
Pick Every Unit in the group won't run anything if the group is empty already, no need to check number of units in it.
How else can I turn off the periodic trigger when it's not used?
 
Last edited:
Level 20
Joined
Aug 13, 2013
Messages
1,696
I don't know much about triggers, so I'd appreciate your advice on how I can make it more efficient, as long as it's not too complicated.
I documented every changes I made.

However, care to explain why the dummies have ghost ability on them? ^^
Is this for pathing obstructions, unit's transparency, hiding for player, or something?
 

Attachments

  • Firefly.w3x
    235.1 KB · Views: 23
Level 21
Joined
May 29, 2013
Messages
1,567
I documented every changes I made.
Thank you! :smile:
However, care to explain why the dummies have ghost ability on them?
It's to prevent the enemy from knowing they're being spied upon. That's also the reason why I'm using True Sight instead of Far Sight.

By the way, True Sight and Item Sight Range Bonus are one of those abilities that cannot be leveled up properly; they always use the level 1 stats when they're made to have more than one level, so I have to make a different ability for each level.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
By the way, True Sight and Item Sight Range Bonus are one of those abilities that cannot be leveled up properly; they always use the level 1 stats when they're made to have more than one level, so I have to make a different ability for each level.
Oh right. Just change the ability variables for True Sight and Sight Range
to ability arrays like: Firefly_TrueSight_Ability[1] = True Sight Level 1 and so on... (Just follow what I did to other constants)
And you'll notice that Unit - Add Ability and Set Ability functions will turn red as the variable type changes. Just re-edit them.
 
Status
Not open for further replies.
Top