Add-on UserPets

The latest preview looks great!

Would it be possible to implement a stat based win chance algorithm? (Maybe have it optional to set it to 50/50 or have it stat based)

You could call it "Casual" vs "Ranked" and you could perhaps have two leaderboards for each. Only "Casual" players can duel each other, and only "Ranked" players can duel each other. Maybe set the modes up with phrases so the terms can be easily customised by Admin if it doesn't suit their need.
Maybe have a Pets Panel, where you see your pet, it's stats, a log of actions you've made with your pet (Feeding Log, Duel Log, Pet history) and Pet Settings where you choose which mode you would prefer to be in. You could then also have a list of online users with the same pet mode as you but this area should use their pet as the main display name with the actual username visible smaller in brackets, so you can easily duel or interact with the online players in your currently selected mode.

You could maybe even build a shop to purchase food, shields to defend against attack, and other perks which you could maybe integrate with the DragonBytes Credits/Shop system.

I was thinking maybe you could even have multiple pets available to interect with in the pet panel, but only have one selected as the "active" pet that is displayed on your profile.

You could then have a widget of the top 10(Maybe be able to select how many rows to display in the widget setup, as well as selecting which mode leaderboard to display in the widget), so you can have a widget displayed somewhere else on the forum.
 
You could call it "Casual" vs "Ranked" and you could perhaps have two leaderboards for each. Only "Casual" players can duel each other, and only "Ranked" players can duel each other. Maybe set the modes up with phrases so the terms can be easily customised by Admin if it doesn't suit their need.
Maybe have a Pets Panel, where you see your pet, it's stats, a log of actions you've made with your pet (Feeding Log, Duel Log, Pet history) and Pet Settings where you choose which mode you would prefer to be in. You could then also have a list of online users with the same pet mode as you but this area should use their pet as the main display name with the actual username visible smaller in brackets, so you can easily duel or interact with the online players in your currently selected mode.

You could maybe even build a shop to purchase food, shields to defend against attack, and other perks which you could maybe integrate with the DragonBytes Credits/Shop system.

I was thinking maybe you could even have multiple pets available to interect with in the pet panel, but only have one selected as the "active" pet that is displayed on your profile.
Yeah sorry I'm not going to be doing that. Don't get me wrong it's interesting and I can see a few bits that I could see myself adding. But what your describing right now is turning more and more into a game.

If you would like to work on that kind of system yourself you are free to use my add-on as a base, or if you really want it in the software PR it and it could be an optional feature. But personally I have no need for this.

I will also not be including external add-ons such as DragonBytes products. I have no problem with the developer I just don't feel comfortable adding a dependency for a paid product. If DragonByte had an open source software I'd consider it but again I have no personal use for this, and if I did I'd feel more comfortable developing a currency system of my own that I could keep open source rather than relying on another developers product.

What I do find interesting is the Pets panel, the log of actions, and pet settings. Now granted the case could be made some of these features already exist, I'd be up for adding a dedicated area as well for these features as I can see a use case for it. Pet settings though, they have a section in the account details. I had to specifically create a method to let me do this as Xenforo by default doesn't allow you to attach Custom user fields to an account. (Now that I'm thinking back though, I wonder if I can achieve the same result using the content types? I need to explore that more..)

You could then have a widget of the top 10(Maybe be able to select how many rows to display in the widget setup, as well as selecting which mode leaderboard to display in the widget), so you can have a widget displayed somewhere else on the forum.
This is another interesting bit. It's not exactly needed if I create a dedicated space for it anyway. But I can see the appeal of it. I'll add a widget as well as a dedicated space so admins can control which they'd prefer to use.

Would it be possible to implement a stat based win chance algorithm? (Maybe have it optional to set it to 50/50 or have it stat based)
Finally the most interesting point, I could have a lot of fun with this but could you expand on what your thinking? For me it would be either hard coded algorithms used, a customisable field or both mixed together. What is it your thinking?

Keep in mind I'd prefer not to set up extra stats like strength, dexterity etc. I'd prefer to stick with the current values which are level, exp, happiness, hunger and sleepiness.




That said though thank you for your interest, I'm glad you like what you see so far. :)
 
Yeah sorry I'm not going to be doing that. Don't get me wrong it's interesting and I can see a few bits that I could see myself adding. But what your describing right now is turning more and more into a game.

If you would like to work on that kind of system yourself you are free to use my add-on as a base, or if you really want it in the software PR it and it could be an optional feature. But personally I have no need for this.

I will also not be including external add-ons such as DragonBytes products. I have no problem with the developer I just don't feel comfortable adding a dependency for a paid product. If DragonByte had an open source software I'd consider it but again I have no personal use for this, and if I did I'd feel more comfortable developing a currency system of my own that I could keep open source rather than relying on another developers product.

What I do find interesting is the Pets panel, the log of actions, and pet settings. Now granted the case could be made some of these features already exist, I'd be up for adding a dedicated area as well for these features as I can see a use case for it. Pet settings though, they have a section in the account details. I had to specifically create a method to let me do this as Xenforo by default doesn't allow you to attach Custom user fields to an account. (Now that I'm thinking back though, I wonder if I can achieve the same result using the content types? I need to explore that more..)


This is another interesting bit. It's not exactly needed if I create a dedicated space for it anyway. But I can see the appeal of it. I'll add a widget as well as a dedicated space so admins can control which they'd prefer to use.


Finally the most interesting point, I could have a lot of fun with this but could you expand on what your thinking? For me it would be either hard coded algorithms used, a customisable field or both mixed together. What is it your thinking?

Keep in mind I'd prefer not to set up extra stats like strength, dexterity etc. I'd prefer to stick with the current values which are level, exp, happiness, hunger and sleepiness.




That said though thank you for your interest, I'm glad you like what you see so far. :)
Fair points! Once you have a final version released, I'll likely use as a base to work on for the extra features... If I get it working, etc, I'll do a PR so it's there if it happens.

Regarding the last point, that’s exactly what I was thinking. Keeping it realistic and tied to how well the pet is actually being looked after, rather than introducing extra RPG stats.

The duel system could use a logic-based outcome that favours the better cared-for pet. For example:

  • A happy, well-fed, rested pet will naturally perform better in battle.
  • A hungry, tired, or unhappy pet would have a noticeable disadvantage as they'll be slower, weaker, less focused.
  • Higher level and experience still play a big role, but overall condition affects the final outcome.

Internally, it could still be handled through a weighted score with condition multipliers to determine the odds; for example:

Code:
$petACondition = (
($petA['happiness'] / 100) * 0.4 +
((100 - $petA['hunger']) / 100) * 0.3 +
((100 - $petA['sleepiness']) / 100) * 0.3
);

$petBCondition = (
($petB['happiness'] / 100) * 0.4 +
((100 - $petB['hunger']) / 100) * 0.3 +
((100 - $petB['sleepiness']) / 100) * 0.3
);

$petAPower = ($petA['level'] * 1.5) + ($petA['exp'] / 50);
$petBPower = ($petB['level'] * 1.5) + ($petB['exp'] / 50);

$petAFinal = $petAPower * $petACondition;
$petBFinal = $petBPower * $petBCondition;

// Add a small random variance (±10%)
$variance = mt_rand(-10, 10) / 100;
$petAFinal *= (1 + $variance);
$petBFinal *= (1 - $variance);

Then the two pets’ scores are compared to determine the winner, and a battle log can be include descriptive feedback(set these up as phrases to ease customization) based on conditions; for example:

  • “Petname looks well-rested and alert!”
  • “Petname seems happy and confident!”
  • “Petname looks weak from hunger…”
  • “Petname doesn’t seem very motivated…”
  • “Petname wins the duel!”

A small random factor ensures outcomes aren’t completely predictable, but the better cared-for pet should almost always have the upper hand.

In the ACP there could simply be a toggle for:

  • Balanced Mode (50/50)
  • Realistic Mode (Stat-based logic + battle log feedback)

That way, duels feel fair, skill-based, and pets that are well maintained and trained will consistently outperform neglected ones, and the battle log adds personality and storytelling to each encounter.
 
The duel system could use a logic-based outcome that favours the better cared-for pet. For example:
I think I improved on this idea :cool:
The duel system now comes with four built in algorithms, but you can also create your own custom ones.
The best part is it's super simple!

All you need to do is create a class like this in your add-on at:
src/addons/Vendor/Addon/Sylphian/UserPets/Service/DuelAlgorithms/CheatAlgorithm.php
Code:
<?php

namespace Vendor\Addon\Sylphian\UserPets\Service\DuelAlgorithms;

class CheatAlgorithm implements DuelAlgorithmInterface
{
    public function calculateWinner(array $petA, array $petB): array
    {
        return $petA;
    }
}
Just like that, a new algorithm has been created, now petA will always win.

Check it out if you want :)
 
This is my next goal, I want to be able to manage sprites completely in the admin control panel.

This is a preview of what I mean. You'd be able to control each sprites frame size, how many animations etc. Then that would render in on the front end so it can accept any pixel art people decide on using.
View attachment ShowcaseUserPetsSpritesheetManagement.Mp4

The next step for me is to edit the preview javascript so it cycles through all the animations rather than just looping through the idle.
 
Hey :)

I’ve downloaded the latest version of this to help test etc, but it seems to require a version of your library newer than what is available on git. :)
 
Hey :)

I’ve downloaded the latest version of this to help test etc, but it seems to require a version of your library newer than what is available on git. :)
Ah yes that was due to the spritesheet manager, it needed a method that could update the user field options so it could be automated.
I'll update the master branch of the library now.
 
  • Like
Reactions: Lee
Back
Top Bottom