toxictester Posted June 8, 2016 Share Posted June 8, 2016 Hello! I'm Toxictester, a not-that new modder (i made my first mod at the beginning of this year i think ). I was wondering if I could get some help on coding some of the Plague Doctor's abilities? ABILITIES (also listed in above picture): x1.5 sanity drain More health gain from healing items More sanity gain from crockpot foods Sanity gain from killing monsters Death at 0 sanity Uses poison damage (inflicts damage over a period of time) Telltale hearts cost less health I'm sure I can find code for the x1.5 sanity drain, poison damage, and extra sanity from killing monsters. So can anyone lend me a hand towards her other abilities (extra sanity gain from crockpot, more health from healing items, death at 0 sanity, telltale hearts costing less)? Any help would be greatly appreciated ! Link to comment https://forums.kleientertainment.com/forums/topic/68016-help-coding-custom-character-abilities/ Share on other sites More sharing options...
Aquaterion Posted June 8, 2016 Share Posted June 8, 2016 (edited) When you say "more health gain from healing items" do you mean "heal" items like spider gland or foods that give health like fish sticks? as for some others: "More sanity gain from crockpot foods": --in ur character.lua local function oneat(eater, food) local fooditem = food.prefab local crockpotfoods = require("preparedfoods") if table.containskey(crockpotfoods, fooditem) and eater.components.sanity then --if its a crockpot food eater.components.sanity:DoDelta(20)--change 20 to whatever you want end end -- in ur characters master_postinit function inst.components.eater:SetOnEatFn(oneat) "Death at 0 sanity": --in ur character.lua -- in ur characters master_postinit function inst:ListenForEvent("sanitydelta", function(inst, data) if data.newpercent == 0 then inst.components.health:Kill() end end) Edited June 8, 2016 by Aquaterion Link to comment https://forums.kleientertainment.com/forums/topic/68016-help-coding-custom-character-abilities/#findComment-781140 Share on other sites More sharing options...
toxictester Posted June 8, 2016 Author Share Posted June 8, 2016 Ah, thank you for a speedy reply! By the health gain from healing items, i DO mean spider glands, healing salve, ect. Link to comment https://forums.kleientertainment.com/forums/topic/68016-help-coding-custom-character-abilities/#findComment-781142 Share on other sites More sharing options...
Aquaterion Posted June 8, 2016 Share Posted June 8, 2016 (edited) --in modmain.lua AddComponentPostInit("healer", function(self) local oldheal = self.Heal function self:Heal(target) if target.components.health then target:PushEvent("consumehealer", {healer = self.inst.prefab, healing = self.health}) oldheal(self, target) end end end) --in ur character.lua -- in ur characters master_postinit function inst:ListenForEvent("consumehealer", function(inst, data) inst.components.health:DoDelta(data.healing*0.25)-- +25% extra from normal amount end) haven't tried it but should work Edited June 8, 2016 by Aquaterion edited to the working version Link to comment https://forums.kleientertainment.com/forums/topic/68016-help-coding-custom-character-abilities/#findComment-781156 Share on other sites More sharing options...
toxictester Posted June 8, 2016 Author Share Posted June 8, 2016 I got this error message from the healing strings Link to comment https://forums.kleientertainment.com/forums/topic/68016-help-coding-custom-character-abilities/#findComment-781175 Share on other sites More sharing options...
Aquaterion Posted June 8, 2016 Share Posted June 8, 2016 (edited) did you add the first part to modmain.lua? if so, try changing target:PushEvent("consumehealer", self.inst.prefab, self.health) --to target:PushEvent("consumehealer", self.inst.prefab, self.inst.components.healer.health) Edited June 8, 2016 by Aquaterion Link to comment https://forums.kleientertainment.com/forums/topic/68016-help-coding-custom-character-abilities/#findComment-781191 Share on other sites More sharing options...
toxictester Posted June 8, 2016 Author Share Posted June 8, 2016 Yeah, it still doesn't seem to be working :/ Wouldn't the issue be in the character.lua? Or at least that's what the game's warning message is pointing at inst:ListenForEvent("consumehealer", function(inst, healer, amount) inst.components.health:DoDelta(amount*0.25)-- +25% extra from normal amount end) Here's my script btw: Link to comment https://forums.kleientertainment.com/forums/topic/68016-help-coding-custom-character-abilities/#findComment-781199 Share on other sites More sharing options...
Aquaterion Posted June 8, 2016 Share Posted June 8, 2016 ok so this should work target:PushEvent("consumehealer", self.inst.prefab, self.health) --to target:PushEvent("consumehealer", {healer = self.inst.prefab, healing = self.health}) and inst:ListenForEvent("consumehealer", function(inst, healer, amount) inst.components.health:DoDelta(amount*0.25)-- +25% extra from normal amount end) --to inst:ListenForEvent("consumehealer", function(inst, data) inst.components.health:DoDelta(data.healing*0.25)-- +25% extra from normal amount end) Link to comment https://forums.kleientertainment.com/forums/topic/68016-help-coding-custom-character-abilities/#findComment-781202 Share on other sites More sharing options...
toxictester Posted June 8, 2016 Author Share Posted June 8, 2016 Yes, that works, thank you! Link to comment https://forums.kleientertainment.com/forums/topic/68016-help-coding-custom-character-abilities/#findComment-781230 Share on other sites More sharing options...
Aquaterion Posted June 9, 2016 Share Posted June 9, 2016 14 hours ago, toxictester said: Yes, that works, thank you! btw if whenever you use a healer item, your character says "I can't do that" or something similar --change oldheal(self, target) --to return oldheal(self, target) Link to comment https://forums.kleientertainment.com/forums/topic/68016-help-coding-custom-character-abilities/#findComment-781474 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