mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-01-29 12:31:09 +00:00
Updated Item
This commit is contained in:
parent
9d8cdcd67b
commit
f5664a9ce9
@ -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")
|
||||
|
@ -47,7 +47,6 @@ public final class Utility
|
||||
private Utility ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -75,7 +75,7 @@ class CharacterV1 extends Character
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void linkItems (List<Item> itemList)
|
||||
public void linkItems (List<ItemV1> 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;
|
||||
|
@ -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 ();
|
||||
}
|
||||
|
206
src/com/bytezone/diskbrowser/wizardry/Item.java
Executable file → Normal file
206
src/com/bytezone/diskbrowser/wizardry/Item.java
Executable file → Normal file
@ -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<Item>
|
||||
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<Item>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
163
src/com/bytezone/diskbrowser/wizardry/ItemV1.java
Executable file
163
src/com/bytezone/diskbrowser/wizardry/ItemV1.java
Executable file
@ -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<ItemV1>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
// 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<ItemV1> items, List<Spell> 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;
|
||||
// }
|
||||
}
|
@ -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 ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -50,9 +50,9 @@ class MazeCell
|
||||
MazeAddress addressTo; // if teleport/stairs/chute
|
||||
|
||||
public MessageV1 message;
|
||||
public List<Monster> monsters;
|
||||
public Item itemRequired;
|
||||
public Item itemObtained;
|
||||
public List<MonsterV1> 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 (" <b>" + monster.getRealName () + " </b>");
|
||||
while (monster.partnerOdds == 100)
|
||||
{
|
||||
|
@ -25,8 +25,8 @@ public class MazeLevel extends AbstractFile
|
||||
|
||||
public final int level;
|
||||
private List<MessageV1> messages;
|
||||
private List<Monster> monsters;
|
||||
private List<Item> items;
|
||||
private List<MonsterV1> monsters;
|
||||
private List<ItemV1> 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<Monster> monsters)
|
||||
public void setMonsters (List<MonsterV1> monsters)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.monsters = monsters;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void setItems (List<Item> items)
|
||||
public void setItems (List<ItemV1> 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;
|
||||
|
||||
|
282
src/com/bytezone/diskbrowser/wizardry/Monster.java
Executable file → Normal file
282
src/com/bytezone/diskbrowser/wizardry/Monster.java
Executable file → Normal file
@ -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<Monster> 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<Dice> 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<Dice> 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<Reward> rewards, List<Monster> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
233
src/com/bytezone/diskbrowser/wizardry/MonsterV1.java
Executable file
233
src/com/bytezone/diskbrowser/wizardry/MonsterV1.java
Executable file
@ -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<MonsterV1> 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<Reward> rewards, List<MonsterV1> 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;
|
||||
}
|
||||
}
|
@ -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 ();
|
||||
}
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ class Reward extends AbstractFile
|
||||
int totalElements;
|
||||
|
||||
List<RewardElement> elements;
|
||||
List<Item> items;
|
||||
List<Monster> goldMonsters = new ArrayList<> ();
|
||||
List<Monster> chestMonsters = new ArrayList<> ();
|
||||
List<ItemV1> items;
|
||||
List<MonsterV1> goldMonsters = new ArrayList<> ();
|
||||
List<MonsterV1> chestMonsters = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
Reward (String name, byte[] buffer, int id, List<Item> items)
|
||||
Reward (String name, byte[] buffer, int id, List<ItemV1> 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");
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ public class Wizardry4BootDisk extends PascalDisk
|
||||
private List<CharacterV4> characters = new ArrayList<> ();
|
||||
private List<CharacterParty> parties = new ArrayList<> ();
|
||||
private List<ItemV4> items = new ArrayList<> ();
|
||||
private List<MonsterV4> 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<DiskAddress> 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);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -30,11 +30,11 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||
public Header scenarioHeader;
|
||||
|
||||
public List<AbstractImage> images;
|
||||
public List<Item> items;
|
||||
public List<ItemV1> items;
|
||||
public List<CharacterV1> characters;
|
||||
public List<Spell> spells;
|
||||
public List<MessageV1> messages;
|
||||
public List<Monster> monsters;
|
||||
public List<MonsterV1> monsters;
|
||||
public List<MazeLevel> levels;
|
||||
List<ExperienceLevel> experiences;
|
||||
List<Reward> 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user