找回密码
 点一下
查看: 2083|回复: 20

请高手指教下,单位组伤害,能不能带入带出参数(用J写)

[复制链接]
发表于 2008-3-10 18:57:27 | 显示全部楼层 |阅读模式
RT
主是我想让
call ForGroupBJ( unit02, function Trig_xjh03_Func021A )


function Trig_xjh03_Func021A takes unit china returns real
    local real int
    local unit china
    set china = GetTriggerUnit()
    if ( Trig_xjh03_Func021Func001C() ) then
        set int = ( ( I2R(GetHeroAgi(china, true)) / 100.00 ) + 1.00 )
    else
        set int = 1.00
    endif
    set china = null
    return int
endfunction

带入参数和带出参数
发表于 2008-3-10 18:58:35 | 显示全部楼层
不能带参数,必须用其他方法保存(全局变量或者缓存)
回复

使用道具 举报

 楼主| 发表于 2008-3-10 18:59:07 | 显示全部楼层
猪头大哥用缓存帮我搞下了
回复

使用道具 举报

发表于 2008-3-10 19:03:04 | 显示全部楼层
啊呀呀………………

参考一下
回复

使用道具 举报

 楼主| 发表于 2008-3-10 19:06:59 | 显示全部楼层
猪头大哥,那个完全不对呀,我要是用缓存解决,不是对全局变量呀
回复

使用道具 举报

发表于 2008-3-10 19:13:27 | 显示全部楼层
不好意思,前面跟同学扯昏掉了………………

我说的不能带参数是指这个函数的codeback不能带参数,但是可以把触发的数据带入的,嗯
回复

使用道具 举报

 楼主| 发表于 2008-3-10 19:14:37 | 显示全部楼层
帮我改一改,没懂你的意思
回复

使用道具 举报

发表于 2008-3-10 19:20:06 | 显示全部楼层
我也没理解你的意思呀………………

能把要求详细的说一遍吗??
回复

使用道具 举报

 楼主| 发表于 2008-3-10 19:21:58 | 显示全部楼层
就是上面的一个调用,一个函数实体,我要在调用时带入单位局部变量CHINA,在函数执行完后,要带出实数局部变量INT
回复

使用道具 举报

发表于 2008-3-10 19:27:19 | 显示全部楼层
你把整个触发的代码都发上来看下吧,否则很难说清楚的
回复

使用道具 举报

 楼主| 发表于 2008-3-10 19:29:01 | 显示全部楼层
function Trig_xjh03_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A004' ) ) then
        return false
    endif
    return true
endfunction

