XJDHDR Posted February 3, 2019 Author Share Posted February 3, 2019 I took a look around Cobl's code. Basically, it prevents death by using SetEssential on the Player then watching for when the player's health drops to 0. It's death handler also requires that the fEssentialHealthPercentRegain setting be set to 0, which is required because otherwise the essential PC's health would never drop to 0. My problem is that this is a non-trivial setting; setting it to 0 means that any NPC in the game that gets knocked out will have 0 health when they get back up.If I go this route, I would need to add a way for essential NPCs to get healed the amount they would from that setting any time they get knocked out, including accounting for any mods the user may have installed changing this setting. I have an idea or two of how one might implement this (for example is something like the below code) but I'm just wondering if there isn't a better way. ; Quest script If GetGameRestarted == 1 Set fMyGlobalSettingVar to GetGameSetting fEssentialHealthPercentRegain SetNumericGameSetting fEssentialHealthPercentRegain 0 EndIf ; Token script carried by all essential NPCs If ContainerRef.GetAV Health <= 0 && ContainerRef.GetKnockedState == 1 Set fHealthToRestore to ContainerRef.GetBaseAV Health * fMyGlobalSettingVar ContainerRef.ModAV Heath fHealthToRestore EndIf Link to comment Share on other sites More sharing options...
Moktah Posted February 4, 2019 Share Posted February 4, 2019 looking at the code, it looks like a pretty good way to solve it. Only other way I can think of to do your own death handling, if at all possible,would be to: Add a large amount of health to yourself. ie 100,000 hpHave the HUD report the players health minus the 100,000 hp.If your player.getav health == 100,120 then the HUD will display 120 Then you can use the OnHealthDamage event handler to fire off to monitor your health.if your players health drops to 100,000 or less, then initiate your own death scripting. I'd have to look into menuque and the xml for showing the huds health to see if I can pull it off as far as the health display.At first thought, it sounds feasible, but with my luck, Its probably a pipe dream though.I think I can use insertxml to insert what I'd need to control the huds display.I've got a couple ideas on how to go about it, but there again.... I'd have to tinker with it and see what happens. if I can pull it off, I wouldn't edit the xml directly.I like things to be flexible.Besides, DarnifiedUI replaces the games default xml files for the hud display.I havn't looked at the dark version of DarnUI, but I guess it has different xml files too.By using insertxml, it's flexible enough not to have to replace the xml file itself. A thought on this.....It might work fine for most deaths butIt may not work if you're hit with a kill command though. Was going to look into this idea last night but worked late and watched the last of the Super Bowl. UPDATE: worked on my ideas for a while. I was able to take control of the healthbar of the main menu. In my test mod, I can raise and lower my healthbar via the pageup and pagedown keys.Haven't worked on the health info that pops up when you hit your tab key and check your stats yet. From the looks of it, I'm able to make it compatible with vanilla, darnifiedui, and HSBE. IF there's a mod out there that changes the following sections in the hud_main_menu.xml file. <image name="hudmain_health_full"> </image><image name="hudmain_health_edge"></image>then we might be in trouble. I haven't checked to see what that xml file looks like for the dark version of darnUI.I'm expecting it to be the same as the regular darnUI though. Link to comment Share on other sites More sharing options...
XJDHDR Posted February 12, 2019 Author Share Posted February 12, 2019 @MoktahI see two potential problems with your idea, unfortunately. The first is that I'm wondering how fall damage is calculated. Is it a percentage of your health or just a flat X amount of health per unit of distance? If the former, your idea would turn every fall that causes damage to be deadly. The second issue is mods that cause certain effects when the player reaches certain health thresholds. This idea is incompatible with all of them because your health will never drop low enough to reach those thresholds. It is a great idea. I myself would never have dreamed of such a solution. Unfortunately, I just think there are too many issues. Link to comment Share on other sites More sharing options...
Moktah Posted February 13, 2019 Share Posted February 13, 2019 yeah, mods that depend on a certain amount of health to trigger something would be an issue. fall damage is calculated by how long your fallingathletics supposed to go into the calculationyou can see the amount of time with the obse function reference.getfalltimercan't find a specific formula to rule out the percentage of the players health being a considerationguess you can test it by jumping off a bridge or something and seeing how much damage you takethen retest after adding a large number to your health wasn't a total loss for me, I was able to learn a bit more about how the health bars and such are programmed Link to comment Share on other sites More sharing options...
Recommended Posts