• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] My lift spell is not lifting the same unit twice (Change unit flying height)

Status
Not open for further replies.
Level 20
Joined
Jun 27, 2011
Messages
1,864
I've been stucked with this bug for a couple of days and I'm losing my sanity trying to debug. The spell works as follows: you target a unit to lift and the unit will be lifted for a couple of seconds and be back down afterwards. The unit won't be able to move and is targeted as flying unit for the duration.

GIF: Imgur

It works fine and can handle multiple units at the same time but when you cast it on the same unit, the unit won't be lifted anymore.

GIF: Imgur

Here's the code:


  • Suffocate
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Suffocate
    • Actions
      • Set VariableSet Temp_Unit = (Target unit of ability being cast)
      • Set VariableSet Temp_Index = (Custom value of Temp_Unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Temp_Unit is A flying unit) Equal to True
        • Then - Actions
          • Set VariableSet S_MaxHeight[Temp_Index] = (Default flying height of Temp_Unit)
          • Unit Group - Add Temp_Unit to S_MainGroup
        • Else - Actions
          • Custom script: if UnitAddAbility(udg_Temp_Unit,'Amrf') then
          • Custom script: call UnitRemoveAbility(udg_Temp_Unit,'Amrf')
          • Custom script: endif
          • Set VariableSet S_MaxHeight[Temp_Index] = 240.00
          • Unit Group - Add Temp_Unit to S_IntroGroup
      • Set VariableSet S_CurrentHeight[Temp_Index] = (Current flying height of Temp_Unit)
      • Set VariableSet S_DefaultHeight[Temp_Index] = (Default flying height of Temp_Unit)
      • Unit - Set Unit: Temp_Unit's Integer Field: Targeted as ('utar') to Value: 4
      • Trigger - Turn on Suffocate Height <gen>



  • Suffocate Height
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in S_IntroGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet Temp_Index = (Custom value of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Suffocate ) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • S_CurrentHeight[Temp_Index] Less than or equal to S_MaxHeight[Temp_Index]
                • Then - Actions
                  • Set VariableSet S_CurrentHeight[Temp_Index] = (S_CurrentHeight[Temp_Index] + 6.66)
                  • Animation - Change (Picked unit) flying height to S_CurrentHeight[Temp_Index] at 0.00
                • Else - Actions
                  • Unit Group - Add (Picked unit) to S_MainGroup
                  • Unit Group - Remove (Picked unit) from S_IntroGroup.
            • Else - Actions
              • Unit Group - Remove (Picked unit) from S_IntroGroup.
              • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Naga\NagaDeath\NagaDeath.mdl
              • Special Effect - Set Scale of (Last created special effect) to 0.33
              • Special Effect - Destroy (Last created special effect)
              • Animation - Change (Picked unit) flying height to S_DefaultHeight[Temp_Index] at (S_MaxHeight[Temp_Index] x 8.00)
              • Unit - Set Unit: (Picked unit)'s Integer Field: Targeted as ('utar') to Value: 2
      • Unit Group - Pick every unit in S_MainGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet Temp_Index = (Custom value of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Suffocate ) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • S_BobbleUp[Temp_Index] Equal to True
                • Then - Actions
                  • Set VariableSet S_CurrentHeight[Temp_Index] = (S_CurrentHeight[Temp_Index] + 0.33)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • S_CurrentHeight[Temp_Index] Greater than or equal to (S_MaxHeight[Temp_Index] + 25.00)
                    • Then - Actions
                      • Set VariableSet S_BobbleUp[Temp_Index] = False
                    • Else - Actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • S_BobbleUp[Temp_Index] Equal to False
                • Then - Actions
                  • Set VariableSet S_CurrentHeight[Temp_Index] = (S_CurrentHeight[Temp_Index] - 0.20)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • S_CurrentHeight[Temp_Index] Less than or equal to (S_MaxHeight[Temp_Index] - 25.00)
                    • Then - Actions
                      • Set VariableSet S_BobbleUp[(Custom value of (Picked unit))] = True
                    • Else - Actions
                • Else - Actions
              • Animation - Change (Picked unit) flying height to S_CurrentHeight[Temp_Index] at 0.00
            • Else - Actions
              • Unit Group - Remove (Picked unit) from S_MainGroup.
              • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Naga\NagaDeath\NagaDeath.mdl
              • Special Effect - Set Scale of (Last created special effect) to 0.33
              • Special Effect - Destroy (Last created special effect)
              • Animation - Change (Picked unit) flying height to S_DefaultHeight[Temp_Index] at (S_MaxHeight[Temp_Index] x 8.00)
              • Unit - Set Unit: (Picked unit)'s Integer Field: Targeted as ('utar') to Value: 2
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in S_IntroGroup) Less than or equal to 0
          • (Number of units in S_MainGroup) Less than or equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions


I've also attached a test map for the spell.

Some things I should mention:
The spell is based on Entangle.
-------

I'm using Bribe's Unit Indexer as the only library for the spell. I've also tried to log if it's the same unit ID who is being targeted and it is the same.
-------

The S_IntroGroup unit group is for the lifting of the unit before it gets transferred to S_MainGroup which is for the "bobbling" up and down. The trigger periodically checks if the unit still has the spell's debuff or not and will remove it from the group if it doesn't have it anymore.
-------

  • Custom script: if UnitAddAbility(udg_Temp_Unit,'Amrf') then
  • Custom script: call UnitRemoveAbility(udg_Temp_Unit,'Amrf')
  • Custom script: endif
Adds and removes Storm Crow ability (Medivh's version) so that the unit can fly.
-------
  • Unit - Set Unit: Temp_Unit's Integer Field: Targeted as ('utar') to Value: 4
  • Unit - Set Unit: Temp_Unit's Integer Field: Targeted as ('utar') to Value: 2
Sets the unit's "Targeted as..." field, with 2 being ground and 4 being air. This makes it so that swordsmen for example cannot attack units under the spell. I've tried disabling these to see if they affect anything but they did not.

More things I've tried/noticed:
  • The flying height of the unit still increases even if it doesn't visually change the height.

  • I've tried setting the default height of the unit to 200 when it gets down and it will work just fine. The unit will be stuck in the air at 200 height but when I cast the spell on the same unit again, it will be pulled back down instead of following the height change.
    GIF: https://i.imgur.com/c8hUGxg.mp4

  • I've tried using the default Druid of the Talon Storm Crow abilities.

  • I've tried to use the JASS version of Change [Unit] Flying Height. Don't know if there's any difference.
Please help me, thank you!
 

Attachments

  • SuffocateDemo.w3m
    22.5 KB · Views: 31

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,596
I think this is a bug as I don't see any reason why it shouldn't work on the second cast. It just refuses to adjust the flying height.

I did notice that the Footman's flying height was only being reduced to 0.01 when you set it back down to 0.00. But that shouldn't interfere with the trigger in any way.

I believe the issue lies with some weird interaction with Entangling Roots. Because I created some triggers that allowed me to freely increase/decrease a unit's flying height, and tested this in your map, and it worked properly.


Also, here's a useful trigger for handling Storm Crow Form:
  • GUI AutoFly
    • Events
      • Game - UnitIndexEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Custom script: if UnitAddAbility(udg_UDexUnits[udg_UDex], 'Amrf') and UnitRemoveAbility(udg_UDexUnits[udg_UDex], 'Amrf') then
      • Custom script: endif
 
Last edited:
Status
Not open for further replies.
Top