找回密码
 点一下
查看: 3925|回复: 11

模拟箭矢伤害等待函数(供参考)

[复制链接]
发表于 2007-11-27 22:08:38 | 显示全部楼层 |阅读模式
[jass]function DamageTimedAction takes nothing returns nothing
    local real inv = 0.02
    local integer tmIndex = GetTimerIndex(GetExpiredTimer())
    local unit su = I2U(SYS_TimerData_1[tmIndex])
    local unit tu = I2U(SYS_TimerData_2[tmIndex])
    local real value = SYS_TimerData_R0[tmIndex]
    local real heroconfig = SYS_TimerData_R1[tmIndex]
    local real x = SYS_TimerData_R2[tmIndex]
    local real y = SYS_TimerData_R3[tmIndex]
    local real speed = SYS_TimerData_R4[tmIndex]*inv
    local real tx = GetUnitX(tu)
    local real ty = GetUnitY(tu)
    local real c = Atan2(ty-y,tx-x)
    local real l = ((tx-x)*(tx-x)+((ty-y)*(ty-y)))
    if(l<=10000 or l<=speed*speed)then
       if(IsUnitType(tu,UNIT_TYPE_HERO))then
          set value = value * heroconfig
       endif
       if(SYS_TimerData_0[tmIndex]>0)then
          call UnitDamageTarget(su,tu,I2R(R2I(value)),true,false,ATTACK_TYPE_NORMAL, DAMAGE_TYPE_POISON,WEAPON_TYPE_WHOKNOWS)
       else
          call SetUnitState(tu,UNIT_STATE_LIFE,GetUnitState(tu,UNIT_STATE_LIFE)+value)
          call ShowStrPosUnitCfg(su,tu,I2S(R2I(value)),2,1.00,false,true)
       endif
       call PauseTimer(GetExpiredTimer())
       call ReleaseTimer(GetExpiredTimer())
    elseif(SYS_TimerData_R5[tmIndex]<=0)then
       call PauseTimer(GetExpiredTimer())
       call ReleaseTimer(GetExpiredTimer())
    endif
    set SYS_TimerData_R5[tmIndex] = SYS_TimerData_R5[tmIndex] - inv
    if(not(ty==y) and not(tx==x))then
       if(((tx-x)*(tx-x))>=1000)then
          set x = x+Cos(c)*speed
       endif
       if(((ty-y)*(ty-y))>=1000)then
          set y = y+Sin(c)*speed
       endif
       set SYS_TimerData_R2[tmIndex] = x
       set SYS_TimerData_R3[tmIndex] = y
    endif
    set su = null
    set tu = null
endfunction

function DamageTargetTimed takes unit su,unit tu,real BlotSpeed,real MaxWaitTime, boolean DamOrHeal,real Value,real HeroConfig returns nothing
    local timer tm = GetTimer()
    local integer tmIndex = GetTimerIndex(tm)
    if(DamOrHeal)then
       set SYS_TimerData_0[tmIndex] = 1
    else
       set SYS_TimerData_0[tmIndex] = 0
    endif
    set SYS_TimerData_1[tmIndex] = H2I(su)
    set SYS_TimerData_2[tmIndex] = H2I(tu)
    set SYS_TimerData_R0[tmIndex] = Value
    set SYS_TimerData_R1[tmIndex] = HeroConfig
    set SYS_TimerData_R2[tmIndex] = GetUnitX(su)
    set SYS_TimerData_R3[tmIndex] = GetUnitY(su)
    set SYS_TimerData_R4[tmIndex] = BlotSpeed
    set SYS_TimerData_R5[tmIndex] = MaxWaitTime
    call TimerStart(tm,0.02,true,function DamageTimedAction)
    set tm = null
endfunction
[/jass]
//============================================================

该函数可以模拟箭矢,射出去命中目标后才造成伤害,考虑了目标的移动对伤害时间造成的细微影响。

适合大家做地图的时候更完美地模拟“风暴之锤”一类的魔法造成的伤害效果。

附测试地图
333.JPG

LostTemple_C_Wow.rar

341 KB, 下载次数: 217

发表于 2007-11-27 22:44:33 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

 楼主| 发表于 2007-11-28 09:11:59 | 显示全部楼层
说白了和那个原理一样的。。。只是他那个对地面,我这个对单位而已
回复

使用道具 举报

发表于 2007-11-28 17:37:20 | 显示全部楼层
怎么不亮起来啊...看起来好花噢
回复

