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

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


 1
 2六十八.生命号角(吹牛角让农田和植物迅速长出)
 3
 4	MT管理器打开游戏目录/assets/scripts/prefabs/horn.lua文件
 5
 6	1.在下列内容:
 7
 8local function onfinished(inst)
 9	inst:Remove()
10end
11
12	的下一行插入以下内容:
13
14function growfn(inst, reader)
15	local pos = Vector3(reader.Transform:GetWorldPosition())
16	local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30)
17	for k,v in pairs(ents) do
18		if v.components.pickable then
19		   v.components.pickable:FinishGrowing()
20		end
21		if v.components.crop then
22		   v.components.crop:DoGrow(TUNING.TOTAL_DAY_TIME*3)
23		end
24		if v:HasTag("tree") and v.components.growable and not v:HasTag("stump") then
25		   v.components.growable:DoGrowth()
26		end
27	end
28end
29
30	2.将下列内容:
31
32	inst.components.instrument.range = TUNING.HORN_RANGE
33	inst.components.instrument:SetOnHeardFn(HearHorn)
34
35	替换为:
36
37	inst.components.instrument.onheard = growfn
38
39	即可在采集过的植物根附近吹牛角,使植物瞬间生长出来,小树也可以长成大树,牛角原有让牛跟随功能失效