mob resist issue

This commit is contained in:
2024-05-11 19:58:57 -05:00
parent e39c7bebb5
commit bcbeacd60e
5 changed files with 76 additions and 2 deletions
@@ -23,7 +23,25 @@ public class dbResistHandler extends dbHandlerBase {
public dbResistHandler() {
}
public void LOAD_RESISTS_FOR_MOBS() {
Resists resists = null;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mob_resists`;")) {
ResultSet rs = preparedStatement.executeQuery();
while(rs.next()){
resists = new Resists(rs);
if(!Resists.mobResists.containsKey(rs.getInt("ID")))
Resists.mobResists.put(rs.getInt("ID"),resists);
}
} catch (SQLException e) {
Logger.error(e);
}
}
public Resists GET_RESISTS_FOR_MOB(int resistID) {
Resists resists = null;
@@ -685,6 +685,9 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
}
public final void setResists(final Resists value) {
if(this.getObjectType().equals(GameObjectType.Mob))
return;
this.resists = value;
}
+50 -1
View File
@@ -38,6 +38,7 @@ import java.util.LinkedHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import static engine.gameManager.NPCManager._runeSetMap;
import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
public class Mob extends AbstractIntelligenceAgent {
@@ -161,14 +162,62 @@ public class Mob extends AbstractIntelligenceAgent {
this.agentType = AIAgentType.MOBILE;
this.setResists(Resists.getResists(rs.getInt("mob_spawnType")));
//this.setResists(Resists.getResists(rs.getInt("mob_spawnType")));
setResistsForMob(this);
} catch (Exception e) {
Logger.error(e + " " + this.dbID);
}
}
public static void setResistsForMob(Mob mob){
mob.resists = new Resists("Generic");
Zone MacroParent = null;
for(Zone zone : ZoneManager.getAllZonesIn(mob.loc)){
if(zone.isMacroZone() == false)
continue;
switch(zone.getName()){
//ice generics
case "Ymur's Crown":
case "Kralgaar Holm":
case "Ecklund Wilds":
case "Aurrochs Skrae":
mob.resists = Resists.getResists(28);
break;
//Desert Generics
case "Leth'khalivar Desert":
case "Kharsoom":
case "Vale of Nar Addad":
case "The Blood Sands":
mob.resists = Resists.getResists(2);
break;
//Swamp Generics
case "Thollok Marsh":
case "The Black Bog":
case "Sevaath Mere":
mob.resists = Resists.getResists(10);
break;
//Oblivion Generics
case "Plain of Ashes":
case "Bone Marches":
case "The Doomplain":
case "Greensward Pyre":
mob.resists = Resists.getResists(4);
break;
//Maelstrom Generics
case "Pandemonium":
case "Western Battleground":
mob.resists = Resists.getResists(32);
break;
}
if(mob.getNameOverride().length() > 1){
mob.resists = Resists.getResists(3);
}
}
}
public static void serializeMobForClientMsgOtherPlayer(Mob mob, ByteBufferWriter writer) throws SerializationException {
Mob.serializeForClientMsgOtherPlayer(mob, writer);
}
+1 -1
View File
@@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class Resists {
private static ConcurrentHashMap<Integer, Resists> mobResists = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public static ConcurrentHashMap<Integer, Resists> mobResists = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private ConcurrentHashMap<DamageType, Float> resists = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private ConcurrentHashMap<DamageType, Boolean> immuneTo = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private DamageType protection;
+4
View File
@@ -375,6 +375,10 @@ public class WorldServer {
BaseClass.LoadAllBaseClasses();
Race.loadAllRaces();
RuneBaseEffect.LoadRuneBaseEffects();
Logger.info("Loading MobBases.");
DbManager.ResistQueries.LOAD_RESISTS_FOR_MOBS();
Logger.info("Loading MobBases.");
DbManager.MobBaseQueries.GET_ALL_MOBBASES();