找回密码
 点一下
查看: 1845|回复: 7

新手求助,代码出现问题~ 新问题,貌似只有第一次运行有效……

[复制链接]
发表于 2009-9-2 14:03:47 | 显示全部楼层 |阅读模式
只有第一次释放技能时有效果,后来再放就无效了。


[jass]
function Trig_gamecache_TimerFunc takes nothing returns nothing
  local integer n = GetStoredInteger(udg_GC, I2S(h2i(GetExpiredTimer())), "N")
  local unit u = i2u(GetStoredInteger(udg_GC, I2S(h2i(GetExpiredTimer())), "Caster"))
  local real distance = GetStoredReal(udg_GC, I2S(h2i(GetExpiredTimer())), "distance")
  local real angle = GetStoredReal(udg_GC, I2S(h2i(GetExpiredTimer())), "angle")
  local location p1 = GetUnitLoc(u)
  local location p2
  set p2  = PolarProjectionBJ(p1, distance, angle)
  call SetUnitPositionLocFacingBJ( u, p2, angle )
  set n = n - 1
  call StoreInteger(udg_GC, I2S(h2i(bj_lastStartedTimer)), "N", n)
  call RemoveLocation(p1)
  call RemoveLocation(p2)
if n <= 0 then
  call FlushStoredMission(udg_GC, I2S(h2i(GetExpiredTimer())))
  call DestroyTimer(GetExpiredTimer())
endif
endfunction

function Trig_jump_1_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_jump_1_Actions takes nothing returns nothing
local location p1 = GetUnitLoc(GetTriggerUnit())
local location p2 = GetSpellTargetLoc()
local real distance = ((DistanceBetweenPoints(p1, p2))/60.00)
local real angle = AngleBetweenPoints(p1, p2)
local integer n = 50
if not HaveStoredInteger(udg_GC, I2S(h2i(GetTriggerUnit())), "JumpTimer") then
set bj_lastStartedTimer = CreateTimer()
call StoreInteger(udg_GC, I2S(h2i(GetTriggerUnit())), "JumpTimer", h2i(bj_lastStartedTimer))
call StoreInteger(udg_GC, I2S(h2i(bj_lastStartedTimer)), "Caster", h2i(GetTriggerUnit()))
call StoreInteger(udg_GC, I2S(h2i(bj_lastStartedTimer)), "N", n)
call StoreReal(udg_GC, I2S(h2i(bj_lastStartedTimer)), "distance", distance)
call StoreReal(udg_GC, I2S(h2i(bj_lastStartedTimer)), "angle", angle)
call TimerStart(bj_lastStartedTimer,0.01,true, function Trig_gamecache_TimerFunc)
endif
endfunction
//===========================================================================
function InitTrig_jump_1 takes nothing returns nothing
    set gg_trg_jump_1 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_jump_1, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_jump_1, Condition( function Trig_jump_1_Conditions ) )
    call TriggerAddAction( gg_trg_jump_1, function Trig_jump_1_Actions )
endfunction
[/jass]

之前返回值的问题已经解决,但是现在写完后发现,只有第一次释放技能时有效果,后来再放就无效了。
发表于 2009-9-2 14:09:14 | 显示全部楼层
[codes=jass]function Trig_jump_1_Actions takes nothing returns nothing
local location p1 = GetUnitLoc(GetTriggerUnit())
local location p2 = GetSpellTargetLoc()
local real distance = (DistanceBetweenPoints(udg_p1, udg_p2))/50
local real angle = AngleBetweenPoints(udg_p1, udg_p2)
if not HaveStoredInteger(udg_GC, I2S(h2i(GetTriggerUnit())), "JumpTimer") then
set bj_lastStartedTimer = CreateTimer()
call StoreInteger(udg_GC, I2S(h2i(GetTriggerUnit())), "JumpTimer", h2i(bj_lastStartedTimer))
call StoreInteger(udg_GC, I2S(h2i(bj_lastStartedTimer)), "Caster", h2i(GetTriggerUnit()))
call StoreInteger(udg_GC, I2S(h2i(bj_lastStartedTimer)), "N", 50)
call StoreReal(udg_GC, I2S(h2i(bj_lastStartedTimer)), "distance", distance)
call StoreReal(udg_GC, I2S(h2i(bj_lastStartedTimer)), "angle", angle)
call TimerStart(bj_lastStartedTimer,0.02,true, function Trig_gamecache_TimerFunc)
endif
return false
endfunction
[/codes]

这个函数是return nothing的,你写了一个return false……
回复

使用道具 举报

 楼主| 发表于 2009-9-2 14:12:32 | 显示全部楼层
原来如此

真是太谢谢了~
回复

使用道具 举报

 楼主| 发表于 2009-9-2 17:48:51 | 显示全部楼层
