MobBase builds its stats from the race rune's rune_attr_adj since 3.2, so LOAD_STATS and the MobBaseStats ResultSet constructor have no callers. No value change. The table is dropped by sql/3.6-mob-stats-resists-drop.sql. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
102 lines
3.6 KiB
Java
102 lines
3.6 KiB
Java
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
// Magicbane Emulator Project © 2013 - 2026
|
|
// https://www.magicbane.com
|
|
|
|
|
|
package engine.db.handlers;
|
|
|
|
import engine.gameManager.DbManager;
|
|
import engine.mbEnums;
|
|
import engine.mbEnums.GameObjectType;
|
|
import engine.objects.MobBase;
|
|
import org.pmw.tinylog.Logger;
|
|
|
|
import java.sql.Connection;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.ResultSet;
|
|
import java.sql.SQLException;
|
|
import java.util.ArrayList;
|
|
|
|
public class dbMobBaseHandler extends dbHandlerBase {
|
|
|
|
public dbMobBaseHandler() {
|
|
this.localClass = MobBase.class;
|
|
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
|
|
}
|
|
|
|
public MobBase GET_MOBBASE(int id) {
|
|
|
|
if (id == 0)
|
|
return null;
|
|
|
|
MobBase mobBase = (MobBase) DbManager.getFromCache(GameObjectType.MobBase, id);
|
|
|
|
if (mobBase != null)
|
|
return mobBase;
|
|
|
|
try (Connection connection = DbManager.getConnection();
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mobbase` WHERE `ID`=? AND `ID` = `loadID`")) {
|
|
|
|
preparedStatement.setInt(1, id);
|
|
|
|
ResultSet rs = preparedStatement.executeQuery();
|
|
mobBase = (MobBase) getObjectFromRs(rs);
|
|
|
|
} catch (SQLException e) {
|
|
Logger.error(e);
|
|
}
|
|
|
|
return mobBase;
|
|
}
|
|
|
|
|
|
public ArrayList<MobBase> GET_ALL_MOBBASES() {
|
|
|
|
ArrayList<MobBase> mobbaseList = new ArrayList<>();
|
|
|
|
// ID <> loadID rows were junk server-made mobbases (15000-17266); skip them on databases that still have them.
|
|
|
|
try (Connection connection = DbManager.getConnection();
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mobbase` WHERE `ID` = `loadID`;")) {
|
|
|
|
ResultSet rs = preparedStatement.executeQuery();
|
|
mobbaseList = getObjectsFromRs(rs, 1000);
|
|
|
|
} catch (SQLException e) {
|
|
Logger.error(e);
|
|
}
|
|
|
|
Logger.info("Loaded " + mobbaseList.size() + " mobbases");
|
|
|
|
return mobbaseList;
|
|
}
|
|
|
|
public void LOAD_ALL_MOBBASE_SPEEDS(MobBase mobBase) {
|
|
|
|
if (mobBase.getLoadID() == 0)
|
|
return;
|
|
|
|
try (Connection connection = DbManager.getConnection();
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mobbase_race` WHERE `mobbaseID` = ?")) {
|
|
|
|
preparedStatement.setInt(1, mobBase.getLoadID());
|
|
ResultSet rs = preparedStatement.executeQuery();
|
|
|
|
while (rs.next()) {
|
|
float walk = rs.getFloat("walkStandard");
|
|
float walkCombat = rs.getFloat("walkCombat");
|
|
float run = rs.getFloat("runStandard");
|
|
float runCombat = rs.getFloat("runCombat");
|
|
mobBase.updateSpeeds(walk, walkCombat, run, runCombat);
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
Logger.error(e);
|
|
}
|
|
}
|
|
}
|