Deleted2746547User Posted May 13, 2015 Share Posted May 13, 2015 (edited) I've created a feature in my mod where the player can build a base. In the process of building that base he constructs a generator that is used to power the lights. HOWEVER, the lights consume fuel that you must put in a tank if you want them to stay on. When the lights go out at night (well, when I figure out how to script it) bad things happen.Problem is, it's all tied to a quest. The quest checks fuel supplies against lights on every 5 seconds. Once the fuel runs out the lights go off. However, it seems to be causing intermittent crashes and really doesn't need to be checking that often. The main point was to create a need to build a generator, to be reminded that electrical devices need power to run and that you must produce that energy somehow.At some point, another quest will be created to upgrade to solar, etc. but for now... I need to fix this script. How would you change this so it checks less (or any other suggestion that might make it run more smoothly.UNRELATED QUESTION: I know how to create dialogue and an npc. But how would you create a companion wheel for people in your faction that just allowed you to change their inventory (armor, etc.) As part of the base building you can create guards...but I'd like to make it possible for the player to change anyone in his faction's armor, weapons, etc.MANY THANKS!###MAIN QUEST SCRIPT. Right now. eac lights in each room, etc. are attached to an x marker. That marker is linked to an activator (a switch). If the generator is fixed and you have fuel, the lights come on. If not, you're alone in the dark. scn BlackbriarPowerBaseQuestScript int Fuel ; This is the total fuel units in stockint FuelRqd ; This is the calculated amount that will be used in a single 5 second period Begin GameMode If Fuel Else return Endif set FuelRqd to 0 ;Lghts1 uses 1 unit of Fuel/5sec If BlackbriarLgts1.GetDisabled Else set FuelRqd to FuelRqd + 1 Endif ;Lghts2 uses 1 unit of Fuel/5sec If BlackbriarLgts2.GetDisabled Else set FuelRqd to FuelRqd + 1 Endif ;Lghts3 uses 1 unit of Fuel/5sec If BlackbriarLgts3.GetDisabled Else set FuelRqd to FuelRqd + 1 Endif ;Lghts4 uses 1 unit of Fuel/5sec If BlackbriarLgts4.GetDisabled Else set FuelRqd to FuelRqd + 1 Endif ;Lghts5 uses 1 unit of Fuel/5sec If BlackbriarLgts5.GetDisabled Else set FuelRqd to FuelRqd + 1 Endif ;Lghts6 uses 1 unit of Fuel/5sec If BlackbriarLgts6.GetDisabled Else set FuelRqd to FuelRqd + 1 Endif ;Lghts7 uses 1 unit of Fuel/5sec If BlackbriarLgts7.GetDisabled Else set FuelRqd to FuelRqd + 1 Endif ;Lghts8 uses 1 unit of Fuel/5sec If BlackbriarLgts8.GetDisabled Else set FuelRqd to FuelRqd + 1 Endif ;Lghts9a uses 1 unit of Fuel/5sec If BlackbriarLgts9a.GetDisabled Else set FuelRqd to FuelRqd + 1 Endif ;Lghts10a uses 1 unit of Fuel/5sec If BlackbriarLgts10a.GetDisabled Else set FuelRqd to FuelRqd + 1 Endif ;Lghts11 uses 1 unit of Fuel/5sec If BlackbriarLgts11.GetDisabled Else set FuelRqd to FuelRqd + 1 Endif ;Lghts12 uses 1 unit of Fuel/5sec If BlackbriarLgts12.GetDisabled Else set FuelRqd to FuelRqd + 1 Endif ;Subtract the fuel used set Fuel to Fuel - FuelRqd ;Turn off all power users when Fuel runs out. If Fuel < 1 set Fuel to 0 BlackbriarLgts1.Disable BlackbriarLgts2.Disable BlackbriarLgts3.Disable BlackbriarLgts4.Disable BlackbriarLgts5.Disable BlackbriarLgts6.Disable BlackbriarLgts7.Disable BlackbriarLgts8.Disable BlackbriarLgts9a.Disable BlackbriarLgts10a.Disable BlackbriarLgts11.Disable BlackbriarLgts12.Disable Endif######ScriptName BlackbriarPowerLightScript ref light Begin OnActivate if BlackbriarPowerBaseQuest.Fuel == 0 return Endif if light == 0set light to GetLinkedRefendif if light.GetDisabledlight.Enableelselight.DisableendifActivateEnd ################# scn BlackbriarFuelTank Begin onActivate If GetQuestRunning BlackbriarPowerBaseQuest Else StartQuest BlackbriarPowerBaseQuest Endif If player.GetItemCount BlackbriarAtwoodFUELOIL player.removeItem BlackbriarAtwoodFUELOIL 1 set BlackbriarPowerBaseQuest.Fuel to BlackbriarPowerBaseQuest.Fuel + 500 ElseShowMessage BlackbriarPowerNoBatteriesMsg EndifEnd Edited May 13, 2015 by Guest Link to comment Share on other sites More sharing options...
RoyBatterian Posted May 14, 2015 Share Posted May 14, 2015 Just change the quest delay to make it longer, default is 5 seconds, it can be much long or shorter if you like. I don't see why this would cause crashes, but I just quickly skimmed it. Link to comment Share on other sites More sharing options...
Jokerine Posted May 14, 2015 Share Posted May 14, 2015 Yeah, I had the game crash randomly when I had a quest script set to check too often (I think it was like 0.01 seconds or something, hahaha!), so if you set the delay to something a bit higher it should work. I think. UNRELATED QUESTION: I know how to create dialogue and an npc. But how would you create a companion wheel for people in your faction that just allowed you to change their inventory (armor, etc.) As part of the base building you can create guards...but I'd like to make it possible for the player to change anyone in his faction's armor, weapons, etc. I'm not sure if it's possible with the wheel if they're not currently hired per se, but if you give them a dialogue topic like "I have some better equipment for you" with OpenTeammateContainer in the result script (like the vanilla "let's trade equipment" dialogue prompt does) I think you should be able to do what you want. Link to comment Share on other sites More sharing options...
Fallout2AM Posted May 14, 2015 Share Posted May 14, 2015 You can check it with a different frequency if you want, but running on default delay time has already an impercetible workload, I believe it is already good as it is. What would worry me is the CTD, I don't see a reason why it could be related to the delay time, nor I can notice anything on the script that could lead to that Link to comment Share on other sites More sharing options...
Deleted2746547User Posted May 14, 2015 Author Share Posted May 14, 2015 Thank you both for the feedback :) I really have so much to learn when it comes to scripting.... it takes me hours to put together what you all do in 2.2 seconds. So, thank you for the feedback! A follow up question:1. Would I just give every one of the npc's in the player's faction that dialogue line? Let me rephrase: I know how to make dialogue for a specific character - how do you make it for the whole faction? Link to comment Share on other sites More sharing options...
Jokerine Posted May 14, 2015 Share Posted May 14, 2015 Add a condition that checks if the subject is in the faction. GetInFaction should do the trick. Link to comment Share on other sites More sharing options...
Deleted2746547User Posted May 14, 2015 Author Share Posted May 14, 2015 You can check it with a different frequency if you want, but running on default delay time has already an impercetible workload, I believe it is already good as it is. What would worry me is the CTD, I don't see a reason why it could be related to the delay time, nor I can notice anything on the script that could lead to thatTHE CTD worries me...and almost every time it happens, it is after I turn on the lights. :/ Also: another unrelated question: I'm also working on a syringe of medicine that has a couple of possible effects if you use it: 1. It heals you completely of any wounds (and resurrects you/NPC if "dead"), 2.Does nothing at alll and 4. Brings you back as a zombie/ghoul that can infect others. Can't seem to get it to work right though... ## scn BlackbriarReviverScript short sRandref rTarget begin Gamemode set rTarget to player.GetCombatTargetSet sRand to GetRandomPercent If player.IsSneaking==1 && rTarget.Getdead && player.getitemcount BlackbriaReviver >= 1 && sRand >= 10playsound NPCHumanUsingPsychorTarget.DisablerTarget.PlaceAtMe BlackbriarZombieLevel4player.removeItem BlackbriaReviver 1player.additem BlackbriaReviverEMPTY 1elseif player.IsSneaking==1 && rTarget.Getdead && player.getitemcount BlackbriaReviver >= 1playsound NPCHumanUsingPsychorTarget.Resurrectplayer.removeItem BlackbriaReviver 1player.additem BlackbriaReviverEMPTY 1endIf end Link to comment Share on other sites More sharing options...
Fallout2AM Posted May 14, 2015 Share Posted May 14, 2015 (edited) If the siringue is an ingestible, the best deal to use a gamemode would be attaching that script on a spell, casted (CIOSed...)by the ingestible. Instead, if you simply are attaching the script to the ingestible, then you should use an onactivate. Whatever approach you take, the script is assuming that rTarget exists, but instead it would be required to check if it exists first.It also assumes that npc is either an actor or a creature. You are creating a zombie, so maybe you want only actors, at that point you should use conditional statement that checks if GetType 42 / 45 is true. Last, but this is personal, since you're using functions like Equip and PlaceAtMe, staging it in more frames wouldn't be bad, so I personally wouldn't use an OnActivate but I would stick with the spell in gamemode, with a duration of at least 1 second, or undefined (dispelled by the script when it has finished) Edited May 14, 2015 by Fallout2AM Link to comment Share on other sites More sharing options...
Deleted2746547User Posted May 14, 2015 Author Share Posted May 14, 2015 Right now it's attached to an ingestible. Could you make edits to my script (if you were doing it to your preference) and show me the difference? You don't know how long that script took to bring together :) THANKS as always for the feedback! :) Link to comment Share on other sites More sharing options...
claustromaniac Posted May 14, 2015 Share Posted May 14, 2015 TL;DRTry this for your CTDs: scn BlackbriarPowerLightScript ref light Begin OnActivate if BlackbriarPowerBaseQuest.Fuel == 0 Return endif set light to GetLinkedRef if light if light.GetDisabled light.Enable else light.Disable endif endif Activate End Link to comment Share on other sites More sharing options...
Recommended Posts