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

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



一六九.速射步枪(黄色魔杖左键点射、右键连射蜂刺子弹)

	用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/staff.lua文件,将下列内容:

local function yellow()
	local inst = commonfn("yellow")
	inst.fxcolour = {223/255, 208/255, 69/255}
	inst.castsound = "dontstarve/common/staffteleport"

	inst:AddComponent("spellcaster")
	inst.components.spellcaster:SetSpellFn(createlight)
	inst.components.spellcaster:SetSpellTestFn(cancreatelight)
	inst.components.spellcaster.canuseonpoint = true
	inst.components.spellcaster.canusefrominventory = false

	inst:AddComponent("reticule")
	inst.components.reticule.targetfn = function() 
		return Vector3(GetPlayer().entity:LocalToWorldSpace(5,0,0))
	end
	inst.components.reticule.ease = true

	inst.components.finiteuses:SetMaxUses(TUNING.YELLOWSTAFF_USES)
	inst.components.finiteuses:SetUses(TUNING.YELLOWSTAFF_USES)
	inst:AddTag("nopunch")

	return inst
end

	替换为:

local function yellow()
	local inst = commonfn("yellow")
	inst.fxcolour = {223/255, 208/255, 69/255}
	inst.castsound = "dontstarve/common/staffteleport"
local function canattack(inst, target)
	if GetPlayer().components.inventory:Has("stinger", 1) and TheInput:IsMouseDown(MOUSEBUTTON_RIGHT) then
	   inst.components.weapon:LaunchProjectile(inst, target)
	end
	if GetPlayer().components.inventory:Has("stinger", 1) then
	   return true
	end
end
local function onattack_yellow(inst, owner, target)
	owner.SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo")
	SpawnPrefab("die_fx").Transform:SetPosition(target.Transform:GetWorldPosition())
	TheCamera:Shake("FULL", 0.2, 0.02, .5, 40)
	owner.components.inventory:ConsumeByName("stinger", 1)
end
	inst:AddComponent("weapon")
	inst.components.weapon:SetDamage(100)
	inst.components.weapon:SetRange(25, 30)
	inst.components.weapon:SetOnAttack(onattack_yellow)
	inst.components.weapon:SetCanAttack(canattack)
	inst.components.weapon:SetProjectile("fire_projectile")
	inst.components.finiteuses:SetMaxUses(TUNING.YELLOWSTAFF_USES*1000)
	inst.components.finiteuses:SetUses(TUNING.YELLOWSTAFF_USES*1000)
	return inst
end

	即可在装备黄色魔杖时,对敌人按鼠标左键点射,按鼠标右键连射,身上没有蜂刺时无法射击(不要光顾着按住右键扫射,时不时关注一下还有多少子弹)。黄色魔杖在远古选项(画着远古祭坛)下,用4个噩梦燃料、2个活木头、2个黄色宝石制造,制造时需要靠近远古祭坛。黄色魔杖原有种小星星功能取消