找回密码
 点一下
查看: 1883|回复: 3

在原版we无法通过编译

[复制链接]
发表于 2012-2-6 00:48:32 | 显示全部楼层 |阅读模式
写了个函数,在jasscraft通过了,但放到we代码区却出错良多,望高人指教,不胜感激。
  1. globals
  2. hashtable ht1 = InitHashtable()
  3. endglobals
  4. //**********被动跳跃函数************
  5. function KillLivingTrees takes nothing returns nothing     //杀死活树
  6.     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
  7.         call KillDestructable( GetEnumDestructable() )
  8.     else
  9.     endif
  10. endfunction
  11. //计时器函数
  12. function PasJmpTimerFunc takes nothing returns nothing
  13.     local unit damto = LoadUnitHandle( ht1, GetHandleId(GetExpiredTimer()), StringHash("damto"))
  14.     local real steplong =LoadReal(ht1, GetHandleId(GetExpiredTimer()),StringHash("steplong"))
  15.     local real high = LoadReal(ht1, GetHandleId(GetExpiredTimer()), StringHash("high"))
  16.     local integer timeindex = LoadInteger(ht1, GetHandleId(GetExpiredTimer()),StringHash("timeindex"))
  17.     local real angle = LoadReal(ht1,GetHandleId(GetExpiredTimer()),StringHash("angle"))
  18.     local real x=GetUnitX(damto)+(steplong*CosBJ(angle))
  19.     local real y=GetUnitY(damto)+(steplong*SinBJ(angle))
  20.     local integer time = LoadInteger(ht1, GetHandleId(GetExpiredTimer()),StringHash("time"))
  21.     local location p
  22.     if ((timeindex > time) or (IsUnitAliveBJ(damto)==false)) then
  23.         call PauseUnit(damto,false)
  24.         call UnitRemoveAbility( damto, 'Amrf' )
  25.         call FlushChildHashtable(ht1,GetHandleId(GetExpiredTimer()))
  26.         call DestroyTimer(GetExpiredTimer())
  27.     else
  28.          //高度变化,依据自由落体公式并进行相对计算,避免多个跳跃同时进行造成的高度摇摆
  29.         if ((GetUnitFlyHeight( damto) >= GetUnitDefaultFlyHeight(damto)) and (GetUnitFlyHeight(damto) <= 500.00)) then
  30.             if ( timeindex <= (time / 2 )) then
  31.             call SetUnitFlyHeight( damto, ( GetUnitFlyHeight(damto) + ( 2*high *I2R(timeindex )/(I2R(time)*I2R(time)))) , 0.00 )
  32.             else
  33.             call SetUnitFlyHeight( damto, ( GetUnitFlyHeight(damto) - ( 2*high *(I2R(time) - I2R(timeindex) )/(I2R(time)*I2R(time)))) , 0.00 )
  34.             endif
  35.         endif
  36.         //位移变化,同样采用相对位移计算,所以支持路径合成,并进行了可通行检测。
  37.         if ((IsTerrainPathable(( GetUnitX(damto) + ( steplong * CosBJ(angle) ) ), ( GetUnitY(damto) + ( steplong * SinBJ(angle) ) ), PATHING_TYPE_WALKABILITY) == false)) then
  38.             call SetUnitX( damto,x)
  39.             call SetUnitY( damto,y)
  40.            //高度小于120时破坏树木和水中特效
  41.             if ((GetUnitFlyHeight(damto) < 120.00)) then
  42.                 //破坏树木
  43.                  set p = GetUnitLoc(damto)
  44.                  call EnumDestructablesInCircleBJ( 40.00, p , function KillLivingTrees )
  45.                  call RemoveLocation( p )
  46.                  set p = null
  47.                  //高度小于10时水中显示水波
  48.                  if ((GetUnitFlyHeight(damto) < 10.00) and (IsTerrainPathable(GetUnitX(damto), GetUnitY(damto), PATHING_TYPE_FLOATABILITY) == false)) then
  49.                  call DestroyEffect( AddSpecialEffectTarget("Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl", damto, "origin") )
  50.                  endif   
  51.              endif
  52.         endif
  53.     call SaveInteger(ht1, GetHandleId(GetExpiredTimer()),StringHash("timeindex"), ( timeindex + 1 ))
  54.     endif
  55.     set damto = null
  56.     set steplong = 0
  57.     set high = 0
  58.     set timeindex = 0
  59.     set angle = 0
  60.     set x = 0
  61.     set y = 0
  62.     set time = 0
  63. endfunction
  64. //主体函数
  65. function PasJmp takes unit damfrom,unit damto,real dam,boolean ifdam ,boolean ifjmp returns nothing
  66.     local timer jmptimer=CreateTimer()
  67.     call PauseUnit(damto,true)
  68.     call SetUnitAnimation( damto , "death" )
  69.     call SaveUnitHandle( ht1, GetHandleId( jmptimer ), StringHash("damto"), damto)
  70.     call SaveReal(ht1, GetHandleId( jmptimer ),  StringHash("angle"), Atan2BJ((GetUnitY(damto) - GetUnitY(damfrom)),( GetUnitX(damto) - GetUnitX(damfrom) )))
  71.     if (ifdam == true) then
  72.     call UnitDamageTarget( damfrom, damto, dam, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_METAL_HEAVY_SLICE )
  73.         endif
  74.     if (ifjmp == true) then
  75.         call UnitAddAbility( damto, 'Amrf' )
  76.         call SaveReal(ht1, GetHandleId( jmptimer ), StringHash("high"), ( 130.00 + ( dam / 5.00 ) ))
  77.     else
  78.         call SaveReal(ht1, GetHandleId( jmptimer ),StringHash("high"), 0 )
  79.     endif
  80.     call SaveInteger(ht1, GetHandleId(jmptimer),StringHash("timeindex"), 1 )
  81.     call SaveReal(ht1, GetHandleId(jmptimer),StringHash("steplong"), ( 15.00 + ( dam / 50.00 ) ))
  82.     call SaveInteger(ht1, GetHandleId(jmptimer),StringHash("time"), ( 11 + R2I(( dam / 10.00 )) ))
  83.     call TimerStart(jmptimer, 0.02, true, function PasJmpTimerFunc)
  84.     set jmptimer = null
  85.    
  86. endfunction
  87.   
复制代码
发表于 2012-2-6 01:13:11 | 显示全部楼层
WE的代码区无法写globals

使用“变量编辑器”来创建全局变量吧……
回复

使用道具 举报

发表于 2012-2-6 01:20:46 | 显示全部楼层
所以说在弄清原版WE运作之前,最好不要使用扩展性质工具。
不然在你用回原版之后,你会发现还要重新开始学……

NEWGEN,YDWE等等扩展WE都支持直接在任何地方写全局变量的定义。
猜测楼主是不是用惯了哪些扩展工具,所以……

好吧,上面都是牢骚,可以无视之……
回复

使用道具 举报

发表于 2012-2-7 15:42:00 | 显示全部楼层
这个完全可以自己改
创建一个全局变量ht1
删除globals内容
在调用前用T添加一个初始化hashtable的喊声然后设置udg_ht1等于最后创建的hashtable
最后将代码中的ht1替换成udg_ht1
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-5-2 17:45 , Processed in 0.033669 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表