|
- function act(index,act) -- 执行封包
- local json = {
- ["index"] = index,
- ["Act"] = act
- }
- SendTableToServer(global.MsgType.MSG_CS_NPC_TASK_CLICK, json)
-
- end
- local function acct(data)
- if data == 2 then
- play_act = 0
- end
- end
- SL:RegisterLUAEvent(LUA_EVENT_PLAYER_BEHAVIOR_STATE_CAHNGE, "动作", acct)
- local function isTableEmpty(t) -- 检测表的值是否为空
- SL:print(tostring(next(t)))
- return next(t) == nil
- end
- local storeItems = {"战神","死神"} --存储道具
- local hp_ini = 90 -- 50代表50%
- local function humanhp(human)
- local now_hp = SL:GetMetaValue("HP")/SL:GetMetaValue("MAXHP")
- if now_hp*1 < hp_ini/100 then
- SL:print("使用疗伤药,人物!")
- eatiteam("疗伤药",human)
- end
- if human == 2 then
- eatiteam("疗伤药",human)
- end
- end
- local function main()
- SL:print("---------------当前状态"..current)
- if not SL:GetMetaValue("BATTLE_IS_AFK") and SL:GetMetaValue("MAP_NAME") ~= "盟重省" then
- openAT()
- end
- if SL:GetMetaValue("MAP_NAME") == "盟重省" then
- closeAT()
- ssr.AutoMoveBegin(333,333, "3") -- 自动寻路
- end
- humanhp(1) -- 监控血量
-
- if SL:GetMetaValue("USEHERO") and SL:GetMetaValue("MAP_NAME") == "盟重省" then
- SL:print("英雄ID",SL:GetMetaValue("HERO_ID"),SL:GetMetaValue("ACTOR_HP", SL:GetMetaValue("HERO_ID"))/SL:GetMetaValue("ACTOR_MAXHP", SL:GetMetaValue("HERO_ID")))
- if SL:GetMetaValue("ACTOR_HP", SL:GetMetaValue("HERO_ID"))/SL:GetMetaValue("ACTOR_MAXHP", SL:GetMetaValue("HERO_ID")) > 0.8 then
- else
- humanhp(2) -- 英雄加血
- send("等待英雄满血80%")
- return
- end
-
- end
- play_act = play_act or 0
- num = num or 0
- num = num + 1
- play_act = play_act + 1
-
- if play_act > 10 then
- useitem("盟重传送石")
- play_act = 0 -- 重新开始
- end
- SL:print("开启!"..num.."状态"..play_act)
- -- checkbag() ---- 仓库存储!! 打开仓库权限!
- local player_map = SL:GetMetaValue("MAP_NAME")
- local player_x = SL:GetMetaValue("ACTOR_MAP_X", player)
- local player_y = SL:GetMetaValue("ACTOR_MAP_Y", player)
-
- if current == 0 and player_map == "盟重省" and math.abs(SL:GetMetaValue("ACTOR_MAP_X", player)-333) < 10 and math.abs(SL:GetMetaValue("ACTOR_MAP_Y", player)-333) < 10 then
- sendnpc(40)
- act(40,"@Boss皇宫")
- end
-
- if current == 2 and player_map == "盟重省" and math.abs(SL:GetMetaValue("ACTOR_MAP_X", player)-333) < 10 and math.abs(SL:GetMetaValue("ACTOR_MAP_Y", player)-333) < 10 then
- sendnpc(40)
- act(40,"@地下皇陵")
- end
- if player_map == "BOSS皇宫" then
- local mon_list = SL:GetMetaValue("FIND_IN_VIEW_MONSTER_LIST")
- SL:dump(mon_list,"",5)
- if isTableEmpty(mon_list) then
- SL:print("一层没有怪物了,撤退!")
- -- useitem("盟重传送石")
- current = 1
- if current == 1 then
- sendnpc(46)
- act(46,"@go")
-
- -- 设置状态 下个地图
- -- 回城存储装备
- end
- else
- SL:print("一层还有怪物!")
- end
- end
-
- if player_map == "BOSS皇宫二层" then
- local mon_list2 = SL:GetMetaValue("FIND_IN_VIEW_MONSTER_LIST")
- SL:dump(mon_list2,"",5)
- if isTableEmpty(mon_list2) then
- SL:print("第二层没有怪物了,撤退!")
- useitem("盟重传送石")
- current = 2
- -- 设置状态 下个地图
- -- 回城存储装备
- else
- SL:print("二层还有怪物!")
- end
- end
- if player_map == "地下皇陵一层" then
- map_3 = map_3 or 0
- map_3 = map_3 + 1
- local mon_list3 = SL:GetMetaValue("FIND_IN_VIEW_MONSTER_LIST")
- SL:dump(mon_list3)
- if isTableEmpty(mon_list3) then
- useitem("随机传送石")
- end
- end
-
-
-
- end
- function checkbag() -- 查看背包的物品数据!
- local bagItems = SL:GetMetaValue("BAG_DATA")
- for k,v in pairs(bagItems) do
- for i=1 ,#storeItems do
-
- if string.find(v["Name"],storeItems[i]) then
- -- send("存储"..v["Name"])
- global.Facade:sendNotification(global.NoticeTable.Layer_NPC_Storage_Open) -- 底层命令!
- SL:RequestSaveItemToNpcStorage({ MakeIndex = v.MakeIndex , Name = v["Name"]
- }, 1)
- end
- end
- end
- end
- function sendnpc(id) -- 打开NPC
- local sendData = {
- index = id,
- }
- SendTableToServer(global.MsgType.MSG_CS_NPC_CLICK, sendData)
- end
- function send(msg) -- 发送消息
- local mdata = {
- Type = 13,
- Msg = msg,
- y = 255,
- FColor= 255,
- BColor = 0,
- X = 255,
- Y = 500,
- Time = 1,
- Count = 1
- }
- SL:ShowLocalNoticeByType(mdata)
- end
- function eatiteam(itemname,human) -- 背包发现疗伤药
- getitemindx = SL:GetMetaValue("ITEM_INDEX_BY_NAME", itemname)
- haveitem = 0
- hero_haveitem =0
- getbaglist_1 = SL:GetMetaValue("BAG_DATA")
- getbaglist_2 = SL:GetMetaValue("QUICKUSE_DATA")
- getbaglist_hero = SL:GetMetaValue("H.BAG_DATA")
- if human == 1 then
- for k,v in pairs(getbaglist_1) do
- if v.Index*1 == getitemindx*1 then
- SL:print("背包发现疗伤药!")
- haveitem = 1
- end
- end
- for k,v in pairs(getbaglist_2) do
- SL:print(v.Index*1,getitemindx*1)
- if v.Index*1 == getitemindx*1 then
- SL:print("快捷发现疗伤药!")
- haveitem = 1
- end
- end
- if haveitem == 1 then
- SL:UseItemByIndex(getitemindx)
- else
- send("缺少疗伤药")
- end
-
- end
-
- end
- function useitem(itemname) -- 使用回城石
- getitemindx = SL:GetMetaValue("ITEM_INDEX_BY_NAME", itemname)
- haveitem = 0
- getbaglist_1 = SL:GetMetaValue("BAG_DATA")
- getbaglist_2 = SL:GetMetaValue("QUICKUSE_DATA")
- for k,v in pairs(getbaglist_1) do
- if v.Index*1 == getitemindx*1 then
- SL:print("--------",v.Index*1,getitemindx*1)
- haveitem = 1
- end
- end
- for k,v in pairs(getbaglist_2) do
- SL:print(v.Index*1,getitemindx*1)
- if v.Index*1 == getitemindx*1 then
- SL:print("快捷发现!"..itemname)
- haveitem = 1
- end
- end
- if haveitem == 1 then
- local player_map = SL:GetMetaValue("MAP_NAME")
- local player_x = SL:GetMetaValue("ACTOR_MAP_X", player)
- local player_y = SL:GetMetaValue("ACTOR_MAP_Y", player)
-
- if player_map == "盟重省" and math.abs(SL:GetMetaValue("ACTOR_MAP_X", player)-333) < 10 and math.abs(SL:GetMetaValue("ACTOR_MAP_Y", player)-333) < 10 then
- else
- SL:UseItemByIndex(getitemindx)
- end
-
-
- else
- send(itemname.."没有了,手动购买")
- end
- end
- function closeAT()
- SL:SetMetaValue("BATTLE_AFK_END")
- end
- function openAT()
- SL:SetMetaValue("BATTLE_AFK_BEGIN")
- end
- local function shortcutKeys()
-
- if afkStatus then
- closeAT()
- afkStatus = nil
- SL:Print("关闭循环")
- SL:UnSchedule(timer1)
- -- ssr.AutoMoveBegin(333,333, "3") -- 自动寻路
- -- 回城初始化
- -- 开启定时器 -- 判断血量 回血 -- 发现等级装备大于43 自动存储装备
- -- 开始下地图 发现没有怪物 进入下一个地图
- else
- num = 0
- player = SL:GetMetaValue("MAIN_ACTOR_ID")
- player_map = SL:GetMetaValue("MAP_NAME")
- player_x = SL:GetMetaValue("ACTOR_MAP_X", player)
- player_y = SL:GetMetaValue("ACTOR_MAP_Y", player)
- if player_map ~= "盟重省" then
- useitem("盟重传送石")
- end
- current = 0
- afkStatus = true
- SL:Print("开启循环")
- timer1 = SL:Schedule(main, 3)
-
- end
-
- end
- GUI:addKeyboardEvent("KEY_F7", pressedCB, shortcutKeys)
- -- getMons = SL:GetMetaValue("MAP_GET_MONSTERS")
- -- SL:dump(getMons,"----",5)
- -- SL:SetMetaValue("BATTLE_MOVE_BEGIN", 0, 400, 300, target, type)
- -- table2 = {mapID = 3, x = 400, y = 300}
- -- SL:onLUAEvent(LUA_EVENT_AUTOMOVEBEGIN, table2)
- -- SL:SetMetaValue("BATTLE_AFK_BEGIN") --- 执行
- -- SL:SetMetaValue("BATTLE_MOVE_BEGIN", "3", 333, 333, {type=0,index=1}, type)
- -- local movePos = {
- -- mapID = 3,
- -- x = 333,
- -- y = 333,
- -- autoMoveType = 0
- -- }
- -- global.Facade:sendNotification(global.NoticeTable.AutoMoveBegin, movePos)
- -- local movePos = {
- -- mapID = 3,
- -- x = 333,
- -- y = 333,
- -- autoMoveType = 0 or global.MMO.AUTO_MOVE_TYPE_MINIMAP
- -- }
- -- global.Facade:sendNotification(global.NoticeTable.AutoMoveBegin, movePos)
- -- local function onRefAttr22()
- -- local list =
- -- {
- -- ["go"] = "LUA_EVENT_AUTOMOVEBEGIN",
- -- ["stop"] = "LUA_EVENT_AFKBEGIN"
- -- }
- -- p1 = SL:GetMetaValue("MAP_ID")
- -- SL:onLUAEvent(list["go"], {mapID = p1, x = 40, y = 715}) --- 注册
- -- end
- -- SL:RegisterLUAEvent(LUA_EVENT_AUTOMOVEBEGIN, "自动行走", onRefAttr22) -- 触发
- -- local function aotuwalk(data)
- -- SL:print("自动寻走进入!")
- -- -- SL:SetMetaValue("BATTLE_MOVE_BEGIN", "0", 400, 300, {type=0,index=121}, 0)
- -- end
- -- SL:RegisterLUAEvent(LUA_EVENT_AUTOMOVEBEGIN, "自动寻走", aotuwalk)
- -- local json = {
- -- ["index"] = 121,
- -- ["Act"] = "@野外传送#地图名=石墓一层#地图=D710#坐标x=29#坐标y=20#范围=3"
- -- }
- -- SL:print("发包",index,act)
- -- SendTableToServer(global.MsgType.MSG_CS_NPC_TASK_CLICK, json)
- -- local monsters = SL:GetMetaValue("FIND_IN_VIEW_PLAYER_LIST")
- -- SL:dump(monsters,"-===",5)
- -- function sendmsg(str)
- -- SL:ShowSystemTips(str)
- -- end
- -- SL:dump(bagItems,"提示:",5)
- -- end
- -- if not SL:GetMetaValue("BATTLE_IS_AFK") then
- -- if win then
- -- GUI:removeAllChildren(win)
- -- end
- -- local win = GUI:Win_Create("Win_1", 0, 0, 0, 0)
- -- GUI:LoadExport(win, "btt")
- -- ui = GUI:ui_delegate(win)
- -- else
- -- --- 遍历背包的物品
- -- --- 如果发现有存储的选项 那么存储到仓库中!
- -- checkbag()
- -- end
- -- if ui.Button then
- -- GUI:addOnClickEvent(ui.Button, function()
- -- SL:SetMetaValue(const["结束挂机"])
- -- SL:print("--------------------",GUI:getTag(ui.Button))
- -- if GUI:getTag(ui.Button) == -1 then
- -- GUI:Button_loadTextures(ui.Button, "res/public/icon_fubentg_03_1.png", nil, nil, 0)
- -- GUI:setTag(ui.Button,1)
- -- SL:SetMetaValue(const["开始挂机"])
- -- sendmsg("开始挂机")
- -- else
- -- SL:SetMetaValue(const["结束挂机"])
- -- GUI:Button_loadTextures(ui.Button, "res/public/icon_fubentg_03.png", nil, nil, 0)
- -- GUI:setTag(ui.Button,-1)
- -- sendmsg("结束挂机")
- -- SL:SetMetaValue("BATTLE_AFK_END")
- -- end
- -- end)
- -- end
- -- --
- -- function main() -- 开始巡航页面!
- -- if win then
- -- GUI:removeAllChildren(win)
- -- end
- -- local win = GUI:Win_Create("Win_1", 0, 0, 1136, 640)
- -- GUI:LoadExport(win, "main")
- -- ui = GUI:ui_delegate(win)
- -- if ui.Button1 then
- -- GUI:addOnClickEvent(ui.Button1, function()
- -- SL:SetMetaValue(const["开始挂机"])
- -- -- SL:onLUAEvent(LUA_EVENT_AFKBEGIN) -- 引擎!~
- -- -- state = 1
- -- -- SL:SetMetaValue(const["开始挂机"])
- -- end)
- -- end
- -- if ui.Button2 then
- -- GUI:addOnClickEvent(ui.Button2, function()
- -- SL:print("结束循环")
- -- SL:SetMetaValue(const["结束挂机"])
- -- end)
- -- end
- -- end
复制代码
|
|