xrws31 Posted February 16, 2012 Share Posted February 16, 2012 (edited) For a while now I've been wanting to modify how armour affects the amount of damage you take because, imo, it's rather unbalanced in vanilla. I'm not posting here to talk about how it should be re-balanced. I'm posting to ask for help in implementing changes. Having looked through the creation kit and through the scripts folder in data (using MofoMojo's script dumper), I can't find where the actual equation governing the relationship between armour and damage is. Meaning I can't directly edit how damage is applied. If someone does actually know where the formula governing armour and damage is, then this post is rather pointless, and do please let me know :P But I was thinking it might be possible to work around that problem with a papyrus script that goes something like this (Pseudo-Code): On Startup ( Store Health Value in variable 'H' ) On Hit ( Get Damage Value of Last Hit, store in variable 'D' Restore Health to 'H' Do modified maths on 'D' to get new desired amount of damage Apply Modified Damage Set 'H' to new health value ) Now I'm a reasonably experienced scripter, but I don't know much about how Papyrus interacts with the game engine, so I was wondering if anyone with more detailed knowledge of Papyrus could advise on whether this is viable. One concern of mine is that in-game the health bar slides downwards after being hit, it doesn't instantly jump down, and sometimes it takes half a second for a killing blow to actually kill, meaning perhaps a solution like that given above might run into issues with lag. I also don't really know how I would get around killing blows if they were instant. Restore Health would probably be a little too late after a Kill event has been triggered. Edited February 16, 2012 by xrws31 Link to comment Share on other sites More sharing options...
kromey Posted February 16, 2012 Share Posted February 16, 2012 I think the health bar sliding is a UI effect -- I've seen creatures (and myself!) start their "I'm dead!" animation while their health bar is still depleting (although I've only been able to notice this from particularly big hits on relatively weak targets). So I suspect that simply changing the health value as you propose will still "play nice" with that UI animation. As to your approach, it seems like it might not be the best one (you'd have to attach this script to every single actor, which while I'm sure you can do that to the base object easily enough could introduce performance issues), but it does seem to me to be viable. Ideally you would be able to get the unmodified damage value (i.e. how much damage the attack dealt, as opposed to how much was left over after armor absorbed much of it) and work with that, instead of working backwards from the "original" modified value, although even if you can't it's no game-breaker. You would have to be careful about determining the source of damage -- armor doesn't (I don't think) reduce damage from spells, or even from falling, so unless you want to change that you'd need to make sure it was weapon damage before you modified it, and if it's not let it through unmodified. I don't know how you would determine that, though. As an added bonus, if you do manage to get this implemented and working, it would be easily extensible to make certain weapons more effective against armored targets, by implementing a sort of "armor piercing" property that would mitigate some of the damage reduction (or even allow a specific portion of the damage to pass through unmodified); conversely, you could make some less effective against armor by increasing the effective armor rating in your calculations. Similarly, you could design perks, e.g. "Find the Gap", that would allow the player to be more effective against armored foes (or foes more effective against armored players...). Link to comment Share on other sites More sharing options...
xrws31 Posted February 16, 2012 Author Share Posted February 16, 2012 (edited) Thanks for the input. Nice to have a little confirmation that sliding health bar shouldn't be an issue. And yes, attaching this to every actor in the game would likely be a lag problem. For the time being, I'm just thinking of applying it to the player's character. As far as I can tell, the OnHit() function does keep a reference of what type of damage it was that hit (weapon / spell etc), so hopefully that won't be a problem. What I'm having trouble thinking of a solution for is dealing with attacks which would kill the player in vanilla, but which wouldn't under the modified scheme. If the script is executing after the player has already died, then I doubt restoring health would be workable. Ideally want a way of forcing the script to execute in between a hit being registered and health actually being removed, but I'm doubtful about whether that's possible. Edited February 16, 2012 by xrws31 Link to comment Share on other sites More sharing options...
kromey Posted February 16, 2012 Share Posted February 16, 2012 Well, if the hit is a killing blow and modifying the player's health doesn't make them not die, you can always use the Resurrect() method on them. Link to comment Share on other sites More sharing options...
kromey Posted February 16, 2012 Share Posted February 16, 2012 I just found that there's a DamageResist actor value in the game. I'm not sure what already uses it (if anything), nor how it's used, but you might be able to use it as a second "layer" on top of the vanilla armor system to get to the same damage reduction you're trying to achieve -- any time the player changes their armor, get their new armor value, do whatever adjustments you want to, and apply whatever DamageResist value is necessary to achieve the ends you are after. ...Maybe. I have no idea if this can in fact help you reach your goal, but it's worth investigating. Link to comment Share on other sites More sharing options...
Recommended Posts