Search the Community
Showing results for tags 'reanimation'.
I'm trying to make bernie activate and be active only when Willow is insane. I successfully made it so that he doesn't activate for characters that are now Willow, but there is a bug in relation to reanimating when Willow is insane. I added this code (with "end" being placed where appropriate): if v.prefab == "willow" then Underneath "for i, v in ipairs(AllPlayers) do" for both bernie_active.lua: local function tryreanimate(inst) local target = nil local rangesq = 256 --[[16 * 16]] local x, y, z = inst.Transform:GetWorldPosition() for i, v in ipairs(AllPlayers) do if v.prefab == "willow" then if v.components.sanity:IsCrazy() and v.entity:IsVisible() then local distsq = v:GetDistanceSqToPoint(x, y, z) if distsq < rangesq then rangesq = distsq target = v end end end end if target ~= nil then local active = SpawnPrefab("bernie_active") if active ~= nil then --Transform fuel % into health. active.components.health:SetPercent(inst.components.fueled:GetPercent()) active.Transform:SetPosition(inst.Transform:GetWorldPosition()) inst:Remove() end end end and berniebrain.lua: local function FindLeader(self) self._leader = nil local rangesq = LOSE_LEADER_DIST_SQ local x, y, z = self.inst.Transform:GetWorldPosition() for i, v in ipairs(AllPlayers) do if v.prefab == "wollow" then if v.components.sanity:IsCrazy() and v.entity:IsVisible() then local distsq = v:GetDistanceSqToPoint(x, y, z) if distsq < rangesq then rangesq = distsq self._leader = v end end end end end return self._leader end Yet, for some reason, Bernie wakes up for 2 - 3 seconds and then sits back down again and keeps doing that over and over, deactivating and activating when he should just be active. This code is written inside copied files of bernie_active.lua and berniebrain.lua from the actual game (there is a reason as to why I'm simplifying this for myself and not using modmain.lua almost at all, but that's besides the point). I also indented any functions and variables related to decaying for Bernie in bernie_inactive.lua. And yes, I was standing next to him when he did that, in fact he does that whilst I'm standing right on top of him as Willow!