找回密码
 点一下
查看: 1706|回复: 4

一个菜鸟的求助

[复制链接]
发表于 2010-12-21 16:39:25 | 显示全部楼层 |阅读模式
  1. function timerzhouqi takes unit a,unit b  returns nothing
  2.     local location loc_c = GetUnitLoc(a)
  3.     local location loc_b = GetUnitLoc(b)
  4.     local location loc_a = call  PolarProjectionBJ(a, 15.00, AngleBetweenPoints(b, a))
  5.     call SetUnitPositionLoc( a,loc_a  )
  6.     call RemoveLocation(loc_a)
  7.     call RemoveLocation(loc_c)
  8.     call RemoveLocation(loc_b)
  9. endfunction
  10. function tf takes unit a,unit b returns nothing
  11.     local timer t = CreateTimer()
  12.    call TimerStart( t ,0.3,true,function timerzhouqi(a,b))
  13. endfunction
复制代码
单位-任意单位死亡
动作-call tf(GetTriggerUnit (),GetKillingUnit())

帮助下指点错误和修正
谢谢了。是不是计时器要用到缓存的
发表于 2010-12-21 16:46:11 | 显示全部楼层
Timer执行的函数只能是无参
回复

使用道具 举报

 楼主| 发表于 2010-12-21 16:47:18 | 显示全部楼层
那么怎么传递变量信息呢
回复

使用道具 举报

发表于 2010-12-21 17:05:22 | 显示全部楼层
全局变量啊哈希表啊都可以,如果1.24以前是没有哈希表的,大部分是通过GC来做,当然你也可以自己实现数据结构
回复

使用道具 举报

发表于 2010-12-23 13:22:12 | 显示全部楼层
要用到缓存和wc3sear的转化函数,在分割线前面,后面是对你函数的修正:
function H2I takes handle h returns integer
    return h
    return 0
endfunction
function tfgc takes nothing returns gamecache
    return InitGameCache("tfgc.w3v")
endfunction
function SetHandleHandle takes handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(tfgc(),I2S(H2I(subject)),name)
    else
        call StoreInteger(tfgc(), I2S(H2I(subject)), name, H2I(value))
    endif
endfunction
function GetHandleUnit takes handle subject, string name returns unit
    return GetStoredInteger(tfgc(), I2S(H2I(subject)), name)
    return null
endfunction
//==========================================================================
function timerzhouqi takes nothing returns nothing
    local timer t = CreateTimer()
    local unit a = GetHandleUnit(t, "a")
    local unit b = GetHandleUnit(t, "b")
    local location loc_c = GetUnitLoc(a)
    local location loc_b = GetUnitLoc(b)
    local location loc_a = PolarProjectionBJ(loc_c, 15.00, AngleBetweenPoints(loc_b, loc_c))
    call SetUnitPositionLoc(a,loc_a)
    call RemoveLocation(loc_a)
    call RemoveLocation(loc_c)
    call RemoveLocation(loc_b)
    set t = null
    set a = null
    set b = null
endfunction
function tf takes unit a,unit b returns nothing
    local timer t = CreateTimer()
    call SetHandleHandle(t, "a", a)
    call SetHandleHandle(t, "b", b)
    call TimerStart( t ,0.3,true,function timerzhouqi)
endfunction
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-24 21:18 , Processed in 0.034736 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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