• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Unit Flying Height

Status
Not open for further replies.
Level 4
Joined
Sep 6, 2012
Messages
88
Hi guys !

Can you look at this segment of triggers and help me a bit ?

  • Events
    • Time - Every 0.01 seconds of game time
  • Conditions
  • Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (FinishingTouch_TargetGroup is empty) Equal to False
    • Then - Actions
      • Unit Group - Pick every unit in FinishingTouch_TargetGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is in FinishingTouch_HitTargets) Equal to False
            • Then - Actions
              • Unit - Add Crow Form to (Picked unit)
              • Animation - Change (Picked unit) flying height to 500.00 at 1500.00
              • Animation - Change (Picked unit) flying height to 0.00 at 1500.00
              • Unit - Remove Crow Form from (Picked unit)
              • Unit Group - Add (Picked unit) to FinishingTouch_HitTargets
              • Set FinishingTouch_AliveTime = 0
            • Else - Actions
    • Else - Actions
I cannot make the "Picked Unit" fly into the air and get down to the ground. I tried the Wait action but it didn't seem to work. The picked units just stayed on the air for the whole time. Can you help me tell the problem of this trigger and how to fix it ? Thanks a lot !
 
Level 11
Joined
May 8, 2009
Messages
275
First never use "Every 0.01 seconds of game time", 0.03 is far enough.
Though in your case it's not even required. To make a unit fly you just have to add and remove the crow form ability once; either when they enter playable map, or at map initialization.

  • Unit - Add Crow Form to (Picked unit)
  • Unit - Remove Crow Form from (Picked unit)
In a second trigger, create the event that is supposed to trigger your stuff, let's say
  • Event - Player 1 skips a cinematic sequence
Then pick all your units in the Unit Group, change their flying height to 500 at 300. Wait the desired amount of time (when they'll be in the air) and change their flying height once again but to 0 at 300.
 
Level 4
Joined
Sep 6, 2012
Messages
88
Hi,

@Xtrheo: I had to use 0.01 time inverval since I'm making an Elune Arrow-like ability, and setting it as 0.03 second made the projectile either fly really slow or look not smooth. And I don't see how your suggestion is different from what I've already did, but anyway, thank you for replying !

@gorillabull: If you look closer, they are 2 different unit groups, the first one is to pick all units within range of the projectile, and the second one is to ensure that no unit will be affected by the skill effect twice since there's a possibility that they are still within the projectile range when the next loop runs. And I did send them fly higher, just cannot let them be down. Thank you for the comment !
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I had to use 0.01 time inverval since I'm making an Elune Arrow-like ability, and setting it as 0.03 second made the projectile either fly really slow or look not smooth. And I don't see how your suggestion is different from what I've already did, but anyway, thank you for replying !
This is to improve the trigger's efficiency to reduce "lag" or drops in FPS of your game by decreasing action per second.
Currently you are moving the unit 100 times per second, compared to (0.03s interval), you will only move the unit 33 times per second, now you see 100 compared to 33, it's a big improvement.

A 0.03s interval will make the unit to move smoothly, trust me, this is the standard interval we coders of Warcraft III usually use to move things like projectiles, dummy, etc.
 
Level 4
Joined
Sep 6, 2012
Messages
88
I see your point, but that is not my current problem at the moment :). I'll keep the advice in my mind anyway !

