How to find out whether the player has just used a potion?

Post » Sat May 28, 2011 7:35 am

I would like to disable player controls for a short time if he drinks a potion (and add a 'gulping' sound and maybe an animation). No matter whether he does it from inventory mode or via hotkey (if from inventory the controls would be disabled after he closes the inventory obviously). What conditions do I need to find out whether the player used a potion during the last frame or a short time like 0.1 seconds? Can use Obse.

IsAlchemyItem sound interesting, but I don't know how to find out what item was the last one the player activated.

Or am I missing a simple function to achieve this?
User avatar
N Only WhiTe girl
 
Posts: 3353
Joined: Mon Oct 30, 2006 2:30 pm

Post » Fri May 27, 2011 8:33 pm

Any potion ? - don't know about obse but if you added a script effect to the potion that sets a quest variable ?
User avatar
bonita mathews
 
Posts: 3405
Joined: Sun Aug 06, 2006 5:04 am

Post » Fri May 27, 2011 9:13 pm

Any potion ? - don't know about obse but if you added a script effect to the potion that sets a quest variable ?


Problem is that I need any potion, not a specific one added by my mod.
User avatar
Robyn Lena
 
Posts: 3338
Joined: Mon Jan 01, 2007 6:17 am

Post » Sat May 28, 2011 4:53 am

Listen for the sound of a potion being drank? GetSoundPlaying??
User avatar
keri seymour
 
Posts: 3361
Joined: Thu Oct 19, 2006 4:09 am

Post » Sat May 28, 2011 6:32 am

Listen for the sound of a potion being drank? GetSoundPlaying??


Sounds like a good idea, but either I'm not using the function correctly or there is a problem with it. I made a debug message, but the script never triggered. I tried the following:

if player.getsoundplaying "NPCHumanSwallow" > 0 ; NPCHumanSwallow is the sound effect ID in the CS for the 'drink potion' sound
if player.getsoundplaying "*swallow*" 150 > 0 ; tried with a radius setting and a wild card since the sound effect points to a directory with 3 different sounds
if getsoundplaying "*swallow*" > 0 ; tried without specific reference

The script is a quest script that runs at 0.1 fquestdelaytime, the sound effects have ~0.4 seconds duration so it should be enough time to return true.

Is it maybe a problem that the sound effect in the CS points to a directory with three random sound effects and not a single wav file? Is there anything wrong with the way I use the function?
User avatar
Kelly James
 
Posts: 3266
Joined: Wed Oct 04, 2006 7:33 pm

Post » Fri May 27, 2011 9:27 pm

IIRC, there should be a "Potions drank" misc. stat that you can track using getPCMiscStat.
User avatar
Sherry Speakman
 
Posts: 3487
Joined: Fri Oct 20, 2006 1:00 pm

Post » Fri May 27, 2011 10:00 pm

IIRC, there should be a "Potions drank" misc. stat that you can track using getPCMiscStat.


Unfortunately there is only one for 'potions made'.
User avatar
T. tacks Rims
 
Posts: 3447
Joined: Wed Oct 10, 2007 10:35 am

Post » Sat May 28, 2011 3:27 am

Erm, not sure just what the heck is going on, but, I can't even come up with the right page in the CS Wiki for getsoundplaying.........
User avatar
TWITTER.COM
 
Posts: 3355
Joined: Tue Nov 27, 2007 3:15 pm

Post » Sat May 28, 2011 12:47 am

Erm, not sure just what the heck is going on, but, I can't even come up with the right page in the CS Wiki for getsoundplaying.........


I think the Wiki is not up to date with the latest OBSE commands. http://obse.silverlock.org/obse_command_doc.html#GetSoundPlaying is the description from the OBSS documentation.
User avatar
Hearts
 
Posts: 3306
Joined: Sat Oct 20, 2007 1:26 am

Post » Sat May 28, 2011 2:00 am

looks like you could maybe use "*swallow" as your search parameter? instead of three individual checks? my guess is you would have to be checking in both menumode, and gamemode blocks as well?
User avatar
Taylor Thompson
 
Posts: 3350
Joined: Fri Nov 16, 2007 5:19 am

Post » Fri May 27, 2011 6:05 pm

looks like you could maybe use "*swallow" as your search parameter? instead of three individual checks? my guess is you would have to be checking in both menumode, and gamemode blocks as well?


I didn't use the three checks I posted at once in a script, I used one of them at a time and none of them worked.

Like

if getsoundplaying "*swallow*" > 0message "Potion"endif


So far I only tested with a gamemode block and potions used via hotkey while in gamemode, but if I'd get it to work correctly I'd make a menumode part of the script as well of course.
User avatar
Laura Wilson
 
Posts: 3445
Joined: Thu Oct 05, 2006 3:57 pm

Post » Sat May 28, 2011 5:39 am

What about "if getsoundplaying "NPCHumanswallow" > 0" or "if getsoundplaying NPCHumanswallow > 0"

Maybe it was the reference messing up number one, and the extra "*" messing up number three?
User avatar
Ownie Zuliana
 
Posts: 3375
Joined: Thu Jun 15, 2006 4:31 am

Post » Sat May 28, 2011 7:02 am

What about "if getsoundplaying "NPCHumanswallow" > 0" or "if getsoundplaying NPCHumanswallow > 0"

Maybe it was the reference messing up number one, and the extra "*" messing up number three?


Indeed, that was the problem. Without reference and radius it works like expected with

if getsoundplaying NPCHumanSwallow > 0

I feel a bit dumb now for not trying this, but thanks for the help.
User avatar
Cathrin Hummel
 
Posts: 3399
Joined: Mon Apr 16, 2007 7:16 pm


Return to IV - Oblivion