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

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



一九二.毒龙兵团(装备暗影剑召唤坎普斯士兵)

	1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/nightsword.lua文件,将inst.components.equippable.dapperness = TUNING.CRAZINESS_MED替换为以下内容:

local function cancreatelight(staff, caster, target, pos)
	local ground = GetWorld()
	if ground and pos then
		local tile = ground.Map:GetTileAtPoint(pos.x, pos.y, pos.z)
		return tile ~= GROUND.IMPASSIBLE and tile < GROUND.UNDERGROUND
	end
	return false
end
local function createlight(staff, target, pos)
	local light = SpawnPrefab("krampus")
	light.Transform:SetPosition(pos.x, pos.y, pos.z)
	local caster = staff.components.inventoryitem.owner
end
	inst:AddComponent("spellcaster")
	inst.components.spellcaster:SetSpellFn(createlight)
	inst.components.spellcaster:SetSpellTestFn(cancreatelight)
	inst.components.spellcaster.canuseonpoint = true
	inst.components.spellcaster.canusefrominventory = false


	2.用MT管理器打开游戏目录/assets/scripts/prefabs/krampus.lua文件,将下列内容:

local function OnAttacked(inst, data)
	inst.components.combat:SetTarget(data.attacker)
	--inst.components.combat:ShareTarget(data.attacker, SEE_DIST, function(dude) return dude:HasTag("hound") and not dude.components.health:IsDead() end, 5)
end

	替换为:

local function Retarget(inst)
	local newtarget = FindEntity(inst, 20, function(guy)
			return  guy.components.combat and 
					inst.components.combat:CanTarget(guy) and
					(guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy)
	end)
	return newtarget
end
local function OnAttacked(inst, data)
	local attacker = data.attacker
	if attacker and attacker:HasTag("player") then
		inst.components.health:SetVal(0)
	else
		inst.components.combat:SetTarget(attacker)
	end
end


	3.local brain = require "brains/krampusbrain"替换为local brain = require "brains/abigailbrain"


	4.将下列内容:

	inst:AddComponent("sleeper")
	inst:AddComponent("health")
	inst.components.health:SetMaxHealth(TUNING.KRAMPUS_HEALTH)
	
	inst:AddComponent("combat")
	inst.components.combat.hiteffectsymbol = "krampus_torso"
	inst.components.combat:SetDefaultDamage(TUNING.KRAMPUS_DAMAGE)
	inst.components.combat:SetAttackPeriod(TUNING.KRAMPUS_ATTACK_PERIOD)

	替换为:

	inst:AddComponent("health")
	inst.components.health:SetMaxHealth(TUNING.KRAMPUS_HEALTH*10)
	inst:AddComponent("follower")
	inst:AddComponent("combat")
	inst.components.combat.hiteffectsymbol = "krampus_torso"
	inst.components.combat:SetDefaultDamage(TUNING.KRAMPUS_DAMAGE*10)
	inst.components.combat:SetAttackPeriod(TUNING.KRAMPUS_ATTACK_PERIOD*.1)
	inst.components.combat:SetRetargetFunction(3, Retarget)
	inst.AnimState:Hide("SACK")
	inst.AnimState:Show("ARM")

	即可装备暗影剑时,在空地上按鼠标右键召唤坎普斯士兵。坎普斯经过了深度改造,不会偷东西,只会为主角浴血奋战。不想要坎普斯跟随时,杀死它即可,它虽然强悍,但主角对它一击毙命