Cridow Posted September 10, 2021 Share Posted September 10, 2021 After watching the GTA V Chaos Mod in action, I thought it'd be a fun thing to have in Skyrim.I was thinking of making a mod, using the creation kit, that plays one of a certain number of console commands randomly in a specified time interval. Like 30 seconds or 1 minute.Console Util allows papyrus scripts to execute console commands. So I figure that's the place to start. But how about the random timer?How would I go creating such a mod, setting a "pool" of console commands to be executed, setting up time intervals and all?I have never delved too deep into that sort of thing and would appreciate some pointers or links ^^' Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 10, 2021 Share Posted September 10, 2021 You can use RandomInt or RandomFloat to come up with the time to wait before processing the console command. After you have the time value, you can use RegisterForSingleUpdate or RegisterForSingleUpdateGameTime to trigger the "wait" process. Finally, use the OnUpdate or OnUpdateGameTime event to run the code that processes the desired console command. You may wish to further randomize it by using RandomInt or RandomFloat again to pick numbers that correspond with your list of console commands. Incomplete example: ;event / function begin ;previous code if any Int RealTimeWait = RandomInt(30,60) ;picks a number between and including 30 seconds and 60 seconds RegisterForSingleUpdate(RealTimeWait) ;additional code if any ;event / function end Event OnUpdate() Int ConsoleCommandChoice = RandomInt(0,9) ;picks a number between and including 0 and 9 If ConsoleCommandChoice == 0 ;process #0 CC ElseIf ConsoleCommandChoice == 1 ;process #1 CC ;etc... ElseIf ConsoleCommandChoice == 9 ;process #9 CC EndIf EndEvent Link to comment Share on other sites More sharing options...
Cridow Posted September 10, 2021 Author Share Posted September 10, 2021 O You can use RandomInt or RandomFloat to come up with the time to wait before processing the console command. After you have the time value, you can use RegisterForSingleUpdate or RegisterForSingleUpdateGameTime to trigger the "wait" process. Finally, use the OnUpdate or OnUpdateGameTime event to run the code that processes the desired console command. You may wish to further randomize it by using RandomInt or RandomFloat again to pick numbers that correspond with your list of console commands. Incomplete example: ;event / function begin ;previous code if any Int RealTimeWait = RandomInt(30,60) ;picks a number between and including 30 seconds and 60 seconds RegisterForSingleUpdate(RealTimeWait) ;additional code if any ;event / function end Event OnUpdate() Int ConsoleCommandChoice = RandomInt(0,9) ;picks a number between and including 0 and 9 If ConsoleCommandChoice == 0 ;process #0 CC ElseIf ConsoleCommandChoice == 1 ;process #1 CC ;etc... ElseIf ConsoleCommandChoice == 9 ;process #9 CC EndIf EndEvent Hell yesss thank you so much! This is a good start for me :D Link to comment Share on other sites More sharing options...
dylbill Posted September 10, 2021 Share Posted September 10, 2021 For picking a random console command, I would recommend to use an array, to cut down on if / elseif conditions, which is better for performance. String[] Property ConsoleCommands Auto ;array list of console commands, set in the creation kit. Event OnInit() Int RealTimeWait = Utility.RandomInt(30,60) ;picks a number between and including 30 seconds and 60 seconds RegisterForSingleUpdate(RealTimeWait) EndEvent Event OnUpdate() Int R = Utility.RandomInt(0, ConsoleCommands.Length - 1) ;get random index for available entries in the ConsoleCommands array. ConsoleUtil.ExecuteCommand(ConsoleCommands[R]) ;execute random console command Int RealTimeWait = Utility.RandomInt(30,60) ;picks a number between and including 30 seconds and 60 seconds RegisterForSingleUpdate(RealTimeWait) EndEvent Link to comment Share on other sites More sharing options...
Cridow Posted September 10, 2021 Author Share Posted September 10, 2021 (edited) For picking a random console command, I would recommend to use an array, to cut down on if / elseif conditions, which is better for performance. String[] Property ConsoleCommands Auto ;array list of console commands, set in the creation kit. Event OnInit() Int RealTimeWait = Utility.RandomInt(30,60) ;picks a number between and including 30 seconds and 60 seconds RegisterForSingleUpdate(RealTimeWait) EndEvent Event OnUpdate() Int R = Utility.RandomInt(0, ConsoleCommands.Length - 1) ;get random index for available entries in the ConsoleCommands array. ConsoleUtil.ExecuteCommand(ConsoleCommands[R]) ;execute random console command Int RealTimeWait = Utility.RandomInt(30,60) ;picks a number between and including 30 seconds and 60 seconds RegisterForSingleUpdate(RealTimeWait) EndEvent Ohh neat neat, I almost forgot arrays existed lol (I'm studying to be a programmer analyst but c*vid threw me off and I forgot to practice a lot)i'm going to try this! ty!! Edit: I'm having trouble declaring the array lolThis... can't be right, right? Don't I need a loop and what have you... I don't remember how to do it LOL Here was my test attempt to declare an array of just 3 strings for testing String[] Property ConsoleCommands(Int 3, String fill = "player.placeatme 000EBA01 30", "player.placeatme 000F4314 30", "player.setscale 20")Won't compile ^^' Data\Source\Scripts\temp\chaosscript1test.psc(3,85): required (...)+ loop did not match anything at input ','No output generated for chaosscript1test, compilation failed. I'm also having trouble getting ConsoleUtil to work... How do I Install it if I'm developing?I get this error, so I'm guessing the end-user file isn't what I need lol variable ConsoleUtil is undefined Thanks so far for the help and I hope I'm not being too muchof a noob ^^' Edited September 10, 2021 by Cridow Link to comment Share on other sites More sharing options...
Cridow Posted September 10, 2021 Author Share Posted September 10, 2021 (edited) Oops double post sorry Edited September 10, 2021 by Cridow Link to comment Share on other sites More sharing options...
dylbill Posted September 10, 2021 Share Posted September 10, 2021 For arrays in papyrus, this is how you declare in the script: String[] Property ConsoleCommands Auto ; Event OnInit() ;runs when the script is first loaded. ConsoleCommands = New String[3] ConsoleCommands[0] = "player.placeatme 000EBA01 30" ConsoleCommands[1] = "player.placeatme 000F4314 30" ConsoleCommands[2] = "player.setscale 20" Int RealTimeWait = Utility.RandomInt(30,60) ;picks a number between and including 30 seconds and 60 seconds RegisterForSingleUpdate(RealTimeWait) EndEvent Event OnUpdate() Int R = Utility.RandomInt(0, ConsoleCommands.Length - 1) ;get random index for available entries in the ConsoleCommands array. ConsoleUtil.ExecuteCommand(ConsoleCommands[R]) ;execute random console command Int RealTimeWait = Utility.RandomInt(30,60) ;picks a number between and including 30 seconds and 60 seconds RegisterForSingleUpdate(RealTimeWait) ;picks a number between and including 30 seconds and 60 seconds EndEventYou can also see the array strings in the Creation Kit. When filling the array property, click on the ConsoleCommands property and hit the Edit Value button to add or remove strings to the array. Link to comment Share on other sites More sharing options...
dylbill Posted September 10, 2021 Share Posted September 10, 2021 For consoleUtil, make sure the source .psc script is in the right folder. In SE they moved the source scripts from Data/Scripts/Source to Data/Source/Scripts. Just copy the .psc file to both locations, that's what I do anyways. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 10, 2021 Share Posted September 10, 2021 I had thought about suggesting an array approach but had no idea how to set it up for console command usage. Especially since I had no idea how the ConsoleUtil thing actually worked. Glad you knew how to do that dylbill Link to comment Share on other sites More sharing options...
dylbill Posted September 10, 2021 Share Posted September 10, 2021 No worries, happy to help :) I've used ConsoleUtil in a few of my mods. Also fyi the console command Player.SetScale 20 will make the player HUGE. 1.0 is normal size, 2.0 is double size, so 20.0 would be 20 times bigger! Link to comment Share on other sites More sharing options...
Recommended Posts