• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[General] Flying Height Fixed In-Game Over Terrain Through Trigger (Flying Movement System)

Level 13
Joined
Jul 21, 2015
Messages
292
Hello all,

I have a system of triggers that function only half-way in my goal towards creating a movement system for flying with arrow key. I will attach a map that shows it off. But there are some issues with my triggers currently.

What Works:
*Unit's Heights Increases and Decrease With the Arrow Keys
*Triggers Begin With Levitation Ability Activated
*Maximum Flying Height Blocks Unit From Going Above Height of 1100
*A Secondary Unit Is What Maintains The Basic Flying Unit And Changes Is From Hover Movement Type To Flying Movement Type
*Camera Is Fixed Because I Am Using Arrow Keys For Up and Down (But Would Prefer W for Up and S for Down But Don't Know How to Do It)

What Doesn't Work Yet:
*Unit's Height Still Changes Depending On What Terrain Level They Are At, I would Like The Terrain Height To NOT Affect the Flying Height Of Unit While My Triggers Are Running
*Not Sure If More Efficient Way Could Be Created

Thank you!

I see a possible solution from this link.
But don't know how to incorporate for a singular, FLYING unit. I also don't really use JASS in my triggers so i would prefer a GUI version.

JASS:
local location loc = GetUnitLoc(unit)
local real groundZ = GetLocationZ(loc)
local real maxZ = 300
call SetUnitFlyHeight(unit,maxZ-groundZ,0)
call RemoveLocation(loc)
set loc = null

The Triggers Below Turn Off/On Based On Whether [Ability - Levitation] Being Activated. (Ability Levitation is based on Immolation)

TLDR: What I Want Is To Make My System More Efficient, And To Incorporate Ignoring Terrain Height When In Levitation Mode.


Edit (8/12): Figured out how to make the system work with some minor glitches. Would still appreciate some help to make it more smooth but understand it may be a bit too complicated. (Deleted triggers from my Original Post, but if you want to see again let me know) Also the map below does not contain the better version but i can post if ppl want.
 

Attachments

Last edited:
I whipped up a little sample map to show how you could do it (requires the latest patch).

For starters, instead of having two separate units (one for the ground and one for flying), you can add and remove the storm crow ability. This will allow you to set the unit's fly height via triggers:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Level of Crow Form for (Triggering unit)) Equal to 0
    • Then - Actions
      • Unit - Add Crow Form to (Triggering unit)
      • Unit - Remove Crow Form from (Triggering unit)
    • Else - Actions
That simplifies some of the logic a bit since you won't need to manage two units. The downside is that the unit will still have a ground movement type--so they won't be able to fly over cliffs.

If you do want them to fly over cliffs, you could instead use a transformation ability trick (e.g. druid of the claw morphing):
That's usually simpler than trying to keep a copy of the unit, especially since you'll need to update the unit's health/mana/items/cooldowns etc. to match.

Next, you'll need to use a periodic timer to "fight" against Warcraft 3's default behavior which brings a flying unit up or down depending on the terrain below them. I recommend keeping a variable, e.g. "LevitationGoalZ", to represent the absolute Z value that the unit should be positioned at. To understand that, consider a few examples where we want the unit to stay positioned at a Z of "700.0":
  • If the unit is on ground that is at Z=0, then we would want to set its flying height to "700.0" so we can reach that "goal" value
  • If the unit is on ground that is at Z=300, then we would want to set its flying height to "400.0" so we can reach that "goal" value
  • If the unit is on ground that is at Z=-300, then we would want to set its flying height to "1000.0" so we can reach that goal value
So at its essence, you just want to periodically set the flying height to "Goal Z - Ground Z". Since our unit has a minimum flying height of 0, we can use the "Unit - Position - Z" function (introduced in reforged) as a GUI-friendly way to get the terrain height:
  • Animation - Change LevitationUnit flying height to (LevitationGoalZ - (Position - Z of LevitationUnit)) at 0.00
Then it should do what you want. And as a neat little trick, instead of having separate timers for the up arrow/down arrow, you can just set some boolean variables like "UpArrowPressed" and "DownArrowPressed" and just add/subtract some height from LevitationGoalZ in that same periodic trigger. The math should automatically work out.

In the sample map below, I implemented it with arrays (indexed by the player number) so that you can have different players control different units. I also added some logic to clamp the height (so the goal Z doesn't go below the terrain, nor above 1100), and I added some logic to smoothly transition the flying height when the unit first casts the spell. The up and down movement is when I'm pressing the arrow keys. :thumbs_up:
giphy.gif
 

Attachments

I whipped up a little sample map to show how you could do it (requires the latest patch).

For starters, instead of having two separate units (one for the ground and one for flying), you can add and remove the storm crow ability. This will allow you to set the unit's fly height via triggers:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Level of Crow Form for (Triggering unit)) Equal to 0
    • Then - Actions
      • Unit - Add Crow Form to (Triggering unit)
      • Unit - Remove Crow Form from (Triggering unit)
    • Else - Actions
That simplifies some of the logic a bit since you won't need to manage two units. The downside is that the unit will still have a ground movement type--so they won't be able to fly over cliffs.

If you do want them to fly over cliffs, you could instead use a transformation ability trick (e.g. druid of the claw morphing):
That's usually simpler than trying to keep a copy of the unit, especially since you'll need to update the unit's health/mana/items/cooldowns etc. to match.

Next, you'll need to use a periodic timer to "fight" against Warcraft 3's default behavior which brings a flying unit up or down depending on the terrain below them. I recommend keeping a variable, e.g. "LevitationGoalZ", to represent the absolute Z value that the unit should be positioned at. To understand that, consider a few examples where we want the unit to stay positioned at a Z of "700.0":
  • If the unit is on ground that is at Z=0, then we would want to set its flying height to "700.0" so we can reach that "goal" value
  • If the unit is on ground that is at Z=300, then we would want to set its flying height to "400.0" so we can reach that "goal" value
  • If the unit is on ground that is at Z=-300, then we would want to set its flying height to "1000.0" so we can reach that goal value
So at its essence, you just want to periodically set the flying height to "Goal Z - Ground Z". Since our unit has a minimum flying height of 0, we can use the "Unit - Position - Z" function (introduced in reforged) as a GUI-friendly way to get the terrain height:
  • Animation - Change LevitationUnit flying height to (LevitationGoalZ - (Position - Z of LevitationUnit)) at 0.00
Then it should do what you want. And as a neat little trick, instead of having separate timers for the up arrow/down arrow, you can just set some boolean variables like "UpArrowPressed" and "DownArrowPressed" and just add/subtract some height from LevitationGoalZ in that same periodic trigger. The math should automatically work out.

In the sample map below, I implemented it with arrays (indexed by the player number) so that you can have different players control different units. I also added some logic to clamp the height (so the goal Z doesn't go below the terrain, nor above 1100), and I added some logic to smoothly transition the flying height when the unit first casts the spell. The up and down movement is when I'm pressing the arrow keys. :thumbs_up:
giphy.gif
This is just chef's kiss so awesome PurgeandFire. I already have you credited in my map for helping me with another trigger. And you were one of like 2 people who welcomed me into HIVE way back in 2015, so just want to say you're the bomb dude.

One thing I did edit your trigger Levitation Loop to include this if/then/else at the top of the trigger (in the Loop):

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • LevitationUnit[(Integer A)] Not equal to No unit
      • (LevitationUnit[(Integer A)] has buff Immolation) Equal to False
    • Then - Actions
      • Animation - Change LevitationUnit[(Integer A)] flying height to 0.00 at 300.00
      • Set VariableSet LevitationUnit[(Player number of (Triggering player))] = No unit
      • Special Effect - Create a special effect attached to the origin of LevitationUnit[(Integer A)] using Abilities\Spells\Orc\FeralSpirit\feralspirittarget.mdl
      • Special Effect - Destroy (Last created special effect)
    • Else - Actions

Do you think including this if/then in the Loop will help to check for when the Immolation (Levitation) ability runs out of mana?

I love the use of boolean making the Up/Down Pressed/Released triggers so neat and tidy now. :D

Other than that I love the effiecient triggers you have and how much time it saves me, because I was planning on copying and pasting my original post triggers for each player color so thank you for saving me time, completely reconstructing a brand new fly system from my idea, and making it work so much smoother!

ALSO: watch out soon because once I have it fully implemented I plan on sharing its usage to you in my RPG with a video ;)
 
Last edited:
Back
Top