- Joined
- May 3, 2008
- Messages
- 3,154
---problem solved---
Now the arrow does travel to the destination. However, it does not dead the moment it reach the destination.
Just where did the carculation goes wrong?
JASS:
function Arrow_Split_Conditions takes nothing returns boolean
return GetSpellAbilityId()=='A62X'
endfunction
function Arrow_Split_Actions takes nothing returns nothing
local unit caster=GetTriggerUnit()
local location loc = GetSpellTargetLoc()
local real x1=GetUnitX(caster)
local real y1=GetUnitY(caster)
local real sd=(GetUnitFacing(caster))
local real x2 = x1 + 100 * Cos(sd*bj_DEGTORAD)
local real y2 = y1 + 100 * Sin (sd*bj_DEGTORAD)
local real td
local real t1=GetLocationX(loc)
local real t2=GetLocationY(loc)
local unit lastcreated=CreateUnit(GetOwningPlayer(caster),'n61Q',x2,y2,sd)
call IssuePointOrder(lastcreated, "move", t1,t2)
set td=SquareRoot((t1-y2)*(t1-y2)+(t2-x2)*(t2-x2))/522
call UnitApplyTimedLife(lastcreated,'BTLF',td)
set caster=null
set lastcreated=null
set loc=null
call RemoveLocation(loc)
endfunction
function Arrow_Death_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit())=='n61Q'
endfunction
function Arrow_Death_Actions takes nothing returns nothing
local unit dead=GetTriggerUnit()
local unit lastcreated=null
local real x1=GetUnitX(dead)
local real y1=GetUnitY(dead)
local integer Arrow_Split=1
local real SA_real=0
local real missilefacing=bj_RADTODEG*Atan2(y1,x1)
local real newX
local real newY
loop
exitwhen Arrow_Split>12
set newX=x1+300*Cos(SA_real+.523599)
set newY=y1+300*Sin(SA_real+.523599)
set lastcreated=CreateUnit(GetOwningPlayer(dead),'n61R',x1,y1,missilefacing)
call UnitApplyTimedLife(lastcreated,'BTLF',.30)
call IssuePointOrder(lastcreated,"shockwave",newX,newY)
set SA_real=SA_real+.523599
set Arrow_Split=Arrow_Split+1
endloop
set dead=null
set lastcreated=null
endfunction
//===========================================================================
constant function CSAS takes nothing returns boolean
return true
endfunction
function InitTrig_Arrow_Split takes nothing returns nothing
local trigger T=CreateTrigger()
local trigger T2=CreateTrigger()
local integer TI=0
local filterfunc FF=Filter(function CSAS)
loop
exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call TriggerRegisterPlayerUnitEvent(T2,Player(TI),EVENT_PLAYER_UNIT_DEATH,null)
set TI=TI+1
endloop
call DestroyBoolExpr(FF)
call DestroyFilter(FF)
call TriggerAddAction(T,function Arrow_Split_Actions)
call TriggerAddCondition(T,Condition(function Arrow_Split_Conditions))
call TriggerAddAction(T2,function Arrow_Death_Actions)
call TriggerAddCondition(T2,Condition(function Arrow_Death_Conditions))
set FF=null
set T=null
set T2=null
endfunction
Now the arrow does travel to the destination. However, it does not dead the moment it reach the destination.
Just where did the carculation goes wrong?
JASS:
set td=SquareRoot((t1-y2)*(t1-y2)+(t2-x2)*(t2-x2))/522
Last edited: