Moderator
M
Moderator
12:23, 17th Jun 2010
Hanky:
Nice idea and a nice spell. Approved!
Hanky:
Nice idea and a nice spell. Approved!
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//XXXXX XXXXXX
//XXXXX Copy this to the map header XXXXXX
//XXXXX (HellCircle.w3x) XXXXXX
//XXXXX on top of the trigger list XXXXXX
//XXXXX XXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function HideItem takes nothing returns nothing
call SetItemVisible(GetFilterItem(), false)
endfunction
function ShowItem takes nothing returns nothing
call SetItemVisible(GetFilterItem(), true)
endfunction
//this function checks if a point is pathable by moving 2 items to it and comparing their coordinates
function IsPathable takes real x, real y returns boolean
local boolean b = false
call MoveRectTo(udg_PathCheckRegion, x, y)
call EnumItemsInRect(udg_PathCheckRegion, null, function HideItem)
call SetItemPosition(udg_pathitem, x, y)
call SetItemPosition(udg_pathitem2, x, y)
if GetWidgetX(udg_pathitem)==x and GetWidgetY(udg_pathitem)==y and GetWidgetX(udg_pathitem2)!=x and GetWidgetY(udg_pathitem2)!=y then
set b = true
else
set b = false
endif
call EnumItemsInRect(udg_PathCheckRegion, null, function ShowItem)
call SetItemVisible(udg_pathitem, false)
call SetItemVisible(udg_pathitem2, false)
return b
endfunction
//destroys a tree and increases a counter
function KillTree takes nothing returns nothing
set udg_TreeKills = udg_TreeKills + 1
call KillDestructable(GetEnumDestructable())
endfunction
//checks if a destructable is a tree by ordering a dummy to harvest it
//dead destructables won't be effected either
function IsTree takes nothing returns boolean
return GetWidgetLife(GetFilterDestructable())>0.405 and IssueTargetOrder(udg_harvester, "harvest", GetFilterDestructable())
endfunction
//destroys all trees in the udg_PathCheckRegion (I felt like using this region since size is perfect)
function KillTrees takes real x, real y returns real
set udg_TreeKills = 0
call MoveRectTo(udg_PathCheckRegion, x, y)
call EnumDestructablesInRect(udg_PathCheckRegion, Condition(function IsTree), function KillTree)
call IssueImmediateOrder(udg_harvester, "stop")
return udg_TreeKills
endfunction
//moves the picked dummy to a certain position
function HellCircle_MoveDummys takes nothing returns nothing
set udg_a = udg_a + 360 / udg_HellCircle_Data[udg_i*11+7]
set udg_x2 = udg_x + Cos(udg_a*bj_DEGTORAD) * udg_r
set udg_y2 = udg_y + Sin(udg_a*bj_DEGTORAD) * udg_r
call SetUnitX(GetEnumUnit(), udg_x2)
call SetUnitY(GetEnumUnit(), udg_y2)
set udg_HellCircle_Data[udg_i*11+9] = udg_HellCircle_Data[udg_i*11+9] + KillTrees(udg_x2, udg_y2)
endfunction