代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
一三六.装备回旋镖召唤猎物(打猎游戏)
用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/boomerang.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 names = {"crow","robin","robin_winter","frog","mosquito","bee","killerbee","butterfly","rabbit","babybeefalo"}
local name = names[math.random(#names)]
local prey = SpawnPrefab(name)
prey.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
即可在装备回旋镖后,在空地上点鼠标右键召唤猎物,包括鸟、昆虫、青蛙、兔子、小牛,尽情捕猎吧