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

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



一七七.活捉手杖(装备龙卷风魔杖,鼠标左键点鸟、鼹鼠等小动物,可远程活捉)

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

local function canattack(inst, target)
	if target.prefab == "bee" or target.prefab == "killerbee" or target.prefab == "crow" or target.prefab == "robin" or target.prefab == "robin_winter" or target.prefab == "butterfly" or target.prefab == "mole" or target.prefab == "mosquito" or target.prefab == "rabbit" then
	   return true
	end
	return false
end
local function onattack(inst, attacker, target)
	if target.prefab == "bee" then
	   local prey = SpawnPrefab("bee")
	   GetPlayer().components.inventory:GiveItem(prey)
	end
	if target.prefab == "killerbee" then
	   local prey = SpawnPrefab("killerbee")
	   GetPlayer().components.inventory:GiveItem(prey)
	end
	if target.prefab == "crow" then
	   local prey = SpawnPrefab("crow")
	   GetPlayer().components.inventory:GiveItem(prey)
	end
	if target.prefab == "robin" then
	   local prey = SpawnPrefab("robin")
	   GetPlayer().components.inventory:GiveItem(prey)
	end
	if target.prefab == "robin_winter" then
	   local prey = SpawnPrefab("robin_winter")
	   GetPlayer().components.inventory:GiveItem(prey)
	end
	if target.prefab == "butterfly" then
	   local prey = SpawnPrefab("butterfly")
	   GetPlayer().components.inventory:GiveItem(prey)
	end
	if target.prefab == "mole" then
	   local prey = SpawnPrefab("mole")
	   GetPlayer().components.inventory:GiveItem(prey)
	end
	if target.prefab == "mosquito" then
	   local prey = SpawnPrefab("mosquito")
	   GetPlayer().components.inventory:GiveItem(prey)
	end
	if target.prefab == "rabbit" then
	   local prey = SpawnPrefab("rabbit")
	   GetPlayer().components.inventory:GiveItem(prey)
	end
	target:Remove()
end
	inst:AddComponent("weapon")
	inst.components.weapon:SetDamage(0)
	inst.components.weapon:SetRange(25, 30)
	inst.components.weapon:SetOnAttack(onattack)
	inst.components.weapon:SetCanAttack(canattack)
	inst.components.weapon:SetProjectile("bishop_charge")

	即可将龙卷风魔杖升级为活捉手杖,装备活捉手杖,鼠标左键点小动物,可远距离活捉它们。可活捉的小动物包括蜜蜂、杀人蜂、鸟、蝴蝶、鼹鼠、蚊子、兔子。龙卷风魔杖右键召唤龙卷风的功能保留。龙卷风魔杖在战斗选项下,用10个鹿鸭羽毛、1个闪电羊角、1个齿轮制造