Mr.Mulk Posted August 18, 2015 Share Posted August 18, 2015 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) Link to comment Share on other sites More sharing options...
DarkXero Posted August 18, 2015 Share Posted August 18, 2015 @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 More sharing options...
Mr.Mulk Posted August 18, 2015 Author Share Posted August 18, 2015 Thank you! I really appreciate the help you are awesome! If you would like me to give you some credit on the mod page simply let me know, as I have been trying to figure this out for a while. Link to comment Share on other sites More sharing options...
Mr.Mulk Posted August 18, 2015 Author Share Posted August 18, 2015 (edited) @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 August 18, 2015 by TheSlackPack Link to comment Share on other sites More sharing options...
DarkXero Posted August 18, 2015 Share Posted August 18, 2015 @TheSlackPack:jake.lua Link to comment Share on other sites More sharing options...
Mr.Mulk Posted August 18, 2015 Author Share Posted August 18, 2015 @DarkXero,That seems to be working perfectly! Thank you a ton. I will test the damage modifier later and notify you if there's anything else that needs to be fixed. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now