|
发表于 2012-9-11 16:43:58
|
显示全部楼层
[jass]
globals
unit g_Unit = null
endglobals
function GroupFunc takes nothing returns nothing
if (IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(g_Unit)) == true and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) >= 0.405) then
call KillUnit(GetFilterUnit())
endif
endfunction
function tb takes nothing returns nothing
local unit bolt = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()),"u001",GetUnitLoc(GetTriggerUnit()),0)
set g_Unit = bolt
call GroupEnumUnitsInRange(udg_tempgroup,GetUnitX(caster),GetUnitY(caster),200,Condition(function GroupFunc))
endfunction[/jass]
如果不想多弄个全局可以这么写:
[jass]
function GroupFunc takes nothing returns nothing
if (IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(bj_lastCreatedUnit)) == true and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) >= 0.405) then
call KillUnit(GetFilterUnit())
endif
endfunction
function tb takes nothing returns nothing
local unit bolt = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()),"u001",GetUnitLoc(GetTriggerUnit()),0)
set bj_lastCreatedUnit = bolt
call GroupEnumUnitsInRange(udg_tempgroup,GetUnitX(caster),GetUnitY(caster),200,Condition(function GroupFunc))
endfunction[/jass]
当然如果这个bolt不需要在等待或计时器后仍旧能用话直接set g_Unit = CreateUnit( …… )
用哈希表的方法如下:
[jass]
globals
hashtable g_HT = InitHashtable()
endglobals
function GroupFunc takes nothing returns nothing
if (IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(LoadUnitHandle(g_HT, StringHash("这里用唯一的字符串"), 0))) == true and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) >= 0.405) then
call KillUnit(GetFilterUnit())
endif
endfunction
function tb takes nothing returns nothing
local unit bolt = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()),"u001",GetUnitLoc(GetTriggerUnit()),0)
local integer pkey = StringHash("这里用唯一的字符串")
call SaveUnitHandle( g_HT, pkey, 0, bolt )
call GroupEnumUnitsInRange(udg_tempgroup,GetUnitX(caster),GetUnitY(caster),200,Condition(function GroupFunc))
call RemoveSavedHandle( g_HT, pkey, 0 )
endfunction[/jass]
话说我不是在JASS区回复你了嘛。。。
还有标签不要用code,那个没高亮,用jass |
|