Skip to content

Fixed Pet Logic and Implementation Buff System#110

Open
SVDNESS wants to merge 6 commits intobeyond-aion:4.8from
SVDNESS:fixed-pet-system
Open

Fixed Pet Logic and Implementation Buff System#110
SVDNESS wants to merge 6 commits intobeyond-aion:4.8from
SVDNESS:fixed-pet-system

Conversation

@SVDNESS
Copy link
Contributor

@SVDNESS SVDNESS commented Dec 26, 2025

Pet logic refactoring for JDK 25.
Fixes for some vulnerabilities.
Implementation of the Pet Buff System.
It is worth paying attention to the "TODO" in the "CM_PET_EMOTE" package.

<xs:enumeration value="LOOT"/>
<xs:enumeration value="DOPING"/>
<xs:enumeration value="BUFF"/>
<xs:enumeration value="CHERRY"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function type in toypets.xml of the game client is called buff and is a descriptive name, so it should not be renamed to CHERRY.

</pet_buffs>
<?xml version="1.0" encoding="UTF-8"?>
<pet_buffs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="pet_buffs.xsd">
<pet_buffs buff_id="1" food_count="5">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As each entry represents a single buff, the <buff> element name was more clear than the new name pet_buffs in my opnion.

<?xml version="1.0" encoding="UTF-8"?>
<pet_buffs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="pet_buffs.xsd">
<pet_buffs buff_id="1" food_count="5">
<penalty_attr stat="ATTACK_SPEED" func="PERCENT" value="-2"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the name <penalty_attr>? They're called <bonus_attr1-5> in toypet_buff.xml of the game client.
The previous version of this xml that used <modifier> templates made it very convenient to directly apply the effects.
I think this whole XML should be reset to its original state if your changes don't fix any errors in it.

log.info("Loaded " + petData.size() + " pet templates and " + petFeedData.size() + " food flavours");
log.info("Loaded " + petDopingData.size() + " pet doping templates");
log.info("Loaded " + petBuffsData.size() + " pet buffs templates");
log.info("Loaded {} pet doping templates.", petDopingData.size());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a mistake. petBuffData is no longer logged but petDopingData is logged twice now.
And let's use the original formatting, for constistency reasons:

Suggested change
log.info("Loaded {} pet doping templates.", petDopingData.size());
log.info("Loaded " + petBuffData.size() + " pet buffs templates");


public boolean getCancelFeed() {
return cancelFeed;
return !cancelFeed;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names of getters that return boolean should never start with "get". Let's find a more descriptive name here and try to remove the negation at the same time.

private short lovedFoodMax = 0;
private boolean lovedFeeded = false;
private final short lovedFoodMax;
private boolean loved_feed = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field name and related method names should be renamed to something like this:

Suggested change
private boolean loved_feed = false;
private boolean lovedFood;

Feel free to suggest a better name.

@@ -137,92 +130,91 @@ private void checkFeeding(Pet pet, Player player, Item item, int count) {
}

public void useDoping(Pet pet, int action, int itemId, int slot, int slot2) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments in this method should not be removed.

Comment on lines +187 to +200
AuditLogger.log(pet.getMaster(), "Tried to set buff item " + itemId + " but " + pet + " doesn't support buffing.");
return false;
}
PetDopingEntry dope = DataManager.PET_DOPING_DATA.getDopingTemplate(petFunction.getId());
var dope = DataManager.PET_DOPING_DATA.getDopingTemplate(petFunction.getId());
if (slot == 0 && !dope.isUseFood()) {
AuditLogger.log(pet.getMaster(), "tried to set item " + itemId + " in pet buff food slot but " + pet + " doesn't support buffing with food");
AuditLogger.log(pet.getMaster(), "Tried to set item " + itemId + " in pet buff food slot but " + pet + " doesn't support buffing with food.");
return false;
}
if (slot == 1 && !dope.isUseDrink()) {
AuditLogger.log(pet.getMaster(), "tried to set item " + itemId + " in pet buff drink slot but " + pet + " doesn't support buffing with drinks");
AuditLogger.log(pet.getMaster(), "Tried to set item " + itemId + " in pet buff drink slot but " + pet + " doesn't support buffing with drinks.");
return false;
}
if (slot > 1 && slot - 1 > dope.getScrollsUsed()) {
AuditLogger.log(pet.getMaster(), "tried to set item " + itemId + " in pet buff scroll slot " + (slot - 1) + " but " + pet + " only supports "
+ dope.getScrollsUsed() + " scrolls");
AuditLogger.log(pet.getMaster(), "Tried to set item " + itemId + " in pet buff scroll slot " + (slot - 1) + " but " + pet + " only supports " + dope.getScrollsUsed() + " scrolls.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Tried" should be changed to "tried" due to the way the message will be formatted (as I explained it in your previous PR).

The same applies to lines 217 and 233

}

private static class SingletonHolder {
public void activeCheering(Player player, boolean activate) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public void activeCheering(Player player, boolean activate) {
public void activateCheering(Player player, boolean activate) {

Comment on lines +258 to +260
if (player == null) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This null check can be removed:

Suggested change
if (player == null) {
return;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants