• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Problems with flying height

Status
Not open for further replies.
Level 12
Joined
Sep 4, 2007
Messages
407
I got a problem. I got this trigger that works perfecly except for one thing. it don't change the units flying height as it is told to.

here's the trigger.

JASS:
function Trig_Creature_Model_Air_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A00G' then
        return true
    endif
    return false
endfunction

function Trig_Creature_Model_Air_Actions takes nothing returns nothing
    local unit creator = GetSpellAbilityUnit()
    local player playerA = GetOwningPlayer(creator)
    local real x = -256.000
    local real y = 8576.000
    local unit creature
    local effect effectA

    call AddSpecialEffect("Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl", x, y )
    call RemoveUnit(udg_CC_Unit[GetPlayerId(playerA) + 1])
    if GetSpellAbilityId() == 'A00G' then
       if udg_CC_Size[GetPlayerId(playerA) + 1] == 1 then
          set creature =  CreateUnit( playerA, 'h00G', x, y, 270)
          call SetUnitAbilityLevel(creature, 'A008', 1 )
       endif
       if udg_CC_Size[GetPlayerId(playerA) + 1] == 2 then
          set creature =  CreateUnit( playerA, 'h00H', x, y, 270)
          call SetUnitAbilityLevel(creature, 'A008', 2 )
       endif
       if udg_CC_Size[GetPlayerId(playerA) + 1] == 3 then
          set creature =  CreateUnit( playerA, 'h00I', x, y, 270)
          call SetUnitAbilityLevel(creature, 'A008', 3 )
       endif
    endif
    call SetUnitFlyHeight(creature, 100.00, 0.01)
    set udg_CC_Unit[GetPlayerId(playerA) + 1] = creature
    set udg_CC_CreatureType[GetPlayerId(playerA) + 1] = GetUnitTypeId(creature)
    call UnitAddAbility(creature, 'Apiv')
    call UnitRemoveAbility(creator, 'A00G')
    call UnitRemoveAbility(creature, 'Awan')
    call UnitAddAbility(creator, 'A00L')
    call UnitAddAbility(creator, 'A00K')
    call UnitAddAbility(creator, 'A00J')

    set creator = null
    set creature = null
    set playerA = null
    call DestroyEffect(effectA)
endfunction

//===========================================================================
function InitTrig_Creature_Model_Air takes nothing returns nothing
    set gg_trg_Creature_Model_Air = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Creature_Model_Air, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Creature_Model_Air, Condition( function Trig_Creature_Model_Air_Conditions ) )
    call TriggerAddAction( gg_trg_Creature_Model_Air, function Trig_Creature_Model_Air_Actions )
endfunction
 
Try adding it anyway. =P You should also try setting its height to something a bit more drastic. Here, I optimized/cleaned it up just for readability:
JASS:
function Trig_Creature_Model_Air_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00G'
endfunction

function Trig_Creature_Model_Air_Actions takes nothing returns nothing
    local unit creator   = GetTriggerUnit()
    local player playerA = GetOwningPlayer(creator)
    local real x         = -256.000
    local real y         = 8576.000
    local unit creature
    local integer Size   = udg_CC_Size[GetPlayerId(playerA)+1]

    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl", x, y ))
    call RemoveUnit(udg_CC_Unit[GetPlayerId(playerA) + 1])
    
    if GetSpellAbilityId() == 'A00G' then
       if Size == 1 then
          set creature = CreateUnit( playerA, 'h00G', x, y, 270)
          call SetUnitAbilityLevel(creature, 'A008', 1 )
       elseif Size == 2 then
          set creature = CreateUnit( playerA, 'h00H', x, y, 270)
          call SetUnitAbilityLevel(creature, 'A008', 2 )
       elseif Size == 3 then
          set creature = CreateUnit( playerA, 'h00I', x, y, 270)
          call SetUnitAbilityLevel(creature, 'A008', 3 )
       endif
    endif
    call UnitAddAbility(creature,'Amrf') //just in case
    call UnitRemoveAbility(creature,'Amrf')
    call SetUnitFlyHeight(creature, 500, 0) //it was originally 100, try any high/low value
//0 will set it instantly
    set udg_CC_Unit[GetPlayerId(playerA) + 1] = creature
    set udg_CC_CreatureType[GetPlayerId(playerA) + 1] = GetUnitTypeId(creature)
    call UnitAddAbility(creature, 'Apiv')
    call UnitRemoveAbility(creator, 'A00G')
    call UnitRemoveAbility(creature, 'Awan')
    call UnitAddAbility(creator, 'A00L')
    call UnitAddAbility(creator, 'A00K')
    call UnitAddAbility(creator, 'A00J')

    set creator = null
    set creature = null
    set playerA = null
endfunction

function InitTrig_Creature_Model_Air takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t,Condition(function Trig_Creature_Model_Air_Conditions))
    call TriggerAddAction(t,function Trig_Creature_Model_Air_Actions)
endfunction
 
Status
Not open for further replies.
Top