Browse Source

Cleanup and bonus code removal.

master
MagicBot 2 years ago
parent
commit
5a0136cd3d
  1. 77
      src/engine/objects/NPC.java

77
src/engine/objects/NPC.java

@ -377,7 +377,6 @@ public class NPC extends AbstractCharacter {
this.minDamageHandTwo = 1; this.minDamageHandTwo = 1;
this.maxDamageHandTwo = 4; this.maxDamageHandTwo = 4;
this.atrHandOne = 300; this.atrHandOne = 300;
this.atrHandOne = 300;
this.defenseRating = 200; this.defenseRating = 200;
this.isActive = true; this.isActive = true;
@ -484,10 +483,6 @@ public class NPC extends AbstractCharacter {
* Serialization * Serialization
*/ */
public static void __serializeForClientMsg(NPC npc,ByteBufferWriter writer) throws SerializationException {
}
public static void serializeNpcForClientMsgOtherPlayer(NPC npc,ByteBufferWriter writer, boolean hideAsciiLastName) public static void serializeNpcForClientMsgOtherPlayer(NPC npc,ByteBufferWriter writer, boolean hideAsciiLastName)
throws SerializationException { throws SerializationException {
serializeForClientMsgOtherPlayer(npc,writer); serializeForClientMsgOtherPlayer(npc,writer);
@ -538,10 +533,8 @@ public class NPC extends AbstractCharacter {
if (classID != 0) if (classID != 0)
cnt++; cnt++;
if (extraRune != 0 && extraRune != contractID) { if (extraRune != 0 && extraRune != contractID)
cnt++; cnt++;
}
writer.putInt(cnt); writer.putInt(cnt);
@ -561,9 +554,9 @@ public class NPC extends AbstractCharacter {
writer.putInt(5); writer.putInt(5);
writer.putInt(0); writer.putInt(0);
if (npc.contract != null) { if (npc.contract != null)
writer.putInt(contractID); writer.putInt(contractID);
}else else
writer.putInt(2500); writer.putInt(2500);
writer.putInt(GameObjectType.NPCClassRune.ordinal()); writer.putInt(GameObjectType.NPCClassRune.ordinal());
@ -598,14 +591,6 @@ public class NPC extends AbstractCharacter {
cnt = serializeExtraRune(npc,252654, cnt, writer); cnt = serializeExtraRune(npc,252654, cnt, writer);
} }
// if (extraRune != 0 && extraRune != contractID) {
// writer.putInt(3);
// writer.putInt(0);
// writer.putInt(extraRune);
// writer.putInt(GameObjectType.NPCExtraRune.ordinal());
// writer.putInt(npc.getObjectUUID());
// }
//Shopkeeper //Shopkeeper
writer.putInt(5); writer.putInt(5);
writer.putInt(0); writer.putInt(0);
@ -648,20 +633,18 @@ public class NPC extends AbstractCharacter {
writer.putInt(0); writer.putInt(0);
writer.putInt(0); writer.putInt(0);
writer.putInt(0); writer.putInt(0);
//writer.putInt(0); wHy do i see 4 in recording?
writer.put((byte) 0); writer.put((byte) 0);
writer.putInt(npc.getObjectType().ordinal()); writer.putInt(npc.getObjectType().ordinal());
writer.putInt(npc.currentID); writer.putInt(npc.currentID);
// writer.putLong(npc.getCompositeID());
writer.putFloat(1.0f); writer.putFloat(1.0f);
writer.putFloat(1.0f); writer.putFloat(1.0f);
writer.putFloat(1.0f); writer.putFloat(1.0f);
if (npc.region != null){ if (npc.region != null)
writer.putVector3f(npc.inBuildingLoc); writer.putVector3f(npc.inBuildingLoc);
}else{ else{
writer.putFloat(npc.getLoc().getX()); writer.putFloat(npc.getLoc().getX());
writer.putFloat(npc.getLoc().getY()); writer.putFloat(npc.getLoc().getY());
writer.putFloat(npc.getLoc().getZ()); writer.putFloat(npc.getLoc().getZ());
@ -718,9 +701,8 @@ public class NPC extends AbstractCharacter {
writer.putInt(val); writer.putInt(val);
} }
} else { } else
writer.putInt(0); writer.putInt(0);
}
writer.put((byte) 1); writer.put((byte) 1);
@ -734,28 +716,25 @@ public class NPC extends AbstractCharacter {
writer.putLong(0); writer.putLong(0);
} }
if (npc.contract != null) { if (npc.contract != null)
writer.putInt(npc.contract.getIconID()); writer.putInt(npc.contract.getIconID());
} else { else
writer.putInt(0); //npc icon ID writer.putInt(0); //npc icon ID
}
// for (int i=0;i<5;i++)
// writer.putInt(0);
writer.putInt(0); writer.putInt(0);
writer.putShort((short)0); writer.putShort((short)0);
if (npc.contract != null && npc.contract.isTrainer()) { if (npc.contract != null && npc.contract.isTrainer()) {
writer.putInt(classID); writer.putInt(classID);
} else { } else {
writer.putInt(0); writer.putInt(0);
} }
if (npc.contract != null && npc.contract.isTrainer()) { if (npc.contract != null && npc.contract.isTrainer())
writer.putInt(classID); writer.putInt(classID);
} else { else
writer.putInt(0); writer.putInt(0);
}
writer.putInt(0); writer.putInt(0);
writer.putInt(0); writer.putInt(0);
@ -767,14 +746,10 @@ public class NPC extends AbstractCharacter {
//Pull guild info from building if linked to one //Pull guild info from building if linked to one
Guild.serializeForClientMsg(npc.guild,writer, null, true); Guild.serializeForClientMsg(npc.guild,writer, null, true);
writer.putInt(1); writer.putInt(1);
writer.putInt(0x8A2E); writer.putInt(0x8A2E);
// writer.putInt((npc.contract != null) ? npc.contract.getContractID() : 0x8A2E);
writer.putInt(0); writer.putInt(0);
writer.putInt(0); writer.putInt(0);
@ -794,7 +769,6 @@ public class NPC extends AbstractCharacter {
for (Mob toRemove : this.siegeMinionMap.keySet()) { for (Mob toRemove : this.siegeMinionMap.keySet()) {
try { try {
toRemove.clearEffects(); toRemove.clearEffects();
} catch(Exception e){ } catch(Exception e){
@ -826,11 +800,11 @@ public class NPC extends AbstractCharacter {
writer.putInt(5); writer.putInt(5);
writer.putInt(0); writer.putInt(0);
writer.putInt(runeID); writer.putInt(runeID);
if (cnt == 0) { if (cnt == 0)
writer.putInt(GameObjectType.NPCClassRuneTwo.ordinal()); writer.putInt(GameObjectType.NPCClassRuneTwo.ordinal());
} else { else
writer.putInt(GameObjectType.NPCClassRuneThree.ordinal()); writer.putInt(GameObjectType.NPCClassRuneThree.ordinal());
}
writer.putInt(npc.currentID); writer.putInt(npc.currentID);
return cnt + 1; return cnt + 1;
} }
@ -838,12 +812,12 @@ public class NPC extends AbstractCharacter {
@Override @Override
public float getSpeed() { public float getSpeed() {
if (this.isWalk()) {
if (this.isWalk())
return MBServerStatics.WALKSPEED; return MBServerStatics.WALKSPEED;
} else { else
return MBServerStatics.RUNSPEED; return MBServerStatics.RUNSPEED;
} }
}
@Override @Override
public float getPassiveChance(String type, int AttackerLevel, boolean fromCombat) { public float getPassiveChance(String type, int AttackerLevel, boolean fromCombat) {
@ -869,9 +843,8 @@ public class NPC extends AbstractCharacter {
//Orphan inventory so it can be looted //Orphan inventory so it can be looted
//if (!this.inSafeZone) //if (!this.inSafeZone)
if (this.charItemManager != null) { if (this.charItemManager != null)
this.charItemManager.orphanInventory(); this.charItemManager.orphanInventory();
}
//TODO Send death message if needed //TODO Send death message if needed
//Question? How would a mob die to water? //Question? How would a mob die to water?
@ -894,9 +867,10 @@ public class NPC extends AbstractCharacter {
} }
public int getParentZoneID() { public int getParentZoneID() {
if (this.parentZone != null) {
if (this.parentZone != null)
return this.parentZone.getObjectUUID(); return this.parentZone.getObjectUUID();
}
return 0; return 0;
} }
@ -929,7 +903,6 @@ public class NPC extends AbstractCharacter {
if (!this.parentZone.isPlayerCity()) if (!this.parentZone.isPlayerCity())
this.sellPercent = 1; this.sellPercent = 1;
if (this.building != null) { if (this.building != null) {
BuildingModelBase buildingModel = BuildingModelBase.getModelBase(this.building.getMeshUUID()); BuildingModelBase buildingModel = BuildingModelBase.getModelBase(this.building.getMeshUUID());
@ -954,13 +927,9 @@ public class NPC extends AbstractCharacter {
this.setRot(new Vector3f(buildingLocation.getRot())); this.setRot(new Vector3f(buildingLocation.getRot()));
} }
else{ else if (this.building.getHirelings().containsKey(this) && putSlot != -1)
//only log if npc has been loaded in building.
if (this.building.getHirelings().containsKey(this) && putSlot != -1) {
Logger.error("could not slot npc : " + currentID + " in slot " + putSlot + " for building Mesh " + this.building.getMeshUUID()); Logger.error("could not slot npc : " + currentID + " in slot " + putSlot + " for building Mesh " + this.building.getMeshUUID());
} }
}
}
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(this.building, slotLocation); Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(this.building, slotLocation);

Loading…
Cancel
Save