Custom pawn - reservation problems

Started by isistoy, June 22, 2015, 11:31:40 PM

Previous topic - Next topic

isistoy

Ok, I believe this one to be a tough one:

Project K9 spawns custom pawns as wild. At that stage, these pawns already have several specific jobs, directly commanded by ThinkTree.
Some of these jobs are in need of putting exclusive reservation on things, to avoid concurrency with colonists.

For instance, before these custom pawns become "Colonists", they would be able to nourish from corpses.
From what I have seen, if they are not in Colony faction, I will get potential conflicts trying to do a reserve on a corpse and I have no guarantee that someone in the colony doesn't try to grab that corpse when I have a job on it.

From what I have also seen briefly, other mods creating pawns (Droids for instance) are setting faction to be of the Colony one. It makes sense in their point of view, but this is probably also made to allow hauling and more generally, works, to respect colony reservations.

In my case, I don't necessarily want my pawns to be in that Colony faction immediately, but maybe after an interaction has been done with the custom pawn itself, later on.


QUESTION:
can I get a reserve flag of a thing, that will be cross-faction or at least Colonist-safe, if I am not in colony faction? Or should I only do Colony faction pawns, like others did and deal with all the other trackers initially?

Will appreciate any contrib/help on this one a lot!
<Stay on the scene like a State machine>

Tynan

Can you rewrite and clarify the question? Honestly sentences like "can I get a reserve flag of a thing, that will be cross-faction or at least Colonist-safe, if I am not in colony faction?" are just incomprehensible to me. Who am "I"? What is "reserve flag"? What is "cross-faction"? What is "colonist-safe"?
Tynan Sylvester - @TynanSylvester - Tynan's Blog

isistoy

Agreed.
Better one (hopefully) would be:

Specific pawns were created with a custom pawn class and in a custom faction, not in colonists.
For a moment, I tried to have them "haul to storage" colonist things and got hauling job exceptions.
These exceptions were pointing me in the direction of a reservation problem and possibly on the storage cell reservation, not on things to be hauled, but I could be mistaken...

I only was able to avoid these errors, when switching my custom pawns to the colonist faction. At that time, I had a deep look at reservations and saw faction segmentation in there.

A supposition, structured like a question: would there be an impossibility to non-colonist faction's pawns, to try and reserve colony stockpile cells?
As a complementary question: are guests benefiting from a special reservation consideration that would make them interact smoothly with colonists reservations in general (maybe ok with things already) and with colony stockpiles, in particular?
<Stay on the scene like a State machine>

Tynan

OK.

Well, reservations only record the pawn that claimed them. Then they check for conflicts by looking at the faction of that pawn. Which means that sadly no, a foreign non-allied pawn can't make a reservation that will be respected by colonists, unless I were to refactor the reservation system. This is by design; there's no reason yet why a colonist should respect a reservation of someone who isn't in the colony.

This is the code that determines whether a pawn respects another pawn's reservations:

private static bool RespectsReservationsOf( Pawn newClaimant, Pawn oldClaimant )
{
//Factionless pawns (animals) respect the reservations of nobody, and nobody respects their reservations
if( newClaimant.Faction == null || oldClaimant.Faction == null )
return false;

//Respect the reservations of anyone in your faction
if( newClaimant.Faction == oldClaimant.Faction )
return true;

//Respect the reservations of your allies
if( !newClaimant.Faction.HostileTo(oldClaimant.Faction) )
return true;

//Respect the reservations of your prisoners
if( oldClaimant.HostFaction != null && oldClaimant.HostFaction == newClaimant.HostFaction)
return true;

if( newClaimant.HostFaction != null )
{
//Respect the reservations of other prisoners
if( oldClaimant.HostFaction != null )
return true;

//Respect the reservations of your jailers
if( newClaimant.HostFaction == oldClaimant.Faction )
return true;
}

return false;
}
Tynan Sylvester - @TynanSylvester - Tynan's Blog

isistoy

ok, thank you for your consideration on this!
<Stay on the scene like a State machine>

isistoy

After giving another look, I was not precise enough again, sorry for that. In my scenario, it should have worked because the foreign faction was having a good relationship with colonists...

I prefer to try again, in a specific test scenario and really point you out on sthg that's worth a debug, if anything

<Stay on the scene like a State machine>