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

[JASS] Setting a unit's fly height to a negative value?

Status
Not open for further replies.
JASS:
function submergeC takes nothing returns boolean
    return GetSpellAbilityId()=='A05H'
endfunction

function movesA takes nothing returns nothing
    call SetUnitFlyHeight(GetTriggerUnit(),0,1)
    call UnitRemoveAbility(GetTriggerUnit(),'B01A')
    call DestroyTrigger(GetTriggeringTrigger())
endfunction

function submergeAfter takes unit caster returns nothing
    local unit dummy = CreateUnitAtLoc(GetOwningPlayer(caster),'h00R',GetUnitLoc(caster),270)
    local trigger moves = CreateTrigger()
    call UnitApplyTimedLife(dummy,'B019',2)
    call IssueTargetOrder(dummy,"invisibility",caster)
    call TriggerRegisterUnitEvent(moves,caster,EVENT_UNIT_ISSUED_POINT_ORDER)
    call TriggerRegisterUnitEvent(moves,caster,EVENT_UNIT_ISSUED_TARGET_ORDER)
    call TriggerRegisterUnitEvent(moves,caster,EVENT_UNIT_ISSUED_ORDER)
    call TriggerRegisterUnitEvent(moves,caster,EVENT_UNIT_DETECTED)
    call TriggerAddAction(moves,function movesA)
endfunction

function submergeP takes nothing returns nothing
    local timer time = GetExpiredTimer()
    local unit caster = GetHandleUnit(time,"caster")
    local integer forc = GetHandleInt(time,"forc")
    local real height = GetUnitFlyHeight(caster)
    if height>10 then
        call SetUnitFlyHeight(caster,height+I2R(forc),0)
    else
        call SetUnitFlyHeight(caster,height+I2R(forc/2),0)
    endif
    call SetHandleInt(time,"forc",forc-1)
    if forc<-50 or height<1 then
        call submergeAfter(caster)
        call FlushHandleLocals(time)
        call DestroyTimer(time)
    endif
endfunction

function submergeA takes nothing returns nothing
    local timer time = CreateTimer()
    local unit caster = GetSpellAbilityUnit()
    local integer forc = 20
    local location pos = GetUnitLoc(GetSpellAbilityUnit())
    if IsTerrainPathable(GetLocationX(pos),GetLocationY(pos),PATHING_TYPE_WALKABILITY) then
        call UnitAddAbility(caster,'Amrf')
        call UnitRemoveAbility(caster,'Amrf')
        call SetHandleHandle(time,"caster",caster)
        call SetHandleInt(time,"forc",forc)
        call TimerStart(time,.03,true,function submergeP)
    else
        call DisplayTextToPlayer(GetOwningPlayer(GetSpellAbilityUnit()),0,0,"The water is not deep enough here!")
    endif
endfunction

function InitTrig_submerge takes nothing returns nothing
    set gg_trg_submerge = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_submerge,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_submerge,Condition(function submergeC))
    call TriggerAddAction(gg_trg_submerge,function submergeA)
endfunction

I've ran a few debugs and it seems it's height over the water will never go below 0.

Is there some way to reduce it so it's underwater?

Thanks for any help.
 
Thanks for the help, if anyone's curious, I'm solving this problem by temporarily pausing the hero and creating a dummy with a -200 height (defined by the object editor) and then changing the heroes height (through triggers) to 3000 so it can't be clicked. Then when triggered the dummy is removed and the hero will go back to it's defaults and unpause.

The dummy will be un-targetable but detectable.

+reps to redflash of course
 
Status
Not open for further replies.
Top