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

[Solved] i don't understand why it doesn't compile

Status
Not open for further replies.

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
Hi,
there is an error but the syntax check fail to find it.
[Jass=]
function FireSpread takes nothing returns nothing
local real x
local real x1
local real y
local real y1
local real n
local real d
local unit fire
local integer chance
set x = GetUnitX(GetTriggerUnit())
set y = GetUnitY(GetTriggerUnit())
set n = GetRandomReal(0, 360)
set d = GetRandomReal(1000., 2000.)
set x1 = x + d * Cos(n * bj_DEGTORAD)
set y1 = y + d * Sin(n * bj_DEGTORAD)
if IsTerrainPathable( x1, y1, PATHING_TYPE_FLOATABILITY) then
set chance = GetUnitUserData(GetTriggerUnit())
if GetRandomInt(1, chance )== 1 and chance < 5 then
set fire = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), 'n00S', x1, y1, bj_UNIT_FACING)
call SetUnitUserData( fire, chance + 1)
if udg_Rain == false and ugd_Wind == false then
call SetUnitState(fire, UNIT_STATE_LIFE, GetRandomReal(20., 60.) )
call SetUnitAbilityLevel( fire, 'A0H7', 2 )
else
call SetUnitState(fire, UNIT_STATE_LIFE, GetRandomReal(20., 40.) )
if udg_Rain then
call SetUnitAbilityLevel( fire, 'A0H7', 1 )
else
call SetUnitAbilityLevel( fire, 'A0H7', 3 )
endif
endif
else
set fire = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), 'n00R', x1, y1, bj_UNIT_FACING)
if udg_Rain == false and ugd_Wind == false then
call SetUnitState(fire, UNIT_STATE_LIFE, GetRandomReal(20., 60.) )
call SetUnitAbilityLevel( fire, 'A0H7', 2 )
else
call SetUnitState(fire, UNIT_STATE_LIFE, GetRandomReal(20., 40.) )
if udg_Rain then
call SetUnitAbilityLevel( fire, 'A0H7', 1 )
else
call SetUnitAbilityLevel( fire, 'A0H7', 3 )
endif
endif
endif
endif
set fire =null
endfunction

//===========================================================================
function InitTrig_ForestFire_Spread_JASS takes nothing returns nothing
set gg_trg_ForestFire_Spread_JASS = CreateTrigger( )
call TriggerAddAction( gg_trg_ForestFire_Spread_JASS, function FireSpread )
endfunction
[/code]
the trigger is run from a unit die trigger.
i am not sure but maybe the polar offset part i tried to do bug...?
i cannot find anything wich would cause it not to compile...
 
Level 4
Joined
Jan 27, 2010
Messages
133
Seems like you might be able to cut some redundant code by separating the if's:

JASS:
if GetRandomInt(1, chance )== 1 and chance < 5 then
    set fire = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), 'n00S', x1, y1, bj_UNIT_FACING)
    call SetUnitUserData( fire, chance + 1)
else
    set fire = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), 'n00R', x1, y1, bj_UNIT_FACING)
endif

if udg_Rain == false and udg_Wind == false then
    call SetUnitState(fire, UNIT_STATE_LIFE, GetRandomReal(20., 60.) )
    call SetUnitAbilityLevel( fire, 'A0H7', 2 )
else
    call SetUnitState(fire, UNIT_STATE_LIFE, GetRandomReal(20., 40.) )
    if udg_Rain then
        call SetUnitAbilityLevel( fire, 'A0H7', 1 )
    else
        call SetUnitAbilityLevel( fire, 'A0H7', 3 )
    endif
endif
 
Last edited:

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
thanks a lot maker !!!
i was so tired with many part of code that didn't compile, that i overlooked such a stupid mistake...
thanks themerion,
i have shorten the code like you showed me ^^
 
Status
Not open for further replies.
Top