Jump to content

How to give my character natural damage resistance?


Recommended Posts

So, I am still working on my modded character, and i'm quite happy with how she's coming along:

Darnaxe.png.c9ead0bc2cee01babe1ab0bcfd2e659c.png

I succesfuly added a heavy axe that only she can craft, has damage on par with the battle spear and can still be used to chop wood. And thanks to the help i got here previosuly she also has a considerable downside: she will randomly hit herself when in combat.

Now, I was thinking of ways to help make her survivable and fit my playstyle, which involves a lot of exploring. See, I like to carry a backpack almost all of the time so i dont like to wear armor, and while football helmets are nice, they arent as easily accesible as, say, log suits. I considered giving her a crafted helmet just like Wigfrid, but I really wanted to try something different before falling back to that.

Would it be possible to give her grass armor levels of damage absorption when not wearing armor? so I can feel more confident fighting things and healing between rounds with food or salves, but still needing to equip real armor if i plan to face anything thats actually a threat.

Of course, a main concern would be to make sure this damage resist doesnt stack with new armor she puts on top.

Link to comment
Share on other sites

Hmm, ok, so looking at that dample and pondering a bit, on my character.lua I added this line below her stats

inst.components.combat.externaldamagetakenmultipliers:SetModifier("myuniquemodifierkey", 0.6)

If i understand this correctly, the uniquemodifier key should be something i set up to check if the character if wearing armor, and if false, then enable the damage taken multiplier?

Link to comment
Share on other sites

Yes, if you only want the modifier to be on when the character is not wearing armor, then you can listen to the "equip" and "unequip" events on your character, which send you both the item and the equipment slot they were unequipped from, so you can check if an armor was unequipped. And the same for when equipping an armor. It's pretty straight-forward. Look at the inventory component, inventory.lua, and search for: PushEvent
You can see what data it sends along, and you can trace what that data is. For examle, 'eslot' is an enum, so it might be EQUIPSLOTS.HANDS or EQUIPSLOTS.BODY or EQUIPSLOTS.HEAD.

Link to comment
Share on other sites

Hmm, i'm hitting a snag here, I tried to just add 

inst.components.combat.externaldamagemultipliers:SetModifier(0.4)

to see if i could first get the damage resistance to kick in without keys, even if its active all the time, but nothing happens to the damage my character takes, its still the same. I dont get an error of any kind, the line just doesnt seem to have any effect?

Did i skip a step somewhere? is there something i have to set up prior to this code in here or a diferent .lua?

I apologize, my understanding of scripting is pretty limited.

Link to comment
Share on other sites

Ah, indeed, I left the code as is and added a special armor variable. for now I just set it as true for testing, and as expected, my character now shaves off 60% of incoming damage, but it stacks with armor so yeah i will have to work out those exceptions. Would it be more complicated if i tried to call the armor pieces in the game one by one by name?, since some are helmets and others are body equipment, and i dont want the buff to go away if, say, im wearing both a backpack and a straw hat.

Link to comment
Share on other sites

You can check whether the HEAD or BODY item being equipped or unequipped has an armor component on.

I don't understand the first part of your post. Can I see the code you have?

Edited by Ultroman
Link to comment
Share on other sites

sorry i didnt reply, i went to sleep after my last post. 

 

This is my character.lua, if it helps. Since my knowledge of scripting is very limited, right now I am just taking bits and pieces of other mods and tweaking until they work.

darna.lua

Link to comment
Share on other sites

this would be the weapon. havent really fine tuned it for balance yet, just trying to get everything working first. 

 

To keep it simple, what i desire is for her passive damage resistance to not stack with armors. So i guess it should be disabled when anything that would give her damage absorb is equipped, be it a football helmet, a marble suit, or what have you.

darnaxe.lua

Link to comment
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
 Share

×
  • Create New...