Implement trekker honor titles

- Setting affinity via commands will not add new honor titles
This commit is contained in:
Melledy
2026-04-15 06:38:45 -07:00
parent 9ba38d5a5e
commit 36e8bc1467
8 changed files with 119 additions and 22 deletions
@@ -30,6 +30,7 @@ import emu.nebula.proto.Public.AffinityInfo;
import emu.nebula.proto.Public.Char;
import emu.nebula.proto.Public.CharGemPreset;
import emu.nebula.proto.Public.CharGemSlot;
import emu.nebula.proto.Public.Honor;
import emu.nebula.proto.Public.UI32;
import emu.nebula.proto.PublicStarTower.StarTowerChar;
import emu.nebula.proto.PublicStarTower.StarTowerCharGem;
@@ -411,7 +412,7 @@ public class GameCharacter implements GameDatabaseObject {
return data != null ? data.getNeedExp() : 0;
}
public void addAffinityExp(int amount) {
public void addAffinityExp(int amount, PlayerChangeInfo change) {
// Setup
int expRequired = this.getMaxAffinityExp();
@@ -420,10 +421,17 @@ public class GameCharacter implements GameDatabaseObject {
// Check for level ups
while (this.affinityExp >= expRequired && expRequired > 0) {
// Level up affinity and reset exp required
this.affinityLevel += 1;
this.affinityExp -= expRequired;
expRequired = this.getMaxAffinityExp();
// Add honor title if we meet the requirements
if (this.affinityLevel == GameConstants.AFFINITY_HONOR_UNLOCK_LEVEL && this.getData().getHonor() != null) {
var proto = Honor.newInstance().setNewId(this.getData().getHonor().getId());
change.add(proto);
}
}
// Clamp exp
@@ -472,15 +480,15 @@ public class GameCharacter implements GameDatabaseObject {
return null;
}
// Remove items
var change = this.getPlayer().getInventory().removeItems(items);
// Add affinity exp
this.addAffinityExp(exp);
this.addAffinityExp(exp, change);
// Trigger quest/achievement
this.getPlayer().trigger(QuestCondition.GiftGiveTotal, count);
// Remove items
var change = this.getPlayer().getInventory().removeItems(items);
// Success
return change;
}
@@ -247,6 +247,32 @@ public class Inventory extends PlayerManager implements GameDatabaseObject {
return true;
}
public IntCollection getAllHonorTitles() {
// Setup int collection
var list = new IntOpenHashSet();
// Add character honor titles
for (var character : getPlayer().getCharacters().getCharacterCollection()) {
// Check affinity level
if (character.getAffinityLevel() < GameConstants.AFFINITY_HONOR_UNLOCK_LEVEL) {
continue;
}
// Get honor data
var honor = character.getData().getHonor();
if (honor == null) continue;
// Add to honor list
list.add(honor.getId());
}
// Finally, add extra honor titles
list.addAll(this.getHonorList());
// Complete and return
return list;
}
public boolean addHonor(int id) {
// Make sure we are not adding duplicates
if (this.getHonorList().contains(id)) {
@@ -264,7 +290,27 @@ public class Inventory extends PlayerManager implements GameDatabaseObject {
}
public boolean hasHonor(int id) {
return id == GameConstants.DEFAULT_HONOR_ID || this.getHonorList().contains(id);
// Check if honor title is default or if the player owns it
if (id == GameConstants.DEFAULT_HONOR_ID || this.getHonorList().contains(id)) {
return true;
}
// Get honor data
var honor = GameData.getHonorDataTable().get(id);
if (honor == null) return false;
// Check if honor title is a trekker affinity title
if (honor.getType() == 2 && honor.getParams().length >= 1) {
int charId = honor.getParams()[0];
var character = this.getPlayer().getCharacters().getCharacterById(charId);
if (character != null && character.getAffinityLevel() >= GameConstants.AFFINITY_HONOR_UNLOCK_LEVEL) {
return true;
}
}
// Failure
return false;
}
// Resources
@@ -936,7 +936,7 @@ public class Player implements GameDatabaseObject {
proto.addHonors(info);
}
this.getInventory().getHonorList().forEach(proto::addHonorList);
this.getInventory().getAllHonorTitles().forEach(proto::addHonorList);
// Set world class
proto.getMutableWorldClass()