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

ForGroup 这么写有后遗症没?

[复制链接]
发表于 2008-7-1 21:17:35 | 显示全部楼层 |阅读模式
[jass]
function For_func takes nothing returns nothing
local unit u = GetEnumUnit()
set udg_count=udg_count+1
if GetUnitState(u,UNIT_STATE_LIFE)<0.01 then
call DisplayTimedTextToPlayer(GetOwningPlayer(u),0,0,0.75,"挂掉了")
endif
if IsUnitEnemy(u,GetOwningPlayer(udg_u))==false then
call DisplayTimedTextToPlayer(GetOwningPlayer(u),0,0,0.75,"叛逆了")
endif
set u = null
endfunction

function Time_func takes nothing returns nothing
local integer ih = h2i(GetExpiredTimer())
set udg_u=i2u(GetStoredInteger(udg_gc,I2S(ih),"u"))
set udg_g=i2g(GetStoredInteger(udg_gc,I2S(ih),"g"))
set udg_count=0
call ForGroup(udg_g,function For_func)
if udg_count<=0 then
call DestroyGroup(udg_g)
call PauseTimer(i2t(ih))
call FlushStoredMission(udg_gc,I2S(ih))
call DestroyTimer(i2t(ih))
call DisplayTimedTextToPlayer(GetOwningPlayer(udg_u),0,0,0.75,"终于退出了判断")
endif
endfunction

function Filter_func takes nothing returns nothing
local unit u = GetFilterUnit()
local integer ih = h2i(u)
if GetUnitState(u,UNIT_STATE_LIFE)>0.01 and IsUnitEnemy(u,GetOwningPlayer(udg_u))==true then
set udg_count=udg_count+1
call GroupAddUnit(udg_g,u)
else
call GroupRemoveUnit(udg_g,u)
endif
set u = null
endfunction

function test takes unit u returns nothing
local timer t = CreateTimer()
local integer ih = h2i(t)
//call StoreInteger(udg_gc,I2S(ih),"u",h2i(u))//写错地方。
//call StoreInteger(udg_gc,I2S(ih),"g",h2i(udg_g))//写错地方。
set udg_count=0
set udg_u=u
set udg_g=CreateGroup()
call GroupEnumUnitsInRange(udg_g,0,0,99999,Condition(function Filter_func))
if udg_count>0 then
call StoreInteger(udg_gc,I2S(ih),"u",h2i(u))//这才对了
call StoreInteger(udg_gc,I2S(ih),"g",h2i(udg_g))//这才对了
call TimerStart(t,0.25,true,function Time_func)
else
call DisplayTimedTextToPlayer(GetOwningPlayer(u),0,0,0.75,"没有匹配的单位")
endif
set t = null
endfunction
[/jass]

主要是Filter_func 那段不知道会留下什么问题么?
发表于 2008-7-1 22:40:25 | 显示全部楼层
我倒是感觉For_func 和Time_func  有问题

Time_func  中  udg_count不要清零
For_func 中   udg_count=udg_count+1 去掉
              同时 在两个if 判断语句中同时加入  set  udg_count=udg_count-1

就是判断g中的所有单位  要么是被杀死 或者 要么是被召唤以后    销毁计时器
不知道有没有理解错?

还有 g是全局变量  没必要用缓存传递吧
回复

使用道具 举报

 楼主| 发表于 2008-7-2 10:17:06 | 显示全部楼层
Time_func  中  udg_count不要清零 独立的计时器,多个不冲突啊= =
For_func 中  udg_count=udg_count+1 去掉 这个无所谓了,看自己爱好

For_func  少写了一个GroupRemoveUnit写了一个
写了一个群体心灵控制了为了不冲突
udg_u udg_count udg_g 都是用来 传递的,一般都使用局部。

[jass]
function Trig_Skill_C2_Conditions takes nothing returns boolean
    return GetSpellAbilityId()=='A00J'
endfunction

