alexaldin Posted October 27, 2016 Share Posted October 27, 2016 (edited) I'm making a new character based on my girlfriend, to gift it for Christmas. We play a lot DST, and I thought it will be funny to see her play as her! I need help with two things. 1: Since she is afraid of spider, I thought of making her drop a bit of sanity and do damage vs them like 1.75% stronger, but can't find the right code anywhere. 2: I want to give her an healing aura. Not too much, just a bit, and I don't know what to use. I found two codes that can do the job, since in the Workshop there's two thing that give the healing aura, but they are not character. One is an item, one a creature. The first one is Lyrica Keyboard link to Workshop, that when you click with right button use this code (I think): Quote local function keyboard_aura(inst) local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner owner.SoundEmitter:PlaySound("dontstarve/wilson/onemanband") if owner then local x,y,z = owner.Transform:GetWorldPosition() local range = 15 local ents = TheSim:FindEntities(x,y,z, range) local rate = .01 * owner.components.health.maxhealth owner.components.health:DoDelta(rate) for i,v in ipairs(ents) do if not TheNet:GetPVPEnabled() and v:HasTag("player") and v ~= owner then rate = .01 * v.components.health.maxhealth v.components.health:DoDelta(rate) end end for v in pairs(owner.components.leader.followers) do rate = .01 * v.components.health.maxhealth v.components.health:DoDelta(rate) end end end OR This one is from a creature from the character mod Celnar, the Supportoise, that sometimes emits healing aura. Think the code is this: Quote local function HealAura(inst) -- Cancel the task if we already have one running if inst.HealAura then inst.HealAura:Cancel() inst.HealAura = nil end local p = inst:GetPosition() for _,v in ipairs(TheSim:FindEntities(p.x, p.y, p.z, 12, nil, nil, {"player", "toad"})) do if v and v.components and v.components.health then v.components.health:DoDelta(5) end end -- Launch a tracer so we know what's up SpawnPrefab("sparks").Transform:SetPosition(inst:GetPosition():Get()) -- Schedule it to happen again inst.HealAura = inst:DoTaskInTime(math.random(25,30), HealAura) end How can I adjust them for my character? Edited October 27, 2016 by alexaldin Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/ Share on other sites More sharing options...
. . . Posted October 27, 2016 Share Posted October 27, 2016 7 minutes ago, alexaldin said: I want to give her an healing aura. Not too much, just a bit WIll the healing aura always be active? Does it heal someone every 1 second? Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-830147 Share on other sites More sharing options...
alexaldin Posted October 27, 2016 Author Share Posted October 27, 2016 2 minutes ago, SuperDavid said: WIll the healing aura always be active? Does it heal someone every 1 second? I think it's better always active, like 0.05 point every 1 second, so it's not too unbalanced. Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-830149 Share on other sites More sharing options...
. . . Posted October 27, 2016 Share Posted October 27, 2016 will the range of the healing be close, medium or far? Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-830152 Share on other sites More sharing options...
alexaldin Posted October 28, 2016 Author Share Posted October 28, 2016 Medium Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-830155 Share on other sites More sharing options...
. . . Posted October 28, 2016 Share Posted October 28, 2016 (edited) I tested this code it should work, if it causes a crash or doesn't work tell me . You would put them both in mycharacter.lua under master_postinit. If you want the healing aura to be only for a specific character like for example if you have your own unique character I can do that too. With this code your character will deal 10 bonus damage to all spiders when you attack them & your character will give any player in a med dist a .5 health every 1 second. -- Deal bonus damage to spiders. inst:ListenForEvent("onattackother", function(inst, data) if data.target:HasTag("spider") then -- if the target is a spider (does not count webber) data.target.components.health:DoDelta(-10) -- deal 10 bonus damage with any attack (even fists) inst.components.talker:Say("AHHHH, STAY AWAY!") -- Say something special, if you want end end) -- Every 1 second any player within a medium distance will restore 0.5 health. inst:DoPeriodicTask(1, function() if inst:HasTag("playerghost") or inst.components.health:IsDead() then -- Do not heal others if you are dead. return end local x, y, z = inst.Transform:GetWorldPosition() local players = FindPlayersInRange(x, y, z, (8), true) -- You can change "8" to any number it's the dist this code activates for _, v in pairs(players) do if (v~=inst) then v.components.health:DoDelta(.5) -- amount of healing --v.components.sanity:DoDelta(.15) --if you want a tiny sanity heal too :) end end end) Edited October 28, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-830167 Share on other sites More sharing options...
alexaldin Posted October 28, 2016 Author Share Posted October 28, 2016 Awesome! Thank you very much, I let you know if it work Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-830171 Share on other sites More sharing options...
alexaldin Posted November 6, 2016 Author Share Posted November 6, 2016 Here I am again. The mod was a success, it worked really well ^^ But, she has no negative side. How can I make her lose sanity when near spider? Can't find a similar script anywhere... Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-834157 Share on other sites More sharing options...
. . . Posted November 6, 2016 Share Posted November 6, 2016 you'd put this in your character's modmain, this make it that she loses moar sanity from anything that's a spider if GLOBAL.TheNet:GetIsServer() then AddComponentPostInit("sanityaura", function(self) local old = self.GetAura function self:GetAura(observer) if observer.prefab == "nicole" and self.inst:HasTag("spider") then return -999999999999999 -- Change number for desired effect end return old(self,observer) end end) end Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-834304 Share on other sites More sharing options...
alexaldin Posted November 6, 2016 Author Share Posted November 6, 2016 Thank you mate! You are really awesome. How will this work? If she sees a spider she will lose how much sanity in how much time? So I know what number to put there. Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-834315 Share on other sites More sharing options...
. . . Posted November 6, 2016 Share Posted November 6, 2016 1 hour ago, alexaldin said: If she sees a spider she will lose how much sanity in how much time? So I know what number to put there. I really have no idea, hahaha.... If I was you I'd start messing with numbers like -1, -2 ect Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-834358 Share on other sites More sharing options...
alexaldin Posted November 6, 2016 Author Share Posted November 6, 2016 45 minutes ago, SuperDavid said: I really have no idea, hahaha.... If I was you I'd start messing with numbers like -1, -2 ect Nice ahahah Okay, thank you ^^ If you want to see the mod click here. I uploaded it into the workshop, with great success! Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-834371 Share on other sites More sharing options...
alexaldin Posted November 7, 2016 Author Share Posted November 7, 2016 (edited) Quote local function onkilledbyother(inst, attacker) if attacker and attacker.components.sanity then attacker.components.sanity:DoDelta(inst.sanityreward or TUNING.SANITY_SMALL) end end Is this the code when killed to give a little sanity? How can I edit it to when she kill a spider give her like 1-2 of sanity? EDIT: Found this from wathgrithr.lua Quote local function onkilled(inst, data) local victim = data.victim if IsValidVictim(victim) then -- local delta = victim.components.combat.defaultdamage * 0.25 -- inst.components.health:DoDelta(delta, false, "battleborn") -- inst.components.sanity:DoDelta(delta) if not victim.components.health.nofadeout and (victim:HasTag("epic") or math.random() < .1) then local time = victim.components.health.destroytime or 2 local x, y, z = victim.Transform:GetWorldPosition() local scale = (victim:HasTag("smallcreature") and smallScale) or (victim:HasTag("largecreature") and largeScale) or medScale inst:DoTaskInTime(time, spawnspirit, x, y, z, scale) end end end To make it only for spider and sanity: Quote local function onkilled(inst, data) if data.target:HasTag("spider") then inst.components.sanity:DoDelta(+1) end end Right? Edited November 7, 2016 by alexaldin Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-834384 Share on other sites More sharing options...
. . . Posted November 7, 2016 Share Posted November 7, 2016 (edited) Um, to be honest I don't know how to use the onkill or whatever function xD... For what you want to achieve the best I can say is to replace -- Deal bonus damage to spiders. inst:ListenForEvent("onattackother", function(inst, data) if data.target:HasTag("spider") then -- if the target is a spider (does not count webber) data.target.components.health:DoDelta(-10) -- deal 10 bonus damage with any attack (even fists) inst.components.talker:Say("AHHHH, STAY AWAY!") -- Say something special, if you want end end) with this -- Deal bonus damage to spiders. inst:ListenForEvent("onattackother", function(inst, data) if data.target:HasTag("spider") then data.target.components.health:DoDelta(-10) inst.components.talker:Say("AHHHH, STAY AWAY!") inst.components.sanity:DoDelta(.1) -- For real this is all you need, just put it into the bonus damage she deals to spider thing end end) she would heal a tenth of a point of sanity whenever she hits a spider, I think that's pretty okay for what you want too. EDIT: Also Wigfrids code I think works that if she doesn't get the kill & someone else kills it even though she hit it the most she still no boost, so the way I recommend might be even better. Edited November 7, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-834386 Share on other sites More sharing options...
alexaldin Posted November 7, 2016 Author Share Posted November 7, 2016 I'm adjusting the number, but it's working perfectly I'm using a 1 instead of the .1, cause the Quote if GLOBAL.TheNet:GetIsServer() then AddComponentPostInit("sanityaura", function(self) local old = self.GetAura function self:GetAura(observer) if observer.prefab == "nicole" and self.inst:HasTag("spider") then return -3 -- Change number for desired effect end return old(self,observer) end end) end draw like a crazy the sanity when they are really close! I think this code modify the normal sanity aura drop, like multiple times. Cause if you stay at medium range the sanity drop is normal, then when you get close to attack the sanity goes like "One, two, three, four" at the same speed as you can read it! Link to comment https://forums.kleientertainment.com/forums/topic/71204-help-for-a-new-character/#findComment-834390 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