[jass]
function Trig_gamecache_TimerFunc takes nothing returns nothing
  local integer n = GetStoredInteger(udg_GC, I2S(h2i(GetExpiredTimer())), "N")
  local unit u = i2u(GetStoredInteger(udg_GC, I2S(h2i(GetExpiredTimer())), "Caster"))
  local real distance = GetStoredReal(udg_GC, I2S(h2i(GetExpiredTimer())), "distance")
  local real angle = GetStoredReal(udg_GC, I2S(h2i(GetExpiredTimer())), "angle")
  local location p1 = GetUnitLoc(u)
  local location p2
  set p2  = PolarProjectionBJ(p1, distance, angle)
  call SetUnitPositionLocFacingBJ( u, p2, angle )
  set n = n - 1
  call StoreInteger(udg_GC, I2S(h2i(bj_lastStartedTimer)), "N", n)
  call RemoveLocation(p1)
  call RemoveLocation(p2)
if n <= 0 then
  call FlushStoredMission(udg_GC, I2S(h2i(GetExpiredTimer())))
  call DestroyTimer(GetExpiredTimer())
endif
endfunction


function Trig_jump_1_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction


function Trig_jump_1_Actions takes nothing returns nothing
local location p1 = GetUnitLoc(GetTriggerUnit())
local location p2 = GetSpellTargetLoc()
local real distance = ((DistanceBetweenPoints(p1, p2))/60.00)
local real angle = AngleBetweenPoints(p1, p2)
local integer n = 50
if not HaveStoredInteger(udg_GC, I2S(h2i(GetTriggerUnit())), "JumpTimer") then
set bj_lastStartedTimer = CreateTimer()
call StoreInteger(udg_GC, I2S(h2i(GetTriggerUnit())), "JumpTimer", h2i(bj_lastStartedTimer))
call StoreInteger(udg_GC, I2S(h2i(bj_lastStartedTimer)), "Caster", h2i(GetTriggerUnit()))
call StoreInteger(udg_GC, I2S(h2i(bj_lastStartedTimer)), "N", n)
call StoreReal(udg_GC, I2S(h2i(bj_lastStartedTimer)), "distance", distance)
call StoreReal(udg_GC, I2S(h2i(bj_lastStartedTimer)), "angle", angle)
call TimerStart(bj_lastStartedTimer,0.01,true, function Trig_gamecache_TimerFunc)
endif
endfunction

//===========================================================================
function InitTrig_jump_1 takes nothing returns nothing
    set gg_trg_jump_1 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_jump_1, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_jump_1, Condition( function Trig_jump_1_Conditions ) )
    call TriggerAddAction( gg_trg_jump_1, function Trig_jump_1_Actions )
endfunction
[/jass]

还是那段代码,为啥只有第一次有效,后面再次释放技能就无效呢?
回复

使用道具 举报

发表于 2009-9-2 18:38:06 | 显示全部楼层
问题请加描述性语句,我们不是源代码阅读者
回复

使用道具 举报

发表于 2009-9-7 13:34:10 | 显示全部楼层
if not HaveStoredInteger(udg_GC, I2S(h2i(GetTriggerUnit())), "JumpTimer") then

你计时器里没加清除这个的
所以自然以后都无效了
回复

使用道具 举报

发表于 2009-9-9 06:30:17 | 显示全部楼层
补充LS的话:
[jass]function Trig_gamecache_TimerFunc takes nothing returns nothing
  local integer n = GetStoredInteger(udg_GC, I2S(h2i(GetExpiredTimer())), "N")
  local unit u = i2u(GetStoredInteger(udg_GC, I2S(h2i(GetExpiredTimer())), "Caster"))
  local real distance = GetStoredReal(udg_GC, I2S(h2i(GetExpiredTimer())), "distance")
  local real angle = GetStoredReal(udg_GC, I2S(h2i(GetExpiredTimer())), "angle")
  local location p1 = GetUnitLoc(u)
  local location p2
  set p2  = PolarProjectionBJ(p1, distance, angle)
  call SetUnitPositionLocFacingBJ( u, p2, angle )
  set n = n - 1
  call StoreInteger(udg_GC, I2S(h2i(bj_lastStartedTimer)), "N", n)
  call RemoveLocation(p1)
  call RemoveLocation(p2)
if n <= 0 then
  call FlushStoredMission(udg_GC, I2S(h2i(GetExpiredTimer())))
  call DestroyTimer(GetExpiredTimer())
endif
endfunction[/jass]
在call FlushStoredMissile....
下面加上
[jass]
call FlushStoredInteger( udg_GC, I2S( h2i(u) ), "JumpTimer" )
[/jass]
这样就行了。
回复

使用道具 举报

 楼主| 发表于 2009-9-11 20:25:36 | 显示全部楼层
原来如此    感谢
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-4 09:04 , Processed in 0.061769 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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