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

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



一九三.我的小伙伴(用火炬召唤其他主角一起工作战斗)

	1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/torch.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:

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("shadowwaxwell")
	light.Transform:SetPosition(pos.x, pos.y, pos.z)
	local caster = staff.components.inventoryitem.owner
	light.components.follower:SetLeader(caster)
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/shadowwaxwell.lua文件,将下列内容:

	anim:SetBuild("waxwell_shadow_mod")
	anim:PlayAnimation("idle")

	anim:Hide("ARM_carry")
	anim:Hide("hat")
	anim:Hide("hat_hair")

	inst:AddTag("scarytoprey")
	inst:AddTag("NOCLICK")

	inst:AddComponent("colourtweener")
	inst.components.colourtweener:StartTween({0,0,0,.5}, 0)

	inst:AddComponent("locomotor")
	inst.components.locomotor:SetSlowMultiplier( 0.6 )
	inst.components.locomotor.pathcaps = { ignorecreep = true }
	inst.components.locomotor.runspeed = TUNING.SHADOWWAXWELL_SPEED

	inst:AddComponent("combat")
	inst.components.combat.hiteffectsymbol = "torso"
	-- inst.components.combat:SetRetargetFunction(1, Retarget)
	inst.components.combat:SetKeepTargetFunction(KeepTarget)
	inst.components.combat:SetAttackPeriod(TUNING.SHADOWWAXWELL_ATTACK_PERIOD)
	inst.components.combat:SetRange(2, 3)
	inst.components.combat:SetDefaultDamage(TUNING.SHADOWWAXWELL_DAMAGE)

	inst:AddComponent("health")
	inst.components.health:SetMaxHealth(TUNING.SHADOWWAXWELL_LIFE)
	inst.components.health.nofadeout = true
	inst:ListenForEvent("death", ondeath)

	inst:AddComponent("inventory")
	inst.components.inventory.dropondeath = false

	inst:AddComponent("sanityaura")
	inst.components.sanityaura.penalty = TUNING.SHADOWWAXWELL_SANITY_PENALTY

	替换为:

	local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"}
	inst.animname = names[math.random(#names)]
	anim:SetBuild(inst.animname)
	anim:PlayAnimation("idle")
	anim:Hide("ARM_carry")
	anim:Hide("hat")
	anim:Hide("hat_hair")
	inst:AddComponent("locomotor")
	inst.components.locomotor.pathcaps = { ignorecreep = true }
	inst.components.locomotor.runspeed = TUNING.SHADOWWAXWELL_SPEED*2
	inst:AddComponent("combat")
	inst.components.combat.hiteffectsymbol = "torso"
	inst.components.combat:SetKeepTargetFunction(KeepTarget)
	inst.components.combat:SetAttackPeriod(TUNING.SHADOWWAXWELL_ATTACK_PERIOD*.1)
	inst.components.combat:SetRange(2, 3)
	inst.components.combat:SetDefaultDamage(TUNING.SHADOWWAXWELL_DAMAGE*10)
	inst:AddComponent("health")
	inst.components.health:SetMaxHealth(TUNING.SHADOWWAXWELL_LIFE*10)
	inst.components.health.nofadeout = true
	inst:AddComponent("inventory")
	inst.components.inventory.dropondeath = false

	即可装备火炬在空地上点鼠标右键,随机召唤其他主角,一起砍树、开矿、战斗。不想要伙伴时,对其按Ctrl + 鼠标左键杀掉即可,不杀掉几天后其也会自然死去,想要就再召唤吧。不要与“火炬召唤亡灵”一同修改,使用麦斯威尔作主角时不要修改本条