www.ClassicTW.com
http://www.classictw.com/

SysOp Script: Random Fighter Placement
http://www.classictw.com/viewtopic.php?f=15&t=32210
Page 1 of 1

Author:  Promethius [ Sun Sep 04, 2011 3:03 pm ]
Post subject:  SysOp Script: Random Fighter Placement

A request for random placement of fighters after a bang was made. The script below provides a little more than my original script response. I still do not check for StarDock in this script, but that gives you something to do. I am also assigning the fighters to Ferrengi, but you can change that. Just be aware that Gold Aliens have an additional setting that you will have to account for.

A snippet of the text file output is below the script.

Code:
# random fighters, random fighter action (def, toll, att)
# from admin - select T-edit - Select Game and run

# the list of figged sectors to look at after script run.
delete "figgedSectors.txt"

# Number of sectors to Fig
setVar $maxSectorsToFig 100

# if max is higher than min, then a random number of fighters per sector will be sent
setVar $maxFigsPerSector 15
setVar $minFigsPerSector 1

# if figType is set to 3 it will randomly choose between defend, toll, attack
#  type 0 - defend, 1 - toll, 2 - attack, 3 - random
setVar $figType 3

# just in case
if ($maxFigsPerSector < $minFigsPerSector)
   setVar $temp $maxfigsPerSector
   setVar $maxFigsPerSector $minFigsPerSector
   setVar $minFigsPerSector $temp
end

send "s"
setTextLineTrigger getSectors :getSectors "Sector number (0=Abort)  (0 to"
setDelayTrigger m :m 500

pause
:m
  send "0*"
  pause
:getSectors
getWord currentline $sectors 6
stripText $sectors ","
stripText $sectors ")"
getLength $sectors $maxSectorLen
setVar $i 1
while ($i <= $maxSectorsToFig)
   # grabbing a random sector 11 to max sectors in the game
   getRnd $rnd 11 $sectors
   if ($chk[$rnd] = 0)
      # need the length to deal with auto-complete
      getlength $rnd $len
      if ($len < $maxSectorLen)
         send  "s" & $rnd & "*"
      else
         send "s" & $rnd
      end
      # get a random number of figs for the sector or set it to max
      if ($maxFigsPerSector > $minFigsPerSector)
         getRnd $figsPerSector $minFigsPerSector $maxFigsPerSector
      else
         # min and max was set to the same number so use max
         setVar $figsPerSector $maxFigsPerSector
      end
      # setfig and assign to Ferr as defensive
      send "h" $figsPerSector "*5v"
      # figtype 3 is for random defensive, toll, offensive
      if ($figType = 3)
         getRnd $figAction 0 2
         send $figAction & "*x"
      else
        # figtype was set to to 0, 1 or 2
        send $figType & "*x"
      end
      setVar $chk[$rnd] $rnd
      # edit - adding so you will have a list of sectors with figs added
      write "figgedSectors.txt" $rnd & "  Num Figs: " & $figsPerSector & "  Fig Type:" & $figType & "  Fig Action " & $figAction & "*"
      add $i 1
    end
    # slow it down so you can monitor it - 500ms is 1/2 second
    setDelayTrigger m1 :m1 500
    pause
    :m1
end


Fig type was set to 3 so we get a random fig action (0-def, 1-toll, 2-attack). Min fighter level was set to 1, and max to 15.

13728 Num Figs: 15 Fig Type:3 Fig Action 0
1718 Num Figs: 13 Fig Type:3 Fig Action 2
8006 Num Figs: 7 Fig Type:3 Fig Action 0
3059 Num Figs: 5 Fig Type:3 Fig Action 0
16862 Num Figs: 10 Fig Type:3 Fig Action 0
1071 Num Figs: 14 Fig Type:3 Fig Action 2
3631 Num Figs: 3 Fig Type:3 Fig Action 1
14215 Num Figs: 9 Fig Type:3 Fig Action 1
214 Num Figs: 5 Fig Type:3 Fig Action 0
8280 Num Figs: 5 Fig Type:3 Fig Action 2
10528 Num Figs: 4 Fig Type:3 Fig Action 2
1663 Num Figs: 15 Fig Type:3 Fig Action 2
13483 Num Figs: 1 Fig Type:3 Fig Action 0

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/