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

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


 1
 2一七八.巨人帽(带猪皮帽变巨人,攻击、防御上升,可撞毁建筑、树、石头)
 3
 4	MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/hats.lua文件,将下列内容:
 5
 6	local function football()
 7		local inst = simple()
 8		inst:AddComponent("armor")
 9
10		inst:AddComponent("waterproofer")
11		inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_SMALL)
12		
13		inst.components.armor:InitCondition(TUNING.ARMOR_FOOTBALLHAT, TUNING.ARMOR_FOOTBALLHAT_ABSORPTION)
14		return inst
15	end
16
17	替换为:
18
19local function football_equip(inst, owner)
20	onequip(inst, owner)
21	if owner == GetPlayer() then
22	   owner.Transform:SetScale(3, 3, 3)
23	   owner.components.combat:SetDefaultDamage(500)
24	   owner.Physics:SetCollisionCallback(function(owner, other)
25		   if other and other.components.workable and other.components.workable.workleft > 0 then
26			  other.components.workable:Destroy(owner)
27		   end
28	   end)
29	end
30end
31local function football_unequip(inst, owner)
32	onunequip(inst, owner)
33	if owner == GetPlayer() then
34	   owner.Transform:SetScale(1, 1, 1)
35	   owner.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE)
36	   owner.Physics:SetCollisionCallback( nil )
37	end
38end
39local function football()
40	local inst = simple()
41	inst:AddComponent("armor")
42	inst.components.armor:InitCondition(TUNING.ARMOR_FOOTBALLHAT, 0.95)
43	inst:AddComponent("waterproofer")
44	inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_SMALL)
45	inst.components.equippable:SetOnEquip( football_equip )
46	inst.components.equippable:SetOnUnequip( football_unequip )
47	return inst
48end
49
50	即可戴猪皮帽变巨人,空手攻击力达到500点(空手按Ctrl + 鼠标左键攻击,或按住F反击),防御敌人95%的伤害(只掉5%的血),可撞毁建筑、树、石头。猪皮帽在战斗选项(画着两把剑)下,用1个绳子、1个猪皮制造,制造时须靠近炼金术引擎