代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。

原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html



二一一.无限进化(给远古祭坛500个黄金,升级主角血量、饥饿、脑最大值各100点)

	1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,将下列内容:

		inst:AddComponent("health")
		inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH)
		inst.components.health.nofadeout = true
		-------
		
		inst:AddComponent("hunger")
		inst.components.hunger:SetMax(TUNING.WILSON_HUNGER)
		inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE)
		inst.components.hunger:SetKillRate(TUNING.WILSON_HEALTH/TUNING.STARVE_KILL_TIME)

		
		inst:AddComponent("sanity")
		inst.components.sanity:SetMax(TUNING.WILSON_SANITY)
		inst.components.sanity.onSane = OnSane
		inst.components.sanity.onInsane = OnInsane

	替换为:

local function newupgrades(inst)
	inst.components.health.maxhealth = TUNING.WILSON_HEALTH + inst.level_num*100
	inst.components.hunger.max = TUNING.WILSON_HUNGER + inst.level_num*100
	inst.components.sanity.max = TUNING.WILSON_SANITY + inst.level_num*100
end
		inst.level_num = 0
		inst:AddComponent("health")
		inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH + inst.level_num*100)
		inst.components.health.nofadeout = true
		inst:AddComponent("hunger")
		inst.components.hunger:SetMax(TUNING.WILSON_HUNGER + inst.level_num*100)
		inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE)
		inst.components.hunger:SetKillRate(TUNING.WILSON_HEALTH/TUNING.STARVE_KILL_TIME)
		inst:AddComponent("sanity")
		inst.components.sanity:SetMax(TUNING.WILSON_SANITY + inst.level_num*100)
		inst.components.sanity.onSane = OnSane
		inst.components.sanity.onInsane = OnInsane
		newupgrades(inst)
local function onsave(inst, data)
	data.level_num = inst.level_num
end
local function onload(inst, data)
	inst.level_num = data.level_num or 0
	inst.components.health.maxhealth = TUNING.WILSON_HEALTH + inst.level_num*100
	inst.components.hunger.max = TUNING.WILSON_HUNGER + inst.level_num*100
	inst.components.sanity.max = TUNING.WILSON_SANITY + inst.level_num*100
	if data.health and data.health.health then inst.components.health.currenthealth = data.health.health end
	if data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger end
	if data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current end
end
	inst.OnSave = onsave
	inst.OnLoad = onload


	2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/altar_prototyper.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:

local function ShouldAcceptItem(inst, item)
	local player = GetPlayer()
	if player.components.inventory:Has("goldnugget", 500) then
	   if item.prefab == "goldnugget" then
		return true
		end
	end
	return false
end
local function OnGetItemFromPlayer(inst, giver, item)
	if item.prefab == "goldnugget" then
	   giver.components.inventory:ConsumeByName("goldnugget", 499)
	   giver.level_num = giver.level_num + 1
	   inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
	   giver.HUD.controls.status.heart:PulseGreen()
	   giver.HUD.controls.status.stomach:PulseGreen()
	   giver.HUD.controls.status.brain:PulseGreen()
	   giver.HUD.controls.status.brain:ScaleTo(1.3,1,.7)
	   giver.HUD.controls.status.heart:ScaleTo(1.3,1,.7)
	   giver.HUD.controls.status.stomach:ScaleTo(1.3,1,.7)
	   giver.components.health.maxhealth = TUNING.WILSON_HEALTH + giver.level_num*100
	   giver.components.hunger.max = TUNING.WILSON_HUNGER + giver.level_num*100
	   giver.components.sanity.max = TUNING.WILSON_SANITY + giver.level_num*100
	   giver.components.health:DoDelta(giver.components.health.maxhealth)
	   giver.components.hunger:DoDelta(giver.components.hunger.max)
	   giver.components.sanity:DoDelta(giver.components.sanity.max)
	end
end
	inst:AddComponent("trader")
	inst.components.trader.onaccept = OnGetItemFromPlayer
	inst.components.trader:SetAcceptTest(ShouldAcceptItem)

	即可给远古祭坛500个黄金(拿着黄金对远古祭坛按鼠标左键),升级主角血量、饥饿、脑最大值各100点,升级无上限,身上黄金不足500时不会升级。如果缺少黄金,可以修改“菜市场”、“肉食店”、“流动商贩”、“杂货收购行”、“收藏品黑市”、“收藏品期货市场”等交易系统赚取黄金(见本修改技巧)。用机器人(wx78)、大力士(沃尔夫冈)作主角时,不要修改此项