Jump to content

How to detect disease contraction?


Recommended Posts

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 by Fiore1300
Link to comment
Share on other sites

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 by mixxa77
Link to comment
Share on other sites

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

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 by VencGanence
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...