代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1 2一九九.人工女友(用蜂刺种三个女友之一,可背东西、做饭、换衣帽) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/stinger.lua文件, 5 6 1.在Asset("ANIM", "anim/stinger.zip"),的下一行插入以下内容: 7 8 Asset("ANIM", "anim/wathgrithr.zip"), 9 Asset("SOUND", "sound/wathgrithr.fsb"), 10 11 12 2.在inst:AddComponent("inspectable")的下一行插入以下内容: 13 14local slotpos = {} 15for y = 5, 0, -1 do 16 for x = 0, 2 do 17 table.insert(slotpos, Vector3(75*x-75*2+75, 75*y-75*2+75,0)) 18 end 19end 20local widgetbuttoninfo = { 21 text = "Do", 22 position = Vector3(68, 361, 0), 23 fn = function(inst) 24 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") 25 if not inst:HasTag("withme") then 26 inst:AddTag("withme") 27 local brain = require "brains/chesterbrain" 28 inst:SetBrain(brain) 29 inst:RestartBrain() 30 inst.components.follower:SetLeader(GetPlayer()) 31 else 32 inst:RemoveTag("withme") 33 inst.components.locomotor:Stop() 34 inst:SetBrain(nil) 35 inst.components.follower:SetLeader(nil) 36 end 37end } 38local function OnDeploy (inst, pt) 39 local girl = SpawnPrefab("stinger") 40 girl.Transform:SetPosition(pt.x, pt.y, pt.z) 41 girl.AnimState:SetBank("wilson") 42 local girlnames = {"wendy","willow","wathgrithr"} 43 girl.buildname = girlnames[math.random(#girlnames)] 44 girl.AnimState:SetBuild(girl.buildname) 45 girl.AnimState:PlayAnimation("idle") 46 girl.AnimState:Show("ARM_normal") 47 girl.AnimState:Hide("ARM_carry") 48 girl.Transform:SetFourFaced() 49 girl.entity:AddSoundEmitter() 50 local shadow = girl.entity:AddDynamicShadow() 51 shadow:SetSize( 1.3, .6 ) 52 MakeCharacterPhysics(girl, 75, .5) 53 local minimap = girl.entity:AddMiniMapEntity() 54 minimap:SetIcon( "wendy.png" ) 55 girl:RemoveComponent("stackable") 56 girl:RemoveComponent("inventoryitem") 57 girl:RemoveComponent("deployable") 58 girl:AddComponent("named") 59 girl.components.named:SetName("My Baby") 60 girl:AddComponent("knownlocations") 61 girl:AddComponent("follower") 62 girl.components.follower:SetLeader(GetPlayer()) 63 girl:AddComponent("inventory") 64 girl.components.container.canbeopened = true 65 girl:AddComponent("locomotor") 66 girl.components.locomotor.walkspeed = 8 67 girl.components.locomotor.runspeed = 12 68 girl:SetStateGraph("SGshadowwaxwell") 69 local brain = require "brains/chesterbrain" 70 girl:SetBrain(brain) 71 girl:AddComponent("combat") 72 girl:AddComponent("health") 73 girl.components.health:SetMaxHealth(2000) 74 girl:ListenForEvent("death", function() 75 girl.components.container:DropEverything() 76 end ) 77 girl:AddComponent("talker") 78 girl:DoPeriodicTask(60, function() 79 local words = {"I love you","You are my love","I like you","I want stay with you","I miss you","you are my darling","I am your sweetheart","You have to love me","Don't go","Are you hungry"} 80 local word = words[math.random(#words)] 81 girl.components.talker:Say(word, 4, false) 82 girl.components.health:DoDelta(2000) 83 end) 84 girl:DoPeriodicTask(400, function() 85 local names = {"waffles","turkeydinner","baconeggs"} 86 local name = names[math.random(#names)] 87 local foods = SpawnPrefab(name) 88 girl.components.container:GiveItem(foods) 89 girl.components.talker:Say("Come to eat", 4, false) 90 end) 91 girl:AddComponent("machine") 92 girl.components.machine.turnonfn = function(girl) 93 girl.components.machine.ison = true 94 girl:AddTag("neat") 95 local hats = {"hat_flower","hat_earmuffs","hat_feather","hat_slurper","hat_spider","hat_straw","hat_top","hat_walrus","hat_winter","hat_beefalo","hat_rain","hat_catcoon"} 96 girl.hat = hats[math.random(#hats)] 97 local armors = {"armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter","armor_sanity","armor_slurper","torso_rain"} 98 girl.armor = armors[math.random(#armors)] 99 girl.sg:GoToState("hit") 100 girl.AnimState:OverrideSymbol("swap_hat", girl.hat, "swap_hat") 101 girl.AnimState:OverrideSymbol("swap_body", girl.armor, "swap_body") 102 girl.AnimState:Show("HAT") 103 girl.AnimState:Show("HAT_HAIR") 104 girl.AnimState:Hide("HAIR_NOHAT") 105 girl.AnimState:Hide("HAIR") 106 local words = {"I like it","I don't loke it"} 107 local word = words[math.random(#words)] 108 girl.components.talker:Say(word, 4, false) 109 end 110 girl.components.machine.turnofffn = function(girl) 111 girl.components.machine.ison = false 112 girl:RemoveTag("neat") 113 girl.sg:GoToState("stunned") 114 girl.AnimState:Hide("HAT") 115 girl.AnimState:Hide("HAT_HAIR") 116 girl.AnimState:Show("HAIR_NOHAT") 117 girl.AnimState:Show("HAIR") 118 girl.AnimState:ClearOverrideSymbol("swap_body") 119 girl.SoundEmitter:PlaySound("dontstarve/characters/wendy/hurt") 120 girl.components.talker:Say("Don't, Don't, Don't", 4, false) 121 end 122 girl:AddComponent("sanityaura") 123 girl.components.sanityaura.aura = TUNING.SANITYAURA_HUGE 124 girl:ListenForEvent("attacked", function(girl, data) 125 girl.sg:GoToState("stunned") 126 girl.SoundEmitter:PlaySound("dontstarve/characters/wendy/hurt") 127 girl.components.talker:Say("Don't, Don't, Don't", 4, false) 128 end ) 129 girl:AddTag("fridge") 130 girl:AddTag("withme") 131 girl:AddTag("companion") 132 girl:AddTag("girls") 133 inst.components.stackable:Get():Remove() 134end 135 inst:AddComponent("deployable") 136 inst.components.deployable.ondeploy = OnDeploy 137 inst:AddComponent("container") 138 inst.components.container.widgetbuttoninfo = widgetbuttoninfo 139 inst.components.container:SetNumSlots(#slotpos) 140 inst.components.container.widgetslotpos = slotpos 141 inst.components.container.widgetpos = Vector3(0,150,0) 142 inst.components.container.side_align_tip = 160 143 inst.components.container.canbeopened = false 144local function onsave(inst, data) 145 if inst:HasTag("girls") then 146 data.girls = true 147 end 148 if inst:HasTag("withme") then 149 data.withme = true 150 end 151 if inst:HasTag("neat") then 152 data.neat = true 153 end 154 data.buildname = inst.buildname 155 data.hat = inst.hat 156 data.armor = inst.armor 157end 158local function onload(inst, data) 159 if data and data.girls then 160 inst.AnimState:SetBank("wilson") 161 local girlnames = {"wendy","willow","wathgrithr"} 162 inst.buildname = girlnames[math.random(#girlnames)] 163 inst.AnimState:SetBuild(inst.buildname) 164 inst.AnimState:PlayAnimation("idle") 165 inst.AnimState:Show("ARM_normal") 166 inst.AnimState:Hide("ARM_carry") 167 inst.Transform:SetFourFaced() 168 inst.entity:AddSoundEmitter() 169 local shadow = inst.entity:AddDynamicShadow() 170 shadow:SetSize( 1.3, .6 ) 171 MakeCharacterPhysics(inst, 75, .5) 172 local minimap = inst.entity:AddMiniMapEntity() 173 minimap:SetIcon( "wendy.png" ) 174 inst:RemoveComponent("stackable") 175 inst:RemoveComponent("inventoryitem") 176 inst:RemoveComponent("deployable") 177 inst:AddComponent("named") 178 inst.components.named:SetName("My Baby") 179 inst:AddComponent("knownlocations") 180 inst:AddComponent("follower") 181 inst:AddComponent("inventory") 182 inst.components.container.canbeopened = true 183 inst:AddComponent("locomotor") 184 inst.components.locomotor.walkspeed = 8 185 inst.components.locomotor.runspeed = 12 186 inst:SetStateGraph("SGshadowwaxwell") 187 inst:AddComponent("combat") 188 inst:AddComponent("health") 189 inst.components.health:SetMaxHealth(2000) 190 inst:ListenForEvent("death", function() 191 inst.components.container:DropEverything() 192 end ) 193 inst:AddComponent("talker") 194 inst:DoPeriodicTask(60, function() 195 local words = {"I love you","You are my love","I like you","I want stay with you","I miss you","you are my darling","I am your sweetheart","You have to love me","Don't go","Are you hungry"} 196 local word = words[math.random(#words)] 197 inst.components.talker:Say(word, 4, false) 198 inst.components.health:DoDelta(2000) 199 end) 200 inst:DoPeriodicTask(400, function() 201 local names = {"waffles","turkeydinner","baconeggs"} 202 local name = names[math.random(#names)] 203 local foods = SpawnPrefab(name) 204 inst.components.container:GiveItem(foods) 205 inst.components.talker:Say("Come to eat", 4, false) 206 end) 207 inst:AddComponent("machine") 208 inst.components.machine.turnonfn = function(inst) 209 inst.components.machine.ison = true 210 inst:AddTag("neat") 211 local hats = {"hat_flower","hat_earmuffs","hat_feather","hat_slurper","hat_spider","hat_straw","hat_top","hat_walrus","hat_winter","hat_beefalo","hat_rain","hat_catcoon"} 212 inst.hat = hats[math.random(#hats)] 213 local armors = {"armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter","armor_sanity","armor_slurper","torso_rain"} 214 inst.armor = armors[math.random(#armors)] 215 inst.sg:GoToState("hit") 216 inst.AnimState:OverrideSymbol("swap_hat", inst.hat, "swap_hat") 217 inst.AnimState:OverrideSymbol("swap_body", inst.armor, "swap_body") 218 inst.AnimState:Show("HAT") 219 inst.AnimState:Show("HAT_HAIR") 220 inst.AnimState:Hide("HAIR_NOHAT") 221 inst.AnimState:Hide("HAIR") 222 local words = {"I like it","I don't loke it"} 223 local word = words[math.random(#words)] 224 inst.components.talker:Say(word, 4, false) 225 end 226 inst.components.machine.turnofffn = function(inst) 227 inst.components.machine.ison = false 228 inst:RemoveTag("neat") 229 inst.sg:GoToState("stunned") 230 inst.AnimState:Hide("HAT") 231 inst.AnimState:Hide("HAT_HAIR") 232 inst.AnimState:Show("HAIR_NOHAT") 233 inst.AnimState:Show("HAIR") 234 inst.AnimState:ClearOverrideSymbol("swap_body") 235 inst.SoundEmitter:PlaySound("dontstarve/characters/wendy/hurt") 236 inst.components.talker:Say("Don't, Don't, Don't", 4, false) 237 end 238 inst:AddComponent("sanityaura") 239 inst.components.sanityaura.aura = TUNING.SANITYAURA_HUGE 240 inst:ListenForEvent("attacked", function(inst, data) 241 inst.sg:GoToState("stunned") 242 inst.SoundEmitter:PlaySound("dontstarve/characters/wendy/hurt") 243 inst.components.talker:Say("Don't, Don't, Don't", 4, false) 244 end ) 245 inst:AddTag("fridge") 246 inst:AddTag("companion") 247 inst:AddTag("girls") 248 end 249 if data and data.withme then 250 inst:AddTag("withme") 251 local brain = require "brains/chesterbrain" 252 inst:SetBrain(brain) 253 inst:RestartBrain() 254 inst.components.follower:SetLeader(GetPlayer()) 255 end 256 if data and data.neat then 257 inst.components.machine.ison = true 258 inst:AddTag("neat") 259 inst.AnimState:Show("HAT") 260 inst.AnimState:Show("HAT_HAIR") 261 inst.AnimState:Hide("HAIR_NOHAT") 262 inst.AnimState:Hide("HAIR") 263 if data and data.hat then 264 inst.hat = data.hat 265 inst.AnimState:OverrideSymbol("swap_hat", inst.hat, "swap_hat") 266 end 267 if data and data.armor then 268 inst.armor = data.armor 269 inst.AnimState:OverrideSymbol("swap_body", inst.armor, "swap_body") 270 end 271 end 272 if data and data.buildname then 273 inst.buildname = data.buildname 274 inst.AnimState:SetBuild(inst.buildname) 275 end 276end 277 inst.OnSave = onsave 278 inst.OnLoad = onload 279 280 即可用蜂刺种人工女友,随机为温蒂、薇洛、瓦丝格雷斯三人之一。鼠标左键点女友,可打开她的背包格(18格),让她帮你背东西,她的背包带有冷藏功能。点格子右上方的“Do”按钮,可让女友停留在原地,再次点“Do”按钮可继续跟随,如果你殴打她,她不再跟随你,也可通过点“Do”按钮让她继续跟随。鼠标右键点女友,可为她随机更换衣帽,再次点击可脱下衣帽,搭配好的衣帽会一直保留在她身上,不受存读档影响。每天女友会为你做一份料理,在她的背包格中拿取。女友会不时对你说话,与她紧紧依偎可以补脑(不再孤独了)。女友没有战斗能力,如果遇到敌人,要保护好她哦,你也可以选择逃跑,她会努力跟上你的,如果她遇难了,背包里的物品将掉在地上。不想要女友了,杀掉即可(按Ctrl + 鼠标左键攻击)。不要与“用蜂刺种杀人蜂窝”一同修改