Patch for EveBot - Hauler no longer leaves 1 ore of each

Da_Teach

Active Member
By applying this fix to obj_Hauler.iss from evebot, it will no longer leave 1 ore of each type in a can but rather only leave 1 ore (in total) behind (unless full).

Code:
	function LootEntity(int id, int leave = 0)
	{
		variable index:item ContainerCargo
		variable iterator Cargo
		variable int QuantityToMove
		variable int CargoLeft

		UI:UpdateConsole["DEBUG: obj_OreHauler.LootEntity ${id} ${leave}"]
		
		Entity[${id}]:DoGetCargo[ContainerCargo]
		ContainerCargo:GetIterator[Cargo]
		if ${Cargo:First(exists)}
		{
			CargoLeft:Set[0]
			do
			{
				UI:UpdateConsole["Hauler: Found ${Cargo.Value.Quantity} x ${Cargo.Value.Name} - ${Math.Calc[${Cargo.Value.Quantity} * ${Cargo.Value.Volume}]}m3"]
				if (${Cargo.Value.Quantity} * ${Cargo.Value.Volume}) > ${Ship.CargoFreeSpace}
				{
					/* Move only what will fit, minus 1 to account for CCP rounding errors. */
					QuantityToMove:Set[${Ship.CargoFreeSpace} / ${Cargo.Value.Volume} - 1]
				}
				else
				{
					if ${CargoLeft} > 0
					{
						QuantityToMove:Set[${Cargo.Value.Quantity}]
					}
					else
					{
						QuantityToMove:Set[${Cargo.Value.Quantity} - ${leave}]
					}
				}

				if ${CargoLeft} == 0
				{
					CargoLeft:Set[${Cargo.Value.Quantity} - ${QuantityToMove}]
				}

				UI:UpdateConsole["Hauler: Moving ${QuantityToMove} units: ${Math.Calc[${QuantityToMove} * ${Cargo.Value.Volume}]}m3"]
				if ${QuantityToMove} > 0
				{
					Cargo.Value:MoveTo[MyShip,${QuantityToMove}]
					wait 30
				}
								
				if ${Ship.CargoFreeSpace} < ${Ship.CargoMinimumFreeSpace}
				{
					/* TODO - this needs to keep a queue of bookmarks, named for the can ie, "Can CORP hh:mm", of partially looted cans */
					/* Be sure its names, and not ID.  We shouldn't store anything in a bookmark name that we shouldnt know */
					
					UI:UpdateConsole["DEBUG: obj_Hauler.LootEntity: Ship Cargo: ${Ship.CargoFreeSpace} < ${Ship.CargoMinimumFreeSpace}"]
					break
				}
			} 
			while ${Cargo:Next(exists)}
		}

		Me.Ship:StackAllCargo
		wait 10
	}
For people interested to know how it works. I've added the variable "CargoLeft" which starts at 0. Once the bot has filled the "QuantityToMove" variable it will check if this was all the ore. If it wasnt, then it'll set the "CargoLeft" variable.

When it picks up the next ore, it will do its normal check (enough cargo / etc), if it can fit the entire quantity, it will check if ore was previously left inside the can (if ${CargoLeft} > 0) and if there was it'll move the entire quantity and not quantity - 'leave' (which, normally, is 1).
 
Top Bottom