Fixed Pet Logic and Implementation Buff System#110
Fixed Pet Logic and Implementation Buff System#110SVDNESS wants to merge 6 commits intobeyond-aion:4.8from
Conversation
| <xs:enumeration value="LOOT"/> | ||
| <xs:enumeration value="DOPING"/> | ||
| <xs:enumeration value="BUFF"/> | ||
| <xs:enumeration value="CHERRY"/> |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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"/> |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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:
| log.info("Loaded {} pet doping templates.", petDopingData.size()); | |
| log.info("Loaded " + petBuffData.size() + " pet buffs templates"); |
|
|
||
| public boolean getCancelFeed() { | ||
| return cancelFeed; | ||
| return !cancelFeed; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
The field name and related method names should be renamed to something like this:
| 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) { | |||
There was a problem hiding this comment.
The comments in this method should not be removed.
| 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."); |
There was a problem hiding this comment.
"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) { |
There was a problem hiding this comment.
| public void activeCheering(Player player, boolean activate) { | |
| public void activateCheering(Player player, boolean activate) { |
| if (player == null) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
This null check can be removed:
| if (player == null) { | |
| return; | |
| } |
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.