|
原jass代码如下,其中有个公式很不明白!想了许久
就是这个
local real b=1-a
call SetUnitX(kF,CheckX(Ax*a*a+Bx*2*a*b+Cx*b*b)) 左边这个难道是椭圆的轨迹方程? (Ax*a*a+Bx*2*a*b+Cx*b*b)
call SetUnitY(kF,CheckY(Ay*a*a+By*2*a*b+Cy*b*b)) 左边这个难道是椭圆的轨迹方程? (Ay*a*a+By*2*a*b+Cy*b*b)
就是这个方程式不太明白。。就是这个公式。 椭圆方程应该没有2ab这项啊。。。。
(原作者提示说是三角形公式。。。三角形有这样的公式?)
原附件下最下面
[jass]
function initCache takes nothing returns nothing
call FlushGameCache(InitGameCache("DotACache.x"))
set udg_Cache=InitGameCache("DotACache.x")
endfunction
function H2I takes handle h returns integer
return h
return 0
endfunction
function H2S takes handle h returns string
return I2S(H2I(h))
endfunction
function FlushCache takes string Eq returns nothing
call FlushStoredMission(udg_Cache,Eq)
endfunction
function SetStringHandle takes string Eq,string Er,handle ER returns nothing
call StoreInteger(udg_Cache,Eq,Er,H2I(ER))
endfunction
function SetStringInt takes string Eq,string Er,integer ES returns nothing
call StoreInteger(udg_Cache,Eq,Er,ES)
endfunction
function SetStringReal takes string Eq,string Er,real ES returns nothing
call StoreReal(udg_Cache,Eq,Er,ES)
endfunction
function SetStringBool takes string Eq,string Er,boolean ES returns nothing
call StoreBoolean(udg_Cache,Eq,Er,ES)
endfunction
function GetStringUnit takes string Eq,string Er returns unit
return GetStoredInteger(udg_Cache,Eq,Er)
return null
endfunction
function GetStringPlayer takes string Eq,string Er returns player
return GetStoredInteger(udg_Cache,Eq,Er)
return null
endfunction
function GetStringTimer takes string Eq,string Er returns timer
return GetStoredInteger(udg_Cache,Eq,Er)
return null
endfunction
function GetStringTrigger takes string Eq,string Er returns trigger
return GetStoredInteger(udg_Cache,Eq,Er)
return null
endfunction
function GetStringGroup takes string Eq,string Er returns group
return GetStoredInteger(udg_Cache,Eq,Er)
return null
endfunction
function GetStringEffect takes string Eq,string Er returns effect
return GetStoredInteger(udg_Cache,Eq,Er)
return null
endfunction
function GetStringLocation takes string Eq,string Er returns location
return GetStoredInteger(udg_Cache,Eq,Er)
return null
endfunction
function GetStringTriggeraction takes string Eq,string Er returns triggeraction
return GetStoredInteger(udg_Cache,Eq,Er)
return null
endfunction
function GetStringInt takes string Eq,string Er returns integer
return GetStoredInteger(udg_Cache,Eq,Er)
endfunction
function GetStringBool takes string Eq,string Er returns boolean
return GetStoredBoolean(udg_Cache,Eq,Er)
endfunction
function CheckX takes real x returns real
local real E2=GetRectMinX(bj_mapInitialPlayableArea)+50
if(x<E2)then
return E2
endif
set E2=GetRectMaxX(bj_mapInitialPlayableArea)-50
if(x>E2)then
return E2
endif
return x
endfunction
function CheckY takes real y returns real
local real E2=GetRectMinY(bj_mapInitialPlayableArea)+50
if(y<E2)then
return E2
endif
set E2=GetRectMaxY(bj_mapInitialPlayableArea)-50
if(y>E2)then
return E2
endif
return y
endfunction
function Trig_axe_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A000' ) ) then
return false
endif
return true
endfunction
function killdes takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction
function damage takes unit Em,real x,real y,group ke returns nothing
local group fA=CreateGroup()
local unit fz
local rect kE=Rect(x-150,y-150,x+150,y+150)
call GroupEnumUnitsInRange(fA,x,y,150,null)
loop
set fz=FirstOfGroup(fA)
exitwhen fz==null
if(IsUnitInGroup(fz,ke)==false and IsUnitEnemy(fz,GetOwningPlayer(Em)) and IsUnitVisible(fz,GetOwningPlayer(Em)))then
if(GetUnitAbilityLevel(fz,'A04R')!=1 and GetUnitState(fz,UNIT_STATE_LIFE)>0 and IsUnitType(fz,UNIT_TYPE_STRUCTURE)==false)then //注:A04R在此演示中无用
call GroupAddUnit(ke,fz)
call UnitDamageTarget(Em,fz,60+GetUnitAbilityLevel(Em,'A000')*30,true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_METAL_HEAVY_SLICE)
call AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl",fz,"overhead")
endif
endif
call GroupRemoveUnit(fA,fz)
endloop
call EnumDestructablesInRect(kE,null,function killdes)
call RemoveRect(kE)
call DestroyGroup(fA)
endfunction
function AxeAction takes nothing returns nothing
local string fT=H2S(GetExpiredTimer())
local unit kF=GetStringUnit(fT,"Axe")
local unit fy=GetStringUnit(fT,"Hero")
local real Ax=GetStringReal(fT,"Ax")
local real Ay=GetStringReal(fT,"Ay")
local real Cx=GetStringReal(fT,"Cx")
local real Cy=GetStringReal(fT,"Cy")
local real Bx=GetStringReal(fT,"Bx")
local real By=GetStringReal(fT,"By")
local real a=GetStringReal(fT,"a")
local real b=1-a
local boolean kg=GetStringBool(fT,"FirstPass")
local group ke=GetStringGroup(fT,"AlreadyDamaged")
call SetUnitX(kF,CheckX(Ax*a*a+Bx*2*a*b+Cx*b*b))
call SetUnitY(kF,CheckY(Ay*a*a+By*2*a*b+Cy*b*b))
call damage(fy,GetUnitX(kF),GetUnitY(kF),ke)
if(kg)then
call SetStringReal(fT,"a",a-0.02)
else
call SetStringReal(fT,"a",a+0.02)
call SetStringReal(fT,"Ax",GetUnitX(fy))
call SetStringReal(fT,"Ay",GetUnitY(fy))
endif
if(a<0 and kg)then
call SetStringBool(fT,"FirstPass",false)
call SetStringReal(fT,"Bx",Ax+300*Cos(Atan2(Cy-Ay,Cx-Ax)+GetStringReal(fT,"AngleOffset")))
call SetStringReal(fT,"By",Ay+300*Sin(Atan2(Cy-Ay,Cx-Ax)+GetStringReal(fT,"AngleOffset")))
endif
if(a>1 and kg==false)then
call PauseTimer(GetExpiredTimer())
call DestroyGroup(ke)
call FlushCache(fT)
call RemoveUnit(kF)
call PolledWait(.1)
call DestroyTimer(GetExpiredTimer())
endif
endfunction
function Trig_axe_Actions takes nothing returns nothing
local unit Em=GetTriggerUnit()
local real Ax=GetUnitX(Em)
local real Ay=GetUnitY(Em)
local real Cx=GetLocationX(GetSpellTargetLoc())
local real Cy=GetLocationY(GetSpellTargetLoc())
local unit kh=CreateUnit(GetOwningPlayer(Em),'e000',Ax,Ay,270.)
local unit kH=CreateUnit(GetOwningPlayer(Em),'e000',Ax,Ay,270.)
local string ki
local string kI
local timer kj=CreateTimer()
local timer kJ=CreateTimer()
call UnitAddAbility(kh,'Amrf')
call UnitRemoveAbility(kh,'Amrf')
call SetUnitFlyHeight(kh,150,0)
call UnitAddAbility(kH,'Amrf')
call UnitRemoveAbility(kH,'Amrf')
call SetUnitFlyHeight(kH,150,0)
set ki=H2S(kj)
call SetStringHandle(ki,"Hero",Em)
call SetStringHandle(ki,"Axe",kh)
call SetStringHandle(ki,"AlreadyDamaged",CreateGroup())
call SetStringReal(ki,"Ax",Ax)
call SetStringReal(ki,"Ay",Ay)
call SetStringReal(ki,"Cx",Cx)
call SetStringReal(ki,"Cy",Cy)
call SetStringReal(ki,"Bx",Ax+300*Cos(Atan2(Cy-Ay,Cx-Ax)+45))
call SetStringReal(ki,"By",Ay+300*Sin(Atan2(Cy-Ay,Cx-Ax)+45))
call SetStringReal(ki,"a",1)
call SetStringReal(ki,"AngleOffset",-45)
call SetStringBool(ki,"FirstPass",true)
set kI=H2S(kJ)
call SetStringHandle(kI,"Hero",Em)
call SetStringHandle(kI,"Axe",kH)
call SetStringHandle(kI,"AlreadyDamaged",CreateGroup())
call SetStringReal(kI,"Ax",Ax)
call SetStringReal(kI,"Ay",Ay)
call SetStringReal(kI,"Cx",Cx)
call SetStringReal(kI,"Cy",Cy)
call SetStringReal(kI,"Bx",Ax+300*Cos(Atan2(Cy-Ay,Cx-Ax)-45))
call SetStringReal(kI,"By",Ay+300*Sin(Atan2(Cy-Ay,Cx-Ax)-45))
call SetStringReal(kI,"a",1)
call SetStringReal(kI,"AngleOffset",45)
call SetStringBool(kI,"FirstPass",true)
call TimerStart(kj,.035,true,function AxeAction)
call TimerStart(kJ,.035,true,function AxeAction)
endfunction
//===========================================================================
function InitTrig_axe takes nothing returns nothing
set gg_trg_axe = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_axe, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_axe, Condition( function Trig_axe_Conditions ) )
call TriggerAddAction( gg_trg_axe, function Trig_axe_Actions )
endfunction
[/jass] |
|