找回密码
 点一下
查看: 706|回复: 4

如何实现停止任何生命回复效果

[复制链接]
发表于 2012-3-8 19:46:55 | 显示全部楼层 |阅读模式
我想做出的效果是这样的:
使周围的地方单位在一定时间内停止任何生命回复,并将原本的生命回复数值给予施法者。

但是前一半就出问题了,不知道这段代码有什么问题
[jass]

globals
    hashtable UnitHashtable  
endglobals

function BloodFrost_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == 'A000')
endfunction

function BloodFrost_Actions3 takes nothing returns nothing
    local real UnitLife0=LoadReal(UnitHashtable,GetHandleId(GetEnumUnit()),1)
    local real UnitLife1=GetUnitState(GetEnumUnit(),UNIT_STATE_LIFE)
    if UnitHasBuffBJ(GetEnumUnit(), 'B000') == true then
        if UnitLife1>=UnitLife0 then
            call SetUnitState(GetEnumUnit(),UNIT_STATE_LIFE,UnitLife0)
        else
            call SaveReal(UnitHashtable,GetHandleId(GetEnumUnit()),1,UnitLife1)
        endif
    endif
endfunction

function BloodFrost_Actions2 takes nothing returns nothing
    local timer t = CreateTimer()
    if UnitHasBuffBJ(GetEnumUnit(), 'B000') == true then
        call SaveReal(UnitHashtable,GetHandleId(GetEnumUnit()),1,GetUnitState(GetEnumUnit(),UNIT_STATE_LIFE))
        call TimerStart(t, 0.01,true,function BloodFrost_Actions3)
    endif
    set t = null
endfunction

function BloodFrost_Actions takes nothing returns nothing
    call ForGroup(GetUnitsInRangeOfLocAll(600.00, GetUnitLoc(GetTriggerUnit())),function BloodFrost_Actions2)
endfunction

function InitTrig_BloodFrost takes nothing returns nothing
    local trigger BloodFrost=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(BloodFrost,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(BloodFrost,Condition(function BloodFrost_Conditions))
    call TriggerAddAction(BloodFrost,function BloodFrost_Actions)
    set BloodFrost=null
endfunction
[/jass]
发表于 2012-3-8 22:20:46 | 显示全部楼层
其实看见第一印象就是计时器设置单位的生命值。。。。。。
回复

使用道具 举报

 楼主| 发表于 2012-3-8 22:38:45 | 显示全部楼层

回 xu695622238 的帖子

xu695622238:其实看见第一印象就是计时器设置单位的生命值。。。。。。 (2012-03-08 22:20) 
是啊,就是这样做的,但是没效果。。难道是哈希表存数据的时候出问题了?之前加Debug测试的时候貌似是Actions2里没有反应
回复

使用道具 举报

发表于 2012-3-8 23:21:02 | 显示全部楼层
UnitHashtable没有初始化
另外GetUnitLoc会创建点,没有排泄
GetUnitsInRangeOfLocAll不仅效率低还会创建单位组,也没排泄
回复

使用道具 举报

 楼主| 发表于 2012-3-9 00:19:04 | 显示全部楼层

回 chyj4747 的帖子

chyj4747:UnitHashtable没有初始化
另外GetUnitLoc会创建点,没有排泄
GetUnitsInRangeOfLocAll不仅效率低还会创建单位组,也没排泄
 (2012-03-08 23:21) 
原来学的这么不扎实。。。了解了。。谢谢鸟~
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-10-6 11:52 , Processed in 0.033016 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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