请选择 进入手机版 | 继续访问电脑版

 找回密码
 点一下
查看: 2000|回复: 12

我纠结啦各位大神我的这个函数有错吗??

[复制链接]
发表于 2010-6-22 20:39:38 | 显示全部楼层 |阅读模式
我纠结啦各位大神我的这个函数有错吗??
代码在二楼。莫名奇妙的BUG
我补充一下 BUG是 调用该功能时 创建的单位不会移动  很郁闷
 楼主| 发表于 2010-6-22 20:41:27 | 显示全部楼层
//======================================
function H2I takes handle h returns integer
return h
return 0                  
endfunction
function I2U takes integer i returns unit
return i
return null
endfunction
function U2I takes unit u returns integer
return u
return 0
endfunction
function Tm2I takes timer t returns integer
return t
return 0
endfunction
function I2H takes integer i returns handle
return i
return null
endfunction

//============================环绕函数============================
function HR takes nothing returns nothing
local timer tm = GetExpiredTimer()
local unit u = I2U(GetStoredInteger(udg_gc,I2S(Tm2I(tm)),"u"))
local real x = GetStoredReal(udg_gc,I2S(Tm2I(tm)),"x")
local real y = GetStoredReal(udg_gc,I2S(Tm2I(tm)),"y")
local integer N =GetStoredInteger(udg_gc,I2S(Tm2I(tm)),"N")
local real r = GetStoredReal(udg_gc,I2S(Tm2I(tm)),"r")
local real h = GetStoredReal(udg_gc,I2S(Tm2I(tm)),"h")
local real x2 = GetUnitX(u)
local real y2 = GetUnitY(u)
local integer n = GetStoredInteger(udg_gc,I2S(Tm2I(tm)),"n")
call SetUnitX(u,r*(Cos(n*10)))
call SetUnitY(u,r*(Sin(n*10)))
call SetUnitFlyHeight(u,h,0.00)
set n = n+1
call FlushStoredInteger(udg_gc,I2S(Tm2I(tm)),"n")
call StoreInteger(udg_gc,I2S(Tm2I(tm)),"n",n)
if n > N  then
call DestroyTimer(tm)
call PauseUnit(u,false)
call FlushStoredMission(udg_gc,I2S(Tm2I(tm)))
endif
set tm = null
endfunction
//============================环绕启动函数==================================
function HRcontral takes location loc,unit u,integer N,real h,real r returns nothing
local timer tm = CreateTimer()
local integer n = 1
local real x = GetLocationX(loc)
local real y = GetLocationY(loc)
set N = N*36
call PauseUnit(u,true)
call StoreInteger(udg_gc,I2S(Tm2I(tm)),"N",N)
call StoreInteger(udg_gc,I2S(Tm2I(tm)),"n",n)
call StoreReal(udg_gc,I2S(Tm2I(tm)),"x",x)
call StoreReal(udg_gc,I2S(Tm2I(tm)),"y",y)
call StoreReal(udg_gc,I2S(Tm2I(tm)),"r",r)
call StoreReal(udg_gc,I2S(Tm2I(tm)),"h",h)
call StoreInteger(udg_gc,I2S(Tm2I(tm)),"u",U2I(u))
call TimerStart(tm,0.02,true,function HR)
set tm = null
endfunction
//==================================

----------- 帖子于 20:41 更新 --------- 之前内容发布于 20:40 ------------

各位JASS大神帮帮忙呀 我在线等  我学JASS的时间不长 处理不了啦
回复

使用道具 举报

 楼主| 发表于 2010-6-22 23:40:33 | 显示全部楼层
我等的天都黑啦

----------- 帖子于 23:40 更新 --------- 之前内容发布于 23:40 ------------

传说中的EA大神们都在哪?
回复

使用道具 举报

发表于 2010-6-23 10:27:18 | 显示全部楼层
EA????他们在做游戏吧。。。

----------- 帖子于 09:58 更新 --------- 之前内容发布于 09:39 ------------

问题:环绕函数里面,你的XY一点都没用上,跑哪里去了?

