[SW-induced RoG bug] Koalaphants show no fear


Recommended Posts

I decided to play a little RoG today after playing way too much shipwrecked, and lo and behold! Somehow SW is screwing with RoG a little. Koalaphants no longer run away when I approach them, either while awake or sleeping. This does take some of the difficulty out of killing them, but I'm actually against that. That's what made them a fun challenge, worth all that tasty meat. Does this have something to do with whales?

 

Apologies if this has been addressed already. I think I remember someone else complaining about it, but I couldn't find the post with the search function.

 

Thanks again, Capy and Klei, for making a wonderful game and for listening to your players and being prompt with fixes!

Link to comment
Share on other sites

How could one DLC interfere with another? Playing RoG, Shipwrecked files are not even loaded.

 

I have no idea how it happened, I only know that now that I have SW, koalaphants will just stand there and let me hit them. Even if I run directly into them, they don't run away.

post-580207-0-81022600-1451402161_thumb.

Link to comment
Share on other sites

How could one DLC interfere with another? Playing RoG, Shipwrecked files are not even loaded.

A fair amount of Shipwrecked was actually applied to the base game. Even if you uninstall any DLCs, Koalefants will stay put when approached, so this is a bug in Don't Starve that happened to coincide with Shipwrecked--possibly the latest update.

 

The culprit is in scripts/behaviours/runaway.lua, line 59. It's part of an if-elseif-else block with the following contents:

 

		if type(self.hunterparams) == "string" then			self.hunter = FindEntity(self.inst, self.see_dist, nil, {self.hunterparams}, {'notarget'} )        elseif type(self.hunterparams) == "function" then            self.hunter = self.hunterparams(self.inst)        else			self.hunter = FindEntity(self.inst, self.see_dist, self.hunterparams)		end
Normally this wouldn't be too helpful, but we have the Don't Starve Together version of this script to compare with:

 

		if type(self.hunterparams) == "string" then			self.hunter = FindEntity(self.inst, self.see_dist, nil, {self.hunterparams}, {'notarget'} )		else			self.hunter = FindEntity(self.inst, self.see_dist, self.hunterparams)		end
See that extra "elseif" clause in there? That's what's causing the problem. If you comment out lines 59 and 60, Koalefants run away again. So what's that doing, exactly?

 

scripts/brains/koalefantbrain.lua passes a function called ShouldRunAway to its brain constructor, which in this file is the "self.hunterparams" field. The old way of checking nearby entities would pass this function into FindEntity, which ran it on the list of nearby entities to determine whether it qualified. The new way, with that elseif in there, explicitly checks for a function and uses it to directly determine who it is it should be running away from.

 

Thing is, ShouldRunAway doesn't return an entity like the RunAway bahavior expects, but rather returns true or false because it was designed to work as a parameter to FindEntity. It's always being called with the Koalefant itself as the entity to check, which of course means it always returns false because it's very difficult to run away from oneself.

 

I don't know why that elseif clause was added to runaway.lua, but I don't recommend commenting it out because it will probably break something else. I have some errands to run, but when I get back, I'll post a quick hack for koalefantbrain.lua that should at least fix this particular problem in the short-term.

Link to comment
Share on other sites

Okay, I have a fix for the Koalefant's fearlessness now.

Within scripts/brains/koalefantbrain.lua, you'll find this on line 28:
 

local function ShouldRunAway(guy)	return guy:HasTag("character") and not guy:HasTag("notarget")end

Once again, the reason this breaks is because scripts/behaviors/runaway.lua was changed in such a way that it executes this function expecting an entity as the return value, whereas it's currently returning a boolean.

 

Instead, we can work around the problem by having this function do what the old version of runaway.lua did, only locally. This should prevent whatever else this was implemented for from breaking. Replace the function in koalefantbrain.lua with the following:

local function ShouldRunAway(inst)	return FindEntity(inst, RUN_AWAY_DIST, function(guy)		return guy:HasTag("character") and not guy:HasTag("notarget")	end)end

Now Koalefants will again avoid the player.

Link to comment
Share on other sites

Okay, I have a fix for the Koalefant's fearlessness now.

 

 

Wow! Thanks for all the useful info! Unfortunately I am not confident enough in my coding ability to make these changes myself, but hopefully your info will help someone else with the same problem! I'll just keep killing koalaphants in cold blood until the devs patch it.

 

Link to comment
Share on other sites

I was grep'ing my way through the files and found that Floaty Boaty Knight has this same bug, so I decided a more general fix was in order. Patching RunAway so that it detects whether its hunterparams fields returns a boolean on execute, then wrapping around it with a function that calls FindEntity, will fix this problem in a broader sense.

 

scripts/behaviours/runaway.lua, bottom of the file:

-- Run-once wrapper method to intercept misconfigured hunterparams functionslocal Visit = RunAway.Visitfunction RunAway:Visit()    -- Check whether hunterparams() returns a boolean    local hp = self.hunterparams    if type(hp) == "function" and type(hp(self.inst)) == "boolean" then        -- Wrapper function to make hunterparams() return an entity        self.hunterparams = function()            return FindEntity(self.inst, self.see_dist, hp)        end    end    -- Restore original Visit method    self.Visit = Visit    self:Visit()end
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.