• 🏆 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] Boolean Condition problem :(

Status
Not open for further replies.
Level 7
Joined
Jun 16, 2008
Messages
253
This is the little snippet that's causing me trouble.

JASS:
1       if udg_collision_on[GetUnitUserData(jumper)] == true then
2               call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1573" )
3               call SetUnitPathing((jumper), true )
4               set exec = 0
5               call SetUnitFlyHeightBJ((jumper), 0.00, 1000000000.00 )
6               call AddSpecialEffectLocBJ(GetUnitLoc(jumper), "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl" )
7               call RemoveLocation (jumpto)
8           else
9           endif

I modified a GUI version that my buddy Orc made, into Jass, and made some locals like jumper (unit) and jumpto (location), getting rid of most of the functions so I could use locals effectively. Now when I use syntax checker it says: (Line 1) Comparing two variables of different primitive types (except real and integer) is not allowed...
But it seems fine for Line 2, no problem going 'set udg_collision_on = true'.

Could anybody please tell me why? One step away from finishing this little system Orc gave me.
 
Level 7
Joined
Jun 16, 2008
Messages
253
I know what you mean :(, like when you don't add enough )))))'s to the previous line I get that kinda stuff, here's the full thing.

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

function Trig_Jump_Activate_Jass_Funky takes nothing returns boolean
    return (GetTriggerUnit() != GetFilterUnit())
endfunction

function Trig_Jump_Activate_Jass_Actions takes nothing returns nothing
    local unit jumper = GetTriggerUnit()
    local real dist = DistanceBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetSpellTargetLoc())
    local real exec = 0
    local real height = 0
    local location jumpto = GetSpellTargetLoc()
    local location temppoint = null
    local location temppoint2 = null
    set udg_collision_on[GetUnitUserData(GetTriggerUnit())] = true
    call AddSpecialEffectLocBJ( GetUnitLoc((jumper)), "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl" )
    // Jump Effect
    call SetUnitFacingToFaceLocTimed((jumper),(jumpto), 0 )
    set exec = (exec) + 1
    set height = ((-0.49 * ((exec)*(exec))) + (((dist)/22.50)* (exec)))
    set temppoint = PolarProjectionBJ(GetUnitLoc(udg_jumping_unit[1]), 10.00, GetUnitFacing(jumper))
    set temppoint2 = PolarProjectionBJ(temppoint, 10.00, GetUnitFacing(jumper))
     if ( DistanceBetweenPoints(GetUnitLoc((jumper)),(jumpto)) <= 10.00 ) then
        call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1576" )
        call SetUnitPathing((jumper), true )
        set exec = 0
        call SetUnitFlyHeightBJ((jumper), 0.00, 1000000000.00 )
        call AddSpecialEffectLocBJ( GetUnitLoc((jumper)), "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl" )
        call RemoveLocation(jumpto)
    else
    if ((CountUnitsInGroup(GetUnitsInRangeOfLocMatching(32.00,(temppoint2), Condition(function Trig_Jump_Activate_Jass_Funky)))) > 0 ) then
        if udg_collision_on[GetUnitUserData(jumper)] == true then
                call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1573" )
                call SetUnitPathing((jumper), true )
                set exec = 0
                call SetUnitFlyHeightBJ((jumper), 0.00, 1000000000.00 )
                call AddSpecialEffectLocBJ(GetUnitLoc(jumper), "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl" )
                call RemoveLocation (jumpto)
            else
            endif
        else
            call UnitAddAbilityBJ( 'Amrf',(jumper))
            call SetUnitFlyHeightBJ((jumper),(height), 1000000000.00 )
            call UnitRemoveAbilityBJ( 'Amrf',(jumper))
            call SetUnitPositionLoc((jumper),(temppoint) )
            if ((height) >= 100.00 ) then
                if udg_collision_on[GetUnitUserData(jumper)] == true then
                    set udg_collision_on[GetUnitUserData(jumper)] = false
                    call SetUnitPathing((jumper), false )
                    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1575" )
                else
                endif
            else
                if ( udg_collision_on[GetUnitUserData(jumper)] == false ) then
                    set udg_collision_on[GetUnitUserData(jumper)] = true
                    call SetUnitPathing((jumper), true )
                    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1574" )
                else
                endif
            endif
            if ((height) <= 0.00 ) then
                call AddSpecialEffectLocBJ( GetUnitLoc((jumper)), "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl" )
            else
            endif
        endif
    endif
    call RemoveLocation (jumpto)
    call RemoveLocation (temppoint)
    call RemoveLocation (temppoint2)
endfunction

//===========================================================================
function InitTrig_Jump_Activate_Jass takes nothing returns nothing
    set gg_trg_Jump_Activate_Jass = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Jump_Activate_Jass, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Jump_Activate_Jass, Condition( function Trig_Jump_Activate_Jass_Conditions ) )
    call TriggerAddAction( gg_trg_Jump_Activate_Jass, function Trig_Jump_Activate_Jass_Actions )
