找回密码
 注册
搜索
查看: 274|回复: 13

过桃花阵函数优化

[复制链接]
门派:古墓派
发表于 2024-5-25 23:30:21 | 显示全部楼层 |阅读模式
taohuazhen.lua
主要涉及以下几个函数
1.替换
  1. function thz_steps()
  2.     if _dir == 'north' then
  3.            return checkWait(thz_south,0.2)
  4.         elseif _dir == 'south' then
  5.            return checkWait(thz_west,0.2)
  6.         elseif _dir == 'west' then
  7.            return checkWait(thz_east,0.2)
  8.         elseif _dir == 'east' then
  9.            return checkWait(find_min_count_and_variable,0.5)
  10.         end
  11. end
复制代码


2下方新增函数
  1. function find_min_count_and_variable()
  2.     local minValue = math.huge
  3.     local minCount = 0
  4.     local minVariables = {}
  5.     local variables = {n_cnt, s_cnt, e_cnt, w_cnt}
  6.     local variableNames = {'n_cnt', 's_cnt', 'e_cnt','w_cnt'}

  7.     for i, v in ipairs(variables) do
  8.         if v <= minValue then
  9.             if v < minValue then
  10.                 minValue = v
  11.                 minCount = 1
  12.                 minVariables = {variableNames[i]}
  13.             else
  14.                 minCount = minCount + 1
  15.                 table.insert(minVariables, variableNames[i])
  16.             end
  17.         end
  18.     end
  19.     if minCount > 1 then
  20.         randomIndex = math.random(minCount)
  21.         direction = minVariables[randomIndex]
  22.     else
  23.                 direction = minVariables[1]
  24.     end
  25.         return checkWait(thz_act3,0.2)
  26. end
复制代码


3.替换

  1. function thz_act3()
  2.     EnableTrigger('thzact1',true)
  3.         EnableTrigger('thzact3',false)
  4.         checkWait(thz_random,0.5)
  5. end
复制代码


4.替换
  1. function thz_random()
  2.     if direction == "n_cnt" then
  3.                 print("北,"..direction)
  4.                 return exe('north')
  5.         elseif direction == "s_cnt" then
  6.                 print("南,"..direction)
  7.                 return exe('south')
  8.         elseif direction == "w_cnt" then
  9.                 print("西,"..direction)
  10.                 return exe('west')
  11.         else
  12.                 print("东,"..direction)
  13.                 return exe('east')
  14.         end
  15. end
复制代码

门派:华山派
发表于 2024-5-25 23:49:26 | 显示全部楼层
这个有用,要更新进去啊。
门派:明教
发表于 2024-5-26 08:37:30 | 显示全部楼层
漂亮,可以更快的过阵了
门派:明教
发表于 2024-5-26 08:38:02 | 显示全部楼层
我们热爱大波妹
门派:天龙寺
发表于 2024-5-26 15:38:46 | 显示全部楼层
桃花阵里面2个人基本就过不去了
门派:古墓派
 楼主| 发表于 2024-5-26 20:09:48 | 显示全部楼层
我只能说有人捣乱就过不去,比如说一个人捡石子,一个人丢,肯定过不去,如果都是机器,以前的算法可能会过不去,现在人多不影响过
门派:嵩山派
发表于 2024-5-27 13:49:15 | 显示全部楼层
dbm@ts2 发表于 2024-5-26 20:09
我只能说有人捣乱就过不去,比如说一个人捡石子,一个人丢,肯定过不去,如果都是机器,以前的算法可能会过 ...

你就不能把taohuazhen.lua 发上来嘛?

我懒得改了啊
门派:华山派
发表于 2024-5-27 14:03:19 | 显示全部楼层
等晚上回去更新。。
门派:华山派
发表于 2024-5-27 16:29:35 | 显示全部楼层
jsfbi@ts2 发表于 2024-5-27 13:49
你就不能把taohuazhen.lua 发上来嘛?

我懒得改了啊

我这是鼓励大家多多动手
门派:铁掌帮
发表于 2024-5-27 16:40:07 | 显示全部楼层
看着就好高级,完全看不懂
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|书剑永恒MUD ( 闽ICP备14012032号|闽公网安备 35050202000162号 )

GMT+8, 2025-5-1 09:43 , Processed in 0.033977 second(s), 25 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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