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

[JASS] if/then statement not triggering actions

Status
Not open for further replies.
Level 10
Joined
Sep 21, 2007
Messages
517
they unit does go off playable map rect, but sure:
there is also eerror with units not being able to move after first time il post:
JASS:
library SPS
globals
    constant real INTERVAL = 0.03
    constant real PHeight = 50.
    constant real CollisionSize = 96.
    string ATTACH = "origin"
    constant integer PARTICLE_ID = 'e000'
    //boolexpr UnitDmg = Condition( function FilterUnit )
    timer sps = CreateTimer()
    integer SPSIndex = 0 
    SPS array temp_SPS
endglobals

//function FilterUnit takes nothing returns boolean
    //return GetWidgetLife(GetFilterUnit()) > .405 and IsUnitEnemy(GetFilterUnit(),dat.p) and not ConvertUnitType(2)
//endfunction
struct SPS
    unit u
    unit u2
    real s
    real x
    real y
    real x2
    real y2
    real a
    real dx
    real dy
    real z1
    string sfxs2
    effect sfx
    effect sfx2
    real dmg
    boolean DamageDestructible
    player p
    attacktype atk
    
    method onDestroy takes nothing returns nothing
        call DestroyEffect( .sfx )
        call DestroyEffect( .sfx2 )
        set .sfx = null
        set .sfx2 = null
        call RemoveUnit( .u )
        set .u = null
        call UnitApplyTimedLife( .u2, 'BTLF', 1.0 )
        set .u2 = null
        if SPSIndex == 0 then
            call PauseTimer( sps )
        endif
    endmethod
endstruct
    
function GetMoveX takes real s, real a returns real
        return Cos(a)*s
endfunction
    
function GetMoveY takes real s, real a returns real
        return Sin(a)*s
endfunction

//===============================================================
function move takes nothing returns nothing
    local SPS dat
    local real fh
    local integer i = 0
    loop
        exitwhen i >= SPSIndex
        set dat = temp_SPS[i]
        call SetUnitPosition( dat.u, dat.x + dat.dx, dat.y + dat.dy )
        set dat.x = GetUnitX( dat.u )
        set dat.y = GetUnitY( dat.u )        
        call SetUnitFlyHeight( dat.u, GetUnitFlyHeight( dat.u ) + (dat.z1 - GetLocationZ(Location(dat.x, dat.y))), 0. )
        if fh <= GetLocationZ(Location(dat.x, dat.y)) or IsTerrainPathable( dat.x, dat.y, ConvertPathingType(2) ) == false then
            set dat.u2 = CreateUnit( GetOwningPlayer(dat.u), PARTICLE_ID, dat.x, dat.y, 0. )
            set fh = GetUnitFlyHeight( dat.u )
            call SetUnitFlyHeight( dat.u2, fh, 0 )
            call AddSpecialEffectTarget( dat.sfxs2, dat.u2, ATTACH )
            set SPSIndex = SPSIndex - 1
            set temp_SPS[i] = temp_SPS[SPSIndex]
            call DisplayTextToForce( GetPlayersAll(), "test" )
            call dat.destroy()
        endif
        set i = i + 1
    endloop
endfunction

function InitSPS takes player p, real d, real s, string sfx, string sfx2, real x, real y, real x2, real y2, boolean DD, attacktype atk returns SPS
    local SPS dat = SPS.create()
    set temp_SPS[SPSIndex] = dat
    set dat.x = x
    set dat.x2 = x2
    set dat.y = y
    set dat.y2 = y2
    set dat.a = Atan2( dat.y2 - dat.y, dat.x2 - dat.x )
    set dat.p = p
    set dat.u = CreateUnit( dat.p, PARTICLE_ID, dat.x, dat.y, dat.a )
    call SetUnitX( dat.u, dat.x )
    call SetUnitY( dat.u, dat.y )
    set dat.z1 = GetLocationZ(Location(x, y))
    set dat.dx = GetMoveX( s*INTERVAL, dat.a )
    set dat.dy = GetMoveY( s*INTERVAL, dat.a )
    set dat.sfx = AddSpecialEffectTarget( sfx, dat.u, ATTACH )
    set dat.sfxs2 = sfx2
    set dat.dmg = d
    set dat.DamageDestructible = DD
    set dat.atk = atk
    call UnitAddAbility( dat.u, 'Amrf' )
    call UnitRemoveAbility( dat.u, 'Amrf' )
    call SetUnitFlyHeight( dat.u, PHeight + dat.z1, 0. )
    if SPSIndex == 0 then
        call TimerStart( sps, INTERVAL, true, function move )
    endif
    set SPSIndex = SPSIndex + 1
    return dat
endfunction
endlibrary

i just started jass, so dont be pissed i did bad ;p
also in filter do we use dat.u or just .u? thanks :X

also its not complete, just detects, or supposed to detect collision by now...

EDIT~~ ONLY PROBLEM IS MISSILE NOT HAVING ITS TERRAIN PATHABILITY IDENTIFIED, OTHERS FIXED.
 
Last edited:
Level 10
Joined
Sep 21, 2007
Messages
517
Deod, you are a JASS "Jenius", ty my friend. Offtopic: My jass skills suck dont they? any tips on efficiency? since i saw ur coding at wc3campaigns once i started jass, pretty impressive even tho i didnt understand it X_X Vexorian is king of all though t.t
 
Last edited:
Status
Not open for further replies.
Top