endfunction
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Your indentations are confusing. You're also leaking. I didn't fix effect leaks yet, so do so.

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

function Trig_Jump_Activate_Jass_Funky takes nothing returns boolean
    return (GetTriggerUnit() != GetFilterUnit())
endfunction

function Trig_Jump_Activate_Jass_Actions takes nothing returns nothing
    local unit jumper = GetTriggerUnit()
    local real dist = DistanceBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetSpellTargetLoc())
    local real exec = 0
    local real height = 0
    local location jumpto = GetSpellTargetLoc()
    local location temppoint = null
    local location temppoint2 = null
    local group unitsinrange = CreateGroup()
    set udg_collision_on[GetUnitUserData(GetTriggerUnit())] = true
    call AddSpecialEffectLocBJ( GetUnitLoc((jumper)), "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl" )
    // Jump Effect
    call SetUnitFacingToFaceLocTimed((jumper),(jumpto), 0 )
    set exec = (exec) + 1
    set height = ((-0.49 * ((exec)*(exec))) + (((dist)/22.50)* (exec)))
    set temppoint = PolarProjectionBJ(GetUnitLoc(udg_jumping_unit[1]), 10.00, GetUnitFacing(jumper))
    set temppoint2 = PolarProjectionBJ(temppoint, 10.00, GetUnitFacing(jumper))
    if ( DistanceBetweenPoints(GetUnitLoc((jumper)),(jumpto)) <= 10.00 ) then
        call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1576" )
        call SetUnitPathing((jumper), true )
        set exec = 0
        call SetUnitFlyHeightBJ((jumper), 0.00, 1000000000.00 )
        call AddSpecialEffectLocBJ( GetUnitLoc((jumper)), "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl" )
        call RemoveLocation(jumpto)
    else
        call GroupEnumUnitsInRangeOfLocMatching(32.00, temppoint2, Condition(function Trig_Jump_Activate_Jass_Funky))
        if FirstOfGroup(unitsinrange) != null then // equivalent of CountUnitsInGroup(g) > 0
            if udg_collision_on[GetUnitUserData(jumper)] == true then
                call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1573" )
                call SetUnitPathing((jumper), true )
                set exec = 0.0
                call SetUnitFlyHeightBJ((jumper), 0.00, 1000000000.00 )
                call AddSpecialEffectLocBJ(GetUnitLoc(jumper), "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl" )
                call RemoveLocation (jumpto)
            endif
        else
            call UnitAddAbilityBJ( 'Amrf',(jumper))
            call SetUnitFlyHeightBJ((jumper),(height), 1000000000.00 )
            call UnitRemoveAbilityBJ( 'Amrf',(jumper))
            call SetUnitPositionLoc((jumper),(temppoint) )
            if ((height) >= 100.00 ) then
                if udg_collision_on[GetUnitUserData(jumper)] == true then
                    set udg_collision_on[GetUnitUserData(jumper)] = false
                    call SetUnitPathing((jumper), false )
                    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1575" )
                endif
            else
                if ( udg_collision_on[GetUnitUserData(jumper)] == false ) then
                    set udg_collision_on[GetUnitUserData(jumper)] = true
                    call SetUnitPathing((jumper), true )
                    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1574" )
                endif
            endif
            if ((height) <= 0.00 ) then
                call AddSpecialEffectLocBJ( GetUnitLoc((jumper)), "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl" )
            endif
        endif
    endif
    call RemoveLocation (jumpto)
    call RemoveLocation (temppoint)
    call RemoveLocation (temppoint2)
endfunction

//===========================================================================
function InitTrig_Jump_Activate_Jass takes nothing returns nothing
    set gg_trg_Jump_Activate_Jass = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Jump_Activate_Jass, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Jump_Activate_Jass, Condition( function Trig_Jump_Activate_Jass_Conditions ) )
    call TriggerAddAction( gg_trg_Jump_Activate_Jass, function Trig_Jump_Activate_Jass_Actions )
endfunction

Also, you use GetUnitUserData(jumper) a lot, so you might want to make a new local variable
local integer userdata = GetUnitUserData(jumper)

It's possible that I overlooked your mistake, it looks ok though
 
Level 7
Joined
Jun 16, 2008
Messages
253
Like I said it was converted directly from GUI, with a lot of locals hastily put in. I ran into the little syntax problem before I had a chance to worry about the indentations.

I'll try copying your code onto my map, maybe the problem wil go away. :D
 
Level 7
Joined
Jun 16, 2008
Messages
253
I think it's actually fine, i ran into the same problem with GetAttacker() == gg_unit_Hero_0183 sort of thing. It's just an error with the syntax checker not recognising it. I can just ignore it.
I hope.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
You can not ignore any syntax errory. If you do your map will not work.

Basically if a syntax error occurs it does not compile the trigger script and so is unplayable. Please post the full function where the syntax error is and highlight the line it reports the error and the exact error.

