找回密码
 点一下
查看: 5899|回复: 13

近于完美的被动技能(致命一击)的跟踪演示

[复制链接]
发表于 2006-5-30 20:26:35 | 显示全部楼层 |阅读模式
这是使用WE TRIGGER的方法,需要使用WAIT

另外,不需要使用WAIT的纯JASS解决方案请见7楼RED_WOLF提供的好方法。

思路是给致命一击 加个目标BUFF, 然后跟踪被攻击的目标的BUFF

不足之处就是要使用wait

注意演示中致命一击相关的技能设置(包括物品的致命一击)--增加了致命一击技能的魔法特效(buff),只用于辅助判断,无实际作用。
怎么跟踪被攻击的目标的BUFF要用等待WAIT????很是郁闷!!!!

------------------------------------------
更完美但复杂的解决办法是跟踪所造成的伤害,
这种办法是100%可以跟踪到致命一击的概率,就是比较基础伤害和实际伤害,但因为RPG系统装备是可以+伤害的,所以每加一个物品或英雄升级,都要跟踪。这便造成做出的演示没有可移植性。

当然,可以用复制单位的方法来做,就是让复制单位(隐形)攻击一个目标得到基础伤害,这办法也很复杂。
------------------------------------------

在条件里应该增加被动技能(致命一击)类的判断,包括物品类的致命一击技能,避免因目标BUFF持续期间由于其他持续技能造成的伤害而误判(如攻击单位同时释放蝗虫群的技能)。

通过这测试,观察在屏幕中的数字,是不是在致命一击后必然有个伤害为0的数字??这是一个跟踪响应致命一击的更好方法!!!

另外在致命一击的机会很高的而且攻击速度很快的时候,被攻击目标有可能没有机会来反击的!!!这跟动画损伤点有关

攻击速度跟敏捷有关,当然也跟+速物品有关,这里realoffset用于WAIT TIME的衰减,以便于更快的响应。realoffset用于WAIT的时间衰减。
计算realoffset公式有3个常数:
    一个是0.02,是指游戏平衡常数里的每点敏捷增加速度;
    一个是1.77,是这个演示里面剑圣单位的默认攻击速度,即是攻击一的魔法施放时间间隔。
    另一个是除以200,敏捷大概200就达到最高攻击速度了(使用以上2个默认值)
但好像产生可以探测到的BUFF时间有个最低值,这里设置最低为0.06,就是说1秒最多16次的攻击(据说)

感谢有关人员对攻击速度影响因素的研究。

[trigger]Critical slam
    事件
        单位 - A unit 被攻击的
    环境
    动作
        -------- 在条件里应该增加被动技能(致命一击)类的判断,包括物品类的致命一击技能 --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - 环境
                Or - Any (Conditions) are true
                    环境
                        (Level of 致命一击 (改--------------) for (Attacking unit)) 大于 0
                        ((Attacking unit) has an item of type 灼热之刀) 等于 TRUE
            Then - 动作
                -------- 攻击速度跟敏捷有关,当然也跟+速物品有关,这里用于WAIT TIME的衰减 --------
                Set realoffset = (((((Real((敏捷 of (Attacking unit) (包括 bonuses)))) x 0.02) + 1.00) x 1.77) / 200.00)
                Set realoffset = (0.20 - realoffset)
                -------- 设置等待时间的最小值 --------
                If (realoffset 小于 0.06) then do (Set realoffset = 0.06) else do (Do nothing)
                -------- 必须有等待语句(郁闷啊,为什么???blizzard!!!) --------
                Wait realoffset seconds
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - 环境
                        ((Attacked unit) has buff 致命一击 改 ---------------) 等于 TRUE
                    Then - 动作
                        -------- 必须移掉造成的BUFF,为下一次攻击的跟踪做准备 --------
                        单位 - Remove 致命一击 改 --------------- buff from (Attacked unit)
                        -------- 可以不要,为了显示而已 --------
                        游戏 - Display to (All players) the text: (|c00FF0303致命一击:   + ((String(realtmp)) + |r))
                        -------- 以下可以加你自己的响应代码了 --------
                        --------    --------
                    Else - 动作
            Else - 动作[/trigger]


