Jump to content

Making a 'Chaos Mod' with ConsoleUtilSSE


Cridow

Recommended Posts

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

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

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

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

 

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 lol

This... 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 by Cridow
Link to comment
Share on other sites

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
EndEvent

You 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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...