cache: update npc definition and loader

This commit is contained in:
Adam
2019-10-25 19:07:52 -04:00
parent 7bb95ef7c7
commit c2e7b61a68
3 changed files with 77 additions and 80 deletions

View File

@@ -31,38 +31,37 @@ import lombok.Data;
@Data
public class NpcDefinition
{
public final int id;
public short[] recolorToFind;
public int rotation = 32;
public String name = "null";
public short[] recolorToReplace;
public int size = 1;
public int[] models;
public int[] models_2;
public int stanceAnimation = -1;
public int anInt2165 = -1;
public int tileSpacesOccupied = 1;
public int walkAnimation = -1;
public short[] retextureToReplace;
public int rotate90RightAnimation = -1;
public boolean aBool2170 = true;
public int resizeX = 128;
public int contrast = 0;
public int[] chatheadModels;
public int standingAnimation = -1;
public int rotateLeftAnimation = -1;
public int rotateRightAnimation = -1;
public int walkingAnimation = -1;
public int rotate180Animation = -1;
public int varbitIndex = -1;
public String[] options = new String[5];
public boolean renderOnMinimap = true;
public int combatLevel = -1;
public int rotate90RightAnimation = -1;
public int rotate90LeftAnimation = -1;
public int resizeY = 128;
public boolean hasRenderPriority = false;
public int ambient = 0;
public int headIcon = -1;
public int[] configs;
public short[] recolorToFind;
public short[] recolorToReplace;
public short[] retextureToFind;
public short[] retextureToReplace;
public String[] actions = new String[5];
public boolean isMinimapVisible = true;
public int combatLevel = -1;
public int widthScale = 128;
public int heightScale = 128;
public boolean hasRenderPriority;
public int ambient;
public int contrast;
public int headIcon = -1;
public int rotationSpeed = 32;
public int[] configs;
public int varbitId = -1;
public int varpIndex = -1;
public boolean isClickable = true;
public int anInt2189 = -1;
public boolean aBool2190 = false;
public Map<Integer, Object> params = null;
public boolean isInteractable = true;
public boolean rotationFlag = true;
public boolean isPet;
public Map<Integer, Object> params;
}

View File

