|
http://www.tudou.com/v/asrfwXXE34E视频上传完毕
[codes=jass]
scope Blaze
globals
private constant integer abil_id='A000'//释放魔法相应的技能
private constant real int=.025 //释放技能动作时间
private constant integer dummy_id='n000'//创建出来的魔法效果
private constant integer max_missiles=6
private constant real start_dist=150. //释放技能释放的距离
private constant real end_height=280. //释放技能旋转的高度
private constant real twirl_time=1.
private constant real twirl_speed=5.
private constant real speed=15. //创建出来的魔法效果移动速度
private constant boolean new_target=true//原攻击目标死亡是否寻找新的目标(默认 是)
private constant real height_diff=35.
private constant attacktype a_type=ATTACK_TYPE_MAGIC //根据自己的需要可以自行修改
private constant damagetype d_type=DAMAGE_TYPE_FIRE //根据自己的需要可以自行修改
endglobals
private function damage takes integer lvl returns real
return lvl*25. //每个攻击的伤害
endfunction
private function range takes integer lvl returns real
return(lvl*50.)+750.//攻击的距离
endfunction
private function count takes integer lvl returns integer
return 4+lvl //魔法火球能够创建来的个数
endfunction
globals
private unit U=null
private group G=CreateGroup()
private timer Tball=CreateTimer()
private integer Total1=0
private integer Total2=0
private Blaze_data1 array structArray1
private Blaze_data2 array structArray2
public trigger Trigger=CreateTrigger()
endglobals
private function ABU takes unit a,unit b returns real
return bj_RADTODEG*Atan2(GetUnitY(b)-GetUnitY(a),GetUnitX(b)-GetUnitX(a))
endfunction
private function DBU takes unit a,unit b returns real
return SquareRoot(Pow(GetUnitX(b)-GetUnitX(a),2)+Pow(GetUnitY(b)-GetUnitY(a),2))
endfunction
private function Filt takes nothing returns boolean
return GetWidgetLife(GetFilterUnit())>.405 and IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(U))==true
endfunction
struct Blaze_data2
unit ball=null
unit targ=null
real height=end_height
integer lvl=0
method Start takes unit ball,integer lvl returns nothing
set .ball=ball
set .targ=GroupPickRandomUnit(G)
set .lvl=lvl
endmethod
method Effects takes nothing returns nothing
local real ang=ABU(.ball,.targ)
call SetUnitX(.ball,GetUnitX(.ball)+speed*Cos(ang*bj_DEGTORAD))
call SetUnitY(.ball,GetUnitY(.ball)+speed*Sin(ang*bj_DEGTORAD))
call SetUnitFacing(.ball,ang)
set .height=.height-10.
if .height<GetUnitFlyHeight(.targ)+height_diff then
set .height=GetUnitFlyHeight(.targ)+height_diff
endif
call SetUnitFlyHeight(.ball,.height,0.0)
endmethod
method Update takes integer i returns nothing
set structArray2=structArray2[Total2]
set Total2=Total2-1
endmethod
method onDestroy takes nothing returns nothing
if .targ!=null then
call UnitDamageTarget(.ball,.targ,damage(.lvl),false,false,a_type,d_type,null)
endif
call KillUnit(.ball)
endmethod
endstruct
struct Blaze_data1
integer runs=0
unit tower=null
unit array ball[max_missiles]
real array ang[max_missiles]
real xtower
real ytower
integer total=0
real increment=0.
real change=0.
real Hchange=0.
integer total_runs=0
method Start takes unit tower returns nothing
local integer i=1
local real x=GetUnitX(tower)
local real x2
local real y=GetUnitY(tower)
local real y2
local player p=GetOwningPlayer(tower)
set .total=count(GetUnitAbilityLevel(tower,abil_id))
set .increment=360/.total
set .total_runs=R2I(twirl_time/int)
set .change=start_dist/.total_runs
set .Hchange=end_height/.total_runs
loop
exitwhen i>.total
set .ang=i*.increment
set x2=x+start_dist*Cos(.ang*bj_DEGTORAD)
set y2=y+start_dist*Sin(.ang*bj_DEGTORAD)
set .ball=CreateUnit(p,dummy_id,x2,y2,0.)
set i=i+1
endloop
set .tower=tower
set .xtower=x
set .ytower=y
endmethod
method Effects takes nothing returns nothing
local integer i=1
local real height=.runs*.Hchange
local real distance=start_dist-(.runs*.change)
loop
exitwhen i>.total
set .ang=.ang+twirl_speed
call SetUnitX(.ball,.xtower+distance*Cos(.ang*bj_DEGTORAD))
call SetUnitY(.ball,.ytower+distance*Sin(.ang*bj_DEGTORAD))
call SetUnitFlyHeight(.ball,height,0.0)
set i=i+1
endloop
endmethod
method Update takes integer i returns nothing
set structArray1=structArray1[Total1]
set Total1=Total1-1
endmethod
method onDestroy takes nothing returns nothing
local integer i=1
local Blaze_data2 dat
local integer lvl
if GetWidgetLife(.tower)<.405 then
loop
exitwhen i>.total
call KillUnit(.ball)
set i=i+1
endloop
else
set lvl=GetUnitAbilityLevel(.tower,abil_id)
call GroupClear(G)
set U=.tower
call GroupEnumUnitsInRange(G,.xtower,.ytower,range(lvl),Condition(function Filt))
loop
exitwhen i>.total
set dat=Blaze_data2.create()
call dat.Start(.ball,lvl)
set Total2=Total2+1
set structArray2[Total2]=dat
set i=i+1
endloop
endif
endmethod
endstruct
private function Conditions takes nothing returns boolean
return GetSpellAbilityId()==abil_id
endfunction
private function Movement takes nothing returns nothing
local integer i=1
local Blaze_data1 dat1
local Blaze_data2 dat2
loop
exitwhen i>Total1
set dat1=structArray1
set dat1.runs=dat1.runs+1
if dat1.runs>dat1.total_runs or GetWidgetLife(dat1.tower)<.405 then
call dat1.destroy()
call dat1.Update(i)
set i=i-1
else
call dat1.Effects()
endif
set i=i+1
endloop
set i=1
loop
exitwhen i>Total2
set dat2=structArray2
if dat2.targ==null or GetWidgetLife(dat2.targ)<.405 then
if new_target then
call GroupClear(G)
set U=dat2.ball
call GroupEnumUnitsInRange(G,GetUnitX(dat2.ball),GetUnitY(dat2.ball),range(dat2.lvl),Condition(function Filt))
set dat2.targ=GroupPickRandomUnit(G)
if dat2.targ==null then
call dat2.destroy()
call dat2.Update(i)
endif
set i=i+1
else
call dat2.destroy()
call dat2.Update(i)
set i=i-1
endif
elseif DBU(dat2.ball,dat2.targ)<speed then
call dat2.destroy()
call dat2.Update(i)
set i=i-1
else
call dat2.Effects()
endif
set i=i+1
endloop
if Total1==0 and Total2==0 then
call PauseTimer(Tball)
endif
endfunction
private function Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local Blaze_data1 dat=Blaze_data1.create()
if Total1==0 and Total2==0 then
call TimerStart(Tball,int,true,function Movement)
endif
call dat.Start(u)
set Total1=Total1+1
set structArray1[Total1]=dat
set u=null
endfunction
public function InitTrig takes nothing returns nothing
call TriggerRegisterAnyUnitEventBJ(Trigger,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(Trigger,Condition(function Conditions))
call TriggerAddAction(Trigger,function Actions)
endfunction
endscope
[/codes]
|
评分
-
查看全部评分
|