[Solved] jass error

Status
Not open for further replies.
Level 7
Joined
Apr 1, 2010
Messages
289
i have this in my maps header, but the map will not says, expecting endif, but i have one if and one endif could somone please tell me what the problem.

JASS:
//=======================================================
//Header for 2d projectile system

function Collision takes nothing returns nothing
   set udg_MS_Collision = 0
   set udg_MS_CollisionUnit = LoadUnitHandle(udg_MS,0,GetHandleId(GetTriggeringTrigger()))
   set udg_MS_CollidingU = GetTriggerUnit()
   set udg_MS_Collision = 1
endfunction

function CP takes player p, real x, real y, real f returns unit 
  if udg_MS_Group_Count==0 then
     set udg_U = CreateUnit(p,'h000',x,y,f)
     set udg_T = CreateTrigger()
     call TriggerRegisterUnitInRangeSimple( udg_T,60, udg_U)
     call TriggerAddAction(udg_T,function Collision)
     call SaveTriggerHandle(udg_MS,0,GetHandleId(udg_U),udg_T)
     call SaveUnitHandle(udg_MS,0,GetHandleId(udg_T),udg_U)   
     return udg_U
  endif       
    set udg_U = FirstOfGroup(udg_MS_Group)
    set udg_MS_Group_Count = udg_MS_Group_Count - 1
    call EnableTrigger(LoadTriggerHandle(udg_MS,0,GetHandleId(udg_U)))
    call SetUnitX(udg_U,x)
    call SetUnitY(udg_U,y)
    call SetUnitFacing(udg_U,f)
    call SetUnitOwner(udg_U,p,true)  
    return udg_U
endfuntion
//=======================================================
 
Last edited:
This function:
JASS:
function CP takes player p, real x, real y, real f returns unit 
  if udg_MS_Group_Count==0 then
     set udg_U = CreateUnit(p,'h000',x,y,f)
     set udg_T = CreateTrigger()
     call TriggerRegisterUnitInRangeSimple( udg_T,60, udg_U)
     call TriggerAddAction(udg_T,function Collision)
     call SaveTriggerHandle(udg_MS,0,GetHandleId(udg_U),udg_T)
     call SaveUnitHandle(udg_MS,0,GetHandleId(udg_T),udg_U)   
     return udg_U
  endif       
    set udg_U = FirstOfGroup(udg_MS_Group)
    set udg_MS_Group_Count = udg_MS_Group_Count - 1
    call EnableTrigger(LoadTriggerHandle(udg_MS,0,GetHandleId(udg_U)))
    call SetUnitX(udg_U,x)
    call SetUnitY(udg_U,y)
    call SetUnitFacing(udg_U,f)
    call SetUnitOwner(udg_U,p,true)  
    return udg_U
endfuntion

In the very last line:
endfuntion
should be:
endfunction
 
Narogog, you realy should at first exercise with simple jass spells or even make this system in GUI first before you want to actually do that in jass.

JASS:
call TriggerRegisterUnitInRangeSimple( udg_T,60, udg_U)

// function aboves looks like:
function TriggerRegisterUnitInRangeSimple takes trigger trig, real range, unit whichUnit returns event
    return TriggerRegisterUnitInRange(trig, whichUnit, range, null)
endfunction

->>
// it's better call call the native instead
call TriggerRegisterUnitInRange(udg_T, udg_U, 60, null)
Again, there is ton of possible improvements.
 
Status
Not open for further replies.
Top