可以参考我的一个跟随脚本的逻辑片段:
[Lua] 纯文本查看 复制代码
local followUnit = nil;
-- 要跟随的固定角色名字,没有就配置为空
local followPlayerName = "妖·蓝玉";
-- 尝试查找指定目标
if followPlayerName ~= "" then
RunMacroText("/cleartarget\n/target " .. followPlayerName);
if UnitName("target") == followPlayerName and BeeRange("target") <= 30 then
followUnit = "target";
else
RunMacroText("/cleartarget");
end
end
-- 没有特定目标时,在队伍中随机选择一个玩家
if followUnit == nil then
local partyCount = GetNumPartyMembers();
for i = 1, partyCount, 1 do
local range = BeeRange("party" .. i);
if range <= 30 then
followUnit = "party" .. i;
end
end
end
-- 有跟随目标则开始跟随
if followUnit then
FollowUnit(followUnit);
end
|