找回密码
 立即注册
    查看: 8|回复: 0

    前端 脱机脚本

    [复制链接]

    326

    主题

    66

    回帖

    1466

    积分

    积分
    1466
    发表于 2025-2-16 07:44:02 | 显示全部楼层 |阅读模式

    1. function act(index,act)  -- 执行封包
    2.     local json = {
    3.         ["index"] = index,
    4.         ["Act"] = act
    5.     }
    6.     SendTableToServer(global.MsgType.MSG_CS_NPC_TASK_CLICK, json)
    7.    
    8. end


    9. local function acct(data)
    10.   if data == 2 then
    11.     play_act =  0
    12.   end
    13. end
    14. SL:RegisterLUAEvent(LUA_EVENT_PLAYER_BEHAVIOR_STATE_CAHNGE, "动作", acct)


    15. local function isTableEmpty(t)  -- 检测表的值是否为空
    16.     SL:print(tostring(next(t)))
    17.     return next(t) == nil
    18. end

    19. local storeItems = {"战神","死神"} --存储道具
    20. local hp_ini = 90   -- 50代表50%


    21. local function humanhp(human)
    22.     local now_hp = SL:GetMetaValue("HP")/SL:GetMetaValue("MAXHP")
    23.     if now_hp*1 < hp_ini/100 then
    24.         SL:print("使用疗伤药,人物!")
    25.         eatiteam("疗伤药",human)
    26.     end
    27.     if human == 2 then
    28.         eatiteam("疗伤药",human)
    29.     end
    30. end

    31. local function main()
    32.     SL:print("---------------当前状态"..current)
    33.     if not SL:GetMetaValue("BATTLE_IS_AFK") and SL:GetMetaValue("MAP_NAME") ~= "盟重省"   then
    34.         openAT()
    35.     end

    36.     if  SL:GetMetaValue("MAP_NAME") == "盟重省"   then
    37.         closeAT()
    38.         ssr.AutoMoveBegin(333,333, "3")  -- 自动寻路
    39.     end


    40.     humanhp(1)  -- 监控血量
    41.    
    42.     if  SL:GetMetaValue("USEHERO") and SL:GetMetaValue("MAP_NAME") == "盟重省"  then
    43.         SL:print("英雄ID",SL:GetMetaValue("HERO_ID"),SL:GetMetaValue("ACTOR_HP", SL:GetMetaValue("HERO_ID"))/SL:GetMetaValue("ACTOR_MAXHP", SL:GetMetaValue("HERO_ID")))
    44.         if SL:GetMetaValue("ACTOR_HP", SL:GetMetaValue("HERO_ID"))/SL:GetMetaValue("ACTOR_MAXHP", SL:GetMetaValue("HERO_ID")) > 0.8 then
    45.         else
    46.             humanhp(2)  -- 英雄加血
    47.             send("等待英雄满血80%")
    48.             return
    49.         end
    50.         
    51.     end
    52.     play_act = play_act or 0
    53.     num = num or 0
    54.     num = num + 1
    55.     play_act = play_act + 1
    56.   
    57.     if play_act > 10 then
    58.         useitem("盟重传送石")
    59.         play_act = 0   --  重新开始
    60.     end

    61.     SL:print("开启!"..num.."状态"..play_act)
    62.     -- checkbag()  ---- 仓库存储!! 打开仓库权限!
    63.     local player_map = SL:GetMetaValue("MAP_NAME")
    64.     local player_x = SL:GetMetaValue("ACTOR_MAP_X", player)
    65.     local player_y = SL:GetMetaValue("ACTOR_MAP_Y", player)
    66.    
    67.     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
    68.         sendnpc(40)
    69.         act(40,"@Boss皇宫")
    70.     end
    71.    
    72.     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
    73.         sendnpc(40)
    74.         act(40,"@地下皇陵")
    75.     end
    76.     if player_map == "BOSS皇宫" then
    77.        local mon_list = SL:GetMetaValue("FIND_IN_VIEW_MONSTER_LIST")
    78.         SL:dump(mon_list,"",5)
    79.         if isTableEmpty(mon_list) then
    80.             SL:print("一层没有怪物了,撤退!")
    81.             -- useitem("盟重传送石")
    82.             current = 1
    83.             if current == 1 then
    84.                 sendnpc(46)
    85.                 act(46,"@go")
    86.    
    87.                 -- 设置状态 下个地图
    88.                 -- 回城存储装备
    89.             end
    90.         else
    91.             SL:print("一层还有怪物!")
    92.         end
    93.     end
    94.    
    95.     if player_map == "BOSS皇宫二层" then
    96.         local mon_list2 = SL:GetMetaValue("FIND_IN_VIEW_MONSTER_LIST")
    97.         SL:dump(mon_list2,"",5)
    98.         if isTableEmpty(mon_list2) then
    99.             SL:print("第二层没有怪物了,撤退!")
    100.             useitem("盟重传送石")
    101.             current = 2
    102.             -- 设置状态 下个地图
    103.             -- 回城存储装备
    104.         else
    105.             SL:print("二层还有怪物!")
    106.         end
    107.     end
    108.     if player_map == "地下皇陵一层" then
    109.         map_3 = map_3 or 0
    110.         map_3 = map_3 + 1

    111.        local  mon_list3 = SL:GetMetaValue("FIND_IN_VIEW_MONSTER_LIST")
    112.         SL:dump(mon_list3)
    113.         if isTableEmpty(mon_list3) then
    114.             useitem("随机传送石")
    115.         end


    116.     end
    117.    
    118.    
    119.    
    120. end

    121. function checkbag()  -- 查看背包的物品数据!
    122.     local bagItems = SL:GetMetaValue("BAG_DATA")
    123.     for k,v in pairs(bagItems) do
    124.         for i=1 ,#storeItems do
    125.             
    126.             if string.find(v["Name"],storeItems[i]) then
    127.                 -- send("存储"..v["Name"])
    128.                 global.Facade:sendNotification(global.NoticeTable.Layer_NPC_Storage_Open)  -- 底层命令!
    129.                 SL:RequestSaveItemToNpcStorage({ MakeIndex =   v.MakeIndex ,      Name = v["Name"]
    130.             }, 1)
    131.         end
    132.     end
    133. end
    134. end


    135. function sendnpc(id)  -- 打开NPC
    136.     local sendData = {
    137.         index = id,
    138.     }
    139.     SendTableToServer(global.MsgType.MSG_CS_NPC_CLICK, sendData)
    140. end

    141. function send(msg)  -- 发送消息
    142.     local mdata = {
    143.         Type = 13,
    144.         Msg  = msg,
    145.         y = 255,
    146.         FColor= 255,
    147.         BColor  = 0,
    148.         X  = 255,
    149.         Y  = 500,
    150.         Time  = 1,
    151.         Count = 1
    152.     }
    153.     SL:ShowLocalNoticeByType(mdata)
    154. end

    155. function eatiteam(itemname,human)    -- 背包发现疗伤药
    156.     getitemindx =   SL:GetMetaValue("ITEM_INDEX_BY_NAME", itemname)
    157.     haveitem = 0
    158.     hero_haveitem =0
    159.     getbaglist_1 = SL:GetMetaValue("BAG_DATA")
    160.     getbaglist_2 = SL:GetMetaValue("QUICKUSE_DATA")
    161.     getbaglist_hero = SL:GetMetaValue("H.BAG_DATA")
    162.     if human == 1 then
    163.         for k,v in pairs(getbaglist_1) do
    164.             if v.Index*1 == getitemindx*1 then
    165.                 SL:print("背包发现疗伤药!")
    166.                 haveitem = 1
    167.             end
    168.         end
    169.         for k,v in pairs(getbaglist_2) do
    170.             SL:print(v.Index*1,getitemindx*1)
    171.             if v.Index*1 == getitemindx*1 then
    172.                 SL:print("快捷发现疗伤药!")
    173.                 haveitem = 1
    174.             end
    175.         end
    176.         if haveitem == 1 then
    177.             SL:UseItemByIndex(getitemindx)
    178.         else
    179.             send("缺少疗伤药")
    180.         end
    181.         
    182.     end
    183.    
    184. end



    185. function useitem(itemname)    -- 使用回城石
    186.     getitemindx =   SL:GetMetaValue("ITEM_INDEX_BY_NAME", itemname)
    187.     haveitem = 0
    188.     getbaglist_1 = SL:GetMetaValue("BAG_DATA")
    189.     getbaglist_2 = SL:GetMetaValue("QUICKUSE_DATA")
    190.     for k,v in pairs(getbaglist_1) do
    191.         if v.Index*1 == getitemindx*1 then
    192.             SL:print("--------",v.Index*1,getitemindx*1)
    193.             haveitem = 1
    194.         end
    195.     end
    196.     for k,v in pairs(getbaglist_2) do
    197.         SL:print(v.Index*1,getitemindx*1)
    198.         if v.Index*1 == getitemindx*1 then
    199.             SL:print("快捷发现!"..itemname)
    200.             haveitem = 1
    201.         end
    202.     end
    203.     if haveitem == 1 then
    204.         local player_map = SL:GetMetaValue("MAP_NAME")
    205.         local player_x = SL:GetMetaValue("ACTOR_MAP_X", player)
    206.         local player_y = SL:GetMetaValue("ACTOR_MAP_Y", player)
    207.         
    208.         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
    209.         else
    210.             SL:UseItemByIndex(getitemindx)
    211.         end
    212.         
    213.         
    214.     else
    215.         send(itemname.."没有了,手动购买")
    216.     end
    217. end

    218. function closeAT()
    219.     SL:SetMetaValue("BATTLE_AFK_END")
    220. end

    221. function openAT()
    222.     SL:SetMetaValue("BATTLE_AFK_BEGIN")
    223. end

    224. local function shortcutKeys()
    225.    
    226.     if afkStatus then
    227.         closeAT()
    228.         afkStatus = nil
    229.         SL:Print("关闭循环")
    230.         SL:UnSchedule(timer1)
    231.         -- ssr.AutoMoveBegin(333,333, "3")  -- 自动寻路
    232.         -- 回城初始化
    233.         -- 开启定时器  -- 判断血量 回血  -- 发现等级装备大于43 自动存储装备
    234.         -- 开始下地图 发现没有怪物 进入下一个地图
    235.     else
    236.         num = 0
    237.         player = SL:GetMetaValue("MAIN_ACTOR_ID")
    238.         player_map = SL:GetMetaValue("MAP_NAME")
    239.         player_x = SL:GetMetaValue("ACTOR_MAP_X", player)
    240.         player_y = SL:GetMetaValue("ACTOR_MAP_Y", player)
    241.         if player_map ~= "盟重省" then
    242.             useitem("盟重传送石")
    243.         end
    244.         current = 0
    245.         afkStatus = true
    246.         SL:Print("开启循环")
    247.         timer1 =  SL:Schedule(main, 3)
    248.         
    249.     end
    250.    
    251. end

    252. GUI:addKeyboardEvent("KEY_F7", pressedCB, shortcutKeys)


    253. -- getMons = SL:GetMetaValue("MAP_GET_MONSTERS")

    254. -- SL:dump(getMons,"----",5)

    255. -- SL:SetMetaValue("BATTLE_MOVE_BEGIN", 0, 400, 300, target, type)

    256. -- table2 = {mapID = 3, x = 400, y = 300}
    257. -- SL:onLUAEvent(LUA_EVENT_AUTOMOVEBEGIN, table2)


    258. -- SL:SetMetaValue("BATTLE_AFK_BEGIN") --- 执行
    259. -- SL:SetMetaValue("BATTLE_MOVE_BEGIN", "3", 333, 333, {type=0,index=1}, type)
    260. -- local movePos =    {
    261. --     mapID = 3,
    262. --     x    = 333,
    263. --     y    = 333,
    264. --     autoMoveType = 0
    265. -- }
    266. -- global.Facade:sendNotification(global.NoticeTable.AutoMoveBegin, movePos)
    267. -- local movePos =    {
    268. --     mapID = 3,
    269. --     x    = 333,
    270. --     y    = 333,
    271. --     autoMoveType = 0 or global.MMO.AUTO_MOVE_TYPE_MINIMAP
    272. -- }
    273. -- global.Facade:sendNotification(global.NoticeTable.AutoMoveBegin, movePos)




    274. -- local function onRefAttr22()
    275. --     local  list =
    276. --     {
    277. --         ["go"] = "LUA_EVENT_AUTOMOVEBEGIN",
    278. --         ["stop"] = "LUA_EVENT_AFKBEGIN"
    279. --     }
    280. --     p1 = SL:GetMetaValue("MAP_ID")
    281. --     SL:onLUAEvent(list["go"], {mapID = p1, x = 40, y = 715})  --- 注册


    282. -- end
    283. -- SL:RegisterLUAEvent(LUA_EVENT_AUTOMOVEBEGIN, "自动行走", onRefAttr22)  -- 触发



    284. -- local function aotuwalk(data)
    285. --     SL:print("自动寻走进入!")
    286. --     -- SL:SetMetaValue("BATTLE_MOVE_BEGIN", "0", 400, 300, {type=0,index=121}, 0)

    287. -- end
    288. -- SL:RegisterLUAEvent(LUA_EVENT_AUTOMOVEBEGIN, "自动寻走", aotuwalk)


    289. -- local json = {
    290. --     ["index"] = 121,
    291. --     ["Act"] = "@野外传送#地图名=石墓一层#地图=D710#坐标x=29#坐标y=20#范围=3"
    292. -- }
    293. -- SL:print("发包",index,act)
    294. -- SendTableToServer(global.MsgType.MSG_CS_NPC_TASK_CLICK, json)


    295. -- local monsters = SL:GetMetaValue("FIND_IN_VIEW_PLAYER_LIST")

    296. -- SL:dump(monsters,"-===",5)

    297. -- function sendmsg(str)
    298. --     SL:ShowSystemTips(str)
    299. -- end



    300. -- SL:dump(bagItems,"提示:",5)
    301. -- end

    302. -- if not SL:GetMetaValue("BATTLE_IS_AFK") then
    303. --     if win then
    304. --         GUI:removeAllChildren(win)
    305. --     end
    306. --     local win = GUI:Win_Create("Win_1", 0, 0, 0, 0)
    307. --     GUI:LoadExport(win, "btt")
    308. --     ui = GUI:ui_delegate(win)
    309. -- else
    310. --     ---  遍历背包的物品
    311. --     ---  如果发现有存储的选项  那么存储到仓库中!
    312. --     checkbag()
    313. -- end
    314. -- if ui.Button then
    315. --     GUI:addOnClickEvent(ui.Button, function()
    316. --         SL:SetMetaValue(const["结束挂机"])
    317. --         SL:print("--------------------",GUI:getTag(ui.Button))
    318. --         if GUI:getTag(ui.Button) == -1 then
    319. --             GUI:Button_loadTextures(ui.Button, "res/public/icon_fubentg_03_1.png", nil, nil, 0)
    320. --             GUI:setTag(ui.Button,1)
    321. --             SL:SetMetaValue(const["开始挂机"])
    322. --             sendmsg("开始挂机")

    323. --         else
    324. --             SL:SetMetaValue(const["结束挂机"])
    325. --             GUI:Button_loadTextures(ui.Button, "res/public/icon_fubentg_03.png", nil, nil, 0)
    326. --             GUI:setTag(ui.Button,-1)
    327. --             sendmsg("结束挂机")
    328. --             SL:SetMetaValue("BATTLE_AFK_END")
    329. --         end
    330. --     end)
    331. -- end
    332. -- --


    333. -- function main()  -- 开始巡航页面!
    334. --     if win then
    335. --         GUI:removeAllChildren(win)
    336. --     end
    337. --     local win = GUI:Win_Create("Win_1", 0, 0, 1136, 640)  

    338. --     GUI:LoadExport(win, "main")
    339. --     ui = GUI:ui_delegate(win)
    340. --     if ui.Button1 then
    341. --         GUI:addOnClickEvent(ui.Button1, function()
    342. --             SL:SetMetaValue(const["开始挂机"])
    343. --             -- SL:onLUAEvent(LUA_EVENT_AFKBEGIN)  -- 引擎!~
    344. --             -- state = 1
    345. --             -- SL:SetMetaValue(const["开始挂机"])
    346. --         end)
    347. --     end
    348. --     if ui.Button2 then
    349. --         GUI:addOnClickEvent(ui.Button2, function()
    350. --             SL:print("结束循环")
    351. --             SL:SetMetaValue(const["结束挂机"])
    352. --         end)
    353. --     end

    354. -- end
    复制代码


    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则