PrisonLove
Hard Realist
- Reaction score
- 78
Okay so I've created this trigger out of a GUI code that I had to convert to JASS in order to add a few functions to check pathability at a point. I can enable the trigger in the world editor as though it is fine, but when I go to save the map it creates an error when generating map script variables. So I need to know why this happens, and if the trigger will even work. Please keep in mind that I'm not good with JASS and I'm just starting to learn it.
I needed my trigger to use SetUnitX,Y because I need to preserve orders while sliding, and I can't use "Unit - Move Unit Instantly" or SetUnitPosition().
Here's the trigger please help.
Sorry it's kind of long. +rep for help!
I needed my trigger to use SetUnitX,Y because I need to preserve orders while sliding, and I can't use "Unit - Move Unit Instantly" or SetUnitPosition().
Here's the trigger please help.
JASS:
function IsCar takes nothing returns boolean
return ( GetFilterUnit() == udg_Car[GetConvertedPlayerId(GetEnumPlayer())] )
endfunction
function NotCar takes nothing returns boolean
return ( GetFilterUnit() != udg_Car[GetConvertedPlayerId(GetEnumPlayer())] )
endfunction
function IsPowerUp takes nothing returns boolean
return ( GetUnitTypeId(GetFilterUnit()) != 039;h009039; )
endfunction
function IsDummy takes nothing returns boolean
return ( GetUnitTypeId(GetFilterUnit()) != 039;h008039; )
endfunction
function UnitComparison takes nothing returns boolean
return GetBooleanAnd( IsPowerUp(), IsDummy() )
endfunction
function BooleanUnk takes nothing returns boolean
return GetBooleanAnd( NotCar(), UnitComparison() )
endfunction
function CheckPathabilityTrickGet takes nothing returns nothing
set bj_rescueChangeColorUnit = bj_rescueChangeColorUnit or (GetEnumItem()!=bj_itemRandomCurrentPick)
endfunction
function CheckPathabilityTrick takes item p, real x, real y returns boolean
local integer i=30
local rect r
call SetItemPosition(p,x,y)
if ((Pow(GetItemX(p)-x,2)+Pow(GetItemY(p)-y,2))<=100) then
return true
endif
set r=Rect(x-i,y-i,x+i,y+i)
set bj_itemRandomCurrentPick=p
set bj_rescueChangeColorUnit=false
call EnumItemsInRect(r,null,function CheckPathabilityTrickGet)
call RemoveRect(r)
set r=null
return bj_rescueChangeColorUnit
endfunction
function CheckPathability takes real x, real y returns boolean
local item it = CreateItem(039;ciri039;,x,y)
local boolean b = CheckPathabilityTrick(it,x,y)
call SetItemVisible(it,false)
call RemoveItem(it)
set it=null
return b
endfunction
function Booleans1 takes nothing returns boolean
if ( not ( udg_Forward[GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit()))] == true ) ) then
return false
endif
if ( not ( IsUnitType(GetEnumUnit(), UNIT_TYPE_STUNNED) == false ) ) then
return false
endif
return true
endfunction
function Function2 takes nothing returns nothing
if ( Booleans1() ) then
set udg_TempPoint = GetUnitLoc(GetEnumUnit())
set udg_TempReal = GetUnitFacing(GetEnumUnit())
set udg_TempPoint2 = PolarProjectionBJ(udg_TempPoint, 11.00, udg_TempReal)
set udg_TempUnitGroup2 = GetUnitsInRangeOfLocMatching(100.00, udg_TempPoint2, Condition(function BooleanUnk))
if (CheckPathability(GetLocationX(udg_TempPoint2), GetLocationY(udg_TempPoint2)) == true) then
call SetUnitX(GetEnumUnit(), GetLocationX(udg_TempPoint2))
call SetUnitY(GetEnumUnit(), GetLocationY(udg_TempPoint2))
else
endif
call DestroyGroup(udg_TempUnitGroup)
call RemoveLocation(udg_TempPoint2)
call RemoveLocation(udg_TempPoint)
else
endif
endfunction
function Function1 takes nothing returns nothing
set udg_TempUnitGroup = GetUnitsOfPlayerMatching(GetEnumPlayer(), Condition(function IsCar))
call ForGroupBJ( udg_TempUnitGroup, function Function2 )
set udg_DetructPathable[GetConvertedPlayerId(GetEnumPlayer())] = false
call DestroyGroup(udg_TempUnitGroup)
set udg_CheckedDestructible = null
endfunction
function Trig_move_forward_Copy_Actions takes nothing returns nothing
call ForForce( GetPlayersAll(), function Function1 )
endfunction
//===========================================================================
function InitTrig_move_forward_Copy takes nothing returns nothing
set gg_trg_move_forward_Copy = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_move_forward_Copy, 0.01 )
call TriggerAddAction( gg_trg_move_forward_Copy, function Trig_move_forward_Copy_Actions )
endfunction
Sorry it's kind of long. +rep for help!