• 🏆 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] I dont believe this function returns a boolean

Status
Not open for further replies.
Level 10
Joined
Sep 21, 2007
Messages
517
The problem is that the trigger itself doesnt seem to cause any of the text messages in the testing trigger i put below.
here is the function:
JASS:
library VectorSystem
    
    globals
        private constant real DistIntervalCheck = 25.
        private constant real radius = 50.  
    endglobals
            
        function IsPathSafe takes real X, real Y, real angle, real maxDist returns boolean
            local real x = X
            local real y = Y
            local real mx = Cos(angle)*DistIntervalCheck
            local real my = Sin(angle)*DistIntervalCheck
            local real curDist
            local rect r
            loop
                exitwhen curDist >= maxDist
                set x = x + mx
                set y = y + my
                set r = Rect(x - radius, y - radius, x + radius, y + radius)
                if RandomDestructableInRectBJ(r, null) != null then
                    call RemoveRect(r)
                    set r = null
                    return false
                endif
                call RemoveRect(r)
                set r = null
                set curDist = curDist + DistIntervalCheck
            endloop
            return true
        endfunction
                
                
endlibrary

here is the test trigger:
JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local unit t = udg_PlayerHero[1]
if IsPathSafe(GetUnitX(t), GetUnitY(t), GetUnitFacing(t), 1000) == true then
    call BJDebugMsg("true")
else
    call BJDebugMsg("false")
endif
set t = null
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Untitled_Trigger_001, Player(0), "test", true )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction

Please dont comment on me using the BJ, its like a transitional method instead of having to use structs and a global boolean.

thanks for your time
 
Level 11
Joined
Apr 29, 2007
Messages
826
Try to initialize curDist to 0.

e/ SHOULD work. I don't really know what integers defaultly initialize to, but its not 0.
Try the following:
JASS:
scope IntTest initializer init
    private function init takes nothing returns nothing
        local integer i
        if i == 0
            call BJDebugMsg("0")
        else
            call BJDebugMsg("not 0")
        endif
    endfunction
endscope
It shows nothing. Not "0" and also not "not 0"

e2/ yup, I'm right. Same goes for reals ofcourse, they have to be initialized.

e3/ @Marcelo. Seems to be right.
 
Last edited:
Status
Not open for further replies.
Top