代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1
2一三七.一支吹箭用20次(按百分比使用)
3
4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/blowdart.lua文件,
5
6 1.将下列内容:
7
8local function onhit(inst, attacker, target)
9 local impactfx = SpawnPrefab("impact")
10 if impactfx and attacker then
11 local follower = impactfx.entity:AddFollower()
12 follower:FollowSymbol(target.GUID, target.components.combat.hiteffectsymbol, 0, 0, 0 )
13 impactfx:FacePoint(attacker.Transform:GetWorldPosition())
14 end
15 inst:Remove()
16end
17
18 替换为:
19
20local function onfinished(inst)
21 inst:Remove()
22end
23local function onhit(inst, attacker, target)
24 local impactfx = SpawnPrefab("impact")
25 if impactfx and attacker then
26 local follower = impactfx.entity:AddFollower()
27 follower:FollowSymbol(target.GUID, target.components.combat.hiteffectsymbol, 0, 0, 0 )
28 impactfx:FacePoint(attacker.Transform:GetWorldPosition())
29 end
30 if inst.components.finiteuses.current > 0 then
31 if inst.prefab == "blowdart_walrus" then
32 inst:Remove()
33 else
34 attacker.components.inventory:Equip(inst)
35 end
36 end
37end
38
39
40 2.在inst:AddComponent("inspectable")的下一行插入以下内容:
41
42 inst:AddComponent("finiteuses")
43 inst.components.finiteuses:SetOnFinished( onfinished )
44 inst.components.finiteuses:SetMaxUses(20)
45 inst.components.finiteuses:SetUses(20)
46
47 即可让一支吹箭使用20次,每次击中敌人后自动回到手中,可以修改其中2处数字20为想要的使用次数。不要与“吹箭无限使用(射中目标后自动回到手中)”一同修改