Browse Source

mob resist issue

lakebane-master
FatBoy-DOTC 7 months ago
parent
commit
bcbeacd60e
  1. 18
      src/engine/db/handlers/dbResistHandler.java
  2. 3
      src/engine/objects/AbstractCharacter.java
  3. 51
      src/engine/objects/Mob.java
  4. 2
      src/engine/objects/Resists.java
  5. 4
      src/engine/server/world/WorldServer.java

18
src/engine/db/handlers/dbResistHandler.java

@ -23,7 +23,25 @@ public class dbResistHandler extends dbHandlerBase { @@ -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;

3
src/engine/objects/AbstractCharacter.java

@ -685,6 +685,9 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -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;
}

51
src/engine/objects/Mob.java

@ -38,6 +38,7 @@ import java.util.LinkedHashMap; @@ -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 { @@ -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);
}

2
src/engine/objects/Resists.java

@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHashMap; @@ -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
src/engine/server/world/WorldServer.java

@ -375,6 +375,10 @@ public class WorldServer { @@ -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();

Loading…
Cancel
Save