Checking what the pawn is doing

Started by naryl, August 13, 2021, 07:25:04 AM

Previous topic - Next topic

naryl

Is there an easy way to check what a pawn is doing at the current tick? I only found pawn.pather.Moving to check if the pawn is walking. I also need to know when a pawn is constructing, crafting, cooking, taming, etc. It would help if somebody can at least point me to the sources of a mod that does it.

RawCode

then you should search a bit longer.
probably you may want to open savegame with text editor and check how such data is saved, pawns keep their task after save-load you know?

naryl

#2
thing.Pawn/jobs/curJob is the closest there is but it seems to contain the job the pawn currently intends to do. I had one pawn smoothing a wall and another one walking to smooth another wall and they had the same data (other than target IDs etc). When I saved the game the second pawn was walking, not smoothing.

Did nobody really ever do that in a single mod?

RawCode

and job pawn intents to do have no state at all, no progress, no location, no target, just "Job" without any data, right?

naryl

>> they had the same data

> just "Job" without any data, right?

...

Well, same except loadID, targetA, startTick, and lastJobGiverKey. But it's not obvious how any of these can help.

mikeejimbo

Jobs are pretty complicated, and to tell what a pawn is doing at any given time I think it'd help to have a general understanding of the system itself. It's an important topic because - as you are likely aware - almost everything a pawn does is a job.

I'd start here: https://github.com/Mehni/ExampleJob/wiki. I'm sure there are mods that do something similar to what you're trying to do, but I don't know of any offhand. What are you trying to do anyway?




naryl

pawn.jobs.curDriver.curToil looks appropriate but Toils are plain objects with delegates. There's no way to tell them apart. I can use toil.activeSkill to at least tell which skill is used. Hopefully that would be good enough.

naryl

Quote from: mikeejimbo on August 14, 2021, 12:54:02 PM
What are you trying to do anyway?

I want to make a trait which makes pawns *sometimes* have accidents while working. Of course making them hurt themselves all the time would be tedious so it would be avoidable.

Thanks for the link too! I think I saw it somewhere on rimworldwiki earlier but couldn't find it yesterday. >_>

mikeejimbo

Ahh neat - maybe you should look into Run and Gun. That mod adds a check for a nearby target whenever the pawn's job is moving, so it kind of interrupts and modifies a job. I know that's not quite where you need but it might be a decent place to start.