kflee Posted May 3, 2013 Share Posted May 3, 2013 I want to start learning the script syntax, and after reading the TES4 Construction Kit it seems easy enough. To begin, I want to try scripting so that whenever my character gets hit, he mutters something as long as he didn't say anything for the last 3 seconds. So, this is what I think I need to do: 1) Create new sound entry. Pointed it to directory full of .wav's and called it MVgetHitSound 2) Create a new script, lets call it MVOnHit ScriptName MVOnHit short currentHP short newHP short doOnce Begin GameMode ;Set up variables: if doOnce == 0 set currentHP to player.GetCurrentHealth set newHP to currentHP set doOnce to 1 endif ;Loop to check when currentHP != newHp if currentHP != newHP set newHP to currentHP player.playsound3d MVgetHitSound endif End 3) Attach script to Player NPC. 4) Skip ???, go straight to profit. However, I'm missing something. I don't know to add a timed delay, nor do I know why this won't werk. Halp plz? Link to comment Share on other sites More sharing options...
jazzisparis Posted May 3, 2013 Share Posted May 3, 2013 Hi kflee,First, create a new "dummy" quest, put a check in 'Start Game Enabled' and set 'Script Processing Delay' to 0.1.Now, create a new script, set 'Script Type' to 'Quest', and use this code: scn MVOnHit float fLastHP float fCurrentHP float fDelay begin GameMode if fDelay set fDelay to (fDelay > 0) * (fDelay - GetSecondsPassed) endif if fCurrentHP != player.GetCurrentHealth set fCurrentHP to player.GetCurrentHealth if (fCurrentHP < fLastHP) && (fDelay == 0) set fDelay to 3 player.PlaySound3D MVgetHitSound endif set fLastHP to fCurrentHP endif end Finally, return to the quest you created and have it use this script. Link to comment Share on other sites More sharing options...
kflee Posted May 4, 2013 Author Share Posted May 4, 2013 (edited) Hmmm, the script won't save. EDIT: Oh, now it does. Problem is that it doesn't seem to work. EDIT: Got working with the PrintC commands to debug, it seems that Player.getCurrentHealth is always returning 100.000?Wat. Oh, I got it working. Great success. Thank you for helping me out! Edited May 4, 2013 by kflee Link to comment Share on other sites More sharing options...
Recommended Posts