summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortom-overton <tom.overton@outlook.com>2022-05-16 12:23:43 -0700
committerrafa_99 <raroma09@gmail.com>2022-05-16 22:57:36 +0100
commit4744fe9c8335401805b53578f3739bfc5236a20e (patch)
tree0ef9739a8a1f6207ddfd0f1737c47f35f9564dcf
parent7b9e41f3a4c7db46d8e138b2aee41c2d652b3a56 (diff)
Read crit information from moves
-rw-r--r--src/com/sneed/pkrandom/constants/Gen1Constants.java3
-rw-r--r--src/com/sneed/pkrandom/constants/Gen2Constants.java10
-rw-r--r--src/com/sneed/pkrandom/constants/Gen3Constants.java15
-rw-r--r--src/com/sneed/pkrandom/constants/Gen4Constants.java38
-rw-r--r--src/com/sneed/pkrandom/pokemon/CriticalChance.java31
-rwxr-xr-xsrc/com/sneed/pkrandom/pokemon/Move.java8
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/Gen1RomHandler.java45
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/Gen2RomHandler.java62
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java84
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java97
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java8
-rw-r--r--src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java8
-rw-r--r--src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java8
13 files changed, 266 insertions, 151 deletions
diff --git a/src/com/sneed/pkrandom/constants/Gen1Constants.java b/src/com/sneed/pkrandom/constants/Gen1Constants.java
index a84b622..8b09c6d 100644
--- a/src/com/sneed/pkrandom/constants/Gen1Constants.java
+++ b/src/com/sneed/pkrandom/constants/Gen1Constants.java
@@ -80,6 +80,9 @@ public class Gen1Constants {
damageAtkMinusOneEffect = 68, damageDefMinusOneEffect = 69, damageSpeMinusOneEffect = 70,
damageSpecialMinusOneEffect = 71, damageConfusionEffect = 76, twineedleEffect = 77;
+ // Taken from critical_hit_moves.asm; we could read this from the ROM, but it's easier to hardcode it.
+ public static final List<Integer> increasedCritMoves = Arrays.asList(Moves.karateChop, Moves.razorLeaf, Moves.crabhammer, Moves.slash);
+
public static final List<Integer> earlyRequiredHMs = Collections.singletonList(Moves.cut);
public static final int hmsStartIndex = Gen1Items.hm01, tmsStartIndex = Gen1Items.tm01;
diff --git a/src/com/sneed/pkrandom/constants/Gen2Constants.java b/src/com/sneed/pkrandom/constants/Gen2Constants.java
index 32ef9eb..4ca383b 100644
--- a/src/com/sneed/pkrandom/constants/Gen2Constants.java
+++ b/src/com/sneed/pkrandom/constants/Gen2Constants.java
@@ -82,9 +82,13 @@ public class Gen2Constants {
noDamageDefMinusTwoEffect = 59, noDamageSpeMinusTwoEffect = 60, noDamageSpDefMinusTwoEffect = 62, noDamagePoisonEffect = 66,
noDamageParalyzeEffect = 67, damageAtkMinusOneEffect = 68, damageDefMinusOneEffect = 69, damageSpeMinusOneEffect = 70,
damageSpDefMinusOneEffect = 72, damageAccuracyMinusOneEffect = 73, damageConfusionEffect = 76, twineedleEffect = 77,
- snoreEffect = 92, swaggerEffect = 118, damageBurnAndThawUserEffect = 125, damageUserDefPlusOneEffect = 138,
- damageUserAtkPlusOneEffect = 139, damageUserAllPlusOneEffect = 140, twisterEffect = 146, stompEffect = 150,
- thunderEffect = 152, defenseCurlEffect = 156;
+ snoreEffect = 92, flailAndReversalEffect = 102, swaggerEffect = 118, damageBurnAndThawUserEffect = 125,
+ damageUserDefPlusOneEffect = 138, damageUserAtkPlusOneEffect = 139, damageUserAllPlusOneEffect = 140,
+ twisterEffect = 146, futureSightEffect = 148, stompEffect = 150, thunderEffect = 152, defenseCurlEffect = 156;
+
+ // Taken from critical_hit_moves.asm; we could read this from the ROM, but it's easier to hardcode it.
+ public static final List<Integer> increasedCritMoves = Arrays.asList(Moves.karateChop, Moves.razorWind, Moves.razorLeaf,
+ Moves.crabhammer, Moves.slash, Moves.aeroblast, Moves.crossChop);
public static final List<Integer> requiredFieldTMs = Arrays.asList(4, 20, 22, 26, 28, 34, 35, 39,
40, 43, 44, 46);
diff --git a/src/com/sneed/pkrandom/constants/Gen3Constants.java b/src/com/sneed/pkrandom/constants/Gen3Constants.java
index c15d2b9..4721893 100644
--- a/src/com/sneed/pkrandom/constants/Gen3Constants.java
+++ b/src/com/sneed/pkrandom/constants/Gen3Constants.java
@@ -190,7 +190,7 @@ public class Gen3Constants {
noDamageDefPlusOneEffect = 11, noDamageSpAtkPlusOneEffect = 13, noDamageEvasionPlusOneEffect = 16,
noDamageAtkMinusOneEffect = 18, noDamageDefMinusOneEffect = 19, noDamageSpeMinusOneEffect = 20,
noDamageAccuracyMinusOneEffect = 23, noDamageEvasionMinusOneEffect = 24, flinchEffect = 31, toxicEffect = 33,
- damageRecoil25PercentEffect = 48, noDamageConfusionEffect = 49, noDamageAtkPlusTwoEffect = 50,
+ increasedCritEffect = 43, damageRecoil25PercentEffect = 48, noDamageConfusionEffect = 49, noDamageAtkPlusTwoEffect = 50,
noDamageDefPlusTwoEffect = 51, noDamageSpePlusTwoEffect = 52, noDamageSpAtkPlusTwoEffect = 53,
noDamageSpDefPlusTwoEffect = 54, noDamageAtkMinusTwoEffect = 58, noDamageDefMinusTwoEffect = 59,
noDamageSpeMinusTwoEffect = 60, noDamageSpDefMinusTwoEffect = 62, noDamagePoisonEffect = 66,
@@ -199,12 +199,13 @@ public class Gen3Constants {
damageAccuracyMinusOneEffect = 73, skyAttackEffect = 75, damageConfusionEffect = 76, twineedleEffect = 77,
snoreEffect = 92, minimizeEffect = 108, swaggerEffect = 118, damageBurnAndThawUserEffect = 125,
damageUserDefPlusOneEffect = 138, damageUserAtkPlusOneEffect = 139, damageUserAllPlusOneEffect = 140,
- twisterEffect = 146, flinchWithMinimizeBonusEffect = 150, thunderEffect = 152, defenseCurlEffect = 156, fakeOutEffect = 158,
- flatterEffect = 166, noDamageBurnEffect = 167, chargeEffect = 174, damageUserAtkAndDefMinusOneEffect = 182,
- damageRecoil33PercentEffect = 198, teeterDanceEffect = 199, blazeKickEffect = 200, poisonFangEffect = 202,
- damageUserSpAtkMinusTwoEffect = 204, noDamageAtkAndDefMinusOneEffect = 205, noDamageDefAndSpDefPlusOneEffect = 206,
- noDamageAtkAndDefPlusOneEffect = 208, damagePoisonWithIncreasedCritEffect = 209,
- noDamageSpAtkAndSpDefPlusOneEffect = 211, noDamageAtkAndSpePlusOneEffect = 212;
+ twisterEffect = 146, futureSightAndDoomDesireEffect = 148, flinchWithMinimizeBonusEffect = 150, thunderEffect = 152,
+ defenseCurlEffect = 156, fakeOutEffect = 158, spitUpEffect = 161, flatterEffect = 166, noDamageBurnEffect = 167,
+ chargeEffect = 174, damageUserAtkAndDefMinusOneEffect = 182, damageRecoil33PercentEffect = 198,
+ teeterDanceEffect = 199, blazeKickEffect = 200, poisonFangEffect = 202, damageUserSpAtkMinusTwoEffect = 204,
+ noDamageAtkAndDefMinusOneEffect = 205, noDamageDefAndSpDefPlusOneEffect = 206,
+ noDamageAtkAndDefPlusOneEffect = 208, poisonTailEffect = 209, noDamageSpAtkAndSpDefPlusOneEffect = 211,
+ noDamageAtkAndSpePlusOneEffect = 212;
public static final List<Integer> rsRequiredFieldTMs = Arrays.asList(1, 2, 6, 7, 11, 18, 22, 23,
26, 30, 37, 48);
diff --git a/src/com/sneed/pkrandom/constants/Gen4Constants.java b/src/com/sneed/pkrandom/constants/Gen4Constants.java
index 3d6bcfb..b573913 100644
--- a/src/com/sneed/pkrandom/constants/Gen4Constants.java
+++ b/src/com/sneed/pkrandom/constants/Gen4Constants.java
@@ -686,25 +686,25 @@ public class Gen4Constants {
noDamageDefPlusOneEffect = 11, noDamageSpAtkPlusOneEffect = 13, noDamageEvasionPlusOneEffect = 16,
noDamageAtkMinusOneEffect = 18, noDamageDefMinusOneEffect = 19, noDamageSpeMinusOneEffect = 20,
noDamageAccuracyMinusOneEffect = 23, noDamageEvasionMinusOneEffect = 24, flinchEffect = 31, toxicEffect = 33,
- damageRecoil25PercentEffect = 48, noDamageConfusionEffect = 49, noDamageAtkPlusTwoEffect = 50,
- noDamageDefPlusTwoEffect = 51, noDamageSpePlusTwoEffect = 52, noDamageSpAtkPlusTwoEffect = 53,
- noDamageSpDefPlusTwoEffect = 54, noDamageAtkMinusTwoEffect = 58, noDamageDefMinusTwoEffect = 59,
- noDamageSpeMinusTwoEffect = 60, noDamageSpDefMinusTwoEffect = 62, noDamagePoisonEffect = 66,
- noDamageParalyzeEffect = 67, damageAtkMinusOneEffect = 68, damageDefMinusOneEffect = 69,
- damageSpeMinusOneEffect = 70, damageSpAtkMinusOneEffect = 71, damageSpDefMinusOneEffect = 72,
- damageAccuracyMinusOneEffect = 73, skyAttackEffect = 75, damageConfusionEffect = 76, twineedleEffect = 77,
- snoreEffect = 92, minimizeEffect = 108, swaggerEffect = 118, damageBurnAndThawUserEffect = 125,
- damageUserDefPlusOneEffect = 138, damageUserAtkPlusOneEffect = 139, damageUserAllPlusOneEffect = 140,
- twisterEffect = 146, stompEffect = 150, thunderEffect = 152, defenseCurlEffect = 156, fakeOutEffect = 158,
- flatterEffect = 166, noDamageBurnEffect = 167, chargeEffect = 174, damageUserAtkAndDefMinusOneEffect = 182,
- damageRecoil33PercentEffect = 198, teeterDanceEffect = 199, blazeKickEffect = 200, poisonFangEffect = 202,
- damageUserSpAtkMinusTwoEffect = 204, noDamageAtkAndDefMinusOneEffect = 205, noDamageDefAndSpDefPlusOneEffect = 206,
- noDamageAtkAndDefPlusOneEffect = 208, damagePoisonWithIncreasedCritEffect = 209,
- noDamageSpAtkAndSpDefPlusOneEffect = 211, noDamageAtkAndSpePlusOneEffect = 212, damageUserSpeMinusOneEffect = 218,
- damageUserDefAndSpDefMinusOneEffect = 229, flareBlitzEffect = 253, blizzardEffect = 260, voltTackleEffect = 262,
- bounceEffect = 263, noDamageSpAtkMinusTwoEffect = 265, chatterEffect = 267, damageRecoil50PercentEffect = 269,
- damageSpDefMinusTwoEffect = 271, fireFangEffect = 273, iceFangEffect = 274, thunderFangEffect = 275,
- damageUserSpAtkPlusOneEffect = 276;
+ razorWindEffect = 39, increasedCritEffect = 43, damageRecoil25PercentEffect = 48, noDamageConfusionEffect = 49,
+ noDamageAtkPlusTwoEffect = 50, noDamageDefPlusTwoEffect = 51, noDamageSpePlusTwoEffect = 52,
+ noDamageSpAtkPlusTwoEffect = 53, noDamageSpDefPlusTwoEffect = 54, noDamageAtkMinusTwoEffect = 58,
+ noDamageDefMinusTwoEffect = 59, noDamageSpeMinusTwoEffect = 60, noDamageSpDefMinusTwoEffect = 62,
+ noDamagePoisonEffect = 66, noDamageParalyzeEffect = 67, damageAtkMinusOneEffect = 68,
+ damageDefMinusOneEffect = 69, damageSpeMinusOneEffect = 70, damageSpAtkMinusOneEffect = 71,
+ damageSpDefMinusOneEffect = 72, damageAccuracyMinusOneEffect = 73, skyAttackEffect = 75,
+ damageConfusionEffect = 76, twineedleEffect = 77, snoreEffect = 92, minimizeEffect = 108, swaggerEffect = 118,
+ damageBurnAndThawUserEffect = 125, damageUserDefPlusOneEffect = 138, damageUserAtkPlusOneEffect = 139,
+ damageUserAllPlusOneEffect = 140, twisterEffect = 146, futureSightAndDoomDesireEffect = 148, stompEffect = 150,
+ thunderEffect = 152, defenseCurlEffect = 156, fakeOutEffect = 158, flatterEffect = 166, noDamageBurnEffect = 167,
+ chargeEffect = 174, damageUserAtkAndDefMinusOneEffect = 182, damageRecoil33PercentEffect = 198,
+ teeterDanceEffect = 199, blazeKickEffect = 200, poisonFangEffect = 202, damageUserSpAtkMinusTwoEffect = 204,
+ noDamageAtkAndDefMinusOneEffect = 205, noDamageDefAndSpDefPlusOneEffect = 206, noDamageAtkAndDefPlusOneEffect = 208,
+ damagePoisonWithIncreasedCritEffect = 209, noDamageSpAtkAndSpDefPlusOneEffect = 211, noDamageAtkAndSpePlusOneEffect = 212,
+ damageUserSpeMinusOneEffect = 218, damageUserDefAndSpDefMinusOneEffect = 229, flareBlitzEffect = 253,
+ blizzardEffect = 260, voltTackleEffect = 262, bounceEffect = 263, noDamageSpAtkMinusTwoEffect = 265, chatterEffect = 267,
+ damageRecoil50PercentEffect = 269, damageSpDefMinusTwoEffect = 271, fireFangEffect = 273, iceFangEffect = 274,
+ thunderFangEffect = 275, damageUserSpAtkPlusOneEffect = 276;
public static final List<Integer> dpRequiredFieldTMs = Arrays.asList(2, 3, 5, 9, 12, 19, 23, 28,
34, 39, 41, 43, 46, 47, 49, 50, 62, 69, 79, 80, 82, 84, 85, 87);
diff --git a/src/com/sneed/pkrandom/pokemon/CriticalChance.java b/src/com/sneed/pkrandom/pokemon/CriticalChance.java
new file mode 100644
index 0000000..f7445d0
--- /dev/null
+++ b/src/com/sneed/pkrandom/pokemon/CriticalChance.java
@@ -0,0 +1,31 @@
+package com.sneed.pkrandom.pokemon;
+
+/*----------------------------------------------------------------------------*/
+/*-- CriticalChance.java - represents a move's odds to critical hit. --*/
+/*-- --*/
+/*-- Part of "Universal Pokemon Randomizer ZX" by the UPR-ZX team --*/
+/*-- Pokemon and any associated names and the like are --*/
+/*-- trademark and (C) Nintendo 1996-2020. --*/
+/*-- --*/
+/*-- The custom code written here is licensed under the terms of the GPL: --*/
+/*-- --*/
+/*-- This program is free software: you can redistribute it and/or modify --*/
+/*-- it under the terms of the GNU General Public License as published by --*/
+/*-- the Free Software Foundation, either version 3 of the License, or --*/
+/*-- (at your option) any later version. --*/
+/*-- --*/
+/*-- This program is distributed in the hope that it will be useful, --*/
+/*-- but WITHOUT ANY WARRANTY; without even the implied warranty of --*/
+/*-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --*/
+/*-- GNU General Public License for more details. --*/
+/*-- --*/
+/*-- You should have received a copy of the GNU General Public License --*/
+/*-- along with this program. If not, see <http://www.gnu.org/licenses/>. --*/
+/*----------------------------------------------------------------------------*/
+
+public enum CriticalChance {
+ NONE, // Phased out in Gen 5+
+ NORMAL,
+ INCREASED,
+ GUARANTEED
+}
diff --git a/src/com/sneed/pkrandom/pokemon/Move.java b/src/com/sneed/pkrandom/pokemon/Move.java
index f87da77..a9e42ff 100755
--- a/src/com/sneed/pkrandom/pokemon/Move.java
+++ b/src/com/sneed/pkrandom/pokemon/Move.java
@@ -38,21 +38,21 @@ public class Move {
public int pp;
public double hitratio;
public Type type;
+ public MoveCategory category;
public StatChangeMoveType statChangeMoveType = StatChangeMoveType.NONE_OR_UNKNOWN;
public StatChange[] statChanges = new StatChange[3];
public StatusMoveType statusMoveType = StatusMoveType.NONE_OR_UNKNOWN;
public StatusType statusType = StatusType.NONE;
+ public CriticalChance criticalChance = CriticalChance.NORMAL;
public double statusPercentChance;
public double flinchPercentChance;
public int recoilPercent;
public int absorbPercent;
+ public int priority;
+ public boolean makesContact;
public int effectIndex;
public int target;
- public MoveCategory category;
public double hitCount = 1; // not saved, only used in randomized move powers.
- public double secondaryEffectChance;
- public int priority;
- public boolean makesContact;
public Move() {
// Initialize all statStageChanges to something sensible so that we don't need to have
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen1RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen1RomHandler.java
index 275bd82..bc59cce 100755
--- a/src/com/sneed/pkrandom/romhandlers/Gen1RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen1RomHandler.java
@@ -466,25 +466,7 @@ public class Gen1RomHandler extends AbstractGBCRomHandler {
loadStatChangesFromEffect(moves[trueMoveIndex]);
loadStatusFromEffect(moves[trueMoveIndex]);
-
- switch (moves[i].effectIndex) {
- case Gen1Constants.flinch10PercentEffect:
- moves[i].flinchPercentChance = 10.0;
- break;
-
- case Gen1Constants.flinch30PercentEffect:
- moves[i].flinchPercentChance = 30.0;
- break;
-
- case Gen1Constants.damageAbsorbEffect:
- case Gen1Constants.dreamEaterEffect:
- moves[i].absorbPercent = 50;
- break;
-
- case Gen1Constants.damageRecoilEffect:
- moves[i].recoilPercent = 25;
- break;
- }
+ loadMiscMoveInfoFromEffect(moves[trueMoveIndex]);
}
}
}
@@ -676,6 +658,31 @@ public class Gen1RomHandler extends AbstractGBCRomHandler {
}
}
+ private void loadMiscMoveInfoFromEffect(Move move) {
+ switch (move.effectIndex) {
+ case Gen1Constants.flinch10PercentEffect:
+ move.flinchPercentChance = 10.0;
+ break;
+
+ case Gen1Constants.flinch30PercentEffect:
+ move.flinchPercentChance = 30.0;
+ break;
+
+ case Gen1Constants.damageAbsorbEffect:
+ case Gen1Constants.dreamEaterEffect:
+ move.absorbPercent = 50;
+ break;
+
+ case Gen1Constants.damageRecoilEffect:
+ move.recoilPercent = 25;
+ break;
+ }
+
+ if (Gen1Constants.increasedCritMoves.contains(move.number)) {
+ move.criticalChance = CriticalChance.INCREASED;
+ }
+ }
+
private void saveMoves() {
int movesOffset = romEntry.getValue("MoveDataOffset");
for (Move m : moves) {
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen2RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen2RomHandler.java
index 746b98f..03c57f7 100755
--- a/src/com/sneed/pkrandom/romhandlers/Gen2RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen2RomHandler.java
@@ -415,7 +415,6 @@ public class Gen2RomHandler extends AbstractGBCRomHandler {
if (moves[i].power == 0 && !GlobalConstants.noPowerNonStatusMoves.contains(i)) {
moves[i].category = MoveCategory.STATUS;
}
- moves[i].secondaryEffectChance = ((rom[offs + (i - 1) * 7 + 6] & 0xFF)) / 255.0 * 100;
if (i == Moves.swift) {
perfectAccuracy = (int)moves[i].hitratio;
@@ -443,30 +442,14 @@ public class Gen2RomHandler extends AbstractGBCRomHandler {
moves[i].priority = 1;
}
- loadStatChangesFromEffect(moves[i]);
- loadStatusFromEffect(moves[i]);
-
- switch (moves[i].effectIndex) {
- case Gen2Constants.flinchEffect:
- case Gen2Constants.snoreEffect:
- case Gen2Constants.twisterEffect:
- case Gen2Constants.stompEffect:
- moves[i].flinchPercentChance = moves[i].secondaryEffectChance;
- break;
-
- case Gen2Constants.damageAbsorbEffect:
- case Gen2Constants.dreamEaterEffect:
- moves[i].absorbPercent = 50;
- break;
-
- case Gen2Constants.damageRecoilEffect:
- moves[i].recoilPercent = 25;
- break;
- }
+ double secondaryEffectChance = ((rom[offs + (i - 1) * 7 + 6] & 0xFF)) / 255.0 * 100;
+ loadStatChangesFromEffect(moves[i], secondaryEffectChance);
+ loadStatusFromEffect(moves[i], secondaryEffectChance);
+ loadMiscMoveInfoFromEffect(moves[i], secondaryEffectChance);
}
}
- private void loadStatChangesFromEffect(Move move) {
+ private void loadStatChangesFromEffect(Move move, double secondaryEffectChance) {
switch (move.effectIndex) {
case Gen2Constants.noDamageAtkPlusOneEffect:
case Gen2Constants.damageUserAtkPlusOneEffect:
@@ -602,7 +585,7 @@ public class Gen2RomHandler extends AbstractGBCRomHandler {
if (move.statChangeMoveType == StatChangeMoveType.DAMAGE_TARGET || move.statChangeMoveType == StatChangeMoveType.DAMAGE_USER) {
for (int i = 0; i < move.statChanges.length; i++) {
if (move.statChanges[i].type != StatChangeType.NONE) {
- move.statChanges[i].percentChance = move.secondaryEffectChance;
+ move.statChanges[i].percentChance = secondaryEffectChance;
if (move.statChanges[i].percentChance == 0.0) {
move.statChanges[i].percentChance = 100.0;
}
@@ -611,7 +594,7 @@ public class Gen2RomHandler extends AbstractGBCRomHandler {
}
}
- private void loadStatusFromEffect(Move move) {
+ private void loadStatusFromEffect(Move move, double secondaryEffectChance) {
switch (move.effectIndex) {
case Gen2Constants.noDamageSleepEffect:
case Gen2Constants.toxicEffect:
@@ -670,13 +653,42 @@ public class Gen2RomHandler extends AbstractGBCRomHandler {
}
if (move.statusMoveType == StatusMoveType.DAMAGE) {
- move.statusPercentChance = move.secondaryEffectChance;
+ move.statusPercentChance = secondaryEffectChance;
if (move.statusPercentChance == 0.0) {
move.statusPercentChance = 100.0;
}
}
}
+ private void loadMiscMoveInfoFromEffect(Move move, double secondaryEffectChance) {
+ switch (move.effectIndex) {
+ case Gen2Constants.flinchEffect:
+ case Gen2Constants.snoreEffect:
+ case Gen2Constants.twisterEffect:
+ case Gen2Constants.stompEffect:
+ move.flinchPercentChance = secondaryEffectChance;
+ break;
+
+ case Gen2Constants.damageAbsorbEffect:
+ case Gen2Constants.dreamEaterEffect:
+ move.absorbPercent = 50;
+ break;
+
+ case Gen2Constants.damageRecoilEffect:
+ move.recoilPercent = 25;
+ break;
+
+ case Gen2Constants.flailAndReversalEffect:
+ case Gen2Constants.futureSightEffect:
+ move.criticalChance = CriticalChance.NONE;
+ break;
+ }
+
+ if (Gen2Constants.increasedCritMoves.contains(move.number)) {
+ move.criticalChance = CriticalChance.INCREASED;
+ }
+ }
+
private void saveMoves() {
int offs = romEntry.getValue("MoveDataOffset");
for (int i = 1; i <= 251; i++) {
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java
index 8f3a645..803a975 100755
--- a/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java
@@ -830,7 +830,6 @@ public class Gen3RomHandler extends AbstractGBRomHandler {
moves[i].category = MoveCategory.STATUS;
}
moves[i].priority = rom[offs + i * 0xC + 7];
- moves[i].secondaryEffectChance = rom[offs + i * 0xC + 5] & 0xFF;
int flags = rom[offs + i * 0xC + 8] & 0xFF;
moves[i].makesContact = (flags & 1) != 0;
@@ -838,30 +837,6 @@ public class Gen3RomHandler extends AbstractGBRomHandler {
perfectAccuracy = (int)moves[i].hitratio;
}
- switch (moves[i].effectIndex) {
- case Gen3Constants.flinchEffect:
- case Gen3Constants.skyAttackEffect:
- case Gen3Constants.snoreEffect:
- case Gen3Constants.twisterEffect:
- case Gen3Constants.flinchWithMinimizeBonusEffect:
- case Gen3Constants.fakeOutEffect:
- moves[i].flinchPercentChance = moves[i].secondaryEffectChance;
- break;
-
- case Gen3Constants.damageAbsorbEffect:
- case Gen3Constants.dreamEaterEffect:
- moves[i].absorbPercent = 50;
- break;
-
- case Gen3Constants.damageRecoil25PercentEffect:
- moves[i].recoilPercent = 25;
- break;
-
- case Gen3Constants.damageRecoil33PercentEffect:
- moves[i].recoilPercent = 33;
- break;
- }
-
if (GlobalConstants.normalMultihitMoves.contains(i)) {
moves[i].hitCount = 3;
} else if (GlobalConstants.doubleHitMoves.contains(i)) {
@@ -870,12 +845,14 @@ public class Gen3RomHandler extends AbstractGBRomHandler {
moves[i].hitCount = 2.71; // this assumes the first hit lands
}
- loadStatChangesFromEffect(moves[i]);
- loadStatusFromEffect(moves[i]);
+ int secondaryEffectChance = rom[offs + i * 0xC + 5] & 0xFF;
+ loadStatChangesFromEffect(moves[i], secondaryEffectChance);
+ loadStatusFromEffect(moves[i], secondaryEffectChance);
+ loadMiscMoveInfoFromEffect(moves[i], secondaryEffectChance);
}
}
- private void loadStatChangesFromEffect(Move move) {
+ private void loadStatChangesFromEffect(Move move, int secondaryEffectChance) {
switch (move.effectIndex) {
case Gen3Constants.noDamageAtkPlusOneEffect:
case Gen3Constants.noDamageDefPlusOneEffect:
@@ -1073,7 +1050,7 @@ public class Gen3RomHandler extends AbstractGBRomHandler {
if (move.statChangeMoveType == StatChangeMoveType.DAMAGE_TARGET || move.statChangeMoveType == StatChangeMoveType.DAMAGE_USER) {
for (int i = 0; i < move.statChanges.length; i++) {
if (move.statChanges[i].type != StatChangeType.NONE) {
- move.statChanges[i].percentChance = move.secondaryEffectChance;
+ move.statChanges[i].percentChance = secondaryEffectChance;
if (move.statChanges[i].percentChance == 0.0) {
move.statChanges[i].percentChance = 100.0;
}
@@ -1082,12 +1059,12 @@ public class Gen3RomHandler extends AbstractGBRomHandler {
}
}
- private void loadStatusFromEffect(Move move) {
+ private void loadStatusFromEffect(Move move, int secondaryEffectChance) {
if (move.number == Moves.bounce) {
// GF hardcoded this, so we have to as well
move.statusMoveType = StatusMoveType.DAMAGE;
move.statusType = StatusType.PARALYZE;
- move.statusPercentChance = move.secondaryEffectChance;
+ move.statusPercentChance = secondaryEffectChance;
return;
}
@@ -1114,7 +1091,7 @@ public class Gen3RomHandler extends AbstractGBRomHandler {
case Gen3Constants.thunderEffect:
case Gen3Constants.blazeKickEffect:
case Gen3Constants.poisonFangEffect:
- case Gen3Constants.damagePoisonWithIncreasedCritEffect:
+ case Gen3Constants.poisonTailEffect:
move.statusMoveType = StatusMoveType.DAMAGE;
break;
@@ -1130,7 +1107,7 @@ public class Gen3RomHandler extends AbstractGBRomHandler {
case Gen3Constants.damagePoisonEffect:
case Gen3Constants.noDamagePoisonEffect:
case Gen3Constants.twineedleEffect:
- case Gen3Constants.damagePoisonWithIncreasedCritEffect:
+ case Gen3Constants.poisonTailEffect:
move.statusType = StatusType.POISON;
break;
case Gen3Constants.damageBurnEffect:
@@ -1161,13 +1138,52 @@ public class Gen3RomHandler extends AbstractGBRomHandler {
}
if (move.statusMoveType == StatusMoveType.DAMAGE) {
- move.statusPercentChance = move.secondaryEffectChance;
+ move.statusPercentChance = secondaryEffectChance;
if (move.statusPercentChance == 0.0) {
move.statusPercentChance = 100.0;
}
}
}
+ private void loadMiscMoveInfoFromEffect(Move move, int secondaryEffectChance) {
+ switch (move.effectIndex) {
+ case Gen3Constants.increasedCritEffect:
+ case Gen3Constants.blazeKickEffect:
+ case Gen3Constants.poisonTailEffect:
+ move.criticalChance = CriticalChance.INCREASED;
+ break;
+
+ case Gen3Constants.futureSightAndDoomDesireEffect:
+ case Gen3Constants.spitUpEffect:
+ move.criticalChance = CriticalChance.NONE;
+
+ case Gen3Constants.flinchEffect:
+ case Gen3Constants.snoreEffect:
+ case Gen3Constants.twisterEffect:
+ case Gen3Constants.flinchWithMinimizeBonusEffect:
+ case Gen3Constants.fakeOutEffect:
+ move.flinchPercentChance = secondaryEffectChance;
+ break;
+
+ case Gen3Constants.skyAttackEffect:
+ move.criticalChance = CriticalChance.INCREASED;
+ move.flinchPercentChance = secondaryEffectChance;
+
+ case Gen3Constants.damageAbsorbEffect:
+ case Gen3Constants.dreamEaterEffect:
+ move.absorbPercent = 50;
+ break;
+
+ case Gen3Constants.damageRecoil25PercentEffect:
+ move.recoilPercent = 25;
+ break;
+
+ case Gen3Constants.damageRecoil33PercentEffect:
+ move.recoilPercent = 33;
+ break;
+ }
+ }
+
private void saveMoves() {
int moveCount = romEntry.getValue("MoveCount");
int offs = romEntry.getValue("MoveData");
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java
index 0422ab2..223ba55 100755
--- a/src/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java
@@ -574,7 +574,6 @@ public class Gen4RomHandler extends AbstractDSRomHandler {
moves[i].type = Gen4Constants.typeTable[moveData[4] & 0xFF];
moves[i].target = readWord(moveData, 8);
moves[i].category = Gen4Constants.moveCategoryIndices[moveData[2] & 0xFF];
- moves[i].secondaryEffectChance = moveData[7] & 0xFF;
moves[i].priority = moveData[10];
int flags = moveData[11] & 0xFF;
moves[i].makesContact = (flags & 1) != 0;
@@ -591,48 +590,17 @@ public class Gen4RomHandler extends AbstractDSRomHandler {
moves[i].hitCount = 2.71; // this assumes the first hit lands
}
- loadStatChangesFromEffect(moves[i]);
- loadStatusFromEffect(moves[i]);
-
- switch (moves[i].effectIndex) {
- case Gen4Constants.flinchEffect:
- case Gen4Constants.skyAttackEffect:
- case Gen4Constants.snoreEffect:
- case Gen4Constants.twisterEffect:
- case Gen4Constants.stompEffect:
- case Gen4Constants.fakeOutEffect:
- case Gen4Constants.fireFangEffect:
- case Gen4Constants.iceFangEffect:
- case Gen4Constants.thunderFangEffect:
- moves[i].flinchPercentChance = moves[i].secondaryEffectChance;
- break;
-
- case Gen4Constants.damageAbsorbEffect:
- case Gen4Constants.dreamEaterEffect:
- moves[i].absorbPercent = 50;
- break;
-
- case Gen4Constants.damageRecoil25PercentEffect:
- moves[i].recoilPercent = 25;
- break;
-
- case Gen4Constants.damageRecoil33PercentEffect:
- case Gen4Constants.flareBlitzEffect:
- case Gen4Constants.voltTackleEffect:
- moves[i].recoilPercent = 33;
- break;
-
- case Gen4Constants.damageRecoil50PercentEffect:
- moves[i].recoilPercent = 50;
- break;
- }
+ int secondaryEffectChance = moveData[7] & 0xFF;
+ loadStatChangesFromEffect(moves[i], secondaryEffectChance);
+ loadStatusFromEffect(moves[i], secondaryEffectChance);
+ loadMiscMoveInfoFromEffect(moves[i], secondaryEffectChance);
}
} catch (IOException e) {
throw new RandomizerIOException(e);
}
}
- private void loadStatChangesFromEffect(Move move) {
+ private void loadStatChangesFromEffect(Move move, int secondaryEffectChance) {
switch (move.effectIndex) {
case Gen4Constants.noDamageAtkPlusOneEffect:
case Gen4Constants.noDamageDefPlusOneEffect:
@@ -845,7 +813,7 @@ public class Gen4RomHandler extends AbstractDSRomHandler {
if (move.statChangeMoveType == StatChangeMoveType.DAMAGE_TARGET || move.statChangeMoveType == StatChangeMoveType.DAMAGE_USER) {
for (int i = 0; i < move.statChanges.length; i++) {
if (move.statChanges[i].type != StatChangeType.NONE) {
- move.statChanges[i].percentChance = move.secondaryEffectChance;
+ move.statChanges[i].percentChance = secondaryEffectChance;
if (move.statChanges[i].percentChance == 0.0) {
move.statChanges[i].percentChance = 100.0;
}
@@ -854,7 +822,7 @@ public class Gen4RomHandler extends AbstractDSRomHandler {
}
}
- private void loadStatusFromEffect(Move move) {
+ private void loadStatusFromEffect(Move move, int secondaryEffectChance) {
switch (move.effectIndex) {
case Gen4Constants.noDamageSleepEffect:
case Gen4Constants.toxicEffect:
@@ -941,7 +909,7 @@ public class Gen4RomHandler extends AbstractDSRomHandler {
}
if (move.statusMoveType == StatusMoveType.DAMAGE) {
- move.statusPercentChance = move.secondaryEffectChance;
+ move.statusPercentChance = secondaryEffectChance;
if (move.statusPercentChance == 0.0) {
if (move.number == Moves.chatter) {
move.statusPercentChance = 1.0;
@@ -952,6 +920,55 @@ public class Gen4RomHandler extends AbstractDSRomHandler {
}
}
+ private void loadMiscMoveInfoFromEffect(Move move, int secondaryEffectChance) {
+ switch (move.effectIndex) {
+ case Gen4Constants.razorWindEffect:
+ case Gen4Constants.increasedCritEffect:
+ case Gen4Constants.blazeKickEffect:
+ case Gen4Constants.damagePoisonWithIncreasedCritEffect:
+ move.criticalChance = CriticalChance.INCREASED;
+ break;
+
+ case Gen4Constants.futureSightAndDoomDesireEffect:
+ move.criticalChance = CriticalChance.NONE;
+
+ case Gen4Constants.flinchEffect:
+ case Gen4Constants.snoreEffect:
+ case Gen4Constants.twisterEffect:
+ case Gen4Constants.stompEffect:
+ case Gen4Constants.fakeOutEffect:
+ case Gen4Constants.fireFangEffect:
+ case Gen4Constants.iceFangEffect:
+ case Gen4Constants.thunderFangEffect:
+ move.flinchPercentChance = secondaryEffectChance;
+ break;
+
+ case Gen4Constants.skyAttackEffect:
+ move.criticalChance = CriticalChance.INCREASED;
+ move.flinchPercentChance = secondaryEffectChance;
+ break;
+
+ case Gen4Constants.damageAbsorbEffect:
+ case Gen4Constants.dreamEaterEffect:
+ move.absorbPercent = 50;
+ break;
+
+ case Gen4Constants.damageRecoil25PercentEffect:
+ move.recoilPercent = 25;
+ break;
+
+ case Gen4Constants.damageRecoil33PercentEffect:
+ case Gen4Constants.flareBlitzEffect:
+ case Gen4Constants.voltTackleEffect:
+ move.recoilPercent = 33;
+ break;
+
+ case Gen4Constants.damageRecoil50PercentEffect:
+ move.recoilPercent = 50;
+ break;
+ }
+ }
+
private void loadPokemonStats() {
try {
String pstatsnarc = romEntry.getFile("PokemonStats");
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java
index 023b861..4791888 100755
--- a/src/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java
@@ -559,6 +559,14 @@ public class Gen5RomHandler extends AbstractDSRomHandler {
moves[i].target = moveData[20] & 0xFF;
moves[i].category = Gen5Constants.moveCategoryIndices[moveData[2] & 0xFF];
moves[i].priority = moveData[6];
+
+ int critStages = moveData[14] & 0xFF;
+ if (critStages == 6) {
+ moves[i].criticalChance = CriticalChance.GUARANTEED;
+ } else if (critStages > 0) {
+ moves[i].criticalChance = CriticalChance.INCREASED;
+ }
+
int flags = FileFunctions.readFullInt(moveData, 32);
moves[i].makesContact = (flags & 1) != 0;
int qualities = moveData[1];
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java
index b107b0a..e4c9bde 100644
--- a/src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java
@@ -610,6 +610,14 @@ public class Gen6RomHandler extends Abstract3DSRomHandler {
moves[i].target = moveData[20] & 0xFF;
moves[i].category = Gen6Constants.moveCategoryIndices[moveData[2] & 0xFF];
moves[i].priority = moveData[6];
+
+ int critStages = moveData[14] & 0xFF;
+ if (critStages == 6) {
+ moves[i].criticalChance = CriticalChance.GUARANTEED;
+ } else if (critStages > 0) {
+ moves[i].criticalChance = CriticalChance.INCREASED;
+ }
+
int flags = FileFunctions.readFullInt(moveData, 32);
moves[i].makesContact = (flags & 1) != 0;
int qualities = moveData[1];
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java
index 1e2ed98..9d4ceb7 100644
--- a/src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java
@@ -682,6 +682,14 @@ public class Gen7RomHandler extends Abstract3DSRomHandler {
moves[i].target = moveData[20] & 0xFF;
moves[i].category = Gen7Constants.moveCategoryIndices[moveData[2] & 0xFF];
moves[i].priority = moveData[6];
+
+ int critStages = moveData[14] & 0xFF;
+ if (critStages == 6) {
+ moves[i].criticalChance = CriticalChance.GUARANTEED;
+ } else if (critStages > 0) {
+ moves[i].criticalChance = CriticalChance.INCREASED;
+ }
+
int flags = FileFunctions.readFullInt(moveData, 36);
moves[i].makesContact = (flags & 1) != 0;
int qualities = moveData[1];