VencGanence Posted April 21, 2020 Share Posted April 21, 2020 Is it possible to detect when the PC contracts a disease? I don't need to know which disease it is, simply the moment they contract it. I don't want to detect that they have a disease, but that they gained a disease. Link to comment Share on other sites More sharing options...
Oblivionaddicted Posted April 22, 2020 Share Posted April 22, 2020 (edited) Nevermind. Edited April 22, 2020 by Oblivionaddicted Link to comment Share on other sites More sharing options...
Fiore1300 Posted April 22, 2020 Share Posted April 22, 2020 (edited) https://cs.elderscrolls.com/index.php?title=GetDisease Note the function is deprecated. The page explains further. So to get the time the PC contracts a disease, I'd wager you'd want to combine IsSpellTarget to detect if the PC has a disease, if yes then GetCurrentTime, then go from there? I dunno. Just spitballin. Edited April 22, 2020 by Fiore1300 Link to comment Share on other sites More sharing options...
mixxa77 Posted April 22, 2020 Share Posted April 22, 2020 (edited) Seems like the best way to do it is as described on the linked article from Fiore1300. Loop through the players spells, probably every second or so, and if any of them is a disease, the script can switch a variable that will kick off whatever you want to do. Edited April 22, 2020 by mixxa77 Link to comment Share on other sites More sharing options...
VencGanence Posted April 22, 2020 Author Share Posted April 22, 2020 That does seem like the only way to me, but it has the unwanted drawback of being unable to detect multiple diseases unless I go a step further tracking sources of effects in addition to effect types. That just sounds like it'd get a bit too complicated, which worries me that it may impact performance. There are the OnMagicApply and OnMagicCast event handlers, but my testing of OnMagicApply fired inconsistently, plus I don't know if a disease would trigger the handler despite technically being a spell. Link to comment Share on other sites More sharing options...
Fiore1300 Posted April 22, 2020 Share Posted April 22, 2020 Maybe OBSE has the functions you need? Link to comment Share on other sites More sharing options...
VencGanence Posted April 22, 2020 Author Share Posted April 22, 2020 There's functions to get the total magnitude of disease effects, but that information doesn't tell me what I want. Link to comment Share on other sites More sharing options...
VencGanence Posted April 23, 2020 Author Share Posted April 23, 2020 (edited) I found a method to detect disease contraction, using an OnMagicApply event handler: ;Parameters ;----------------------------------------------------------------------------- ref MagicItem ref Caster ref Self short Type ;----------------------------------------------------------------------------- ;----------------------------------------------------------------------------- begin Function { MagicItem, Caster } ;----------------------------------------------------------------------------- ;GetSelf returns who was hit Let Self := GetSelf Let Type := GetSpellType MagicItem if ( Self == Player && Type == 1 ) DebugPrint "%n contracted %n." Self MagicItem endif ;----------------------------------------------------------------------------- end ;----------------------------------------------------------------------------- Unfortunately, this handler type cannot be filtered by target, so there will be some wasted cycles. Edit: oddly enough, the Caster for diseases is the victim, so I can apply a filter for Caster. The question is if mod added diseases have the same behaviour. Edited April 23, 2020 by VencGanence Link to comment Share on other sites More sharing options...
Fiore1300 Posted April 24, 2020 Share Posted April 24, 2020 The question is if mod added diseases have the same behaviour.Well, you're in luck. I don't think any mods add new diseases. Link to comment Share on other sites More sharing options...
Recommended Posts