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

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



一九一.火炬召唤亡灵(阿比盖尔)

	用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("abigail")
	light.Transform:SetPosition(pos.x, pos.y, pos.z)
end
	inst:AddComponent("spellcaster")
	inst.components.spellcaster:SetSpellFn(createlight)
	inst.components.spellcaster:SetSpellTestFn(cancreatelight)
	inst.components.spellcaster.canuseonpoint = true
	inst.components.spellcaster.canusefrominventory = false

	即可在装备火炬时,在空地上按鼠标右键召唤亡灵,亡灵会保护你。想取消亡灵,召唤两个以上(一个追不上它),对其中一个按ctrl + 鼠标左键,即可取消全部亡灵。不要与“我的小伙伴”一同修改