MemphisMyst Posted February 13, 2017 Share Posted February 13, 2017 (edited) I was wondering if there was a way for me to add wigfrid's ability to gain health and sanity on kill to a character i have. I have seen ones on the forums but they seen to be a flat bonus and not based on the mobs combat damage. If anyone would be able to separate that function from the battleborn one that she has or if they would be able to rewrite it out that would be greatly appreciated. Thank you very much for any assistance you can provide in advance. Edited February 13, 2017 by MemphisMyst Link to comment Share on other sites More sharing options...
CarlZalph Posted February 13, 2017 Share Posted February 13, 2017 (edited) 1 hour ago, MemphisMyst said: I was wondering if there was a way for me to add wigfrid's ability to gain health and sanity on kill to a character i have. I have seen ones on the forums but they seen to be a flat bonus and not based on the mobs combat damage. If anyone would be able to separate that function from the battleborn one that she has or if they would be able to rewrite it out that would be greatly appreciated. Thank you very much for any assistance you can provide in advance. The reason why Wigfrid was changed for DST to do this is because killstealing is a thing and can happen, which makes it an unfun experience to be 'robbed' of stats because someone else got the final blow. That being said, a way to do this is to: AddPrefabPostInit("wilson", function(inst) if not GLOBAL.TheWorld.ismastersim then return end inst:ListenForEvent("killed", function(inst, data) local victim = data and data.victim or nil if victim~=nil and victim.components.combat then local damage = victim.components.combat.defaultdamage inst.components.health:DoDelta(damage) inst.components.sanity:DoDelta(damage) end end ) end ) Though not sure why you'd want it based on the enemy's combat damage, but it's what was asked~ To scale how much is given merely multiply 'damage' by a factor, constant or functional. Edited February 13, 2017 by CarlZalph GLOBAL Link to comment Share on other sites More sharing options...
MemphisMyst Posted February 13, 2017 Author Share Posted February 13, 2017 Thank you very much; the main reason i wanted it scaled off the combat damage was because it is an easy way to filter killing rabbits and butterflies along with other object for hp. Plus it also gives a nicer balance to fights so people just don't face tank a bunch of mobs and get rewarded for it. Link to comment Share on other sites More sharing options...
MemphisMyst Posted February 14, 2017 Author Share Posted February 14, 2017 7 hours ago, CarlZalph said: The reason why Wigfrid was changed for DST to do this is because killstealing is a thing and can happen, which makes it an unfun experience to be 'robbed' of stats because someone else got the final blow. That being said, a way to do this is to: AddPrefabPostInit("wilson", function(inst) if not GLOBAL.TheWorld.ismastersim then return end inst:ListenForEvent("killed", function(inst, data) local victim = data and data.victim or nil if victim~=nil and victim.components.combat then local damage = victim.components.combat.defaultdamage inst.components.health:DoDelta(damage) inst.components.sanity:DoDelta(damage) end end ) end ) Though not sure why you'd want it based on the enemy's combat damage, but it's what was asked~ To scale how much is given merely multiply 'damage' by a factor, constant or functional. it seems to be giving me an error at the [AddprefabPostInit("wilson",] line Link to comment Share on other sites More sharing options...
CarlZalph Posted February 14, 2017 Share Posted February 14, 2017 2 hours ago, MemphisMyst said: it seems to be giving me an error at the [AddprefabPostInit("wilson",] line Since you're doing a custom character merely adapt the code. Do this by only using the ListenForEvent portion after the ismastersim check for components. Link to comment Share on other sites More sharing options...
MemphisMyst Posted February 14, 2017 Author Share Posted February 14, 2017 (edited) 19 minutes ago, CarlZalph said: Since you're doing a custom character merely adapt the code. Do this by only using the ListenForEvent portion after the ismastersim check for components. Could you please give me pointers to where i would need to edit for the code? I noticed the name text at the start which didn't correct the issue as to why i posted.. Edited February 14, 2017 by MemphisMyst Link to comment Share on other sites More sharing options...
. . . Posted February 14, 2017 Share Posted February 14, 2017 30 minutes ago, MemphisMyst said: Could you please give me pointers to where i would need to edit for the code? I noticed the name text at the start which didn't correct the issue as to why i posted.. You can just put this in YOURCHARACTER.lua inside the master_postinit inst:ListenForEvent("killed", function(inst, data) local victim = data and data.victim or nil if victim~=nil and victim.components.combat then local damage = victim.components.combat.defaultdamage inst.components.health:DoDelta(damage) inst.components.sanity:DoDelta(damage) end end) Link to comment Share on other sites More sharing options...
MemphisMyst Posted February 14, 2017 Author Share Posted February 14, 2017 Thanks for all the help guys! 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