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

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


 1
 2一九二.毒龙兵团(装备暗影剑召唤坎普斯士兵)
 3
 4	1.MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/nightsword.lua文件,将inst.components.equippable.dapperness = TUNING.CRAZINESS_MED替换为以下内容
 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("krampus")
16	light.Transform:SetPosition(pos.x, pos.y, pos.z)
17	local caster = staff.components.inventoryitem.owner
18end
19	inst:AddComponent("spellcaster")
20	inst.components.spellcaster:SetSpellFn(createlight)
21	inst.components.spellcaster:SetSpellTestFn(cancreatelight)
22	inst.components.spellcaster.canuseonpoint = true
23	inst.components.spellcaster.canusefrominventory = false
24
25
26	2.MT管理器打开游戏目录/assets/scripts/prefabs/krampus.lua文件,将下列内容:
27
28local function OnAttacked(inst, data)
29	inst.components.combat:SetTarget(data.attacker)
30	--inst.components.combat:ShareTarget(data.attacker, SEE_DIST, function(dude) return dude:HasTag("hound") and not dude.components.health:IsDead() end, 5)
31end
32
33	替换为:
34
35local function Retarget(inst)
36	local newtarget = FindEntity(inst, 20, function(guy)
37			return  guy.components.combat and 
38					inst.components.combat:CanTarget(guy) and
39					(guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy)
40	end)
41	return newtarget
42end
43local function OnAttacked(inst, data)
44	local attacker = data.attacker
45	if attacker and attacker:HasTag("player") then
46		inst.components.health:SetVal(0)
47	else
48		inst.components.combat:SetTarget(attacker)
49	end
50end
51
52
53	3.local brain = require "brains/krampusbrain"替换为local brain = require "brains/abigailbrain"
54
55
56	4.将下列内容:
57
58	inst:AddComponent("sleeper")
59	inst:AddComponent("health")
60	inst.components.health:SetMaxHealth(TUNING.KRAMPUS_HEALTH)
61	
62	inst:AddComponent("combat")
63	inst.components.combat.hiteffectsymbol = "krampus_torso"
64	inst.components.combat:SetDefaultDamage(TUNING.KRAMPUS_DAMAGE)
65	inst.components.combat:SetAttackPeriod(TUNING.KRAMPUS_ATTACK_PERIOD)
66
67	替换为:
68
69	inst:AddComponent("health")
70	inst.components.health:SetMaxHealth(TUNING.KRAMPUS_HEALTH*10)
71	inst:AddComponent("follower")
72	inst:AddComponent("combat")
73	inst.components.combat.hiteffectsymbol = "krampus_torso"
74	inst.components.combat:SetDefaultDamage(TUNING.KRAMPUS_DAMAGE*10)
75	inst.components.combat:SetAttackPeriod(TUNING.KRAMPUS_ATTACK_PERIOD*.1)
76	inst.components.combat:SetRetargetFunction(3, Retarget)
77	inst.AnimState:Hide("SACK")
78	inst.AnimState:Show("ARM")
79
80	即可装备暗影剑时,在空地上按鼠标右键召唤坎普斯士兵。坎普斯经过了深度改造,不会偷东西,只会为主角浴血奋战。不想要坎普斯跟随时,杀死它即可,它虽然强悍,但主角对它一击毙命