使用道具 举报

发表于 2007-12-2 20:44:18 | 显示全部楼层
如果技能刚要打上目标,目标用"闪烁"技能,闪开了这一次技能,如何算呢?
如果技能刚要打上的时候,目标动用"分身"技能,结果出现了一次瞬间无敌,如何算呢?
如果技能刚要打上的时候,某人钻进了地洞,或是上了飞艇,或是跑上了船,如何算呢?
如果刚要打上的时间,被大法师用传送,带跑了.或是被人家用回城给带跑了.或是被科多吃了,怎么算呢


__________________
我还是相信那一个保守的buff.
因为buff的附加时,伤害大小都是0.  而且击晕这样的技能,都是晕的时候是一个0伤害,晕结束时也是一个0伤害.  找到这两个伤害就知道什么时候开始晕,什么时候晕结束.
回复

使用道具 举报

发表于 2007-12-7 19:49:08 | 显示全部楼层
LS,你说的这些可能还是比较小的..

不过问句,

那下面的=======要不要加?还是那个 // ==== 
回复

使用道具 举报

发表于 2007-12-7 20:53:08 | 显示全部楼层
引用第5楼star于2007-12-07 19:49发表的  :
LS,你说的这些可能还是比较小的..

不过问句,

那下面的=======要不要加?还是那个 // ==== 
这些东西发生的机会大着呢.  我经常看录像上有人用剑圣分身的瞬间无敌逃过山丘的锤子,或是铁乌鸦用闪烁躲过了死骑的一个死亡缠绕.
回复

使用道具 举报

发表于 2007-12-9 15:17:28 | 显示全部楼层
意外的几率是很大,但貌似这些担心是多余的

闪烁闪过的技能会照样跟踪
无敌和装载不伤害(标准技能也是这样的)

那个BUFF捕捉方法倒是比较麻烦(您可以试试)
回复

使用道具 举报

发表于 2007-12-9 16:34:10 | 显示全部楼层
这样也麻烦?
(让山丘的锤子,能打掉对面一半的血.)


[codes=jass]
//! import zhuzhu.j
function testfunc takes nothing returns nothing
    local unit from=GetBuffFrom()
    local unit to=GetBuffTo()
    local real damage=GetUnitState(to,UNIT_STATE_LIFE)/2
    call  FullDamageUnit(from,to,damage)
endfunction
[/codes]
BQ@Y5$Z{RYBPVGFRJ%Z@`2O.jpg
回复

使用道具 举报

发表于 2007-12-9 18:05:03 | 显示全部楼层
[jass]//| 技能属性注册:
//|                        |技能ID|初始伤害|导弹速率|目标函数名|
call SetAbilityAttribute(   'AHtb',   200,     555,   "Effe_tb"  )[/jass]

这样貌似更简单点
回复

使用道具 举报

发表于 2007-12-9 18:11:01 | 显示全部楼层
MissileLaunch.w3x (37 KB, 下载次数: 15)
可能这东西已经找不到了,传一个吧

(早期作品,语法格式混乱,看得懂就看吧)
回复

使用道具 举报

 楼主| 发表于 2007-12-10 09:23:12 | 显示全部楼层
[jass]function WaitForBuff_func takes nothing returns nothing
&#160; &#160; &#160; local integer buffid
&#160; &#160; &#160; local string&#160;&#160; func
&#160; &#160; &#160; set gt_trigger=GetTriggeringTrigger()
&#160; &#160; &#160; set buffid=GetInt(gt_trigger,"buffid")
&#160; &#160; &#160; set func=GetStr(gt_trigger,"func")
&#160; &#160; &#160; if GetUnitAbilityLevel(GetTriggerUnit(),buffid)>0 and GetUnit(gt_trigger,"master")==GetEventDamageSource()then
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; call DisableTrigger(GetTriggeringTrigger())
&#160; &#160; &#160; &#160; &#160; &#160; set&#160;&#160; gt_unit=GetUnit(gt_trigger,"master")
&#160; &#160; &#160; &#160; &#160; &#160; call ExecuteFunc(func)
&#160; &#160; &#160; &#160; &#160; &#160; call FlushTable(gt_trigger)
&#160; &#160; &#160; &#160; &#160; &#160; call DestroyTrigger(gt_trigger)
&#160; &#160; &#160; endif
endfunction[/jass]

果然是动态创建的触发。。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-24 10:52 , Processed in 0.089420 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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