scope Fakes initializer Init
globals
private constant real WIDTH = 768.00
private constant real HEIGHT = 768.00
private real AREA
private constant real MAX_ALPHA = 100.00
private constant real MIN_ALPHA = 0.00
private constant real Y_INTERCEPT = MAX_ALPHA - MIN_ALPHA
private constant real INTERVAL = 0.04
endglobals
struct fake
unit object
rect area
timer transTimer = CreateTimer()
private static method handler takes nothing returns nothing
local fake dat = GetCSData(GetExpiredTimer())
local real dist = SquareRoot((GetUnitX(Character) - GetUnitX(dat.object)) * (GetUnitX(Character) - GetUnitX(dat.object)) + (GetUnitY(Character) - GetUnitY(dat.object)) * (GetUnitY(Character) - GetUnitY(dat.object)))
local real alpha = Y_INTERCEPT / AREA * dist + MIN_ALPHA
call SetUnitVertexColor(dat.object, 255, 255, 255, PercentTo255(alpha))
endmethod
private static method enterArea takes nothing returns nothing
local fake dat = GetCSData(GetTriggeringTrigger())
if GetTriggerUnit() == Character then
if EI2I(GetTriggerEventId()) == 5 then
call TimerStart(dat.transTimer, INTERVAL, true, function fake.handler)
elseif EI2I(GetTriggerEventId()) == 6 then
call PauseTimer(dat.transTimer)
call SetUnitVertexColor(dat.object, 255, 255, 255, 255)
endif
endif
endmethod
static method create takes unit object returns fake
local fake dat = fake.allocate()
local trigger trig = CreateTrigger()
set dat.object = object
set dat.area = Rect(GetUnitX(object) - WIDTH / 2, GetUnitY(object) - HEIGHT / 2, GetUnitX(object) + WIDTH / 2, GetUnitY(object) + HEIGHT / 2)
call SetCSData(trig, dat)
call SetCSData(dat.transTimer, dat)
call TriggerRegisterEnterRectSimple(trig, dat.area)
call TriggerRegisterLeaveRectSimple(trig, dat.area)
call TriggerAddAction(trig, function fake.enterArea)
return dat
endmethod
endstruct
private function EnumConditions takes nothing returns boolean
local integer id = GetDestructableTypeId(GetFilterDestructable())
return id == 039;B003039; or id == 039;B004039;
endfunction
private function EnumActions takes nothing returns nothing
local destructable f = GetEnumDestructable()
local integer id = GetDestructableTypeId(GetFilterDestructable())
if id == 039;B003039; then
call fake.create(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 039;h003039;, GetDestructableX(f), GetDestructableY(f), 270.00))
elseif id == 039;B004039; then
call fake.create(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 039;h004039;, GetDestructableX(f), GetDestructableY(f), 270.00))
endif
call RemoveDestructable(f)
set f = null
endfunction
private function Init takes nothing returns nothing
set AREA = ((WIDTH + HEIGHT) / 4)
call EnumDestructablesInRect(bj_mapInitialPlayableArea, Condition(function EnumConditions), function EnumActions)
endfunction
endscope
EDIT://I would appreciate if you place the map in the Downloads folder, so I could actually view it.
EDIT://Still doesn't work. Are you sure you did? It asks for a file Maps\Test\WorldEditTestMap.w3x