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

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


 1
 2一九三.我的小伙伴(用火炬召唤其他主角一起工作战斗)
 3
 4	1.MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/torch.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
 5
 6local function cancreatelight(staff, caster, target, pos)
 7	local ground = GetWorld()
 8	if ground and pos then
 9		local tile = ground.Map:GetTileAtPoint(pos.x, pos.y, pos.z)
10		return tile ~= GROUND.IMPASSIBLE and tile < GROUND.UNDERGROUND
11	end
12	return false
13end
14local function createlight(staff, target, pos)
15	local light = SpawnPrefab("shadowwaxwell")
16	light.Transform:SetPosition(pos.x, pos.y, pos.z)
17	local caster = staff.components.inventoryitem.owner
18	light.components.follower:SetLeader(caster)
19end
20	inst:AddComponent("spellcaster")
21	inst.components.spellcaster:SetSpellFn(createlight)
22	inst.components.spellcaster:SetSpellTestFn(cancreatelight)
23	inst.components.spellcaster.canuseonpoint = true
24	inst.components.spellcaster.canusefrominventory = false
25
26
27	2.MT管理器打开游戏目录/assets/scripts/prefabs/shadowwaxwell.lua文件,将下列内容:
28
29	anim:SetBuild("waxwell_shadow_mod")
30	anim:PlayAnimation("idle")
31
32	anim:Hide("ARM_carry")
33	anim:Hide("hat")
34	anim:Hide("hat_hair")
35
36	inst:AddTag("scarytoprey")
37	inst:AddTag("NOCLICK")
38
39	inst:AddComponent("colourtweener")
40	inst.components.colourtweener:StartTween({0,0,0,.5}, 0)
41
42	inst:AddComponent("locomotor")
43	inst.components.locomotor:SetSlowMultiplier( 0.6 )
44	inst.components.locomotor.pathcaps = { ignorecreep = true }
45	inst.components.locomotor.runspeed = TUNING.SHADOWWAXWELL_SPEED
46
47	inst:AddComponent("combat")
48	inst.components.combat.hiteffectsymbol = "torso"
49	-- inst.components.combat:SetRetargetFunction(1, Retarget)
50	inst.components.combat:SetKeepTargetFunction(KeepTarget)
51	inst.components.combat:SetAttackPeriod(TUNING.SHADOWWAXWELL_ATTACK_PERIOD)
52	inst.components.combat:SetRange(2, 3)
53	inst.components.combat:SetDefaultDamage(TUNING.SHADOWWAXWELL_DAMAGE)
54
55	inst:AddComponent("health")
56	inst.components.health:SetMaxHealth(TUNING.SHADOWWAXWELL_LIFE)
57	inst.components.health.nofadeout = true
58	inst:ListenForEvent("death", ondeath)
59
60	inst:AddComponent("inventory")
61	inst.components.inventory.dropondeath = false
62
63	inst:AddComponent("sanityaura")
64	inst.components.sanityaura.penalty = TUNING.SHADOWWAXWELL_SANITY_PENALTY
65
66	替换为:
67
68	local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"}
69	inst.animname = names[math.random(#names)]
70	anim:SetBuild(inst.animname)
71	anim:PlayAnimation("idle")
72	anim:Hide("ARM_carry")
73	anim:Hide("hat")
74	anim:Hide("hat_hair")
75	inst:AddComponent("locomotor")
76	inst.components.locomotor.pathcaps = { ignorecreep = true }
77	inst.components.locomotor.runspeed = TUNING.SHADOWWAXWELL_SPEED*2
78	inst:AddComponent("combat")
79	inst.components.combat.hiteffectsymbol = "torso"
80	inst.components.combat:SetKeepTargetFunction(KeepTarget)
81	inst.components.combat:SetAttackPeriod(TUNING.SHADOWWAXWELL_ATTACK_PERIOD*.1)
82	inst.components.combat:SetRange(2, 3)
83	inst.components.combat:SetDefaultDamage(TUNING.SHADOWWAXWELL_DAMAGE*10)
84	inst:AddComponent("health")
85	inst.components.health:SetMaxHealth(TUNING.SHADOWWAXWELL_LIFE*10)
86	inst.components.health.nofadeout = true
87	inst:AddComponent("inventory")
88	inst.components.inventory.dropondeath = false
89
90	即可装备火炬在空地上点鼠标右键,随机召唤其他主角,一起砍树、开矿、战斗。不想要伙伴时,对其按Ctrl + 鼠标左键杀掉即可,不杀掉几天后其也会自然死去,想要就再召唤吧。不要与“火炬召唤亡灵”一同修改,使用麦斯威尔作主角时不要修改本条