Shinoryoshu Posted September 2, 2016 Share Posted September 2, 2016 (edited) So I'm doing my first mod and the character I decided to do a mod on is someone who powers up from absorbing electricity. Is their a way to add to the script to where when she gets struck by lightning that she powers up permanently kinda like WX, but an actual damage increase and immunity to it? This is the last thing i need before uploading Edited September 2, 2016 by Shinoryoshu added and revised Link to comment Share on other sites More sharing options...
. . . Posted September 3, 2016 Share Posted September 3, 2016 By permanently do you mean when you log the character still keeps the damage boost from lightning strikes? Link to comment Share on other sites More sharing options...
Shinoryoshu Posted September 3, 2016 Author Share Posted September 3, 2016 It doesnt really matter if it persists through log sessions I was just thinking that it should persist through one session then resets after game closes, and you re-log. Link to comment Share on other sites More sharing options...
. . . Posted September 3, 2016 Share Posted September 3, 2016 (edited) 24 minutes ago, Shinoryoshu said: persist through one session then resets after game closes -- Stuff inside here will activate eachtime your character gets struck by lightning. inst:ListenForEvent("lightningstrike", function(inst, data) inst.components.talker:Say("I feel so alive!") inst:AddTag("electricdamageimmune") -- Immune to electric damage. inst.components.burnable.lightningimmune = true -- Immune to lightning. local x, y, z = inst.Transform:GetWorldPosition() -- Cool effect. SpawnPrefab("sparks").Transform:SetPosition(x, y, z) -- Cool effect. end) inst:AddTag("lightningrod") -- If you want your character to always get struck by lightning. Edited September 3, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
Shinoryoshu Posted September 3, 2016 Author Share Posted September 3, 2016 8 minutes ago, SuperDavid said: -- Stuff inside here will activate eachtime your character gets struck by lightning. inst:ListenForEvent("lightningstrike", function(inst, data) inst:AddTag("electricdamageimmune") -- Immune to electric damage. inst.components.burnable.lightningimmune = true -- Immune to lightning. local x, y, z = inst.Transform:GetWorldPosition() -- Cool effect. SpawnPrefab("sparks").Transform:SetPosition(x, y, z) -- Cool effect. end) inst:AddTag("lightningrod") -- If you want your character to always get struck by lightning. Dude you rock i saw come code lines in WX's script, but I couldn't figure out what i needed Link to comment Share on other sites More sharing options...
Shinoryoshu Posted September 3, 2016 Author Share Posted September 3, 2016 13 minutes ago, SuperDavid said: -- Stuff inside here will activate eachtime your character gets struck by lightning. inst:ListenForEvent("lightningstrike", function(inst, data) inst.components.talker:Say("I feel so alive!") inst:AddTag("electricdamageimmune") -- Immune to electric damage. inst.components.burnable.lightningimmune = true -- Immune to lightning. local x, y, z = inst.Transform:GetWorldPosition() -- Cool effect. SpawnPrefab("sparks").Transform:SetPosition(x, y, z) -- Cool effect. end) inst:AddTag("lightningrod") -- If you want your character to always get struck by lightning. forgot to ask, I dont see anything about her damage multiplier. Would that be something like inst.components.combat.damagemultiplier + value or what because I'm kinda new to coding Link to comment Share on other sites More sharing options...
. . . Posted September 3, 2016 Share Posted September 3, 2016 (edited) Oh, I assumed you knew that so that's why I didn't put it, here a go . inst.components.combat.damagemultiplier = 1 -- I think default's 1 so for 50% bonus you would do. inst.components.combat.damagemultiplier = 1.5 or 25% inst.components.combat.damagemultiplier = 1.25 Edited September 3, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
Shinoryoshu Posted September 3, 2016 Author Share Posted September 3, 2016 8 minutes ago, SuperDavid said: Oh, I assumed you knew that here . inst.components.combat.damagemultiplier = 1 -- I think default's 1 so for 50% bonus you would do. inst.components.combat.damagemultiplier = 1.5 or 25% inst.components.combat.damagemultiplier = 1.25 what i'm trying to do is get her to get a multiplier bonus from getting hit. I have her base multiplier in the lua. just not the lightning modifier. Link to comment Share on other sites More sharing options...
. . . Posted September 3, 2016 Share Posted September 3, 2016 10 minutes ago, Shinoryoshu said: what i'm trying to do is get her to get a multiplier bonus from getting hit. I have her base multiplier in the lua. just not the lightning modifier. Um, i'm sorry I don't understand if you still need help so I just say exactly what you need to do ! If you want your character to do 50% more damage damage when she gets striked by lightning you would do like this. In your character.lua under master_postinit you put & that's all inst.components.combat.damagemultiplier = 1 -- Your character's default damage power inst:ListenForEvent("lightningstrike", function(inst, data) inst.components.combat.damagemultiplier = 1.5 -- 50% boost when strike by lightning inst.components.talker:Say("I feel so alive!") inst:AddTag("electricdamageimmune") -- Immune to electric damage. inst.components.burnable.lightningimmune = true -- Immune to lightning. local x, y, z = inst.Transform:GetWorldPosition() -- Cool effect. SpawnPrefab("sparks").Transform:SetPosition(x, y, z) -- Cool effect. end) Link to comment Share on other sites More sharing options...
Serpens Posted September 3, 2016 Share Posted September 3, 2016 (edited) Dont just set a new value for damagemultiplier. Some characters have a default value of 0.75. And also other mods might change that. The other stuff SuperDavid posted looks right So you have to change it that way, that you easily can revert it back to the previous value, without removing other effects. The best way is to multiply the multiplier. So if you want an increase of 25%, do:inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier * 1.25 And when you remove it, do:inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier / 1.25 Edited September 3, 2016 by Serpens Link to comment Share on other sites More sharing options...
Shinoryoshu Posted September 3, 2016 Author Share Posted September 3, 2016 9 minutes ago, SuperDavid said: Um, i'm sorry I don't understand if you still need help so I just say exactly what you need to do ! If you want your character to do 50% more damage damage when she gets striked by lightning you would do like this. In your character.lua under master_postinit you put & that's all inst.components.combat.damagemultiplier = 1 -- Your character's default damage power inst:ListenForEvent("lightningstrike", function(inst, data) inst.components.combat.damagemultiplier = 1.5 -- 50% boost when strike by lightning inst.components.talker:Say("I feel so alive!") inst:AddTag("electricdamageimmune") -- Immune to electric damage. inst.components.burnable.lightningimmune = true -- Immune to lightning. local x, y, z = inst.Transform:GetWorldPosition() -- Cool effect. SpawnPrefab("sparks").Transform:SetPosition(x, y, z) -- Cool effect. end) ahh okay i think there was a misunderstanding on my part i thought you were referring to my base multiplier didn't realize that was the line i need. Sorry Link to comment Share on other sites More sharing options...
. . . Posted September 3, 2016 Share Posted September 3, 2016 11 minutes ago, Serpens said: Dont just set a new value for damagemultiplier. Some characters have a default value of 0.75. And also other mods might change that. The other stuff SuperDavid posted looks right So you have to change it that way, that you easily can revert it back to the previous value, without removing other effects. The best way is to multiply the multiplier. So if you want an increase of 25%, do:inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier * 1.25 And when you remove it, do:inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier / 1.25 Oh my god, thanks a lot because I didn't know that & for my character I just changed the damage multiplier. I didn't know changing damage multiplier changes all character's damage multiplier ... Can I ask you @Serpens does changing inst.components.hunger.hungerrate = 4 * TUNING.WILSON_HUNGER_RATE or inst.components.health.absorb = -2 effect all characters too or will it just affect my character? Also, very sorry but can I ask one more thing because it seems you're more knowledgeable than me. Is there something like inst.components.locomotor:SetExternalSpeedMultiplier(inst, "1_speed_mod", 0.75) but for damage? Link to comment Share on other sites More sharing options...
Shinoryoshu Posted September 3, 2016 Author Share Posted September 3, 2016 wait... so is their a way to give my character a boosted damage multiplier after getting struck by lightning Link to comment Share on other sites More sharing options...
Serpens Posted September 3, 2016 Share Posted September 3, 2016 (edited) 37 minutes ago, SuperDavid said: Oh my god, thanks a lot because I didn't know that & for my character I just changed the damage multiplier. I didn't know changing damage multiplier changes all character's damage multiplier ... Can I ask you @Serpens does changing inst.components.hunger.hungerrate = 4 * TUNING.WILSON_HUNGER_RATE or inst.components.health.absorb = -2 effect all characters too or will it just affect my character? Also, very sorry but can I ask one more thing because it seems you're more knowledgeable than me. Is there something like inst.components.locomotor:SetExternalSpeedMultiplier(inst, "1_speed_mod", 0.75) but for damage? No, of course it does not affect all characters, only your character But there are mods out there, that changes the value during game. E.g my Home Base Bonus Mod on steam. - Let's say this char from Shinoryoshu has 1.25 damagemultiplier as default. - Now my mod adds a 10% bonus (because he stands on floor), resulting in 1.25*1.1 = 1.375 . - Now the char is hit by lightning, that's why you set it to 1.5. - Character leaves floor, so my mod will try to remove the 10% bonus, so it will calculate now: 1.5 / 1.1 = 1.3636 - So the endresult would be totally wrong. So on character creation, you can set the damagemultiplier to every value you like. But when you change it during game, you have to do it with multiplication. The same of course for all other values. If you change them during game, do it in a way you can revert it. (In case of absorb for example it would be Addition, since it is no multiplier) And about your question about "SetExternalSpeedMultiplier", unfortunately not... that is exactly the same question Joachim and I made here:http://forums.kleientertainment.com/topic/69490-why-devs-commented-out-damagemultiplier-in-coombat-component/#comment-802993 @Shinoryoshu: Yes of course there is But first you should tell us if it should be permanent, or if it should be removed after some time. And if he gets hit twice or more often, should it always increase by e.g 25%? Or should it only increase once, regardless how often he is hit? Edited September 3, 2016 by Serpens Link to comment Share on other sites More sharing options...
Shinoryoshu Posted September 3, 2016 Author Share Posted September 3, 2016 10 minutes ago, Serpens said: No, of course it does not affect all characters, only your character But there are mods out there, that changes the value during game. E.g my Home Base Bonus Mod on steam. - Let's say this char from Shinoryoshu has 1.25 damagemultiplier as default. - Now my mod adds a 10% bonus (because he stands on floor), resulting in 1.25*1.1 = 1.375 . - Now the char is hit by lightning, that's why you set it to 1.5. - Character leaves floor, so my mod will try to remove the 10% bonus, so it will calculate now: 1.5 / 1.1 = 1.3636 - So the endresult would be totally wrong. So on character creation, you can set the damagemultiplier to every value you like. But when you change it during game, you have to do it with multiplication. The same of course for all other values. If you change them during game, do it in a way you can revert it. (In case of absorb for example it would be Addition, since it is no multiplier) I'm trying to make her base multiplier higher during and after she has been struck by lighting from my 1.25 base. Could i just change that in the line of code or could that be really dangerous to do with other multiplier mods? Link to comment Share on other sites More sharing options...
Serpens Posted September 3, 2016 Share Posted September 3, 2016 I edited my previous post, please read it again and tell me how long it should last and if it should be inceased only once or multiple times Link to comment Share on other sites More sharing options...
Shinoryoshu Posted September 3, 2016 Author Share Posted September 3, 2016 8 minutes ago, Serpens said: I edited my previous post, please read it again and tell me how long it should last and if it should be inceased only once or multiple times What i want is a non-login persistent buff, that only last during that one session and stacks only once. So she gets hit she gets more damage then when you close off its gone until you get hit again in your next login. Link to comment Share on other sites More sharing options...
Serpens Posted September 3, 2016 Share Posted September 3, 2016 (edited) 15 minutes ago, Shinoryoshu said: What i want is a non-login persistent buff, that only last during that one session and stacks only once. So she gets hit she gets more damage then when you close off its gone until you get hit again in your next login. inst:ListenForEvent("lightningstrike", function(inst, data) if not inst.alreadylightningdamage then -- you can save any name you want in inst. but it is not saved when leaving the game inst.alreadylightningdamage = true -- save that we already gave him the bonus, so this will only work once per session. This will be deleted in a new session automatically inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier * 1.5 -- 50% boost when strike by lightning inst.components.talker:Say("I feel so alive!") inst:AddTag("electricdamageimmune") -- Immune to electric damage. inst.components.burnable.lightningimmune = true -- Immune to lightning. local x, y, z = inst.Transform:GetWorldPosition() -- Cool effect. SpawnPrefab("sparks").Transform:SetPosition(x, y, z) -- Cool effect. end end) I think this should work. When you test this, you should also enable some mod like "ShowMe". If you have an item on your cursor and hover over your char, it will show you the damagemultiplier if it is unequal to 1. Edited September 3, 2016 by Serpens Link to comment Share on other sites More sharing options...
Shinoryoshu Posted September 3, 2016 Author Share Posted September 3, 2016 10 minutes ago, Serpens said: inst:ListenForEvent("lightningstrike", function(inst, data) if not inst.alreadylightningdamage then -- you can save any name you want in inst. but it is not saved when leaving the game inst.alreadylightningdamage = true -- save that we already gave him the bonus, so this will only work once per session. This will be deleted in a new session automatically inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier * 1.5 -- 50% boost when strike by lightning inst.components.talker:Say("I feel so alive!") inst:AddTag("electricdamageimmune") -- Immune to electric damage. inst.components.burnable.lightningimmune = true -- Immune to lightning. local x, y, z = inst.Transform:GetWorldPosition() -- Cool effect. SpawnPrefab("sparks").Transform:SetPosition(x, y, z) -- Cool effect. end end) in the line if not inst.alreadylightningdamage then. you said i can save a name in inst. What do you mean by this that i need to save the characters name somewhere in the code? Sorry for all the noob questions Link to comment Share on other sites More sharing options...
Serpens Posted September 3, 2016 Share Posted September 3, 2016 (edited) All I wanted to say with this line is, that " alreadylightningdamage " is just something I made up. It is not something that already exist in the game. You can also name it different. It will be saved in "inst", so your character, but only for that session. edit: And I hope the modification of damagemultipler is also only changed for that session. I think it is that way, but that's why I told you to test it with the Show Me mod active Edited September 3, 2016 by Serpens Link to comment Share on other sites More sharing options...
. . . Posted September 3, 2016 Share Posted September 3, 2016 @Serpens I'm sorry but i'm a little confused I just want to ask you something. So, my character's supposed to deal 75% more damage than normal characters & I put inst.components.combat.damagemultiplier = 1.75 Would that change all character's attack to 1.75 or just my character? Link to comment Share on other sites More sharing options...
Shinoryoshu Posted September 3, 2016 Author Share Posted September 3, 2016 13 minutes ago, Serpens said: All I wanted to say with this line is, that " alreadylightningdamage " is just something I made up. It is not something that already exist in the game. You can also name it different. It will be saved in "inst", so your character, but only for that session. edit: And I hope the modification of damagemultipler is also only changed for that session. I think it is that way, but that's why I told you to test it with the Show Me mod active so i ran that code into my lua and now its crashing my game :/ Link to comment Share on other sites More sharing options...
Serpens Posted September 3, 2016 Share Posted September 3, 2016 (edited) 23 minutes ago, SuperDavid said: @Serpens I'm sorry but i'm a little confused I just want to ask you something. So, my character's supposed to deal 75% more damage than normal characters & I put inst.components.combat.damagemultiplier = 1.75 Would that change all character's attack to 1.75 or just my character? it never changes the attack for all players. It only changes it for "inst". And when "inst" in this case is your player, it only changes it for your player And as I said above, if you plan to change this value during game, use multiplication. (But as a default value before game starts, it is okay to set it to a specific value) At Shinoryoshu: Everytime your game crashes, the first thing you do is go to C:\Users\Serpens\Documents\Klei\DoNotStarveTogether ( of course it is called different at your pc) and open the client_log.txt file. Then search for the word "error". There you might read, what causes the problem and you can fix it. Or you can post the complete error message here, so we can find out what is wrong. And where did you put the code? In which file? edit: I will go to sleep now. I think SuperDavid can help when you post the error Edited September 3, 2016 by Serpens Link to comment Share on other sites More sharing options...
Shinoryoshu Posted September 3, 2016 Author Share Posted September 3, 2016 (edited) 22 minutes ago, Serpens said: it never changes the attack for all players. It only changes it for "inst". And when "inst" in this case is your player, it only changes it for your player And as I said above, if you plan to change this value during game, use multiplication. (But as a default value before game starts, it is okay to set it to a specific value) At Shinoryoshu: Everytime your game crashes, the first thing you do is go to C:\Users\Serpens\Documents\Klei\DoNotStarveTogether ( of course it is called different at your pc) and open the client_log.txt file. Then search for the word "error". There you might read, what causes the problem and you can fix it. Or you can post the complete error message here, so we can find out what is wrong. And where did you put the code? In which file? edit: I will go to sleep now. I think SuperDavid can help when you post the error I put it in the characters main script lua heres the error i think scripts/mods.lua(44,1) error calling LoadPrefabFile in mod Nora (Nora Valkyrie): ...nt_starve/data/../mods/Nora/scripts/prefabs/nora.lua:65: variable 'inst' is not declared Edited September 3, 2016 by Shinoryoshu Link to comment Share on other sites More sharing options...
. . . Posted September 3, 2016 Share Posted September 3, 2016 (edited) @Shinoryoshu It'd be a lot easier for me if you post your character here then I can see what's wrong & fix it or if you can tell me what's the crash then I can help you. Also, did your character start crashing when you put this code inst:ListenForEvent("lightningstrike", function(inst, data) if not inst.alreadylightningdamage then -- you can save any name you want in inst. but it is not saved when leaving the game inst.alreadylightningdamage = true -- save that we already gave him the bonus, so this will only work once per session. This will be deleted in a new session automatically inst.components.combat.damagemultiplier = inst.components.combat.damagemultiplier * 1.5 -- 50% boost when strike by lightning inst.components.talker:Say("I feel so alive!") inst:AddTag("electricdamageimmune") -- Immune to electric damage. inst.components.burnable.lightningimmune = true -- Immune to lightning. local x, y, z = inst.Transform:GetWorldPosition() -- Cool effect. SpawnPrefab("sparks").Transform:SetPosition(x, y, z) -- Cool effect. end end) in it? You have to put the code above under this code local master_postinit = function(inst) in your character.lua if you did that & it crashes then that's really strange because that shouldn't happen. Edited September 3, 2016 by SuperDavid 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