Somehow, this just never works for me. The affected units just don't want to come back down once they get sent on the air. What's the problem here ?
  • Unit Group - Pick every unit in FinishingTouch_TargetGroup and do (Actions)
    • Loop - Actions
      • Unit - Add Crow Form to (Picked unit)
      • Unit - Remove Crow Form from (Picked unit)
      • Animation - Change (Picked unit) flying height to 700.00 at 700.00
      • Wait 0.90 seconds
      • Animation - Change (Picked unit) flying height to 0.00 at 1000.00
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I'll have to think it's not the problem with the code itself, I think it's the problem with your own ways to construct the actions.
I mean, from where does the variable FinishingTouch_TargetGroup comes from ?
You don't reveal to us your full code, how can we identify the problem ?
Perhaps it has to do with your trigger itself (perhaps you don't add the unit in the Unit Group correctly ?). It has endless possibilities, we can't troubleshoot.

But that's not the problem as I already see the problem right here;
  • Animation - Change (Picked unit) flying height to 500.00 at 1500.00
  • Animation - Change (Picked unit) flying height to 0.00 at 1500.00
As you can see, you did those 2 actions in an instant, no delay at all.
The moment the unit wants to ascend, you're forcing him to go back down, that is why it will never go up.

For the script you showed on post #6 does not work because Unit Group action does not work very well with Wait, you should avoid it, it will cause bug.

So you want the unit to fly to the air for 1 second, is it ?

You should make the unit fly to that height (and has a delay) for it to come back down (you're doing great putting that Wait action there but Wait simply can't cooperate with Unit Group action).

I'm too lazy to recreate something that I had did before, try my system: http://www.hiveworkshop.com/forums/...stem-v1-2-a-222122/?prev=status=r2&u=defskull
If you don't understand, PM me.
 
Level 4
Joined
Sep 6, 2012
Messages
88
Thanks defskull for your detailed explanations. I looked at your map but it was too complicated for me to understand, but thank you.

Somehow, I managed to make a unit go up and down using separate loops. Here is my trigger:

  • Finishing Touch Movement
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
      • (Unit-type of FinishingTouch_Unit) Equal to Finishing Touch Tornado
    • Actions
      • Set Temp_Point = (Position of FinishingTouch_Unit)
      • Unit - Move FinishingTouch_Unit instantly to (Temp_Point offset by 25.00 towards FinishingTouch_FacingAngle degrees), facing FinishingTouch_FacingAngle degrees
      • Set FinishingTouch_UnitsUp = (Units within 200.00 of Temp_Point matching ((((Matching unit) Not equal to FinishingTouch_Owner) and ((Matching unit) Not equal to FinishingTouch_Unit)) and ((((Matching unit) is A structure) Equal to False) and (((Unit-type of (Matching unit)) Not equal to
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (FinishingTouch_UnitsUp is empty) Equal to False
        • Then - Actions
          • Unit Group - Pick every unit in FinishingTouch_UnitsUp and do (Actions)
            • Loop - Actions
              • Unit - Add Crow Form to (Picked unit)
              • Unit - Remove Crow Form from (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current flying height of (Picked unit)) Less than 600.00
                  • ((Picked unit) is in FinishingTouch_UnitsDown) Equal to False
                • Then - Actions
                  • Animation - Change (Picked unit) flying height to ((Current flying height of (Picked unit)) + 40.00) at 0.00
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Current flying height of (Picked unit)) Greater than or equal to 600.00
                    • Then - Actions
                      • Unit Group - Add (Picked unit) to FinishingTouch_UnitsDown
                    • Else - Actions
                • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (FinishingTouch_UnitsDown is empty) Equal to False
        • Then - Actions
          • Unit Group - Pick every unit in FinishingTouch_UnitsDown and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current flying height of (Picked unit)) Greater than 0.01
                • Then - Actions
                  • Animation - Change (Picked unit) flying height to ((Current flying height of (Picked unit)) - 30.00) at 0.00
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Current flying height of (Picked unit)) Less than or equal to 0.01
                    • Then - Actions
                      • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • Unit Group - Remove (Picked unit) from FinishingTouch_UnitsDown
                    • Else - Actions
                • Else - Actions
        • Else - Actions
      • Set FinishingTouch_UnitsNoUpDown = (Units in (Playable map area) matching ((((Matching unit) is in FinishingTouch_UnitsUp) Equal to False) and ((((Matching unit) is in FinishingTouch_UnitsDown) Equal to False) and (((Current flying height of (Matching unit)) Greater than 0.01) and ((Current fl
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (FinishingTouch_UnitsNoUpDown is empty) Equal to False
        • Then - Actions
          • Unit Group - Pick every unit in FinishingTouch_UnitsNoUpDown and do (Actions)
            • Loop - Actions
              • Animation - Change (Picked unit) flying height to ((Current flying height of (Picked unit)) - 30.00) at 0.00
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current flying height of (Picked unit)) Less than or equal to 0.01
                • Then - Actions
                  • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Unit Group - Remove (Picked unit) from FinishingTouch_UnitsNoUpDown
                • Else - Actions
        • Else - Actions
      • Custom script: call DestroyGroup (udg_FinishingTouch_TargetGroup)
      • Custom script: call DestroyGroup (udg_FinishingTouch_HitTargets)
I have a problem at the moment. As you can see, I'm using 3 different unit groups to store units' states. However, since the method I use for lifting units up and down requires several unit groop loops for each unit,

  • Animation - Change (Picked unit) flying height to ((Current flying height of (Picked unit)) + 40.00) at 0.00
So I can't destroy the unit group after one loop like usual. It has to be sometimes later, and I have no idea how I can safely remove leaks after the unit groups have done their tasks. The current DestroyGroup functions destroys my unit groups each time the trigger runs, which I'm afraid it might get in the way of my unit flying height continuous settings. Can anyone help me with this ? Thanks a lot.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
is it save to use wait in ForGroup?
maybe thats why it doesnt work
also in the huge trigger right in second line you have a point leak, you should have another point variable which is set to offset and then remove it with the custom script
 
Level 4
Joined
Sep 6, 2012
Messages
88
Oh yeah, I didn't know that. Thanks a lot, How about the way to safely destroy my unit group ?

@edo494: I took a look at the offset value, but it turns out to be a simple real value, not a point value. Hmm, I think it wouldn't leak... Anyone can confirm ?
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
  • Unit - Move FinishingTouch_Unit instantly to (Temp_Point offset by 25.00 towards FinishingTouch_FacingAngle degrees), facing FinishingTouch_FacingAngle degrees
in fact, the Temp_Point offset by 25.00 towards FinishingTouch_FacingAngle degrees creates a new location,
JASS:
call SetUnitPositionLoc(udg_unit, Location(Temp_Point + 25*Cos(FinishingTouch_FacingAngle*bj_DEGTORAD), Temp_Point + 25*Sin(FinishingTouch_FacingAngle*bj_DEGTORAD)))
so yea its a point leak, it should be
  • Set Temp_Point = (Position of FinishingTouch_Unit)
  • Set Temp_Point2 = Temp_Point offset by 25.00 towards FinishingTouch_FacingAngle degrees)
  • Unit - Move FinishingTouch_Unit instantly to (Temp_Point offset by 25.00 towards FinishingTouch_FacingAngle degrees), facing FinishingTouch_FacingAngle degrees
  • ...
  • ...
  • Custom script: call RemoveLocation (udg_Temp_Point)
  • Custom script: call RemoveLocation (udg_Temp_Point2)
 
Level 8
Joined
Oct 26, 2008
Messages
387
Hi guys !

Can you look at this segment of triggers and help me a bit ?


  • Animation - Change (Picked unit) flying height to 500.00 at 1500.00
  • Animation - Change (Picked unit) flying height to 0.00 at 1500.00
What in God's name is this susposed to do?
You increase the unit's height, with a process that needs 0,3 seconds to take place, and then you reduce the unit's height, with a process that also needs 0,3 seconds to take place. But you give those two opposite orders simultaneously. From my point of view its bound to fail..



This is to improve the trigger's efficiency to reduce "lag" or drops in FPS of your game by decreasing action per second.
Currently you are moving the unit 100 times per second, compared to (0.03s interval), you will only move the unit 33 times per second, now you see 100 compared to 33, it's a big improvement.

A 0.03s interval will make the unit to move smoothly, trust me, this is the standard interval we coders of Warcraft III usually use to move things like projectiles, dummy, etc.

I thought 0,03 seconds was the minimum time the editor would recognize :z
 
Status
Not open for further replies.
Top