- Joined
- Oct 11, 2012
- Messages
- 711
Why there is always a dummy created in the middle of the map even when the casting unit is far away from that location and there is no enemy at that location? Can't figure out why..... Thanks guys.
Here are the triggers:
Here are the triggers:
JASS:
function Trig_QT_Conditions takes nothing returns boolean
return ((GetSpellAbilityId() == 'A00H'))
endfunction
function Trig_QT_001 takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit())) and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.405
endfunction
function Trig_QT_002 takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u1
set u1=FirstOfGroup(udg_zhansha)
loop
exitwhen u1==null
set u1=FirstOfGroup(udg_zhansha)
call GroupRemoveUnit(udg_zhansha,u1)
call RemoveUnit(u1)
endloop
call GroupClear(udg_zhansha)
call PauseTimer(t)
call DestroyTimer(t)
set u1 = null
endfunction
function Trig_QT_Actions takes nothing returns nothing
local timer t = CreateTimer()
local group g=CreateGroup()
local unit target = GetSpellTargetUnit()
local unit dummy
local unit u
local integer p = GetPlayerId(GetTriggerPlayer())
local real x = GetUnitX(target)
local real y = GetUnitY(target)
local real x2
local real y2
local real a
local unit u1
call GroupEnumUnitsInRange(g,x,y,700.00,Condition (function Trig_QT_001))
set u=FirstOfGroup(g)
loop
exitwhen u == null
set u=FirstOfGroup(g)
set a=GetUnitFacing(u)
//Position the dummy behind the enemy unit
set x2=GetUnitX(u)+ 100. * Cos((a-180)* bj_DEGTORAD)
set y2=GetUnitY(u)+ 100. * Sin((a-180)* bj_DEGTORAD)
set dummy=CreateUnit(Player(p),'o001',x2,y2,a)
call SetUnitAnimation(dummy,"slam")
call UnitDamageTarget(dummy,u,33.,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_DEMOLITION,null)
call GroupAddUnit(udg_zhansha,dummy)
call GroupRemoveUnit(g,u)
endloop
call TimerStart(t,1.00,false,function Trig_QT_002)
call DestroyGroup(g)
set target = null
set g = null
set dummy =null
set t = null
endfunction
//===========================================================================
function InitTrig_QT takes nothing returns nothing
set gg_trg_QT = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_QT, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(gg_trg_QT, Condition(function Trig_QT_Conditions))
call TriggerAddAction(gg_trg_QT, function Trig_QT_Actions)
endfunction