@@ -24,13 +24,12 @@
*/
package net.runelite.cache.definitions.loaders;
import java.util.HashMap;
import net.runelite.cache.definitions.NpcDefinition;
import net.runelite.cache.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
public class NpcLoader
{
private static final Logger logger = LoggerFactory.getLogger(NpcLoader.class);
@@ -67,7 +66,6 @@ public class NpcLoader
{
def.models[index] = stream.readUnsignedShort();
}
}
else if (opcode == 2)
{
@@ -75,37 +73,37 @@ public class NpcLoader
}
else if (opcode == 12)
{
def.tileSpacesOccupied = stream.readUnsignedByte();
def.size = stream.readUnsignedByte();
}
else if (opcode == 13)
{
def.stanceAnimation = stream.readUnsignedShort();
def.standingAnimation = stream.readUnsignedShort();
}
else if (opcode == 14)
{
def.walkAnimation = stream.readUnsignedShort();
def.walkingAnimation = stream.readUnsignedShort();
}
else if (opcode == 15)
{
def.anInt2165 = stream.readUnsignedShort();
def.rotateLeftAnimation = stream.readUnsignedShort();
}
else if (opcode == 16)
{
def.anInt2189 = stream.readUnsignedShort();
def.rotateRightAnimation = stream.readUnsignedShort();
}
else if (opcode == 17)
{
def.walkAnimation = stream.readUnsignedShort();
def.walkingAnimation = stream.readUnsignedShort();
def.rotate180Animation = stream.readUnsignedShort();
def.rotate90RightAnimation = stream.readUnsignedShort();
def.rotate90LeftAnimation = stream.readUnsignedShort();
}
else if (opcode >= 30 && opcode < 35)
{
def.options[opcode - 30] = stream.readString();
if (def.options[opcode - 30].equalsIgnoreCase("Hidden"))
def.actions[opcode - 30] = stream.readString();
if (def.actions[opcode - 30].equalsIgnoreCase("Hidden"))
{
def.options[opcode - 30] = null;
def.actions[opcode - 30] = null;
}
}
else if (opcode == 40)
@@ -137,17 +135,17 @@ public class NpcLoader
else if (opcode == 60)
{
length = stream.readUnsignedByte();
def.models_2 = new int[length];
def.chatheadModels = new int[length];
for (index = 0; index < length; ++index)
{
def.models_2[index] = stream.readUnsignedShort();
def.chatheadModels[index] = stream.readUnsignedShort();
}
}
else if (opcode == 93)
{
def.renderOnMinimap = false;
def.isMinimapVisible = false;
}
else if (opcode == 95)
{
@@ -155,11 +153,11 @@ public class NpcLoader
}
else if (opcode == 97)
{
def.resizeX = stream.readUnsignedShort();
def.widthScale = stream.readUnsignedShort();
}
else if (opcode == 98)
{
def.resizeY = stream.readUnsignedShort();
def.heightScale = stream.readUnsignedShort();
}
else if (opcode == 99)
{
@@ -179,18 +177,18 @@ public class NpcLoader
}
else if (opcode == 103)
{
def.rotation = stream.readUnsignedShort();
def.rotationSpeed = stream.readUnsignedShort();
}
else if (opcode == 106)
{
def.varbitIndex = stream.readUnsignedShort();
if ('\uffff' == def.varbitIndex)
def.varbitId = stream.readUnsignedShort();
if (def.varbitId == 65535)
{
def.varbitIndex = -1;
def.varbitId = -1;
}
def.varpIndex = stream.readUnsignedShort();
if ('\uffff' == def.varpIndex)
if (def.varpIndex == 65535)
{
def.varpIndex = -1;
}
@@ -212,26 +210,26 @@ public class NpcLoader
}
else if (opcode == 107)
{
def.isClickable = false;
def.isInteractable = false;
}
else if (opcode == 109)
{
def.aBool2170 = false;
def.rotationFlag = false;
}
else if (opcode == 111)
{
def.aBool2190 = true;
def.isPet = true;
}
else if (opcode == 118)
{
def.varbitIndex = stream.readUnsignedShort();
if ('\uffff' == def.varbitIndex)
def.varbitId = stream.readUnsignedShort();
if (def.varbitId == 65535)
{
def.varbitIndex = -1;
def.varbitId = -1;
}
def.varpIndex = stream.readUnsignedShort();
if ('\uffff' == def.varpIndex)
if (def.varpIndex == 65535)
{
def.varpIndex = -1;
}

View File

@@ -47,45 +47,45 @@ public class NpcSaver
out.writeByte(2);
out.writeString(npc.name);
}
if (npc.tileSpacesOccupied != 1)
if (npc.size != 1)
{
out.writeByte(12);
out.writeByte(npc.tileSpacesOccupied);
out.writeByte(npc.size);
}
if (npc.stanceAnimation != -1)
if (npc.standingAnimation != -1)
{
out.writeByte(13);
out.writeShort(npc.stanceAnimation);
out.writeShort(npc.standingAnimation);
}
if (npc.walkAnimation != -1)
if (npc.walkingAnimation != -1)
{
out.writeByte(14);
out.writeShort(npc.walkAnimation);
out.writeShort(npc.walkingAnimation);
}
if (npc.anInt2165 != -1)
if (npc.rotateLeftAnimation != -1)
{
out.writeByte(15);
out.writeShort(npc.anInt2165);
out.writeShort(npc.rotateLeftAnimation);
}
if (npc.anInt2189 != -1)
if (npc.rotateRightAnimation != -1)
{
out.writeByte(16);
out.writeShort(npc.anInt2189);
out.writeShort(npc.rotateRightAnimation);
}
if (npc.rotate180Animation != -1 || npc.rotate90LeftAnimation != -1 || npc.rotate90RightAnimation != -1)
{
out.writeByte(17);
out.writeShort(npc.walkAnimation);
out.writeShort(npc.walkingAnimation);
out.writeShort(npc.rotate180Animation);
out.writeShort(npc.rotate90RightAnimation);
out.writeShort(npc.rotate90LeftAnimation);
}
for (int i = 0; i < 5; ++i)
{
if (npc.options[i] != null)
if (npc.actions[i] != null)
{
out.writeByte(30 + i);
out.writeString(npc.options[i]);
out.writeString(npc.actions[i]);
}
}
if (npc.recolorToFind != null && npc.recolorToReplace != null)
@@ -108,16 +108,16 @@ public class NpcSaver
out.writeShort(npc.retextureToReplace[i]);
}
}
if (npc.models_2 != null)
if (npc.chatheadModels != null)
{
out.writeByte(60);
out.writeByte(npc.models_2.length);
for (int modelId : npc.models_2)
out.writeByte(npc.chatheadModels.length);
for (int modelId : npc.chatheadModels)
{
out.writeShort(modelId);
}
}
if (!npc.renderOnMinimap)
if (!npc.isMinimapVisible)
{
out.writeByte(93);
}
@@ -127,9 +127,9 @@ public class NpcSaver
out.writeShort(npc.combatLevel);
}
out.writeByte(97);
out.writeShort(npc.resizeX);
out.writeShort(npc.widthScale);
out.writeByte(98);
out.writeShort(npc.resizeY);
out.writeShort(npc.heightScale);
if (npc.hasRenderPriority)
{
out.writeByte(99);
@@ -144,23 +144,23 @@ public class NpcSaver
out.writeShort(npc.headIcon);
}
out.writeByte(103);
out.writeShort(npc.rotation);
if (!npc.isClickable)
out.writeShort(npc.rotationSpeed);
if (!npc.isInteractable)
{
out.writeByte(107);
}
if (!npc.aBool2170)
if (!npc.rotationFlag)
{
out.writeByte(109);
}
if (npc.aBool2190)
if (npc.isPet)
{
out.writeByte(111);
}
if (npc.configs != null)
{
out.writeByte(118);
out.writeShort(npc.varbitIndex);
out.writeShort(npc.varbitId);
out.writeShort(npc.varpIndex);
int[] c = npc.configs;