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

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



一六三.犬牙手雷(扔犬牙炸倒一大片)

	用MT管理器打开游戏目录/assets/scripts/prefabs/houndstooth.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:

local function onhit(inst, attacker, target)
	SpawnPrefab("collapse_small").Transform:SetPosition(target.Transform:GetWorldPosition())
	SpawnPrefab("explode_small").Transform:SetPosition(target.Transform:GetWorldPosition())
	local pos = Vector3(target.Transform:GetWorldPosition())
	GetClock():DoLightningLighting()
	GetPlayer().components.playercontroller:ShakeCamera(target, "FULL", 0.7, 0.02, .5, 40)
	inst.components.combat:DoAreaAttack(target, 8)
	inst:Remove()
end
local function onthrown(inst, data)
	inst.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround )
end
	inst:AddComponent("weapon")
	inst.components.weapon:SetDamage(3000)
	inst.components.weapon:SetRange(15, 18)
	inst:AddComponent("combat")
	inst.components.combat:SetDefaultDamage(3000)
	inst.components.combat.playerdamagepercent = 0
	inst:AddComponent("equippable")
	inst.components.equippable.equipstack = true
	inst:AddComponent("projectile")
	inst.components.projectile:SetSpeed(60)
	inst.components.projectile:SetOnHitFn(onhit)
	inst:ListenForEvent("onthrown", onthrown)

	即可在装备犬牙时,对一群敌人扔出(远距离对敌人按鼠标左键)炸倒一大片。犬牙手雷不会伤到主角