Tallon314 Posted November 29, 2013 Share Posted November 29, 2013 (edited) Hey community,I have another query related to the mod I am building, and I thought I'd put the question out here just in case someone who knows an answer is watching. I've gotten a lot more experience with scripting in the past few weeks, but I'm still really at a novice level.The short question is: Is there a way for a script to detect if a player has just used a Stimpak or other healing Item (that's not just checking if the player's health has gone up)?Or, and this will help me way more, but I've resigned myself to having to circumnavigate it, is there a way to detect if the player is unconscious if they have been set essential and been knocked out? GetUnconcious is for detection of the SetUnconscious command, and GetKnockedState doesn't return proper values for the player as far as I can tell...Any help is appreciated! Cheers, Tallon Edited November 29, 2013 by Tallon314 Link to comment Share on other sites More sharing options...
jazzisparis Posted November 30, 2013 Share Posted November 30, 2013 The short question is: Is there a way for a script to detect if a player has just used a Stimpak or other healing Item (that's not just checking if the player's health has gone up)?Since the effect of Stimpaks is instantaneous, there is no way that is 100% reliable to detect whether the player (or any actor) has used a Stimpak - at least none that I know of.The only way is to have a quest-script running continuously in the background that would keep track of the number of Stimpaks (or any other healing item, for that matter) the player carries. Whenever that number is decremented, that would (supposedly) mean the player has used one.Create a new Quest form, set Script Processing Delay to 0.5 and tick Start Game Enabled. Now create a new Script, set Script Type to Quest and use the code below as skeleton: scn DetectStimpakUseScript short iLastCount short iCurrentCount short bMenuModeFlag begin MenuMode if (MenuMode 1002 || bMenuModeFlag) == 0 set bMenuModeFlag to 1 endif end begin GameMode set iCurrentCount to player.GetItemCount Stimpak if iCurrentCount != iLastCount if (bMenuModeFlag == 0) && (iCurrentCount < iLastCount) ; (A Stimpak was used - do stuff) endif set iLastCount to iCurrentCount endif if bMenuModeFlag set bMenuModeFlag to 0 endif end (After saving, don't forget to return to the quest you created and have it use this script) Or, and this will help me way more, but I've resigned myself to having to circumnavigate it, is there a way to detect if the player is unconscious if they have been set essential and been knocked out? GetUnconcious is for detection of the SetUnconscious command, and GetKnockedState doesn't return proper values for the player as far as I can tell...The player cannot fall unconscious (if he does, it means game over). If you mean other actors, in general, then the condition statement if SomeActorRef.GetKnockedState == 1 will return True if SomeActorRef is unconscious. Link to comment Share on other sites More sharing options...
Tallon314 Posted November 30, 2013 Author Share Posted November 30, 2013 Darn, that's what I feared I'd have to do to track stimpak usage, just thought I'd check to see if there was something simple I was missing. Oh well.As far as the Player being knocked out however, well, in the vanilla game, yes, The Player cannot be knocked out, as they will die. But if set essential though the console or a script (as I have done, conditionally), the Player CAN be knocked out like an Essential Actor, but GetKnockedState won't return proper values for the Player and the Player will not automatically recover, probably because the engine isn't built to handle the Player as an essential character and doesn't bother to look at them.So to detect it, I'm having to use a set of proxy conditions that would indicate that the player has been knocked out, one of which requires testing for stimpak or other immediate restorative health usage.Thanks for the help though, this tracking the stimpaks this way should be able to be integrated.Tallon Link to comment Share on other sites More sharing options...
Recommended Posts