|
发表于 2008-5-13 22:59:12
|
显示全部楼层
还素看这个吧
[jass]
constant function Aval_AbilCode takes nothing returns integer
return 'A02H' //Ability rawcode
endfunction
function Aval_Damage takes unit u returns real
return (GetUnitAbilityLevel(u,Aval_AbilCode())*45.0)+20.0 //Damage per each snowball
endfunction
function Aval_Number takes unit u returns integer
return (GetUnitAbilityLevel(u,Aval_AbilCode())*3)+5//Maximum of possible snowballs in line
endfunction
function Aval_Duration takes unit u returns real
return (GetUnitAbilityLevel(u,Aval_AbilCode())*0.0)+3.0 //Seconds of Avalanche duration
endfunction
constant function Aval_Distance takes nothing returns real
return 25.0 //Distance between snowballs
endfunction
constant function Aval_MoveSpeed takes nothing returns integer
return 40 //Speed of Avalanche moving
endfunction
constant function Aval_Dummy_Code takes nothing returns integer
return 'e009' //Rawcode of dummy unit
endfunction
//========================================================
function Aval_MoveCond takes nothing returns boolean
local timer t = GetExpiredTimer()
local unit un = GetHandleUnit(t,"snowball")
local boolean bool = IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE) == false and IsUnitType(GetFilterUnit(),UNIT_TYPE_FLYING) == false
set t = null
set un = null
return bool
endfunction
function Aval_Move takes nothing returns nothing
local timer t = GetExpiredTimer()
local trigger trg = GetHandleTrigger(t, "trigger")
local unit u = GetHandleUnit(t,"snowball")
local real ang = GetHandleReal(trg,"angle")
local real z = GetLocationZ(GetUnitLoc(u)) + GetUnitFlyHeight(u) - 60
local real x = GetUnitX(u) - Cos(ang*bj_DEGTORAD)*15
local real y = GetUnitY(u) - Sin(ang*bj_DEGTORAD)*15
local unit cas = GetHandleUnit(trg,"caster")
local location loc = Location(x,y)
local integer i = 0
if not GetHandleBoolean(t,"turn off") == true then
set z = z - GetLocationZ(loc)
call SetHandleReal(t,"height",z )
call SetUnitFlyHeight(u,z,0)
call SetUnitX(u,x)
call SetUnitY(u,y)
endif
set trg = null
set cas = null
set t = null
set u = null
call RemoveLocation(loc)
endfunction
function Aval_InitMove takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local unit cas = GetHandleUnit(t,"caster")
local real dist = GetHandleReal(t,"distance") + Aval_MoveSpeed()*GetHandleReal(t,"number") + 200
local real dist2
local real ang = GetHandleReal(t,"angle")
local real x = GetHandleReal(t,"x loc") + Cos(ang*bj_DEGTORAD)*dist
local real y = GetHandleReal(t,"y loc") + Sin(ang*bj_DEGTORAD)*dist
local integer i = GetRandomInt(Aval_Number(cas)+1,Aval_Number(cas)+3)
local real int = R2I(GetHandleReal(t,"number"))
local timer tim = CreateTimer()
local unit un
local group g = CreateGroup()
if i >= (Aval_Number(cas) + 3) then
call SetHandleReal(t,"number", int + 1.0)
endif
set dist2 = Aval_Distance()*GetRandomReal(1,Aval_Number(cas)/2)
set ang = GetRandomInt(1,2)*180-90 + ang
set x = x + Cos(ang*bj_DEGTORAD)*dist2
set y = y + Sin(ang*bj_DEGTORAD)*dist2
set un = CreateUnit(GetOwningPlayer(cas),Aval_Dummy_Code(),x,y,0)
call SetUnitPathing(un,false)
call SetUnitFlyHeight(un,850,0)
call SetHandleHandle(tim,"trigger",t )
call SetHandleHandle(tim,"snowball",un)
call SetHandleBoolean(tim,"turn off",false)
call SetHandleReal(tim,"height",1)
call TimerStart(tim,0.05,true,function Aval_Move)
loop
exitwhen GetHandleReal(tim,"height") <= 0
call TriggerSleepAction(0.1)
endloop
call SetHandleBoolean(tim,"turn off",true)
set x = GetUnitX(un)
set y = GetUnitY(un)
call GroupEnumUnitsInRange(g,x,y,250.0,Condition(function Aval_MoveCond))
set i = CountUnitsInGroup(g)
call UnitDamageTarget(cas,FirstOfGroup(g),Aval_Damage(cas),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffect("Abilities\\\\Spells\\\\Undead\\\\FrostNova\\\\FrostNovaTarget.mdl",x,y))
call FlushHandleLocals(tim)
call RemoveUnit(un)
call DestroyTimer(tim)
set t = null
set cas = null
set tim = null
set un = null
call DestroyGroup(g)
endfunction
function Aval_TrigAct takes nothing returns nothing
local unit u = GetTriggerUnit()
local location loc = GetUnitLoc(u)
local real ang = AngleBetweenPoints(loc,GetSpellTargetLoc())
local real dist = DistanceBetweenPoints(loc,GetSpellTargetLoc())
local trigger t = CreateTrigger()
call SetHandleHandle(t,"caster",u)
call SetHandleReal(t,"angle",ang)
call SetHandleReal(t,"distance",dist)
call SetHandleInt(t,"number",1)
call SetHandleReal(t,"x loc",GetLocationX(loc))
call SetHandleReal(t,"y loc",GetLocationY(loc))
call TriggerRegisterTimerEvent(t,0.10,true)
call TriggerAddAction(t,function Aval_InitMove)
call PolledWait(Aval_Duration(u))
call FlushHandleLocals(t)
call TriggerClearActions(t)
call DestroyTrigger(t)
set u = null
call RemoveLocation(loc)
endfunction
//===========================================================================
function Trig_Avalanche_Cond takes nothing returns boolean
return GetSpellAbilityId() == Aval_AbilCode()
endfunction
function InitTrig_Avalanche takes nothing returns nothing
set gg_trg_Avalanche = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Avalanche, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Avalanche,Condition(function Trig_Avalanche_Cond))
call TriggerAddAction(gg_trg_Avalanche,function Aval_TrigAct)
endfunction
[/jass] |
|