|
楼主 |
发表于 2008-9-28 14:12:06
|
显示全部楼层
我来把图和代码发上来了。。。
真的很诡异哦,默认的是用//注释掉了那条命令单位的语句的,意思是你可以先进地图试一试,发现一切很正常,再修改把//注释删掉,就会发现仅仅是这么一条命令单位的语句就会让接下来的函数运行出现奇怪的问题。。。
也可以把创建单位和命令单位的语句写到ZZLD_Filter里面(我最先是写到这个里面的,但是没有保存,要加的话里面的if语句加全要加4次,懒得了就直接写在外面了),会发现写在ZZLD_Filter里面也是会导致下面的函数运行出现问题的。。。
高手帮忙解答一下吧。。。
代码:
[jass]
function ZZLD_Timer_Right takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetUnit(H2S(t),"u")
local unit u3
local real angle = GetReal(H2S(t),"angle") - 90
local real d = GetReal(H2S(t),"d")
if(d > 0) then
call SetUnitX(u,GetMapX(22.0 * CosBJ(angle) + GetUnitX(u)))
call SetUnitY(u,GetMapY(22.0 * SinBJ(angle) + GetUnitY(u)))
call SetReal(H2S(t),"d",d-22)
call SetUnitFacing(u,angle + 180)
else
call CleanCV(H2S(t))
call DestroyTimer(t)
call PauseUnit(u,false)
set u3 = CreateUnitYX(GetOwningPlayer(u),'h000',GetUnitX(u),GetUnitY(u),'A00S')
call IssueNeutralTargetOrder( GetOwningPlayer(u), u3, "slow", u )
endif
set u3 = null
set u = null
set t = null
endfunction
function ZZLD_Timer_Left takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetUnit(H2S(t),"u")
local real angle = GetReal(H2S(t),"angle") + 90
local real d = GetReal(H2S(t),"d")
local unit u3
if(d > 0) then
call SetUnitX(u,GetMapX(22.0 * CosBJ(angle) + GetUnitX(u)))
call SetUnitY(u,GetMapY(22.0 * SinBJ(angle) + GetUnitY(u)))
call SetReal(H2S(t),"d",d-22)
call SetUnitFacing(u,angle - 180)
else
call CleanCV(H2S(t))
call DestroyTimer(t)
call PauseUnit(u,false)
set u3 = CreateUnitYX(GetOwningPlayer(u),'h000',GetUnitX(u),GetUnitY(u),'A00S')
call IssueNeutralTargetOrder( GetOwningPlayer(u), u3, "slow", u )
endif
set u3 = null
set u = null
set t = null
endfunction
function ZZLD_Filter takes nothing returns nothing
local unit u1 = GetTriggerUnit()
local unit u = GetFilterUnit()
local unit u2 = GetSpellTargetUnit()
local timer t = CreateTimer()
local real k
local real b
local real q
local real d
local real maxX
local real minX
local real maxY
local real minY
local real angle = AngleBetweenUnits(u1,u2)
local real x1 = GetUnitX(u1)
local real y1 = GetUnitY(u1)
local real x2 = GetUnitX(GetSpellTargetUnit())
local real y2 = GetUnitY(GetSpellTargetUnit())
local real x3 = GetUnitX(u)
local real y3 = GetUnitY(u)
local real damage = 100//
local group lGroup = GetGroup(H2S(u1),"ZZLD")
local unit uc
if(y1 >= y2) then
set maxY = y1
set minY = y2
else
set maxY = y2
set minY = y1
endif
if(x1 >= x2) then
set maxX = x1
set minX = x2
else
set maxX = x2
set minX = x1
endif
if(u!=u2 and IsUnitInGroup(u,lGroup) == false and GetUnitState(u,UNIT_STATE_LIFE)>1 and IsUnitEnemy(u, GetOwningPlayer(u1)) and IsUnitType(u, UNIT_TYPE_STRUCTURE) == false and GetUnitAbilityLevel(u, 'A006') == 0 ) then
call GroupAddUnit(lGroup,u)
if(x1-x2 == 0) then
if(y3 <= maxY and y3 >= minY) then
call CDamage(u1,u,damage)
set d = 350 - JDZ(x3-x1)
call SetReal(H2S(t),"d",d)
call SetUnit(H2S(t),"u",u)
call SetReal(H2S(t),"angle",angle)
call PauseUnit(u,true)
if(x3 >= x1) then
call TimerStart(t,.035,true,function ZZLD_Timer_Right)
else
call TimerStart(t,.035,true,function ZZLD_Timer_Left)
endif
endif
else
if(y1-y2 == 0) then
if(x3 <= maxX and x3 >= minX) then
call CDamage(u1,u,damage)
set d = 350 - JDZ(y3-y1)
call SetReal(H2S(t),"d",d)
call SetUnit(H2S(t),"u",u)
call SetReal(H2S(t),"angle",angle)
call PauseUnit(u,true)
if(y3 >= y1) then
call TimerStart(t,.035,true,function ZZLD_Timer_Left)
else
call TimerStart(t,.035,true,function ZZLD_Timer_Right)
endif
endif
else
set k = (y2-y1)/(x2-x1)
set b = y1 - k*x1
set q = y3 - k*x3 - b
set angle = AtanBJ(k)
if(JDZ(k)>=1) then
if(y3>=minY and y3<=maxY) then
call CDamage(u1,u,damage)
set d = 350 - JDZ(q/SquareRoot(1+k*k))
call SetReal(H2S(t),"d",d)
call SetUnit(H2S(t),"u",u)
call SetReal(H2S(t),"angle",angle)
call PauseUnit(u,true)
if(q <= 0) then
call TimerStart(t,.035,true,function ZZLD_Timer_Right)
else
call TimerStart(t,.035,true,function ZZLD_Timer_Left)
endif
endif
else
if(x3<=maxX and x3>=minX) then
call CDamage(u1,u,damage)
set d = 350 - JDZ(q/SquareRoot(1+k*k))
call SetReal(H2S(t),"d",d)
call SetUnit(H2S(t),"u",u)
call SetReal(H2S(t),"angle",angle)
call PauseUnit(u,true)
if(q <= 0) then
call TimerStart(t,.035,true,function ZZLD_Timer_Right)
else
call TimerStart(t,.035,true,function ZZLD_Timer_Left)
endif
endif
endif
endif
endif
endif
set lGroup = null
set t = null
set u1 = null
set u = null
set uc = null
endfunction
function Trig_ZZLD_Actions takes nothing returns nothing
local real x1 = GetUnitX(GetTriggerUnit())
local real y1 = GetUnitY(GetTriggerUnit())
local real x2 = GetUnitX(GetSpellTargetUnit())
local real y2 = GetUnitY(GetSpellTargetUnit())
local real angle = Angle(x1,y1,x2,y2)
local real s = ((SquareRoot((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)))/50) - 1
local real i = 1
local group lGroup = CreateGroup()
local group lGroup2 = CreateGroup()
local unit u
call SetHandle(H2S(GetTriggerUnit()),"ZZLD",lGroup2)
loop
exitwhen i > s
call GroupEnumUnitsInRange(lGroup,50*i*CosBJ(angle)+x1,50*i*SinBJ(angle)+y1,300,Condition(function ZZLD_Filter))
set u = CreateUnitYX(GetOwningPlayer(GetTriggerUnit()),'h000',50*i*CosBJ(angle)+x1,50*i*SinBJ(angle)+y1,'A000')
//call IssueImmediateOrder( u, "thunderclap" )
set i = i + 1
endloop
call DestroyGroup(lGroup)
set lGroup = null
call DestroyGroup(lGroup2)
set lGroup2 = null
set u = null
endfunction
function Trig_ZZLD_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A00E' ) ) then
return false
endif
return true
endfunction
function InitTrig_ZZLD takes nothing returns nothing
set gg_trg_ZZLD = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_ZZLD, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_ZZLD, Condition( function Trig_ZZLD_Conditions ) )
call TriggerAddAction( gg_trg_ZZLD, function Trig_ZZLD_Actions )
endfunction
[/jass] |
|