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

[JASS] Noob Jass Question !

Status
Not open for further replies.

Rmx

Rmx

Level 19
Joined
Aug 27, 2007
Messages
1,164
Ok not noob but got you to enter :wink:

I need to know a way to Destroy TREES ! ..

I know it's a jump spell ... but just help me know a WAY ..


To destroy trees :D

JASS:
scope Slide initializer Init

    globals
        timer Tim = CreateTimer()
        real DISTANCE = 1000
        real INTERVAL = 0.04
        real SPEED = 15
        real MAX = 400
        integer array Ar
        string Thunder = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl"
        string Effectx = "Abilities\\Weapons\\FaerieDragonMissile\\FaerieDragonMissile.mdl"
        integer Spam = 3
        private real MaxX
        private real MaxY
        private real MinX
        private real MinY
    endglobals
    
//===============================================================================

    struct DATA
        unit u
        real dist
        real distInc
        real time
        real distDecoy
        real max
        real equ
        real z
        real cos
        real sin
        string Special
        string special2
        integer Spamy
        static integer P = 0
        static method Loop takes nothing returns nothing
            local DATA dat
            local integer i = 0
            local real x1
            local real y1
            local real x2
            local real y2
            local location Zx2
            local real z2
            local real Debug
            local real Debugc
            loop
                exitwhen i >= dat.P
                set dat = Ar[i]
                if ( dat.distDecoy >= 0.01 ) and (GetUnitFlyHeight(dat.u) <= 1) then
                    call SetUnitPathing(dat.u, true)
                    call SetUnitFlyHeight(dat.u, GetUnitDefaultFlyHeight(dat.u), 0)
                    call DestroyEffect(AddSpecialEffect(dat.Special, GetUnitX(dat.u), GetUnitY(dat.u)))
                    set dat.u = null
                    set Ar[i] = Ar[dat.P - 1]
                    set dat.P = dat.P - 1
                else
                    set dat.distDecoy = dat.distDecoy + dat.distInc
                    set x1 = GetUnitX(dat.u)
                    set y1 = GetUnitY(dat.u)
                    set x2 = x1 + dat.distInc * dat.cos
                    set y2 = y1 + dat.distInc * dat.sin
                    set Zx2 = Location(x2, y2)
                    set z2 = GetLocationZ(Zx2)
                    call RemoveLocation(Zx2)
                    if (MinX <= x2 and x2 <= MaxX and MinY <= y2 and y2 <= MaxY) then
                        call SetUnitX(dat.u, x2)
                        call SetUnitY(dat.u, y2)
                        set dat.equ = ((4 * dat.max) / dat.dist) * ( dat.dist - dat.distDecoy ) * ( dat.distDecoy / dat.dist )
                        set Debug = dat.z - z2
                        set Debugc = dat.equ + Debug
                        call SetUnitFlyHeight(dat.u, Debugc, 0)
                            if dat.Spamy == 0 then
                                call DestroyEffect(AddSpecialEffectTarget(dat.special2, dat.u, "chest"))
                                set dat.Spamy = Spam
                        else
                            set dat.Spamy = dat.Spamy - 1
                        endif
                    else
                        set dat.dist = 0
                    endif
                endif
                set i = i + 1
            endloop
            if dat.P == 0 then
                call PauseTimer(Tim)
            endif
            endmethod
        static method Create takes unit ME, real a, real d, real f, string rr, string xaa, integer yy, real op returns DATA
            local DATA dat = DATA.allocate()
            local location Zx
            set dat.u = ME
            set Zx = Location(GetUnitX(dat.u), GetUnitY(dat.u))
            call SetUnitPosition(dat.u, GetUnitX(dat.u), GetUnitY(dat.u))
            call SetUnitPathing(dat.u, false)
            set dat.cos = Cos(a * bj_DEGTORAD)
            set dat.sin = Sin(a * bj_DEGTORAD)
            set dat.dist = d
            set dat.distInc = f
            set dat.Special = rr
            set dat.special2 = xaa
            set dat.Spamy = yy
            set dat.distDecoy = 0
            set dat.max = op
            set dat.equ = 0
            set dat.z = GetLocationZ(Zx)
            call UnitAddAbility(dat.u, 'Amrf')
            call UnitRemoveAbility(dat.u, 'Amrf')
            call RemoveLocation(Zx)
            if dat.P == 0 then            
                call TimerStart(Tim, INTERVAL, true, function DATA.Loop)
            endif
            set dat.P = dat.P + 1
            set Ar[dat.P - 1] = dat
            return dat
        endmethod
    endstruct
            
//===============================================================================    
    function Con takes nothing returns boolean
        return GetSpellAbilityId() == 'X1X2'
    endfunction

    function Yo takes nothing returns nothing
    local DATA dat = DATA.Create(GetSpellAbilityUnit(), GetUnitFacing(GetSpellAbilityUnit()), DISTANCE, SPEED, Thunder, Effectx, Spam, MAX)
    endfunction

//===============================================================================
    function Init takes nothing returns nothing
        local trigger t = CreateTrigger( )
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( t, Condition( function Con ) )
        call TriggerAddAction( t, function Yo )
        set t = null
        call Preload("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl")
        set MaxX = GetRectMaxX(bj_mapInitialPlayableArea) - 64
        set MaxY = GetRectMaxY(bj_mapInitialPlayableArea) - 64
        set MinX = GetRectMinX(bj_mapInitialPlayableArea) + 64
        set MinY = GetRectMinY(bj_mapInitialPlayableArea) + 64
    endfunction

endscope
 
Status
Not open for further replies.
Top