Jump to content

Help with a Weird Proximity Modifyer


Recommended Posts

Hey guys,

So I was working on my character mod, which currently almost finished for Don't Starve, and on track for being put into Don't Starve Together. For Don't Starve Together, however, I would like to add a damage modifyer based on my character's proximity to the character Willow. The closer my character is, the more damage he would do, up to 2X is my plan. But the honest truth is that I am unsure of how to add this to my mod, or if this is even possible. Any help would be greatly appreciated, as I am still learning the more advanced side of luas.

 

For those wondering, here are some pictures of my character, Jake the Banjo-Playing Detective, and the mod itself in its current state can be found here. (Currently DS only)

post-652109-0-04746900-1439857561_thumb.

post-652109-0-23769100-1439858011_thumb.

Link to comment
Share on other sites

@TheSlackPack:

-- outside master_postinit of character.lualocal function WillowBonus(inst)    local x, y, z = inst.Transform:GetWorldPosition()	local bonus_mult = 1    local min_rad = 5    local max_rad = 10	local med_rad = min_rad + (max_rad - min_rad) / 2    local ents = TheSim:FindEntities(x, y, z, med_rad, { "player" }, { "playerghost" })    for i, v in ipairs(ents) do        if v.prefab == "willow" then			local dist = math.sqrt(inst:GetDistanceSqToInst(v))			if dist <= min_rad then				bonus_mult = bonus_mult + 1			else				bonus_mult = bonus_mult + 0.5			end			-- It's 0 for more than med_rad, so we don't calculate or bother looking over that in FindEntities        end    end	return bonus_mult	-- No willow, x1 mult	-- One close willow, x2 mult	-- Two close willow, x3 multend-- inside master_postinit of character.lualocal my_multiplier = 2local old_CalcDamage = inst.components.combat.CalcDamageinst.components.combat.CalcDamage = function(self, target, weapon, multiplier)	multiplier = (multiplier or 1) * WillowBonus(self.inst)	return old_CalcDamage(self, target, weapon, multiplier)end
Link to comment
Share on other sites

@DarkXero,
I am running into one problem: When I put this in my character lua, the game states there's a traceback error around the posts I made inside the master_postinit. 

Here is my mod so if you would like to check out the actual lua file and see what's wrong:Jake(Beta).zip

 

Here's just a quick copy/paste of what's inside my master_postinit:

 
-- This initializes for the server only. Components are added here.local master_postinit = function(inst)-- choose which sounds this character will playinst.soundsname = "jake"local my_multiplier = 2local old_CalcDamage = inst.components.combat.CalcDamageinst.components.combat.CalcDamage = function(self, target, weapon, multiplier)    multiplier = (multiplier or 1) * WillowBonus(self.inst)    return old_CalcDamage(self, target, weapon, multiplier)-- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used    --inst.talker_path_override = "dontstarve_DLC001/characters/"-- Stats inst.components.health:SetMaxHealth(150)inst.components.hunger:SetMax(150)inst.components.sanity:SetMax(175)-- Damage multiplier (optional)    inst.components.combat.damagemultiplier = 1.25-- Hunger rate (optional)inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATEinst.OnLoad = onload    inst.OnNewSpawn = onloadreturn MakePlayerCharacter("jake", prefabs, assets, common_postinit, master_postinit, start_inv)endOnce again any help is greatly appreciated

 

Edited by TheSlackPack
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...