找回密码
 点一下
查看: 1108|回复: 1

一个技能关于数学的问题

[复制链接]
发表于 2010-5-26 12:18:10 | 显示全部楼层 |阅读模式
我做了个技能,其中伤害部分的触发注册是这样的注册事件是单位接近指定单位80范围,条件无,动作伤害触发单位。指定单位呢,我用timerstart把她沿一条直线运动,是每0.01秒时间,每次移动距离为50,技能设定是点目标或单位目标,而当我用这个技能点一个敌方单位时,却有一定的概率会伤害不到,而根据数学,目标单位在那条直线上,而每次移动距离50是小于触发事件中的范围直径160,就是所目标单位一定会进入这个范围,所以这个伤害的触发理应可以触发,但为什么却有一定的概率不触发呢?而当我把范围调成300的时候,伤害就是100%了,从不丢失,对于这一点我十分的迷惑,哪位高人出来指点一下迷津?
 楼主| 发表于 2010-5-26 12:20:33 | 显示全部楼层
我把技能也发上来吧,要的随便拿
function Conditions takes nothing returns boolean
if(not(GetSpellAbilityId()=='A00A')) then
return false
endif
return true
endfunction

function RowRun takes nothing returns nothing
local timer tm=GetExpiredTimer()
local unit me=LoadUnitHandle(udg_HT[2],GetHandleId(tm),StringHash("me"))
local unit temp=LoadUnitHandle(udg_HT[2],GetHandleId(tm),StringHash("temp"))
local trigger trg=LoadTriggerHandle(udg_HT[2],GetHandleId(tm),StringHash("trg"))
local location point=LoadLocationHandle(udg_HT[2],GetHandleId(tm),StringHash("point"))
local real x=GetUnitX(temp)
local real y=GetUnitY(temp)
local real x1=GetLocationX(point)
local real y1=GetLocationY(point)
local real x2=GetUnitX(me)
local real y2=GetUnitY(me)
local real k=Atan2(y1-y2,x1-x2)
local real dx=50*Cos(k)
local real dy=50*Sin(k)
local integer i=0
if Pow(Pow(x-x2,2)+Pow(y-y2,2),0.5)>2500 then
call RemoveLocation(point)
call RemoveUnit(temp)
call FlushChildHashtable(udg_HT[2],GetHandleId(tm))
call DestroyTimer(tm)
call FlushChildHashtable(udg_HT[2],GetHandleId(trg))
call DestroyTrigger(trg)
set i=1
endif
if i==0 then
if RAbsBJ(x)>4000 or RAbsBJ(y)>4000 then
call RemoveUnit(temp)
endif
call SetUnitX(temp,x+dx)
call SetUnitY(temp,y+dy)
else
set me=null
set temp=null
set point=null
set tm=null
endif
endfunction


function damage takes nothing returns nothing
local trigger trg=GetTriggeringTrigger()
local unit me=LoadUnitHandle(udg_HT[2],GetHandleId(trg),StringHash("me"))
local real i=LRtg(2,trg,"i")
if GetOwningPlayer(GetTriggerUnit())!=Player(0) then
call UnitDamageTarget(me, GetTriggerUnit(), i, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
set i=i*0.9
call SRtg(2,trg,"i",i)
endif
call DisplayTimedTextToPlayer(Player(0),0,0,0.1,"c")
set trg=null
set me=null
set trg=null
endfunction



function row takes nothing returns nothing
local trigger trg=GetTriggeringTrigger()
local timer tm=CreateTimer()
local trigger trg1=CreateTrigger()
local real t=LRtg(2,trg,"t")
local timer tm1=LTMtg(2,trg,"tm")
local unit me=LoadUnitHandle(udg_HT[2],GetHandleId(trg),StringHash("me"))
local unit temp=LoadUnitHandle(udg_HT[2],GetHandleId(trg),StringHash("temp"))
local location point=LoadLocationHandle(udg_HT[2],GetHandleId(trg),StringHash("point"))
local triggeraction act
local event ev
local real i=360*t
call SetUnitTimeScale(me,1)
call FlushChildHashtable(udg_HT[2],GetHandleId(tm1))
call DestroyTimer(tm1)
call SRtg(2,trg1,"i",i)
call SaveTriggerHandle(udg_HT[2],GetHandleId(tm),StringHash("trg"),trg1)
call SaveUnitHandle(udg_HT[2],GetHandleId(trg1),StringHash("me"),me)
set ev=TriggerRegisterUnitInRangeSimple(trg1,300,temp)
set act=TriggerAddAction(trg1,function damage)
call SaveUnitHandle(udg_HT[2],GetHandleId(tm),StringHash("me"),me)
call SaveUnitHandle(udg_HT[2],GetHandleId(tm),StringHash("temp"),temp)
call SaveLocationHandle(udg_HT[2],GetHandleId(tm),StringHash("point"),point)
set me=null
set temp=null
set point=null
call TimerStart(tm,0.01,true,function RowRun)
set tm=null
set tm1=null
set act=null
call FlushChildHashtable(udg_HT[2],GetHandleId(trg))
call DestroyTrigger(trg)
set trg=null
endfunction

function timing takes nothing returns nothing
local timer tm=GetExpiredTimer()
local trigger trg=LTGtm(2,tm,"trg")
local unit me=LUtm(2,tm,"me")
local real t=LRtg(2,trg,"t")
set t=t+0.01
if t==0.8 then
call SetUnitTimeScale(me,0.01)
endif
call SRtg(2,trg,"t",t)
set me=null
set tm=null
set trg=null
endfunction




function Trig_wind_Actions takes nothing returns nothing
local timer tm=CreateTimer()
local trigger trg=CreateTrigger()
local location point =GetSpellTargetLoc()
local triggeraction act
local triggercondition cd
local unit temp=CreateUnit(Player(0),'uaco',GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),0)
local event ev
local event ev1
local real t=0
call STMtg(2,trg,"tm",tm)
call SRtg(2,trg,"t",t)
call STGtm(2,tm,"trg",trg)
call SUtm(2,tm,"me",GetTriggerUnit())
call TimerStart(tm,0.01,true,function timing)
call SaveUnitHandle(udg_HT[2],GetHandleId(trg),StringHash("temp"),temp)
call SaveLocationHandle(udg_HT[2],GetHandleId(trg),StringHash("point"),point)
call SaveUnitHandle(udg_HT[2],GetHandleId(trg),StringHash("me"),GetTriggerUnit())
set ev1=TriggerRegisterUnitEvent(trg,GetTriggerUnit(),EVENT_UNIT_SPELL_ENDCAST)
set ev=TriggerRegisterUnitEvent(trg,GetTriggerUnit(),EVENT_UNIT_SPELL_FINISH)
set cd=TriggerAddCondition(trg,Condition(function Conditions))
set act=TriggerAddAction(trg,function row)
set temp=null
set trg=null
set point=null
set act=null
set cd=null
set ev=null
set ev1=null
endfunction

//===========================================================================
function InitTrig_wind takes nothing returns nothing
    set gg_trg_wind = CreateTrigger(  )
call TriggerRegisterAnyUnitEventBJ(gg_trg_wind,EVENT_PLAYER_UNIT_SPELL_CHANNEL)
call TriggerAddCondition(gg_trg_wind,Condition(function Conditions))
    call TriggerAddAction( gg_trg_wind, function Trig_wind_Actions )
endfunction
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-24 01:59 , Processed in 0.123791 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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