|
楼主 |
发表于 2009-10-9 12:55:05
|
显示全部楼层
顺便附送一个最新制作的闪电链函数
[jass]
//==Sample:===
call ChainLightning_Start(su,tu,UnitSelectFilter,JumpCount,JumpRange,TempGroup)
[/jass]
[jass]function CreateGroupTimed_End takes nothing returns nothing
local integer tmIndex=GetTimerIndex(GetExpiredTimer())
call DestroyGroup(SYS_TimerData_Group[tmIndex])
call ReleaseTimer(GetExpiredTimer())
endfunction
function CreateGroupTimed takes real looptime returns group
local integer tmIndex=GetTimerIndex(GetTimer())
set SYS_TimerData_Group[tmIndex]=CreateGroup()
call TimerStart(SYS_Timer[tmIndex],looptime,false,function CreateGroupTimed_End)
return SYS_TimerData_Group[tmIndex]
endfunction
function AddLightningTimedByUnit_Loop takes nothing returns nothing
local integer tmIndex=GetTimerIndex(GetExpiredTimer())
local integer inv = 10
local unit su = SYS_TimerData_U00[tmIndex]
local unit tu = SYS_TimerData_U01[tmIndex]
local real x1 = GetUnitX(su)
local real y1 = GetUnitY(su)
local real z1 = GetUnitFlyHeight(su) + 60.0
local real x2 = GetUnitX(tu)
local real y2 = GetUnitY(tu)
local real z2 = GetUnitFlyHeight(tu) + 60.0
local real alpha =0.0
if(GetUnitState(su,UNIT_STATE_MAX_LIFE)<=0.0 or GetUnitState(tu,UNIT_STATE_MAX_LIFE)<=0.0)then
set SYS_TimerData_I00[tmIndex] = 0
set SYS_TimerData_I01[tmIndex] = 0
endif
if(SYS_TimerData_I00[tmIndex]>0)then
set SYS_TimerData_I00[tmIndex] = SYS_TimerData_I00[tmIndex] - inv
call MoveLightningEx(SYS_TimerData_Lightning[tmIndex],false,x1,y1,z1,x2,y2,z2)
elseif(SYS_TimerData_I01[tmIndex]>0)then
set SYS_TimerData_I01[tmIndex] = IMax(0,SYS_TimerData_I01[tmIndex] - inv)
set alpha = I2R(SYS_TimerData_I01[tmIndex])/I2R(SYS_TimerData_I02[tmIndex])
call MoveLightningEx(SYS_TimerData_Lightning[tmIndex],false,x1,y1,z1,x2,y2,z2)
call SetLightningColor(SYS_TimerData_Lightning[tmIndex],1.0,1.0,1.0,alpha)
else
call DestroyLightning(SYS_TimerData_Lightning[tmIndex])
call ReleaseTimer(GetExpiredTimer())
endif
set su = null
set tu = null
endfunction
function AddLightningTimedByUnit takes string s,unit su,unit tu,integer lTime,integer rTime returns nothing
local integer tmIndex=GetTimerIndex(GetTimer())
local real x1 = GetUnitX(su)
local real y1 = GetUnitY(su)
local real z1 = GetUnitFlyHeight(su) + 60.0
local real x2 = GetUnitX(tu)
local real y2 = GetUnitY(tu)
local real z2 = GetUnitFlyHeight(tu) + 60.0
set SYS_TimerData_U00[tmIndex] = su
set SYS_TimerData_U01[tmIndex] = tu
set SYS_TimerData_I00[tmIndex] = lTime
set SYS_TimerData_I01[tmIndex] = rTime
set SYS_TimerData_I02[tmIndex] = rTime
set SYS_TimerData_Lightning[tmIndex]=AddLightningEx(s,false,x1,y1,z1,x2,y2,z2)
call TimerStart(SYS_Timer[tmIndex],0.1,true,function AddLightningTimedByUnit_Loop)
endfunction
function ChainLightning_SelectUnit_Cond takes nothing returns boolean
if(not(IsUnitInRangeXY(GetFilterUnit(),SYS_GroupX,SYS_GroupY,SYS_GroupR)))then
return false
endif
if(IsUnitInGroup(GetFilterUnit(),SYS_Group))then
return false
endif
if(not(TargetUnitCheck(GetFilterUnit(),SYS_GroupUnit,SYS_GroupInt)))then
return false
endif
set SYS_GroupTempData[0] = SYS_GroupTempData[0] + 1
return true
endfunction
function ChainLightning_SelectUnit_Action takes nothing returns nothing
set SYS_GroupTempData[0] = SYS_GroupTempData[0] - 1
if(SYS_GroupTempData[0]==0)then
set SYS_GroupTarget = GetEnumUnit()
endif
endfunction
function ChainLightning_SelectUnit takes unit su,integer filter,real x,real y,real r,group fGroup returns unit
local group g = CreateGroup()
local real range = 100.0
set SYS_GroupTarget = null
set SYS_GroupUnit = su
set SYS_Group = fGroup
set SYS_GroupInt = filter
set SYS_GroupX = x
set SYS_GroupY = y
loop
exitwhen(SYS_GroupTarget!=null or range>r)
call GroupClear(g)
set SYS_GroupTempData[0] = 0
set SYS_GroupR = range
call GroupEnumUnitsInRange(g,x,y,range+200.0,Condition(function ChainLightning_SelectUnit_Cond))
if(SYS_GroupTempData[0]>0)then
set SYS_GroupTempData[0] = GetRandomInt(1,SYS_GroupTempData[0])
call ForGroup(g,function ChainLightning_SelectUnit_Action)
endif
set range = range + 100.0
endloop
call DestroyGroup(g)
set g = null
return SYS_GroupTarget
endfunction
function ChainLightning_Loop takes nothing returns nothing
local integer tmIndex = GetTimerIndex(GetExpiredTimer())
local unit su = SYS_TimerData_U00[tmIndex]
local unit lu = SYS_TimerData_U01[tmIndex]
local unit tu = SYS_TimerData_U02[tmIndex]
local real x = GetUnitX(lu)
local real y = GetUnitY(lu)
local real r = SYS_TimerData_R00[tmIndex]
local integer filter = SYS_TimerData_I04[tmIndex]
set SYS_TimerData_I03[tmIndex] = SYS_TimerData_I03[tmIndex] - 1
if(tu==null and SYS_TimerData_I03[tmIndex]>=0)then
set tu = ChainLightning_SelectUnit(su,filter,x,y,r,SYS_TimerData_Group[tmIndex])
endif
if(tu!=null and SYS_TimerData_I03[tmIndex]>=0)then
if(not(IsUnitInGroup(tu,SYS_TimerData_Group[tmIndex])))then
call GroupAddUnit(SYS_TimerData_Group[tmIndex],tu)
if(lu==su and SYS_TimerData_B00[tmIndex])then
call AddLightningTimedByUnit("CLPB",lu,tu,0,100)
else
call AddLightningTimedByUnit("CLSB",lu,tu,0,100)
endif
call DestroyEffect(AddSpecialEffectTarget("Abilities\\\\Weapons\\\\Bolt\\\\BoltImpact.mdl",tu,"origin"))
set SYS_GroupUnit = su
set SYS_GroupTarget = tu
call ExecuteBoolexpr(SYS_TimerData_Boolexpr[tmIndex])
endif
set SYS_TimerData_U01[tmIndex] = tu
set SYS_TimerData_U02[tmIndex] = null
call TimerStart(SYS_Timer[tmIndex],0.33,true,function ChainLightning_Loop)
else
call ReleaseTimer(GetExpiredTimer())
endif
set su = null
set lu = null
set tu = null
endfunction
function ChainLightning_Start takes unit su,unit tu,integer filter,integer Count,real range,group fGroup,boolexpr cond returns integer
local integer tmIndex = GetTimerIndex(GetTimer())
set SYS_TimerData_U00[tmIndex] = su
set SYS_TimerData_U01[tmIndex] = su
set SYS_TimerData_U02[tmIndex] = tu
set SYS_TimerData_I03[tmIndex] = Count
set SYS_TimerData_I04[tmIndex] = filter
set SYS_TimerData_R00[tmIndex] = range
set SYS_TimerData_Boolexpr[tmIndex] = cond
if(fGroup==null)then
set SYS_TimerData_Group[tmIndex] = CreateGroupTimed(I2R(IMax(0,(Count-1)))*0.33+0.1)
else
set SYS_TimerData_Group[tmIndex] = fGroup
endif
call TimerStart(SYS_Timer[tmIndex],0.0,true,function ChainLightning_Loop)
return tmIndex
endfunction[/jass] |
|