Detect when poison is applied

Post » Thu Jun 21, 2012 8:40 pm

I need to detect when the player applies a poison, but the events don't work as intuitive as I hoped. I have a script attached to the player which receives Actor and ObjectReference events, but I can't seem to find an event that covers all cases.

I've tested the following events in-game:

OnSpellCast()
Only gets called for Potions, not for Poisons (Which are essentially just Potions with the IsHostile() property)

OnObjectEquipped()
Also only gets called for Potions, not Poisons

OnMagicEffectApply()
Since poison effects are applied to the weapon, this also only gets called for Potions

OnItemRemoved()
Gets called two times, once when the confirmation dialog is shown and another time when the poison is applied, so I need to detect when I receive this event two times. However since I have no way of knowing if the player answered "no" on the confirmation, receiving the event two times could just mean the player cancelled the poison two times.

Any help would be greatly appreciated. If you can suggest any other event I could look at that may be triggered when a poison is applied, please tell me.
User avatar
xx_Jess_xx
 
Posts: 3371
Joined: Thu Nov 30, 2006 12:01 pm

Post » Thu Jun 21, 2012 9:30 pm

I haven't done this. so I don't know whether it works, but "Poisons Used" is a stat that gets tracked. So you could perhaps call
RegisterForTrackedStatsEvent() 
and then
Event OnTrackedStatsEvent(string asStatFilter, int aiStatValue)    if (asStatFilter == "Poisons Used")       ; etc
User avatar
lilmissparty
 
Posts: 3469
Joined: Sun Jul 23, 2006 7:51 pm

Post » Thu Jun 21, 2012 10:08 pm

Thank you for the reply. I have found a similar solution inspired by the following thread: http://www.gamesas.com/topic/1371503-info-onspellcast/

I now save the value of Poisons Used before I start tracking the OnItemRemoved() events and then check if the Poisons Used has increased. It looks like this:

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)  int stat = Game.QueryStat("Poisons Used")  if(stat > previousStat)	; the poison was actually used  endifEndEvent
User avatar
Hearts
 
Posts: 3306
Joined: Sat Oct 20, 2007 1:26 am


Return to V - Skyrim