Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Wivex

#151
Help / Re: Troubles with Job_Drivers
July 22, 2015, 02:15:55 PM
I sure have and they are working properly, just non important here.
#152
Help / Troubles with Job_Drivers
July 22, 2015, 07:17:00 AM
So, I'm making mod for auto using tools from RTFTJ for the corresponding jobs (auto picking them up, using and getting hauled to storage by pawns automatically). And stuck with writing my own Job_driver to do that.
To ease the coding i decided to call for vanilla jobs in my Job_Driver instead or writing my own toils from scratch. The scheme (not full code) for wood cutting with axes:

namespace ToolsForJobs
{
    public class JobDriver_PlantCut_WithTool : JobDriver
    {
        public JobDriver_PlantCut_WithTool() : base() { }

        protected override IEnumerable<Toil> MakeNewToils()
        {
            //Pick up Tool
            {
                Toil toilPickupTool = new Toil();
                toilPickupTool.initAction = () =>
                {
                    ...
                    pawn.jobs.jobQueue.EnqueueLast(new Job(JobDefOf.Equip, closestAvailableTool))
                }
                yield return toilPickupTool;
            }

            //Cut Tree
            {
                Toil toilCutTree = new Toil();
                toilCutTree.initAction = () =>
                {
                    ...
                    pawn.jobs.jobQueue.EnqueueLast(new Job(JobDefOf.CutPlant, closestAvailableTree))
                }
                yield return toilCutTree;
            }

            //Return Tool
            {
                Toil toilReturnTool = new Toil();
                toilReturnTool.initAction = () =>
                {
                    ...
                    pawn.jobs.jobQueue.EnqueueLast(HaulAIUtility.HaulToStorageJob(pawn, pawn.equipment.Primary as Thing))
                }
                yield return toilCutTree;
            }
      }
}


The problem here is that all toils initialize at the same time and checking acting pawn hands (to pick up an axe if pawn doesn't have it equipped and then check hands again to drop it) doesn't work because i can't trace pawn's status and equpment change while toils are executed. Meaning i will get the same pawn.equipment.Primary status in toilPickupTool and toilReturnTool even if it's really changed while Job_driver executes. How can i do that?
#153
I can't figure out how to recharge cleaning/hauling bots in alpha 11 version. Bots just keep dying from non resting even if i have recharge stations and power. MAI droids recharge normally.