I found 1 undlecared function error which I fixed up below.

JASS:
function Trig_Jump_Activate_Jass_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00G'
endfunction

function Trig_Jump_Activate_Jass_Funky takes nothing returns boolean
    return (GetTriggerUnit() != GetFilterUnit())
endfunction

function Trig_Jump_Activate_Jass_Actions takes nothing returns nothing
    local unit jumper = GetTriggerUnit()
    local real dist = DistanceBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetSpellTargetLoc())
    local real exec = 0
    local real height = 0
    local location jumpto = GetSpellTargetLoc()
    local location temppoint = null
    local location temppoint2 = null
    local group unitsinrange = CreateGroup()
    set udg_collision_on[GetUnitUserData(GetTriggerUnit())] = true
    call AddSpecialEffectLocBJ( GetUnitLoc((jumper)), "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl" )
    // Jump Effect
    call SetUnitFacingToFaceLocTimed((jumper),(jumpto), 0 )
    set exec = (exec) + 1
    set height = ((-0.49 * ((exec)*(exec))) + (((dist)/22.50)* (exec)))
    set temppoint = PolarProjectionBJ(GetUnitLoc(udg_jumping_unit[1]), 10.00, GetUnitFacing(jumper))
    set temppoint2 = PolarProjectionBJ(temppoint, 10.00, GetUnitFacing(jumper))
    if ( DistanceBetweenPoints(GetUnitLoc((jumper)),(jumpto)) <= 10.00 ) then
        call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1576" )
        call SetUnitPathing((jumper), true )
        set exec = 0
        call SetUnitFlyHeightBJ((jumper), 0.00, 1000000000.00 )
        call AddSpecialEffectLocBJ( GetUnitLoc((jumper)), "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl" )
        call RemoveLocation(jumpto)
    else
        call GroupEnumUnitsInRangeOfLoc(unitsinrange,temppoint2,32.00,  Condition(function Trig_Jump_Activate_Jass_Funky))
        if FirstOfGroup(unitsinrange) != null then // equivalent of CountUnitsInGroup(g) > 0
            if udg_collision_on[GetUnitUserData(jumper)] == true then
                call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1573" )
                call SetUnitPathing((jumper), true )
                set exec = 0.0
                call SetUnitFlyHeightBJ((jumper), 0.00, 1000000000.00 )
                call AddSpecialEffectLocBJ(GetUnitLoc(jumper), "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl" )
                call RemoveLocation (jumpto)
            endif
        else
            call UnitAddAbilityBJ( 'Amrf',(jumper))
            call SetUnitFlyHeightBJ((jumper),(height), 1000000000.00 )
            call UnitRemoveAbilityBJ( 'Amrf',(jumper))
            call SetUnitPositionLoc((jumper),(temppoint) )
            if ((height) >= 100.00 ) then
                if udg_collision_on[GetUnitUserData(jumper)] == true then
                    set udg_collision_on[GetUnitUserData(jumper)] = false
                    call SetUnitPathing((jumper), false )
                    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1575" )
                endif
            else
                if ( udg_collision_on[GetUnitUserData(jumper)] == false ) then
                    set udg_collision_on[GetUnitUserData(jumper)] = true
                    call SetUnitPathing((jumper), true )
                    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1574" )
                endif
            endif
            if ((height) <= 0.00 ) then
                call AddSpecialEffectLocBJ( GetUnitLoc((jumper)), "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl" )
            endif
        endif
    endif
    call RemoveLocation (jumpto)
    call RemoveLocation (temppoint)
    call RemoveLocation (temppoint2)
endfunction

//===========================================================================
function InitTrig_Jump_Activate_Jass takes nothing returns nothing
    set gg_trg_Jump_Activate_Jass = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Jump_Activate_Jass, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Jump_Activate_Jass, Condition( function Trig_Jump_Activate_Jass_Conditions ) )
    call TriggerAddAction( gg_trg_Jump_Activate_Jass, function Trig_Jump_Activate_Jass_Actions )
endfunction

Copy the above into WE.
 
Level 7
Joined
Jun 16, 2008
Messages
253
Well SOME stuff you can ignore. I don't pretend to know why, but I used to get a syntax 'error' with unit == gg_unit... and the trigger + map works fine.

But thanks for the above, I'll try it out.

Maybe I misplace a parenthesis somewhere, I've done that before :(.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
The script above that I provided is completly syntax perfect if the vairable types are correct. I only found 1 invalid function call that made no sense which I corrected.

You should also not get any errors on map save. If you are using JNGP be sure to disable normal WE syntax checker and enable the jass hellper one for vJASS.

Basically if an error occurs, usually the piece with the error is disabled or skipped when compiling. This may result in bugs if it was an important line. Remember that with normal WE it often reports the wrong line (the one below the error) so check above the error location as well.

Also be sure your globals are the right type and the right spelling. Variables are case sensitive so then slightest spelling difference will result in an error
 
Status
Not open for further replies.
Top