代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
一三七.一支吹箭用20次(按百分比使用)
用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/blowdart.lua文件,
1.将下列内容:
local function onhit(inst, attacker, target)
local impactfx = SpawnPrefab("impact")
if impactfx and attacker then
local follower = impactfx.entity:AddFollower()
follower:FollowSymbol(target.GUID, target.components.combat.hiteffectsymbol, 0, 0, 0 )
impactfx:FacePoint(attacker.Transform:GetWorldPosition())
end
inst:Remove()
end
替换为:
local function onfinished(inst)
inst:Remove()
end
local function onhit(inst, attacker, target)
local impactfx = SpawnPrefab("impact")
if impactfx and attacker then
local follower = impactfx.entity:AddFollower()
follower:FollowSymbol(target.GUID, target.components.combat.hiteffectsymbol, 0, 0, 0 )
impactfx:FacePoint(attacker.Transform:GetWorldPosition())
end
if inst.components.finiteuses.current > 0 then
if inst.prefab == "blowdart_walrus" then
inst:Remove()
else
attacker.components.inventory:Equip(inst)
end
end
end
2.在inst:AddComponent("inspectable")的下一行插入以下内容:
inst:AddComponent("finiteuses")
inst.components.finiteuses:SetOnFinished( onfinished )
inst.components.finiteuses:SetMaxUses(20)
inst.components.finiteuses:SetUses(20)
即可让一支吹箭使用20次,每次击中敌人后自动回到手中,可以修改其中2处数字20为想要的使用次数。不要与“吹箭无限使用(射中目标后自动回到手中)”一同修改