(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Resources > Submissions > "Graveyard"

"Graveyard" Resources which were not approved are moved to this section.

 
 
LinkBack Thread Tools Display Modes
Old 02-03-2008, 10:35 PM   #1 (permalink)
 
GhostWolf's Avatar

Just another Nobody
 
Join Date: Jul 2007
Posts: 2,384

GhostWolf is a jewel in the rough (247)GhostWolf is a jewel in the rough (247)GhostWolf is a jewel in the rough (247)GhostWolf is a jewel in the rough (247)


Raising/Lowering heights with a timer

I made this nice and easy code that raises or lowers units based on a timer.
You set the height which the unit will stop moving/die (you choose if he dies based on a boolean) and what speed he moves at.

Here is the code with more explenations inside it

//****************************************************************************************
// Move unit's height with timers
// call goingdown(whichUnit,speed,deadheight,kill)
//
// Warning ! The dead height CANNOT BE 0 ! (I think this is a bug in warcraft)
// If you want your units to die/stop on the ground, make the deadheight=1
//
// If you want the unit to go up, its height should be -lower- then the deadheight and vice versa.
//
// Remember: to calculate speed per second, do your speed value * 50 !


function goingdowntimer takes nothing returns nothing
       local timer t = GetExpiredTimer()
       local boolean kill = GetHandleBoolean(t, "kill")
       local real deadheight = GetHandleReal(t, "deadheight")
       local unit whichUnit = GetHandleUnit(t, "whichUnit")
       local real speed = GetHandleReal(t, "speed")
       local real whichUnitStartheight = GetHandleReal(t, "whichUnitStartheight")
       local real whichUnitHeight = GetUnitFlyHeight(whichUnit)
       if deadheight > whichUnitStartheight then
            if whichUnitHeight < deadheight then
                call SetUnitFlyHeight(whichUnit, whichUnitHeight+speed, 1000000)
            else
                call FlushHandleLocals(t)
                call DestroyTimer(t)
                if kill == true then
                    call KillUnit(whichUnit)
                endif
            endif
elseif deadheight < whichUnitStartheight then
            if whichUnitHeight > deadheight then
                call SetUnitFlyHeight(whichUnit, whichUnitHeight-speed, 1000000)
            else
                call FlushHandleLocals(t)
                call DestroyTimer(t)
                call KillUnit(whichUnit)
            endif
       endif
       set t = null
       set whichUnit = null
endfunction
function goingdown takes unit whichUnit, real speed, real deadheight, boolean kill returns nothing
       local timer t = CreateTimer()
       local real whichUnitStartheight = GetUnitFlyHeight(whichUnit)
       call SetHandleBoolean(t, "kill", kill)
       call SetHandleReal(t, "whichUnitStartheight", whichUnitStartheight)
       call SetHandleReal(t, "deadheight", deadheight)
       call SetHandleHandle(t, "whichUnit", whichUnit)
       call SetHandleReal(t, "speed", speed)
       call TimerStart(t, 0.02, true, function goingdowntimer)
       set t = null
endfunction


Example raising units and killing them when they get to the max height you want

function Example_Actions takes nothing returns nothing
    local unit whichUnit = GetTriggerUnit()
    call goingdown(whichUnit,10,800,true) // WhichUnit will raise at 500 per second untill
                                          // he gets to a height of 800 and then he will die
endfunction

//==== Init Trigger NewTrigger ====
function InitTrig_Example takes nothing returns nothing
    set gg_trg_Example = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Example, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction(gg_trg_Example, function Example_Actions)
endfunction


Example lowering units and not killingthem when they get to the max (min) height you want

function Example_Actions takes nothing returns nothing
    local unit whichUnit = GetTriggerUnit()
    call goingdown(whichUnit,5,1,false) // WhichUnit will get lowerd at 250 per second untill
                                          // he gets to a height of 1
endfunction

//==== Init Trigger NewTrigger ====
function InitTrig_Example takes nothing returns nothing
    set gg_trg_Example = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Example, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction(gg_trg_Example, function Example_Actions)
endfunction


I will say it again, please notice that the lowering/raising is based on the unit's current height which means that if you give him a value higher then his height - he will be flying up, if you give him a lower value then his height, he will descend down.
GhostWolf is offline  
Old 02-06-2008, 01:16 AM   #2 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

This is useless due to the 'rate' parameter on SetUnitFlyHeight. (Except for the Kill, but that is very easy to do since rate works fine anyways)

Also, 0 rate works as instant as well as a very large number.
PurplePoot is offline  
Old 02-06-2008, 01:38 AM   #3 (permalink)
Spell and Map Moderator
 
Dr Super Good's Avatar

The Helpful Personage
 
Join Date: Jan 2005
Posts: 4,261

Dr Super Good is a name known to all (690)Dr Super Good is a name known to all (690)Dr Super Good is a name known to all (690)Dr Super Good is a name known to all (690)


0 rate is better than a very large number probably is more demanding and not as instant as 0.
Dr Super Good is offline  
Old 02-06-2008, 01:42 AM   #4 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

Not that it really matters anyways, as this entire function is basically a slower SetUnitFlyHeight. (I'll graveyard this soon, just waiting for the author to respond)
PurplePoot is offline  
Old 02-06-2008, 12:43 PM   #5 (permalink)
 
GhostWolf's Avatar

Just another Nobody
 
Join Date: Jul 2007
Posts: 2,384

GhostWolf is a jewel in the rough (247)GhostWolf is a jewel in the rough (247)GhostWolf is a jewel in the rough (247)GhostWolf is a jewel in the rough (247)


Quote:
Originally Posted by PurplePoot View Post
This is useless due to the 'rate' parameter on SetUnitFlyHeight. (Except for the Kill, but that is very easy to do since rate works fine anyways)

Hmm... I guess I never thought about it that way... guess you're right
GhostWolf is offline  
Old 02-06-2008, 06:24 PM   #6 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

~Graveyarded, then.
PurplePoot is offline  
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Raising the water-level grandchaos Terrain Board 7 11-22-2007 04:42 AM
[Trigger] Lowering unit height to less than 0 Drain Pipe Triggers & Scripts 9 09-06-2007 08:34 PM
Raising Doodads Deathbringer Terrain Board 12 05-06-2007 01:15 PM
Timer windows with text and no timer? Seb_Boss_ Map Development 2 03-11-2006 04:50 PM
Change Cliff Heights During Game Couchdweller Map Development 0 07-14-2005 08:34 PM

All times are GMT. The time now is 09:32 AM.






Your link here 
Credit Cards | Credit Cards | Loans | Guitar Books | Loans
Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Copyright©Ralle