• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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

Status
Not open for further replies.

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,560
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.
 

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,560
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