forked from mirrors/cobblemon
Merge branch 'alpha-moveset-fix' into 'main'
Fixed alpha pokemon not using full movesets See merge request cable-mc/cobblemon!2263
This commit is contained in:
@@ -674,9 +674,6 @@ open class PokemonProperties {
|
||||
@JvmOverloads
|
||||
fun createEntity(world: Level, player: ServerPlayer? = null): PokemonEntity {
|
||||
val pokemon = create(player)
|
||||
if (pokemon.isAlpha) {
|
||||
pokemon.initializeMovesetWithRandomTm()
|
||||
}
|
||||
return PokemonEntity(world, pokemon).also { applyCustomProperties(it) }
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ class FishingSpawnCause(
|
||||
return
|
||||
}
|
||||
pokemonEntity.pokemon.isAlpha = true
|
||||
pokemonEntity.pokemon.initializeMovesetWithRandomTm(2)
|
||||
pokemonEntity.pokemon.initializeMovesetFromDefault()
|
||||
if (!pokemonEntity.level().isClientSide) {
|
||||
// Alpha status is applied after entity creation in bait flows, so rebuild the brain
|
||||
// to ensure alpha-only sensors/memories are actually attached.
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ class SaccharineLogSlatheredInfluence(val pos: BlockPos? = null) : SpawningInflu
|
||||
val chance = Cobblemon.config.honeySlatherAlphaChance
|
||||
if (chance > 0 && Random.nextInt(chance) == 0) {
|
||||
pokemon.isAlpha = true
|
||||
pokemon.initializeMovesetWithRandomTm(2)
|
||||
pokemon.initializeMovesetFromDefault()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -384,7 +384,7 @@ class FossilMultiblockStructure (
|
||||
val chance = Cobblemon.config.fossilMachineAlphaChance
|
||||
if (Random.nextInt(chance) == 0) {
|
||||
pokemon.isAlpha = true
|
||||
pokemon.initializeMovesetWithRandomTm(2)
|
||||
pokemon.initializeMovesetFromDefault()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1891,7 +1891,12 @@ open class Pokemon : ShowdownIdentifiable {
|
||||
}
|
||||
|
||||
fun initializeMovesetFromDefault() {
|
||||
initializeMovesetFrom(movesetBuilder = CobblemonMovesetBuilders.getOrThrow(form.defaultWildMovesetBuilder))
|
||||
val movesetBuilderId = if (isAlpha) {
|
||||
cobblemonResource("alpha")
|
||||
} else {
|
||||
form.defaultWildMovesetBuilder
|
||||
}
|
||||
initializeMovesetFrom(movesetBuilder = CobblemonMovesetBuilders.getOrThrow(movesetBuilderId))
|
||||
}
|
||||
|
||||
fun initializeMovesetFrom(movesetBuilder: MovesetBuilder) {
|
||||
@@ -1899,53 +1904,6 @@ open class Pokemon : ShowdownIdentifiable {
|
||||
moveSet.copyFrom(newMoveset)
|
||||
}
|
||||
|
||||
fun initializeMovesetWithRandomTm(moveCount: Int = MoveSet.MOVE_COUNT): Boolean {
|
||||
val numTMMoves = moveCount.coerceIn(1, MoveSet.MOVE_COUNT)
|
||||
|
||||
val tmMoves = form.moves.tmMoves.distinct().toMutableList()
|
||||
if (tmMoves.isEmpty()) {
|
||||
return false
|
||||
}
|
||||
|
||||
tmMoves.shuffle()
|
||||
val tmCount = min(numTMMoves, tmMoves.size)
|
||||
moveSet.doWithoutEmitting {
|
||||
moveSet.clear()
|
||||
val selectedMoves = mutableSetOf<MoveTemplate>()
|
||||
for (i in 0 until tmCount) {
|
||||
val selectedTm = tmMoves[i]
|
||||
moveSet.setMove(i, selectedTm.create())
|
||||
moveSet[i]?.update()
|
||||
selectedMoves.add(selectedTm)
|
||||
}
|
||||
|
||||
// Fill blank moveset slots with random benched moves
|
||||
if (tmCount < MoveSet.MOVE_COUNT) {
|
||||
val benchedCandidates = benchedMoves
|
||||
.filter { benchedMove ->
|
||||
benchedMove.moveTemplate !is MoveTemplate.Dummy &&
|
||||
benchedMove.moveTemplate !in selectedMoves
|
||||
}
|
||||
.distinctBy { it.moveTemplate }
|
||||
.shuffled()
|
||||
|
||||
var nextMoveSlot = tmCount
|
||||
for (benchedMove in benchedCandidates) {
|
||||
if (nextMoveSlot >= MoveSet.MOVE_COUNT) {
|
||||
break
|
||||
}
|
||||
|
||||
moveSet.setMove(nextMoveSlot, Move(benchedMove.moveTemplate, benchedMove.ppRaisedStages))
|
||||
moveSet[nextMoveSlot]?.update()
|
||||
selectedMoves.add(benchedMove.moveTemplate)
|
||||
nextMoveSlot++
|
||||
}
|
||||
}
|
||||
}
|
||||
moveSet.update()
|
||||
return true
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
message = "Will be removed with a title update, maybe as early as 1.9",
|
||||
replaceWith = ReplaceWith("initializeMovesetFromDefault() or initializeMovesetFrom(movesetBuilder)"),
|
||||
|
||||
Reference in New Issue
Block a user