• 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.

Height

Status
Not open for further replies.
Level 9
Joined
Apr 7, 2010
Messages
480
i created two triggers

one to detect when the up arrow key is press
then two, every sec the unit's height increase
but my problem is.
the unit won't increase height.

can someone show me the exact triggers??
 
Give the unit Storm Crow ability.

My solution is similar.
I usually just create a system that adds the Storm crow form ability to every unit on
entering the map.
Also, be sure to remove the ability immediately after you give it to the units :)

That way, I don't have to repeat the same function calls over and over again.
It all depends on the kind of map you have.

For most maps, my solution wouldn't be logical.
For others, it's possibly the best.

Just go with Makers solution :)
 
Level 9
Joined
Apr 7, 2010
Messages
480
i was planning on using triggers instead of abilities because i'll be adding decrease height too.

something like when up arrow is press the unit's height increases per second but when release it goes down per second until the unit's normal height. and if the down arrow is press the unit's height decreases per second until release then goes up per second until normal height.

but if storn crow ability works on both increase and decrease, sure i'll try it. (first time) ^^
 
Level 9
Joined
Apr 7, 2010
Messages
480
doesn't work. i'm not good at making triggers and doesn't know how to detect leaks. so can you guys fix this?
 

Attachments

  • TEST.w3x
    17.4 KB · Views: 41
JASS:
library GiveUnitsZ initializer Init
    // Boolexprs leak, so I created this function to avoid the leak
    private function True takes nothing returns boolean
        return true
    endfunction
    
    private function Act2 takes nothing returns nothing
        local unit u = GetTriggerUnit()
        call UnitAddAbility(u,'Arav')
        call UnitRemoveAbility(u,'Arav')
        set u = null
    endfunction
    
    private function Give takes nothing returns nothing
        local unit u = GetEnumUnit()
        call UnitAddAbility(u,'Arav')
        call UnitRemoveAbility(u,'Arav')
        set u = null
    endfunction
    
    private function Act takes nothing returns nothing
        local group g = CreateGroup()
        call GroupEnumUnitsInRange(g,0.00,0.00,9999999.00, function True)
        call ForGroup(g, function Give)
        call DestroyGroup(g)
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterEnterRegion(t,bj_mapInitialPlayableArea,function True)
        call TriggerAddAction(t, function Act2)
        call TimerStart(CreateTimer(),0.00,false,function Act)
        set t = null
    endfunction
endlibrary

Just copy this library into your code.
It doesn't require you to do anything ^^
Just paste it, and it will do the ability adding for you :)
 
Last edited:
Level 9
Joined
Apr 7, 2010
Messages
480
what should i do? i don't understand jass
 

Attachments

  • Problem.jpg
    Problem.jpg
    136.8 KB · Views: 99
Last edited:
Level 9
Joined
Apr 7, 2010
Messages
480
i changed both true to null. still one more problem. what should i do now?
 

Attachments

  • Problem.jpg
    Problem.jpg
    128.4 KB · Views: 91
Its because it was a Rect not a region... you could do this:
JASS:
private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local region rectRegion = CreateRegion()
        call RegionAddRect(rectRegion, bj_mapInitialPlayableArea)
        call TriggerRegisterEnterRegion(t, rectRegion, null)
        call TriggerAddAction(t, function Act2)
        call TimerStart(CreateTimer(),0.00,false,function Act)
        set t = null
endfunction
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
What adding and removing the crow form ability does it allow you to alter any unit's flying height.

Normally only flying units use a fly height but adding that ability makes all units use one. Better still, it need not be kept on the unit or given to the unit ever again once a unit has it.

When changing flying height, be aware the change occurs over time. With a rate of change of 1, it will change 1 unit every second so from 0 to a flying height of 1000 will take 1000 seconds (about 10 minutes). With a rate of 2000, 0 to 1000 will take 0.5 seconds. I think a rate of 0 means instant.
 
Level 9
Joined
Apr 7, 2010
Messages
480
the jass has no errors but doesn't work on game. doesn't increase the unit's height nor decrease when i press up/down arrow keys.
 
Level 9
Joined
Apr 7, 2010
Messages
480
doesn't work for decrease.

btw, does the jass i copied is something like crow form?
 
Level 9
Joined
Apr 7, 2010
Messages
480
its in first page, the file name is TEST

you might laugh at my triggers, i'm just a noob at editing^^ lol
 
