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

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



六十八.生命号角(吹牛角让农田和植物迅速长出)

	用MT管理器打开游戏目录/assets/scripts/prefabs/horn.lua文件,

	1.在下列内容:

local function onfinished(inst)
	inst:Remove()
end

	的下一行插入以下内容:

function growfn(inst, reader)
	local pos = Vector3(reader.Transform:GetWorldPosition())
	local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30)
	for k,v in pairs(ents) do
		if v.components.pickable then
		   v.components.pickable:FinishGrowing()
		end
		if v.components.crop then
		   v.components.crop:DoGrow(TUNING.TOTAL_DAY_TIME*3)
		end
		if v:HasTag("tree") and v.components.growable and not v:HasTag("stump") then
		   v.components.growable:DoGrowth()
		end
	end
end

	2.将下列内容:

	inst.components.instrument.range = TUNING.HORN_RANGE
	inst.components.instrument:SetOnHeardFn(HearHorn)

	替换为:

	inst.components.instrument.onheard = growfn

	即可在采集过的植物根附近吹牛角,使植物瞬间生长出来,小树也可以长成大树,牛角原有让牛跟随功能失效