代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1
2二六七.蜘蛛座骑(按键盘PageUP键召唤蜘蛛座骑,按PageDown键取消)
3
4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("inventory")的下一行插入以下内容:
5
6TheInput:AddKeyUpHandler(KEY_PAGEUP, function()
7 if inst.task then inst.task:Cancel() inst.task = nil end
8 if inst.task2 then inst.task2:Cancel() inst.task2 = nil end
9 if inst.doll then inst.doll:Remove() inst.doll = nil end
10 inst.components.locomotor:Stop()
11 inst.components.playercontroller:Enable(false)
12 SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition())
13 inst.SoundEmitter:PlaySound("dontstarve/creatures/spiderqueen/scream_short")
14 inst:DoTaskInTime(0.1, function()
15 inst.AnimState:SetBank("spider_queen")
16 inst.AnimState:SetBuild("spider_queen_build")
17 inst.AnimState:PlayAnimation("idle", true)
18 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
19 inst:SetStateGraph("SGspiderqueen")
20 shadow:SetSize( 7, 3 )
21 inst.components.locomotor.walkspeed = 15
22 inst.components.locomotor.runspeed = 20
23 inst.components.health:SetInvincible(true)
24 inst.components.hunger:Pause()
25 inst.components.combat:SetDefaultDamage(300)
26 inst.components.temperature:SetTemp(20)
27 inst.components.playercontroller:Enable(true)
28 local pt = GetPlayer():GetPosition()
29 inst.doll = SpawnPrefab( "beardhair" )
30 inst.doll.Transform:SetPosition(pt.x, 3.5, pt.z)
31 inst.doll.Physics:SetActive(false)
32 inst.doll.AnimState:SetBank("wilson")
33 inst.doll.AnimState:SetBuild(name)
34 inst.doll.AnimState:OverrideSymbol("swap_object", "swap_spear", "swap_spear")
35 inst.doll.AnimState:Hide("ARM_normal")
36 inst.doll.AnimState:Show("ARM_carry")
37 inst.doll.Transform:SetFourFaced()
38 inst.doll.AnimState:PlayAnimation("idle")
39 inst.doll:RemoveComponent("burnable")
40 inst.doll:RemoveComponent("propagator")
41 inst.doll:RemoveComponent("inspectable")
42 inst.doll:RemoveComponent("inventoryitem")
43 inst.doll:RemoveComponent("stackable")
44 inst.doll:RemoveComponent("fuel")
45 inst.task = inst:DoPeriodicTask(.05, function()
46 local pt1 = GetPlayer():GetPosition()
47 inst.doll.Transform:SetPosition(pt1.x, 3.5, pt1.z)
48 inst.doll.Transform:SetRotation(GetPlayer().Transform:GetRotation())
49 end )
50 inst.task2 = inst:DoPeriodicTask(10, function()
51 inst.doll.AnimState:PlayAnimation("give",true)
52 inst:DoTaskInTime(2.2, function() inst.doll.AnimState:PlayAnimation("idle") end )
53 end )
54 end )
55end )
56TheInput:AddKeyUpHandler(KEY_PAGEDOWN, function()
57 inst.components.locomotor:Stop()
58 inst.components.playercontroller:Enable(false)
59 SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition())
60 inst.SoundEmitter:PlaySound("dontstarve/creatures/spiderqueen/scream_short")
61 inst:DoTaskInTime(0.1, function()
62 inst.AnimState:SetBank("wilson")
63 inst.AnimState:SetBuild(name)
64 inst.AnimState:PlayAnimation("idle")
65 inst.AnimState:SetBloomEffectHandle("")
66 inst:SetStateGraph("SGwilson")
67 shadow:SetSize( 1.3, .6 )
68 inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED
69 inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED
70 inst.components.health:SetInvincible(false)
71 inst.components.hunger:Resume()
72 inst.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE)
73 inst.components.temperature:SetTemp(nil)
74 inst.components.playercontroller:Enable(true)
75 if inst.task then inst.task:Cancel() inst.task = nil end
76 if inst.task2 then inst.task2:Cancel() inst.task2 = nil end
77 if inst.doll then inst.doll:Remove() inst.doll = nil end
78 end )
79end )
80
81 即可按键盘PageUP键召唤蜘蛛座骑(自动骑在蜘蛛身上),按PageDown键取消座骑。攻击时对敌人按Ctrl + 鼠标左键(也可以按住F键连续还击)。骑在蜘蛛身上时,敌人无法打到主角,所以主角不会掉血