fixed bug in known spells
This commit is contained in:
parent
d71cabb754
commit
b19e89d7cf
|
@ -26,6 +26,10 @@ public abstract class Character extends AbstractFile
|
||||||
public int characterLevel;
|
public int characterLevel;
|
||||||
public int possessionsCount;
|
public int possessionsCount;
|
||||||
|
|
||||||
|
public boolean mysteryBit; // first bit in spellsKnown
|
||||||
|
public final boolean[] spellsKnown = new boolean[50];
|
||||||
|
public final int[][] spellAllowance = new int[2][7];
|
||||||
|
|
||||||
public enum Race
|
public enum Race
|
||||||
{
|
{
|
||||||
NORACE, HUMAN, ELF, DWARF, GNOME, HOBBIT
|
NORACE, HUMAN, ELF, DWARF, GNOME, HOBBIT
|
||||||
|
@ -70,6 +74,25 @@ public abstract class Character extends AbstractFile
|
||||||
attributes[ptr + 1] = (value & 0x03E0) >>> 5;
|
attributes[ptr + 1] = (value & 0x03E0) >>> 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
protected void checkKnownSpells (byte[] buffer, int ptr)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
int bit = 1; // skip first bit
|
||||||
|
int val = buffer[ptr];
|
||||||
|
mysteryBit = (val & 0x01) == 1;
|
||||||
|
|
||||||
|
for (int i = 0; i < spellsKnown.length; i++)
|
||||||
|
{
|
||||||
|
if (bit == 8)
|
||||||
|
{
|
||||||
|
val = buffer[++ptr];
|
||||||
|
bit = 0;
|
||||||
|
}
|
||||||
|
spellsKnown[i] = ((val >>> bit++) & 0x01) != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public String getAwardString ()
|
public String getAwardString ()
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
|
@ -78,6 +78,8 @@ class CharacterV1 extends Character
|
||||||
hpLeft = Utility.getShort (buffer, 134);
|
hpLeft = Utility.getShort (buffer, 134);
|
||||||
hpMax = Utility.getShort (buffer, 136);
|
hpMax = Utility.getShort (buffer, 136);
|
||||||
|
|
||||||
|
checkKnownSpells (buffer, 138);
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++)
|
for (int i = 0; i < 7; i++)
|
||||||
mageSpells[i] = buffer[146 + i * 2];
|
mageSpells[i] = buffer[146 + i * 2];
|
||||||
|
|
||||||
|
@ -98,16 +100,9 @@ class CharacterV1 extends Character
|
||||||
assetValue += baggage.item.getCost ();
|
assetValue += baggage.item.getCost ();
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = 0;
|
for (int i = 0; i < spellsKnown.length; i++)
|
||||||
for (int i = 138; i < 145; i++)
|
if (spellsKnown[i])
|
||||||
for (int bit = 0; bit < 8; bit++)
|
spellBook.add (spellList.get (i));
|
||||||
{
|
|
||||||
if (((buffer[i] >>> bit) & 0x01) != 0)
|
|
||||||
spellBook.add (spellList.get (index));
|
|
||||||
|
|
||||||
if (++index >= spellList.size ())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
nextLevel = experienceLevels.get (typeInt).getExperiencePoints (characterLevel + 1);
|
nextLevel = experienceLevels.get (typeInt).getExperiencePoints (characterLevel + 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,6 @@ public class CharacterV4 extends Character
|
||||||
public final long experience;
|
public final long experience;
|
||||||
public final int maxlevac; // max level armour class?
|
public final int maxlevac; // max level armour class?
|
||||||
|
|
||||||
public final boolean mysteryBit; // first bit in spellsKnown
|
|
||||||
public final boolean[] spellsKnown = new boolean[50];
|
|
||||||
public final int[][] spellAllowance = new int[2][7];
|
|
||||||
|
|
||||||
public final int hpCalCmd;
|
public final int hpCalCmd;
|
||||||
public final int healPts;
|
public final int healPts;
|
||||||
|
|
||||||
|
@ -101,18 +97,7 @@ public class CharacterV4 extends Character
|
||||||
hpLeft = Utility.getShort (buffer, 135);
|
hpLeft = Utility.getShort (buffer, 135);
|
||||||
hpMax = Utility.getShort (buffer, 137);
|
hpMax = Utility.getShort (buffer, 137);
|
||||||
|
|
||||||
mysteryBit = (buffer[139] & 0x01) == 1;
|
checkKnownSpells (buffer, 139);
|
||||||
int index = -1; // skip mystery bit
|
|
||||||
for (int i = 139; i < 146; i++)
|
|
||||||
for (int bit = 0; bit < 8; bit++)
|
|
||||||
{
|
|
||||||
if (((buffer[i] >>> bit) & 0x01) != 0)
|
|
||||||
if (index >= 0)
|
|
||||||
spellsKnown[index] = true;
|
|
||||||
|
|
||||||
if (++index >= MAX_SPELLS)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++)
|
for (int i = 0; i < 7; i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue