New Looting Function in Ship.iss (Pre Beta)

Digi

Member
When Complete and Working, You pass it a Wrecks Entity ID and it loots it!

Code:
  function LootWreck(int64 EntityID)
  {
   variable int64 EntityID
   variable index:item ContainerCargo
   variable entity entityToLoot = ${Entity[${EntityID}]}
   variable int i = 1
   variable int temp = 0
   variable index:item cargo
   variable iterator cargoIterator
   
   ; Make sure that there is actually a cargo container there that matches the name we set
  if !${entityToLoot(exists)}
   {
      return
   }
   
  if ${entityToLoot(exists)}
   {
      echo Looting ${entityToLoot.Name} 
   }
    
   ; If it exists, get close enough to it!
   if (${entityToLoot.Distance} > 2500)
   {
     Entity[${entityToLoot}]:Approach
      do
      {
        wait 20
      }
      while ${entityToLoot.Distance} > 2450
   }
 
   ; Always open the cargo container window
 
   Entity[${entityToLoot}:GetCargo[cargo]
   do
      {
        wait 20
      }
   cargo:GetIterator[cargoIterator]

   if ${cargoIterator:First(exists)}
    {
      do
        {
          cargoIterator.Value:MoveToMyship
        }
    while ${cargoIterator:Next(exists)}
    }
 
   ; After everything is looted...let's clean up our Cargo
   Me.Ship:StackAllCargo
   
   ; Now close the cargo window (if it's still open)
   Entity[${entityToLoot}]:CloseCargo
   wait 5
   
   echo Looting Complete

  }
TODO:

Make it Salvage the wreck if you have a salvager
pass 2 more variables into it

A set of Strings and a set of ints,
It Loots anything with one of the strings in its name
doesnt loot anything with the typeID of the ints

if i dont pass anything it loots everything.

Credits: Amadeus for the starting Snippet, and Stealthy for help and the parts that use iterators.
 

Antecx

Member
Is it your goal to to loot Special wrecks or all wrecks ?
Going off what Digi said here:
It Loots anything with one of the strings in its name
doesnt loot anything with the typeID of the ints

if i dont pass anything it loots everything.
.
I would imagine that you input what containers you want to loot.. for instance
" Dread Guristas Large Wreck ", you could put all faction/officer wreck names in it that you want looted, but if you choose to NOT put in any specific names, it would loot EVERY wreck.

Again, I'm only assuming that's what Digi means, I'm not speaking for him.
 
Top Bottom