Discussion in 'Script Releases' started by GliderPro, Feb 18, 2008.

  1. GliderPro

    GliderPro Active Member

    Messages:
    184
    Here is a little script to make generating safe spots easier. It will:

    1. Warp to the farthest moon @ 100km.
    2. Snap a bookmark 30 seconds after initiating warp. The 30 seconds does include align time!
    3. Warp back to the bookmark it just created.
    4. Repeat 1-3 ten times.

    If you have a fast warping ship you may want to reduce the 30 second delay.

    Be sure that your system is safe before using this script!

    Code (Text):

    #define CATEGORYID_CELESTIAL    2
    #define GROUPID_MOON            8

    #define CATEGORYID_STRUCTURE    23
    #define GROUPID_CONTROL_TOWER   365

    variable string LogFile

    function atexit()
    {
        call LogEcho "EVE Safespot Maker Script -- Ended"
        return
    }

    function LogEcho(string aString)
    {
        echo "${aString}"
        redirect -append "${LogFile}" echo "${aString}"
    }

    function WarpWait()
    {
        variable bool Warped = FALSE
       
        variable int Count
        for (Count:Set[0] ; ${Count}<10 ; Count:Inc)
        {
            if ${Me.ToEntity.Mode} == 3
            {
                call LogEcho "Warping..."
                break
            }
            wait 20
        }
       
        while ${Me.ToEntity.Mode} == 3
        {
            Warped:Set[TRUE]
            wait 20
        }
        call LogEcho "Dropped out of warp"
        wait 20
        return ${Warped}
    }  

    function WarpToFarthestMoonAndMakeBookmark(string bm_name)
    {
        if ${EVE.Bookmark[${bm_name}](exists)}
        {
            call LogEcho "Bookmark ${bm_name} already exists!"
            return
        }

        variable index:entity moonIndex
        variable iterator moonIterator
       
        EVE:DoGetEntities[moonIndex,CategoryID,CATEGORYID_CELESTIAL,GroupID,GROUPID_MOON]
        moonIndex:GetIterator[moonIterator]
       
        if !${moonIterator:Last(exists)}
        {
            call LogEcho "moonIterator:Last not found!"
            return
        }
       
        moonIterator.Value:WarpTo[100000]
       
        variable int Count
        for (Count:Set[0] ; ${Count}<10 ; Count:Inc)
        {
            if ${Me.ToEntity.Mode} == 3
            {
                break
            }
            wait 20
        }
       
        for (Count:Set[0] ; ${Me.ToEntity.Mode} == 3 ; Count:Inc)
        {
            if ${Count} == 30
            {
                EVE:CreateBookmark["${bm_name}"]
                call LogEcho "${bm_name} created."
            }
            wait 10
        }    
    }

    ; 'Args' is an array
    function main(... Args)
    {
        LogFile:Set["${Script.CurrentDirectory}/${Universe[${Me.SolarSystemID}]}-ssmaker.log"]

        call LogEcho "EVE Safespot Maker Script"
        call LogEcho "EVE Safespot Maker will log to ${LogFile}"
       
        variable int BookmarkCount
        variable string bm_name
        for (BookmarkCount:Set[1] ; ${BookmarkCount}<10 ; BookmarkCount:Inc)    
        {
            bm_name:Set["SS ${Universe[${Me.SolarSystemID}]} #${BookmarkCount}"]
            call LogEcho "Making ${bm_name}"
            call WarpToFarthestMoonAndMakeBookmark "${bm_name}"
            if ${EVE.Bookmark[${bm_name}](exists)}
            {
                EVE.Bookmark[${bm_name}]:WarpTo
                call WarpWait
            }
            else
            {
                call LogEcho "${bm_name} not found!"
                break
            }
        }
    }
     
  2. tsumari

    tsumari Active Member

    Messages:
    22
    another version

    Heya, I made a modded copy of this. It warps to the third closest planet, keeping track of which planets it has been to, and excluding them from the list of valid warp-to objects until you've visited every planet in the system.

    It does safespots in multiple systems - you have to bookmark an object inside of the systems, and call it as run scriptname bookmark1 bookmark2 bookmark3. If you start it in a station it will return you to that station when it is done. Pulled some code from Ama's salvager. It's useful for everything.


    Code (Text):
    #define CATEGORYID_CELESTIAL    2
    #define GROUPID_MOON            8
    #define GROUPID_PLANET          7

    #define CATEGORYID_STRUCTURE    23
    #define GROUPID_CONTROL_TOWER   365

    ;; Declare all script or global variables here
    variable(script) int NumSafeSpotLocations
    variable(script) index:bookmark MyBookmarks
    variable(script) int MyBookmarksCount
    variable(script) bool LeftStation
    variable(script) bool SafeSpotHomeBaseFound
    variable(script) int Counter
    variable(script) bool SafeSpotSystemFound
    variable(script) bool DoLoot
    variable(script) index:string SafeSpotLocationLabels
    variable(script) collection:int ProcessedEntities


    variable string LogFile

    function atexit()
    {
        call LogEcho "EVE Safespot Maker Script -- Ended"
        return
    }

    function LogEcho(string aString)
    {
        echo "${aString}"
        redirect -append "${LogFile}" echo "${aString}"
    }

    function WarpWait()
    {
        variable bool Warped = FALSE
       
        variable int Count
        for (Count:Set[0] ; ${Count}<10 ; Count:Inc)
        {
            if ${Me.ToEntity.Mode} == 3
            {
                call LogEcho "Warping..."
                break
            }
            wait 20
        }
       
        while ${Me.ToEntity.Mode} == 3
        {
            Warped:Set[TRUE]
            wait 20
        }
        call LogEcho "Dropped out of warp"
        wait 20
        return ${Warped}
    }  

    function WarpToFarthestMoonAndMakeBookmark(string bm_name)
    {
        if ${EVE.Bookmark[${bm_name}](exists)}
        {
            call LogEcho "Bookmark ${bm_name} already exists!"
            return
        }

        variable index:entity moonIndex
        variable iterator moonIterator
       
        EVE:DoGetEntities[moonIndex,CategoryID,CATEGORYID_CELESTIAL,GroupID,GROUPID_MOON]
        moonIndex:GetIterator[moonIterator]
       
        if !${moonIterator:Last(exists)}
        {
            call LogEcho "moonIterator:Last not found!"
            return
        }
       
        moonIterator.Value:WarpTo[100000]
       
        variable int Count
        for (Count:Set[0] ; ${Count}<10 ; Count:Inc)
        {
            if ${Me.ToEntity.Mode} == 3
            {
                break
            }
            wait 20
        }
       
        for (Count:Set[0] ; ${Me.ToEntity.Mode} == 3 ; Count:Inc)
        {
            if ${Count} == 16
            {
                EVE:CreateBookmark["${bm_name}"]
                call LogEcho "${bm_name} created."
            }
            wait 10
        }    
    }

    function WarpToFarthestPlanetAndMakeBookmark(string bm_name)
    {
        if ${EVE.Bookmark[${bm_name}](exists)}
        {
            call LogEcho "Bookmark ${bm_name} already exists!"
            return
        }

        variable index:entity planetIndex
        variable iterator planetIterator
       
        EVE:DoGetEntities[planetIndex,CategoryID,CATEGORYID_CELESTIAL,GroupID,GROUPID_PLANET]
        planetIndex:GetIterator[planetIterator]
       
        if !${planetIterator:Last(exists)}
        {
            call LogEcho "moonIterator:Last not found!"
            return
        }
       
        planetIterator.Value:WarpTo[100000]
       
        variable int Count
        for (Count:Set[0] ; ${Count}<10 ; Count:Inc)
        {
            if ${Me.ToEntity.Mode} == 3
            {
                break
            }
            wait 20
        }
       
        for (Count:Set[0] ; ${Me.ToEntity.Mode} == 3 ; Count:Inc)
        {
            if ${Count} == 17
            {
                EVE:CreateBookmark["${bm_name}"]
                call LogEcho "${bm_name} created."
            }
            wait 10
        }    
    }

    function WarpToPlanetAndMakeBookmark(string bm_name)
    {
        if ${EVE.Bookmark[${bm_name}](exists)}
        {
            call LogEcho "Bookmark ${bm_name} already exists!"
            return
        }

        variable index:entity planetIndex
        variable iterator planetIterator
       
        EVE:DoGetEntities[planetIndex,CategoryID,CATEGORYID_CELESTIAL,GroupID,GROUPID_PLANET]
        planetIndex:GetIterator[planetIterator]
       
        if !${planetIterator:First(exists)}
        {
            call LogEcho "planetIterator:First not found!"
            return
        }
       
        if ${planetIterator:First(exists)}
        {
        /* Exclude closest planets */
        planetIterator:Next
        planetIterator:Next
            do
            {    
                if (!${ProcessedEntities.Element[${planetIterator.Value.ID}](exists)})
                    {
                    planetIterator.Value:WarpTo[100000]
                    ProcessedEntities:Set[${planetIterator.Value.ID},1]
                    break
                    }
                }
                while ${planetIterator:Next(exists)}
            }
       

       
        variable int Count
        for (Count:Set[0] ; ${Count}<10 ; Count:Inc)
        {
            if ${Me.ToEntity.Mode} == 3
            {
                break
            }
            wait 20
        }
       
        for (Count:Set[0] ; ${Me.ToEntity.Mode} == 3 ; Count:Inc)
        {
            if ${Count} == 28
            {
                EVE:CreateBookmark["${bm_name}"]
                call LogEcho "${bm_name} created."
            }
            wait 5
        }    
    }

    ; 'Args' is an array
    function MakeSafeSpots(... Args)
    {
            variable int i = 1
            /* this is just used one time */
            variable index:entity planetarray
            variable int Planets = ${EVE.GetEntities[planetarray,CategoryID,CATEGORYID_CELESTIAL,GroupID,GROUPID_PLANET]}
        LogFile:Set["${Script.CurrentDirectory}/${Universe[${Me.SolarSystemID}]}-ssmaker.log"]

        call LogEcho "EVE Safespot Maker Script"
        call LogEcho "EVE Safespot Maker will log to ${LogFile}"
       
        variable int BookmarkCount
        variable string bm_name
        for (BookmarkCount:Set[1] ; ${BookmarkCount}<20 ; BookmarkCount:Inc)    
        {
            bm_name:Set["SS ${Universe[${Me.SolarSystemID}]} #${BookmarkCount}"]
            call LogEcho "Making ${bm_name}"
            call WarpToPlanetAndMakeBookmark "${bm_name}"
            if ${EVE.Bookmark[${bm_name}](exists)}
            {
                EVE.Bookmark[${bm_name}]:WarpTo
                call WarpWait
                wait 150
            }
            else
            {
                call LogEcho "${bm_name} not found!"
                break
            }
            echo "recycle check ${i} - number of planets ${Planets}
            if ${i:Inc} > ${Planets}
            {
                ProcessedEntities:Clear
                i:Set[1]
            }
        }
        ProcessedEntities:Clear
    }

    function main(... Args)
    {
        variable int i = 1
      variable int j = 1
      variable int k = 1
      variable int WaitCount = 0
      variable int Iterator = 1
     
      SafeSpotSystemFound:Set[FALSE]
      LeftStation:Set[FALSE]
     
      if !${ISXEVE(exists)}
      {
         echo "- ISXEVE must be loaded to use this script."
         return
      }
      do
      {
         waitframe
      }
      while !${ISXEVE.IsReady}
     
      echo " \n \n \n** EVE Safespot creation script ** \n \n"
     
      ; 'Args' is an array ... arrays are static.  Copying to an index just in case we have a desire at some point to add/remove elements.
        if ${Args.Size} > 0
        {
            do
            {
                if ${EVE.Bookmark[${Args[${Iterator}]}](exists)}
                    SafeSpotLocationLabels:Insert[${Args[${Iterator}]}]
                else
                    echo "- '${Args[${Iterator}]}' is not a valid Bookmark label or command line argument:  Ignoring..."
            }
            while ${Iterator:Inc} <= ${Args.Size}
        }

      if (${SafeSpotLocationLabels.Used} <= 0)
      {
        echo "- Syntax:  'run makesafespots <bookmarklabel1> <bookmarklabel2> ...'"
        return
      }  
     
     
        MyBookmarksCount:Set[${EVE.GetBookmarks[MyBookmarks]}]
        if ${MyBookmarksCount} == 0
        {
            echo "- Sorry, you do not appear to have any bookmarks!"
            return
        }  
     

      ;;; Main Loop ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      NumSafeSpotLocations:Set[${SafeSpotLocationLabels.Used}]
      do
      {
        j:Set[1]
        do
        {
                if (${MyBookmarks.Get[${j}].Label.Find[${SafeSpotLocationLabels[${i}]}]} > 0)
                {  
                  SafeSpotSystemFound:Set[TRUE]
                    echo "- Safespot location found in bookmarks: (${SafeSpotLocationLabels[${i}]})..."
               
                ;;; Leave station
                if !${LeftStation}
                {
                    if ${Me.InStation}
                    {
                           ;; First, make sure we have a bookmark labeled "SafeSpot Home Base" -- otherwise, create it ;;;;;;;;;;;;;
                           SafeSpotBaseFound:Set[FALSE]
                           do
                           {
                                if (${MyBookmarks.Get[${k}].Label.Find["SafeSpot Home Base"]} > 0)
                                {
                                    SafeSpotHomeBaseFound:Set[TRUE]
                                }
                           }
                           while ${k:Inc} <= ${MyBookmarksCount}
                       
                           if !${SafeSpotHomeBaseFound}
                           {
                                echo "- Creating 'SafeSpot Home Base' bookmark..."
                                EVE:CreateBookmark["SafeSpot Home Base"]
                                wait 10
                             }
                                       
                       echo "- Undocking from station..."
                       EVE:Execute[CmdExitStation] 
                       wait 150
                       Counter:Set[0]
                       if (${Me.InStation})
                       {
                            do
                            {
                                wait 20
                                Counter:Inc[20]
                                    if (${Counter} > 300)
                                    {
                                      echo "- Undocking atttempt failed ... trying again."
                                        EVE:Execute[CmdExitStation]
                                        Counter:Set[0]
                                    }                          
                            }
                            while (${Me.InStation} || !${EVEWindow[Local](exists)} || !${Me.InStation(exists)})
                       }
                       wait 5
                       LeftStation:Set[TRUE]
                    }
                    else
                       echo "- WARNING: You must be in a station to properly utilize this script."
                    wait 1
                }
               
                ;;; Set destination and then activate autopilot (if we're not in that system to begin with)            
                if (${MyBookmarks[${j}].SolarSystemID} != ${Me.SolarSystemID})
                {
                  echo "- Setting Destination and activating auto pilot for safespot operation ${i} (${MyBookmarks.Get[${j}].Label})."
                  wait 5
                    MyBookmarks[${j}]:SetDestination
                    wait 5
                    EVE:Execute[CmdToggleAutopilot]
                        do
                        {
                           wait 50
                           if !${Me.AutoPilotOn(exists)}
                           {
                             do
                             {
                                wait 5
                             }
                             while !${Me.AutoPilotOn(exists)}
                           }
                        }
                    while ${Me.AutoPilotOn}
                    wait 20
                    do
                    {
                       wait 10
                    }
                    while !${Me.ToEntity.IsCloaked}
                    wait 5
                }
               
                    ;*******************************
                    call MakeSafeSpots
                    ;********************************
          }
        }
        while ${j:Inc} <= ${MyBookmarksCount}
      }
      while ${i:Inc} <= ${NumSafeSpotLocations}
     
     
      ; No SafeSpot locations were found..so just end the script
      if !${SafeSpotSystemFound}
      {
        echo "- Sorry, no bookmarks were found that matched the arguments given."
        return
      }

     
      ;;; Finished...returning home ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      echo "- Safespotting operations completed .. returning to home base" 

      MyBookmarksCount:Set[${EVE.GetBookmarks[MyBookmarks]}]
        j:Set[1]
        do
        {
            if (${MyBookmarks.Get[${j}].Label.Find["SafeSpot Home Base"]} > 0)
            {
                if (${MyBookmarks[${j}].SolarSystemID} != ${Me.SolarSystemID})
                {
                    echo "- Setting destination and activating auto pilot for return to home base"
                    MyBookmarks[${j}]:SetDestination
                    wait 5
                    EVE:Execute[CmdToggleAutopilot]
                    do
                    {
                       wait 50
                       if !${Me.AutoPilotOn(exists)}
                       {
                         do
                         {
                            wait 5
                         }
                         while !${Me.AutoPilotOn(exists)}
                       }
                    }
                    while ${Me.AutoPilotOn}
                    wait 20
                    do
                    {
                       wait 10
                    }
                    while !${Me.ToEntity.IsCloaked}
                }
               
                ;;; Warp to location
                echo "- Warping to home base location"
                MyBookmarks[${j}]:WarpTo
                wait 120
                do
                {
                    wait 20
                }
                while (${Me.ToEntity.Mode} == 3)   
                wait 20
               
                ;;; Dock, if applicable
                if ${MyBookmarks[${j}].ToEntity(exists)}
                {
                    if (${MyBookmarks[${j}].ToEntity.CategoryID} == 3)
                    {
                        MyBookmarks[${j}].ToEntity:Approach
                        do
                        {
                            wait 20
                        }
                        while (${MyBookmarks[${j}].ToEntity.Distance} > 50)
                       
                        MyBookmarks[${j}].ToEntity:Dock
                        Counter:Set[0]         
                        do
                        {
                           wait 20
                           Counter:Inc[20]
                           if (${Counter} > 200)
                           {
                              echo " - Docking atttempt failed ... trying again."
                              ;EVE.Bookmark[${Destination}].ToEntity:Dock  
                              Entity[CategoryID,3]:Dock
                              Counter:Set[0]
                           }
                        }
                        while (!${Me.InStation})                   
                    }
                }
            }
        }
        while ${j:Inc} <= ${MyBookmarksCount}
        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    }
  3. speedy

    speedy Member

    Messages:
    1
    just wondering, is it possible to use this code to make a

    warp to random moon @ 100

    then start making bookmarks for all the stargates
    so 100km then 200km then 300km

    Basically just so i have 300km off gate bookmark

    :)

Share This Page