From f5664a9ce93a7aa0041e47a2028ca90d6d0a90de Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Tue, 31 May 2022 17:44:41 +1000 Subject: [PATCH] Updated Item --- README.md | 2 +- .../diskbrowser/utilities/Utility.java | 1 - .../diskbrowser/wizardry/CharacterV1.java | 10 +- .../diskbrowser/wizardry/CharacterV4.java | 4 +- .../bytezone/diskbrowser/wizardry/Item.java | 206 +++++-------- .../bytezone/diskbrowser/wizardry/ItemV1.java | 163 ++++++++++ .../bytezone/diskbrowser/wizardry/ItemV4.java | 18 +- .../diskbrowser/wizardry/MazeCell.java | 8 +- .../diskbrowser/wizardry/MazeLevel.java | 20 +- .../diskbrowser/wizardry/Monster.java | 282 +++--------------- .../diskbrowser/wizardry/MonsterV1.java | 233 +++++++++++++++ .../diskbrowser/wizardry/MonsterV4.java | 41 ++- .../bytezone/diskbrowser/wizardry/Reward.java | 14 +- .../wizardry/Wizardry4BootDisk.java | 8 + .../wizardry/WizardryScenarioDisk.java | 21 +- 15 files changed, 611 insertions(+), 420 deletions(-) mode change 100755 => 100644 src/com/bytezone/diskbrowser/wizardry/Item.java create mode 100755 src/com/bytezone/diskbrowser/wizardry/ItemV1.java mode change 100755 => 100644 src/com/bytezone/diskbrowser/wizardry/Monster.java create mode 100755 src/com/bytezone/diskbrowser/wizardry/MonsterV1.java diff --git a/README.md b/README.md index c767118..2895192 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ For the truly retro look, programs can be displayed in the [original 40-column l #### Infocom ![Infocom](resources/zork.png?raw=true "Infocom") #### Wizardry -Wizardry scenarios 1 to 3 are reasonably complete, Wizardry IV and V are partially done. For a dedicated Wizardry application see [WizardryApp](https://github.com/dmolony/MazeWalker) +Wizardry scenarios 1 to 3 are reasonably complete, Wizardry IV and V are partially done. For a dedicated Wizardry application see [WizardryApp](https://github.com/dmolony/MazeWalker). ![Wizardry](resources/wizardry.png?raw=true "Wizardry") Scenarios 4 and 5 come on multiple disks, and they need to be named so that the only difference between disk names is the identifier before the '.dsk' suffix. ![Wizardry](resources/wizardry4.png?raw=true "Wizardry IV") diff --git a/src/com/bytezone/diskbrowser/utilities/Utility.java b/src/com/bytezone/diskbrowser/utilities/Utility.java index 2a34415..e23a61f 100644 --- a/src/com/bytezone/diskbrowser/utilities/Utility.java +++ b/src/com/bytezone/diskbrowser/utilities/Utility.java @@ -47,7 +47,6 @@ public final class Utility private Utility () // ---------------------------------------------------------------------------------// { - } // ---------------------------------------------------------------------------------// diff --git a/src/com/bytezone/diskbrowser/wizardry/CharacterV1.java b/src/com/bytezone/diskbrowser/wizardry/CharacterV1.java index b95672c..9529c4d 100755 --- a/src/com/bytezone/diskbrowser/wizardry/CharacterV1.java +++ b/src/com/bytezone/diskbrowser/wizardry/CharacterV1.java @@ -75,7 +75,7 @@ class CharacterV1 extends Character } // ---------------------------------------------------------------------------------// - public void linkItems (List itemList) + public void linkItems (List itemList) // ---------------------------------------------------------------------------------// { boolean equipped; @@ -90,12 +90,12 @@ class CharacterV1 extends Character itemID = (itemID + 24) % 256; if (itemID >= 0 && itemID < itemList.size ()) { - Item item = itemList.get (itemID); + ItemV1 item = itemList.get (itemID); equipped = (buffer[ptr] == 1); identified = (buffer[ptr + 4] == 1); baggageList.add (new Baggage (item, equipped, identified)); stats.assetValue += item.getCost (); - item.partyOwns++; + // item.partyOwns++; } else System.out.println ( @@ -302,11 +302,11 @@ class CharacterV1 extends Character public class Baggage // ---------------------------------------------------------------------------------// { - public Item item; + public ItemV1 item; public boolean equipped; public boolean identified; - public Baggage (Item item, boolean equipped, boolean identified) + public Baggage (ItemV1 item, boolean equipped, boolean identified) { this.item = item; this.equipped = equipped; diff --git a/src/com/bytezone/diskbrowser/wizardry/CharacterV4.java b/src/com/bytezone/diskbrowser/wizardry/CharacterV4.java index 42720cc..e52922c 100644 --- a/src/com/bytezone/diskbrowser/wizardry/CharacterV4.java +++ b/src/com/bytezone/diskbrowser/wizardry/CharacterV4.java @@ -270,8 +270,8 @@ public class CharacterV4 extends Character text.append (party); } - // text.append ("\n\n"); - // text.append (HexFormatter.format (buffer, 1, buffer[0] & 0xFF)); + text.append ("\n\n"); + text.append (HexFormatter.format (buffer, 1, buffer[0] & 0xFF)); return text.toString (); } diff --git a/src/com/bytezone/diskbrowser/wizardry/Item.java b/src/com/bytezone/diskbrowser/wizardry/Item.java old mode 100755 new mode 100644 index 2d84255..b2ceb82 --- a/src/com/bytezone/diskbrowser/wizardry/Item.java +++ b/src/com/bytezone/diskbrowser/wizardry/Item.java @@ -1,36 +1,53 @@ package com.bytezone.diskbrowser.wizardry; import com.bytezone.diskbrowser.applefile.AbstractFile; -import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.utilities.Utility; // -----------------------------------------------------------------------------------// -class Item extends AbstractFile implements Comparable +public class Item extends AbstractFile // -----------------------------------------------------------------------------------// { - public final int itemID; - private final int type; - private final long cost; - public int partyOwns; + int itemId; String genericName; - static int counter = 0; - public final Dice damage; - public final int armourClass; - public final int speed; + protected long price; + public Dice wephpdam; + public int armourClass; + public int xtraSwing; + boolean cursed; + int changeTo; + int changeChance; + int special; + int boltac; + int spellPwr; + int classUseFlags; + int healPts; + int wepvstyFlags; + int wepvsty2Flags; + int wepvsty3Flags; + int wephitmd; + boolean crithitm; + + ObjectType type; + Alignment alignment; + + Item changeToItem; + Spell spell; + + public enum Alignment + { + UNALIGN, GOOD, NEUTRAL, EVIL + } + + public enum ObjectType + { + WEAPON, ARMOR, SHIELD, HELMET, GAUNTLET, SPECIAL, MISC + } // ---------------------------------------------------------------------------------// Item (String name, byte[] buffer) // ---------------------------------------------------------------------------------// { super (name, buffer); - itemID = counter++; - genericName = HexFormatter.getPascalString (buffer, 16); - type = buffer[32]; - cost = Utility.getShort (buffer, 44) + Utility.getShort (buffer, 46) * 10000 - + Utility.getShort (buffer, 48) * 100000000L; - armourClass = buffer[62]; - damage = new Dice (buffer, 66); - speed = buffer[72]; // 14 flags } // ---------------------------------------------------------------------------------// @@ -40,127 +57,48 @@ class Item extends AbstractFile implements Comparable { StringBuilder text = new StringBuilder (); - text.append ("Name ......... : " + getName ()); - // int length = HexFormatter.intValue (buffer[16]); - text.append ("\nGeneric name . : " + genericName); - text.append ("\nType ......... : " + type); - text.append ("\nCost ......... : " + cost); - text.append ("\nArmour class . : " + armourClass); - text.append ("\nDamage ....... : " + damage); - text.append ("\nSpeed ........ : " + speed); - text.append ("\nCursed? ...... : " + isCursed ()); - int stock = getStockOnHand (); - text.append ("\nStock on hand : " + stock); - if (stock < 0) - text.append (" (always in stock)"); + text.append (String.format ("ID ............... %s%n%n", itemId)); + text.append (String.format ("Name ............. %s%n", name)); + text.append (String.format ("Generic name ..... %s%n", genericName)); + + text.append (String.format ("Cost ............. %,d%n", price)); + text.append (String.format ("Damage ........... %s%n", wephpdam)); + text.append (String.format ("Hit mod .......... %d%n", wephitmd)); + text.append (String.format ("Critical hit ..... %s%n", crithitm)); + + text.append (String.format ("Type ............. %s%n", type)); + text.append (String.format ("Alignment ........ %s%n", alignment)); + text.append (String.format ("Armour class ..... %d%n", armourClass)); + text.append (String.format ("Speed ............ %d%n", xtraSwing)); + text.append (String.format ("Cursed? .......... %s%n", cursed)); + + String changeItemName = changeToItem == null ? "" : changeToItem.getName (); + text.append (String.format ("Decay odds ....... %d%%%n", changeChance)); + text.append (String.format ("Decay to ......... %s%n", changeItemName)); + + text.append (String.format ("Special .......... %d%n", special)); + text.append (String.format ("Boltac ........... %d%n", boltac)); + + String spellName = spell == null ? "" : spell.getName (); + text.append (String.format ("Spell ............ %s%n", spellName)); + + text.append (String.format ("Heal ............. %d%n", healPts)); + text.append (String.format ("Class use ........ %d%n", classUseFlags)); + text.append (String.format ("Flags ............ %d%n", wepvstyFlags)); + text.append (String.format ("Flags2 ........... %d%n", wepvsty2Flags)); + text.append (String.format ("Flags3 ........... %d%n", wepvsty3Flags)); return text.toString (); } // ---------------------------------------------------------------------------------// - public int getType () + int getWizLong (byte[] buffer, int offset) // ---------------------------------------------------------------------------------// { - return type; + int low = Utility.getShort (buffer, offset); + int mid = Utility.getShort (buffer, offset + 2); + int high = Utility.getShort (buffer, offset + 4); + + return high * 100000000 + mid * 10000 + low; } - - // public int getArmourClass () - // { - // return buffer[62]; - // } - - // public int getSpeed () - // { - // return HexFormatter.intValue (buffer[72]); - // } - - // ---------------------------------------------------------------------------------// - public long getCost () - // ---------------------------------------------------------------------------------// - { - return cost; - } - - // ---------------------------------------------------------------------------------// - public boolean isCursed () - // ---------------------------------------------------------------------------------// - { - return buffer[36] != 0; - } - - // ---------------------------------------------------------------------------------// - public int getStockOnHand () - // ---------------------------------------------------------------------------------// - { - if (buffer[50] == -1 && buffer[51] == -1) - return -1; - - return Utility.getShort (buffer, 50); - } - - // ---------------------------------------------------------------------------------// - public boolean canUse (int type2) - // ---------------------------------------------------------------------------------// - { - int users = buffer[54] & 0xFF; - return ((users >>> type2) & 1) == 1; - } - - // ---------------------------------------------------------------------------------// - @Override - public String toString () - // ---------------------------------------------------------------------------------// - { - StringBuilder line = new StringBuilder (); - line.append (String.format ("%-16s", getName ())); - if (buffer[36] == -1) - line.append ("(c) "); - else - line.append (" "); - line.append (String.format ("%02X ", buffer[62])); - line.append (String.format ("%02X ", buffer[34])); - line.append (String.format ("%02X %02X", buffer[50], buffer[51])); - - // if (buffer[50] == -1 && buffer[51] == -1) - // line.append ("* "); - // else - // line.append (HexFormatter.intValue (buffer[50], buffer[51]) + " "); - - for (int i = 38; i < 44; i++) - line.append (HexFormatter.format2 (buffer[i]) + " "); - for (int i = 48; i < 50; i++) - line.append (HexFormatter.format2 (buffer[i]) + " "); - for (int i = 52; i < 62; i++) - line.append (HexFormatter.format2 (buffer[i]) + " "); - // for (int i = 64; i < 78; i++) - // line.append (HexFormatter.format2 (buffer[i]) + " "); - - return line.toString (); - } - - // ---------------------------------------------------------------------------------// - public String getDump (int block) - // ---------------------------------------------------------------------------------// - { - StringBuilder line = new StringBuilder (String.format ("%3d %-16s", itemID, getName ())); - - int lo = block == 0 ? 32 : block == 1 ? 56 : 80; - int hi = lo + 24; - if (hi > buffer.length) - hi = buffer.length; - - for (int i = lo; i < hi; i++) - line.append (String.format ("%02X ", buffer[i])); - - return line.toString (); - } - - // ---------------------------------------------------------------------------------// - @Override - public int compareTo (Item otherItem) - // ---------------------------------------------------------------------------------// - { - Item item = otherItem; - return this.type - item.type; - } -} \ No newline at end of file +} diff --git a/src/com/bytezone/diskbrowser/wizardry/ItemV1.java b/src/com/bytezone/diskbrowser/wizardry/ItemV1.java new file mode 100755 index 0000000..cba9412 --- /dev/null +++ b/src/com/bytezone/diskbrowser/wizardry/ItemV1.java @@ -0,0 +1,163 @@ +package com.bytezone.diskbrowser.wizardry; + +import java.util.List; + +import com.bytezone.diskbrowser.utilities.HexFormatter; +import com.bytezone.diskbrowser.utilities.Utility; + +// -----------------------------------------------------------------------------------// +class ItemV1 extends Item // implements Comparable +// -----------------------------------------------------------------------------------// +{ + // public int partyOwns; + static int counter = 0; + + // ---------------------------------------------------------------------------------// + ItemV1 (String name, byte[] buffer) + // ---------------------------------------------------------------------------------// + { + super (name, buffer); + + itemId = counter++; + genericName = HexFormatter.getPascalString (buffer, 16); + + // type = buffer[32]; + // cost = getWizLong (buffer, 44); + // cost = Utility.getShort (buffer, 44) + Utility.getShort (buffer, 46) * 10000 + // + Utility.getShort (buffer, 48) * 100000000L; + // armourClass = buffer[62]; + // wephpdam = new Dice (buffer, 66); + // xtraSwing = buffer[72]; // 14 flags + + type = ObjectType.values ()[buffer[32]]; + alignment = Alignment.values ()[buffer[34]]; + cursed = Utility.signedShort (buffer, 36) == -1; + special = Utility.signedShort (buffer, 38); + changeTo = Utility.getShort (buffer, 40); // decay # + changeChance = Utility.getShort (buffer, 42); + price = getWizLong (buffer, 44); + boltac = Utility.signedShort (buffer, 50); + spellPwr = Utility.getShort (buffer, 52); + classUseFlags = Utility.getShort (buffer, 54); // 8 flags + + healPts = Utility.signedShort (buffer, 56); + wepvsty2Flags = Utility.getShort (buffer, 58); // 16 flags + wepvsty3Flags = Utility.getShort (buffer, 60); // 16 flags + armourClass = Utility.signedShort (buffer, 62); + wephitmd = Utility.signedShort (buffer, 64); + wephpdam = new Dice (buffer, 66); // Dice + xtraSwing = Utility.getShort (buffer, 72); + crithitm = Utility.getShort (buffer, 74) == 1; // boolean + wepvstyFlags = Utility.getShort (buffer, 76); // 14 flags + } + + // ---------------------------------------------------------------------------------// + void link (List items, List spells) + // ---------------------------------------------------------------------------------// + { + if (changeChance > 0) + changeToItem = items.get (changeTo); + + if (spellPwr > 0) + spell = spells.get (spellPwr - 1); + } + + // ---------------------------------------------------------------------------------// + @Override + public String getText () + // ---------------------------------------------------------------------------------// + { + StringBuilder text = new StringBuilder (super.getText ()); + + // int stock = getStockOnHand (); + // text.append ("\nStock on hand : " + stock); + // if (stock < 0) + // text.append (" (always in stock)"); + + return text.toString (); + } + + // ---------------------------------------------------------------------------------// + public long getCost () + // ---------------------------------------------------------------------------------// + { + return price; + } + + // ---------------------------------------------------------------------------------// + public int getStockOnHand () + // ---------------------------------------------------------------------------------// + { + // if (buffer[50] == -1 && buffer[51] == -1) + // return -1; + // + // return Utility.getShort (buffer, 50); + return boltac; + } + + // ---------------------------------------------------------------------------------// + public boolean canUse (int type2) + // ---------------------------------------------------------------------------------// + { + int users = buffer[54] & 0xFF; + return ((users >>> type2) & 1) == 1; + } + + // ---------------------------------------------------------------------------------// + @Override + public String toString () + // ---------------------------------------------------------------------------------// + { + StringBuilder line = new StringBuilder (); + line.append (String.format ("%-16s", getName ())); + if (buffer[36] == -1) + line.append ("(c) "); + else + line.append (" "); + line.append (String.format ("%02X ", buffer[62])); + line.append (String.format ("%02X ", buffer[34])); + line.append (String.format ("%02X %02X", buffer[50], buffer[51])); + + // if (buffer[50] == -1 && buffer[51] == -1) + // line.append ("* "); + // else + // line.append (HexFormatter.intValue (buffer[50], buffer[51]) + " "); + + for (int i = 38; i < 44; i++) + line.append (HexFormatter.format2 (buffer[i]) + " "); + for (int i = 48; i < 50; i++) + line.append (HexFormatter.format2 (buffer[i]) + " "); + for (int i = 52; i < 62; i++) + line.append (HexFormatter.format2 (buffer[i]) + " "); + // for (int i = 64; i < 78; i++) + // line.append (HexFormatter.format2 (buffer[i]) + " "); + + return line.toString (); + } + + // ---------------------------------------------------------------------------------// + public String getDump (int block) + // ---------------------------------------------------------------------------------// + { + StringBuilder line = new StringBuilder (String.format ("%3d %-16s", itemId, getName ())); + + int lo = block == 0 ? 32 : block == 1 ? 56 : 80; + int hi = lo + 24; + if (hi > buffer.length) + hi = buffer.length; + + for (int i = lo; i < hi; i++) + line.append (String.format ("%02X ", buffer[i])); + + return line.toString (); + } + + // ---------------------------------------------------------------------------------// + // @Override + // public int compareTo (ItemV1 otherItem) + // // ---------------------------------------------------------------------------------// + // { + // ItemV1 item = otherItem; + // return this.type - item.type; + // } +} \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/wizardry/ItemV4.java b/src/com/bytezone/diskbrowser/wizardry/ItemV4.java index 6ea9bd0..991e950 100644 --- a/src/com/bytezone/diskbrowser/wizardry/ItemV4.java +++ b/src/com/bytezone/diskbrowser/wizardry/ItemV4.java @@ -1,14 +1,11 @@ package com.bytezone.diskbrowser.wizardry; -import com.bytezone.diskbrowser.applefile.AbstractFile; import com.bytezone.diskbrowser.utilities.HexFormatter; // -----------------------------------------------------------------------------------// -public class ItemV4 extends AbstractFile +public class ItemV4 extends Item // -----------------------------------------------------------------------------------// { - String name; - String nameGeneric; // ---------------------------------------------------------------------------------// ItemV4 (String[] names, byte[] buffer, int id) @@ -16,8 +13,12 @@ public class ItemV4 extends AbstractFile { super (names[1], buffer); + itemId = id; name = names[1]; - nameGeneric = names[0]; + genericName = names[0]; + + price = getWizLong (buffer, 13); + wephpdam = new Dice (buffer, 35); } // ---------------------------------------------------------------------------------// @@ -25,7 +26,12 @@ public class ItemV4 extends AbstractFile public String getText () // ---------------------------------------------------------------------------------// { - return HexFormatter.format (buffer, 1, buffer[0] & 0xFF); + StringBuilder text = new StringBuilder (super.getText ()); + + text.append ("\n\n"); + text.append (HexFormatter.format (buffer)); + + return text.toString (); } // ---------------------------------------------------------------------------------// diff --git a/src/com/bytezone/diskbrowser/wizardry/MazeCell.java b/src/com/bytezone/diskbrowser/wizardry/MazeCell.java index 8ec4dc8..31a8b5e 100755 --- a/src/com/bytezone/diskbrowser/wizardry/MazeCell.java +++ b/src/com/bytezone/diskbrowser/wizardry/MazeCell.java @@ -50,9 +50,9 @@ class MazeCell MazeAddress addressTo; // if teleport/stairs/chute public MessageV1 message; - public List monsters; - public Item itemRequired; - public Item itemObtained; + public List monsters; + public ItemV1 itemRequired; + public ItemV1 itemObtained; // ---------------------------------------------------------------------------------// MazeCell (MazeAddress address) @@ -345,7 +345,7 @@ class MazeCell sign.append (" Monster "); else { - Monster monster = monsters.get (monsterID); + MonsterV1 monster = monsters.get (monsterID); sign.append (" " + monster.getRealName () + " "); while (monster.partnerOdds == 100) { diff --git a/src/com/bytezone/diskbrowser/wizardry/MazeLevel.java b/src/com/bytezone/diskbrowser/wizardry/MazeLevel.java index 86c9872..330bc17 100755 --- a/src/com/bytezone/diskbrowser/wizardry/MazeLevel.java +++ b/src/com/bytezone/diskbrowser/wizardry/MazeLevel.java @@ -25,8 +25,8 @@ public class MazeLevel extends AbstractFile public final int level; private List messages; - private List monsters; - private List items; + private List monsters; + private List items; // ---------------------------------------------------------------------------------// public MazeLevel (byte[] buffer, int level) @@ -105,7 +105,7 @@ public class MazeLevel extends AbstractFile for (MazeAddress address : monsterList) { - Monster monster = getMonster (address.column); + MonsterV1 monster = getMonster (address.column); if (monster != null) { text.append (String.format ("%nMonster: %04X%n", address.column)); @@ -222,7 +222,7 @@ public class MazeLevel extends AbstractFile if (messageType == 4) { if (address.level < monsters.size ()) - extraText += monsters.get (address.level).realName; + extraText += monsters.get (address.level).getName (); else extraText += "Obtained: " + items.get ((address.level - 64536) * -1).getName (); } @@ -240,7 +240,7 @@ public class MazeLevel extends AbstractFile monsterList.add (address); extraText = "Encounter: "; if (monsters != null) - extraText += monsters.get (address.column).realName; + extraText += monsters.get (address.column).getName (); } text.append (String.format (" %X --> %X %-15s %04X %04X %04X %s%n", j, @@ -288,7 +288,7 @@ public class MazeLevel extends AbstractFile { if (id == minenemy + range0n) text.append ("\n"); - Monster monster = monsters == null ? null : monsters.get (id); + MonsterV1 monster = monsters == null ? null : monsters.get (id); text.append (String.format ("%3d %-16s %n", id, monster)); } } @@ -325,14 +325,14 @@ public class MazeLevel extends AbstractFile } // ---------------------------------------------------------------------------------// - public void setMonsters (List monsters) + public void setMonsters (List monsters) // ---------------------------------------------------------------------------------// { this.monsters = monsters; } // ---------------------------------------------------------------------------------// - public void setItems (List items) + public void setItems (List items) // ---------------------------------------------------------------------------------// { this.items = items; @@ -527,13 +527,13 @@ public class MazeLevel extends AbstractFile } // ---------------------------------------------------------------------------------// - private Monster getMonster (int monsterNo) + private MonsterV1 getMonster (int monsterNo) // ---------------------------------------------------------------------------------// { if (monsters == null) return null; - for (Monster m : monsters) + for (MonsterV1 m : monsters) if (m.match (monsterNo)) return m; diff --git a/src/com/bytezone/diskbrowser/wizardry/Monster.java b/src/com/bytezone/diskbrowser/wizardry/Monster.java old mode 100755 new mode 100644 index 0008134..174029a --- a/src/com/bytezone/diskbrowser/wizardry/Monster.java +++ b/src/com/bytezone/diskbrowser/wizardry/Monster.java @@ -4,122 +4,45 @@ import java.util.ArrayList; import java.util.List; import com.bytezone.diskbrowser.applefile.AbstractFile; -import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.utilities.Utility; // -----------------------------------------------------------------------------------// -class Monster extends AbstractFile +public abstract class Monster extends AbstractFile // -----------------------------------------------------------------------------------// { - int scenarioId; + public static final String[] monsterClass = { "Fighter", "Mage", "Priest", "Thief", "Midget", + "Giant", "Mythical", "Dragon", "Animal", "Were", "Undead", "Demon", "Insect", "Enchanted" }; + protected final String[] breathValues = + { "None", "Fire", "Frost", "Poison", "Level drain", "Stoning", "Magic" }; - public final String genericName; - public final String realName; - public final int monsterID; + public int monsterID; - List monsters; - Reward goldReward; - Reward chestReward; + public String genericName; + public String genericNamePlural; + public String namePlural; - final int type; - final int imageID; + public Dice groupSize; + public Dice hitPoints; + int type; + public int armourClass; + public int recsn; + List damage = new ArrayList<> (); - public final int partnerID; - public final int partnerOdds; - public final int armourClass; - public final int recsn; - public final int mageSpellLevel; - public final int priestSpellLevel; + public int mageSpellLevel; + public int priestSpellLevel; - int experiencePoints; int levelDrain; int healPts; int breathe; int unaffect; - int unique; int resistance; int abilities; - public final Dice groupSize, hitPoints; - List damage = new ArrayList<> (); - - static int counter = 0; - - public static String[] monsterClass = { "Fighter", "Mage", "Priest", "Thief", "Midget", "Giant", - "Mythical", "Dragon", "Animal", "Were", "Undead", "Demon", "Insect", "Enchanted" }; - - // Scenario #1 values - private static int[] experience = { // - 55, 235, 415, 230, 380, 620, 840, 520, 550, 350, // 00-09 - 475, 515, 920, 600, 735, 520, 795, 780, 990, 795, // 10-19 - 1360, 1320, 1275, 680, 960, 600, 755, 1120, 2075, 870, // 20-29 - 960, 600, 1120, 2435, 1080, 2280, 975, 875, 1135, 1200, // 30-39 - 620, 740, 1460, 1245, 960, 1405, 1040, 1220, 1520, 1000, // 40-49 - 960, 2340, 2160, 2395, 790, 1140, 1235, 1790, 1720, 2240, // 50-59 - 1475, 1540, 1720, 1900, 1240, 1220, 1020, 20435, 5100, 3515, // 60-69 - 2115, 2920, 2060, 2140, 1400, 1640, 1280, 4450, 42840, 3300, // 70-79 - 40875, 5000, 3300, 2395, 1935, 1600, 3330, 44090, 40840, 5200, // 80-89 - 4155, 3000, 9200, 3160, 7460, 7320, 15880, 1600, 2200, 1000, // 90-99 - 1900 // 100 - }; - // ---------------------------------------------------------------------------------// - Monster (String name, byte[] buffer, List rewards, List monsters, int scenarioId) + Monster (String name, byte[] buffer) // ---------------------------------------------------------------------------------// { super (name, buffer); - - this.scenarioId = scenarioId; - - realName = name; - genericName = HexFormatter.getPascalString (buffer, 0); - this.monsterID = counter++; - this.monsters = monsters; - - imageID = buffer[64]; - groupSize = new Dice (buffer, 66); - hitPoints = new Dice (buffer, 72); - type = buffer[78]; - armourClass = buffer[80]; - - recsn = buffer[82]; // number of dice - for (int i = 0, ptr = 84; i < 7; i++, ptr += 6) - { - if (buffer[ptr] == 0) - break; - damage.add (new Dice (buffer, ptr)); - } - - experiencePoints = getWizLong (buffer, 126); - levelDrain = buffer[132]; - healPts = buffer[134]; - goldReward = rewards.get (buffer[136]); - chestReward = rewards.get (buffer[138]); - partnerID = buffer[140]; - partnerOdds = buffer[142]; - mageSpellLevel = buffer[144]; - priestSpellLevel = buffer[146]; - - unique = buffer[148]; - breathe = buffer[150]; - unaffect = buffer[152]; - - resistance = buffer[154]; // bit flags - abilities = buffer[156]; // bit flags - - goldReward.addMonster (this, 0); - chestReward.addMonster (this, 1); - } - - // ---------------------------------------------------------------------------------// - private int getWizLong (byte[] buffer, int offset) - // ---------------------------------------------------------------------------------// - { - int low = Utility.getShort (buffer, offset); - int mid = Utility.getShort (buffer, offset + 2); - int high = Utility.getShort (buffer, offset + 4); - - return high * 100000000 + mid * 10000 + low; } // ---------------------------------------------------------------------------------// @@ -129,122 +52,35 @@ class Monster extends AbstractFile { StringBuilder text = new StringBuilder (); - int totalExperience = scenarioId == 1 ? getExperience () : experiencePoints; + text.append (String.format ("ID .............. %d%n%n", monsterID)); + text.append (String.format ("Name ............ %s%n", name)); + text.append (String.format ("Name plural ..... %s%n", namePlural)); + text.append (String.format ("Generic name .... %s%n", genericName)); + text.append (String.format ("Generic name pl . %s%n%n", genericNamePlural)); - text.append ("ID .............. " + monsterID); - text.append ("\nMonster name .... " + realName); - text.append ("\nGeneric name .... " + genericName); + text.append (String.format ("Type ............ %2d %s%n", type, monsterClass[type])); + text.append (String.format ("Armour class .... %d%n", armourClass)); + text.append (String.format ("Group size ...... %s%n", groupSize)); + text.append (String.format ("Hit points ...... %s%n%n", hitPoints)); - text.append ("\n\nImage ID ........ " + imageID); - text.append ("\nGroup size ...... " + groupSize); - text.append ("\nHit points ...... " + hitPoints); + text.append (String.format ("# damage ........ %d%n", recsn)); + text.append (String.format ("Damage .......... %s%n%n", getDamage ())); - text.append ("\n\nMonster class ... " + type + " " + monsterClass[type]); - text.append ("\nArmour class .... " + armourClass); + text.append (String.format ("Mage level ...... %d%n", mageSpellLevel)); + text.append (String.format ("Priest level .... %d%n%n", priestSpellLevel)); - text.append ("\n\n# damage ........ " + recsn); + text.append (String.format ("Level drain ..... %d%n", levelDrain)); + text.append (String.format ("Heal pts ........ %d%n", healPts)); + text.append (String.format ("Breathe ......... %d %s%n", breathe, breathValues[breathe])); + text.append (String.format ("Magic resist .... %d%% %n%n", unaffect)); - text.append ("\nDamage .......... " + getDamage ()); - - text.append ("\n\nLevel drain ..... " + levelDrain); - text.append ("\nHeal pts? ....... " + healPts); - - text.append ("\n\nPartner ID ...... " + partnerID); - if (partnerOdds > 0) - text.append (" " + monsters.get (partnerID).getName ()); - text.append ("\nPartner odds .... " + partnerOdds + "%"); - - text.append ("\n\nMage level ...... " + mageSpellLevel); - text.append ("\nPriest level .... " + priestSpellLevel); - - text.append ("\n\nUnique .......... " + unique); - text.append ("\nBreathe ......... " + breathe); - text.append ("\nUnaffect ........ " + unaffect); - - text.append ("\n\nResistance ...... " + String.format ("%3d %<02X", resistance)); - text.append ("\nAbilities ....... " + String.format ("%3d %<02X", abilities)); - - text.append (String.format ("%n%nExperience ...... %-,7d", totalExperience)); - - text.append (String.format ("%n%n===== Gold reward %2d ======", goldReward.id)); - // text.append ("\nTable ........... " + rewardTable1); - text.append ("\n" + goldReward.getText (false)); - text.append (String.format ("===== Chest reward %2d =====", chestReward.id)); - // text.append ("\nTable ........... " + rewardTable2); - text.append ("\n" + chestReward.getText (false)); - - while (text.charAt (text.length () - 1) == 10) - text.deleteCharAt (text.length () - 1); + text.append ( + String.format ("Resistance ...... %s%n", String.format ("%3d %<02X", resistance))); + text.append (String.format ("Abilities ....... %s%n", String.format ("%3d %<02X", abilities))); return text.toString (); } - // ---------------------------------------------------------------------------------// - private int getExperience () - // ---------------------------------------------------------------------------------// - { - int expHitPoints = hitPoints.qty * hitPoints.sides * (breathe == 0 ? 20 : 40); - int expAc = 40 * (11 - armourClass); - - int expMage = getBonus (35, mageSpellLevel); - int expPriest = getBonus (35, priestSpellLevel); - int expDrain = getBonus (200, levelDrain); - int expHeal = getBonus (90, healPts); - - int expDamage = recsn <= 1 ? 0 : getBonus (30, recsn); - int expUnaffect = unaffect == 0 ? 0 : getBonus (40, (unaffect / 10 + 1)); - - int expFlags1 = getBonus (35, Integer.bitCount (resistance & 0x7E)); // 6 bits - int expFlags2 = getBonus (40, Integer.bitCount (abilities & 0x7F)); // 7 bits - - return expHitPoints + expAc + expMage + expPriest + expDrain + expHeal + expDamage + expUnaffect - + expFlags1 + expFlags2; - } - - // ---------------------------------------------------------------------------------// - private int getBonus (int base, int multiplier) - // ---------------------------------------------------------------------------------// - { - if (multiplier == 0) - return 0; - - int total = base; - while (multiplier > 1) - { - int part = total % 10000; // get the last 4 digits - - multiplier--; - total += total; // double the value - - if (part >= 5000) // mimics the wizardry bug - total += 10000; // yay, free points - } - - return total; - } - - // ---------------------------------------------------------------------------------// - // public void setImage (BufferedImage image) - // // ---------------------------------------------------------------------------------// - // { - // this.image = image; - // } - - // ---------------------------------------------------------------------------------// - @Override - public String getName () - // ---------------------------------------------------------------------------------// - { - return realName; - } - - // ---------------------------------------------------------------------------------// - public String getRealName () - // ---------------------------------------------------------------------------------// - { - return realName; - } - // ---------------------------------------------------------------------------------// public String getDamage () // ---------------------------------------------------------------------------------// @@ -264,43 +100,13 @@ class Monster extends AbstractFile } // ---------------------------------------------------------------------------------// - public String getDump (int block) + int getWizLong (byte[] buffer, int offset) // ---------------------------------------------------------------------------------// { - StringBuilder line = new StringBuilder (String.format ("%3d %-16s", monsterID, realName)); + int low = Utility.getShort (buffer, offset); + int mid = Utility.getShort (buffer, offset + 2); + int high = Utility.getShort (buffer, offset + 4); - int lo = block == 0 ? 64 : block == 1 ? 88 : block == 2 ? 112 : 136; - int hi = lo + 24; - if (hi > buffer.length) - hi = buffer.length; - - for (int i = lo; i < hi; i++) - line.append (String.format ("%02X ", buffer[i])); - - if (block == 3) - if (scenarioId == 1) - { - int exp = getExperience (); - line.append (String.format (" %,6d %,6d", exp, exp - experience[monsterID])); - } - else - line.append (String.format (" %,6d", experiencePoints)); - - return line.toString (); + return high * 100000000 + mid * 10000 + low; } - - // ---------------------------------------------------------------------------------// - public boolean match (int monsterID) - // ---------------------------------------------------------------------------------// - { - return this.monsterID == monsterID; - } - - // ---------------------------------------------------------------------------------// - @Override - public String toString () - // ---------------------------------------------------------------------------------// - { - return realName; - } -} \ No newline at end of file +} diff --git a/src/com/bytezone/diskbrowser/wizardry/MonsterV1.java b/src/com/bytezone/diskbrowser/wizardry/MonsterV1.java new file mode 100755 index 0000000..f1613c2 --- /dev/null +++ b/src/com/bytezone/diskbrowser/wizardry/MonsterV1.java @@ -0,0 +1,233 @@ +package com.bytezone.diskbrowser.wizardry; + +import java.util.List; + +import com.bytezone.diskbrowser.utilities.HexFormatter; + +// -----------------------------------------------------------------------------------// +class MonsterV1 extends Monster +// -----------------------------------------------------------------------------------// +{ + int scenarioId; + + List monsters; + Reward goldReward; + Reward chestReward; + + final int imageID; + + public final int partnerID; + public final int partnerOdds; + public final int armourClass; + + int experiencePoints; + int unique; + + static int counter = 0; + + // Scenario #1 values + private static int[] experience = { // + 55, 235, 415, 230, 380, 620, 840, 520, 550, 350, // 00-09 + 475, 515, 920, 600, 735, 520, 795, 780, 990, 795, // 10-19 + 1360, 1320, 1275, 680, 960, 600, 755, 1120, 2075, 870, // 20-29 + 960, 600, 1120, 2435, 1080, 2280, 975, 875, 1135, 1200, // 30-39 + 620, 740, 1460, 1245, 960, 1405, 1040, 1220, 1520, 1000, // 40-49 + 960, 2340, 2160, 2395, 790, 1140, 1235, 1790, 1720, 2240, // 50-59 + 1475, 1540, 1720, 1900, 1240, 1220, 1020, 20435, 5100, 3515, // 60-69 + 2115, 2920, 2060, 2140, 1400, 1640, 1280, 4450, 42840, 3300, // 70-79 + 40875, 5000, 3300, 2395, 1935, 1600, 3330, 44090, 40840, 5200, // 80-89 + 4155, 3000, 9200, 3160, 7460, 7320, 15880, 1600, 2200, 1000, // 90-99 + 1900 // 100 + }; + + // ---------------------------------------------------------------------------------// + MonsterV1 (String name, byte[] buffer, List rewards, List monsters, + int scenarioId) + // ---------------------------------------------------------------------------------// + { + super (name, buffer); + + this.scenarioId = scenarioId; + + genericName = HexFormatter.getPascalString (buffer, 0); + genericNamePlural = HexFormatter.getPascalString (buffer, 16); + namePlural = HexFormatter.getPascalString (buffer, 48); + + this.monsterID = counter++; + this.monsters = monsters; + + imageID = buffer[64]; + groupSize = new Dice (buffer, 66); + hitPoints = new Dice (buffer, 72); + type = buffer[78]; + armourClass = buffer[80]; + + recsn = buffer[82]; // number of dice + for (int i = 0, ptr = 84; i < 7; i++, ptr += 6) + { + if (buffer[ptr] == 0) + break; + damage.add (new Dice (buffer, ptr)); + } + + experiencePoints = getWizLong (buffer, 126); + levelDrain = buffer[132]; + healPts = buffer[134]; + goldReward = rewards.get (buffer[136]); + chestReward = rewards.get (buffer[138]); + partnerID = buffer[140]; + partnerOdds = buffer[142]; + mageSpellLevel = buffer[144]; + priestSpellLevel = buffer[146]; + + unique = buffer[148]; + breathe = buffer[150]; + unaffect = buffer[152]; + + resistance = buffer[154]; // bit flags + abilities = buffer[156]; // bit flags + + goldReward.addMonster (this, 0); + chestReward.addMonster (this, 1); + } + + // ---------------------------------------------------------------------------------// + @Override + public String getText () + // ---------------------------------------------------------------------------------// + { + StringBuilder text = new StringBuilder (super.getText ()); + + int totalExperience = scenarioId == 1 ? getExperience () : experiencePoints; + + text.append ("\nImage ID ........ " + imageID); + + text.append ("\n\nPartner ID ...... " + partnerID); + if (partnerOdds > 0) + text.append (" " + monsters.get (partnerID).getName ()); + text.append ("\nPartner odds .... " + partnerOdds + "%"); + + text.append ("\n\nUnique .......... " + unique); + + text.append (String.format ("%n%nExperience ...... %-,7d", totalExperience)); + + text.append (String.format ("%n%n===== Gold reward %2d ======", goldReward.id)); + // text.append ("\nTable ........... " + rewardTable1); + text.append ("\n" + goldReward.getText (false)); + text.append (String.format ("===== Chest reward %2d =====", chestReward.id)); + // text.append ("\nTable ........... " + rewardTable2); + text.append ("\n" + chestReward.getText (false)); + + while (text.charAt (text.length () - 1) == 10) + text.deleteCharAt (text.length () - 1); + + return text.toString (); + } + + // ---------------------------------------------------------------------------------// + private int getExperience () + // ---------------------------------------------------------------------------------// + { + int expHitPoints = hitPoints.qty * hitPoints.sides * (breathe == 0 ? 20 : 40); + int expAc = 40 * (11 - armourClass); + + int expMage = getBonus (35, mageSpellLevel); + int expPriest = getBonus (35, priestSpellLevel); + int expDrain = getBonus (200, levelDrain); + int expHeal = getBonus (90, healPts); + + int expDamage = recsn <= 1 ? 0 : getBonus (30, recsn); + int expUnaffect = unaffect == 0 ? 0 : getBonus (40, (unaffect / 10 + 1)); + + int expFlags1 = getBonus (35, Integer.bitCount (resistance & 0x7E)); // 6 bits + int expFlags2 = getBonus (40, Integer.bitCount (abilities & 0x7F)); // 7 bits + + return expHitPoints + expAc + expMage + expPriest + expDrain + expHeal + expDamage + expUnaffect + + expFlags1 + expFlags2; + } + + // ---------------------------------------------------------------------------------// + private int getBonus (int base, int multiplier) + // ---------------------------------------------------------------------------------// + { + if (multiplier == 0) + return 0; + + int total = base; + while (multiplier > 1) + { + int part = total % 10000; // get the last 4 digits + + multiplier--; + total += total; // double the value + + if (part >= 5000) // mimics the wizardry bug + total += 10000; // yay, free points + } + + return total; + } + + // ---------------------------------------------------------------------------------// + // public void setImage (BufferedImage image) + // // ---------------------------------------------------------------------------------// + // { + // this.image = image; + // } + + // ---------------------------------------------------------------------------------// + @Override + public String getName () + // ---------------------------------------------------------------------------------// + { + return name; + } + + // ---------------------------------------------------------------------------------// + public String getRealName () + // ---------------------------------------------------------------------------------// + { + return name; + } + + // ---------------------------------------------------------------------------------// + public String getDump (int block) + // ---------------------------------------------------------------------------------// + { + StringBuilder line = new StringBuilder (String.format ("%3d %-16s", monsterID, name)); + + int lo = block == 0 ? 64 : block == 1 ? 88 : block == 2 ? 112 : 136; + int hi = lo + 24; + if (hi > buffer.length) + hi = buffer.length; + + for (int i = lo; i < hi; i++) + line.append (String.format ("%02X ", buffer[i])); + + if (block == 3) + if (scenarioId == 1) + { + int exp = getExperience (); + line.append (String.format (" %,6d %,6d", exp, exp - experience[monsterID])); + } + else + line.append (String.format (" %,6d", experiencePoints)); + + return line.toString (); + } + + // ---------------------------------------------------------------------------------// + public boolean match (int monsterID) + // ---------------------------------------------------------------------------------// + { + return this.monsterID == monsterID; + } + + // ---------------------------------------------------------------------------------// + @Override + public String toString () + // ---------------------------------------------------------------------------------// + { + return name; + } +} \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/wizardry/MonsterV4.java b/src/com/bytezone/diskbrowser/wizardry/MonsterV4.java index 13c8325..8829fdc 100644 --- a/src/com/bytezone/diskbrowser/wizardry/MonsterV4.java +++ b/src/com/bytezone/diskbrowser/wizardry/MonsterV4.java @@ -1,10 +1,10 @@ package com.bytezone.diskbrowser.wizardry; -import com.bytezone.diskbrowser.applefile.AbstractFile; import com.bytezone.diskbrowser.utilities.HexFormatter; +import com.bytezone.diskbrowser.utilities.Utility; // -----------------------------------------------------------------------------------// -public class MonsterV4 extends AbstractFile +public class MonsterV4 extends Monster // -----------------------------------------------------------------------------------// { // ---------------------------------------------------------------------------------// @@ -12,6 +12,35 @@ public class MonsterV4 extends AbstractFile // ---------------------------------------------------------------------------------// { super (names[2], buffer); + + this.monsterID = id; + + genericName = names[0]; + genericNamePlural = names[1]; + namePlural = names[3]; + + groupSize = new Dice (buffer, 1); + hitPoints = new Dice (buffer, 7); + type = Utility.getShort (buffer, 13); + armourClass = Utility.signedShort (buffer, 15); + + recsn = buffer[17]; // number of dice + for (int i = 0, ptr = 19; i < 7; i++, ptr += 6) + { + if (buffer[ptr] == 0) + break; + damage.add (new Dice (buffer, ptr)); + } + + levelDrain = Utility.getShort (buffer, 61); + healPts = Utility.getShort (buffer, 63); + mageSpellLevel = Utility.getShort (buffer, 65); + priestSpellLevel = Utility.getShort (buffer, 67); + breathe = Utility.getShort (buffer, 69); + unaffect = Utility.getShort (buffer, 71); + + resistance = Utility.getShort (buffer, 73); // bit flags + abilities = Utility.getShort (buffer, 75); // bit flags } // ---------------------------------------------------------------------------------// @@ -19,6 +48,12 @@ public class MonsterV4 extends AbstractFile public String getText () // ---------------------------------------------------------------------------------// { - return HexFormatter.format (buffer, 1, buffer[0] & 0xFF); + StringBuilder text = new StringBuilder (super.getText ()); + + text.append ("\n\n"); + // text.append (HexFormatter.format (buffer, 1, buffer[0] & 0xFF)); + text.append (HexFormatter.format (buffer)); + + return text.toString (); } } diff --git a/src/com/bytezone/diskbrowser/wizardry/Reward.java b/src/com/bytezone/diskbrowser/wizardry/Reward.java index e55b25c..ebb7bf0 100755 --- a/src/com/bytezone/diskbrowser/wizardry/Reward.java +++ b/src/com/bytezone/diskbrowser/wizardry/Reward.java @@ -16,12 +16,12 @@ class Reward extends AbstractFile int totalElements; List elements; - List items; - List goldMonsters = new ArrayList<> (); - List chestMonsters = new ArrayList<> (); + List items; + List goldMonsters = new ArrayList<> (); + List chestMonsters = new ArrayList<> (); // ---------------------------------------------------------------------------------// - Reward (String name, byte[] buffer, int id, List items) + Reward (String name, byte[] buffer, int id, List items) // ---------------------------------------------------------------------------------// { super (name, buffer); @@ -41,7 +41,7 @@ class Reward extends AbstractFile } // ---------------------------------------------------------------------------------// - public void addMonster (Monster monster, int location) + public void addMonster (MonsterV1 monster, int location) // ---------------------------------------------------------------------------------// { if (location == 0) @@ -71,14 +71,14 @@ class Reward extends AbstractFile if (goldMonsters.size () > 0) { text.append ("Without chest:\n\n"); - for (Monster m : goldMonsters) + for (MonsterV1 m : goldMonsters) text.append (" " + m + "\n"); text.append ("\n"); } if (chestMonsters.size () > 0) { text.append ("With chest:\n\n"); - for (Monster m : chestMonsters) + for (MonsterV1 m : chestMonsters) text.append (" " + m + "\n"); } } diff --git a/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java b/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java index 2c104f2..ccfe466 100644 --- a/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java +++ b/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java @@ -30,6 +30,7 @@ public class Wizardry4BootDisk extends PascalDisk private List characters = new ArrayList<> (); private List parties = new ArrayList<> (); private List items = new ArrayList<> (); + private List monsters = new ArrayList<> (); // ---------------------------------------------------------------------------------// public Wizardry4BootDisk (AppleDisk[] dataDisks) @@ -232,11 +233,15 @@ public class Wizardry4BootDisk extends PascalDisk for (int i = 0; i < sd.total; i++) { byte[] out = huffman.decodeMessage (buffer, ptr, sd.totalBlocks); + int len = out[0] & 0xFF; + if (len > out.length) + System.out.printf ("Decoded array too short: (#%3d) %3d > %3d%n", i, len, out.length); for (int j = 0; j < monsterNames.length; j++) monsterNames[j] = messageBlock.getMessageLine (i * 4 + 13000 + j); MonsterV4 monster = new MonsterV4 (monsterNames, out, i); + monsters.add (monster); List monsterBlocks = new ArrayList<> (); DiskAddress da = blocks.get (ptr / 512); @@ -299,6 +304,9 @@ public class Wizardry4BootDisk extends PascalDisk for (CharacterV4 character : characters) character.addPossessions (items); + + // for (ItemV4 item : items) + // item.link (items, spells); } // ---------------------------------------------------------------------------------// diff --git a/src/com/bytezone/diskbrowser/wizardry/WizardryScenarioDisk.java b/src/com/bytezone/diskbrowser/wizardry/WizardryScenarioDisk.java index 351665e..93bfc09 100755 --- a/src/com/bytezone/diskbrowser/wizardry/WizardryScenarioDisk.java +++ b/src/com/bytezone/diskbrowser/wizardry/WizardryScenarioDisk.java @@ -30,11 +30,11 @@ public class WizardryScenarioDisk extends PascalDisk public Header scenarioHeader; public List images; - public List items; + public List items; public List characters; public List spells; public List messages; - public List monsters; + public List monsters; public List levels; List experiences; List rewards; @@ -70,8 +70,8 @@ public class WizardryScenarioDisk extends PascalDisk } CodedMessage.codeOffset = 185; - Monster.counter = 0; - Item.counter = 0; + MonsterV1.counter = 0; + ItemV1.counter = 0; DefaultTreeModel model = (DefaultTreeModel) catalogTree.getModel (); DefaultMutableTreeNode currentRoot = (DefaultMutableTreeNode) model.getRoot (); @@ -118,6 +118,9 @@ public class WizardryScenarioDisk extends PascalDisk int type = c.getStatistics ().typeInt; c.linkExperience (experiences.get (type)); } + + for (ItemV1 item : items) + item.link (items, spells); } // ---------------------------------------------------------------------------------// @@ -318,7 +321,7 @@ public class WizardryScenarioDisk extends PascalDisk for (int i = 0; i < 24; i++) text.append (" --"); text.append ("\n"); - for (Monster m : monsters) + for (MonsterV1 m : monsters) text.append (m.getDump (block) + "\n"); text.append ("\n"); } @@ -343,7 +346,7 @@ public class WizardryScenarioDisk extends PascalDisk byte[] data2 = new byte[recLen]; System.arraycopy (buffer, ptr, data2, 0, recLen); - Monster m = new Monster (itemName, data2, rewards, monsters, scenarioHeader.scenarioID); + MonsterV1 m = new MonsterV1 (itemName, data2, rewards, monsters, scenarioHeader.scenarioID); monsters.add (m); addToNode (m, node, blocks, monsterSector); } @@ -376,7 +379,7 @@ public class WizardryScenarioDisk extends PascalDisk for (int i = 0; i < 24; i++) text.append (" --"); text.append ("\n"); - for (Item item : items) + for (ItemV1 item : items) text.append (item.getDump (block) + "\n"); text.append ("\n"); } @@ -400,7 +403,7 @@ public class WizardryScenarioDisk extends PascalDisk byte[] data2 = new byte[recLen]; System.arraycopy (buffer, ptr, data2, 0, recLen); - Item i = new Item (itemName, data2); + ItemV1 i = new ItemV1 (itemName, data2); items.add (i); addToNode (i, node, blocks, itemSector); } @@ -559,7 +562,7 @@ public class WizardryScenarioDisk extends PascalDisk System.arraycopy (buffer, 0, exactBuffer, 0, exactBuffer.length); String name = "Unknown"; - for (Monster m : monsters) + for (MonsterV1 m : monsters) if (m.imageID == i) { name = m.genericName;