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

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


 1
 2二一一.无限进化(给远古祭坛500个黄金,升级主角血量、饥饿、脑最大值各100点)
 3
 4	1.MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,将下列内容:
 5
 6		inst:AddComponent("health")
 7		inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH)
 8		inst.components.health.nofadeout = true
 9		-------
10		
11		inst:AddComponent("hunger")
12		inst.components.hunger:SetMax(TUNING.WILSON_HUNGER)
13		inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE)
14		inst.components.hunger:SetKillRate(TUNING.WILSON_HEALTH/TUNING.STARVE_KILL_TIME)
15
16		
17		inst:AddComponent("sanity")
18		inst.components.sanity:SetMax(TUNING.WILSON_SANITY)
19		inst.components.sanity.onSane = OnSane
20		inst.components.sanity.onInsane = OnInsane
21
22	替换为:
23
24local function newupgrades(inst)
25	inst.components.health.maxhealth = TUNING.WILSON_HEALTH + inst.level_num*100
26	inst.components.hunger.max = TUNING.WILSON_HUNGER + inst.level_num*100
27	inst.components.sanity.max = TUNING.WILSON_SANITY + inst.level_num*100
28end
29		inst.level_num = 0
30		inst:AddComponent("health")
31		inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH + inst.level_num*100)
32		inst.components.health.nofadeout = true
33		inst:AddComponent("hunger")
34		inst.components.hunger:SetMax(TUNING.WILSON_HUNGER + inst.level_num*100)
35		inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE)
36		inst.components.hunger:SetKillRate(TUNING.WILSON_HEALTH/TUNING.STARVE_KILL_TIME)
37		inst:AddComponent("sanity")
38		inst.components.sanity:SetMax(TUNING.WILSON_SANITY + inst.level_num*100)
39		inst.components.sanity.onSane = OnSane
40		inst.components.sanity.onInsane = OnInsane
41		newupgrades(inst)
42local function onsave(inst, data)
43	data.level_num = inst.level_num
44end
45local function onload(inst, data)
46	inst.level_num = data.level_num or 0
47	inst.components.health.maxhealth = TUNING.WILSON_HEALTH + inst.level_num*100
48	inst.components.hunger.max = TUNING.WILSON_HUNGER + inst.level_num*100
49	inst.components.sanity.max = TUNING.WILSON_SANITY + inst.level_num*100
50	if data.health and data.health.health then inst.components.health.currenthealth = data.health.health end
51	if data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger end
52	if data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current end
53end
54	inst.OnSave = onsave
55	inst.OnLoad = onload
56
57
58	2.MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/altar_prototyper.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
59
60local function ShouldAcceptItem(inst, item)
61	local player = GetPlayer()
62	if player.components.inventory:Has("goldnugget", 500) then
63	   if item.prefab == "goldnugget" then
64		return true
65		end
66	end
67	return false
68end
69local function OnGetItemFromPlayer(inst, giver, item)
70	if item.prefab == "goldnugget" then
71	   giver.components.inventory:ConsumeByName("goldnugget", 499)
72	   giver.level_num = giver.level_num + 1
73	   inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
74	   giver.HUD.controls.status.heart:PulseGreen()
75	   giver.HUD.controls.status.stomach:PulseGreen()
76	   giver.HUD.controls.status.brain:PulseGreen()
77	   giver.HUD.controls.status.brain:ScaleTo(1.3,1,.7)
78	   giver.HUD.controls.status.heart:ScaleTo(1.3,1,.7)
79	   giver.HUD.controls.status.stomach:ScaleTo(1.3,1,.7)
80	   giver.components.health.maxhealth = TUNING.WILSON_HEALTH + giver.level_num*100
81	   giver.components.hunger.max = TUNING.WILSON_HUNGER + giver.level_num*100
82	   giver.components.sanity.max = TUNING.WILSON_SANITY + giver.level_num*100
83	   giver.components.health:DoDelta(giver.components.health.maxhealth)
84	   giver.components.hunger:DoDelta(giver.components.hunger.max)
85	   giver.components.sanity:DoDelta(giver.components.sanity.max)
86	end
87end
88	inst:AddComponent("trader")
89	inst.components.trader.onaccept = OnGetItemFromPlayer
90	inst.components.trader:SetAcceptTest(ShouldAcceptItem)
91
92	即可给远古祭坛500个黄金(拿着黄金对远古祭坛按鼠标左键),升级主角血量、饥饿、脑最大值各100点,升级无上限,身上黄金不足500时不会升级。如果缺少黄金,可以修改“菜市场”、“肉食店”、“流动商贩”、“杂货收购行”、“收藏品黑市”、“收藏品期货市场”等交易系统赚取黄金(见本修改技巧)。用机器人(wx78)、大力士(沃尔夫冈)作主角时,不要修改此项