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

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


 1
 2一六九.速射步枪(黄色魔杖左键点射、右键连射蜂刺子弹)
 3
 4	MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/staff.lua文件,将下列内容:
 5
 6local function yellow()
 7	local inst = commonfn("yellow")
 8	inst.fxcolour = {223/255, 208/255, 69/255}
 9	inst.castsound = "dontstarve/common/staffteleport"
10
11	inst:AddComponent("spellcaster")
12	inst.components.spellcaster:SetSpellFn(createlight)
13	inst.components.spellcaster:SetSpellTestFn(cancreatelight)
14	inst.components.spellcaster.canuseonpoint = true
15	inst.components.spellcaster.canusefrominventory = false
16
17	inst:AddComponent("reticule")
18	inst.components.reticule.targetfn = function() 
19		return Vector3(GetPlayer().entity:LocalToWorldSpace(5,0,0))
20	end
21	inst.components.reticule.ease = true
22
23	inst.components.finiteuses:SetMaxUses(TUNING.YELLOWSTAFF_USES)
24	inst.components.finiteuses:SetUses(TUNING.YELLOWSTAFF_USES)
25	inst:AddTag("nopunch")
26
27	return inst
28end
29
30	替换为:
31
32local function yellow()
33	local inst = commonfn("yellow")
34	inst.fxcolour = {223/255, 208/255, 69/255}
35	inst.castsound = "dontstarve/common/staffteleport"
36local function canattack(inst, target)
37	if GetPlayer().components.inventory:Has("stinger", 1) and TheInput:IsMouseDown(MOUSEBUTTON_RIGHT) then
38	   inst.components.weapon:LaunchProjectile(inst, target)
39	end
40	if GetPlayer().components.inventory:Has("stinger", 1) then
41	   return true
42	end
43end
44local function onattack_yellow(inst, owner, target)
45	owner.SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo")
46	SpawnPrefab("die_fx").Transform:SetPosition(target.Transform:GetWorldPosition())
47	TheCamera:Shake("FULL", 0.2, 0.02, .5, 40)
48	owner.components.inventory:ConsumeByName("stinger", 1)
49end
50	inst:AddComponent("weapon")
51	inst.components.weapon:SetDamage(100)
52	inst.components.weapon:SetRange(25, 30)
53	inst.components.weapon:SetOnAttack(onattack_yellow)
54	inst.components.weapon:SetCanAttack(canattack)
55	inst.components.weapon:SetProjectile("fire_projectile")
56	inst.components.finiteuses:SetMaxUses(TUNING.YELLOWSTAFF_USES*1000)
57	inst.components.finiteuses:SetUses(TUNING.YELLOWSTAFF_USES*1000)
58	return inst
59end
60
61	即可在装备黄色魔杖时,对敌人按鼠标左键点射,按鼠标右键连射,身上没有蜂刺时无法射击(不要光顾着按住右键扫射,时不时关注一下还有多少子弹)。黄色魔杖在远古选项(画着远古祭坛)下,用4个噩梦燃料、2个活木头、2个黄色宝石制造,制造时需要靠近远古祭坛。黄色魔杖原有种小星星功能取消