- Joined
- May 16, 2012
- Messages
- 635
I'm trying to code the following item effect:
and here is the code that i wrote:
as you can see, i'm calling the function Overgrowth from within the OvergrowthStart if the unit with the effect dies, but thats not allowed because jass read from bottom to top and it gives me an error saying that the Overgrowth function is not declared. I'm a little short of ideas on how to solve this, and i do not want to use the entangle roots ability because i want the source unit to do the damage, not a dummy. Any ideas on how to do this? Thx.
and here is the code that i wrote:
JASS:
scope SphereOfNatureOvergrowth initializer Init
private function OvergrowthStart takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit source
local unit target
local unit u
local unit v
local real duration
local effect e
local effect f
local group g
local group aux
set source = LoadUnitHandle(udg_HeroHash, GetHandleId(t), 1)
set target = LoadUnitHandle(udg_HeroHash, GetHandleId(t), 2)
set duration = LoadReal(udg_HeroHash, GetHandleId(t), 3)
set e = LoadEffectHandle(udg_HeroHash, GetHandleId(t), 4)
call UnitDamageTarget(source, target, 500.0, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
if(UnitAlive(target) == false) then
set g = CreateGroup()
set aux = CreateGroup()
call GroupEnumUnitsInRange(aux, GetUnitX(target), GetUnitY(target), 600.0, null)
loop
set u = FirstOfGroup(aux)
exitwhen u == null
if(IsUnitEnemy(u, GetOwningPlayer(source)) and UnitAlive(u) and u != target and IsUnitType(u, UNIT_TYPE_STRUCTURE) == false) then
call GroupAddUnit(g, u)
endif
call GroupRemoveUnit(aux, u)
endloop
set u = GetClosestUnitGroup(GetUnitX(target), GetUnitY(target), g)
call GroupRemoveUnit(g, u)
if(IsUnitType(u, UNIT_TYPE_HERO)) then
set f = AddSpecialEffectTarget("OvergrowthTarget.mdx", u, "origin")
call PauseUnit(u, true)
call Overgrowth(source, u, 3.0, f)
else
set f = AddSpecialEffectTarget("OvergrowthTarget.mdx", u, "origin")
call PauseUnit(u, true)
call Overgrowth(source, u, 10.0, f)
endif
set v = GetClosestUnitGroup(GetUnitX(target), GetUnitY(target), g)
call GroupRemoveUnit(g, v)
if(IsUnitType(v, UNIT_TYPE_HERO)) then
set f = AddSpecialEffectTarget("OvergrowthTarget.mdx", v, "origin")
call PauseUnit(v, true)
call Overgrowth(source, v, 3.0, f)
else
set f = AddSpecialEffectTarget("OvergrowthTarget.mdx", v, "origin")
call PauseUnit(v, true)
call Overgrowth(source, v, 10.0, f)
endif
call DestroyGroup(g)
call DestroyGroup(aux)
call DestroyEffect(e)
call FlushChildHashtable(udg_HeroHash, GetHandleId(t))
call PauseTimer(t)
call DestroyTimer(t)
else
if(duration > 0) then
call SaveReal(udg_HeroHash, GetHandleId(t), 3, duration - 1)
else
call PauseUnit(target, false)
call DestroyEffect(e)
call FlushChildHashtable(udg_HeroHash, GetHandleId(t))
call PauseTimer(t)
call DestroyTimer(t)
endif
endif
set source = null
set target = null
set e = null
set f = null
set u = null
set v = null
set g = null
set t = null
set aux = null
endfunction
private function Overgrowth takes unit source, unit target, real duration, effect e returns nothing
local timer t = CreateTimer()
call SaveUnitHandle(udg_HeroHash, GetHandleId(t), 1, source)
call SaveUnitHandle(udg_HeroHash, GetHandleId(t), 2, target)
call SaveReal(udg_HeroHash, GetHandleId(t), 3, duration)
call SaveEffectHandle(udg_HeroHash, GetHandleId(t), 4, e)
call TimerStart(t, 1.00, true, function OvergrowthStart)
set t = null
endfunction
private function Actions takes nothing returns nothing
local effect e
if(GetRandomInt(1,100) <= 20 and UnitAlive(udg_PDD_target) and IsUnitEnemy(udg_PDD_target, GetOwningPlayer(udg_PDD_source)) and IsUnitType(udg_PDD_target, UNIT_TYPE_STRUCTURE) == false) then
set e = AddSpecialEffectTarget("OvergrowthTarget.mdx", udg_PDD_target, "origin")
call PauseUnit(udg_PDD_target, true)
if(IsUnitType(udg_PDD_target, UNIT_TYPE_HERO)) then
call Overgrowth(udg_PDD_source, udg_PDD_target, 3.0, e)
else
call Overgrowth(udg_PDD_source, udg_PDD_target, 10.0, e)
endif
endif
set e = null
endfunction
private function Conditions takes nothing returns boolean
if (UnitHasItemOfType(udg_PDD_source, 'I04N') > 0 and udg_PDD_damageType == udg_PDD_PHYSICAL) then
call Actions()
endif
return false
endfunction
//===========================================================================
private function Init takes nothing returns nothing
set gg_trg_SphereOfNatureOvergrowth = CreateTrigger()
call DisableTrigger(gg_trg_SphereOfNatureOvergrowth)
call TriggerRegisterVariableEvent( gg_trg_SphereOfNatureOvergrowth, "udg_PDD_damageEventTrigger", EQUAL, 1.00 )
call TriggerAddCondition( gg_trg_SphereOfNatureOvergrowth, Condition(function Conditions ))
endfunction
endscope
as you can see, i'm calling the function Overgrowth from within the OvergrowthStart if the unit with the effect dies, but thats not allowed because jass read from bottom to top and it gives me an error saying that the Overgrowth function is not declared. I'm a little short of ideas on how to solve this, and i do not want to use the entangle roots ability because i want the source unit to do the damage, not a dummy. Any ideas on how to do this? Thx.
Last edited: