Pet generators and wearing pets as armor

Today I could work on Tamakai or on the Philosopher project. Feeling pretty tired, hoping the tea will kick in soon... but I might do a bit of work on both. I want to add the pet generation to account creation on Tamakai and hopefully get the pet to armor transformation done. Possibly the inverse as well. I guess I will get started with Tamakai.

First thing I need to do is figure out what parts of the pet model need to be randomized and figure out how they will be randomized. Then clamp them within a range of acceptable parameters. Also need to create a registration form.

They may be ugly as sin, but they exist. That's what matters.

Well, it's nearly 3pm now and I have added in the random pet generation function. It took a bit of doing, one bug in particular came from me expecting the DB to start it's index for IDs at 0. It starts at 1. After about half an hour I realized that one and got it fixed.

I also made the mistake of passing a random number index to a queryset as an ID instead of finding the ID of the entry in the queryset with the index. Fixed that after some looking like an idiot as well.

def random(part, specie):
    usable_entries = part.objects.filter(species=specie)
    count = len(usable_entries)
    random_index = randint(1, count)
    return usable_entries.all()[random_index-1]

In the end it all came down to something this simple. I mean, the models do a lot of the heavy lifting for me but really all I had to do was find each part of the body based on the specie of the pet and choose a random one.

Mating will work differently since there will be weights added to the selection, reducing the randomness somewhat. (What I might do is just have multiple entries for the more likely traits to increase odds and only select the traits pool based on parents, then apply a certain level of random rolls to see if we'll get any mutations and what they will be.)

Anyway, that's Tamakai's goal for the day done. On to the Philosopher project.

Feeling a bit tired, only got a couple hours to work on this but I want to work on transforming the Karakasa into armor and back.

First things first, the player needs something to hold equipment.

Conversion works, just need to remove the pet from the camp when it's equipped and have it spawn back in when unequipped.

I have changed the initial idea of destroying the pet on equip then reconstituting it from a prefab to a simpler form of giving the armor controller access to the pet object, disabling the pet in the world and stopping all coroutines. Then on unequip it sets whatever values changed while equipped on to the pet object, sets the transform to the player position, reactivates the object and starts the coroutines again.

While in the future it will be wiser to freeze the state and serialize the pet as JSON like I originally planned, I will do that when I write the code for the pet management on the player. The player will have a script that just keeps track of all their pets whenever you go into the dungeon, serializing them onto the script and deserializing them into game objects again when exiting the dungeon.

But for now I can equip and unequip pets.

Pet go on.
Pet come off.

I guess tomorrow I will work on adding an armor sprite to overlay on the player. I might set it up as just a sprite swap, rather than a paperdoll since it would actually be way simpler. The weapon however will have to be paperdolled.

It's nearly 7:30pm now so I will be clocking out.

Cheers.