一.背景
最近在学习饥荒源码,发现饥荒客机的权限非常高,现有的禁止本地方法似乎非常的好破解,自己尝试了一下居然成功了,在此记录一下自己的思路。
二.引言
绕本地是基于修改服务器模组内容实现的,因为饥荒的服务器模组实际上是运行在客机的,修改即可实现夹带私货,服务器模组内容一般在C:\Program Files (x86)\Steam\steamapps\workshop\content\322330下
三.模组禁止本地
特点
服务器模组有禁止本地mod或禁止特定mod的模组
禁本地原理
定时检查玩家是打开了了鹰眼夜视开关,然后关闭
绕本地思路
比如禁本地mod id为xxx,则清空C:\Program Files (x86)\Steam\steamapps\workshop\content\322330\XXX\modmain.lua里的内容(清空内容,文件别删)
四.官方的禁本地
特点
进房间会提示
禁本地原理
在modoverrides.lua文件加client_mods_disabled=true或者用 游戏内主菜单 模组 去实现官方禁止本地
绕本地思路
在服务器上开任意的服务器模组(比如全球定位,showme,自动堆叠等)追加一些代码
比如全球定位模组id为xxx,打开C:\Program Files (x86)\Steam\steamapps\workshop\content\322330\XXX\modmain.lua
在尾部追加一些代码(见附录),最后三行代码,keysF[1]代表F1开启鹰眼,keysF[2]代表F1开启夜视,keysF[9]代表F9开启大视野,想改键自己改代码即可
五.注意事项
粘贴后出现橙色的框代表有问题,你要去掉这些橙色的框
删除从CSDN上粘贴自带的水印
六.附录
local obc_eagleMode = 0
-- 0 : 默认
-- 1 :高空
-- 2 :鹰眼
local nightsightMode = false
local lastFov = 35
local CIRCLE_STATE = nil
local G = GLOBAL
local showTip = false
local function TIP(stat, green, content)
if showTip then
if green then
G.ThePlayer.HUD.controls.networkchatqueue:PushMessage(stat, content, {0.196, 0.804, 0.196, 1})
else
G.ThePlayer.HUD.controls.networkchatqueue:PushMessage(stat, content, {1, 0.388, 0.278, 1})
end
end
end
local function MakeCircle(inst, n, scale)
local circle = G.CreateEntity()
circle.entity:SetCanSleep(false)
circle.persists = false
circle.entity:AddTransform()
circle.entity:AddAnimState()
circle:AddTag("CLASSIFIED")
circle:AddTag("NOCLICK")
circle:AddTag("placer")
circle.Transform:SetRotation(n)
-- 大小
circle.Transform:SetScale(scale, scale, scale)
circle.AnimState:SetBank("firefighter_placement")
circle.AnimState:SetBuild("firefighter_placement")
circle.AnimState:PlayAnimation("idle")
circle.AnimState:SetLightOverride(1)
circle.AnimState:SetOrientation(G.ANIM_ORIENTATION.OnGround)
circle.AnimState:SetLayer(G.LAYER_BACKGROUND)
circle.AnimState:SetSortOrder(3.1)
-- 颜色
circle.AnimState:SetAddColour(0, 255, 0, 0)
circle.entity:SetParent(inst.entity)
return circle
end
local function IsDefaultScreen()
local screen = GLOBAL.TheFrontEnd:GetActiveScreen()
local screenName = screen and screen.name or ""
return screenName:find("HUD") ~= nil and GLOBAL.ThePlayer ~= nil
end
local function SetCamera(zoomstep, mindist, maxdist, mindistpitch, maxdistpitch, distance, distancetarget)
if GLOBAL.TheCamera ~= nil then
local camera = GLOBAL.TheCamera
camera.zoomstep = zoomstep or camera.zoomstep
camera.mindist = mindist or camera.mindist
camera.maxdist = maxdist or camera.maxdist
camera.mindistpitch = mindistpitch or camera.mindistpitch
camera.maxdistpitch = maxdistpitch or camera.maxdistpitch
camera.distance = distance or camera.distance
camera.distancetarget = distancetarget or camera.distancetarget
end
end
local function SetDefaultView()
if GLOBAL.TheWorld ~= nil then
if GLOBAL.TheWorld:HasTag("cave") then
SetCamera(4, 15, 35, 25, 40, 25, 25)
else
SetCamera(4, 15, 50, 30, 60, 30, 30)
end
end
end
local function SetAerialView()
if GLOBAL.TheWorld ~= nil then
if GLOBAL.TheWorld:HasTag("cave") then
SetCamera(10, 10, 180, 25, 40, 80, 80)
else
SetCamera(10, 10, 180, 30, 60, 80, 80)
end
end
end
function SetVerticalView()
if GLOBAL.TheWorld ~= nil then
if GLOBAL.TheWorld:HasTag("cave") then
SetCamera(10, 10, 180, 90, 90, 80, 80)
else
SetCamera(10, 10, 180, 90, 90, 80, 80)
end
end
end
-- 鹰眼
local function EagleViewMode()
local player = G.ThePlayer
if IsDefaultScreen() then
if (obc_eagleMode == 0) then
obc_eagleMode = 2
lastFov = GLOBAL.TheCamera.fov
SetVerticalView()
GLOBAL.TheCamera.fov = 165
-- 画圆
CIRCLE_STATE = {}
table.insert(CIRCLE_STATE, MakeCircle(player, 0, 2))
table.insert(CIRCLE_STATE, MakeCircle(player, 2, 2))
TIP("视角", false, "鹰眼")
elseif (obc_eagleMode == 1) then
obc_eagleMode = 2
lastFov = GLOBAL.TheCamera.fov
SetVerticalView()
GLOBAL.TheCamera.fov = 165
-- 画圆
CIRCLE_STATE = {}
table.insert(CIRCLE_STATE, MakeCircle(player, 0, 2))
table.insert(CIRCLE_STATE, MakeCircle(player, 2, 2))
TIP("视角", false, "鹰眼")
else
obc_eagleMode = 1
SetAerialView()
GLOBAL.TheCamera.fov = lastFov
-- 画圆
for _,circle in pairs(CIRCLE_STATE) do circle:Remove() end
CIRCLE_STATE = nil
TIP("视角", true, "大视野")
end
end
end
-- 大视野
local function BigViewMode()
local player = G.ThePlayer
if IsDefaultScreen() then
if (obc_eagleMode == 0) then
obc_eagleMode = 1
SetAerialView()
GLOBAL.TheCamera.fov = lastFov
TIP("视角", true, "大视野")
else
obc_eagleMode = 0
SetDefaultView()
GLOBAL.TheCamera.fov = lastFov
TIP("视角", true, "标准")
end
end
end
-- 智能夜视
local function TurnOnNightVision(player)
player.light = player.entity:AddLight()
player.light:SetFalloff(0.5)
player.light:SetIntensity(player.lightx)
player.light:SetRadius(10^4)
player.light:SetColour(255/255, 225/255, 255/255)
player.light:Enable(true)
player:DoTaskInTime(1, function() TIP("提示", true, "夜晚到来, 请准备光源") end)
end
local function TurnOffNightVision(player)
player.light = player.entity:AddLight()
player.light:SetFalloff(0.5)
player.light:SetIntensity(0)
player.light:SetRadius(0)
player.light:SetColour(255/255, 225/255, 255/255)
player.light:Enable(false)
end
local function TurnOffDelay(player)
player:DoTaskInTime(5, function() TurnOffNightVision(player) end)
end
local function NightSight()
if GLOBAL.ThePlayer and not GLOBAL.ThePlayer.HUD:IsChatInputScreenOpen() and not GLOBAL.ThePlayer.HUD:IsConsoleScreenOpen() and not GLOBAL.ThePlayer.HUD.writeablescreen then
local player = G.ThePlayer
nightsightMode = not nightsightMode
if nightsightMode then
player.lightx = player.lightx or 1
player:WatchWorldState("startday",TurnOffDelay)
player:WatchWorldState("startnight",TurnOnNightVision)
if G.TheWorld.state.isday or G.TheWorld.state.isdusk then
TIP("开启", true, "智能夜视已开启, 夜晚将会自动启用")
else
TIP("开启", true, "智能夜视已开启")
TurnOnNightVision(player)
end
else
if G.TheWorld.state.isnight then
TurnOffNightVision(player)
end
player:WatchWorldState("startnight",TurnOffNightVision)
TIP("关闭", false, "智能夜视已关闭")
end
end
end
local keys2 = {
"F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11",
}
local keysF = {}
local keyslist_F = {}
for i=1, #keys2 do
keyslist_F[i] = {description = keys2[i], data = i + 281}
keysF[i] = i+281
end
GLOBAL.TheInput:AddKeyDownHandler(keysF[1], EagleViewMode)
GLOBAL.TheInput:AddKeyDownHandler(keysF[2], NightSight)
GLOBAL.TheInput:AddKeyDownHandler(keysF[9], BigViewMode)