#plugin Fast Bang V1.0 Beta 1 #author Dan Williamson and heavily cribbed from work by Exile In Paradise, Jeff Parker, Ed Diana - Sunday, July 23, 2006 12:00 PM #desc Create random star systems without surface maps for each star in a sector. cancelled = False SaveToDiskCount = 100 ' Number of bodies to process before saving the data to the hard drive NumberOfBodiesProcessed = 0 SystemInProcess = 0 sector = GetCurrentSector() numberOfSystems = sector.SystemCount() ScanSystems RefreshScene Sub ScanSystems sector.RenderMessageBig = CStr(numberOfSystems) & " systems found. Hit [ESC] to cancel and [P] to pause processing." RefreshScene DisplayUpdate = 1 ' Number of systems to process before updating the display for currentSystem = 1 to numberOfSystems SystemInProcess = currentSystem If ((currentSystem Mod DisplayUpdate) = 0) Then sector.RenderMessageBig = CStr(numberOfSystems) & " systems found - " & currentSystem & " systems processed (" & CInt((currentSystem/numberOfSystems) * 100) & "%). Hit [ESC] to cancel and [P] to pause processing.." RefreshScene End If ProcessSystem(currentSystem - 1) NumberOfBodiesProcessed = NumberOfBodiesProcessed + 1 If ((NumberOfBodiesProcessed Mod SaveToDiskCount) = 0) Then Sector.SaveToFile Sector.FileName, false End If If (cancelled) Then Exit Sub Next Sector.SaveToFile Sector.FileName, false sector.UpdateVisibleCount RefreshScene End Sub Sub ProcessSystem( systemNumber ) 'check for a cancel CheckIfCancelled If (cancelled) Then Exit Sub CheckIfPaused aSystem = sector.GetSystem(systemNumber) If not aSystem.Loaded Then sector.DynaLoad aSystem End If ' This flag is set to 1 if the system contains a white dwarf ' It indicates that no planets are to be found in the system. noplanets = 0 ' If the system is of Type Multiple If aSystem.TypeID = BODY_TYPE_MULT Then ' Only create child bodies for each substar individually. ' Check for the presence of a White Dwarf in the system For currentStar = 1 to aSystem.ChildrenCount() thisStar = aSystem.getChild(currentStar-1) If thisStar.TypeID = BODY_TYPE_WHITEDWARF Then noplanets = 1 End If Next ' If there is no White Dwarf, then we can go ahead and generate the system contents for ' each star individually If noplanets = 0 Then For currentStar = 1 to aSystem.ChildrenCount() thisStar = aSystem.getChild(currentStar-1) RegenerateSystem thisStar Next End If End If ' If the system is of Type Star (not White Dwarf), we can go ahead and generate a full system. If aSystem.TypeID = BODY_TYPE_STAR Then RegenerateSystem aSystem End If If (cancelled) Then Exit Sub ProcessPlanetaryBodies aSystem If (cancelled) Then Exit Sub 'do this so that astro can keep track of things like populations & political affiliations more efficiently If (sector.Modified = True) Then aSystem.UpdateRootBody End If End Sub Sub RegenerateSystem( aSystem ) 'check for a cancel CheckIfCancelled If (cancelled) Then Exit Sub CheckIfPaused temp = aSystem.Name ' save name aSystem.ClearFields RandomSystem aSystem, true 'use built-in astro generator, w/ populations aSystem.Name = temp 'restore name End Sub Sub ProcessPlanetaryBodies( aSystem ) 'check for a cancel CheckIfCancelled If (cancelled) Then Exit Sub CheckIfPaused If (aSystem.ChildrenCount() = 0) Then Exit Sub For currentBody = 1 to aSystem.ChildrenCount() ProcessChildBody aSystem, currentBody - 1 If (cancelled) Then Exit Sub NumberOfBodiesProcessed = NumberOfBodiesProcessed + 1 If ((NumberOfBodiesProcessed Mod SaveToDiskCount) = 0) Then Sector.SaveToFile Sector.FileName, false End If Next 'if system is populated, change the label color if aSystem.ChildPopulation > 0 then aSystem.LabelColor = rgb( 128, 255, 0) end if End Sub Sub ProcessChildBody( aSystem, bodyNumber ) 'check for a cancel CheckIfCancelled If (cancelled) Then Exit Sub CheckIfPaused aBody = aSystem.GetChild(bodyNumber) End Sub Sub CheckIfCancelled If (cancelled = False) Then cancelled = (GetKey() = 27) End If End Sub sub CheckIfPaused If ((GetKey() = 80) Or (GetKey() = 112)) Then sector.RenderMessageBig = "Processing paused. Hit [P] to continue processing. Paused on system number " & SystemInProcess RefreshScene KeyPressed = GetKey() Do While (KeyPressed <> 80) And (KeyPressed <> 112) Pause 500 KeyPressed = GetKey() Loop sector.RenderMessageBig = CStr(numberOfSystems) & " systems found - " & SystemInProcess & " systems processed (" & CInt((SystemInProcess/numberOfSystems) * 100) & "%). Hit [ESC] to cancel and [P] to pause processing.." RefreshScene End If End Sub