David Brasher Posted June 25, 2009 Share Posted June 25, 2009 In my mod there is a segment where you have a companion. This companion is sort of talkative and is supposed to generate a random comment every four minutes of real time. This part of the script is for Sundas only. GameHour and GetCurrentTime do not appear to function in Begin GameMode script blocks. So I am experimenting with GetSecondsPassed and am not impressed. I thought a second was 1/60th of a minute by the clock in the real world. These seconds are so small I have not calculated their size yet. We are talking smaller than a millisecond. Maybe smaller than a nanosecond. My companion won't shut up. She says one comment immediately after another eternally. The only escape is to exit the game. Here is the problem script: SCN ChatterboxSCRIPT ; object script attached to NPC float timer Begin GameModeIf ( Getstage MyQuest == 50 && GetDayofWeek == 0 && timer > 0 )Set timer to timer - GetSecondsPassedElseStartConversation player GREETINGSet timer to 200000000EndifEnd Does anyone know how to fix this script or make a totally different one that works? Link to comment Share on other sites More sharing options...
alex2avs Posted June 25, 2009 Share Posted June 25, 2009 if i remember well , you must use float for time variables. oh...and GetDayofWeek == 0 condition will make your npc talk only one day ; Morndas... I think Link to comment Share on other sites More sharing options...
David Brasher Posted June 25, 2009 Author Share Posted June 25, 2009 You are right on both points alex2avs. I originally typed my question in wrong. The script did use float, but I typed in short here. This script does apply to one particular day of the week. I have edited my question to fix these points. Link to comment Share on other sites More sharing options...
Pronam Posted June 25, 2009 Share Posted June 25, 2009 close :).. Sundas.. getsecondspassed seconds are like real-life seconds...so equal to minutes in oblivion.. I'm generally against that whole script..that one will run like forever and the performance hit would be...great....Using && is fine.. but it will run the check even if one of those conditions isn't true...Next to that it will not work because the timer will be reset every second..because it isn't 0 .....So that may explains some :) I would have done a spell that runs for 4 minutes and at the end he'll start the conversation and cast the spell again :)That could evade a lot of trouble :)... Link to comment Share on other sites More sharing options...
alex2avs Posted June 25, 2009 Share Posted June 25, 2009 4 minutes spell Nice one, Vic ;)... Link to comment Share on other sites More sharing options...
David Brasher Posted June 26, 2009 Author Share Posted June 26, 2009 A four minute spell. That sounds like a cool idea. Now how do I put it into practice? I have created my 4 minute spell. It is Resist Normal Weapons 1%. I have named it "timerspell" and placed it in my chattering NPC's spell list. Once when I was trying to do something else with conditions, I researched some of the magic functions. It seemed like most of them did not work very much of the time. They probably have very specific uses which are not well-documented. Now I need a condition function which will detect whether or not the NPC has the spell effect on her. Am I supposed to use HasMagicEffect? IsSpellTarget? Some other function I have never heard of? This Script makes the NPC talk continuously instead of once every four minutes: If HasMagicEffect RSNW == 0StartConversationPlayer GREETINGCast TimerSpell ChatterboxNPCREFEndIf Link to comment Share on other sites More sharing options...
Pronam Posted June 26, 2009 Share Posted June 26, 2009 Spell scripts don't have that much limits...The thing is, is that they only allow three begin blocks.Begin ScriptEffectStart. Begins at the hit of the spell and runs once.Begin ScriptEffectUpdate could be used to do something between the start and the beginning. the time is decided by the time the spell is effecting. ScriptEffectElapsedSeconds replaces the GetSecondsPassed.Begin ScriptEffectFinish, starts at the end of the counter, or immediately after the ones above if the effect is single (no timer) and only runs once again. Although the spell does work how it should work, I don't know if the whole picture will. I had this for the spell. The effect is listed under 'Script Effect' and the range should be set on self... scn Myspellscript ref self Begin ScriptEffectStart set self to GetSelf self.startconversation player Endif End Begin ScriptEffectFinish if spellquest.day == 0 endif if spellquest.day == 1 self.cast MySpell self endif EndThe spell "myspell" had a duration of 240 (seconds) and this for the quest called "spellquest"'The whole 'go' thing is there because 'myspell' only needs to be cast once and then it will run the whole day.Probably one time more on morndas as well...but after that it will stop until sundas. scn Spellquestscript short go short day Begin GameMode if GetDayofWeek == 0 set day to 1 if go == 0 if getstage spellquest == 20 spellbuddyref.cast myspell spellbuddyref set go to 1 endif endif else set day to 0 if go == 1 set go to 0 endif endif End hey, 500th post :D Link to comment Share on other sites More sharing options...
rdamstrom Posted June 28, 2009 Share Posted June 28, 2009 SCN ChatterboxSCRIPT ; object script attached to NPC float timer Begin GameMode If ( Getstage MyQuest == 50 && GetDayofWeek == 0) If timer > 0 Set timer to timer - GetSecondsPassed Else StartConversation player GREETING Set timer to 4 Endif Endif End I think this code might work a little better bacause your code would have started the conversation wheneverit was't sunday or myquest wasn't == 50 completely bypassing timer updates Link to comment Share on other sites More sharing options...
Pronam Posted June 28, 2009 Share Posted June 28, 2009 Yes, but you do put up a timer that will be checked every frame...The combo I made gives less stress on the system :) It doesn't really matter if this is the only mod you're running, but who has 1 mod running these day ;D.In the long end, it definitely counts.Generally agreed using && is unadvised, especially when running in a Gamemode forever.blocks around && means that although the one before is wrong the one behind will still be checked.I can recall an article about it, I don't know where it was (somewhere on the official forums or something...)If you place them beneath each other, that problem is solved. The combo I made had indeed one flaw, it has the chance it will run one more time.But 1 more time, not more. I have an every 5 second check if the day is sunday or not, in the quest script.Now it took a closer look, I must explain how your script isn't really working. The timer is set to 4. Meaning every 4 seconds a conversation is triggered instead of 4 minutes (real-minutes)Initially nothing is wrong with it.. but I can have far more scripts for yours and still reach the same fps :) Link to comment Share on other sites More sharing options...
rdamstrom Posted June 28, 2009 Share Posted June 28, 2009 It is not about weather your script is better or not. It is about a script that wasn't working and will never workwritten the way it was posted. further more if the player is not around the npc containing that script. it will hardlyever get run anyway. a spellquest written the way it is will run every 5 sec. the set timer was lowered to show David that it could work. If set at 200000000 he would probably think it was broken because the timer isset too high. The correct number should be about 240 for game time Link to comment Share on other sites More sharing options...
Recommended Posts