summaryrefslogtreecommitdiff
path: root/src/com/dabomstew/pkrandom
diff options
context:
space:
mode:
authortom-overton <tom.overton@outlook.com>2022-05-03 01:02:20 -0700
committertom-overton <tom.overton@outlook.com>2022-05-03 01:02:20 -0700
commitb81279fb4a46d62c5f2320b613925f0fbe29ca52 (patch)
tree183e44b7a514c7132e1651b6ce7ae8c8a5cb73a8 /src/com/dabomstew/pkrandom
parent51db48c59f70dc6a69b7b16116e4558b0f2662f9 (diff)
Add support for reading move priority from the game
Diffstat (limited to 'src/com/dabomstew/pkrandom')
-rw-r--r--src/com/dabomstew/pkrandom/constants/Gen2Constants.java3
-rwxr-xr-xsrc/com/dabomstew/pkrandom/pokemon/Move.java3
-rwxr-xr-xsrc/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java14
-rwxr-xr-xsrc/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java1
-rwxr-xr-xsrc/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java1
-rwxr-xr-xsrc/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java1
-rw-r--r--src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java1
-rw-r--r--src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java1
8 files changed, 24 insertions, 1 deletions
diff --git a/src/com/dabomstew/pkrandom/constants/Gen2Constants.java b/src/com/dabomstew/pkrandom/constants/Gen2Constants.java
index 57b8a12..e0361bf 100644
--- a/src/com/dabomstew/pkrandom/constants/Gen2Constants.java
+++ b/src/com/dabomstew/pkrandom/constants/Gen2Constants.java
@@ -95,6 +95,9 @@ public class Gen2Constants {
tmBlockTwoIndex = Gen2Items.tm05, tmBlockTwoSize = 24,
tmBlockThreeIndex = Gen2Items.tm29, tmBlockThreeSize = 22;
+ public static final int priorityHitEffectIndex = 0x67, protectEffectIndex = 0x6F, endureEffectIndex = 0x74,
+ forceSwitchEffectIndex = 0x1C,counterEffectIndex = 0x59, mirrorCoatEffectIndex = 0x90;
+
private static Type[] constructTypeTable() {
Type[] table = new Type[256];
table[0x00] = Type.NORMAL;
diff --git a/src/com/dabomstew/pkrandom/pokemon/Move.java b/src/com/dabomstew/pkrandom/pokemon/Move.java
index 8fe345f..73da4e3 100755
--- a/src/com/dabomstew/pkrandom/pokemon/Move.java
+++ b/src/com/dabomstew/pkrandom/pokemon/Move.java
@@ -36,10 +36,11 @@ public class Move {
public int effectIndex;
public MoveCategory category;
public double hitCount = 1; // not saved, only used in randomized move powers.
+ public int priority;
public String toString() {
return "#" + number + " " + name + " - Power: " + power + ", Base PP: " + pp + ", Type: " + type + ", Hit%: "
- + (hitratio) + ", Effect: " + effectIndex;
+ + (hitratio) + ", Effect: " + effectIndex + ", Priority: " + priority;
}
}
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java
index faf548f..5c48e20 100755
--- a/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java
+++ b/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java
@@ -424,6 +424,20 @@ public class Gen2RomHandler extends AbstractGBCRomHandler {
} else if (i == Moves.tripleKick) {
moves[i].hitCount = 2.71; // this assumes the first hit lands
}
+
+ // Values taken from effect_priorities.asm from the Gen 2 disassemblies.
+ if (moves[i].effectIndex == Gen2Constants.priorityHitEffectIndex) {
+ moves[i].priority = 2;
+ } else if (moves[i].effectIndex == Gen2Constants.protectEffectIndex ||
+ moves[i].effectIndex == Gen2Constants.endureEffectIndex) {
+ moves[i].priority = 3;
+ } else if (moves[i].effectIndex == Gen2Constants.forceSwitchEffectIndex ||
+ moves[i].effectIndex == Gen2Constants.counterEffectIndex ||
+ moves[i].effectIndex == Gen2Constants.mirrorCoatEffectIndex) {
+ moves[i].priority = 0;
+ } else {
+ moves[i].priority = 1;
+ }
}
}
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java
index 8b3c6f7..2c4abed 100755
--- a/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java
+++ b/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java
@@ -825,6 +825,7 @@ public class Gen3RomHandler extends AbstractGBRomHandler {
moves[i].pp = rom[offs + i * 0xC + 4] & 0xFF;
moves[i].type = Gen3Constants.typeTable[rom[offs + i * 0xC + 2]];
moves[i].category = GBConstants.physicalTypes.contains(moves[i].type) ? MoveCategory.PHYSICAL : MoveCategory.SPECIAL;
+ moves[i].priority = rom[offs + i * 0xC + 7];
if (i == Moves.swift) {
perfectAccuracy = (int)moves[i].hitratio;
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java
index 2997bc9..1e74e45 100755
--- a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java
+++ b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java
@@ -573,6 +573,7 @@ public class Gen4RomHandler extends AbstractDSRomHandler {
moves[i].pp = moveData[6] & 0xFF;
moves[i].type = Gen4Constants.typeTable[moveData[4] & 0xFF];
moves[i].category = Gen4Constants.moveCategoryIndices[moveData[2] & 0xFF];
+ moves[i].priority = moveData[10];
if (i == Moves.swift) {
perfectAccuracy = (int)moves[i].hitratio;
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java
index cec0049..2fa91cb 100755
--- a/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java
+++ b/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java
@@ -556,6 +556,7 @@ public class Gen5RomHandler extends AbstractDSRomHandler {
moves[i].pp = moveData[5] & 0xFF;
moves[i].type = Gen5Constants.typeTable[moveData[0] & 0xFF];
moves[i].category = Gen5Constants.moveCategoryIndices[moveData[2] & 0xFF];
+ moves[i].priority = moveData[6];
if (i == Moves.swift) {
perfectAccuracy = (int)moves[i].hitratio;
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java
index 080c5f2..e0c607e 100644
--- a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java
+++ b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java
@@ -607,6 +607,7 @@ public class Gen6RomHandler extends Abstract3DSRomHandler {
moves[i].pp = moveData[5] & 0xFF;
moves[i].type = Gen6Constants.typeTable[moveData[0] & 0xFF];
moves[i].category = Gen6Constants.moveCategoryIndices[moveData[2] & 0xFF];
+ moves[i].priority = moveData[6];
if (i == Moves.swift) {
perfectAccuracy = (int)moves[i].hitratio;
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java
index 523a3e6..0300036 100644
--- a/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java
+++ b/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java
@@ -679,6 +679,7 @@ public class Gen7RomHandler extends Abstract3DSRomHandler {
moves[i].pp = moveData[5] & 0xFF;
moves[i].type = Gen7Constants.typeTable[moveData[0] & 0xFF];
moves[i].category = Gen7Constants.moveCategoryIndices[moveData[2] & 0xFF];
+ moves[i].priority = moveData[6];
if (i == Moves.swift) {
perfectAccuracy = (int)moves[i].hitratio;