davethepak Posted April 13, 2018 Share Posted April 13, 2018 So, I think I can understand the Onhit event, but I can't seem to determine a way to figure out how much damage was taken from the hit. I am working on a mod where I need to know the amount of damage the player takes from combat activities. I was thinking maybe compare health actorvalue before and after the hit, but I am not sure how to get it right before the hit?(they could have healed since the last hit, etc.). Any suggestions? thanks in advance. Link to comment Share on other sites More sharing options...
Elias555 Posted April 13, 2018 Share Posted April 13, 2018 There's a mana shield mod that will help you since it needs to constantly get the new damage amount taken and quickly convert it to magicka damage.As for right before the hit, not sure. Maybe you'll need to send an update OnHit and store the amount somewhere. I think you'll also have to constantly send updates due to passive health regen.Why do you need to know the amount of damage taken? Link to comment Share on other sites More sharing options...
davethepak Posted April 13, 2018 Author Share Posted April 13, 2018 Thank you for your reply. What am I doing? Short version; I have a custom skill that gets increased as you take damage. Long version: I am working on a revised version of the mod "way of the monk" an amazing mod, that unfortunately the mod author had left many years ago. He left it up to others to tweak and finish the work, and I am revising it, adding mcm support, and fixing many of the bugs.One of the things it includes is a "unarmored skill" - which is basically an armor skill for cloth users (has its own perks, etc.) One thing the mod author was never able to do, was have his skill contribute to actual skyrim character levels. I have figured out how to do this (he did not have access to skse functions back then). I have figured out to have his skills give actual character xp. Now, I am reviewing, for the sake of balance how his skills increase - and even he admitted they increase too quickly.(he detected a hit, and you got skill xp. but it was kind of a set value, and a bit too generous). I am writing in an option to have the unarmored skill raise similar to the other skills (including their xp offset and exponent rules). But to do so, I need to know how much damage a character takes when they get hit - as this is how the light armor, and heavy armor skills raise.(for example, for your light armor skill to raise from 15 to 16 takes a little more than 200 points of damage - I am using the leveling formula and variables found here; http://en.uesp.net/wiki/Skyrim:Leveling ) Thus.....I am trying to figure out how to calculate incoming damage. it does not have to be perfect - it just has to be an improvement. Link to comment Share on other sites More sharing options...
Elias555 Posted April 14, 2018 Share Posted April 14, 2018 I have a custom skill that gets increased as you take damage.Why not just have a global variable than increases OnHit? From their you can manipulate the skill based on the global. Link to comment Share on other sites More sharing options...
davethepak Posted April 15, 2018 Author Share Posted April 15, 2018 I have a custom skill that gets increased as you take damage.Why not just have a global variable than increases OnHit? From their you can manipulate the skill based on the global. I am sorry, I don't understand what this means - perhaps my long winded explanation is the problem. I don't have a problem with how MANY times I have been hit - I am having a problem determining the AMOUNT of damage taken with each hit. I need the incoming damage amount. Perhaps I still don't understand (there is a strong chance of that - my modding skills are still in their infancy). oh, and as a side note - your smoke and shadow mods are very cool. :) Link to comment Share on other sites More sharing options...
Elias555 Posted April 15, 2018 Share Posted April 15, 2018 I have a custom skill that gets increased as you take damage.Why not just have a global variable than increases OnHit? From their you can manipulate the skill based on the global. I am sorry, I don't understand what this means - perhaps my long winded explanation is the problem. I don't have a problem with how MANY times I have been hit - I am having a problem determining the AMOUNT of damage taken with each hit. I need the incoming damage amount. Perhaps I still don't understand (there is a strong chance of that - my modding skills are still in their infancy). oh, and as a side note - your smoke and shadow mods are very cool. :smile: I was just giving an alternative to the method I mentioned earlier. Constantly registering OnHit and updates are heavy in terms of scripting.Did you try to reverse engineer the mana shield mod or follow the scripting ideas?Thanks for the praise! Link to comment Share on other sites More sharing options...
davethepak Posted April 16, 2018 Author Share Posted April 16, 2018 I did look at the mana shield mod (again, THANK YOU for the idea). Basically it keeps track of current health by registering an event which fires every half second. Then, if you get hit, it compares your current health with the most recent measurement, to determine a delta. This looks simple, but I am a bit ignorant if an event every .5 seconds is a drain on resources (I think it is, but don't know for sure).Here is the relevant code snippet. function OnEffectStart(Actor akTarget, Actor akCaster) Float CurrentHP = game.GetPlayer().GetAV("Health") CeilingHP = CurrentHP self.Register() endFunction function OnUpdate() Float HP = game.GetPlayer().GetAV("Health") if HP >= CeilingHP CeilingHP = HP elseIf HP < CeilingHP Float Dmg = CeilingHP - HP Float mDmg = (CeilingHP - HP) * 0.670000 game.GetPlayer().RestoreAV("Health", Dmg) game.GetPlayer().DamageAV("Magicka", mDmg) Float MP = game.GetPlayer().GetAV("Magicka") if MP <= 0 as Float self.Dispel() endIf endIf endFunction function Register() self.RegisterForUpdate(0.500000) endFunction I am going to see if I can work out some kind of formula that gives an approximation, without having a lot of scripts. thank you again for your insights. I am still kind of surprised there is not a function (even a skse one) for incoming damage. Sigh.... Link to comment Share on other sites More sharing options...
Elias555 Posted April 16, 2018 Share Posted April 16, 2018 What about the perk entry points(mod incoming damage)? I haven't played around with them but maybe they can give feedback somehow. Link to comment Share on other sites More sharing options...
davethepak Posted April 16, 2018 Author Share Posted April 16, 2018 (edited) Thanks again for What about the perk entry points(mod incoming damage)? I haven't played around with them but maybe they can give feedback somehow.Thanks again for your response. I have played with those, but am not sure about a report back mechanism. I will look into it. I think the checking for damage periodically may be the best method - but I have concerns about something that fires every second or so. I don't want to slow the game down, or cause any performance issues - and I am very new to modding (learning as fast as I can!) so not sure about the best way. I went ahead and created a separate topic for in the forums for tracking incoming player hits - as to not get his one too far off track. thanks again for ideas. Edited April 16, 2018 by davethepak Link to comment Share on other sites More sharing options...
FrankFamily Posted April 16, 2018 Share Posted April 16, 2018 (edited) Checking every second or half second isn't necessarily terrible, just minimize what runs in every iteration, don't run unnecessary code. If you make something like the script you posted then most of the time it's just going to run getav and compare and set a variable, I'd say that's lightweight. Consider the frequency, perhaps a full second is enough. Also, as far as I know is better to do a loop with registerforsingle update being called at the end of OnUpdate than registerforupdate, or so I've read. Edited April 16, 2018 by FrankFamily Link to comment Share on other sites More sharing options...
Recommended Posts