[1.0] (WIP) Better Hauling (alpha v0.0.2)

Started by Luka Kama, November 25, 2018, 03:55:48 PM

Previous topic - Next topic

Luka Kama

Description:

The Better Hauling mod improve the AI in situations like hauling, crafting, building etc, by allowing colonists to pick more things using their inventory.

Features

  • When hauling to a stockpile, colonists will pick all adjacent things that can be stored in the target stockpile, preferring things of the same type.
  • When working on a bill on a workbench, colonists will pick all the needed items in a single run until their inventory is full, instead of going back and forth picking a single item at a time.
  • When the job is canceled (for whatever reason, like drafting or job error) all the items in the inventory picked for the job are dropped.

Todo

  • Apply better hauling on other jobs (like building).
  • When looking for additional items to pick for hauling to a stockpile, pawns should check if there is an available place where to drop them, discarding ones that cannot be placed anywhere. Also, a reservation should be applied on identified target locations to avoid over-placing by multiple pawns. If not too complex, partial reservation could be used to allow the same target to be selected by multiple pawns for the "to be placed" quantity.

Know issues (will be fixed before stable release)

  • As reported in the TODO list, pawns do not check if there is an available place to drop an item when picking them, so, when placing them, if they cannot find an available place they will simply drop everything on the floor.

Needs

  • Volunteers to test the mod.
  • Feedbacks & suggestions.

Compatibility
The mod changes the default driver of the improved jobs, so it could conflict with mods that patch/change hauling AI.


Author/Mod Team
Myself (Luca De Petrillo)


Download

How to install:

  • Unzip the contents and place them in your RimWorld/Mods folder.
  • Activate the mod in the mod menu in the game.

Sources are available on GitHub.

Luka Kama

Update 0.0.2

Change log:

  • Deleting the target stockpile while the job is running now cancel the job.
  • Manually dropping hauled things from the inventory while the job is running now cancels the job, instead of causing an error when dropping items.

Zip to manually install here

leestriter

How does this compare to pick up and haul? BTW I enjoy real fog of war, excited to see where this mod goes!

Luka Kama

#3
Hi, AFAIK, the main difference is that Better Hauling aim to apply the inventory usage for all the pick-haul-drop tasks, versus Pick Up and Haul that handles the "hauling to a stockpile" and adds a "pick and keep" action.

Actually Better Hauling handles the "haul to stockpile" task (the same already handled by Pick Up and Haul, but using a slightly different approach explained below), and the "bill material retrieval" (also explained below). The next will be the "structure construction job material retrieval".


Regarding the "hauling to a stockpile" task, as far as I understood, Pick Up and Haul (I tried and checked it before starting Better Hauling development some weeks ago, so I could be a little outdated) creates completely new jobs for inventory hauling tasks (both picking and dropping), and it uses the job queues to integrate them with the standard hauling task: the inventory pickup is followed by a scheduled "standard hauling task", followed itself by another scheduled inventory dropping task; so it can happens that when the task is interrupted while the standard haul is running (for example while going to the stockpile), hauled things remain in the inventory, and could remain there indefinitely if the colonist has other higher-priority non-haul tasks to perform (or if you disable the haul task for him).

Better Hauling instead uses a different approach: it modifies the standard hauling task in order to inject the inventory usage, so there is only a single task running for both standard and inventory picking, hauling and dropping actions, and if the task is interrupted all hauled things are automatically dropped (like the standard haul task do), so other colonists can use dropped things for other tasks or for hauling them their-self.

You could like one approach more then the other... personally, I like the Better Hauling one more :) .

Also, Better Hauling takes advantage of the partial item stack reservation of the game: when there is a stack of items, at the start of the hauling task the mod reserves only the quantity that can be hauled by the colonist, so other colonists can start an haul task for the remaining quantity, or use it for other tasks, at the same time. As far as I can tell, Pick Up and Haul (and the standard haul task) reserves the full stack at the start, and un-reserve the remaining quantity only when the pickup is performed. It is a micro-optimization, but I spent some time trying to make it work, so I think that it worth to be mentioned (and I like it :) ).

There are also other micro-differences in the hauling logic, but it would be too hard to identify and explain them all.


Regarding the inventory usage for "bill material retrieval", when a bill of a production structure (cooking station, fabrication bench, drug lab, etc) requires more than one type of material, the mod inject the inventory usage in order to pick, and place, all the required items in a single run.


I hope that my explanation answered your question.

Regards

leestriter

Wow! Sounds awesome! One small thing, fluffy's mod manager says the mod is the incorrect version, I think it is confused by the 0.0.2? Idk.

Hjkma

Hi, I would like to know if this mod causes Pawns to pick up things after cutting / digging? Unfortunately, mod Pick up and hauling does not do this, Pawns cut trees and plants and dig rocks, but do not pick up dropped things, but go on to the next tree / plant / rock.

JT

Quote from: leestriter on November 27, 2018, 04:17:39 PM
Wow! Sounds awesome! One small thing, fluffy's mod manager says the mod is the incorrect version, I think it is confused by the 0.0.2? Idk.

Yep: <targetVersion>0.0.1</targetVersion> should target the RimWorld version, which is currently <targetVersion>1.0.2059</targetVersion> for the latest DRM-free release, which hasn't been updated for a week now, and <targetVersion>1.0.2096</targetVersion> for the latest Steam build.

Luka Kama

Quote from: JT on November 28, 2018, 01:31:07 AM
Yep: <targetVersion>0.0.1</targetVersion> should target the RimWorld version, which is currently <targetVersion>1.0.2059</targetVersion> for the latest DRM-free release, which hasn't been updated for a week now, and <targetVersion>1.0.2096</targetVersion> for the latest Steam build.

Whoops... I will fix it in the next alpha. For now, just ignore it.

Luka Kama

Quote from: Hjkma on November 27, 2018, 04:49:48 PM
Hi, I would like to know if this mod causes Pawns to pick up things after cutting / digging? Unfortunately, mod Pick up and hauling does not do this, Pawns cut trees and plants and dig rocks, but do not pick up dropped things, but go on to the next tree / plant / rock.

Hi. With Better Hauling I plan to enhance only jobs/tasks that already include an hauling action, like standard hauling, crafting and building, where cutting, mining and destroying jobs does not already include it, so it is likely a "no".

AwesomeMcAwesome

Does it currently have any compatibility issues with other mods that tweaks the hauling? Like Haul to Stack, Pick up and Haul, and While You're Up?

jager666

There might be a compatibility problem with Misc+ Robots.

The hauler bots are getting stuck in same place picking and droping stuff w/o moving, until they ran out of battery.

Luka Kama

Quote from: jager666 on December 06, 2018, 01:06:28 PM
There might be a compatibility problem with Misc+ Robots.

The hauler bots are getting stuck in same place picking and droping stuff w/o moving, until they ran out of battery.
Thanks for the report. I will look into it.

openyourmind

Really like this a lot more than pick up and haul.

Only found a couple of issues, both of them posted on github.

Thank you for making this, hope you will fix them since this is a great mod which does seem better even to end user.

jager666

Hi! Are You planning to update the mod to include the MiscRobots patch?