|
写了个函数,在jasscraft通过了,但放到we代码区却出错良多,望高人指教,不胜感激。- globals
- hashtable ht1 = InitHashtable()
- endglobals
-
- //**********被动跳跃函数************
- function KillLivingTrees takes nothing returns nothing //杀死活树
- if (((GetDestructableTypeId(GetFilterDestructable()) == 'ATtr') or (GetDestructableTypeId(GetFilterDestructable()) == 'ATtc') or (GetDestructableTypeId(GetFilterDestructable()) == 'BTtw') or (GetDestructableTypeId(GetFilterDestructable()) == 'BTtc') or (GetDestructableTypeId(GetFilterDestructable()) == 'KTtw') or (GetDestructableTypeId(GetFilterDestructable()) == 'YTwt') or (GetDestructableTypeId(GetFilterDestructable()) == 'YTct') or (GetDestructableTypeId(GetFilterDestructable()) == 'YTft') or (GetDestructableTypeId(GetFilterDestructable()) == 'YTst') or (GetDestructableTypeId(GetFilterDestructable()) == 'DTsh') or (GetDestructableTypeId(GetFilterDestructable()) == 'CTtr') or (GetDestructableTypeId(GetFilterDestructable()) == 'CTtc') or (GetDestructableTypeId(GetFilterDestructable()) == 'ITtw') or (GetDestructableTypeId(GetFilterDestructable()) == 'ITtc') or (GetDestructableTypeId(GetFilterDestructable()) == 'FTtw') or (GetDestructableTypeId(GetFilterDestructable()) == 'LTlt') or (GetDestructableTypeId(GetFilterDestructable()) == 'WTtw') or (GetDestructableTypeId(GetFilterDestructable()) == 'WTst') or (GetDestructableTypeId(GetFilterDestructable()) == 'NTtw') or (GetDestructableTypeId(GetFilterDestructable()) == 'NTtc') or (GetDestructableTypeId(GetFilterDestructable()) == 'OTtw') or (GetDestructableTypeId(GetFilterDestructable()) == 'ZTtw') or (GetDestructableTypeId(GetFilterDestructable()) == 'ZTtc') or (GetDestructableTypeId(GetFilterDestructable()) == 'GTsh') or (GetDestructableTypeId(GetFilterDestructable()) == 'VTlt'))) then
- call KillDestructable( GetEnumDestructable() )
- else
- endif
- endfunction
- //计时器函数
- function PasJmpTimerFunc takes nothing returns nothing
- local unit damto = LoadUnitHandle( ht1, GetHandleId(GetExpiredTimer()), StringHash("damto"))
- local real steplong =LoadReal(ht1, GetHandleId(GetExpiredTimer()),StringHash("steplong"))
- local real high = LoadReal(ht1, GetHandleId(GetExpiredTimer()), StringHash("high"))
- local integer timeindex = LoadInteger(ht1, GetHandleId(GetExpiredTimer()),StringHash("timeindex"))
- local real angle = LoadReal(ht1,GetHandleId(GetExpiredTimer()),StringHash("angle"))
- local real x=GetUnitX(damto)+(steplong*CosBJ(angle))
- local real y=GetUnitY(damto)+(steplong*SinBJ(angle))
- local integer time = LoadInteger(ht1, GetHandleId(GetExpiredTimer()),StringHash("time"))
- local location p
- if ((timeindex > time) or (IsUnitAliveBJ(damto)==false)) then
- call PauseUnit(damto,false)
- call UnitRemoveAbility( damto, 'Amrf' )
- call FlushChildHashtable(ht1,GetHandleId(GetExpiredTimer()))
- call DestroyTimer(GetExpiredTimer())
- else
- //高度变化,依据自由落体公式并进行相对计算,避免多个跳跃同时进行造成的高度摇摆
- if ((GetUnitFlyHeight( damto) >= GetUnitDefaultFlyHeight(damto)) and (GetUnitFlyHeight(damto) <= 500.00)) then
- if ( timeindex <= (time / 2 )) then
- call SetUnitFlyHeight( damto, ( GetUnitFlyHeight(damto) + ( 2*high *I2R(timeindex )/(I2R(time)*I2R(time)))) , 0.00 )
- else
- call SetUnitFlyHeight( damto, ( GetUnitFlyHeight(damto) - ( 2*high *(I2R(time) - I2R(timeindex) )/(I2R(time)*I2R(time)))) , 0.00 )
- endif
- endif
- //位移变化,同样采用相对位移计算,所以支持路径合成,并进行了可通行检测。
- if ((IsTerrainPathable(( GetUnitX(damto) + ( steplong * CosBJ(angle) ) ), ( GetUnitY(damto) + ( steplong * SinBJ(angle) ) ), PATHING_TYPE_WALKABILITY) == false)) then
- call SetUnitX( damto,x)
- call SetUnitY( damto,y)
- //高度小于120时破坏树木和水中特效
- if ((GetUnitFlyHeight(damto) < 120.00)) then
- //破坏树木
- set p = GetUnitLoc(damto)
- call EnumDestructablesInCircleBJ( 40.00, p , function KillLivingTrees )
- call RemoveLocation( p )
- set p = null
- //高度小于10时水中显示水波
- if ((GetUnitFlyHeight(damto) < 10.00) and (IsTerrainPathable(GetUnitX(damto), GetUnitY(damto), PATHING_TYPE_FLOATABILITY) == false)) then
- call DestroyEffect( AddSpecialEffectTarget("Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl", damto, "origin") )
- endif
- endif
- endif
- call SaveInteger(ht1, GetHandleId(GetExpiredTimer()),StringHash("timeindex"), ( timeindex + 1 ))
- endif
- set damto = null
- set steplong = 0
- set high = 0
- set timeindex = 0
- set angle = 0
- set x = 0
- set y = 0
- set time = 0
- endfunction
- //主体函数
- function PasJmp takes unit damfrom,unit damto,real dam,boolean ifdam ,boolean ifjmp returns nothing
- local timer jmptimer=CreateTimer()
- call PauseUnit(damto,true)
- call SetUnitAnimation( damto , "death" )
- call SaveUnitHandle( ht1, GetHandleId( jmptimer ), StringHash("damto"), damto)
- call SaveReal(ht1, GetHandleId( jmptimer ), StringHash("angle"), Atan2BJ((GetUnitY(damto) - GetUnitY(damfrom)),( GetUnitX(damto) - GetUnitX(damfrom) )))
- if (ifdam == true) then
- call UnitDamageTarget( damfrom, damto, dam, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_METAL_HEAVY_SLICE )
- endif
- if (ifjmp == true) then
- call UnitAddAbility( damto, 'Amrf' )
- call SaveReal(ht1, GetHandleId( jmptimer ), StringHash("high"), ( 130.00 + ( dam / 5.00 ) ))
- else
- call SaveReal(ht1, GetHandleId( jmptimer ),StringHash("high"), 0 )
- endif
- call SaveInteger(ht1, GetHandleId(jmptimer),StringHash("timeindex"), 1 )
- call SaveReal(ht1, GetHandleId(jmptimer),StringHash("steplong"), ( 15.00 + ( dam / 50.00 ) ))
- call SaveInteger(ht1, GetHandleId(jmptimer),StringHash("time"), ( 11 + R2I(( dam / 10.00 )) ))
- call TimerStart(jmptimer, 0.02, true, function PasJmpTimerFunc)
- set jmptimer = null
-
- endfunction
-
复制代码 |
|