• 🏆 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!

[vJass] Realy need help on this one guys.

Status
Not open for further replies.
Level 18
Joined
Oct 18, 2007
Messages
930
Ok im making a spell where you shoot rockets into the air then they fall down another place. The coding is kinda messy right now but it is because i stopped in the middle of my coding trying to figure out the problem.

The problem is that the units wont decrease fly height for sum reason.

Any questions or you maybe have the solution, PLEASE POST :) thx


Here is the struct that the problem lies in
JASS:
    private struct MissileDown
        unit Missile
        unit Caster
        unit tmpUnit
        group G
        real MissileX
        real MissileY
        real EndX
        real EndY
        real Z
        integer lvl
        timer T
        boolexpr G_Filter
        player P
        
        static method MoveMissile takes nothing returns nothing
            local MissileDown m = GetTimerData(GetExpiredTimer())
            if m.Z < Z_Minimum then
                set tmpPlayer = GetOwningPlayer(m.Missile)
                call GroupEnumUnitsInRange(m.G,m.EndX,m.EndY,Radius,m.G_Filter)
                loop
                    set m.tmpUnit = FirstOfGroup(m.G)
                    exitwhen m.tmpUnit == null
                    call DestroyEffect(AddSpecialEffectTarget(Targ_Effect, m.tmpUnit, "chest"))
                    call UnitDamageTarget(m.Caster, m.tmpUnit, Damage(m.lvl),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS) 
                    call GroupRemoveUnit(m.G, m.tmpUnit)
                    set m.tmpUnit = null
                endloop
                call DestroyEffect(AddSpecialEffect(End_Effect, m.EndX, m.EndY ))
                call m.destroy()
            else
                set m.Z = m.Z - Z_Minus
                call SetUnitFlyHeight(m.Missile,m.Z,10000000)
            endif
        endmethod
        
        static method create takes player P, real StartX, real StartY, unit Caster, integer lvl, real Angle returns MissileDown
            local MissileDown m = MissileDown.allocate()
            set m.G = CreateGroup()
            set m.lvl = lvl
            set m.Caster = Caster
            set m.EndX = StartX + GetRandomReal(0, 300) * Cos(Angle)
            set m.EndY = StartY + GetRandomReal(0, 300) * Sin(Angle)
            set m.Missile = CreateUnit(P,Type_Missile_Down,m.EndX,m.EndY,Angle)
            call SetUnitPathing(m.Missile,false)
            call SetUnitFlyHeight(m.Missile, 2000, 10000000)
            set m.G_Filter = Condition(function Filter)
            set m.Z = 2000
            set m.T = NewTimer()
            call SetTimerData(m.T,m)
            call TimerStart(m.T,0.015,true,function MissileDown.MoveMissile)
            return m
        endmethod
        
        method onDestroy takes nothing returns nothing
            call ReleaseTimer(.T)
            call DestroyGroup(.G)
            call RemoveUnit(.Missile)
            set .Caster  = null
            set .Missile = null
            set .T = null
        endmethod
    endstruct
 

Attachments

  • vJass.w3x
    33.2 KB · Views: 34
Last edited:
Level 12
Joined
Apr 27, 2008
Messages
1,228
Presuming the rest of the code is 'correct' then the mistake is this:
call SetUnitFlyHeight(m.Missile,m.Z,10000000)

Should be:
call SetUnitFlyHeight(m.Missile,m.Z,0)

Making it instantly change the fly height.
 
Status
Not open for further replies.
Top