找回密码
 点一下
查看: 5300|回复: 5

群体技能函数

[复制链接]
发表于 2007-10-12 17:12:59 | 显示全部楼层 |阅读模式
  1.     function Multi_Targets_Spell takes unit speller, integer spellId, unit target, integer dummyspellId, real radius, real delay returns nothing
  2.         local group g = CreateGroup()
  3.         local integer f = 0
  4.         local integer fend
  5.         local unit u
  6.         local unit array tg
  7.         local unit array sp
  8.         local real ox = GetUnitX( speller )
  9.         local real oy = GetUnitY( speller )
  10.         local real tx = GetUnitX( target )
  11.         local real ty = GetUnitY( target )
  12.         local integer order = GetUnitCurrentOrder( speller )
  13.         local player who = GetOwningPlayer( speller )
  14.         local boolean isEnemy = IsUnitEnemy( target, who )
  15.         call IssueTargetOrderById( speller, order, target)
  16.         call GroupEnumUnitsInRange( g, tx, ty, radius, null )
  17.         loop
  18.             set u = FirstOfGroup( g )
  19.             exitwhen u == null
  20.             if ( IsUnitEnemy( u, who ) == isEnemy and u != target and GetUnitAbilityLevel( u, 'Aloc' ) <= 0 and GetUnitAbilityLevel( GetFilterUnit(), 'Bvul' ) <= 0 and GetUnitAbilityLevel( u, 'BHds' ) <= 0 and not( GetUnitState( u, UNIT_STATE_LIFE ) <= 0.0 )) then
  21.                 set tg[f] = u
  22.                 set sp[f] = CreateUnit( who, DummyU(), ox, oy, 0.0 )
  23.                 call UnitAddAbility( sp[f], dummyspellId )
  24.                 call SetUnitAbilityLevel( sp[f], dummyspellId, GetUnitAbilityLevel( speller, spellId ))
  25.                 call UnitApplyTimedLife( sp[f], 'BTLF', 10.00 )
  26.                 set f = f + 1
  27.             endif
  28.             call GroupRemoveUnit( g, u )
  29.         endloop
  30.         set fend = f
  31.         if ( delay > 0.1 ) then
  32.             call TriggerSleepAction( delay )
  33.         endif
  34.         set f = 1
  35.         loop
  36.             exitwhen f > fend
  37.             if ( tg[f] != null ) then
  38.                 call IssueTargetOrderById( sp[f], order, tg[f] )
  39.                 set sp[f] = null
  40.                 set tg[f] = null
  41.             endif
  42.             set f = f + 1
  43.         endloop
  44.         call DestroyGroup( g )
  45.         set g = null
  46.     endfunction
复制代码


用法:
以群体风暴之锤为例子
  1. Storm bolt
  2.     Events
  3.         Unit - A unit Begins casting an ability
  4.     Conditions
  5.         (Ability being cast) Equal to Storm Bolt
  6.     Actions
  7.         Custom script:   call Multi_Targets_Spell(GetTriggerUnit(),GetSpellAbilityId(),GetSpellTargetUnit(),[color=#FF0000]'A00B'[/color],[color=#66FF00]300.0,0.25[/color] )
复制代码
其中红色是辅助技能的代码,绿色部分,300.0是影响范围,0.25是延迟(辅助单位必须本身没有延迟,函数中的延迟才能准确)。
发表于 2008-7-2 21:41:56 | 显示全部楼层
请问DummyU()是什么部队阿 还有请问发动的群体技能是不是原先SPELLER发的技能阿
回复

使用道具 举报

发表于 2008-7-12 11:39:44 | 显示全部楼层
DummyU()   应该是个常函数
返回值是辅助单位的id

发动的群体技能不是原先SPELLER发的技能
最多是由同一个基础技能改的
回复

使用道具 举报

发表于 2009-1-22 11:46:27 | 显示全部楼层
想问一下LZ,
把动作放进选取单位的条件里比较好还是你现在的比较好。
回复

使用道具 举报

发表于 2009-1-22 16:00:36 | 显示全部楼层
原来loop比选取单位组中单位做动作好啊~
回复

使用道具 举报

发表于 2009-2-12 18:50:14 | 显示全部楼层
我记得有个函数方法,可以取代loop
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-22 19:02 , Processed in 0.089842 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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