I'm trying to set up a trigger so if a unit targets a certain unit for a spell, the target of that spell changes to another unit. The problem is that it doesn't work with spells (but it does work with attack). So basically the problem is that the redirected spell fails to cast successfully.
Here's the part of the code that is supposed to redirect the spell
and here's the whole function
Here's the part of the code that is supposed to redirect the spell
JASS:
call IssueImmediateOrder(u, "stop")
call PolledWait2(0.1)
call IssueImmediateOrder(u, "spellbook")
call SetUnitAnimation(u, "stand")
call PolledWait2(0.1)
call IssueTargetOrderById(u, o, udg_Heroes[i])
and here's the whole function
JASS:
function Order_Action takes nothing returns nothing
local unit u = GetOrderedUnit()
local unit t = GetOrderTargetUnit()
local integer i = 0
local integer j = GetPlayerId(GetOwningPlayer(u))
local integer o = GetIssuedOrderId()
if (u != t and GetOwningPlayer(u) == GetOwningPlayer(t) and GetUnitTypeId(t) != 'h00Q' and GetUnitTypeId(u)!='h00Q') then
loop
exitwhen i>9 or t == PFArr[j*10+i]
set i = i+1
endloop
call IssueImmediateOrder(u, "stop")
call PolledWait2(0.1)
call IssueImmediateOrder(u, "spellbook")
call SetUnitAnimation(u, "stand")
call PolledWait2(0.1)
call IssueTargetOrderById(u, o, udg_Heroes[i])
endif
set u = null
set t = null
endfunction
Last edited: