mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-20 01:29:54 +02:00
Fix more Monolith achievements
This commit is contained in:
@@ -53,11 +53,45 @@ public class AchievementHelper {
|
||||
}
|
||||
|
||||
private static void fixParams() {
|
||||
// Star Tower TODO
|
||||
addParam(78, 0, 2);
|
||||
addParam(79, 0, 4);
|
||||
// Clear "Misstep On One"
|
||||
addParam(56, 401, 0); // Custom trigger
|
||||
|
||||
// Clear "Currents and Shadows"
|
||||
addParam(57, 102, 0);
|
||||
addParam(58, 103, 0);
|
||||
addParam(59, 104, 0);
|
||||
addParam(60, 105, 0);
|
||||
addParam(61, 106, 0);
|
||||
addParam(62, 107, 0);
|
||||
addParam(63, 108, 0);
|
||||
|
||||
// Clear "Dust and Flames"
|
||||
addParam(64, 202, 0);
|
||||
addParam(65, 203, 0);
|
||||
addParam(66, 204, 0);
|
||||
addParam(67, 205, 0);
|
||||
addParam(68, 206, 0);
|
||||
addParam(69, 207, 0);
|
||||
addParam(70, 208, 0);
|
||||
|
||||
// Clear "Storm and Thunder"
|
||||
addParam(71, 302, 0);
|
||||
addParam(72, 303, 0);
|
||||
addParam(73, 304, 0);
|
||||
addParam(74, 305, 0);
|
||||
addParam(75, 306, 0);
|
||||
addParam(76, 307, 0);
|
||||
addParam(77, 308, 0);
|
||||
|
||||
// First Ascension
|
||||
addParam(498, 0, 1);
|
||||
|
||||
// Monolith Conqueror
|
||||
addParam(78, 2, 0);
|
||||
addParam(79, 4, 0);
|
||||
addParam(80, 6, 0);
|
||||
addParam(81, 7, 0);
|
||||
|
||||
// Money
|
||||
addParam(25, GameConstants.GOLD_ITEM_ID, 0);
|
||||
addParam(26, GameConstants.GOLD_ITEM_ID, 0);
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Map;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
|
||||
import emu.nebula.Nebula;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.data.resources.AchievementDef;
|
||||
@@ -16,8 +17,8 @@ import emu.nebula.game.player.PlayerManager;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.Public.Achievements;
|
||||
import emu.nebula.proto.Public.Events;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import us.hebi.quickbuf.RepeatedInt;
|
||||
|
||||
@Getter
|
||||
@@ -29,8 +30,9 @@ public class AchievementManager extends PlayerManager implements GameDatabaseObj
|
||||
// Achievement data
|
||||
private Map<Integer, GameAchievement> achievements;
|
||||
|
||||
@Setter
|
||||
// Flags
|
||||
private transient boolean queueSave;
|
||||
private transient boolean hasCompleted;
|
||||
|
||||
@Deprecated // Morphia only
|
||||
public AchievementManager() {
|
||||
@@ -79,9 +81,6 @@ public class AchievementManager extends PlayerManager implements GameDatabaseObj
|
||||
}
|
||||
|
||||
public synchronized void handleClientEvents(Events events) {
|
||||
//
|
||||
boolean hasCompleted = false;
|
||||
|
||||
// Parse events
|
||||
for (var event : events.getList()) {
|
||||
// Check id
|
||||
@@ -117,23 +116,15 @@ public class AchievementManager extends PlayerManager implements GameDatabaseObj
|
||||
// Update achievement
|
||||
boolean changed = achievement.trigger(true, progress, 0, 0);
|
||||
|
||||
// Only save/update on client if achievement was changed
|
||||
// Sync with client if achievement was changed
|
||||
if (changed) {
|
||||
// Sync
|
||||
this.syncAchievement(achievement);
|
||||
|
||||
// Set save flag
|
||||
this.queueSave = true;
|
||||
|
||||
// Check if achievement was completed
|
||||
if (achievement.isComplete()) {
|
||||
hasCompleted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger update
|
||||
if (hasCompleted) {
|
||||
// Update total achievements
|
||||
if (this.hasCompleted) {
|
||||
this.hasCompleted = false;
|
||||
this.getPlayer().trigger(AchievementCondition.AchievementTotal, this.getCompletedAchievementsCount());
|
||||
}
|
||||
}
|
||||
@@ -166,8 +157,7 @@ public class AchievementManager extends PlayerManager implements GameDatabaseObj
|
||||
|
||||
// Check what type of achievement condition this is
|
||||
boolean isTotal = AchievementHelper.isIncrementalAchievement(condition);
|
||||
boolean hasCompleted = false;
|
||||
|
||||
|
||||
// Parse achievements
|
||||
for (var data : triggerList) {
|
||||
// Get achievement
|
||||
@@ -176,23 +166,41 @@ public class AchievementManager extends PlayerManager implements GameDatabaseObj
|
||||
// Update achievement
|
||||
boolean changed = achievement.trigger(isTotal, progress, param1, param2);
|
||||
|
||||
// Only save/update on client if achievement was changed
|
||||
// Sync with client if achievement was changed
|
||||
if (changed) {
|
||||
// Sync
|
||||
this.syncAchievement(achievement);
|
||||
|
||||
// Set save flag
|
||||
this.queueSave = true;
|
||||
|
||||
// Check if achievement was completed
|
||||
if (achievement.isComplete()) {
|
||||
hasCompleted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger update
|
||||
if (hasCompleted) {
|
||||
// Update total achievements
|
||||
if (this.hasCompleted) {
|
||||
this.hasCompleted = false;
|
||||
this.getPlayer().trigger(AchievementCondition.AchievementTotal, this.getCompletedAchievementsCount());
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void triggerOne(int id, int progress, int param1, int param2) {
|
||||
// Get achievement data
|
||||
var data = GameData.getAchievementDataTable().get(id);
|
||||
if (data == null) return;
|
||||
|
||||
// Get achievement
|
||||
var achievement = this.getAchievement(data);
|
||||
|
||||
// Check what type of achievement condition this is
|
||||
boolean isTotal = AchievementHelper.isIncrementalAchievement(data.getCompleteCond());
|
||||
|
||||
// Update achievement
|
||||
boolean changed = achievement.trigger(isTotal, progress, param1, param2);
|
||||
|
||||
// Sync with client if achievement was changed
|
||||
if (changed) {
|
||||
this.syncAchievement(achievement);
|
||||
}
|
||||
|
||||
// Update total achievements
|
||||
if (this.hasCompleted) {
|
||||
this.hasCompleted = false;
|
||||
this.getPlayer().trigger(AchievementCondition.AchievementTotal, this.getCompletedAchievementsCount());
|
||||
}
|
||||
}
|
||||
@@ -205,6 +213,15 @@ public class AchievementManager extends PlayerManager implements GameDatabaseObj
|
||||
return;
|
||||
}
|
||||
|
||||
// Set save flag
|
||||
this.queueSave = true;
|
||||
|
||||
// Check if achievement was completed
|
||||
if (achievement.isComplete()) {
|
||||
this.hasCompleted = true;
|
||||
}
|
||||
|
||||
// Send update to player
|
||||
getPlayer().addNextPackage(
|
||||
NetMsgId.achievement_change_notify,
|
||||
achievement.toProto()
|
||||
|
||||
Reference in New Issue
Block a user