Browse Source

NPCs in buildings show correct spawn times and progress

master
FatBoy-DOTC 2 years ago
parent
commit
76f3d2599b
  1. 5
      src/engine/net/client/msg/ManageCityAssetsMsg.java
  2. 42
      src/engine/net/client/msg/ManageNPCMsg.java

5
src/engine/net/client/msg/ManageCityAssetsMsg.java

@ -744,8 +744,9 @@ public class ManageCityAssetsMsg extends ClientNetMsg { @@ -744,8 +744,9 @@ public class ManageCityAssetsMsg extends ClientNetMsg {
if (!npcHire.isAlive()){
writer.put((byte) 1); // 1 SHOWs respawning
writer.putInt(10); // Seconds in respawn.
writer.putInt(20);
int respawnRemaining = (int)(((Mob)npcHire).deathTime + ((Mob)npcHire).spawnTime * 1000 - System.currentTimeMillis()) / 1000;
writer.putInt(respawnRemaining); // Seconds in respawn remaining.
writer.putInt(((Mob)npcHire).spawnTime); // max seconds for respawn
}
else
writer.put((byte)0);

42
src/engine/net/client/msg/ManageNPCMsg.java

@ -615,7 +615,6 @@ public class ManageNPCMsg extends ClientNetMsg { @@ -615,7 +615,6 @@ public class ManageNPCMsg extends ClientNetMsg {
writer.putInt(inventory.size()); //placeholder for item cnt
for (Item i : inventory) {
Item.serializeForClientMsgWithoutSlot(i, writer);
@ -763,27 +762,46 @@ public class ManageNPCMsg extends ClientNetMsg { @@ -763,27 +762,46 @@ public class ManageNPCMsg extends ClientNetMsg {
writer.putInt(0);
writer.putInt(1);
writer.putInt(1);
writer.put((byte) 0);
long curTime = System.currentTimeMillis() / 1000;
long upgradeTime = mob.getTimeToSpawnSiege() / 1000;
long upgradeTime = (mob.deathTime + (mob.spawnTime * 1000)) / 1000;
long timeLife = upgradeTime - curTime;
writer.putInt(900);
writer.putInt(900);
writer.putInt((int) timeLife); //time remaining?
if (upgradeTime * 1000 > System.currentTimeMillis()) {
if(mob.npcOwner.isAlive()) {
writer.put((byte) 0);//shows respawning timer
writer.putInt(mob.spawnTime);
writer.putInt(mob.spawnTime);
writer.putInt((int) timeLife); //time remaining for mob that is dead
writer.putInt(0);
writer.put((byte) 0);
writer.putString(mob.getNameOverride().isEmpty() ? mob.getName() : mob.getNameOverride());
writer.put((byte) 0);
}
else{
writer.put((byte) 0);//shows respawning timer
writer.putInt(0);
writer.putInt(0);
writer.putInt(0); //time remaining for mob that is dead
writer.putInt(0);
writer.put((byte) 0);
writer.putString(mob.getNameOverride().isEmpty() ? mob.getName() : mob.getNameOverride());
writer.put((byte) 0);
}
} else {
//nothing required for countdown for a mob that is alive
writer.put((byte) 1);//shows "Standing By"
writer.putInt(0);
writer.putInt(0);
writer.putInt(0);
writer.putInt(0);
writer.put((byte) 0);
writer.putString(mob.getNameOverride().isEmpty() ? mob.getName() : mob.getNameOverride());
writer.put((byte) 0);
}
}
}
}
}
}catch(Exception e){
e.printStackTrace();
}

Loading…
Cancel
Save