看流星社区

 找回密码
 注册账号
查看: 2824|回复: 0

关于线程里面读取内存地址出错。头疼中,期待帮助!

[复制链接]

该用户从未签到

发表于 2011-3-18 17:43:51 | 显示全部楼层 |阅读模式
是一段自动回血的代码。放在线程里面操作的。代码看起来没错误,而且编译通过,运行的时候没出现错误提示,但是就是通不过。具体代码如下

线程:
  1.   
  2. {自动补药:回红}  
  3. TAutoTonicHP_Thread=Class(tThread)  
  4. Public                        
  5.   Procedure Execute;Override;  
  6.   Constructor Create;virtual;  
  7. End;
  8. {自动回红}
  9. Procedure TAutoTonicHP_Thread.Execute;
  10. begin
  11.   AutoTonicForHp();
  12. end;
  13. Constructor TAutoTonicHP_Thread.Create;
  14. begin
  15.   Inherited Create(False);
  16.   FreeOnTerminate:=True;
  17. end;  
复制代码
//回红里面的过程AutoTonicForHp():

  1. Procedure AutoTonicForHp();
  2. begin
  3.   GetSetIniInfo();     //读取INI文件里面的设置信息
  4.   While true do
  5.   begin
  6.     Sleep(1);
  7.     if Game.SetInfo.AutoTonic=False then Exit;          //如果不设置自动回血则退出
  8.     if Game.SetInfo.MyHpLower > 100 then Exit;       //如果设置的血量保护的百分比大于100则退出,保护是按照百分来判断,比如血量小于20/100则回红
  9.     if Game.Role.HP / Game.Role.AllHP < Game.SetInfo.MyHpLower / 100 then    //如果现在血量跟总血量的比例小于设定的比例时则开始吃药
  10.     begin
  11.       if Game.SetInfo.TonicOrder=1 then    //吃药顺序,1是从小药到大药,2是从大药到小药,其他则是吃指定的药
  12.       begin
  13.         if GetCountForBag('小金疮药')>0 then
  14.           Medicine('小金疮药')
  15.         else if GetCountForBag('金疮药')>0 then
  16.           Medicine('金疮药')
  17.         else if GetCountForBag('大金疮药')>0 then
  18.           Medicine('大金疮药')
  19.         else if GetCountForBag('续命水')>0 then
  20.           Medicine('续命水');
  21.       end
  22.       else if Game.SetInfo.TonicOrder=2 then  //同上
  23.       begin
  24.         if GetCountForBag('续命水')>0 then
  25.           Medicine('续命水')
  26.         else if GetCountForBag('大金疮药')>0 then
  27.           Medicine('大金疮药')
  28.         else if GetCountForBag('金疮药')>0 then
  29.           Medicine('金疮药')
  30.         else if GetCountForBag('小金疮药')>0 then
  31.           Medicine('小金疮药');
  32.       end
  33.       else
  34.         Medicine(Game.SetInfo.SpecifyHP);    //吃指定的药
  35.       Sleep(Game.SetInfo.TonicDelay*1000);    //如果吃药了的话延迟多久才再次吃药
  36.     end;
  37.   end;
  38. end;
复制代码
上面的那个点击背包CALL:ClickTheBag(I:Integer),如果不在线程里面,单独用个按钮来执行,则完全正常,那两个对话框都能弹出并且执行了后面的代码
点击按钮快速添加回复内容: 支持 高兴 激动 给力 加油 苦寻 生气 回帖 路过 感恩
您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

小黑屋|手机版|Archiver|看流星社区 |网站地图

GMT+8, 2024-4-29 23:55

Powered by Kanliuxing X3.4

© 2010-2019 kanliuxing.com

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