用以上WE TRIGGER便可以响应致命一击了。对于此种方法,以下JASS代码都不是必须的,增加伤害跟踪仅仅是为了显示跟踪过程而已
[jass]//===========================================================================
//别人的JASS函数,实用公共函数,很多JASS作的系统都会有这函数群
//如果你图中已经有了这些函数,便不要移植
//原文:http://www.wc3jass.com/viewtopic.php?t=2608
//===========================================================================
function H2I takes handle h returns integer
    return h
    return 0
endfunction

// ===========================
function LocalVars takes nothing returns gamecache
    // Replace InitGameCache("jasslocalvars.w3v") with a global variable!!
    return InitGameCache("jasslocalvars.w3v")
endfunction

function SetHandleHandle takes handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value))
    endif
endfunction

function SetHandleInt takes handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleBoolean takes handle subject, string name, boolean value returns nothing
    if value==false then
        call FlushStoredBoolean(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleReal takes handle subject, string name, real value returns nothing
    if value==0 then
        call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleString takes handle subject, string name, string value returns nothing
    if value==null then
        call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function GetHandleHandle takes handle subject, string name returns handle
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleBoolean takes handle subject, string name returns boolean
    return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleReal takes handle subject, string name returns real
    return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleString takes handle subject, string name returns string
    return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction

function GetHandleUnit takes handle subject, string name returns unit
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTimer takes handle subject, string name returns timer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTrigger takes handle subject, string name returns trigger
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleEffect takes handle subject, string name returns effect
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleGroup takes handle subject, string name returns group
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleLightning takes handle subject, string name returns lightning
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleWidget takes handle subject, string name returns widget
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction
//==============公共函数结束==========================[/jass]

对每个单位增加受到伤害的TRIGGER

得到伤害数值

在"致命一击的跟踪 - BUFF TRACE" 中,只是为了显示伤害而已,实际上如果用这办法作跟踪的时候是不需要的。

使用方法"致命一击的跟踪 - dmg Trace(no "wait")"时,需要使用这个TRIGGER.

这是写得最完善的获得任意单位伤害数值的TRIGGER。

此TIGGER可以自动跟踪全图单位的所受的伤害,当单位死亡的时候会自动销毁单位受到伤害的子TRIGGER,
所以一般不会引起卡(除非一个地图有几千个单位)。如果不要跟踪全图,可以修改区域bj_mapInitialPlayableArea。

此TIGGER不需自己调用。如果会JASS,可以修改function AnyUnitTakesDamage,其他基本不需要修改了。

[jass]//***************************************
//这下面是AddDmg的功能
//***************************************
function GetHandleTriggerAction takes handle subject, string name returns triggeraction
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function AnyUnitTakesDamage takes nothing returns nothing
    // your actions here 在这里放入你的代码
    // udg_realtmp 是在CTRL+B中定义的realtmp真值型变量
    // udg_realtmp2 是在CTRL+B中定义的realtmp2真值型变量
    // udg_realtmp2 用于储存上次造成的伤害值,udg_realtmp是储存当前伤害
    set udg_realtmp2 =  udg_realtmp
    set udg_realtmp = GetEventDamage()
    //call TriggerExecute( gg_trg_Critical_Tracer )
    // Sample Damage display:  显示例子
    call BJDebugMsg( GetUnitName(GetAttackedUnitBJ()) +  "受到:" + R2S(udg_realtmp) + " 的伤害")
endfunction
function AddDamageTriggers takes nothing returns nothing
    local trigger takedamage = CreateTrigger()
    call TriggerRegisterUnitEvent(takedamage,GetTriggerUnit(),EVENT_UNIT_DAMAGED)
    call SetHandleHandle(takedamage,"action",TriggerAddAction(takedamage,function AnyUnitTakesDamage))
    call SetHandleHandle(GetTriggerUnit(),"TakeDamageTrigger",takedamage)
endfunction
function RemoveDamageTriggers takes nothing returns nothing
    local trigger me = GetHandleTrigger(GetTriggerUnit(),"TakeDamageTrigger")
    // delete action and trigger -- 清除TRIGGER
    call TriggerRemoveAction(me,GetHandleTriggerAction(me,"action"))
    call DestroyTrigger(me)
    call FlushHandleLocals(me)
    set me = null
endfunction

function InitTrig_AddDmg takes nothing returns nothing
    local trigger entermap = CreateTrigger()
    local group startingunits = CreateGroup()
    local unit u
    local trigger takedamage
    local trigger upondeath = CreateTrigger()
    call GroupEnumUnitsInRect(startingunits,bj_mapInitialPlayableArea,null)
    loop
        set u = FirstOfGroup(startingunits)
        exitwhen u == null
        set takedamage = CreateTrigger()
        call TriggerRegisterUnitEvent(takedamage,u,EVENT_UNIT_DAMAGED)
        call SetHandleHandle(takedamage,"action",TriggerAddAction(takedamage,function AnyUnitTakesDamage))
        call SetHandleHandle(u,"TakeDamageTrigger",takedamage)
        call GroupRemoveUnit(startingunits,u)
    endloop
    set takedamage = null
    // unit enters the map -- 单位创建时,对该单位增加跟踪所受到伤害的TRIGGER
    call TriggerRegisterEnterRectSimple(entermap, bj_mapInitialPlayableArea)
    call TriggerAddAction(entermap,function AddDamageTriggers)

    // unit dies -- 单位死亡后,销毁跟踪该单位所受到伤害的TRIGGER
    call TriggerRegisterAnyUnitEventBJ(upondeath,EVENT_PLAYER_UNIT_DECAY)
    call TriggerAddAction(upondeath,function RemoveDamageTriggers)
endfunction[/jass]
发表于 2006-5-30 20:27:51 | 显示全部楼层
享受沙发~~~~享受WE~~~~
回复

使用道具 举报

发表于 2006-5-30 20:30:21 | 显示全部楼层
这个可以不用wait
回复

使用道具 举报

 楼主| 发表于 2006-5-30 20:32:18 | 显示全部楼层
楼上先把WAIT去掉看看再说吧
回复

使用道具 举报

发表于 2006-5-30 20:34:34 | 显示全部楼层
不用wait要用take damage触发
回复

使用道具 举报

 楼主| 发表于 2006-5-30 20:46:52 | 显示全部楼层
标题即是目的 --- 对被动技能(致命一击)的响应。

楼上可能是想通过伤害数值的比较来确定是否发生致命一击。
------------------------------------------
更完美但复杂的解决办法是跟踪所造成的伤害,
这种办法是100%可以跟踪到致命一击的概率,就是比较基础伤害和实际伤害,但因为RPG系统装备是可以+伤害的,所以每加一个物品或英雄升级,都要跟踪。这便造成做出的演示没有可移植性。

当然,可以用复制单位的方法来做,就是让复制单位(隐形)攻击一个目标得到基础伤害,这办法也很复杂。
------------------------------------------
回复

使用道具 举报

发表于 2006-5-30 20:52:17 | 显示全部楼层
这个是在原图上改的
if GetUnitAbilityLevel(GetTriggerUnit(), \'Binf\') > 0 then
        call UnitRemoveAbility(GetTriggerUnit(), \'Binf\')
        call DisplayTextToPlayer(Player(0),0,0,\"|c00FF0303致命一击:  \" + R2S(GetEventDamage()) + \"|r\")
endif

就是把这段直接加到jass里了


------这是个不用WAIT的好方法,但需要懂JASS。  greedwind注------
GetUnitAbilityLevel(GetTriggerUnit(), \'Binf\')中的\'Binf\'是指被伤害单位受到致命一击的时候增加的BUFF(只用于辅助判断,无实际作用。)

[jass]//***************************************
//这下面是AddDmg的功能
//***************************************
function GetHandleTriggerAction takes handle subject, string name returns triggeraction
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function AnyUnitTakesDamage takes nothing returns nothing
    // your actions here 在这里放入你的代码
    // udg_realtmp 是在CTRL+B中定义的realtmp真值型变量
    // udg_realtmp2 是在CTRL+B中定义的realtmp2真值型变量
    // udg_realtmp2 用于储存上次造成的伤害值,udg_realtmp是储存当前伤害
    set udg_realtmp2 =  udg_realtmp
    set udg_realtmp = GetEventDamage()
    //call TriggerExecute( gg_trg_Critical_Tracer )
    // Sample Damage display:  显示例子
    call BJDebugMsg( GetUnitName(GetAttackedUnitBJ()) +  \"受到:\" + R2S(udg_realtmp) + \" 的伤害\")

////////////////插入//////////////////
    if GetUnitAbilityLevel(GetTriggerUnit(), \'Binf\') > 0 then
        call UnitRemoveAbility(GetTriggerUnit(), \'Binf\')
        call DisplayTextToPlayer(Player(0),0,0,\"|c00FF0303致命一击:  \" + R2S(udg_realtmp) + \"|r\")
    endif
////////////////插入//////////////////

endfunction

function AddDamageTriggers takes nothing returns nothing
    local trigger takedamage = CreateTrigger()
    call TriggerRegisterUnitEvent(takedamage,GetTriggerUnit(),EVENT_UNIT_DAMAGED)
    call SetHandleHandle(takedamage,\"action\",TriggerAddAction(takedamage,function AnyUnitTakesDamage))
    call SetHandleHandle(GetTriggerUnit(),\"TakeDamageTrigger\",takedamage)
endfunction
function RemoveDamageTriggers takes nothing returns nothing
    local trigger me = GetHandleTrigger(GetTriggerUnit(),\"TakeDamageTrigger\")
    // delete action and trigger -- 清除TRIGGER
    call TriggerRemoveAction(me,GetHandleTriggerAction(me,\"action\"))
    call DestroyTrigger(me)
    call FlushHandleLocals(me)
    set me = null
endfunction

function InitTrig_AddDmg takes nothing returns nothing
    local trigger entermap = CreateTrigger()
    local group startingunits = CreateGroup()
    local unit u
    local trigger takedamage
    local trigger upondeath = CreateTrigger()
    call GroupEnumUnitsInRect(startingunits,bj_mapInitialPlayableArea,null)
    loop
        set u = FirstOfGroup(startingunits)
        exitwhen u == null
        set takedamage = CreateTrigger()
        call TriggerRegisterUnitEvent(takedamage,u,EVENT_UNIT_DAMAGED)
        call SetHandleHandle(takedamage,\"action\",TriggerAddAction(takedamage,function AnyUnitTakesDamage))
        call SetHandleHandle(u,\"TakeDamageTrigger\",takedamage)
        call GroupRemoveUnit(startingunits,u)
    endloop
    set takedamage = null
    // unit enters the map -- 单位创建时,对该单位增加跟踪所受到伤害的TRIGGER
    call TriggerRegisterEnterRectSimple(entermap, bj_mapInitialPlayableArea)
    call TriggerAddAction(entermap,function AddDamageTriggers)

    // unit dies -- 单位死亡后,销毁跟踪该单位所受到伤害的TRIGGER
    call TriggerRegisterAnyUnitEventBJ(upondeath,EVENT_PLAYER_UNIT_DECAY)
    call TriggerAddAction(upondeath,function RemoveDamageTriggers)
endfunction[/jass]
回复

使用道具 举报

 楼主| 发表于 2006-5-30 21:38:23 | 显示全部楼层
楼上好方法
回复

使用道具 举报

发表于 2006-5-30 22:56:50 | 显示全部楼层
其实也就是GW老大你的方法,我也是看了你的贴子才知道致命一击能加效果的
回复

使用道具 举报

发表于 2006-5-31 12:14:05 | 显示全部楼层
进来膜拜楼上的诸位
大大们辛苦了
回复

使用道具 举报

发表于 2009-1-21 10:17:58 | 显示全部楼层
回复

使用道具 举报

发表于 2009-1-21 12:10:30 | 显示全部楼层
看的眼花 不懂啊
回复

使用道具 举报

发表于 2009-1-21 20:59:39 | 显示全部楼层
LS.........你...............居然............挖坟....
回复

使用道具 举报

发表于 2009-2-7 14:24:22 | 显示全部楼层
看不明白...
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-24 23:40 , Processed in 0.044007 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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