Navigation and Command Issues

Navigation thinking for long periods of time before moving, or not at all. With the newest Update changing the way NPCs behave I suppose this is to be expected.
Seems the pets don't want to obey USE commands 100% of the time or think about it a little too long - Likely related to the Navigation issues.
Inventory open issues, seems the system cannot find the prefab or loot panel:

Couldn't find prefab "assets/bundled/prefabs/ui/loopanels/lootpanel.smallwoodbox.prefab"
Missing Loot Panel: assets/bundled/prefabs/ui/loopanels/lootpanel.smallwoodbox.prefab
Definitely looking to use this as it appears to be the cleanest looking plugin for this type of thing. Just a little glitchy in the current state.

Just for everyones information. I have made some revisions to the code. I have everything working 100% with the newest game update.

1) As for the missing Loot Panel look in Pets.cs and change this line:

player.ClientRPCPlayer(null, player, "RPC_OpenLootPanel", "smallwoodbox");​
to
player.ClientRPCPlayer(null, player, "RPC_OpenLootPanel", "generic_resizable");​​

2) As for the slow navigation queue, I am currently trying to this figure out.

3) Eating and Drinking I have fixed as well. If you need the code alterations, just reply on here and I will gladly help!

Thanks Chaotic!
Eating seems to occasionally work on my end, I could use some help getting the eating/drinking code to work correctly. 
Trying the box code now!
And thanks for the work on the movement que! It got better after the FP update weirdly enough, but it's still lacking.

You are very welcome. Here is the fixes I have done to get Eating/Drinking working. I also added the ability for the pet to regenerate Energy slowly when the pet is sleeping. 

All modifications will be inside:

private void Update()
{ 
      [ . . . ]
}​

To fix Drinking - Look for:
                else if (action == Action.Drink)
                {
                    if (entity.Hydration.Level >= 1)
                    {
                        SetBehaviour(BaseNpc.Behaviour.Idle);
                        action = Action.Idle;
                        return;
                    }
                    
                    float distance = Vector3.Distance(transform.position, targetPos);
                    if (distance < 1)
                    {
                        SetBehaviour(BaseNpc.Behaviour.Eat);
                        entity.Hydration.Level += 0.005f;
                        entity.Hydration.Level = Mathf.Clamp01(entity.Hydration.Level);
                    }
                    else UpdateDestination(targetPos, distance > 5); 
                }​

Alter the code to match my Commited Changes below:

                else if (action == Action.Drink)
                {
                	
                    if (entity.Hydration.Level >= 1)
                    {
                        SetBehaviour(BaseNpc.Behaviour.Idle);
                        action = Action.Idle;
                        return;
                    }
                    
                    float distance = Vector3.Distance(transform.position, targetPos);
                    if (distance <= 2) // ChaoticDev [Changed]
                    {
                        SetBehaviour(BaseNpc.Behaviour.Eat);
                        
                        entity.Hydration.Level += 0.00003f; // ChaoticDev [Changed]
                        entity.Hydration.Level = Mathf.Clamp01(entity.Hydration.Level);
                    }
                    else 
                    {
                    	UpdateDestination(targetPos, distance > 5); 
                    }
                }


To fix Eating - Look for:

                        if ((action == Action.Eat || entity.Energy.Level < 0.25f) && targetEnt != owner.player)
                        {
                            SetBehaviour(BaseNpc.Behaviour.Eat);

                            if (distance <= attackRange)
                            {
                                entity.FoodTarget = targetEnt;
                                if (distance <= 2)                                
                                    entity.Eat();                                
                            }
                            else UpdateDestination(targetEnt.transform.position, distance > 5);                              
                        }

Alter the code to match my Commited Changes below:

                        if ((action == Action.Eat || entity.Energy.Level < 0.25f) && targetEnt != owner.player)
                        {
                            SetBehaviour(BaseNpc.Behaviour.Eat);

                            if (distance <= 2)  // ChaoticDev [Changed]
                            {
                                entity.FoodTarget = targetEnt;
                                if (distance <= 2)  {                              
                                    entity.Eat();                                        
                                }
                            }
                            else UpdateDestination(targetEnt.transform.position, distance > 5);                              
                        }

Thats it! You now have working Eating and Drinking for your pets.

Now if you want my added feature of having the Pet's Energy gradually increase while they sleep, you can look for the following:

                else if (action == Action.Sleep)
                {
                    StopMoving();
                    SetBehaviour(BaseNpc.Behaviour.Sleep);

                    entity.health += 0.003f;
                    entity.health = Mathf.Clamp(entity.health, 0, entity.MaxHealth());

                    entity.Sleep += 0.003f;
                    entity.Sleep = Mathf.Clamp01(entity.Sleep);                    
                }

Alter the code to match my Commited Changes below:

                else if (action == Action.Sleep)
                {
                    StopMoving();
                    SetBehaviour(BaseNpc.Behaviour.Sleep);

                    entity.health += 0.00003f;  // ChaoticDev [Changed] to be a gradual increase.
                    entity.health = Mathf.Clamp(entity.health, 0, entity.MaxHealth());

                    entity.Sleep += 0.00003f;  // ChaoticDev [Changed] to be a gradual increase.
                    entity.Sleep = Mathf.Clamp01(entity.Sleep);
                    
                    // ChaoticDev [Added]
                    entity.Energy.Level += 0.00003f;
                    entity.Energy.Level = Mathf.Clamp01(entity.Energy.Level);
                    // End
                    
                }

All Done!



Merged post

Oh and just to touch on what some other people have been requesting to be fixed, is the animal still attacks the owner after taming it. I have created a small workaround for this too. I will now share it with you and everyone.

Inside:
private void TryGetNewPet(BaseNpc npcPet)
{
     [ . . . ]
}​

Look for:

UserMessage(player, "petSet");

Just under that, add the following like so:
                // ChaoticDev [Added]
                component.npcAi.action = Action.Sleep;
                UserMessage(player, "Please run away from your pet for 5 to 10 seconds so they can calm down.\n\nIf you don't do this they will continue to attack you.\n\nAfter running away and giving your pet time to calm down, you can wake your pet back up and they will begin to follow you.");
                // End​

Example would be:

                UserMessage(player, "petSet");
                // ChaoticDev [Added]
                component.npcAi.action = Action.Sleep;
                UserMessage(player, "Please run away from your pet for 5 to 10 seconds so they can calm down.\n\nIf you don't do this they will continue to attack you.\n\nAfter running away and giving your pet time to calm down, you can wake your pet back up and they will begin to follow you.");
                // End

Very nice! I'll implement this right away! Thank you so much!

Merged post

Ah so I've noticed an issue here with the

component.npcAi.action = Action.Sleep;

part of the code here:

Error while compiling: Pets.cs(414,5): error CS0103: The name `component' does not exist in the current context

this is for

UserMessage(player, "petSet");

Is this due to the component being called before it was created?



Merged post

I've tried the following:
UserMessage(player, "petSet");
// ChaoticDev [Added]
npcAi.action = Action.Sleep;
UserMessage(player, "Please run away from your pet for 5 to 10 seconds so they can calm down.\n\nIf you don't do this they will continue to attack you.\n\nAfter running away and giving your pet time to calm down, you can wake your pet back up and they will begin to follow you.");
// End​
Seems to work this way. It just didn't like 'component' from what I see?