42public final class CacheNpcDefinition {
44 public static void unpackConfig(
final Archive archive) {
45 buffer =
Buffer.fromByteBuffer(archive.getData(
"npc.dat"));
46 final Buffer idx =
Buffer.fromByteBuffer(archive.getData(
"npc.idx"));
47 int highestFileId = idx.readUnsignedShort();
49 offsets =
new int[highestFileId + 1];
51 for (
int i = 0; i < highestFileId; i++) {
52 final int size = idx.readUnsignedShort();
53 if (size == -1 || size == 65535) {
62 npcDefCache =
new CacheNpcDefinition[20];
64 for (
int k = 0; k < 20; k++) {
65 npcDefCache[k] =
new CacheNpcDefinition();
69 public static CacheNpcDefinition
lookup(
int npcId) {
70 for (
int cacheIndex = 0; cacheIndex < 20; cacheIndex++)
71 if (npcDefCache[cacheIndex].interfaceType == (
long) npcId)
72 return npcDefCache[cacheIndex];
74 nextNpcDefCacheIndex = (nextNpcDefCacheIndex + 1) % 20;
75 CacheNpcDefinition entityDef = npcDefCache[nextNpcDefCacheIndex] =
new CacheNpcDefinition();
76 buffer.position = offsets[npcId];
77 entityDef.interfaceType = npcId;
78 entityDef.decode(buffer);
79 if (entityDef.combatLevel == 0) {
80 entityDef.combatLevel = 1;
85 entityDef.actions =
new String[5];
86 entityDef.actions[0] =
"Talk-to";
87 entityDef.actions[2] =
"Trade";
88 entityDef.actions[3] =
"Skull";
89 entityDef.name =
"Darth Pker";
90 entityDef.description =
"The hunter of bounties".getBytes();
93 entityDef.actions =
new String[5];
94 entityDef.actions[0] =
"Talk-to";
95 entityDef.actions[2] =
"Pick-up";
96 entityDef.standingAnimation = 813;
97 entityDef.walkingAnimation = 1146;
98 entityDef.widthScale = 85;
99 entityDef.heightScale = 85;
100 entityDef.name =
"Baby Darth";
101 entityDef.description =
"The baby hunter of bounties".getBytes();
104 entityDef.actions =
new String[5];
105 entityDef.actions[0] =
"Open";
108 entityDef.name =
"Tarnish Vote Agent";
109 entityDef.actions =
new String[5];
110 entityDef.actions[0] =
"Talk-to";
111 entityDef.actions[2] =
"Trade";
114 entityDef.name =
"Shady Insurance Agent";
115 entityDef.actions =
new String[5];
116 entityDef.actions[0] =
"Talk-to";
117 entityDef.actions[2] =
"Open";
120 entityDef.actions =
new String[5];
121 entityDef.actions[0] =
"Open";
124 entityDef.name =
"Melee store";
125 entityDef.actions =
new String[5];
126 entityDef.actions[0] =
"Open";
129 entityDef.name =
"Beginner Shops";
130 entityDef.actions =
new String[5];
131 entityDef.actions[0] =
"Open";
134 entityDef.name =
"Magic store";
135 entityDef.actions =
new String[5];
136 entityDef.actions[0] =
"Open";
140 entityDef.name =
"Ensouled Hunter";
144 entityDef.name =
"Shimps & Anchovies";
145 entityDef.actions =
new String[5];
146 entityDef.actions[0] =
"Net";
149 entityDef.name =
"Trout & Salmon";
150 entityDef.actions =
new String[5];
151 entityDef.actions[0] =
"Bait";
154 entityDef.actions =
new String[5];
155 entityDef.actions[0] =
"Talk-to";
156 entityDef.actions[2] =
"Trade";
157 entityDef.actions[3] =
"Claim-armour";
160 entityDef.name =
"Lobster & Swordfish";
163 entityDef.name =
"Tarnish Skillermen";
166 entityDef.name =
"Shark";
169 entityDef.name =
"Manta ray";
170 entityDef.actions =
new String[5];
171 entityDef.actions[0] =
"Big Net";
174 entityDef.name =
"Monkfish";
175 entityDef.actions =
new String[5];
176 entityDef.actions[0] =
"Net";
179 entityDef.name =
"Dark crab";
182 entityDef.actions =
new String[5];
183 entityDef.actions[0] =
"Bank";
186 entityDef.actions =
new String[5];
187 entityDef.actions[0] =
"Talk-to";
188 entityDef.actions[2] =
"Trade";
193 entityDef.actions =
new String[5];
194 entityDef.actions[0] =
"Talk-to";
195 entityDef.actions[2] =
"Dismiss";
198 entityDef.actions =
new String[5];
199 entityDef.actions[0] =
"Open";
200 entityDef.actions[3] =
"Trade";
204 entityDef.actions =
new String[5];
205 entityDef.actions[0] =
"Tan";
206 entityDef.actions[2] =
"Trade";
210 entityDef.name =
"Clanmaster";
211 entityDef.actions =
new String[5];
212 entityDef.actions[0] =
"Open";
216 entityDef.name =
"Clothing store";
217 entityDef.actions =
new String[5];
218 entityDef.actions[0] =
"Open";
223 entityDef.name =
"Pure store";
224 entityDef.actions =
new String[5];
225 entityDef.actions[0] =
"Open";
230 entityDef.name =
"Mage store";
231 entityDef.actions =
new String[5];
232 entityDef.actions[0] =
"Open";
237 entityDef.name =
"Range store";
238 entityDef.actions =
new String[5];
239 entityDef.actions[0] =
"Open";
246 entityDef.actions =
new String[5];
247 entityDef.actions[1] =
"Attack";
252 entityDef.name =
"Skilling store";
253 entityDef.actions =
new String[5];
254 entityDef.actions[0] =
"Open";
259 entityDef.name =
"Hunter store";
260 entityDef.actions =
new String[5];
261 entityDef.actions[0] =
"Open";
266 entityDef.name =
"Consumable store";
267 entityDef.actions =
new String[5];
268 entityDef.actions[0] =
"Open";
273 entityDef.name =
"Farming store";
274 entityDef.actions =
new String[5];
275 entityDef.actions[0] =
"Open";
280 entityDef.actions =
new String[5];
281 entityDef.actions[0] =
"Talk-to";
282 entityDef.actions[2] =
"Trade";
287 entityDef.actions =
new String[5];
288 entityDef.actions[0] =
"Talk-to";
289 entityDef.actions[2] =
"Bank";
294 entityDef.name =
"Vote";
295 entityDef.actions =
new String[5];
296 entityDef.actions[0] =
"Talk-to";
297 entityDef.actions[2] =
"Trade";
298 entityDef.actions[3] =
"Claim";
303 entityDef.name =
"Spellbook";
304 entityDef.actions =
new String[5];
305 entityDef.actions[0] =
"Change";
310 entityDef.name =
"The Donator King";
311 entityDef.actions =
new String[5];
312 entityDef.actions[0] =
"Talk-to";
313 entityDef.actions[2] =
"Open-store";
314 entityDef.actions[3] =
"Claim-purchase";
315 entityDef.description =
"What more is there to say about The Donator King?.".getBytes();
319 entityDef.name =
"Tarnish Guide";
322 entityDef.name =
"Skilling Shop";
325 entityDef.name =
"Skilling Store";
330 entityDef.actions =
new String[5];
331 entityDef.actions[0] =
"Makeover";
336 entityDef.name =
"Merchant";
337 entityDef.actions =
new String[5];
338 entityDef.actions[0] =
"Sell goods";
344 entityDef.actions =
new String[5];
345 entityDef.actions[0] =
"Trade";
348 entityDef.actions =
new String[5];
349 entityDef.actions[0] =
"Talk-to";
352 entityDef.actions =
new String[5];
353 entityDef.actions[0] =
"Exchange for firecape";
359 entityDef.actions =
new String[5];
360 entityDef.actions[0] =
"Talk-to";
361 entityDef.actions[2] =
"Open-interface";
362 entityDef.actions[3] =
"Offer-items";
365 entityDef.name =
"Void Knight";
366 entityDef.combatLevel = 0;
367 entityDef.actions =
new String[5];
368 entityDef.actions[1] =
"Attack";
371 entityDef.name =
"Skilling Store";
372 entityDef.combatLevel = 0;
373 entityDef.actions =
new String[2];
374 entityDef.actions[1] =
"Talk-to";
375 entityDef.actions[1] =
"Trade";
379 entityDef.name =
"Polly";
380 entityDef.description =
"She takes pride in prestiging.".getBytes();
381 entityDef.actions =
new String[5];
382 entityDef.actions[0] =
"Talk-to";
383 entityDef.actions[2] =
"Trade";
384 entityDef.actions[3] =
"Prestige-panel";
385 entityDef.actions[4] =
"Perk-information";
386 entityDef.walkingAnimation = 819;
387 entityDef.standingAnimation = 808;
388 entityDef.modelIds =
new int[10];
389 entityDef.modelIds[0] = 391;
390 entityDef.modelIds[1] = 414;
391 entityDef.modelIds[2] = 18983;
392 entityDef.modelIds[3] = 361;
393 entityDef.modelIds[4] = 356;
394 entityDef.modelIds[5] = 556;
395 entityDef.modelIds[6] = 332;
396 entityDef.modelIds[7] = 474;
397 entityDef.modelIds[8] = 433;
398 entityDef.modelIds[9] = 16348;
399 entityDef.recolorTarget =
new int[]{127, 127, 127, 127, 9168, -22419, 9143, 9168, 9143, 7744, 127, 127};
400 entityDef.recolorOriginal =
new int[]{4626, 10128, 10004, 5018, 61, 10351, 57280, 54183, 54503, 6798, 8741, 25238};
403 entityDef.name =
"Mac";
404 entityDef.description =
"Only the most knowledgeable players of Tarnish are worthy of such a cape.".getBytes();
405 entityDef.combatLevel = 126;
406 entityDef.walkingAnimation = 819;
408 entityDef.actions =
new String[5];
409 entityDef.actions[0] =
"Talk-to";
410 entityDef.modelIds =
new int[8];
411 entityDef.modelIds[0] = 29615;
412 entityDef.modelIds[1] = 29618;
413 entityDef.modelIds[2] = 29621;
414 entityDef.modelIds[3] = 29616;
415 entityDef.modelIds[4] = 29620;
416 entityDef.modelIds[5] = 176;
417 entityDef.modelIds[6] = 29619;
418 entityDef.modelIds[7] = 29622;
421 entityDef.actions =
new String[5];
422 entityDef.modelIds =
new int[9];
423 entityDef.modelIds[0] = 27636;
424 entityDef.modelIds[1] = 27625;
425 entityDef.modelIds[2] = 13307;
426 entityDef.modelIds[3] = 28826;
427 entityDef.modelIds[4] = 29250;
428 entityDef.modelIds[5] = 32678;
429 entityDef.modelIds[6] = 14424;
430 entityDef.modelIds[7] = 31227;
431 entityDef.modelIds[8] = 29616;
432 entityDef.standingAnimation = 7518;
433 entityDef.walkingAnimation = 7520;
434 entityDef.recolorOriginal =
new int[]{668, 675, 673, 815, 784};
435 entityDef.recolorTarget =
new int[]{947, 960, 7104, 8146, 0};
436 entityDef.name =
"Donator Guard";
437 entityDef.combatLevel = 420;
438 entityDef.description =
"The protector of the donator zone.".getBytes();
445 public void decode(
Buffer stream) {
448 int opcode = stream.readUnsignedByte();
452 int j = stream.readUnsignedByte();
453 modelIds =
new int[j];
454 for (
int j1 = 0; j1 < j; j1++)
455 modelIds[j1] = stream.readUnsignedShort();
457 }
else if (opcode == 2) {
458 name = stream.readStringCp1252NullTerminated();
459 }
else if (opcode == 3)
460 description = stream.readBytes();
461 else if (opcode == 12)
462 size = stream.readSignedByte();
463 else if (opcode == 13)
464 standingAnimation = stream.readUnsignedShort();
465 else if (opcode == 14)
466 walkingAnimation = stream.readUnsignedShort();
467 else if (opcode == 15)
468 stream.readUnsignedShort();
469 else if (opcode == 16)
470 stream.readUnsignedShort();
471 else if (opcode == 17) {
472 walkingAnimation = stream.readUnsignedShort();
473 halfTurnAnimation = stream.readUnsignedShort();
474 quarterClockwiseTurnAnimation = stream.readUnsignedShort();
475 quarterAnticlockwiseTurnAnimation = stream.readUnsignedShort();
476 if (halfTurnAnimation == 65535) {
477 halfTurnAnimation = walkingAnimation;
479 if (quarterClockwiseTurnAnimation == 65535) {
480 quarterClockwiseTurnAnimation = walkingAnimation;
482 if (quarterAnticlockwiseTurnAnimation == 65535) {
483 quarterAnticlockwiseTurnAnimation = walkingAnimation;
485 }
else if (opcode == 18) {
486 stream.readUnsignedShort();
487 }
else if (opcode >= 30 && opcode < 35) {
489 actions =
new String[5];
490 actions[opcode - 30] = stream.readStringCp1252NullTerminated();
491 if (actions[opcode - 30].equalsIgnoreCase(
"hidden"))
492 actions[opcode - 30] =
null;
493 }
else if (opcode == 40) {
494 int colors = stream.readUnsignedByte();
495 recolorOriginal =
new int[colors];
496 recolorTarget =
new int[colors];
497 for (
int k1 = 0; k1 < colors; k1++) {
498 recolorOriginal[k1] = stream.readUnsignedShort();
499 recolorTarget[k1] = stream.readUnsignedShort();
501 }
else if (opcode == 41) {
502 int length = stream.readUnsignedByte();
504 for (
int index = 0; index < length; index++) {
505 stream.readUnsignedShort();
506 stream.readUnsignedShort();
508 }
else if (opcode == 60) {
509 int l = stream.readUnsignedByte();
510 anIntArray73 =
new int[l];
511 for (
int l1 = 0; l1 < l; l1++)
512 anIntArray73[l1] = stream.readUnsignedShort();
514 }
else if (opcode == 90)
515 stream.readUnsignedShort();
516 else if (opcode == 91)
517 stream.readUnsignedShort();
518 else if (opcode == 92)
519 stream.readUnsignedShort();
520 else if (opcode == 93)
522 else if (opcode == 95)
523 combatLevel = stream.readUnsignedShort();
524 else if (opcode == 97)
525 widthScale = stream.readUnsignedShort();
526 else if (opcode == 98)
527 heightScale = stream.readUnsignedShort();
528 else if (opcode == 99)
530 else if (opcode == 100)
531 lightModifier = stream.readSignedByte();
532 else if (opcode == 101)
533 shadowModifier = stream.readSignedByte() * 5;
534 else if (opcode == 102) {
535 int bitfield = stream.readUnsignedByte();
537 for (
int var5 = bitfield; var5 != 0; var5 >>= 1) {
541 int[] headIconArchiveIds =
new int[len];
542 short[] headIconSpriteIndex =
new short[len];
544 for (
int i = 0; i < len; i++) {
545 if ((bitfield & 1 << i) == 0) {
546 headIconArchiveIds[i] = -1;
547 headIconSpriteIndex[i] = -1;
549 headIconArchiveIds[i] = stream.readBigSmart2();
550 headIconSpriteIndex[i] = (short) stream.readUnsignedShortSmartMinusOne();
554 headIconSprite = headIconSpriteIndex[0];
555 }
else if (opcode == 103) {
556 rotation = stream.readUnsignedShort();
557 }
else if (opcode == 106) {
558 transformVarbit = stream.readUnsignedShort();
559 if (transformVarbit == 65535) {
560 transformVarbit = -1;
563 transformVarp = stream.readUnsignedShort();
564 if (transformVarp == 65535) {
570 int length = stream.readUnsignedByte();
571 childrenIDs =
new int[length + 2];
573 for (
int index = 0; index <= length; index++) {
574 childrenIDs[index] = stream.readUnsignedShort();
575 if (childrenIDs[index] == 65535) {
576 childrenIDs[index] = -1;
580 childrenIDs[length + 1] = var;
581 }
else if (opcode == 107) {
582 isInteractable =
false;
583 }
else if (opcode == 109) {
585 }
else if (opcode == 111) {
587 }
else if (opcode == 114) {
588 stream.readUnsignedShort();
589 }
else if (opcode == 115) {
590 stream.readUnsignedShort();
591 stream.readUnsignedShort();
592 stream.readUnsignedShort();
593 stream.readUnsignedShort();
594 }
else if (opcode == 116) {
595 stream.readUnsignedShort();
596 }
else if (opcode == 117) {
597 stream.readUnsignedShort();
598 stream.readUnsignedShort();
599 stream.readUnsignedShort();
600 stream.readUnsignedShort();
601 }
else if (opcode == 118) {
602 transformVarbit = stream.readUnsignedShort();
603 if (transformVarbit == 65535) {
604 transformVarbit = -1;
607 transformVarp = stream.readUnsignedShort();
608 if (transformVarp == 65535) {
612 int var = stream.readUnsignedShort();
617 int length = stream.readUnsignedByte();
618 childrenIDs =
new int[length + 2];
620 for (
int index = 0; index <= length; index++) {
621 childrenIDs[index] = stream.readUnsignedShort();
622 if (childrenIDs[index] == 65535) {
623 childrenIDs[index] = -1;
627 childrenIDs[length + 1] = var;
628 }
else if (opcode == 249) {
629 int length = stream.readUnsignedByte();
631 for (
int i = 0; i < length; i++) {
632 boolean isString = stream.readUnsignedByte() == 1;
633 stream.readUnsignedTriByte();
636 stream.readStringCp1252NullTerminated();
638 stream.readUnsignedInt();
642 System.out.println(
"Unrecognized NPC opcode " + opcode +
", last=" + lastOpcode);
649 public CacheNpcDefinition() {
650 quarterAnticlockwiseTurnAnimation = -1;
651 transformVarbit = -1;
652 halfTurnAnimation = -1;
656 walkingAnimation = -1;
659 standingAnimation = -1;
662 quarterClockwiseTurnAnimation = -1;
663 isInteractable =
true;
670 public int quarterAnticlockwiseTurnAnimation;
671 public static int nextNpcDefCacheIndex;
672 public int transformVarbit;
673 public int halfTurnAnimation;
674 public int transformVarp;
675 public static Buffer buffer;
676 public int combatLevel;
677 public final int anInt64;
679 public String[] actions;
680 public int walkingAnimation;
682 public int[] recolorTarget;
683 public static int[] offsets;
684 public int[] anIntArray73;
685 public int headIconSprite;
686 public int[] recolorOriginal;
687 public int standingAnimation;
688 public long interfaceType;
690 public static CacheNpcDefinition[] npcDefCache;
691 public int quarterClockwiseTurnAnimation;
692 public boolean isInteractable;
693 public int lightModifier;
694 public int heightScale;
695 public boolean drawMapDot;
696 public int[] childrenIDs;
697 public byte[] description;
698 public int widthScale;
699 public int shadowModifier;
700 public boolean isVisible;
701 public int[] modelIds;
702 public int interfaceZoom = 0;
705 public String toString() {
706 return "NpcDefinition{" +
707 "quarterAnticlockwiseTurnAnimation=" + quarterAnticlockwiseTurnAnimation +
708 ", transformVarbit=" + transformVarbit +
709 ", halfTurnAnimation=" + halfTurnAnimation +
710 ", transformVarp=" + transformVarp +
711 ", combatLevel=" + combatLevel +
712 ", anInt64=" + anInt64 +
713 ", name='" + name +
'\'' +
714 ", actions=" + Arrays.toString(actions) +
715 ", walkingAnimation=" + walkingAnimation +
717 ", recolorTarget=" + Arrays.toString(recolorTarget) +
718 ", anIntArray73=" + Arrays.toString(anIntArray73) +
719 ", anInt75=" + headIconSprite +
720 ", recolorOriginal=" + Arrays.toString(recolorOriginal) +
721 ", standingAnimation=" + standingAnimation +
722 ", interfaceType=" + interfaceType +
723 ", rotation=" + rotation +
724 ", quarterClockwiseTurnAnimation=" + quarterClockwiseTurnAnimation +
725 ", isInteractable=" + isInteractable +
726 ", lightModifier=" + lightModifier +
727 ", scaleY=" + heightScale +
728 ", drawMapDot=" + drawMapDot +
729 ", childrenIDs=" + Arrays.toString(childrenIDs) +
730 ", description=" + Arrays.toString(description) +
731 ", scaleXZ=" + widthScale +
732 ", shadowModifier=" + shadowModifier +
733 ", isVisible=" + isVisible +
734 ", modelId=" + Arrays.toString(modelIds) +
735 ", interfaceZoom=" + interfaceZoom +