----------- 帖子于 10:02 更新 --------- 之前内容发布于 09:58 ------------

另:sin函数的参数是弧度不是角度

----------- 帖子于 10:27 更新 --------- 之前内容发布于 10:02 ------------

突然发现环绕函数只被执行了一次,是什么终止了它了?
回复

使用道具 举报

 楼主| 发表于 2010-6-23 10:33:58 | 显示全部楼层
额,x和y好像漏掉啦,悲剧
Sin参数是弧度那如果按我那样算弧度也是递推的呀 不应该出现不动的情况吧。。。。。
这个函数的启动参数是这样的
location loc,unit u,integer N,real h,real r
点LOC是单位环绕的中心点
u是环绕单位
N是圈数
h是高度
r是半径
其中那两句是
call SetUnitX(u,x+r*(Cos(n*10)))
call SetUnitY(u,y+r*(Sin(n*10)))
昨天被这函数搞得有点晕
GA打成EA了
。。。。。。。。。。。。

----------- 帖子于 10:33 更新 --------- 之前内容发布于 10:32 ------------

大家先试试再看函数
那单位 他就是不动
回复

使用道具 举报

发表于 2010-6-23 10:35:06 | 显示全部楼层
突然发现终止语句的是“set  n = n + 1”,把它去掉就可以运行多次,单位可以运动了!!!
回复

使用道具 举报

 楼主| 发表于 2010-6-23 10:40:34 | 显示全部楼层
。。。。。。。。。。。。。。。。。怎讲
我也发现啦  
RP问题?
n=n+1
没有什么问题呀
回复

使用道具 举报

发表于 2010-6-23 10:44:54 | 显示全部楼层
OK了

----------- 帖子于 10:44 更新 --------- 之前内容发布于 10:41 ------------

我把set n = n + 0.1删了就可以了,不明白原因。
在原函数的基础上做了较大改动:把角度改成弧度,把整数变量改成实数,把某些无用语句去掉》。。。。。。

test.w3x

14 KB, 下载次数: 8

回复

使用道具 举报

 楼主| 发表于 2010-6-23 10:54:44 | 显示全部楼层
纠结
无尽的纠结

----------- 帖子于 10:54 更新 --------- 之前内容发布于 10:51 ------------

谢谢大神 指点迷津
回复

使用道具 举报

 楼主| 发表于 2010-6-23 11:21:16 | 显示全部楼层
好吧 又出BUG了
上次是应为变量
set n=n+1
实际量不变而不转现下是转起来停不了
郁闷

----------- 帖子于 11:21 更新 --------- 之前内容发布于 11:18 ------------

研究发现直接用n来控制程序它又不动了

test2.w3x

20 KB, 下载次数: 6

回复

使用道具 举报

发表于 2010-6-23 11:48:11 | 显示全部楼层
???停不下来???
明明没有转啊,怎么不用我改过的函数?

----------- 帖子于 11:29 更新 --------- 之前内容发布于 11:25 ------------

貌似这个n又开始作乱了。。。是停不下来

----------- 帖子于 11:41 更新 --------- 之前内容发布于 11:29 ------------

。。。发现了,是N在作怪,错怪n了,把N改没有就OK

----------- 帖子于 11:48 更新 --------- 之前内容发布于 11:41 ------------

哦,发现问题了:缓存项目名称是不区分大小写的,因此“n”和“N”是一样的,你分别用“N”和“n”来做两个key就冲突了~~~~换个名字
解决!!

test2.w3x

19 KB, 下载次数: 7

回复

使用道具 举报

 楼主| 发表于 2010-6-23 11:53:54 | 显示全部楼层
饿   悲剧呀  
我刚刚查看了common.j那gamecache确实是不分大小写的 还是我自己注明的太悲剧啦
好啦 谢谢 希瓦 同学
回复

使用道具 举报

发表于 2010-6-23 13:23:14 | 显示全部楼层
是在解不开就用牙齿咬吧
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-3-28 21:44 , Processed in 0.171220 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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