|
本帖最后由 ckpig 于 2013-12-4 17:45 编辑
- library stupid initializer init
- globals
- private real stupidrevd=45//野怪刷新间隔
- private real starttime=120//初始刷野时机
- endglobals
- //以下为刷野需要用到的变量 无视即可
- globals
- private group array g
- private integer i=0
- private integer a=0
- private integer z=0
- private group gg=CreateGroup()
- private group gt=CreateGroup()
- private unit u
- private hashtable HT=InitHashtable()
- private hashtable HT2=InitHashtable()
- private boolean b=false
- private real x
- private real y
- private real f
- endglobals
- //将野怪按距离分组
- private function f2 takes nothing returns boolean
- if(GetOwningPlayer(GetFilterUnit())==Player(12))then
- call GroupAddUnit(gt,GetFilterUnit())
- call GroupRemoveUnit(gg,GetFilterUnit())
- call SaveGroupHandle(HT,GetHandleId(GetFilterUnit()),1,g[i])
- call SaveReal(HT,GetHandleId(GetFilterUnit()),2,GetUnitX(GetFilterUnit()))
- call SaveReal(HT,GetHandleId(GetFilterUnit()),3,GetUnitY(GetFilterUnit()))
- return true
- endif
- return false
- endfunction
- //遍历初始化地图上的野怪
- private function f1 takes nothing returns nothing
- set u=GetEnumUnit()
- if IsUnitInGroup(u,gt) then
- return
- endif
- set g[i]=CreateGroup()
- call SaveGroupHandle(HT,GetHandleId(u),1,g[i])
- call SaveReal(HT,GetHandleId(u),2,GetUnitX(u))
- call SaveReal(HT,GetHandleId(u),3,GetUnitY(u))
- call GroupEnumUnitsInRange(g[i],GetUnitX(u),GetUnitY(u),300,function f2)//300为判断野怪是否划分为一波的距离限定
- set i=i+1
- endfunction
- //保存每组野怪的参数
- private function f3 takes nothing returns nothing
- set u=GetEnumUnit()
- set x=GetUnitX(u)
- set y=GetUnitY(u)
- set f=GetUnitFacing(u)
- call SaveInteger(HT,GetHandleId(gt),0,a)
- call SaveInteger(HT,GetHandleId(gt),a*5+1,GetUnitTypeId(u))
- call SaveReal(HT,GetHandleId(gt),a*5+2,x)
- call SaveReal(HT,GetHandleId(gt),a*5+3,y)
- call SaveReal(HT,GetHandleId(gt),a*5+4,f)
- set a=a+1
- endfunction
- //复活
- private function rt takes nothing returns nothing
- local timer t=GetExpiredTimer()
- local integer b=1
- set a=GetHandleId(t)
- set gt=LoadGroupHandle(HT,a,1)
- set i=GetHandleId(gt)
- set z=LoadInteger(HT,i,0)
- call GroupClear(gt)
- loop
- exitwhen b>z
- 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))
- call regdmg(u)
- call GroupAddUnit(gt,u)
- call UnitAddAbility(u,'A02A')
- call SetUnitAcquireRange(u, 500)
- call SaveGroupHandle(HT,GetHandleId(u),1,gt)
- call SaveReal(HT,GetHandleId(u),2,GetUnitX(u))
- call SaveReal(HT,GetHandleId(u),3,GetUnitY(u))
- set b=b+1
- endloop
- call FlushChildHashtable(HT,a)
- call DestroyTimer(t)
- set t=null
- endfunction
- //boss野怪复活计时器300秒
- private function rev2 takes group g returns nothing
- local timer t=CreateTimer()
- call SaveGroupHandle(HT,GetHandleId(t),1,g)
- call TimerStart(t,300,false,function rt)
- set t=null
- endfunction
- private function rev takes group g returns nothing
- local timer t=CreateTimer()
- call SaveGroupHandle(HT,GetHandleId(t),1,g)
- call TimerStart(t,stupidrevd,false,function rt)
- set t=null
- endfunction
- //普通野怪复活计时器 间隔为顶端变量设置的值
- private function f4 takes nothing returns boolean
- local group gt
- set u=GetTriggerUnit()
- if UnitHasBuffBJ(u,'Aloc')then
- return false
- endif
- set gt=LoadGroupHandle(HT,GetHandleId(u),1)
- call GroupRemoveUnit(gt,u)
- //if livg(gt)==false then
- if FirstOfGroup(gt)==null then
- if GetUnitTypeId(u)!='nrwm' and GetUnitTypeId(u)!='nlrv' then//判断是否为boss野怪
- call rev(gt)
- //call BJDebugMsg("该野怪点已清空 一段时间后刷新野怪")
- else
- ////call BJDebugMsg("复活boss")
- call rev2(gt)
- endif
- endif
- set gt=null
- return false
- endfunction
- //初始化删除中立敌对单位
- private function hide takes nothing returns nothing
- local unit u=GetEnumUnit()
- call GroupRemoveUnit(LoadGroupHandle(HT,GetHandleId(u),1),u)
- call RemoveUnit(u)
- set u=null
- endfunction
- //第一波刷野
- private function rt2 takes nothing returns nothing
- local timer t=GetExpiredTimer()
- local integer b=1
- set a=GetHandleId(t)
- set gt=LoadGroupHandle(HT,a,1)
- set i=GetHandleId(gt)
- set z=LoadInteger(HT2,i,0)
- call GroupClear(gt)
- loop
- exitwhen b>z
- 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))
- call regdmg(u)
- call GroupAddUnit(LoadGroupHandle(HT2,i,b*6+5),u)
- call UnitAddAbility(u,'A02A')
- call SetUnitAcquireRange(u, 500)
- call SaveGroupHandle(HT,GetHandleId(u),1,LoadGroupHandle(HT2,i,b*6+5))
- call SaveReal(HT,GetHandleId(u),2,GetUnitX(u))
- call SaveReal(HT,GetHandleId(u),3,GetUnitY(u))
- set b=b+1
- endloop
- call FlushChildHashtable(HT,a)
- call DestroyTimer(t)
- //call QuestMessageBJ( GetPlayersAll(), bj_QUESTMESSAGE_DISCOVERED, "少女们注意了,可以攻击野怪了" )
- call FlushParentHashtable(HT2)
- set t=null
- endfunction
- //第一波刷野计时器 时间为顶端变量设定
- private function t100 takes group g returns nothing
- local timer t=CreateTimer()
- call SaveGroupHandle(HT,GetHandleId(t),1,g)
- call TimerStart(t,starttime,false,function rt2)
- set t=null
- endfunction
- //为第一波刷野记录野怪数据
- private function f32 takes nothing returns nothing
- set u=GetEnumUnit()
- set x=GetUnitX(u)
- set y=GetUnitY(u)
- set f=GetUnitFacing(u)
- call SaveInteger(HT2,GetHandleId(gg),0,a)
- call SaveInteger(HT2,GetHandleId(gg),a*6+1,GetUnitTypeId(u))
- call SaveReal(HT2,GetHandleId(gg),a*6+2,x)
- call SaveReal(HT2,GetHandleId(gg),a*6+3,y)
- call SaveReal(HT2,GetHandleId(gg),a*6+4,f)
- call SaveGroupHandle(HT2,GetHandleId(gg),a*6+5,LoadGroupHandle(HT,GetHandleId(u),1))
- set a=a+1
- endfunction
- //初始化函数
- private function init takes nothing returns nothing
- local trigger tg=CreateTrigger()
- call GroupEnumUnitsOfPlayer(gg,Player(12),null)
- call ForGroup(gg,function f1)
- call DestroyGroup(gt)
- loop
- exitwhen z>=i
- set gt=g[z]
- set a=1
- call ForGroup(g[z],function f3)
- set z=z+1
- endloop
- call GroupEnumUnitsOfPlayer(gg,Player(12),null)
- set gt=gg
- call ForGroup(gg,function f32)
- call ForGroup(gg,function hide)
- call t100(gg)
- call TriggerRegisterPlayerUnitEvent(tg,Player(12),EVENT_PLAYER_UNIT_DEATH,null)
- call TriggerAddCondition(tg,function f4)
- endfunction
- endlibrary
复制代码介绍:该刷野系统为每一个区域内的野怪死光后间隔一定时间复活该区域的野怪 非dota类刷野 无拉野
用法:在地图上摆放中立敌对生物即可 |
|
评分
-
查看全部评分
|