- Joined
- May 16, 2020
- Messages
- 660
Hi guys,
I'm trying to use AceHart's Tree Regrow System (Snippet - Regrowing Trees), but I'm getting an error:
"Cannot convert returned value from widget to destructible"
Apparently the library doesn't require any other systems, so I don't understand what is going on. Maybe because I'm using Reforged?
Can anyone please help fix this?
***
I'm trying to use AceHart's Tree Regrow System (Snippet - Regrowing Trees), but I'm getting an error:
"Cannot convert returned value from widget to destructible"
Apparently the library doesn't require any other systems, so I don't understand what is going on. Maybe because I'm using Reforged?
Can anyone please help fix this?
***
JASS:
library REGROWTREES initializer Init
globals
private constant real RegrowAfter = 23.0 // seconds to wait until tree regrows
private constant real Range = 250.0 // distance around tree that needs to be free of units before regrowing
private unit u
private group g = CreateGroup()
private boolexpr b
private boolean ok
endglobals
private function IsTree takes nothing returns boolean
local boolean b
call SetUnitX(u, GetWidgetX(GetFilterDestructable()))
call SetUnitY(u, GetWidgetY(GetFilterDestructable()))
set b = IssueTargetOrder(u, "harvest", GetFilterDestructable())
call IssueImmediateOrder(u, "stop")
return b
endfunction
private function W2D takes widget w returns destructable
return w // do not inline
return null
endfunction
private function IsUnitNear takes nothing returns boolean
if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.5 then
set ok = false
endif
return false
endfunction
private function Regrow takes nothing returns nothing
local widget t = GetTriggerWidget()
call TriggerSleepAction(RegrowAfter)
loop
set ok = true
call GroupClear(g)
call GroupEnumUnitsInRange(g, GetWidgetX(t), GetWidgetY(t), Range, b)
exitwhen ok
call TriggerSleepAction(3.0)
endloop
call DestructableRestoreLife(W2D(t), GetDestructableMaxLife(W2D(t)), true)
set t = null
endfunction
private function Register takes nothing returns nothing
call TriggerRegisterDeathEvent(bj_destInRegionDiesTrig, GetEnumDestructable())
endfunction
private function Init takes nothing returns nothing
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'nmpe', 0, 0, 0) // Mur'gul Slave...
call SetUnitInvulnerable(u, true)
call ShowUnit(u, false)
call UnitAddAbility(u, 'Aloc') // Locust
call UnitAddAbility(u, 'Ahrl') // Harvest Lumber
set bj_destInRegionDiesTrig = CreateTrigger()
call EnumDestructablesInRect(bj_mapInitialPlayableArea, Condition(function IsTree), function Register)
call TriggerAddAction(bj_destInRegionDiesTrig, function Regrow)
set b = Condition(function IsUnitNear)
call RemoveUnit(u)
set u = null
endfunction
endlibrary