|
发表于 2008-6-8 13:11:35
|
显示全部楼层
贴出来,好多.乱七八糟的没整理..
使用了一个自定义函数,缓存的,..
[jass]
// 'A000' = Meat Hook (Butcher : Pudge)
// 'A00*' = Marker
function Trig_Meat_Hook_Conditions takes nothing returns boolean
return GetSpellAbilityId()=='A000'
endfunction
function IcanFly takes nothing returns nothing
local timer ICF=GetExpiredTimer()
local timer Mtt=GetTimer(H2Tx(ICF),"ICFCacheMtt")
local timer Mt=GetTimer(H2Tx(ICF),"ICFCacheMt")
local string ors=H2Tx(Mtt)
local integer Mn=GetInteger(ors,"ChainLinkNumber")
local unit Muu=GetUnit(ors,"ChainLinks"+I2S(Mn))
local unit lTl=GetUnit(ors,"Pudge")
local real Mx=GetUnitX(Muu)
local real My=GetUnitY(Muu)
if Mn>=3 and GetUnitState(lTl,UNIT_STATE_LIFE)>0 then
call SetUnitX(lTl,Mx)
call SetUnitY(lTl,My)
endif
call KillUnit(Muu)
call SetInteger(ors,"ChainLinkNumber",Mn-1)
if Mn==1 then
call UnitRemoveAbility(lTl, 'A00A' )
call PauseTimer(ICF)
call FastFlush(ors)
call FastFlush(H2Tx(Mt))
call FastFlush(H2Tx(ICF))
call PolledWait(1)
call DestroyTimer(ICF)
call DestroyTimer(Mt)
call DestroyTimer(Mtt)
endif
endfunction
function MeatHookFilter takes nothing returns boolean
if GetUnitAbilityLevel(GetFilterUnit(),'A001')==1 or GetFilterUnit()==udg_u_DTAX_temp then
return false
endif
if GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)<=0 then //or GetUnitTypeId(GetFilterUnit())=='u000' or GetUnitTypeId(GetFilterUnit())=='u00F' or IsUnitType(GetFilterUnit(),UNIT_TYPE_ANCIENT)
return false
endif
return true
endfunction
function MeatHookAim takes string ors,real Mxx,real Myy returns nothing
local group lEw
local group OHh=CreateGroup()
local location OHf
local boolexpr lTM
local unit Maim
local unit lTl=GetUnit(ors,"Pudge")
local real Ma=GetReal(ors,"Angle")
local real Mb
local unit OHu
local unit Fhel
local location Mtlo
local integer OLe=GetInteger(ors,"OLevel")
local integer OHo=GetInteger(ors,"OHook")
local integer Mforward=GetInteger(ors,"forward")
local integer lmZ=GetUnitAbilityLevel(lTl,'A000')
set lEw=CreateGroup()
set udg_u_DTAX_temp=lTl
set lTM=Condition(function MeatHookFilter)
call GroupEnumUnitsInRange(lEw,Mxx,Myy,'}',lTM)
call DestroyBoolExpr(lTM)
set Maim=FirstOfGroup(lEw)
call DestroyGroup(lEw)
set lEw=null
if(Maim!=null)then
//检查印记
if (GetUnitAbilityLevel(Maim,'A00A')==1) then
set udg_MH_Hit[GetPlayerId(GetOwningPlayer(lTl))+1] = (udg_MH_Hit[GetPlayerId(GetOwningPlayer(lTl))+1] + 1 )
call SetInteger(ors,"breakN",1)
call UnitDamageTarget(lTl,Maim,20000, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED, WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffect("Units\\\\Undead\\\\Abomination\\\\AbominationExplosion.mdl",GetUnitX(Maim),GetUnitY(Maim)))
call ShowUnit(Maim, false)
call PlaySoundOnUnitBJ( gg_snd_break2, 100, Maim )
call FlyText("撕裂!!",5,Maim,255,0,0)
else
//检查扎钩
if (GetUnitAbilityLevel(Maim,'A007')==1) then
if Mforward==2 then //让钩头延时3个
//再检查一次状态=======================
if (GetUnitAbilityLevel(lTl,'A00A')==1) then
call UnitDamageTarget(lTl,lTl,20000, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED, WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffect("Units\\\\Undead\\\\Abomination\\\\AbominationExplosion.mdl",GetUnitX(lTl),GetUnitY(lTl)))
call ShowUnit(lTl, false)
call PlaySoundOnUnitBJ( gg_snd_break2, 100, lTl )
call FlyText("撕裂!!",5,lTl,255,0,0)
endif
//finish the check-up=
set udg_MH_Hit[GetPlayerId(GetOwningPlayer(lTl))+1] = (udg_MH_Hit[GetPlayerId(GetOwningPlayer(lTl))+1] + 1 )
call SetInteger(ors,"breakN",2)
call UnitAddAbility(lTl, 'A00A' )
call PlaySoundOnUnitBJ( gg_snd_Icfsound, 100, Maim )
else
set Mforward=Mforward+1
call SetInteger(ors,"forward",Mforward)
endif
else
//change the hook head angle
if (GetUnitAbilityLevel(Maim,'A00C')==1) then
set OHu=GetUnit(ors,"ChainLinks"+I2S(1))//borrow var OHu
set Mb=AngleBetweenUnits(OHu,Maim)
set Ma=Ma-2*(90-(Mb-Ma))
call SetReal(ors,"Angle",Ma)
else
set udg_MH_Hit[GetPlayerId(GetOwningPlayer(lTl))+1] = (udg_MH_Hit[GetPlayerId(GetOwningPlayer(lTl))+1] + 1 )
call UnitAddAbility(Maim, 'A00A' )//add the tearing sign
call SetHandle(ors,"Target",Maim)//save the target
if IsUnitEnemy(Maim,GetOwningPlayer(lTl))then
call DestroyEffect(AddSpecialEffectTarget("Objects\\\\Spawnmodels\\\\Human\\\\HumanBlood\\\\BloodElfSpellThiefBlood.mdl",Maim,"origin"))
call PlaySoundOnUnitBJ( gg_snd_Hitana, 100, Maim )
if OHo==1 or OHo==2 then
call UnitDamageTarget(lTl,Maim,(100*lmZ), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED, WEAPON_TYPE_WHOKNOWS)
else
//golden hook damage
if (OHo==3) then
call UnitDamageTarget(lTl,Maim,( ( 100*lmZ ) + ( 200+(100*OLe) ) ), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED, WEAPON_TYPE_WHOKNOWS)
endif
endif
else
call PlaySoundOnUnitBJ( gg_snd_Hitfre, 100, Maim )
endif
//闪钩的伤害计算
if (OHo==4) then
if IsUnitEnemy(Maim,GetOwningPlayer(lTl)) then
call UnitDamageTarget(lTl,Maim,( ( 100*lmZ ) + ( 100+( 35*OLe) ) ), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED, WEAPON_TYPE_WHOKNOWS)
endif
set OHf=GetUnitLoc(Maim)
call DestroyEffect(AddSpecialEffectLoc("Abilities\\\\Spells\\\\Human\\\\Thunderclap\\\\ThunderClapCaster.mdl",OHf))
set OHh=GetUnitsInRangeOfLocMatching(350,OHf,null)
loop
set OHu=FirstOfGroup(OHh)
exitwhen OHu==null
if IsUnitEnemy(OHu,GetOwningPlayer(lTl)) then
set Fhel=CreateUnit(GetOwningPlayer(lTl),'ushd',GetUnitX(OHu),GetUnitY(OHu),0)
call UnitApplyTimedLife(Fhel, 'BHwe',1)
call IssueTargetOrderById(Fhel,852111,OHu)
call UnitDamageTarget(lTl,OHu,( 50+( 60*OLe) ), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED, WEAPON_TYPE_WHOKNOWS)
endif
call GroupRemoveUnit(OHh,OHu)
endloop
call RemoveLocation(OHf)
call DestroyGroup(OHh)
set OHh=null
endif
//==the damage finish====
endif//change the angle
endif//make the pudge flying
endif//tear the pudge up
endif//if main!=null
endfunction
function MeatHookBack takes string ors returns nothing
local integer Mnn=GetInteger(ors,"ChainLinkNumber")
local unit Maim=GetUnit(ors,"Target")
local unit lTl=GetUnit(ors,"Pudge")
local integer OLe=GetInteger(ors,"OLevel")
local integer OHo=GetInteger(ors,"OHook")
local unit Mu
local unit Muu
local real Mxx
local real Myy
local real Maa
loop
exitwhen Mnn<1
set Mu=GetUnit(ors,"ChainLinks"+I2S(Mnn+1))
set Muu=GetUnit(ors,"ChainLinks"+I2S(Mnn))
if (Mu!=null)and(Muu!=null) then
set Maa=bj_RADTODEG * Atan2(GetUnitY(Mu) - GetUnitY(Muu), GetUnitX(Mu) - GetUnitX(Muu))
set Mxx=GetUnitX(Muu)+40*Cos(Maa*bj_DEGTORAD)
set Myy=GetUnitY(Muu)+40*Sin(Maa*bj_DEGTORAD)
call SetUnitFacing(Muu,Maa+180)
call SetUnitX(Muu,Mxx)
call SetUnitY(Muu,Myy)
if (Mnn==1) then
if(Maim!=null)then
call SetUnitX(Maim,Mxx)
call SetUnitY(Maim,Myy)
//===吸血钩抽血代码===
if IsUnitEnemy(Maim,GetOwningPlayer(lTl)) and OHo==2 then
call UnitDamageTarget(lTl,Maim,( 14+( 6*OLe ) ), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED, WEAPON_TYPE_WHOKNOWS)
call SetUnitLifeBJ(lTl, ( GetUnitStateSwap(UNIT_STATE_LIFE, lTl) + (( 14+( 6*OLe ) )*0.3) ) )
call DestroyEffect(AddSpecialEffectTarget("Objects\\\\Spawnmodels\\\\Human\\\\HumanBlood\\\\BloodElfSpellThiefBlood.mdl",Maim,"origin"))
endif
//=======
else
call MeatHookAim(ors,Mxx,Myy)//=====钩头目标====
endif
endif
endif
set Mnn=Mnn-1
endloop
endfunction
function MeatHookPull takes nothing returns nothing
local timer Mt=GetExpiredTimer()
local timer Mtt=GetTimer(H2Tx(Mt),"ExtendCache")
local string ors=H2Tx(Mtt)
local integer Mn=GetInteger(ors,"ChainLinkNumber")
local integer OHo=GetInteger(ors,"OHook")
local integer Noe=GetInteger(ors,"ErrorAway")//==防出错
local integer Mnn=0
local integer MakerY
local unit lTl=GetUnit(ors,"Pudge")
local unit Maim
local unit Mu
local unit Muu
local real Mxx
local real Myy
local real Mx
local real My
local real MDis
local real Maa
local timer ICF
//========不让该function在同一时间运行两次..=================
if (Noe==0) then
call SetInteger(ors,"ErrorAway",1)
//=========检查距离(添加删除单位)==================
set Mn=GetInteger(ors,"ChainLinkNumber")
set Muu=GetUnit(ors,"ChainLinks"+I2S(Mn))
if (Muu!=null) then
set MDis=SquareRoot((GetUnitX(lTl)-GetUnitX(Muu))*(GetUnitX(lTl)-GetUnitX(Muu))+(GetUnitY(lTl)-GetUnitY(Muu))*(GetUnitY(lTl)-GetUnitY(Muu)))
if (MDis<50) then//==删除链条==
loop
exitwhen MDis>=50
call RemoveUnit(Muu)
set Mn=Mn-1
call SetInteger(ors,"ChainLinkNumber",Mn)
set Muu=GetUnit(ors,"ChainLinks"+I2S(Mn))
exitwhen Muu==null
set MDis=SquareRoot((GetUnitX(lTl)-GetUnitX(Muu))*(GetUnitX(lTl)-GetUnitX(Muu))+(GetUnitY(lTl)-GetUnitY(Muu))*(GetUnitY(lTl)-GetUnitY(Muu)))
endloop
else//==添加链条===
if (MDis>90) then
set Maa=bj_RADTODEG * Atan2(GetUnitY(lTl) - GetUnitY(Muu), GetUnitX(lTl) - GetUnitX(Muu))
set Mx=GetUnitX(Muu)
set My=GetUnitY(Muu)
loop
exitwhen Mnn*40>MDis-50
set Mnn=Mnn+1
set Mn=GetInteger(ors,"ChainLinkNumber")
set Mxx=Mx+Mnn*40*Cos(Maa*bj_DEGTORAD)
set Myy=My+Mnn*40*Sin(Maa*bj_DEGTORAD)
set Mu=CreateUnit(GetOwningPlayer(lTl),'u001',Mxx,Myy,Maa+180)
if (OHo==2) then
call SetUnitVertexColor(Mu, 255, 0, 0, 255 )
else
if (OHo==3) then
call SetUnitVertexColor(Mu, 255, 255, 0, 255 )
else
if (OHo==4) then
call SetUnitVertexColor(Mu, 0, 255, 255, 255 )
endif
endif
endif
call SetHandle(ors,"ChainLinks"+I2S(Mn+1),Mu)
call SetInteger(ors,"ChainLinkNumber",Mn+1)
endloop
endif
endif
endif
//=======开始移动=====
set Mn=GetInteger(ors,"ChainLinkNumber")
call SetHandle(ors,"ChainLinks"+I2S(Mn+1),lTl)
call MeatHookBack(ors)
set MakerY=GetInteger(ors,"breakN")
//检查印记2
if MakerY==2 then
call PauseTimer(Mt)
set ICF=CreateTimer()
call SetHandle(H2Tx(ICF),"ICFCacheMtt",Mtt)
call SetHandle(H2Tx(ICF),"ICFCacheMt",Mt)
call TimerStart(ICF,.03,true,function IcanFly)
endif
if(Mn==0)then
//清除印记
set Maim=GetUnit(ors,"Target")
if(Maim!=null)then
call UnitRemoveAbility(Maim, 'A00A' )
endif
call PauseTimer(Mt)
call FastFlush(ors)
call FastFlush(H2Tx(Mt))
call PolledWait(1)
call DestroyTimer(Mt)
call DestroyTimer(Mtt)
endif
call SetInteger(ors,"ErrorAway",0)
endif
endfunction
function MeatHookOut takes string ors,unit lTl returns nothing
local integer Mn=GetInteger(ors,"ChainLinkNumber")
local integer Mnn=0
local real Ma=GetReal(ors,"Angle")
local real Maa
local group lEw
local boolexpr lTM
local unit Mu
local unit Muu
local real Mxx
local real Myy
//========钩头=====
set Mu=GetUnit(ors,"ChainLinks"+I2S(1))
set Mxx=GetUnitX(Mu)+40*Cos(Ma*bj_DEGTORAD)
set Myy=GetUnitY(Mu)+40*Sin(Ma*bj_DEGTORAD)
//======检查边界====
if Mxx > udg_Map_X_Max then
set Mxx = udg_Map_X_Max
endif
if Mxx < udg_Map_X_Min then
set Mxx = udg_Map_X_Min
endif
if Myy > udg_Map_Y_Max then
set Myy = udg_Map_Y_Max
endif
if Myy < udg_Map_Y_Min then
set Myy = udg_Map_Y_Min
endif
call SetUnitX(Mu,Mxx)
call SetUnitY(Mu,Myy)
call MeatHookAim(ors,Mxx,Myy)//目标
//=========链条=====
loop
exitwhen Mnn>Mn-2
set Mnn=Mnn+1
set Mu=GetUnit(ors,"ChainLinks"+I2S(Mnn))
set Muu=GetUnit(ors,"ChainLinks"+I2S(Mnn+1))
set Maa=bj_RADTODEG * Atan2(GetUnitY(Mu) - GetUnitY(Muu), GetUnitX(Mu) - GetUnitX(Muu))
set Mxx=GetUnitX(Muu)+40*Cos(Maa*bj_DEGTORAD)
set Myy=GetUnitY(Muu)+40*Sin(Maa*bj_DEGTORAD)
//======检查边界====
if Mxx > udg_Map_X_Max then
set Mxx = udg_Map_X_Max
endif
if Mxx < udg_Map_X_Min then
set Mxx = udg_Map_X_Min
endif
if Myy > udg_Map_Y_Max then
set Myy = udg_Map_Y_Max
endif
if Myy < udg_Map_Y_Min then
set Myy = udg_Map_Y_Min
endif
call SetUnitX(Muu,Mxx)
call SetUnitY(Muu,Myy)
call SetUnitFacing(Muu,Maa)
endloop
endfunction
function MeatHookThrow takes nothing returns nothing
local timer Mt=GetExpiredTimer()
local string ors=H2Tx(Mt)
local integer Mn=GetInteger(ors,"ChainLinkMax")
local integer Mnn=GetInteger(ors,"ChainLinkNumber")
local integer OHo=GetInteger(ors,"OHook")
local unit lTl=GetUnit(ors,"Pudge")
local real Maa=GetReal(ors,"Angle")
local integer lmZ=GetUnitAbilityLevel(lTl,'A000')
local integer Mnnn=1
local unit Maim
local unit Mu
local unit Muu
local integer Nbreak=0
local real Mx
local real My
local real Mxx
local real Myy
local real MDis
local boolexpr lTM
local timer lTn
local timer ICF
local string lCache2
if(Mn<26+3*lmZ)then
set Mn=Mn+1
call SetInteger(ors,"ChainLinkMax",Mn)
set Mxx=GetUnitX(lTl)+35*Cos(Maa*bj_DEGTORAD)
set Myy=GetUnitY(lTl)+35*Sin(Maa*bj_DEGTORAD)
if (Mn==1) then
set Mu=CreateUnit(GetOwningPlayer(lTl),'u007',Mxx,Myy,Maa)
if (OHo==2) then
call SetUnitVertexColor(Mu, 255, 0, 0, 255 )
else
if (OHo==3) then
call SetUnitVertexColor(Mu, 255, 255, 0, 255 )
else
if (OHo==4) then
call SetUnitVertexColor(Mu, 0, 255, 255, 255 )
endif
endif
endif
call SetHandle(ors,"ChainLinks"+I2S(1),Mu)
call SetInteger(ors,"ChainLinkNumber",1)
else
set Muu=GetUnit(ors,"ChainLinks"+I2S(Mnn))
set MDis=SquareRoot((GetUnitX(lTl)-GetUnitX(Muu))*(GetUnitX(lTl)-GetUnitX(Muu))+(GetUnitY(lTl)-GetUnitY(Muu))*(GetUnitY(lTl)-GetUnitY(Muu)))
if (MDis>34) then
set Mx=GetUnitX(Muu)
set My=GetUnitY(Muu)
set Maa=bj_RADTODEG * Atan2(GetUnitY(lTl) - GetUnitY(Muu), GetUnitX(lTl) - GetUnitX(Muu))
loop
exitwhen MDis-Mnnn*35<0
set Mxx=Mx+Mnnn*35*Cos(Maa*bj_DEGTORAD)
set Myy=My+Mnnn*35*Sin(Maa*bj_DEGTORAD)
set Mu=CreateUnit(GetOwningPlayer(lTl),'u001',Mxx,Myy,Maa+180)
if (OHo==2) then
call SetUnitVertexColor(Mu, 255, 0, 0, 255 )
else
if (OHo==3) then
call SetUnitVertexColor(Mu, 255, 255, 0, 255 )
else
if (OHo==4) then
call SetUnitVertexColor(Mu, 0, 255, 255, 255 )
endif
endif
endif
set Mnn=Mnn+1
set Mnnn=Mnnn+1
call SetHandle(ors,"ChainLinks"+I2S(Mnn),Mu)
call SetInteger(ors,"ChainLinkNumber",Mnn)
endloop
endif
endif
call MeatHookOut(ors,lTl)
set Maim=GetUnit(ors,"Target")
set Nbreak=GetInteger(ors,"breakN")
if (Maim!=null)or(Nbreak==1) then
call PauseTimer(Mt)
set lTn=CreateTimer()
call SetHandle(H2Tx(lTn),"ExtendCache",Mt)
call TimerStart(lTn,.03,true,function MeatHookPull)
endif
if Nbreak==2 then
call PauseTimer(Mt)
set ICF=CreateTimer()
call SetHandle(H2Tx(ICF),"ICFCacheMtt",Mt)
call TimerStart(ICF,.03,true,function IcanFly)
endif
else
call PauseTimer(Mt)
set lTn=CreateTimer()
call SetHandle(H2Tx(lTn),"ExtendCache",Mt)
call TimerStart(lTn,.03,true,function MeatHookPull)
endif
endfunction
function Trig_Meat_Hook_Actions takes nothing returns nothing
local location lTo=GetUnitLoc(GetSpellAbilityUnit())
local location lng=GetSpellTargetLoc()
local timer Mt=CreateTimer()
local unit lTl=GetTriggerUnit()
local real lnM=AngleBetweenPoints(lTo,lng)
local string ors=H2Tx(Mt)
local integer oindex=0
local integer OLe
local integer OHo
call SetHandle(ors,"Pudge",lTl)
call SetReal(ors,"Angle",lnM)
set udg_MH_Throw[GetPlayerId(GetOwningPlayer(lTl))+1] = (udg_MH_Throw[GetPlayerId(GetOwningPlayer(lTl))+1] + 1 )
//==================
loop
exitwhen oindex>7
if (SubString(GetItemName(UnitItemInSlot(lTl,oindex-1)), 2, 4) == "AA" ) then
set OLe = S2I(SubString(GetItemName(UnitItemInSlot(lTl,oindex-1)), 6, 8))
//call EnableTrigger( gg_trg_MH_Extend1_Blood )
set OHo=2
call SetInteger(ors,"OLevel",OLe)
call SetInteger(ors,"OHook",OHo)
exitwhen true
else
if (SubString(GetItemName(UnitItemInSlot(lTl,oindex-1)), 2, 4) == "BB" ) then
set OLe= S2I(SubString(GetItemName(UnitItemInSlot(lTl,oindex-1)), 8, 10))
//call EnableTrigger( gg_trg_MH_Extend1_Golden )
set OHo=3
call SetInteger(ors,"OLevel",OLe)
call SetInteger(ors,"OHook",OHo)
exitwhen true
else
if (SubString(GetItemName(UnitItemInSlot(lTl,oindex-1)), 2, 4) == "CC") then
set OLe= S2I(SubString(GetItemName(UnitItemInSlot(lTl,oindex-1)), 4, 6))
//call EnableTrigger( gg_trg_MH_Extend1_Flash )
set OHo=4
call SetInteger(ors,"OLevel",OLe)
call SetInteger(ors,"OHook",OHo)
exitwhen true
else
if (oindex==7) then
set OHo=1
call SetInteger(ors,"OHook",OHo)
endif
endif
endif
endif
set oindex=oindex + 1
endloop
//==================
call TimerStart(Mt,.03,true,function MeatHookThrow)
call RemoveLocation(lTo)
call RemoveLocation(lng)
endfunction
//===========================================================================
function InitTrig_Meat_Hook takes nothing returns nothing
set gg_trg_Meat_Hook = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(gg_trg_Meat_Hook,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Meat_Hook,Condition(function Trig_Meat_Hook_Conditions))
call TriggerAddAction(gg_trg_Meat_Hook,function Trig_Meat_Hook_Actions)
endfunction
[/jass] |
|