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

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


 1
 2一六二.萌时代(扔蜂蜜将怪物变回童年)
 3
 4	MT管理器打开游戏目录/assets/scripts/prefabs/honey.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
 5
 6local function onhit(inst, attacker, target)
 7	inst:Remove()
 8	SpawnPrefab("collapse_small").Transform:SetPosition(target.Transform:GetWorldPosition())
 9	target.Transform:SetScale(0.7, 0.7, 0.7)
10	if target.components.health then
11	   target.components.health.currenthealth = 1
12	   target.components.health.maxhealth = 1
13	end
14	if target.components.combat then
15	   target.components.combat:SetDefaultDamage(0)
16	   target.components.combat.target = nil
17	end
18	if target.components.locomotor then
19	   target.components.locomotor.runspeed = 1
20	   target.components.locomotor.walkspeed = 1
21	end
22end
23local function onthrown(inst, data)
24	inst.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround )
25end
26	inst:AddComponent("weapon")
27	inst.components.weapon:SetDamage(0)
28	inst.components.weapon:SetRange(20, 25)
29	inst:AddComponent("equippable")
30	inst.components.equippable.equipstack = true
31	inst:AddComponent("projectile")
32	inst.components.projectile:SetSpeed(60)
33	inst.components.projectile:SetOnHitFn(onhit)
34	inst:ListenForEvent("onthrown", onthrown)
35
36	即可扔蜂蜜将怪物变成无害的童年怪物,怪物体型变小、生命值为1、没有攻击力、行走缓慢。因为蜂蜜可装备,如果主角也想吃蜂蜜,请拿起蜂蜜对主角按鼠标右键