% % Stefan's Autoexec Script % % This is my actual autoexec script, for your inspiration. % % Version: February 2005. % % --Stefan Reuther % % You'll probably set this to something else Local ScriptPrefix = "g:/planets/cc/qlib/" % Scripts I like to use Load ScriptPrefix & "bum.q" % "bum"/"btm" cloaker detect Load ScriptPrefix & "auto.q" % some auto tasks Load ScriptPrefix & "load.q" % load stuff to build ammo (Ctrl-C on ship) Load ScriptPrefix & "marker.q" % list markers here (Ctrl-L in chart) Load ScriptPrefix & "revive.q" % keep status across sessions Load ScriptPrefix & "vis.q" % visualize things (Ctrl-V in chart) Load ScriptPrefix & "comment.q" % comment timestamps % When a ship uses warp wells to get to a planet, Host will leave the % waypoint pointing into the warp well. This will reset those waypoints. Sub ResetWP ForEach Ship Do If Owner$=My.Race$ Then If Orbit$ And (Waypoint.DX Or Waypoint.DY) And (PlanetAt(Waypoint.X, Waypoint.Y, 1)=Orbit$) And (Speed$<>1) Then Try SetWaypoint Loc.X, Loc.Y EndIf Next EndSub % "Mark" all old minefields (not scanned this turn) by giving them a % cyan circle. Sub OldMF ForEach Minefield Do If LastScan<>Turn Then NewCircle Loc.x, Loc.y, Radius, 23, 1, 0 EndSub % This marks all my ships and displays how many I have. Very useful to do % at the beginning of a turn. When I'm done with a ship, I deselect it, % so this is very nice to keep an eye on which ships still need to be done. Sub Meins Local n = 0 SelectionExec Current := 0 % Unmark everything ForEach Ship If Owner$=My.Race$ Then Mark n := n + 1 EndIf Next MessageBox "We have " & n & " ships." EndSub % Some people annoy me by naming their ships after other ship classes, % e.g. a Gorbie called PL21 PROBE. This will rename those ships to their % real class name. Sub AntiSpoof Local i ForEach Ship Do If Owner$<>My.Race$ Then For i:=1 To 105 Do If Left(Name,10) = Left(Hull(i).Name,10) Then Name := Hull Break EndIf Next EndIf Next EndSub On Load Do AntiSpoof % This function is useful in PHost games with the extended mine laying % missions: using Home/End, you can alter the "Intercept" parameter of % the mission and see the projected minefield updating on-the-fly. I % have now updated it to work with the standard mine laying missions, % too. If you have 'Lay Mines' or 'Lay Web Mines', this will iterate % through the 'mdX' fcodes. Sub incrI (d) If Mission$>=20 And Mission.Intercept + d >= 0 % simple case SetMission Mission$, Mission.Intercept + d, Mission.Tow EndIf If Mission$=3 Or (Mission$=9 And Mission="Lay Web Mines") Then % figure out how many mines we are laying Local now := Torp.Count Local half := Torp.Count\2, quarter := Torp.Count\4 Local newfc If StrCase(Left(FCode, 2) = "md") Then If StrCase(FCode = "mdh") Then now := half If StrCase(FCode = "mdq") Then now := quarter If FCode = "md0" Then now := Min(100, Torp.Count) If FCode >= "md1" And FCode <= "md9" Then now := Min(10*Val(Right(FCode,1)), Torp.Count) EndIf % okay, we know what we're laying. Now figure out the closest % mdX fcode. This is not particularily elegant, but it's simple. If D > 0 Then % increment Local neworder := Torp.Count For i:=1 To 9 Do If 10*i > now And 10*i < neworder Then newfc := "md" & i; neworder := 10*i If 100 > now And 100 < neworder Then newfc := "md0"; neworder := 100 If half > now And half < neworder Then newfc := "mdh"; neworder := half If quarter > now And quarter < neworder Then newfc := "mdq"; neworder := quarter If neworder = Torp.Count And neworder <> now Then % we had a modifier fcode. To increase the lay amount to % maximum, we can set a random nonspecial fcode. Too bad % there is not a RandomFCode() function (yet). Local paranoia = 0 Do newfc := Chr(Random(65,91))+Chr(Random(49,58))+Chr(Random(65,91)) paranoia := paranoia + 1 Loop While IsSpecialFCode(newfc) And paranoia < 10 EndIf Else % decrement Local neworder := 0 For i:=1 To 9 Do If 10*i < now And 10*i > neworder Then newfc := "md" & i; neworder := 10*i If 100 < now Then newfc := "md0"; neworder := 100 If half < now And half > neworder Then newfc := "mdh"; neworder := half If quarter < now And quarter > neworder Then newfc := "mdq"; neworder := quarter EndIf SetFCode newfc EndIf EndSub Bind ShipScreen 'home':='incrI +1', 'end':='incrI -1' % Ctrl-B searches the "brothers" of this ship (same hull type) Bind ShipScreen 'ctrl-b' := 'UI.Search "Owner$=" & Owner$ & " And Hull$=" & Hull$, "s2"' % As suggested by the PCC docs TryLoad "gameinit.q" % This makes all file selection dialogs start at the game directory UI.Directory := System.GameDirectory % This one is useful when developing PCC: [F12] kills PCC without further % questions. This is undocumented, dangerous and ugly, don't use it. Yes, % I have already ruined a few turns with it. "Normal users" should use % Alt-ESC on the race screen to exit without saving. Bind Global 'f12' := 'CC$Crash "Emergency Exit"' % The NewTurn hook is provided by revive.q (and, since 1.1.13, by the % PCC core). On NewTurn Do ResetWP On NewTurn Do Meins