dave9664 Posted March 12, 2015 Share Posted March 12, 2015 I'm struggling on making the player get a sanity boost during the day, and when he kills any monsters or creatures, please help, been stuck for hours and tried putting in code from other topics but just doesn't work. Also, I literally have no idea what I'm doing with the code so if you could specify exactly where to put the code, that would be super, thanks! Link to comment Share on other sites More sharing options...
DrSmugleaf Posted March 12, 2015 Share Posted March 12, 2015 (edited) From (I believe rezecib's?) mod for vanilla characters, Wigfrid: To get sanity on killIn your character prefab:local function onkill(inst, data) if data.afflicter == inst and not data.inst:HasTag("prey") and not data.inst:HasTag("veggie") and not data.inst:HasTag("structure") then local delta = (data.inst.components.combat.defaultdamage) * 0.25 if data.inst:HasTag("player") then delta = TUNING.WILSON_HEALTH * 0.15 end inst.components.health:DoDelta(delta, false, "battleborn") inst.components.sanity:DoDelta(delta) if math.random() < .1 and not data.inst.components.health.nofadeout then local time = data.inst.components.health.destroytime or 2 inst:DoTaskInTime(time, function() local s = medScale if data.inst:HasTag("smallcreature") then s = smallScale elseif data.inst:HasTag("largecreature") then s = largeScale end local fx = SpawnPrefab("wathgrithr_spirit") fx.Transform:SetPosition(data.inst:GetPosition():Get()) fx.Transform:SetScale(s,s,s) end) end endend In your character's prefab master_postinitinst:ListenForEvent("entity_death", function(wrld, data) onkill(inst, data) end, TheWorld)From thana: To gain sanity during the dayIn your character's prefab master_postinitinst.components.sanity.dapperness = TUNING.DAPPERNESS_MED * (1.2)Basically just adds a passive regen. Increase the night_drain_mult if you want it to counteract during the night:inst.components.sanity.night_drain_mult = 1.55 Edited March 12, 2015 by DrSmugleaf Link to comment Share on other sites More sharing options...
dave9664 Posted March 13, 2015 Author Share Posted March 13, 2015 Thanks, just tried it but the game crashes when I'm killing stuff, any ideas? Link to comment Share on other sites More sharing options...
DarkXero Posted March 13, 2015 Share Posted March 13, 2015 Remove the if with:math.random() < .1 and not data.inst.components.health.nofadeoutleave code up to the deltas. Link to comment Share on other sites More sharing options...
dave9664 Posted March 13, 2015 Author Share Posted March 13, 2015 I've commented out that line but it doesn't load up the game now, can you take a look?wrex.zip Link to comment Share on other sites More sharing options...
DarkXero Posted March 13, 2015 Share Posted March 13, 2015 You fucked up the comment, it should have 2 lines like --.local function onkill(inst, data) if data.afflicter == inst and not data.inst:HasTag("prey") and not data.inst:HasTag("veggie") and not data.inst:HasTag("structure") then local delta = (data.inst.components.combat.defaultdamage) * 0.25 if data.inst:HasTag("player") then delta = TUNING.WILSON_HEALTH * 0.15 end inst.components.health:DoDelta(delta, false, "battleborn") inst.components.sanity:DoDelta(delta) endendis the function you want, and don't change "player" to "wrex". Link to comment Share on other sites More sharing options...
dave9664 Posted March 13, 2015 Author Share Posted March 13, 2015 Hahaha I'm genuinely hopeless!Thanks so much, works perfectly now! Link to comment Share on other sites More sharing options...
dave9664 Posted March 13, 2015 Author Share Posted March 13, 2015 Is there a way to get that to only increase sanity and not health? Character is way too OP now, haha. Link to comment Share on other sites More sharing options...
dave9664 Posted March 13, 2015 Author Share Posted March 13, 2015 Never mind I worked it out on my own! I am learning... 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