This commit is contained in:
Denis Molony 2022-04-06 18:05:37 +10:00
parent f9038810d2
commit 40c2afbd48
7 changed files with 68 additions and 50 deletions

View File

@ -45,12 +45,14 @@ class Character extends AbstractFile
stats.status = statuses[stats.statusValue];
stats.alignment = alignments[buffer[42] & 0xFF];
stats.gold = Utility.getShort (buffer, 52) + Utility.getShort (buffer, 54) * 10000;
stats.gold = Utility.getShort (buffer, 52) + Utility.getShort (buffer, 54) * 10000
+ Utility.getShort (buffer, 56) * 100000000L;
stats.experience = Utility.getShort (buffer, 124) + Utility.getShort (buffer, 126) * 10000;
stats.level = Utility.getShort (buffer, 132);
stats.hitsLeft = Utility.getShort (buffer, 134);
stats.hitsMax = Utility.getShort (buffer, 136);
stats.armourClass = buffer[176];
attributes.strength = (buffer[44] & 0xFF) % 16;
@ -113,17 +115,20 @@ class Character extends AbstractFile
public void linkSpells (List<Spell> spellList)
// ---------------------------------------------------------------------------------//
{
System.out.println (name);
int index = 0;
for (int i = 138; i < 145; i++)
for (int bit = 0; bit < 8; bit++)
if (((buffer[i] >>> bit) & 1) == 1)
{
if (((buffer[i] >>> bit) & 0x01) != 0)
{
int index = (i - 138) * 8 + bit;
if (index > 0 && index <= spellList.size ())
spellBook.add (spellList.get (index - 1));
else
System.out.println ("LinkSpell: " + getName () + " SpellID : " + index
+ " is outside range 1:" + spellList.size ());
spellBook.add (spellList.get (index));
System.out.println (spellList.get (index));
}
if (++index >= spellList.size ())
break;
}
}
// ---------------------------------------------------------------------------------//
@ -333,7 +338,7 @@ class Character extends AbstractFile
public String status;
public int typeInt;
public int statusValue;
public int gold;
public long gold;
public int experience;
public long nextLevel;
public int level;
@ -344,7 +349,9 @@ class Character extends AbstractFile
public int assetValue;
}
// ---------------------------------------------------------------------------------//
public class Attributes
// ---------------------------------------------------------------------------------//
{
public int strength;
public int intelligence;
@ -352,11 +359,6 @@ class Character extends AbstractFile
public int vitality;
public int agility;
public int luck;
public int[] array;
public Attributes ()
{
array = new int[6];
}
public int[] array = new int[6];
}
}

View File

@ -13,8 +13,8 @@ class Image extends AbstractImage
{
super (name, buffer);
if (buffer[0] == -61 && buffer[1] == -115)
fixSlime (buffer);
// if (buffer[0] == -61 && buffer[1] == -115)
// fixSlime (buffer);
image = new BufferedImage (70, 50, BufferedImage.TYPE_BYTE_GRAY); // width/height
DataBuffer db = image.getRaster ().getDataBuffer ();
@ -30,8 +30,10 @@ class Image extends AbstractImage
element += 7 - m;
break;
}
if ((bits & 1) == 1)
db.setElem (element, 255);
bits >>= 1;
element++;
}
@ -44,6 +46,7 @@ class Image extends AbstractImage
{
for (int i = 0; i < 208; i++)
buffer[i] = 0;
buffer[124] = -108;
buffer[134] = -43;
buffer[135] = -128;

View File

@ -24,13 +24,13 @@ class Item extends AbstractFile implements Comparable<Item>
{
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;
genericName = HexFormatter.getPascalString (buffer, 16);
damage = new Dice (buffer, 66);
armourClass = buffer[62];
speed = buffer[72];
damage = new Dice (buffer, 66);
speed = buffer[72]; // 14 flags
}
// ---------------------------------------------------------------------------------//
@ -142,14 +142,16 @@ class Item extends AbstractFile implements Comparable<Item>
public String getDump (int block)
// ---------------------------------------------------------------------------------//
{
StringBuilder line =
new StringBuilder (String.format ("%3d %-16s", itemID, getName ()));
int lo = block == 0 ? 32 : block == 1 ? 46 : 70;
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 ();
}

View File

@ -91,7 +91,7 @@ class Monster extends AbstractFile
damage.add (new Dice (buffer, ptr));
}
experiencePoints = Utility.readTriple (buffer, 126);
experiencePoints = getWizLong (buffer, 126);
levelDrain = buffer[132];
healPts = buffer[134];
goldReward = rewards.get (buffer[136]);
@ -112,6 +112,17 @@ class Monster extends AbstractFile
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;
}
// ---------------------------------------------------------------------------------//
@Override
public String getText ()
@ -267,11 +278,14 @@ class Monster extends AbstractFile
for (int i = lo; i < hi; i++)
line.append (String.format ("%02X ", buffer[i]));
if (block == 3 && scenarioId == 1)
{
int exp = getExperience ();
line.append (String.format (" %,6d %,6d", exp, exp - experience[monsterID]));
}
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 ();
}

