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

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


 1
 2一八二.泡泡糖(吃黄油吹个保护泡泡)
 3
 4	MT管理器打开游戏目录/assets/scripts/prefabs/butter.lua文件,在inst.components.edible.hungervalue = TUNING.CALORIES_MED的下一行插入以下内容
 5
 6	local function proc(inst, eater)
 7		eater.components.health:SetInvincible(true)
 8		inst:AddTag("forcefield")
 9		local fx = SpawnPrefab("forcefieldfx")
10		fx.entity:SetParent(eater.entity)
11		fx.Transform:SetPosition(0, 0.2, 0)
12		local fx_hitanim = function()
13			fx.AnimState:PlayAnimation("hit")
14			fx.AnimState:PushAnimation("idle_loop")
15		end
16		fx:ListenForEvent("blocked", fx_hitanim, eater)
17		inst.active = true
18		eater:DoTaskInTime(60, function()
19			fx:RemoveEventCallback("blocked", fx_hitanim, eater)
20			fx.kill_fx(fx)
21			if inst:IsValid() then
22				eater.components.health:SetInvincible(false)
23				inst:RemoveTag("forcefield")
24				eater:DoTaskInTime(5, function() inst.active = false end)
25			end
26		end)
27	end
28local function oneaten(inst, eater)
29	proc(inst, eater)
30end
31	   	inst.components.edible:SetOnEatenFn(oneaten)
32
33	即可吃黄油后60秒内身边环绕一个保护泡,敌人无法伤到主角。黄油可以靠杀蝴蝶掉落,也可以用本修改技巧的“栽种尖刺灌木产黄油”得到