function Trig_xjh03_Func005Func001C takes nothing returns boolean
    if ( not ( UnitHasBuffBJ(GetTriggerUnit(), 'B000') == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_xjh03_Func021A takes unit china returns real
    local real int
    local unit china
    set china = GetTriggerUnit()
    if ( Trig_xjh03_Func021Func001C() ) then
        set int = ( ( I2R(GetHeroAgi(china, true)) / 100.00 ) + 1.00 )
    else
        set int = 1.00
    endif
    set china = null
    return int
endfunction

function Trig_xjh03_Actions takes nothing returns nothing
    local unit china
    local location array unit01
    local location ti]
    local integer int01
    local integer exp
    local effect array look
    local lightning array look01
    local group unit02
    set china = GetTriggerUnit()
    set ti = GetUnitLoc(GetTriggerUnit())
    set unit02 = GetUnitsInRangeOfLocAll(400.00, ti)
    call ForGroupBJ( unit02, function Trig_xjh03_Func021A )
    call UnitDamagePointLoc( china, 0.20, 400.00, ti, ( ( I2R(GetHeroAgi(china, true)) * 2.00 ) * int ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
    set exp = 1
    set int01 = 0
    loop
        exitwhen exp > 12
        set unit01[exp] = PolarProjectionBJ(ti, 450.00, int01)
        set unit01[( exp + 12 )] = PolarProjectionBJ(ti, 200.00, int01)
        set int01 = ( int01 + 30.00 )
        set exp = exp + 1
    endloop
    set unit01[25] = ti
    set exp = 1
    set exp = 1
    loop
        exitwhen exp > 12
        call AddSpecialEffectLocBJ( unit01[exp], "Objects\\\\Spawnmodels\\\\Undead\\\\UDeathSmall\\\\UDeathSmall.mdl" )
        set look[exp] = bj_lastCreatedEffect
        call AddSpecialEffectLocBJ( unit01[( exp + 12 )], "Objects\\\\Spawnmodels\\\\Undead\\\\UndeadDissipate\\\\UndeadDissipate.mdl" )
        set look[( exp + 12 )] = bj_lastCreatedEffect
        call AddSpecialEffectLocBJ( unit01[( exp + 12 )], "Abilities\\\\Spells\\\\Undead\\\\DeathPact\\\\DeathPactTarget.mdl" )
        set look[( exp + 25 )] = bj_lastCreatedEffect
        set exp = exp + 1
    endloop
    call AddSpecialEffectLocBJ( unit01[25], "Abilities\\\\Spells\\\\Human\\\\Resurrect\\\\ResurrectCaster.mdl" )
    set look[25] = bj_lastCreatedEffect
    call PolledWait( 0.15 )
    set exp = 1
    set exp = 1
    loop
        exitwhen exp > 11
        call AddLightningLoc( "FORK", unit01[exp], unit01[( exp + 1 )] )
        set look01[exp] = bj_lastCreatedLightning
        set exp = exp + 1
    endloop
    call AddLightningLoc( "FORK", unit01[12], unit01[1] )
    set look01[12] = bj_lastCreatedLightning
    call PolledWait( 1.50 )
    set exp = 1
    set exp = 1
    loop
        exitwhen exp > 25
        call RemoveLocation( unit01[exp] )
        set exp = exp + 1
    endloop
    set exp = 1
    set exp = 1
    loop
        exitwhen exp > 37
        call DestroyEffect( look[exp] )
        set exp = exp + 1
    endloop
    set exp = 1
    set exp = 1
    loop
        exitwhen exp > 12
        call DestroyLightning( look01[exp] )
        set exp = exp + 1
    endloop
    call RemoveLocation( ti )
    call GroupClear( unit02 )
    call DestroyGroup( unit02 )
    set int = 0.00
    set exp = 0
    set china = null
endfunction

//===========================================================================
function InitTrig_xjh03 takes nothing returns nothing
    set gg_trg_xjh03 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_xjh03, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_xjh03, Condition( function Trig_xjh03_Conditions ) )
    call TriggerAddAction( gg_trg_xjh03, function Trig_xjh03_Actions )
endfunction
回复

使用道具 举报

 楼主| 发表于 2008-3-10 19:30:27 | 显示全部楼层
代码有些乱,因为想不出,就没去整理
回复

使用道具 举报

发表于 2008-3-10 19:36:54 | 显示全部楼层
额,改之前先问下………………

那个ForGroup调用的函数为什么和group里的单位没有任何关系呢………………
回复

使用道具 举报

 楼主| 发表于 2008-3-10 19:38:39 | 显示全部楼层
local group unit02
    set china = GetTriggerUnit()
    set ti = GetUnitLoc(GetTriggerUnit())
    set unit02 = GetUnitsInRangeOfLocAll(400.00, ti)
    call ForGroupBJ( unit02, function Trig_xjh03_Func021A )
对的呀,先定义局部单位组
再定义单位组的单位是哪些
再做动作,有什么问题
回复

使用道具 举报

发表于 2008-3-10 19:50:40 | 显示全部楼层
我只是觉得这里完全没有必要用ForGroup
ForGroup函数是枚举group内单位做动作,而你在那个函数里的单位却只是触发单位,仅此而已………………
回复

使用道具 举报

 楼主| 发表于 2008-3-10 19:53:05 | 显示全部楼层
这本身是个群伤技能,我本来是把伤害部份放下面的,先做效果,但是伤害部份做的我头大,所以把伤害部份提上来了
回复

使用道具 举报

发表于 2008-3-10 19:54:36 | 显示全部楼层
你这个伤害部分明显会对友军也造成伤害的嘛
回复

使用道具 举报

 楼主| 发表于 2008-3-10 19:56:08 | 显示全部楼层
不好意思,不会的

麻烦猪头大哥敢紧帮我解决了吧,头大了
回复

使用道具 举报

发表于 2008-3-10 20:04:53 | 显示全部楼层
呵呵,那就试试吧

首先要定义一个全局变量缓存udg_gc,在初始化的时候se udg_gc = InitGameCache("w3gc.w3v")

要有自定义函数H2I()
function H2I takes handle h returns integer
    return h
    return 0
endfunction

把Trig_xjh03_Func021A函数的返回值类型改为null,删掉return int,添加call StoreReal(udg_gc, I2S(H2I(china)), "int", int)

在Trig_xjh03_Actions函数开始的地方声明local real int,在ForGroup之后添加set int = GetStoredReal(udg_gc, I2S(H2I(china)), "int")
回复

使用道具 举报

 楼主| 发表于 2008-3-11 19:20:30 | 显示全部楼层
猪头大哥,你写的东西能解释下不,也让我们用了,知道是怎么用的
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-7-9 00:06 , Processed in 0.031803 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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