Level 9
Joined
Apr 7, 2010
Messages
480
This is updated. *the triggers in the first page has height limits*

  • Press Up
    • Events
      • Player - Player 1 (Red) Presses the Up Arrow key
    • Conditions
    • Actions
      • if (All Conditions are True)then do (Then Action) else do (Else Action)
        • If - Conditions
        • Then - Actions
          • Trigger - Turn on Height Increase
          • Trigger - Turn off Height Normal
        • Else - Actions
  • Press Down
    • Events
      • Player - Player 1 (Red) Presses the Down Arrow key
    • Conditions
    • Actions
      • if (All Conditions are True)then do (Then Action) else do (Else Action)
        • If - Conditions
        • Then - Actions
          • Trigger - Turn on Height Decrease
          • Trigger - Turn off Height Normal
        • Else - Actions
  • Release Up
    • Events
      • Player - Player 1 (Red) Releases the Up Arrow key
    • Conditions
    • Actions
      • if (All Conditions are True)then do (Then Action) else do (Else Action)
        • If - Conditions
        • Then - Actions
          • Trigger - Turn off Height Increase
          • Trigger - Turn on Height Normal
        • Else - Actions
  • Release Down
    • Events
      • Player - Player 1 (Red) Releases the Down Arrow key
    • Conditions
    • Actions
      • if (All Conditions are True)then do (Then Action) else do (Else Action)
        • If - Conditions
        • Then - Actions
          • Trigger - Turn off Height Decrease
          • Trigger - Turn on Height Normal
        • Else - Actions
  • Height Increase
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • if (All Conditions are True)then do (Then Action) else do (Else Action)
        • If - Conditions
        • Then - Actions
          • Animation - Change Unit flying height to (Current flying height to Unit) + 2.00) at 0.00
        • Else - Actions
  • Height Decrease
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • if (All Conditions are True)then do (Then Action) else do (Else Action)
        • If - Conditions
        • Then - Actions
          • Animation - Change Unit flying height to (Current flying height to Unit) - 2.00) at 0.00
        • Else - Actions
  • Height Normal
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • if (All Conditions are True)then do (Then Action) else do (Else Action)
        • If - Conditions
          • (Current flying height of Unit) Greater than 380.00
        • Then - Actions
          • Animation - Change Unit flying height to (Current flying height to Unit) - 2.00) at 0.00
        • Else - Actions
          • Animation - Change Unit flying height to (Current flying height to Unit) + 2.00) at 0.00
 
Level 9
Joined
Apr 7, 2010
Messages
480
but i created a trigger to detect unit's flying height.

events - time - every 1.00 seconds of game time
actions - Game - Display to (All players) for 1.00 seconds the text : (String ((Curent flying height of Unit)))

^^ so i should know if the unit really does change height
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
You hadn't set any unit to the unit variable.

I added this trigger:

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Unit = Paladin 0001 <gen>
      • Custom script: call UnitAddAbility(udg_Unit, 'Arav')
      • Custom script: call UnitRemoveAbility(udg_Unit, 'Arav')
      • Camera - Lock camera target for Player 1 (Red) to Unit, offset by (0.00, 0.00) using Default rotation
Now you can test your system, it alters the flying height of the unit. The logic with the triggers might be flawed, but at least you can test it.

http://www.hiveworkshop.com/forums/pastebin.php?id=78dj9k
 
Level 9
Joined
Apr 7, 2010
Messages
480
i already have set a unit to the Unit variable (i forgot to show triggers).

one last problem, the increase height is working but the decrease doesn't.

any solutions?
 
Level 9
Joined
Apr 7, 2010
Messages
480
As long as one presses up, the unit's height will increase.
As long as one presses down, the unit's height will decrease.
If a button is released, the height will return back to normal.

@adiktuz, nah. i'm testing it one by one.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Make sure "Unit" is a reference to an actual unit.

Also you may wish to reduce coupling in your script by making 1 trigger which handles all height changes.

The only difference between height decrease and heigh increase is a -2 and +2, thus you could make 1 trigger for both by simply changing a variable between -2 and +2. When up arrow is pressed you set it to +2 while down arrow sets it to -2. Releasing sets the variable to 0. You could do a slightly better system by keeping track of what is currently pressed or released but that may also have its own inaccuracies so what I described should work fine.

You also have a bug whereby if both up and down is pressed and you release up it will be returning to normal and going down which is most likly not intended as it will shoot the unit down and twice normal rate. My coupling improvement described above would fix this bug.

Your return to normal system currently forms an ossilator around the equivelence class boundaries for the conditional statement. You should turn off the return to normal trigger when it reaches the "normal" height as it is no longer needed.

Infact, what you could do is remove the return to normal trigger all together for even less coupling so that you have 1 trigger controling all height changes. To return to normal, you calculate which direction it has to go (up or down) and set the variable I described earlier while starting a timer which will wait the required duration for it to reach normal and when it does it will set the height change to 0. Logically pressing any keys during this time should stop the timer and overwrite the direction.

Coupling is how linked code is (how many references to other code). Generally you want as little coupling as possible as it makes maintenence harder as well as can result in one making more errors (common one is to change a piece of code bug forget it is mirrored somewhere else).
 
Level 9
Joined
Apr 7, 2010
Messages
480
PROBLEM SOLVED!

the solution was... OBJECT EDITOR - Movement - Height 380
Height Minimum 380

making increase possible but decrease impossible. so i edited height minimum to 0 ^^
thanks guys.
 
Level 9
Joined
Apr 7, 2010
Messages
480
yea, i deleted mine and used maker's, his triggers doesn't have any problems right?.
 
Status
Not open for further replies.
Top