mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-08 04:29:35 +00:00
fixed attributes bug
This commit is contained in:
parent
8765299cf4
commit
e0a2c50d5b
|
@ -1,6 +1,7 @@
|
||||||
package com.bytezone.diskbrowser.wizardry;
|
package com.bytezone.diskbrowser.wizardry;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||||
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
public abstract class Character extends AbstractFile
|
public abstract class Character extends AbstractFile
|
||||||
|
@ -12,6 +13,7 @@ public abstract class Character extends AbstractFile
|
||||||
{ "Fighter", "Mage", "Priest", "Thief", "Bishop", "Samurai", "Lord", "Ninja" };
|
{ "Fighter", "Mage", "Priest", "Thief", "Bishop", "Samurai", "Lord", "Ninja" };
|
||||||
static String[] statuses =
|
static String[] statuses =
|
||||||
{ "OK", "Afraid", "Asleep", "Paralyze", "Stoned", "Dead", "Ashes", "Lost" };
|
{ "OK", "Afraid", "Asleep", "Paralyze", "Stoned", "Dead", "Ashes", "Lost" };
|
||||||
|
static char[] awardsText = ">!$#&*<?BCPKODG@".toCharArray ();
|
||||||
|
|
||||||
int scenario;
|
int scenario;
|
||||||
|
|
||||||
|
@ -21,4 +23,22 @@ public abstract class Character extends AbstractFile
|
||||||
{
|
{
|
||||||
super (name, buffer);
|
super (name, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public String getAwardString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
|
int awards = Utility.getShort (buffer, 206);
|
||||||
|
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
if ((awards & 0x01) != 0)
|
||||||
|
text.append (awardsText[i]);
|
||||||
|
awards >>>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return text.toString ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,9 @@ import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
class CharacterV1 extends Character
|
class CharacterV1 extends Character
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static char[] awardsText = ">!$#&*<?BCPKODG@".toCharArray ();
|
public final int[] attributes = new int[6]; // 0:18
|
||||||
|
public final int[] saveVs = new int[5]; // 0:31
|
||||||
|
|
||||||
private final Attributes attributes;
|
|
||||||
private final Statistics stats;
|
private final Statistics stats;
|
||||||
|
|
||||||
private final List<Spell> spellBook = new ArrayList<> ();
|
private final List<Spell> spellBook = new ArrayList<> ();
|
||||||
|
@ -26,7 +26,6 @@ class CharacterV1 extends Character
|
||||||
|
|
||||||
this.scenario = scenario;
|
this.scenario = scenario;
|
||||||
|
|
||||||
attributes = new Attributes ();
|
|
||||||
stats = new Statistics ();
|
stats = new Statistics ();
|
||||||
|
|
||||||
stats.race = races[buffer[34] & 0xFF];
|
stats.race = races[buffer[34] & 0xFF];
|
||||||
|
@ -37,9 +36,18 @@ class CharacterV1 extends Character
|
||||||
stats.status = statuses[stats.statusValue];
|
stats.status = statuses[stats.statusValue];
|
||||||
stats.alignment = alignments[buffer[42] & 0xFF];
|
stats.alignment = alignments[buffer[42] & 0xFF];
|
||||||
|
|
||||||
stats.gold = Utility.getShort (buffer, 52) + Utility.getShort (buffer, 54) * 10000
|
int attr1 = Utility.getShort (buffer, 44);
|
||||||
+ Utility.getShort (buffer, 56) * 100000000L;
|
int attr2 = Utility.getShort (buffer, 46);
|
||||||
stats.experience = Utility.getShort (buffer, 124) + Utility.getShort (buffer, 126) * 10000;
|
|
||||||
|
attributes[0] = attr1 & 0x001F;
|
||||||
|
attributes[1] = (attr1 & 0x03E0) >>> 5;
|
||||||
|
attributes[2] = (attr1 & 0x7C00) >>> 10;
|
||||||
|
attributes[3] = attr2 & 0x001F;
|
||||||
|
attributes[4] = (attr2 & 0x03E0) >>> 5;
|
||||||
|
attributes[5] = (attr2 & 0x7C00) >>> 10;
|
||||||
|
|
||||||
|
stats.gold = Utility.getWizLong (buffer, 52);
|
||||||
|
stats.experience = Utility.getWizLong (buffer, 124);
|
||||||
stats.level = Utility.getShort (buffer, 132);
|
stats.level = Utility.getShort (buffer, 132);
|
||||||
|
|
||||||
stats.hitsLeft = Utility.getShort (buffer, 134);
|
stats.hitsLeft = Utility.getShort (buffer, 134);
|
||||||
|
@ -47,31 +55,15 @@ class CharacterV1 extends Character
|
||||||
|
|
||||||
stats.armourClass = buffer[176];
|
stats.armourClass = buffer[176];
|
||||||
|
|
||||||
attributes.strength = (buffer[44] & 0xFF) % 16;
|
// saving throws
|
||||||
if (attributes.strength < 3)
|
attr1 = Utility.getShort (buffer, 48);
|
||||||
attributes.strength += 16;
|
attr2 = Utility.getShort (buffer, 50);
|
||||||
attributes.array[0] = attributes.strength;
|
|
||||||
|
|
||||||
int i1 = (buffer[44] & 0xFF) / 16;
|
saveVs[0] = attr1 & 0x001F;
|
||||||
int i2 = (buffer[45] & 0xFF) % 4;
|
saveVs[1] = (attr1 & 0x03E0) >>> 5;
|
||||||
attributes.intelligence = i1 / 2 + i2 * 8;
|
saveVs[2] = (attr1 & 0x7C00) >>> 10;
|
||||||
attributes.array[1] = attributes.intelligence;
|
saveVs[3] = attr2 & 0x001F;
|
||||||
|
saveVs[4] = (attr2 & 0x03E0) >>> 5;
|
||||||
attributes.piety = (buffer[45] & 0xFF) / 4;
|
|
||||||
attributes.array[2] = attributes.piety;
|
|
||||||
|
|
||||||
attributes.vitality = (buffer[46] & 0xFF) % 16;
|
|
||||||
if (attributes.vitality < 3)
|
|
||||||
attributes.vitality += 16;
|
|
||||||
attributes.array[3] = attributes.vitality;
|
|
||||||
|
|
||||||
int a1 = (buffer[46] & 0xFF) / 16;
|
|
||||||
int a2 = (buffer[47] & 0xFF) % 4;
|
|
||||||
attributes.agility = a1 / 2 + a2 * 8;
|
|
||||||
attributes.array[4] = attributes.agility;
|
|
||||||
|
|
||||||
attributes.luck = (buffer[47] & 0xFF) / 4;
|
|
||||||
attributes.array[5] = attributes.luck;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -95,7 +87,6 @@ class CharacterV1 extends Character
|
||||||
identified = (buffer[ptr + 4] == 1);
|
identified = (buffer[ptr + 4] == 1);
|
||||||
baggageList.add (new Baggage (item, equipped, identified));
|
baggageList.add (new Baggage (item, equipped, identified));
|
||||||
stats.assetValue += item.getCost ();
|
stats.assetValue += item.getCost ();
|
||||||
// item.partyOwns++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
System.out.println (
|
System.out.println (
|
||||||
|
@ -112,10 +103,7 @@ class CharacterV1 extends Character
|
||||||
for (int bit = 0; bit < 8; bit++)
|
for (int bit = 0; bit < 8; bit++)
|
||||||
{
|
{
|
||||||
if (((buffer[i] >>> bit) & 0x01) != 0)
|
if (((buffer[i] >>> bit) & 0x01) != 0)
|
||||||
{
|
|
||||||
spellBook.add (spellList.get (index));
|
spellBook.add (spellList.get (index));
|
||||||
// System.out.println (spellList.get (index));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (++index >= spellList.size ())
|
if (++index >= spellList.size ())
|
||||||
break;
|
break;
|
||||||
|
@ -134,8 +122,6 @@ class CharacterV1 extends Character
|
||||||
text.append ("\nType ............... " + stats.type);
|
text.append ("\nType ............... " + stats.type);
|
||||||
text.append ("\nAlignment .......... " + stats.alignment);
|
text.append ("\nAlignment .......... " + stats.alignment);
|
||||||
text.append ("\nStatus ............. " + stats.status);
|
text.append ("\nStatus ............. " + stats.status);
|
||||||
// text.append ("\nType ............... " + stats.typeInt);
|
|
||||||
// text.append ("\nStatus ............. " + stats.statusValue);
|
|
||||||
text.append ("\nGold ............... " + String.format ("%,d", stats.gold));
|
text.append ("\nGold ............... " + String.format ("%,d", stats.gold));
|
||||||
text.append ("\nExperience ......... " + String.format ("%,d", stats.experience));
|
text.append ("\nExperience ......... " + String.format ("%,d", stats.experience));
|
||||||
text.append ("\nNext level ......... " + String.format ("%,d", stats.nextLevel));
|
text.append ("\nNext level ......... " + String.format ("%,d", stats.nextLevel));
|
||||||
|
@ -150,12 +136,12 @@ class CharacterV1 extends Character
|
||||||
text.append ("\nAwards ............. " + getAwardString ());
|
text.append ("\nAwards ............. " + getAwardString ());
|
||||||
text.append ("\nOut ................ " + isOut ());
|
text.append ("\nOut ................ " + isOut ());
|
||||||
|
|
||||||
text.append ("\n\nStrength ........... " + attributes.strength);
|
text.append ("\n\nStrength ........... " + attributes[0]);
|
||||||
text.append ("\nIntelligence ....... " + attributes.intelligence);
|
text.append ("\nIntelligence ....... " + attributes[1]);
|
||||||
text.append ("\nPiety .............. " + attributes.piety);
|
text.append ("\nPiety .............. " + attributes[2]);
|
||||||
text.append ("\nVitality ........... " + attributes.vitality);
|
text.append ("\nVitality ........... " + attributes[3]);
|
||||||
text.append ("\nAgility ............ " + attributes.agility);
|
text.append ("\nAgility ............ " + attributes[4]);
|
||||||
text.append ("\nLuck ............... " + attributes.luck);
|
text.append ("\nLuck ............... " + attributes[5]);
|
||||||
|
|
||||||
int[] spellPoints = getMageSpellPoints ();
|
int[] spellPoints = getMageSpellPoints ();
|
||||||
text.append ("\n\nMage spell points ..");
|
text.append ("\n\nMage spell points ..");
|
||||||
|
@ -216,24 +202,6 @@ class CharacterV1 extends Character
|
||||||
return stats.nextLevel;
|
return stats.nextLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public String getAwardString ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
StringBuilder text = new StringBuilder ();
|
|
||||||
|
|
||||||
int awards = Utility.getShort (buffer, 206);
|
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
if ((awards & 0x01) != 0)
|
|
||||||
text.append (awardsText[i]);
|
|
||||||
awards >>>= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return text.toString ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public boolean isOut ()
|
public boolean isOut ()
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -263,7 +231,7 @@ class CharacterV1 extends Character
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public Attributes getAttributes ()
|
int[] getAttributes ()
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return attributes;
|
return attributes;
|
||||||
|
@ -341,17 +309,4 @@ class CharacterV1 extends Character
|
||||||
public int armourClass;
|
public int armourClass;
|
||||||
public int assetValue;
|
public int assetValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public class Attributes
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
public int strength;
|
|
||||||
public int intelligence;
|
|
||||||
public int piety;
|
|
||||||
public int vitality;
|
|
||||||
public int agility;
|
|
||||||
public int luck;
|
|
||||||
public int[] array = new int[6];
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -18,7 +18,6 @@ import com.bytezone.diskbrowser.gui.DataSource;
|
||||||
import com.bytezone.diskbrowser.pascal.PascalDisk;
|
import com.bytezone.diskbrowser.pascal.PascalDisk;
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
import com.bytezone.diskbrowser.wizardry.CharacterV1.Attributes;
|
|
||||||
import com.bytezone.diskbrowser.wizardry.CharacterV1.Statistics;
|
import com.bytezone.diskbrowser.wizardry.CharacterV1.Statistics;
|
||||||
import com.bytezone.diskbrowser.wizardry.Header.ScenarioData;
|
import com.bytezone.diskbrowser.wizardry.Header.ScenarioData;
|
||||||
import com.bytezone.diskbrowser.wizardry.Spell.SpellType;
|
import com.bytezone.diskbrowser.wizardry.Spell.SpellType;
|
||||||
|
@ -78,11 +77,13 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
DefaultMutableTreeNode currentRoot = (DefaultMutableTreeNode) model.getRoot ();
|
DefaultMutableTreeNode currentRoot = (DefaultMutableTreeNode) model.getRoot ();
|
||||||
DefaultMutableTreeNode dataNode = findNode (currentRoot, "SCENARIO.DATA");
|
DefaultMutableTreeNode dataNode = findNode (currentRoot, "SCENARIO.DATA");
|
||||||
DefaultMutableTreeNode msgNode = findNode (currentRoot, "SCENARIO.MESGS");
|
DefaultMutableTreeNode msgNode = findNode (currentRoot, "SCENARIO.MESGS");
|
||||||
|
|
||||||
if (dataNode == null || msgNode == null)
|
if (dataNode == null || msgNode == null)
|
||||||
{
|
{
|
||||||
System.out.println ("Wizardry data or msg node not found");
|
System.out.println ("Wizardry data or msg node not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataNode.setAllowsChildren (true);
|
dataNode.setAllowsChildren (true);
|
||||||
msgNode.setAllowsChildren (true);
|
msgNode.setAllowsChildren (true);
|
||||||
|
|
||||||
|
@ -90,9 +91,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
|
|
||||||
// Process SCENARIO.MESGS (requires scenario)
|
// Process SCENARIO.MESGS (requires scenario)
|
||||||
AppleFileSource afs = (AppleFileSource) msgNode.getUserObject ();
|
AppleFileSource afs = (AppleFileSource) msgNode.getUserObject ();
|
||||||
// DefaultMutableTreeNode node = linkNode ("Messages", "Messages string", msgNode);
|
|
||||||
extractMessages (msgNode, afs.getSectors ());
|
extractMessages (msgNode, afs.getSectors ());
|
||||||
// makeNodeVisible (node);
|
|
||||||
|
|
||||||
// Process SCENARIO.DATA (requires scenario and messages)
|
// Process SCENARIO.DATA (requires scenario and messages)
|
||||||
afs = (AppleFileSource) dataNode.getUserObject ();
|
afs = (AppleFileSource) dataNode.getUserObject ();
|
||||||
|
@ -104,12 +103,9 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
extractCharacters (linkNode ("Characters", "Characters string", dataNode), sectors);
|
extractCharacters (linkNode ("Characters", "Characters string", dataNode), sectors);
|
||||||
extractImages (linkNode ("Images", "Images string", dataNode), sectors);
|
extractImages (linkNode ("Images", "Images string", dataNode), sectors);
|
||||||
extractExperienceLevels (linkNode ("Experience", "Experience string", dataNode), sectors);
|
extractExperienceLevels (linkNode ("Experience", "Experience string", dataNode), sectors);
|
||||||
// node = linkNode ("Spells", "Spells string", dataNode);
|
|
||||||
DefaultMutableTreeNode node = null;
|
extractSpells (sectors);
|
||||||
extractSpells (node, sectors);
|
|
||||||
extractLevels (linkNode ("Maze", "Levels string", dataNode), sectors);
|
extractLevels (linkNode ("Maze", "Levels string", dataNode), sectors);
|
||||||
// Make the Spells node (and its siblings) visible
|
|
||||||
// makeNodeVisible (node);
|
|
||||||
|
|
||||||
// add information about each characters' baggage, spells known etc.
|
// add information about each characters' baggage, spells known etc.
|
||||||
for (CharacterV1 character : characters)
|
for (CharacterV1 character : characters)
|
||||||
|
@ -131,6 +127,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
DefaultAppleFileSource afs = new DefaultAppleFileSource (name, text, this);
|
DefaultAppleFileSource afs = new DefaultAppleFileSource (name, text, this);
|
||||||
DefaultMutableTreeNode node = new DefaultMutableTreeNode (afs);
|
DefaultMutableTreeNode node = new DefaultMutableTreeNode (afs);
|
||||||
parent.add (node);
|
parent.add (node);
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,6 +148,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
&& !text.equals ("WIZARDRY.CODE"))
|
&& !text.equals ("WIZARDRY.CODE"))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,11 +257,11 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
for (CharacterV1 ch : characters)
|
for (CharacterV1 ch : characters)
|
||||||
{
|
{
|
||||||
Statistics stats = ch.getStatistics ();
|
Statistics stats = ch.getStatistics ();
|
||||||
Attributes att = ch.getAttributes ();
|
int[] att = ch.getAttributes ();
|
||||||
text.append (String.format ("%-15s %2d %-8s %-8s %-8s %3d", ch, (stats.ageInWeeks / 52),
|
text.append (String.format ("%-15s %2d %-8s %-8s %-8s %3d", ch, (stats.ageInWeeks / 52),
|
||||||
stats.alignment, stats.race, stats.type, stats.hitsMax));
|
stats.alignment, stats.race, stats.type, stats.hitsMax));
|
||||||
text.append (String.format (" %2d %2d %2d %2d %2d %2d", att.strength, att.intelligence,
|
text.append (String.format (" %2d %2d %2d %2d %2d %2d", att[0], att[1], att[2], att[3],
|
||||||
att.piety, att.vitality, att.agility, att.luck));
|
att[4], att[5]));
|
||||||
text.append (String.format (" %5s %s%n", stats.status, ch.isOut () ? "* OUT *" : ""));
|
text.append (String.format (" %5s %s%n", stats.status, ch.isOut () ? "* OUT *" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,7 +410,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
private void extractSpells (DefaultMutableTreeNode node, List<DiskAddress> sectors)
|
private void extractSpells (List<DiskAddress> sectors)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
spells = new ArrayList<> ();
|
spells = new ArrayList<> ();
|
||||||
|
@ -427,6 +425,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
byte[] buffer = disk.readBlock (da);
|
byte[] buffer = disk.readBlock (da);
|
||||||
int level = 1;
|
int level = 1;
|
||||||
int ptr = -1;
|
int ptr = -1;
|
||||||
|
|
||||||
while (ptr < 255)
|
while (ptr < 255)
|
||||||
{
|
{
|
||||||
ptr++;
|
ptr++;
|
||||||
|
@ -435,15 +434,17 @@ public class WizardryScenarioDisk extends PascalDisk
|
||||||
ptr++;
|
ptr++;
|
||||||
if (ptr == start)
|
if (ptr == start)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
String spell = HexFormatter.getString (buffer, start, ptr - start);
|
String spell = HexFormatter.getString (buffer, start, ptr - start);
|
||||||
|
|
||||||
if (spell.startsWith ("*"))
|
if (spell.startsWith ("*"))
|
||||||
{
|
{
|
||||||
spell = spell.substring (1);
|
spell = spell.substring (1);
|
||||||
++level;
|
++level;
|
||||||
}
|
}
|
||||||
|
|
||||||
Spell s = Spell.getSpell (spell, spellType, level, buffer);
|
Spell s = Spell.getSpell (spell, spellType, level, buffer);
|
||||||
spells.add (s);
|
spells.add (s);
|
||||||
// addToNode (s, node, da, spellSector);
|
|
||||||
}
|
}
|
||||||
spellType = SpellType.PRIEST;
|
spellType = SpellType.PRIEST;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user