找回密码
 点一下
查看: 3360|回复: 2

万能刷野代码 支持第一波刷野的时机

[复制链接]
发表于 2012-6-11 16:27:29 | 显示全部楼层 |阅读模式
本帖最后由 ckpig 于 2013-12-4 17:45 编辑
  1. library stupid initializer init
  2. globals
  3. private real stupidrevd=45//野怪刷新间隔
  4. private real starttime=120//初始刷野时机
  5. endglobals

  6. //以下为刷野需要用到的变量 无视即可
  7. globals
  8. private group array g
  9. private integer i=0
  10. private integer a=0
  11. private integer z=0
  12. private group gg=CreateGroup()
  13. private group gt=CreateGroup()
  14. private unit u
  15. private hashtable HT=InitHashtable()
  16. private hashtable HT2=InitHashtable()
  17. private boolean b=false
  18. private real x
  19. private real y
  20. private real f
  21. endglobals

  22. //将野怪按距离分组
  23. private function f2 takes nothing returns boolean
  24. if(GetOwningPlayer(GetFilterUnit())==Player(12))then
  25. call GroupAddUnit(gt,GetFilterUnit())
  26. call GroupRemoveUnit(gg,GetFilterUnit())
  27. call SaveGroupHandle(HT,GetHandleId(GetFilterUnit()),1,g[i])
  28. call SaveReal(HT,GetHandleId(GetFilterUnit()),2,GetUnitX(GetFilterUnit()))
  29. call SaveReal(HT,GetHandleId(GetFilterUnit()),3,GetUnitY(GetFilterUnit()))
  30. return true
  31. endif
  32. return false
  33. endfunction

  34. //遍历初始化地图上的野怪
  35. private function f1 takes nothing returns nothing
  36. set u=GetEnumUnit()
  37. if IsUnitInGroup(u,gt) then
  38. return
  39. endif
  40. set g[i]=CreateGroup()
  41. call SaveGroupHandle(HT,GetHandleId(u),1,g[i])
  42. call SaveReal(HT,GetHandleId(u),2,GetUnitX(u))
  43. call SaveReal(HT,GetHandleId(u),3,GetUnitY(u))
  44. call GroupEnumUnitsInRange(g[i],GetUnitX(u),GetUnitY(u),300,function f2)//300为判断野怪是否划分为一波的距离限定
  45. set i=i+1
  46. endfunction

  47. //保存每组野怪的参数
  48. private function f3 takes nothing returns nothing
  49. set u=GetEnumUnit()
  50. set x=GetUnitX(u)
  51. set y=GetUnitY(u)
  52. set f=GetUnitFacing(u)
  53. call SaveInteger(HT,GetHandleId(gt),0,a)
  54. call SaveInteger(HT,GetHandleId(gt),a*5+1,GetUnitTypeId(u))
  55. call SaveReal(HT,GetHandleId(gt),a*5+2,x)
  56. call SaveReal(HT,GetHandleId(gt),a*5+3,y)
  57. call SaveReal(HT,GetHandleId(gt),a*5+4,f)
  58. set a=a+1
  59. endfunction

  60. //复活
  61. private function rt takes nothing returns nothing
  62. local timer t=GetExpiredTimer()
  63. local integer b=1
  64. set a=GetHandleId(t)
  65. set gt=LoadGroupHandle(HT,a,1)
  66. set i=GetHandleId(gt)
  67. set z=LoadInteger(HT,i,0)
  68. call GroupClear(gt)
  69. loop
  70. exitwhen b>z
  71. set u=CreateUnit(Player(12),LoadInteger(HT,i,b*5+1),LoadReal(HT,i,b*5+2),LoadReal(HT,i,b*5+3),LoadReal(HT,i,b*5+4))
  72. call regdmg(u)
  73. call GroupAddUnit(gt,u)
  74. call UnitAddAbility(u,'A02A')
  75. call SetUnitAcquireRange(u, 500)
  76. call SaveGroupHandle(HT,GetHandleId(u),1,gt)
  77. call SaveReal(HT,GetHandleId(u),2,GetUnitX(u))
  78. call SaveReal(HT,GetHandleId(u),3,GetUnitY(u))
  79. set b=b+1
  80. endloop
  81. call FlushChildHashtable(HT,a)
  82. call DestroyTimer(t)
  83. set t=null
  84. endfunction

  85. //boss野怪复活计时器300秒
  86. private function rev2 takes group g returns nothing
  87. local timer t=CreateTimer()
  88. call SaveGroupHandle(HT,GetHandleId(t),1,g)
  89. call TimerStart(t,300,false,function rt)
  90. set t=null
  91. endfunction
  92. private function rev takes group g returns nothing
  93. local timer t=CreateTimer()
  94. call SaveGroupHandle(HT,GetHandleId(t),1,g)
  95. call TimerStart(t,stupidrevd,false,function rt)
  96. set t=null
  97. endfunction

  98. //普通野怪复活计时器 间隔为顶端变量设置的值
  99. private function f4 takes nothing returns boolean
  100. local group gt
  101. set u=GetTriggerUnit()
  102. if UnitHasBuffBJ(u,'Aloc')then
  103. return false
  104. endif
  105. set gt=LoadGroupHandle(HT,GetHandleId(u),1)
  106. call GroupRemoveUnit(gt,u)
  107. //if livg(gt)==false then
  108. if FirstOfGroup(gt)==null then
  109. if GetUnitTypeId(u)!='nrwm' and GetUnitTypeId(u)!='nlrv' then//判断是否为boss野怪
  110. call rev(gt)
  111. //call BJDebugMsg("该野怪点已清空 一段时间后刷新野怪")
  112. else
  113. ////call BJDebugMsg("复活boss")
  114. call rev2(gt)
  115. endif
  116. endif
  117. set gt=null
  118. return false
  119. endfunction

  120. //初始化删除中立敌对单位
  121. private function hide takes nothing returns nothing
  122. local unit u=GetEnumUnit()
  123. call GroupRemoveUnit(LoadGroupHandle(HT,GetHandleId(u),1),u)
  124. call RemoveUnit(u)
  125. set u=null
  126. endfunction

  127. //第一波刷野
  128. private function rt2 takes nothing returns nothing
  129. local timer t=GetExpiredTimer()
  130. local integer b=1
  131. set a=GetHandleId(t)
  132. set gt=LoadGroupHandle(HT,a,1)
  133. set i=GetHandleId(gt)
  134. set z=LoadInteger(HT2,i,0)
  135. call GroupClear(gt)
  136. loop
  137. exitwhen b>z
  138. set u=CreateUnit(Player(12),LoadInteger(HT2,i,b*6+1),LoadReal(HT2,i,b*6+2),LoadReal(HT2,i,b*6+3),LoadReal(HT2,i,b*6+4))
  139. call regdmg(u)
  140. call GroupAddUnit(LoadGroupHandle(HT2,i,b*6+5),u)
  141. call UnitAddAbility(u,'A02A')
  142. call SetUnitAcquireRange(u, 500)
  143. call SaveGroupHandle(HT,GetHandleId(u),1,LoadGroupHandle(HT2,i,b*6+5))
  144. call SaveReal(HT,GetHandleId(u),2,GetUnitX(u))
  145. call SaveReal(HT,GetHandleId(u),3,GetUnitY(u))
  146. set b=b+1
  147. endloop
  148. call FlushChildHashtable(HT,a)
  149. call DestroyTimer(t)
  150. //call QuestMessageBJ( GetPlayersAll(), bj_QUESTMESSAGE_DISCOVERED, "少女们注意了,可以攻击野怪了" )
  151. call FlushParentHashtable(HT2)
  152. set t=null
  153. endfunction

  154. //第一波刷野计时器 时间为顶端变量设定
  155. private function t100 takes group g returns nothing
  156. local timer t=CreateTimer()
  157. call SaveGroupHandle(HT,GetHandleId(t),1,g)
  158. call TimerStart(t,starttime,false,function rt2)
  159. set t=null
  160. endfunction

  161. //为第一波刷野记录野怪数据
  162. private function f32 takes nothing returns nothing
  163. set u=GetEnumUnit()
  164. set x=GetUnitX(u)
  165. set y=GetUnitY(u)
  166. set f=GetUnitFacing(u)
  167. call SaveInteger(HT2,GetHandleId(gg),0,a)
  168. call SaveInteger(HT2,GetHandleId(gg),a*6+1,GetUnitTypeId(u))
  169. call SaveReal(HT2,GetHandleId(gg),a*6+2,x)
  170. call SaveReal(HT2,GetHandleId(gg),a*6+3,y)
  171. call SaveReal(HT2,GetHandleId(gg),a*6+4,f)
  172. call SaveGroupHandle(HT2,GetHandleId(gg),a*6+5,LoadGroupHandle(HT,GetHandleId(u),1))
  173. set a=a+1
  174. endfunction

  175. //初始化函数
  176. private function init takes nothing returns nothing
  177. local trigger tg=CreateTrigger()
  178. call GroupEnumUnitsOfPlayer(gg,Player(12),null)
  179. call ForGroup(gg,function f1)
  180. call DestroyGroup(gt)
  181. loop
  182. exitwhen z>=i
  183. set gt=g[z]
  184. set a=1
  185. call ForGroup(g[z],function f3)
  186. set z=z+1
  187. endloop
  188. call GroupEnumUnitsOfPlayer(gg,Player(12),null)
  189. set gt=gg
  190. call ForGroup(gg,function f32)
  191. call ForGroup(gg,function hide)
  192. call t100(gg)
  193. call TriggerRegisterPlayerUnitEvent(tg,Player(12),EVENT_PLAYER_UNIT_DEATH,null)
  194. call TriggerAddCondition(tg,function f4)

  195. endfunction
  196. endlibrary
复制代码
介绍:该刷野系统为每一个区域内的野怪死光后间隔一定时间复活该区域的野怪 非dota类刷野 无拉野
用法:在地图上摆放中立敌对生物即可

评分

参与人数 1威望 +30 收起 理由
疯人¢衰人 + 30 已阅

查看全部评分

发表于 2012-6-12 19:38:28 | 显示全部楼层
支持了思密达,不过用了哈希表不能够支持1.20了。。
回复

使用道具 举报

发表于 2012-8-4 23:50:20 | 显示全部楼层
ck也来GA?
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-21 23:16 , Processed in 0.094388 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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