Recommended Posts

MemphisMyst    1

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 by MemphisMyst

Share this post


Link to post
Share on other sites
CarlZalph    5247
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 by CarlZalph
GLOBAL

Share this post


Link to post
Share on other sites
MemphisMyst    1

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.

Share this post


Link to post
Share on other sites
MemphisMyst    1
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

Share this post


Link to post
Share on other sites
CarlZalph    5247
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.

Share this post


Link to post
Share on other sites
MemphisMyst    1
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 by MemphisMyst

Share this post


Link to post
Share on other sites
. . .    4196
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)

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this