Discussion in 'Scripts' started by Amadeus, Jul 10, 2007.

Thread Status:
Not open for further replies.
  1. Amadeus

    Amadeus The Maestro Staff Member

    Messages:
    8,264
    This snippet loots everything from a container entity called "Cargo Container". You could easily modify this for looting wrecks as well as specifying particular types of things you wanted to loot (rather than looting everything.)

    Code (Text):

    function main()
    {
       variable string ContainerName = "Cargo Container"
       variable index:item ContainerCargo
       variable int i = 1
     
       ; Make sure that there is actually a cargo container there that matches the name we set
       if (!${Entity[Name =- "${ContainerName}"](exists)})
       {
          echo No Entities in the area that match the name you provided.
          return
       }
     
       ; If it exists, get close enough to it!
       if (${Entity[Name =- "${ContainerName}"].Distance} > 1300)
       {
          Entity[Name =- "${ContainerName}"]:Approach
          do
          {
            wait 20
          }
          while ${Entity[Name =- "${ContainerName}"].Distance} > 1300
       }
     
       ; Always open the cargo container window
       Entity[Name =- "${ContainerName}"]:OpenCargo
       wait 30
     
       Entity[Name =- "${ContainerName}"]:GetCargo[ContainerCargo]
     
       do
       {
          ContainerCargo.Get[${i}]:MoveTo[MyShip]
          wait 15
       }
       while ${i:Inc} <= ${ContainerCargo.Used}
     
       ; After everything is looted...let's clean up our Cargo
       Me.Ship:StackAllCargo
       
       ; Now close the cargo window (if it's still open)
       Entity[${ContainerName}]:CloseCargo
       wait 5
       
       echo Script Ended
    }
  2. Amadeus

    Amadeus The Maestro Staff Member

    Messages:
    8,264
    This particular snippet moves everything from your ship's cargo (that is of CategoryID 25: asteroid) to a cargo container. Basically, it jettisons the first cargo item that matches our search, renames the cargo container to "Amadeus", and then moves everything else in the ship's cargo to the new container.

    Code (Text):

    function main()
    {
       ; The name we want our container to have
       variable string ContainerName = "Amadeus"
       variable index:item MyCargo
       variable int i = 1
     
       ; Open our ship's cargo hold for the duration of any manipulation of ship cargo
       EVE:Execute[OpenCargoHoldOfActiveShip]
       wait 30

       Me.Ship:GetCargo[MyCargo]
     
       ; Loop through my cargo -- I want to jettison the first thing that is of CategoryID 25 (Asteroid).
       ; Then, I want to add all of the other items that match that CategoryID to the container that was created.
       do
       {
          if (${MyCargo.Get[${i}].CategoryID} == 25)
          {
             if !${Entity[Name =- "${ContainerName}"](exists)}
             {
                MyCargo.Get[${i}]:Jettison
                wait 2
                do
                {
                  wait 15
                }
                while !${Entity[Name =- "Cargo Container"](exists)}
                wait 5
                Entity[Name =- "Cargo Container"]:SetName[${ContainerName}]
                wait 20            
                ; Always open the cargo container window
                Entity[Name =- "${ContainerName}"]:OpenCargo
                wait 30            
             }            
             else
             {
                ;echo Moving ${MyCargo.Get[${i}].Name} to ${Entity[Name =- "${ContainerName}"].ID}
                MyCargo.Get[${i}]:MoveTo[${Entity[Name =- "${ContainerName}"].ID}]
                wait 10
             }  
          }
       }
       while ${i:Inc} <= ${MyCargo.Used}
     
       ; After everything is done ...let's clean up the stacks.
       Entity[Name =- "${ContainerName}"]:StackAllCargo
       
       ; Close the cargo container's cargo window if it's still open
       Entity[Name =- "${ContainerName}"]:CloseCargo
       wait 30    
     
       ; Close our ship's cargo
       EVE:Execute[OpenCargoHoldOfActiveShip]
       wait 30
     

       echo Script Ended
    }
     
  3. Amadeus

    Amadeus The Maestro Staff Member

    Messages:
    8,264
    This snippet is an example of how you could move everything that's in your ship's cargo hold to your hangar. You could modify this easily to restrict it to certain types of items.

    Code (Text):
    function main()
    {
        if !${Me.InStation}
           return
     
        ; Open Ship's cargo hold
        EVE:Execute[OpenCargoHoldOfActiveShip]
        wait 30

        ; Open Hangar
        EVE:Execute[OpenHangarFloor]
        wait 30
     
        variable index:item MyCargo
        variable int i = 1
        Me.Ship:GetCargo[MyCargo]
     
        ; Loop through my cargo -- Move EVERYTHING to my hangar
        do
        {
           ; Here is where you could put in conditionals to only move certain types, categories, etc of items
           ; For example:  if (${MyCargo.Get[${i}].CategoryID} == 25)
     
           MyCargo.Get[${i}]:MoveTo[Hangar]
           wait 12
        }  
        while ${i:Inc} <= ${MyCargo.Used}
     
        ; After everything is done ...let's clean up the stacks.
        Me.Station:StackAllHangarItems
       
        ; Close Ship's cargo hold
        EVE:Execute[OpenCargoHoldOfActiveShip]
        wait 12
     
        echo Script Ended
    }
  4. Amadeus

    Amadeus The Maestro Staff Member

    Messages:
    8,264
    Here is an example of moving all of a particular type of item (in this case CategoryID 25: Asteroid) from the hangar to our ship's cargo hold.

    Code (Text):

    function main()
    {
        if !${Me.InStation}
           return
     
        ; Open cargo hold of ship for the duration of item manipulation
        EVE:Execute[OpenCargoHoldOfActiveShip]
        wait 30

     
        ; Open Hangar
        EVE:Execute[OpenHangarFloor]
        wait 25
     
        variable index:item MyHangarItems
        variable int i = 1
        Me.Station:GetHangarItems[MyHangarItems]
     
        do
        {
           ; We're just going to move items that are of CategoryID 25 (asteroid).  You can adjust this and/or make it as fancy as you like.
           if (${MyHangarItems.Get[${i}].CategoryID} == 25)
           {
              MyHangarItems.Get[${i}]:MoveTo[MyShip]
              wait 12
           }
        }  
        while ${i:Inc} <= ${MyHangarItems.Used}
     
        ; After everything is done ...let's clean up the stacks.
        Me.Ship:StackAllCargo
       
        ; Close cargo hold of ship
        EVE:Execute[OpenCargoHoldOfActiveShip]
        wait 12    
     
        echo Script Ended
    }
     
  5. Amadeus

    Amadeus The Maestro Staff Member

    Messages:
    8,264
    Updated the snippets above today. I have discovered that the best thing to do is leave the ship's cargo hold open for the duration of any scripts that are doing any manipulation or checking of cargo related items or capacity.

    Therefore, these snippets should now work much better. Simply start them with all cargo container/ship windows CLOSED.
  6. Amadeus

    Amadeus The Maestro Staff Member

    Messages:
    8,264
    This snippet illustrates how you can iterate through the cargo within secure cargo containers that are located in your hangar.

    Code (Text):

    function main()
    {
        if !${Me.InStation}
           return
     
        ; Open Hangar
        EVE:Execute[OpenHangarFloor]
        wait 25
     
        variable index:item MyHangarItems
        variable index:item ContainerItems
        variable int i = 1
        variable int j = 1
        Me:GetHangarItems[MyHangarItems]
     
        do
        {
           ; We only want to iterate and list items that are in cargo containers for now (groupID: 340)
           if (${MyHangarItems.Get[${i}].GroupID} == 340)
           {
              MyHangarItems.Get[${i}]:Open
              wait 15
     
              ContainerItems:Clear
              j:Set[1]
              ${MyHangarItems.Get[${i}]:GetCargo[ContainerItems]
              echo Container Found: ${MyHangarItems.Get[${i}].GivenName} (Item Count: ${ContainerItems.Used})
              echo Container Found: (Item Capacity: ${MyHangarItems.Get[${i}].Capacity})
              echo Container Found: (Item CargoCapacity: ${MyHangarItems.Get[${i}].CargoCapacity})
              echo Container Found: (Item UsedCargoCapacity: ${MyHangarItems.Get[${i}].UsedCargoCapacity})
     
              if ${ContainerItems.Used} > 0
              {
                do
                {
                  echo ${j}. ${ContainerItems.Get[${j}].Name}
                  ; ...any item datatype members are available here...
                }
                while ${j:Inc} <= ${ContainerItems.Used}
              }
     
              MyHangarItems.Get[${i}]:Close
          }
        }  
        while ${i:Inc} <= ${MyHangarItems.Used}
     
     
        echo Script Ended
    }
     
  7. Amadeus

    Amadeus The Maestro Staff Member

    Messages:
    8,264
    This snippet shows how one would get information about missions given by agents:

    Code (Text):

    function main()
    {
        variable index:agentmission MyAgentMissions
        variable index:bookmark MissionBookmarks
        variable int i = 1
        variable int j = 1
        EVE:GetAgentMissions[MyAgentMissions]
     
        echo "MyAgentMissions Populated, Size: ${MyAgentMissions.Used}"

        do
        {
          echo "Mission ${i}"
          echo "------------"
          echo "- Name: ${MyAgentMissions.Get[${i}].Name}"
          echo "- Type: ${MyAgentMissions.Get[${i}].Type}"
          echo "- State: ${MyAgentMissions.Get[${i}].State}"
          echo "- AgentID: ${MyAgentMissions.Get[${i}].AgentID}"
          echo "- Expires: ${MyAgentMissions.Get[${i}].Expires.DateAndTime} (${MyAgentMissions.Get[${i}].Expires.AsInt64})"
         
         MyAgentMissions.Get[${i}]:GetBookmarks[MissionBookmarks]
         echo "- Bookmarks (Total: ${MissionBookmarks.Used})"  
         if ${MissionBookmarks.Used} > 0
         {
              do
              {
                echo "-- Bookmark ${j}"
                echo "--- AgentID: ${MissionBookmarks.Get[${j}].AgentID}"  
                echo "--- TypeID: ${MissionBookmarks.Get[${j}].TypeID}"
                echo "--- Type: ${MissionBookmarks.Get[${j}].Type}"
                echo "--- SolarSystemID: ${MissionBookmarks.Get[${j}].SolarSystemID}"
                echo "--- Label: ${MissionBookmarks.Get[${j}].Label}"
                echo "--- LocationID: ${MissionBookmarks.Get[${j}].LocationID}"
                echo "--- LocationType: ${MissionBookmarks.Get[${j}].LocationType}"
                echo "--- LocationNumber: ${MissionBookmarks.Get[${j}].LocationNumber}"
                echo "--- X: ${MissionBookmarks.Get[${j}].X}"
                echo "--- Y: ${MissionBookmarks.Get[${j}].Y}"
                echo "--- Z: ${MissionBookmarks.Get[${j}].Z}"
              }
              while ${j:Inc} <= ${MissionBookmarks.Used}
          }
          j:Set[1]
          MissionBookmarks:Clear
        }  
        while ${i:Inc} <= ${MyAgentMissions.Used}
       
        echo END
    }
     
  8. Amadeus

    Amadeus The Maestro Staff Member

    Messages:
    8,264
    This snippet shows a simple example of how you would interact with a particular agent:

    Code (Text):

    variable(script) int Avenid_Voohah_ID

    function main()
    {
        variable index:dialogstring DialogStrings
        variable int i = 1

        ; I'm interested in getting a mission from "Avenid Voohah".  The Agent TLO works best with ID#s instead of names since it can retrieve an agent with an
        ; ID# directly instead of having to search through.  So, let's store her ID# for use as we go along.
        Avenid_Voohah_ID:Set[${Agent[Avenid Voohah].ID}]
        if (${Avenid_Voohah_ID} <= 0)
        {
            echo "There was a problem getting the ID# for the agent you requested.
            return
        }
       
        ; First, let's make sure I'm in the same station with her (and that we're in a station in the first place.)
        if (!${Me.InStation})
        {
            echo "You're not in a station, dumb ass."
            return
        }
        if (!${Me.StationID.Equal[${Agent[id,${Avenid_Voohah_ID}].StationID}]})
        {
            echo "You need to be in the same station with the agent with which you wish to converse.
            return
        }
       
        ; Start conversation (unless you're already talking to him/her)
        if (!${EVEWindow[ByCaption,Agent Conversation - ${Agent[id,${Avenid_Voohah_ID}].Name}](exists)})
        {
            Agent[id,${Avenid_Voohah_ID}]:StartConversation
            ; Wait until the window appears
            do
            {
                echo "waiting for conversation window..."
                wait 5
            }
            while !${EVEWindow[ByCaption,Agent Conversation - ${Agent[id,${Avenid_Voohah_ID}].Name}](exists)}        
        }

        ; display what she said:
        echo "${Agent[id,${Avenid_Voohah_ID}].Name} :: ${Agent[id,${Avenid_Voohah_ID}].Dialog}"
       
        ; display your dialog options
        Agent[id,${Avenid_Voohah_ID}]:GetDialogResponses[DialogStrings]
        echo "- ${DialogStrings.Used} responses available:"
        do
        {
            echo "-- ${i}. ${DialogStrings.Get[${i}].Text}"
        }
        while ${i:Inc} <= ${DialogStrings.Used}
       
        ; Now, I want to say "Can you give me some work"
        i:Set[1]
        do
        {
            if (${DialogStrings.Get[${i}].Text.Find[Can you give me some work]} > 0)
            {
                DialogStrings.Get[${i}]:Say[${Avenid_Voohah_ID}]
                break
            }
        }
        while ${i:Inc} <= ${DialogStrings.Used}    
       
        ; Now wait a couple of seconds and then get the new dialog options...and so forth.  The "Wait" needed may differ from person to person.
        echo "waiting for agent dialog to update..."
        wait 20
        echo "${Agent[id,${Avenid_Voohah_ID}].Name} :: ${Agent[id,${Avenid_Voohah_ID}].Dialog}"
        DialogStrings:Clear
        Agent[id,${Avenid_Voohah_ID}]:GetDialogResponses[DialogStrings]
        echo "- ${DialogStrings.Used} responses available:"
        i:Set[1]
        do
        {
            echo "-- ${i}. ${DialogStrings.Get[${i}].Text}"
        }
        while ${i:Inc} <= ${DialogStrings.Used}

        ; ETC...ETC....
       
        ; After you're all done, close the window with EVEWindow[ByCaption,Agent Conversation - ${Agent[id,${Avenid_Voohah_ID}]:Close
    }
     
  9. Amadeus

    Amadeus The Maestro Staff Member

    Messages:
    8,264
    Here is a sample function for illustrating how to acquire information about current 'attackers' and 'jammers'. These features were added on July 3, 2009.

    Code (Text):

    function Test4()
    {
        variable index:attack Attacks
        variable index:attacker Attackers
        variable index:jammer Jammers  
        variable int Counter
        variable int Counter2
        variable iterator _attack_
        variable iterator _attacker_
        variable iterator _jammer_

        echo "--------------------------------------------------------------------"
        echo "Testing Jammers...."
        Me:GetJammers[Jammers]
        echo "Jammers index initialized ... ${Jammers.Used} Jammers found."
        Jammers:GetIterator[_jammer_]
        Counter:Set[1]
       
        if ${_jammer_:First(exists)}
        {
            do
            {
                echo "Jammer ${Counter}: ${_jammer_.Value.Type}"
                echo "  -- Origin: ${_jammer_.Value.Origin} (entity type)"
                echo "  -- StartTime: ${_jammer_.Value.StartTime}"
                echo "  -- CycleTimeRemaining: ${_jammer_.Value.CycleTimeRemaining}"
               
                Counter:Inc    
            }
            while ${_jammer_:Next(exists)}
        }
       
       
        echo "----"
        echo "Testing Attackers...."
        Me:GetAttackers[Attackers]
        echo "Attackers index initialized ... ${Attackers.Used} Attackers found."
        Attackers:GetIterator[_attacker_]
        Counter:Set[1]
       
        if ${_attacker_:First(exists)}
        {
            do
            {
                echo "Attacker ${Counter}: ${_attacker_.Value.ToEntity} (entity type)"
                echo "  -- IsCurrentlyAttacking: ${_attacker_.Value.IsCurrentlyAttacking}"
               
                _attacker_.Value:GetAttacks[Attacks]
                echo "  -- Attacks: ${Attacks.Used}"
                Attacks:GetIterator[_attack_]
                Counter2:Set[1]
                if ${_attack_:First(exists)}
                {
                    do
                    {
                        echo "  --- Attack ${Counter2}: '${_attack_.Value.Name}'"
                        echo "  ----- TimeStarted: ${_attack_.Value.TimeStarted}"
                        if (${_attack_.Value.ToJammer(exists)})
                        {
                            echo "  ----- ToJammer: ${_attack_.Value.ToJammer.Type}"
                            echo "  -------- Origin: ${_attack_.Value.ToJammer.Origin} (entity type)"
                            echo "  -------- StartTime: ${_attack_.Value.ToJammer.StartTime}"
                            echo "  -------- CycleTimeRemaining: ${_attack_.Value.ToJammer.CycleTimeRemaining}"
                        }
                        else
                            echo "  ----- ToJammer: Not a Jammer or Not Active"
                                           
                        Counter2:Inc   
                    }
                    while ${_attack_:Next(exists)}
                }
                Counter:Inc    
            }
            while ${_attacker_:Next(exists)}
        }  
       
       
        echo "--------------------------------------------------------------------"
    }
     

    And, here is a sample output. In this instance, Amadeus was attacking me with missles, warp scrambler, and target jammer (which was active on me at this time.)

    Code (Text):

    --------------------------------------------------------------------
    Testing Jammers....
    Jammers index initialized ... 1 Jammers found.
    Jammer 1: electronic
      -- Origin: Amadeus (entity type)
      -- StartTime: 2009.07.04 03:53
      -- CycleTimeRemaining: 17.932199
    ----
    Testing Attackers....
    Attackers index initialized ... 1 Attackers found.
    Attacker 1: Amadeus (entity type)
      -- IsCurrentlyAttacking: TRUE
      -- Attacks: 4
      --- Attack 1: 'effects.WarpScramble'
      ----- TimeStarted: 2009.07.04 03:47
      ----- ToJammer: Not a Jammer or Not Active
      --- Attack 2: ''
      ----- TimeStarted: 2009.07.04 03:52
      ----- ToJammer: electronic
      -------- Origin: Amadeus (entity type)
      -------- StartTime: 2009.07.04 03:53
      -------- CycleTimeRemaining: 17.932199
      --- Attack 3: 'effects.MissileDeployment'
      ----- TimeStarted: 2009.07.04 03:53
      ----- ToJammer: Not a Jammer or Not Active
      --- Attack 4: 'effects.MissileDeployment'
      ----- TimeStarted: 2009.07.04 03:53
      ----- ToJammer: Not a Jammer or Not Active
    --------------------------------------------------------------------
     
  10. Amadeus

    Amadeus The Maestro Staff Member

    Messages:
    8,264
    I went through and updated all snippets to be compatible with ISXEVE that was released on January 29, 2012. I did not test everything; however, in theory, they should all work now (or be very close.)
Thread Status:
Not open for further replies.

Share This Page