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

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



一七四.霸王枪(瓦丝格雷斯矛升级为霸王枪,鼠标左键远距离突刺并撤回,右键挑飞敌人,敌人会喷血)

	用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/spear_wathgrithr.lua文件,

	1.local function onequip(inst, owner)的下一行插入以下内容:

	inst.fire = SpawnPrefab( "campfirefire" )
	local follower = inst.fire.entity:AddFollower()
	follower:FollowSymbol( owner.GUID, "swap_object", 20, -88, 1 )
	inst.fire.AnimState:SetMultColour(255/255,0/255,0/255,1)
	inst.fire.Transform:SetScale(0.8, 0.8, 0.8)
	inst.fire:RemoveComponent("heater")
	inst.fire.persists = false


	2.local function onunequip(inst, owner)的下一行插入以下内容:

	inst.fire:Remove()
	inst.fire = nil


	3.将下列内容:

	inst:AddComponent("weapon")
	inst.components.weapon:SetDamage(TUNING.WATHGRITHR_SPEAR_DAMAGE)
	
	-------
	
	inst:AddComponent("finiteuses")
	inst.components.finiteuses:SetMaxUses(TUNING.WATHGRITHR_SPEAR_USES)
	inst.components.finiteuses:SetUses(TUNING.WATHGRITHR_SPEAR_USES)
	
	inst.components.finiteuses:SetOnFinished( onfinished )

	替换为:

local function canattack(inst, target)
	if TheInput:IsMouseDown(MOUSEBUTTON_RIGHT) then
	   GetPlayer().AnimState:PlayAnimation("atk")
	   SpawnPrefab("groundpoundring_fx").Transform:SetPosition(GetPlayer().Transform:GetWorldPosition())
	   SpawnPrefab("explode_small").Transform:SetPosition(target.Transform:GetWorldPosition())
	   GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground")
	   local pt01 = GetPlayer():GetPosition()
	   local pt02 = target:GetPosition()
	   target.Transform:SetPosition((pt02.x-pt01.x)*0.5+pt02.x, 0, (pt02.z-pt01.z)*0.5+pt02.z)
	   local blood = SpawnPrefab("splash")
	   blood.Transform:SetPosition(target.Transform:GetWorldPosition())
	   blood.AnimState:SetMultColour(255/255,0/255,0/255,1)
	   blood.Transform:SetScale(2, 2, 2)
	   if target.components.locomotor then target.components.locomotor:Stop() end
	   if target.components.combat then target.components.combat:SetTarget(GetPlayer()) end
	   if target.components.health then
		  target.components.health:DoDelta(-100)
		  if target.components.health:GetPercent() < 0.3 then
			 target.AnimState:SetMultColour(255/255,0/255,0/255,1)
		  end
	   end
	end
	return true
end
local function onattack(inst, attacker, target)
	local pt1 = attacker:GetPosition()
	local pt2 = target:GetPosition()
	GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground")
	attacker:DoTaskInTime(0.01, function()
		attacker.Transform:SetPosition(pt2.x, pt2.y, pt2.z)
		SpawnPrefab("explode_small").Transform:SetPosition(target.Transform:GetWorldPosition())
		SpawnPrefab("groundpoundring_fx").Transform:SetPosition(target.Transform:GetWorldPosition())
		if target.components.locomotor then target.components.locomotor:Stop() end
		attacker:StartThread(function()
			for k = 1, 3 do
				local blood = SpawnPrefab("splash")
				blood.Transform:SetPosition(pt2.x, 1.5, pt2.z)
				blood.AnimState:SetMultColour(255/255,0/255,0/255,1)
				blood.Transform:SetScale(2, 2, 2)
				Sleep(.1)
			end
		end )
		if target.components.health and target.components.health:GetPercent() < 0.3 then
		   target.AnimState:SetMultColour(255/255,0/255,0/255,1)
		end
	end )
	attacker:DoTaskInTime(0.3, function()
		attacker.Transform:SetPosition(pt1.x, pt1.y, pt1.z)
	end )
end
	inst:AddComponent("weapon")
	inst.components.weapon:SetDamage(300)
	inst.components.weapon:SetRange(15, 20)
	inst.components.weapon:SetOnAttack(onattack)
	inst.components.weapon:SetCanAttack(canattack)

	即可让瓦丝格雷斯矛升级为霸王枪,装备霸王枪,鼠标左键点敌人(按住可连续攻击),会远距离突刺敌人,刺中后迅速撤回原位,不给敌人还击的机会。鼠标右键点敌人,可将敌人挑飞,按住右键扫过一群敌人,可防止被围攻。使用霸王枪时,敌人会喷血,场面极其惨烈,如果你是儿童,请捂住眼睛使用。瓦丝格雷斯矛可修改“全人物可制造瓦丝格雷斯矛、瓦丝格雷斯帽”获得