function Skill_C2_g3_func takes nothing returns nothing
local unit u = GetFilterUnit()
if IsUnitType(u,UNIT_TYPE_GIANT)==false and IsUnitType(u,UNIT_TYPE_STRUCTURE)==false and IsUnitType(u,UNIT_TYPE_MECHANICAL)==false and IsUnitType(u,UNIT_TYPE_ANCIENT)==false and IsUnitType(u,UNIT_TYPE_MAGIC_IMMUNE)==false and GetUnitState(u,UNIT_STATE_LIFE)>0.01 and IsUnitEnemy(u,GetOwningPlayer(udg_u))==true then
set udg_e = AddSpecialEffectTarget("Abilities\\\\Spells\\\\Undead\\\\DeathandDecay\\\\DeathandDecayDamage.mdl",u,"chest")
set udg_time = 2
call ExecuteFunc("ESD")
call UnitDamageTarget(udg_u,u,udg_damage,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
endif
set u = null
endfunction

function Skill_C2_g2_func takes nothing returns nothing
local unit u = GetEnumUnit()
local integer ih
local real x
local real y
local group g
set udg_count=udg_count+1
if GetUnitAbilityLevel(u,'B002')<=0 then
call GroupRemoveUnit(udg_g,u)
set ih = h2i(u)
if GetUnitState(u,UNIT_STATE_LIFE)>0.01 then
call SetUnitOwner(u,i2pr(GetStoredInteger(udg_gc,I2S(ih),"HeiAnZhuanHuan_Pra")),true)
else
set x = GetUnitX(u)
set y = GetUnitY(u)
call DestroyEffect(AddSpecialEffect("Objects\\\\Spawnmodels\\\\Undead\\\\UndeadDissipate\\\\UndeadDissipate.mdl",x,y))
set udg_u = CreateUnit(i2pr(GetStoredInteger(udg_gc,I2S(ih),"HeiAnZhuanHuan_Prb")),'e000',x,y,0)
set g = CreateGroup()
call GroupEnumUnitsInRange(g,x,y,150,Condition(function Skill_C2_g3_func))
call DestroyGroup(g)
call UnitApplyTimedLife(udg_u,'BHwe',0.50)
endif
call FlushStoredInteger(udg_gc,I2S(ih),"HeiAnZhuanHuan_Pra")
call FlushStoredInteger(udg_gc,I2S(ih),"HeiAnZhuanHuan_Prb")
endif
set u = null
set g = null
endfunction

function Skill_C2_t_func takes nothing returns nothing
local integer ih = h2i(GetExpiredTimer())
local group g = i2g(GetStoredInteger(udg_gc,I2S(ih),"g"))
set udg_damage = GetStoredReal(udg_gc,I2S(ih),"damage")
set udg_count=0
set udg_g = g
call ForGroup(g,function Skill_C2_g2_func)
call DisplayTimedTextToPlayer(Player(0),0,0,0.75,I2S(udg_count))
if udg_count<=0 then
call DestroyGroup(g)
call PauseTimer(i2t(ih))
call FlushStoredMission(udg_gc,I2S(ih))
call DestroyTimer(i2t(ih))
endif
set g = null
endfunction

function Skill_C2_g1_func takes nothing returns nothing
local unit u = GetFilterUnit()
local integer ih = h2i(u)
if IsUnitType(u,UNIT_TYPE_GIANT)==false and IsUnitType(u,UNIT_TYPE_STRUCTURE)==false and IsUnitType(u,UNIT_TYPE_MECHANICAL)==false and IsUnitType(u,UNIT_TYPE_ANCIENT)==false and IsUnitType(u,UNIT_TYPE_MAGIC_IMMUNE)==false and GetUnitState(u,UNIT_STATE_LIFE)>0.01 and GetStoredInteger(udg_gc,I2S(ih),"HeiAnZhuanHuan_Pra")<=0 and IsUnitEnemy(u,GetOwningPlayer(udg_u))==true then
set udg_e = AddSpecialEffectTarget("Abilities\\\\Spells\\\\Items\\\\AIil\\\\AIilTarget.mdl",u,"origin")
set udg_time = 2
call ExecuteFunc("ESD")
call SetUnitX(udg_u,GetUnitX(u))
call SetUnitY(udg_u,GetUnitY(u))
call IssueTargetOrderById(udg_u,852560,u)
call StoreInteger(udg_gc,I2S(ih),"HeiAnZhuanHuan_Pra",h2i(GetOwningPlayer(u)))
call StoreInteger(udg_gc,I2S(ih),"HeiAnZhuanHuan_Prb",h2i(GetOwningPlayer(udg_u)))
call SetUnitOwner(u,GetOwningPlayer(udg_u),true)
set udg_count = udg_count+1
call GroupAddUnit(udg_g,u)
else
call GroupRemoveUnit(udg_g,u)
endif
set u = null
endfunction

function Trig_Skill_C2_Actions takes nothing returns nothing
local unit ua = GetTriggerUnit()
local location p = GetSpellTargetLoc()
local unit ub = CreateUnitAtLoc(GetOwningPlayer(ua),'e000',p,0)
local group g = CreateGroup()
local timer t = CreateTimer()
local integer ih = h2i(t)
call UnitAddAbility(ub,'A00K')
call SetUnitAbilityLevel(ub,'A00K',GetUnitAbilityLevel(ua,'A00J'))
set udg_u = ub
set udg_count=0
set udg_g = g
call GroupEnumUnitsInRange(g,GetLocationX(p),GetLocationY(p),150,Condition(function Skill_C2_g1_func))
if udg_count>0 then
call StoreInteger(udg_gc,I2S(ih),"g",h2i(g))
call StoreReal(udg_gc,I2S(ih),"damage",GetUnitAbilityLevel(ua,'A00J')*50)
call TimerStart(t,0.25,true,function Skill_C2_t_func)
else
call DestroyGroup(g)
call DestroyTimer(t)
endif
call UnitApplyTimedLife(ub,'BHwe',0.50)
call RemoveLocation(p)
set ua = null
set ub = null
set g = null
set p = null
set t = null
endfunction

//===========================================================================
function InitTrig_Skill_C2 takes nothing returns nothing
    set gg_trg_Skill_C2 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Skill_C2, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Skill_C2, Condition( function Trig_Skill_C2_Conditions ) )
    call TriggerAddAction( gg_trg_Skill_C2, function Trig_Skill_C2_Actions )
endfunction
[/jass]
回复

使用道具 举报

发表于 2008-7-14 13:17:59 | 显示全部楼层
[codes=jass]2楼太强了!!!
提醒下
ForGroup是不能消除boolexpr的哦!![/codes]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-24 07:25 , Processed in 0.034135 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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