LUACN论坛

 找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
热搜: YJWOW MagicStone BoL

【Ni辅助保姆级入门教程】四、Ni辅助脚本编写实战

  [复制链接]
发表于 2024-6-18 09:08:45 | 显示全部楼层
本帖最后由 老爷们 于 2024-6-18 09:49 AM 编辑

好像可以了,我再试试!
好像是距离这个自定义函数导致乱射不能出来
-------------自定义函数区域-------------------
        local lastSpell, lastGuid, lastTime = "", "", 0
        local function FacingLosCast(spell, tar)
                if ni.player.isfacing(tar, 145) and ni.player.los(tar) and IsSpellInRange(spell, tar) == 1 then
                        ni.spell.cast(spell, tar)
                        ni.debug.log(string.format("Casting %s on %s", spell, tar))
                        lastSpell = spell
                        lastGuid = UnitGUID(tar)
                        lastTime = GetTime()
                        return true
                end
                return false
        end
        local function DoubleCast(spell, tar)
                        if(lastSpell == spell) then
                                if lastGuid == UnitGUID(tar) then
                                        if GetTime() - lastTime < 2 then
                                                return true
                                        end
                                end
                        end
                        return false
        end

        local function ValidUsable(id, tar)
                if ni.spell.available(id) and ni.spell.valid(tar, id, true, true) then
                        return true
                end
                return false
        end

        local function InRange(tar)
                local melee = IsSpellInRange(spells.MongooseBite.name, tar) == 1
                local ranged = IsSpellInRange(spells.ArcaneShot.name, tar) == 1
                if not melee and ranged then
                                return true;
                end
                return false
        end

        local function PetInRange(tar)
                if UnitExists("pet") then
                        if IsSpellInRange(spells.PetGrowl.name, "pettarget") then
                                return true
                        end
                end
                return false
        end

        local _petInRange = false
        local _playerInRange = false
       
        local abilities = {   --queue是依次运行的
               
                ["Volley"] = function()
                        if enables["乱射"] then
-- 获取目标周围8码范围内的怪物数量
                        local nearby = #ni.unit.enemiesinrange("target", 10)
-- 获取当前正在释放的引导类技能的名字(如果没有释放技能或不是引导类技能,n就是nil)
                        local n = UnitChannelInfo("player");
                        if n ~= spells.Volley.name
-- 当前没有在释放乱射
                        and ni.spell.available(spells.Volley.id)
-- 当前可以施放乱射技能
--把这句取消,乱射就能放出来了                        and _playerInRange
-- 目标在攻击范围内
                        and nearby >= values["乱射目标"] then
-- 目标周围的怪物数量大于或等于设置的数量
                        ni.spell.castat(spells.Volley.name, "target", 1)
                                return true
                        end
                end
        end,


回复 支持 反对

使用道具 举报

 楼主| 发表于 2024-6-18 09:48:31 | 显示全部楼层
老爷们 发表于 2024-6-18 09:08 AM
好像可以了,我再试试!

你的_playerInRange一直都没有赋值,一直都是false,肯定就没法释放技能了。改动两个位置:
[Lua] 纯文本查看 复制代码
local spells = {  --技能库
    --General
    --Marksmanship
    Volley = {id = 27022, name = GetSpellInfo(27022)},
    ArcaneShot = {id = 14287, name = GetSpellInfo(14287)},
    --Survival
    MongooseBite = {id = 14270, name = GetSpellInfo(14270)},
}

把ArcaneShot和MongooseBite两个技能加上(InRange函数要用)

[Lua] 纯文本查看 复制代码
local abilities = {
    ["Cache"] = function()
        _playerInRange = InRange("target")
    end,
    --queue是依次运行的
    ["Volley"] = function()
        if enables["乱射"] then
            local nearby = #ni.unit.enemiesinrange("target", 8)
            local n = UnitChannelInfo("player")
            if n ~= nil and n == spells.Volley.name
            and nearby >= values["乱射目标"] then
                return true
            end
                
            if ni.spell.available(spells.Volley.id)
            and _playerInRange
            and nearby >= values["乱射目标"] then
                ni.spell.castat(spells.Volley.name, "target", 1)
                return true
            end
        end
    end,
}

在判断乱射之前,先更新_playerInRange的状态
回复 支持 反对

使用道具 举报

发表于 2024-6-18 09:50:50 | 显示全部楼层
吾奶常煽赵子龙 发表于 2024-6-18 09:48 AM
你的_playerInRange一直都没有赋值,一直都是false,肯定就没法释放技能了。改动两个位置:
[mw_shl_cod ...

收到,我在测测!谢谢大佬指点!
回复 支持 反对

使用道具 举报

发表于 2024-6-18 20:51:27 | 显示全部楼层
比魔蜂要复杂好多,接着学习
回复 支持 反对

使用道具 举报

发表于 2024-6-20 09:50:25 | 显示全部楼层
我觉得楼主是一个帅气多G的好人。
回复 支持 反对

使用道具 举报

发表于 2024-6-22 10:05:38 | 显示全部楼层

感谢大佬指导~~~~感谢大佬指导~~~~
回复 支持 反对

使用道具 举报

发表于 2024-6-22 11:49:58 | 显示全部楼层
学习学习学习学习学习
回复 支持 反对

使用道具 举报

发表于 2024-6-23 15:09:59 | 显示全部楼层
hhhhhhhhhhhrtrrrrqqqqqqq
回复 支持 反对

使用道具 举报

发表于 2024-6-24 22:00:35 | 显示全部楼层
必须支持,这个好像很好用的样子
回复 支持 反对

使用道具 举报

发表于 2024-6-26 13:29:29 | 显示全部楼层
由魔蜂脚本改写的LR输出脚本。为了方便阅读,不会看懵 学习了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

小黑屋|手机版|Archiver|LUACN论坛

GMT+8, 2026-1-12 05:40 AM , Processed in 0.324152 second(s), 29 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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