[Request] ThingDef/PawnKindDef and inheritance

Started by bleedo, April 28, 2014, 07:09:15 PM

Previous topic - Next topic

bleedo

It doesn't make the Pawn_HealthTracker any less final.
Meaning I still can't override _max_ health for pawns of the same race.
I want to do it, the request is to be able to, not have a gazillion non-compliant workarounds.  :-X

pawnstorm

#16
Fair enough. You can make them take more damage based on their age though, which seems like a decent alternative.

Edit: You can actually create a class that extends Pawn_HealthTracker, slap a CompBreeder on all animals, and replace the default healthtracker with your own custom healthtracker that can have any maxhealth you want.

Edit2: Replace parent.healthTracker with your own healthtracker class in CompBreeder.SpawnSetup() I mean

bleedo

Quote from: pawnstorm on April 29, 2014, 08:17:57 AM
Fair enough. You can make them take more damage based on their age though, which seems like a decent alternative.

That's a good idea as far as the babys go.

There was a request to include the alpha muffalo in the mod, and I like the tought of it.
Would be possible to make alpha whatevers, but I need them to be of the same race to be able to treat them as such. Using naming convensions like SquirrelBaby, Squirrel, SquirrelAlpha doesn't ring right, and it would prevent other mods from working seamlessly with it.
IE. someone could add another animal race with n pawnkinds and they'd breed as long as my mod is installed.
Would still probably need convension based baby pawnkinddefs, but having some kind of extensibility for the thingdefs would make that a helluvalot easier too.
IE. thingDef muffalo has field childPawnKind = MuffaloInfant.

AFAIK, it isn't possible to add custom fields to defs?

pawnstorm


bleedo

I'll emphasize... :)

Pawn_HealthTracker has no virtual methods. It's completely final. Extending it won't change the behavior. The "new" methods won't be called.
It doesn't have an interface either, and it's tightly coupled to 20+ methods around the core.

This means that swapping it out with a custom class would probably not compile at all, or as mentioned above, just not be called.

pawnstorm

Hmm, you have a point there... how about swapping the ThingDef on the fly using a ThingComp?

bleedo


pawnstorm

Well, how much the same do you need the ThingDefs to be? You could just create a new ThingDef dynamically which is exactly the same except for the maxhealth... if that doesn't solve it, I'm out of ideas :P

bleedo

Thanks for the effort.

Having the same thingdef would make it possible to treat them as the same race. They can be treated as a herd (JobGiver_WanderHerd, Core), can be identified as possible mating partners (JobGiver_Breeding, MuffaloBreeding), etc.
Having different thingdefs makes them as different as a squirrel from an alpha muffalo. See?

Tynan

Unfortunately I can't think of a really clean way for a modder to do baby animals that grow up.

I'm thinking that I should put maxHealth and a few other things in the PawnKindDef and move them out of ThingDef. PawnKindDef can be changed during a pawn's lifetime (this is how they go from e.g. Pirate Sniper -> Colonist).

For now, I'd consider just making a separate baby ThingDef that follows its parents. Then, at a certain time, do a Sims-style "growing up" moment where they are replaced by the adult. To do it really well you'll want this to not occur while they're being shot at or something.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

Darth Fool

It seems to me getting shot at might cause somepawn to grow up pretty quickly.

bleedo

Thanks for picking up on this, Ty. :)
The current version of my mod actually changes both def and kinddef on the pawn when it grows up. I just had to reset the renderer for the texture to change.

Whatever you can do to make it more flexible with regards to race and individuals will open up several interesting modding opportunities. Looking forward to seeing the next iteration.