View File

@ -111,6 +111,7 @@ class Reward extends AbstractFile
public RewardElement (byte[] buffer)
{
this.buffer = buffer;
type = buffer[8];
odds = buffer[6];
}

View File

@ -12,6 +12,7 @@ class Spell extends AbstractFile
private String translation;
private SpellTarget target;
private String description;
private int value;
public enum SpellType
{
@ -35,6 +36,7 @@ class Spell extends AbstractFile
// ---------------------------------------------------------------------------------//
{
super (spellName, buffer);
this.spellType = type;
this.level = level;
@ -60,6 +62,7 @@ class Spell extends AbstractFile
this.description = descriptions[spellNo];
this.whenCast = when[spellNo];
this.target = affects[spellNo];
value = spellValue[spellNo];
}
// ---------------------------------------------------------------------------------//
@ -189,24 +192,8 @@ class Spell extends AbstractFile
public String toString ()
// ---------------------------------------------------------------------------------//
{
StringBuilder text = new StringBuilder (getName ());
while (text.length () < 14)
text.append (" ");
if (spellType == SpellType.PRIEST)
text.append ("P");
else
text.append ("M");
text.append (level);
while (text.length () < 20)
text.append (" ");
text.append (translation);
while (text.length () < 40)
text.append (" ");
text.append (getArea ());
while (text.length () < 60)
text.append (" ");
text.append (getWhenCast ());
return text.toString ();
return String.format ("%-16s %-6s %d %-20s %-20s %-20s %5d %<04X", getName (), spellType,
level, translation, getArea (), getWhenCast (), value);
}
private static String[] spellNames = { "KALKI", "DIOS", "BADIOS", "MILWA", "PORFIC", "MATU",
@ -261,6 +248,13 @@ class Spell extends AbstractFile
SpellTarget.MONSTER_GROUP, SpellTarget.MONSTER_GROUP, SpellTarget.MONSTER, SpellTarget.PARTY,
SpellTarget.VARIABLE, SpellTarget.PARTY, SpellTarget.PARTY, SpellTarget.ALL_MONSTERS };
private static int[] spellValue =
{ 1449, 2301, 3675, 2889, 2287, 3139, 1717, 2619, 5970, 5333, 2718, 6491, 5169, 761, 1253,
9463, 4322, 1614, 2446, 4396, 1885, 180, 382, 4296, 547, 759, 8330, 5514, 6673,
4178, 2409, 3983, 3245, 3340, 1953, 6181, 4731, 4744, 3180, 6156, 7525, 6612, 4925, 6587,
4573, 3990, 1562, 3128, 2597, 11157 };
private static String[] descriptions = {
"KALKI reduces the AC of all party members by one, and thus makes" + " them harder to hit.",
"DIOS restores from one to eight hit points of damage from a party"

View File

@ -366,10 +366,12 @@ public class WizardryScenarioDisk extends PascalDisk
}
StringBuilder text = new StringBuilder ();
for (int block = 0; block < 3; block++)
for (int block = 0; block < 2; block++)
{
text.append (" ID Name\n");
text.append ("--- ---------------");
text.append (" ID Name ");
for (int i = 0; i < 24; i++)
text.append (String.format ("%2d ", i));
text.append ("\n--- ---------------");
for (int i = 0; i < 24; i++)
text.append (" --");
text.append ("\n");