Compare commits

..
Author SHA1 Message Date
Test bc0d530484 loisence 2026-01-20 19:19:53 -05:00
Test 1537816132 log of change 2026-01-20 00:56:36 -05:00
Test 1705639950 loot 2026-01-20 00:50:04 -05:00
Test ce32541dd6 Merge branch 'main' of https://gitlab.com/cable-mc/cobblemon into decor-split 2026-01-19 23:45:28 -05:00
Test 3ffea4f4dd split items 2026-01-19 23:44:20 -05:00
Hiroku f942d7c34a Merge branch 'misc-additions-fixes' into 'main'
Couple of misc API additions and bug fixes.

See merge request cable-mc/cobblemon!2125
2026-01-19 02:16:09 +00:00
Deltric 0f1ada4624 Pass in pnx to the event 2026-01-18 18:52:27 -06:00
Deltric b4ee4629bf Couple of misc API additions and bug fixes. 2026-01-18 17:57:28 -06:00
Paul d0b64e2d82 Respect the BYPASSES_INVULNERABILITY damage tag 2026-01-18 22:12:25 +10:00
Paul 1ed2042283 Fixed /calculateseatpositions expecting no underscore when actually we always use an underscore 2026-01-17 22:32:57 +10:00
Hiroku 948ca61ef3 Merge branch 'fix-super-potion-ingredients-tag' into 'main'
Fix super potion ingredients tag

See merge request cable-mc/cobblemon!2121
2026-01-16 08:27:19 +00:00
Hiroku e60aca30ba Merge branch 'patch-2' into 'main'
Fix Syrupy Apple missing from evolution items tag

See merge request cable-mc/cobblemon!2120
2026-01-16 08:26:22 +00:00
Hiroku fb5055c39e Merge branch 'form_crash' into 'main'
Initialize FormData when updating

Closes #1916

See merge request cable-mc/cobblemon!2122
2026-01-16 08:20:23 +00:00
Paul dfb5650121 Merge remote-tracking branch 'origin/main' 2026-01-16 18:17:01 +10:00
Paul 8a0cbf28fe Fixed battles not ending fully when a switch is in progress, closes #1917 2026-01-16 18:16:11 +10:00
aeroeng15 a6b9060d57 Changelog 2026-01-15 20:54:54 -07:00
aeroeng15 8e57995e44 Make It Proper 2026-01-15 20:51:59 -07:00
aeroeng15 1d8257808c Initialize rather than set; seems to fix the issue 2026-01-15 20:42:14 -07:00
Faintful e3582ccfb4 Add changelog 2026-01-14 19:49:11 +01:00
Faintful 4c6822b1c6 Merge remote-tracking branch 'upstream/main' into fix-super-potion-ingredients-tag 2026-01-14 19:46:54 +01:00
Faintful 2e6a4c7341 Change Hondew for Aguav 2026-01-14 19:28:49 +01:00
Micky 8edb5e1013 Fix Syrupy Apple missing from evolution items tag 2026-01-14 18:25:06 +00:00
Polymeta 6fb139cbb9 Merge branch 'pokemon-interactions-fixes' into 'main'
Pokémon Interaction fixes

See merge request cable-mc/cobblemon!2117
2026-01-14 00:03:33 +00:00
lionandPolymeta c81c95142b Pokémon Interaction fixes 2026-01-14 00:03:32 +00:00
Hiroku afde822860 Edit CHANGELOG.md [skip-ci] 2026-01-12 10:50:47 +00:00
Hiroku 474c386535 Merge branch 'main' into 'main'
Fix Fresh Start Mochi EV Reset

See merge request cable-mc/cobblemon!2115
2026-01-12 10:48:40 +00:00
ToothCollector 71b9ae8dee add fix to CHANGELOG.md 2026-01-11 21:31:22 +02:00
ToothCollector b87b47d62a Merge branch 'main' of https://gitlab.com/cable-mc/cobblemon 2026-01-11 21:28:04 +02:00
Hiroku 2bb85718d7 Merge branch 'main' into 'main'
Fix Adorn compatibility

See merge request cable-mc/cobblemon!2112
2026-01-11 12:21:25 +00:00
Tate Frost ee187d7b89 Delete file + update Adorn resource pack metadata
- Delete config file that was committed in error
- Update Adorn resource pack metadata to reflect new wood type
2026-01-10 22:30:27 -06:00
Tate Frost 3532cac278 Update CHANGELOG.md 2026-01-10 22:18:01 -06:00
Hiroku 1447ab25b4 Merge branch 'CombeeWorldGenFix' into 'main'
CombeeWorldGenFix

See merge request cable-mc/cobblemon!2071
2026-01-11 02:55:56 +00:00
Hiroku 9a06ca78c6 Merge branch 'fix-mongo-driver' into 'main'
Fix MongoDB ClassNotFoundException by including drivers at runtime

See merge request cable-mc/cobblemon!2098
2026-01-11 02:47:10 +00:00
Hiroku f6ba70634b Merge branch 'double-battle-gimmicks' into 'main'
Fix double battle gimmicks not being processed

See merge request cable-mc/cobblemon!2094
2026-01-11 02:46:36 +00:00
Hiroku 148fd04a93 Merge branch 'molang-evaluate_expression' into 'main'
molang addition: exception handling for run_molang

See merge request cable-mc/cobblemon!2102
2026-01-11 02:12:07 +00:00
Hiroku 17f60623ee Merge branch 'effect-id-regex-update' into 'main'
Custom messages for datapack moves and abilities

See merge request cable-mc/cobblemon!2106
2026-01-11 02:08:42 +00:00
Hiroku c5ece27c11 Merge branch '1861-galarien_mrmime_mount' into 'main'
Fix Galarian Mr. Mime incorrectly being rideable.

Closes #1861

See merge request cable-mc/cobblemon!2107
2026-01-11 02:02:14 +00:00
Hiroku 296ccd1a76 Merge branch 'main' into 'main'
Fix pasture block incorrect hit-box when facing north and south.

See merge request cable-mc/cobblemon!2109
2026-01-11 02:01:44 +00:00
ToothCollector 82a4f71f24 fix(FreshStartMochiItem.kt): Set all Pokemon's EVs to zero with the appropriate method. 2026-01-10 17:10:15 +02:00
Tate Frost 08b58e2f78 Fix Adorn compatibility
- Fixed Apricorn block model rotation for counters/sinks/cupboards/drawers to match that of most recent version of Adorn
- Added Saccharine wood + Adorn compatibility
2026-01-07 02:04:52 -06:00
Merv 62d2b8db2d Edit CHANGELOG.md 2026-01-06 18:47:45 +00:00
Merv 3869f7ed93 Merge branch cobblemon:main into main 2026-01-05 23:09:08 +00:00
Dragonwhisper92 c9c44872d6 Updated Changelog. 2026-01-05 19:35:05 +00:00
Dragonwhisper92 cae53efedc Updated ActivateInstruction.kt to have an optional message parameter. 2026-01-05 19:14:40 +00:00
Polymeta 5fac24cee8 Merge branch 'Molang-SimpleDateFormat-Fix' into 'main'
Fixed Molang functions:

See merge request cable-mc/cobblemon!2105
2026-01-05 11:22:45 +00:00
Polymeta 1954dfec80 Merge branch '1784-riding_stats_order' into 'main'
Fix riding stat boosts to always render in the same order

Closes #1784

See merge request cable-mc/cobblemon!2108
2026-01-05 11:20:29 +00:00
Landon 2eea2b64c2 Merge branch 'bag-clause' into 'main'
Bag Clause (Preventing Item use in Battles)

See merge request cable-mc/cobblemon!1849
2026-01-05 08:12:36 +00:00
GDWR a127a93be8 Sort boosts when rendering to remove the jumping of stats between items
The sort uses the key. As `RidingStat` it sorts them by the enum value.
2026-01-04 20:27:42 +00:00
GDWR 9b32f85817 Set an empty riding definition for Galarian Mr. Mime to avoid inheriting the default definition 2026-01-04 17:28:02 +00:00
Dragonwhisper92 ec139d2677 Updated Effect.kt to use a custom REGEX entry 2026-01-04 16:46:44 +00:00
Landon Wills 4327be0cf9 Omit bag clause from getting sent to showdown 2026-01-04 02:22:32 -05:00
Landon Wills c25c832b31 Remove import 2026-01-04 01:21:20 -05:00
Landon Wills eabaabc535 Move bag clause check to bag items instead of pokemon entity 2026-01-04 01:19:26 -05:00
Dragonwhisper92 9acf97f5a0 Updated CHANGELOG.md 2026-01-04 00:18:24 +00:00
Dragonwhisper92 24fc212c76 Updated CHANGELOG.md 2026-01-04 00:15:32 +00:00
Hiroku 04f88bdd63 Merge branch 'form-change-move-sanitization-fix' into 'main'
Fix the improper sanitization of moves on mons with compounding properties

Closes #1853 and #1846

See merge request cable-mc/cobblemon!2085
2026-01-04 00:05:26 +00:00
Dragonwhisper92 a4eb58aa57 Fixed molang functions:
- date_local_time
- date_of
- date_is_after
too use the correct SimpleDateFormat of "dd/MM/yyyy"
2026-01-03 23:40:12 +00:00
Merv 6704d4e5ee Maybe fix pasture block incorrect hitbox 2026-01-03 02:05:03 +00:00
Hiroku c88087de29 Merge branch 'main' into 'main'
Small improvements to the Battle AI

See merge request cable-mc/cobblemon!2101
2026-01-02 00:38:26 +00:00
Konoha 86bb802140 adjustment: exception handling to run_molang 2026-01-01 11:44:29 -05:00
GGavino1 6b644b384d Updated CHANGELOG.md to include AI changes 2026-01-01 15:00:15 +00:00
Konoha c370af8914 feature: molang function for safe evaluation of booleans 2025-12-31 22:23:50 -05:00
GGavino1 1cd6d2bfc7 Edit StrongBattleAI.kt 2025-12-31 23:15:52 +00:00
Test fc720916fb wall block properties 2025-12-31 00:24:39 -05:00
Konoha 1edeae2a60 fix: let's actually fix 2025-12-27 09:48:49 -05:00
mkh 409f1056b9 fix: Add MongoDB driver dependency to Fabric/NeoForge build configuration and shade it into the mod jar to resolve ClassNotFoundException. 2025-12-26 17:31:46 +08:00
Landon Wills d8c470db3d Oops, forgot a file 2025-12-23 01:28:50 -05:00
Landon Wills c642c4b84b Update changelog 2025-12-23 01:22:01 -05:00
Landon Wills 0b80f7e547 Make the gimmick buttons work with the back button 2025-12-23 01:18:35 -05:00
Landon Wills d543f45607 Fix double battle gimmicks not being processed, prevent people from trying to use the same gimmick multiple times on the same turn 2025-12-23 00:43:31 -05:00
Test e5699c1cdc plaques, policies 2025-12-22 01:34:10 -05:00
Konoha 2b4fdfd219 changelog: sanitization fix 2025-12-21 15:40:17 -05:00
Konoha ce611cc61c cleanup: fix redundancies in form change sanitization 2025-12-18 21:17:48 -05:00
JazzMcNade d69627a9c8 Merge branch 'main' into CombeeWorldGenFix 2025-12-17 20:05:09 -06:00
Konoha 7f008d85ff fix: form_change move updates no longer sanitize the sets of compounding property mons 2025-12-13 18:37:37 -05:00
JazzMcNade 8540a73885 Fix for error occurring while populating bee nests with pokemon on world gen 2025-12-04 01:38:56 -06:00
Konoha aee89f1c92 Preliminary Bag Clause implementation 2025-09-09 18:15:37 -04:00
569 changed files with 14229 additions and 4142 deletions
+44 -13
View File
@@ -4,8 +4,6 @@
### Additions
- Added riding statistics: `Distance by Pokémon on Land`, `Distance by Pokémon in Air` and `Distance by Pokémon in Liquid`.
- Added the Partner Mark, which party Pokémon have a very small chance to earn as the player walks, provided they have enough friendship.
- Added trades for Saccharine Saplings, Hearty Grains, Chipped Pot, and Masterpiece Teacup to the Wandering Trader.
- Added brewing recipe for Throat Spray.
- Added new effects
- Mental Restoration: Reduces "Time Since Last Rest" statistic, which controls Insomnia, by half a minute per second per effect level
- Negative Effect Cleanse: Removes all negative effects
@@ -16,39 +14,72 @@
- Milk - Effect Cleanse
- Moomoo Milk - Effect Cleanse
- Added `label` as an alternate key to the `tag` property.
- Added Saccharine wood furniture for Adorn.
- Added block models for existing items: Potion, Super Potion, Hyper Potion, Max Potion, Full Restore, Antidote, Awakening, Burn Heal, Ice Heal, Paralyze Heal, Full Heal, Ether, Elixir, Max Ether, Max Elixir, X Accuracy, X Attack, X Defence, X Special Attack, X Special Defence, X Speed, Dire Hit, Guard Spec, Weakness Policy, Blunder Policy, Cleanse Tag, and Spell Tag.
- Added decorative sign blocks, Plaques.
### Changes
- Ride sounds have been separated into stereo for passengers and mono for other players. Riding will now sound more spacious.
- Added a new config option, `Enable In-Flight Dismounting` (default: off), which lets you dismount while riding a Pokémon in the air.
- Battle AI now uses a smarter threshold for switching, reducing unnecessary switches.
- AI will always use the most damaging move when at low HP and when it is not switching, improving endgame decision-making.
- Added support for optional message variants in battle activate instructions for more context-specific battle text.
- Example: `this.add('-activate', pokemon, 'ability: example', '[msg]message1');` will parse to lang key `cobblemon.battle.activate.example.message1`
### Fixes
- Fixed an issue in the OmniPathNodeMaker/Navigation that prevented Combees from pathing into and out of Saccharine leaves.
- Fixed an issue in the OmniPathNodeMaker/Navigation that prevented Combee from pathing into and out of Saccharine Leaves.
- Fixed orientation not getting reset after crashing while flying and getting back on the Pokémon.
- Fixed Furfrou not being trimmable on NeoForge.
- Fixed shiny Pokémon not respecting the silent flag on spawn.
- Fixed honey from Saccharine Leaves being harvestable at less than the max age.
- Items given from interacting with Saccharine Leaves are placed in the active hotbar slot if possible.
- Fix all Pokémon being saved to chunks and never despawning.
- Fixed PokeSnacks crashing if there was no available spawn.
- Fixed Pokémon spawn influences not being specific to regional forms
- Fixed crashing when viewing another player in spectator mode
- Fixed missing apricorn textures for Adorn blocks
- Fixed crashing when riding due to malformed json file, instead resetting it
- Fixed mochi items consuming two items at a time
- Fixed possible error on world generation when Combee are placed in naturally generated bee nests.
- Fixed Poké Snacks crashing if there was no available spawn.
- Fixed Pokémon spawn influences not being specific to regional forms.
- Fixed crashing when viewing another player in spectator mode.
- Fixed missing apricorn textures for Adorn blocks.
- Fixed crashing when riding due to malformed json file instead of resetting it.
- Fixed mochi items consuming two items at a time.
- Fix item interaction sometimes not working properly when playing on servers.
- Fixed Soothe Bell not being properly tagged as a held item.
- Fixed Mint Leaves not being usable for filling the Resurrection Machine.
- Added Saccharine Boats and Saccharine Boat with Chests to relevant boat tags.
- Fixed the `run_script` Molang function to not fail if the environment's context is null.
- Fixed battle item duplication issue.
- Fixed the movesets of certain Pokémon being incorrectly sanitized upon reload.
- Fixed the ordering of Aprijuice's riding stat boosts to always have the same order.
- Fixed the Molang functions `date_local_time`, `date_of`, `date_is_after` to use the correct date format.
- Fixed the bottom half of pasture blocks having an incorrect hit-box when facing north or south.
- Fixed Galarian Mr. Mime incorrectly being rideable.
- Fixed gimmicks not being usable in double / triple battles.
- Fixed gimmick buttons showing when already used in the same turn in double / triple battles.
- Fixed Apricorn block model rotation for counters/sinks/cupboards/drawers to match that of most recent version of Adorn.
- Fixed Fresh Start Mochi EV reset not syncing health changes properly.
- Fixed requirements such as `biomeCondition` crashing the game when used to define Pokémon interactions.
- Fixed Pokémon interactions not playing sound effects when the volume was not specified.
- Fixed Pokémon interaction cooldowns taking longer than intended when the Pokémon was in the player’s party.
- Fixed Pokémon interactions occasionally crashing the game when spamming an interaction with a 0 cooldown.
- Fixed Pokémon fullness decreasing more than intended when the Pokémon was pastured.
- Fixed crashing when sending a Pokémon out after editing its form.
- Fixed Super Potion recipes incorrectly using Hondew Berry instead of Aguav Berry.
- Fixed `/calculateseatpositions` expecting a locator format that even we don't use. It needs an underscore after "seat".
- Fixed invulnerability-bypassed damage being resisted by invulnerable NPC entities.
- Fixed selected leading Pokémon in battle not being used when levels are raised.
- Fixed killer not being set early enough on a wild wild Pokémon entity from WinInstruction.
### Developer
- Changed the `owner` parameter in the `OwnerQueryRequirement` interface from `ServerPlayer` to `Player`. This method is now also called on the client to verify whether a Pokémon interaction succeeded, so make sure to update your implementations to handle both server and client contexts.
- Changed the `owner` parameter in the `OwnerQueryRequirement` interface from `ServerPlayer` to `Player`. This method is now also called on the client to verify whether a Pokémon interaction succeeded, so make sure to update your implementations to handle both server and client contexts.
- Added `pnx` to the `BattleFaintedEvent` and `FormeChangeEvent`.
- Added register methods for custom instructions to `ShowdownInterpreter`.
- Changed callback operations in `BattlePokemon` to allow multiple callbacks and is now mutable.
### Molang & Datapacks
- Ride sounds can now be set as exclusive to passengers
- Ride sounds no longer play when submerged unless specified with a new setting
- Ride sounds can now be set as exclusive to passengers.
- Ride sounds no longer play when submerged unless specified with a new setting.
- Exception handling has been added to `run_molang`, resolving some crashes caused by malformed MoLang expressions.
### Particles
### Localization
- Updated translations for:
- Updated translations for:
@@ -11,7 +11,9 @@ package com.cobblemon.mod.common.mixin;
import com.cobblemon.mod.common.CobblemonMemories;
import com.cobblemon.mod.common.api.ai.config.task.PathToBeeHiveTaskConfig;
import com.cobblemon.mod.common.api.pokemon.PokemonProperties;
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
import com.cobblemon.mod.common.world.feature.SaccharineTreeFeature;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tags.BlockTags;
@@ -42,7 +44,21 @@ public abstract class BeeOccupantMixin {
if (cir.getReturnValue() == null) {
final BeehiveBlockEntity.Occupant occupant = (BeehiveBlockEntity.Occupant) (Object) this;
CompoundTag compoundTag = occupant.entityData().copyTag();
Entity entity = EntityType.loadEntityRecursive(compoundTag, level, (entityx) -> entityx);
String id = compoundTag.getString("id");
Entity entity = null;
if (id.equals(SaccharineTreeFeature.Companion.getPOKEMON_PLACEHOLD_ID())) {
// Special case for Pokemon stuffed into a beenest upon world gen.
// For technical reasons we cannot create them as full entities during world gen.
// So we look for this special id tag and complete the entity when it attempts to exit a hive.
if (compoundTag.contains("pokemonProperties")) {
String properties = compoundTag.getString("pokemonProperties");
PokemonProperties pokemon = PokemonProperties.Companion.parse(properties);
entity = pokemon.createEntity(level);
}
} else {
entity = EntityType.loadEntityRecursive(compoundTag, level, (entityx) -> entityx);
}
if (entity instanceof PokemonEntity pokemonEntity) {
var state = level.getBlockState(pos);
var newPos = Vec3.ZERO;
@@ -9,6 +9,7 @@
package com.cobblemon.mod.common
import com.cobblemon.mod.common.api.apricorn.Apricorn
import com.cobblemon.mod.common.api.pokemon.stats.Stats
import com.cobblemon.mod.common.block.*
import com.cobblemon.mod.common.block.campfirepot.CampfireBlock
import com.cobblemon.mod.common.block.LecternBlock
@@ -41,11 +42,11 @@ import net.minecraft.world.level.block.state.BlockBehaviour
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.properties.BlockSetType
import net.minecraft.world.level.block.state.properties.BlockStateProperties
import net.minecraft.world.level.block.state.properties.BlockStateProperties.LIT
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument
import net.minecraft.world.level.block.state.properties.WoodType
import net.minecraft.world.level.material.MapColor
import net.minecraft.world.level.material.PushReaction
import net.minecraft.world.phys.shapes.Shapes
@Suppress("SameParameterValue", "HasPlatformType", "MemberVisibilityCanBePrivate", "unused")
object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<Block>>, Block>() {
@@ -243,9 +244,9 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
val REVIVAL_HERB = this.create("revival_herb", RevivalHerbBlock(BlockBehaviour.Properties.of().pushReaction(PushReaction.DESTROY).mapColor(MapColor.PLANT).ignitedByLava().noCollission().instabreak().sound(CobblemonSounds.REVIVAL_HERB_SOUNDS)))
@JvmField
val POKE_CAKE = this.create("poke_cake", PokeSnackBlock(BlockBehaviour.Properties.of().forceSolidOn().strength(0.5F).sound(SoundType.WOOL).pushReaction(PushReaction.DESTROY).lightLevel { if (it.getValue(LIT)) 3 else 0 }, false))
val POKE_CAKE = this.create("poke_cake", PokeSnackBlock(BlockBehaviour.Properties.of().forceSolidOn().strength(0.5F).sound(SoundType.WOOL).pushReaction(PushReaction.DESTROY).lightLevel { if (it.getValue(BlockStateProperties.LIT)) 3 else 0 }, false))
@JvmField
val POKE_SNACK = this.create("poke_snack", PokeSnackBlock(BlockBehaviour.Properties.of().forceSolidOn().strength(0.5F).sound(SoundType.WOOL).pushReaction(PushReaction.DESTROY).lightLevel { if (it.getValue(LIT)) 3 else 0 }, true))
val POKE_SNACK = this.create("poke_snack", PokeSnackBlock(BlockBehaviour.Properties.of().forceSolidOn().strength(0.5F).sound(SoundType.WOOL).pushReaction(PushReaction.DESTROY).lightLevel { if (it.getValue(BlockStateProperties.LIT)) 3 else 0 }, true))
@JvmField
val TUMBLESTONE_CLUSTER = tumblestoneBlock("tumblestone_cluster", GrowableStoneBlock.STAGE_3, 7, 3, null)
@@ -477,6 +478,99 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
@JvmField
val GIMMIGHOUL_CHEST = create("gimmighoul_chest", GildedChestBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.CHEST).noOcclusion().sound(CobblemonSounds.GILDED_CHEST_SOUNDS), GildedChestBlock.Type.FAKE))
@JvmField
val WHITE_PLAQUE = create("white_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val LIGHT_GRAY_PLAQUE = create("light_gray_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val GRAY_PLAQUE = create("gray_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val BLACK_PLAQUE = create("black_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val BROWN_PLAQUE = create("brown_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val RED_PLAQUE = create("red_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val ORANGE_PLAQUE = create("orange_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val YELLOW_PLAQUE = create("yellow_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val LIME_PLAQUE = create("lime_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val GREEN_PLAQUE = create("green_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val CYAN_PLAQUE = create("cyan_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val LIGHT_BLUE_PLAQUE = create("light_blue_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val BLUE_PLAQUE = create("blue_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val PURPLE_PLAQUE = create("purple_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val MAGENTA_PLAQUE = create("magenta_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val PINK_PLAQUE = create("pink_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val CLEANSE_TAG = create("cleanse_tag", WallAttachedStackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOD).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion().noCollission(), WallAttachedStackableItemBlock.WallStackableItemBlockType.TAG))
@JvmField
val SPELL_TAG = create("spell_tag", WallAttachedStackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOD).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion().noCollission(), WallAttachedStackableItemBlock.WallStackableItemBlockType.TAG))
@JvmField
val BLUNDER_POLICY = create("blunder_policy", WallAttachedDirectionalShapeBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion().noCollission(), 14, 12, 1))
@JvmField
val WEAKNESS_POLICY = create("weakness_policy", WallAttachedDirectionalShapeBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion().noCollission(), 14, 12, 1))
@JvmField
val FULL_HEAL = create("full_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
@JvmField
val ANTIDOTE = create("antidote", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
@JvmField
val AWAKENING = create("awakening", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
@JvmField
val BURN_HEAL = create("burn_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
@JvmField
val ICE_HEAL = create("ice_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
@JvmField
val PARALYZE_HEAL = create("paralyze_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.STATUS_RESTORE))
@JvmField
val ETHER = create("ether", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.ETHER))
@JvmField
val MAX_ETHER = create("max_ether", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.ETHER))
@JvmField
val ELIXIR = create("elixir", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.ETHER))
@JvmField
val MAX_ELIXIR = create("max_elixir", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.ETHER))
@JvmField
val POTION = create("potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.POTION))
@JvmField
val SUPER_POTION = create("super_potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.POTION))
@JvmField
val HYPER_POTION = create("hyper_potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.POTION))
@JvmField
val MAX_POTION = create("max_potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.MAX_POTION))
@JvmField
val FULL_RESTORE = create("full_restore", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.MAX_POTION))
@JvmField
val DIRE_HIT = create("dire_hit", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.BATTLE_ITEM))
@JvmField
val GUARD_SPEC = create("guard_spec", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.BATTLE_ITEM))
@JvmField
val X_ACCURACY = create("x_${Stats.ACCURACY.identifier.path}", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.BATTLE_ITEM))
@JvmField
val X_ATTACK = create("x_${Stats.ATTACK.identifier.path}", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.BATTLE_ITEM))
@JvmField
val X_DEFENSE = create("x_${Stats.DEFENCE.identifier.path}", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.BATTLE_ITEM))
@JvmField
val X_SP_ATK = create("x_${Stats.SPECIAL_ATTACK.identifier.path}", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.BATTLE_ITEM))
@JvmField
val X_SP_DEF = create("x_${Stats.SPECIAL_DEFENCE.identifier.path}", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.BATTLE_ITEM))
@JvmField
val X_SPEED = create("x_${Stats.SPEED.identifier.path}", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.CANDLE).mapColor(MapColor.NONE).noOcclusion(), StackableItemBlock.StackableItemBlockType.BATTLE_ITEM))
@JvmField
val MONITOR = create("monitor", MonitorBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().strength(5.0F, 6.0F).lightLevel { if (it.getValue(MonitorBlock.SCREEN) != MonitorBlock.MonitorScreen.OFF) 13 else 0 }))
@JvmField
@@ -507,6 +507,23 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField val SCROLL_OF_DARKNESS = noSettingsItem("scroll_of_darkness")
@JvmField val SCROLL_OF_WATERS = noSettingsItem("scroll_of_waters")
@JvmField val WHITE_PLAQUE = blockItem("white_plaque", CobblemonBlocks.WHITE_PLAQUE)
@JvmField val LIGHT_GRAY_PLAQUE = blockItem("light_gray_plaque", CobblemonBlocks.LIGHT_GRAY_PLAQUE)
@JvmField val GRAY_PLAQUE = blockItem("gray_plaque", CobblemonBlocks.GRAY_PLAQUE)
@JvmField val BLACK_PLAQUE = blockItem("black_plaque", CobblemonBlocks.BLACK_PLAQUE)
@JvmField val BROWN_PLAQUE = blockItem("brown_plaque", CobblemonBlocks.BROWN_PLAQUE)
@JvmField val RED_PLAQUE = blockItem("red_plaque", CobblemonBlocks.RED_PLAQUE)
@JvmField val ORANGE_PLAQUE = blockItem("orange_plaque", CobblemonBlocks.ORANGE_PLAQUE)
@JvmField val YELLOW_PLAQUE = blockItem("yellow_plaque", CobblemonBlocks.YELLOW_PLAQUE)
@JvmField val LIME_PLAQUE = blockItem("lime_plaque", CobblemonBlocks.LIME_PLAQUE)
@JvmField val GREEN_PLAQUE = blockItem("green_plaque", CobblemonBlocks.GREEN_PLAQUE)
@JvmField val CYAN_PLAQUE = blockItem("cyan_plaque", CobblemonBlocks.CYAN_PLAQUE)
@JvmField val LIGHT_BLUE_PLAQUE = blockItem("light_blue_plaque", CobblemonBlocks.LIGHT_BLUE_PLAQUE)
@JvmField val BLUE_PLAQUE = blockItem("blue_plaque", CobblemonBlocks.BLUE_PLAQUE)
@JvmField val PURPLE_PLAQUE = blockItem("purple_plaque", CobblemonBlocks.PURPLE_PLAQUE)
@JvmField val MAGENTA_PLAQUE = blockItem("magenta_plaque", CobblemonBlocks.MAGENTA_PLAQUE)
@JvmField val PINK_PLAQUE = blockItem("pink_plaque", CobblemonBlocks.PINK_PLAQUE)
private val berries = mutableMapOf<ResourceLocation, BerryItem>()
// Plants
@JvmField val CHERI_BERRY = berryItem("cheri", StatusCuringBerryItem(CobblemonBlocks.CHERI_BERRY, Statuses.PARALYSIS))
@@ -699,15 +716,15 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
val MOOMOO_MILK = create("moomoo_milk", MoomooMilk(Item.Properties().craftRemainder(Items.GLASS_BOTTLE).stacksTo((16))))
@JvmField
val POTION = create("potion", PotionItem(PotionType.POTION))
val POTION = create("potion", PotionItem(PotionType.POTION, CobblemonBlocks.POTION))
@JvmField
val SUPER_POTION = create("super_potion", PotionItem(PotionType.SUPER_POTION))
val SUPER_POTION = create("super_potion", PotionItem(PotionType.SUPER_POTION, CobblemonBlocks.SUPER_POTION))
@JvmField
val HYPER_POTION = create("hyper_potion", PotionItem(PotionType.HYPER_POTION))
val HYPER_POTION = create("hyper_potion", PotionItem(PotionType.HYPER_POTION, CobblemonBlocks.HYPER_POTION))
@JvmField
val MAX_POTION = create("max_potion", PotionItem(PotionType.MAX_POTION))
val MAX_POTION = create("max_potion", PotionItem(PotionType.MAX_POTION, CobblemonBlocks.MAX_POTION))
@JvmField
val FULL_RESTORE = create("full_restore", PotionItem(PotionType.FULL_RESTORE))
val FULL_RESTORE = create("full_restore", PotionItem(PotionType.FULL_RESTORE, CobblemonBlocks.FULL_RESTORE))
@JvmField
val HEAL_POWDER = create("heal_powder", HealPowderItem())
@@ -792,28 +809,27 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val SERIOUS_MINT = mintItem("serious_mint", MintItem(Natures.SERIOUS))
@JvmField val X_ACCURACY = create("x_${Stats.ACCURACY.identifier.path}", XStatItem(Stats.ACCURACY))
@JvmField val X_ATTACK = create("x_${Stats.ATTACK.identifier.path}", XStatItem(Stats.ATTACK))
@JvmField val X_DEFENSE = create("x_${Stats.DEFENCE.identifier.path}", XStatItem(Stats.DEFENCE))
@JvmField val X_SP_ATK = create("x_${Stats.SPECIAL_ATTACK.identifier.path}", XStatItem(Stats.SPECIAL_ATTACK))
@JvmField val X_SP_DEF = create("x_${Stats.SPECIAL_DEFENCE.identifier.path}", XStatItem(Stats.SPECIAL_DEFENCE))
@JvmField val X_SPEED = create("x_${Stats.SPEED.identifier.path}", XStatItem(Stats.SPEED))
@JvmField val X_ACCURACY = create("x_${Stats.ACCURACY.identifier.path}", XStatItem(Stats.ACCURACY, block = CobblemonBlocks.X_ACCURACY))
@JvmField val X_ATTACK = create("x_${Stats.ATTACK.identifier.path}", XStatItem(Stats.ATTACK, block = CobblemonBlocks.X_ATTACK))
@JvmField val X_DEFENSE = create("x_${Stats.DEFENCE.identifier.path}", XStatItem(Stats.DEFENCE, block = CobblemonBlocks.X_DEFENSE))
@JvmField val X_SP_ATK = create("x_${Stats.SPECIAL_ATTACK.identifier.path}", XStatItem(Stats.SPECIAL_ATTACK, block = CobblemonBlocks.X_SP_ATK))
@JvmField val X_SP_DEF = create("x_${Stats.SPECIAL_DEFENCE.identifier.path}", XStatItem(Stats.SPECIAL_DEFENCE, block = CobblemonBlocks.X_SP_DEF))
@JvmField val X_SPEED = create("x_${Stats.SPEED.identifier.path}", XStatItem(Stats.SPEED, block = CobblemonBlocks.X_SPEED))
@JvmField val DIRE_HIT = create("dire_hit", DireHitItem())
@JvmField val GUARD_SPEC = create("guard_spec", GuardSpecItem())
@JvmField val DIRE_HIT = create("dire_hit", DireHitItem(CobblemonBlocks.DIRE_HIT))
@JvmField val GUARD_SPEC = create("guard_spec", GuardSpecItem(CobblemonBlocks.GUARD_SPEC))
@JvmField val BURN_HEAL = create("burn_heal", StatusCureItem("item.cobblemon.burn_heal", Statuses.BURN))
@JvmField val PARALYZE_HEAL = create("paralyze_heal", StatusCureItem("item.cobblemon.paralyze_heal", Statuses.PARALYSIS))
@JvmField val ICE_HEAL = create("ice_heal", StatusCureItem("item.cobblemon.ice_heal", Statuses.FROZEN))
@JvmField val ANTIDOTE = create("antidote", StatusCureItem("item.cobblemon.antidote", Statuses.POISON, Statuses.POISON_BADLY))
@JvmField val AWAKENING = create("awakening", StatusCureItem("item.cobblemon.awakening", Statuses.SLEEP))
@JvmField val FULL_HEAL = create("full_heal", StatusCureItem("item.cobblemon.full_heal", block = CobblemonBlocks.FULL_HEAL))
@JvmField val ANTIDOTE = create("antidote", StatusCureItem("item.cobblemon.antidote", Statuses.POISON, Statuses.POISON_BADLY, block = CobblemonBlocks.ANTIDOTE))
@JvmField val AWAKENING = create("awakening", StatusCureItem("item.cobblemon.awakening", Statuses.SLEEP, block = CobblemonBlocks.AWAKENING))
@JvmField val BURN_HEAL = create("burn_heal", StatusCureItem("item.cobblemon.burn_heal", Statuses.BURN, block = CobblemonBlocks.BURN_HEAL))
@JvmField val ICE_HEAL = create("ice_heal", StatusCureItem("item.cobblemon.ice_heal", Statuses.FROZEN, block = CobblemonBlocks.ICE_HEAL))
@JvmField val PARALYZE_HEAL = create("paralyze_heal", StatusCureItem("item.cobblemon.paralyze_heal", Statuses.PARALYSIS, block = CobblemonBlocks.PARALYZE_HEAL))
@JvmField val FULL_HEAL = create("full_heal", StatusCureItem("item.cobblemon.full_heal"))
@JvmField val ETHER = create("ether", EtherItem(max = false))
@JvmField val MAX_ETHER = create("max_ether", EtherItem(max = true))
@JvmField val ELIXIR = create("elixir", ElixirItem(max = false))
@JvmField val MAX_ELIXIR = create("max_elixir", ElixirItem(max = true))
@JvmField val ETHER = create("ether", EtherItem(max = false, CobblemonBlocks.ETHER))
@JvmField val MAX_ETHER = create("max_ether", EtherItem(max = true, CobblemonBlocks.MAX_ETHER))
@JvmField val ELIXIR = create("elixir", ElixirItem(max = false, CobblemonBlocks.ELIXIR))
@JvmField val MAX_ELIXIR = create("max_elixir", ElixirItem(max = true, CobblemonBlocks.MAX_ELIXIR))
@JvmField
val ABILITY_CAPSULE = this.create("ability_capsule", AbilityChangeItem(AbilityChanger.COMMON_ABILITY))
@@ -922,7 +938,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val BLACK_SLUDGE = heldItem("black_sludge")
@JvmField
val BLUNDER_POLICY = heldItem("blunder_policy")
val BLUNDER_POLICY = itemNameBlockItem("blunder_policy", CobblemonBlocks.BLUNDER_POLICY)
@JvmField
val CELL_BATTERY = heldItem("cell_battery")
@JvmField
@@ -930,7 +946,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val CHOICE_SCARF = heldItem("choice_scarf")
@JvmField
val CLEANSE_TAG = heldItem("cleanse_tag")
val CLEANSE_TAG = itemNameBlockItem("cleanse_tag", CobblemonBlocks.CLEANSE_TAG)
@JvmField
val CLEAR_AMULET = heldItem("clear_amulet")
@JvmField
@@ -1038,7 +1054,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val SOFT_SAND = heldItem("soft_sand")
@JvmField
val SPELL_TAG = heldItem("spell_tag")
val SPELL_TAG = itemNameBlockItem("spell_tag", CobblemonBlocks.SPELL_TAG)
@JvmField
val SMOKE_BALL = heldItem("smoke_ball")
@JvmField
@@ -1056,7 +1072,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val UTILITY_UMBRELLA = heldItem("utility_umbrella")
@JvmField
val WEAKNESS_POLICY = heldItem("weakness_policy")
val WEAKNESS_POLICY = itemNameBlockItem("weakness_policy", CobblemonBlocks.WEAKNESS_POLICY)
@JvmField
val WIDE_LENS = heldItem("wide_lens")
@JvmField
@@ -1553,6 +1569,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
}
}
)
private fun heldItem(name: String, item: Item, remappedName: String? = null) = create(
name = name,
entry = item.also {
@@ -304,7 +304,8 @@ open class PokemonBattle(
.forEach{it.pokemon.heal()}
actors.forEach { actor ->
actor.pokemonList.forEach { battlePokemon ->
battlePokemon.entity?.let { entity -> battlePokemon.postBattleEntityOperation(entity) }
battlePokemon.postBattlePokemonOperations.forEach { it(battlePokemon) }
battlePokemon.entity?.let { entity -> battlePokemon.postBattleEntityOperations.forEach { it(entity) } }
if (battlePokemon.effectedPokemon.entity != null
&& battlePokemon.effectedPokemon.entity?.beamMode == 0
&& battlePokemon.effectedPokemon.entity?.platform != PlatformType.NONE) {
@@ -9,6 +9,7 @@
package com.cobblemon.mod.common.api.events.battles
import com.bedrockk.molang.runtime.value.MoValue
import com.bedrockk.molang.runtime.value.StringValue
import com.cobblemon.mod.common.api.battles.interpreter.BattleContext
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
import com.cobblemon.mod.common.api.battles.model.actor.ActorType
@@ -25,7 +26,8 @@ import com.cobblemon.mod.common.util.asArrayValue
data class BattleFaintedEvent(
override val battle: PokemonBattle,
val killed: BattlePokemon,
val context: BattleContext
val context: BattleContext,
val pnx: String
) : BattleEvent {
val structContext = mutableMapOf<String, MoValue>(
"battle" to battle.struct,
@@ -33,6 +35,7 @@ data class BattleFaintedEvent(
"npcs" to battle.actors.filter { it.type == ActorType.NPC }.asArrayValue { it.struct },
"wild_pokemon" to battle.actors.filter { it.type == ActorType.WILD }.asArrayValue { it.struct },
"pokemon" to killed.struct,
"context" to context.getStruct()
"context" to context.getStruct(),
"pnx" to StringValue(pnx)
)
}
}
@@ -25,7 +25,8 @@ import com.cobblemon.mod.common.util.asArrayValue
data class FormeChangeEvent(
override val battle: PokemonBattle,
val pokemon: BattlePokemon,
val formeName: String
val formeName: String,
val pnx: String
) : BattleEvent {
val context = mutableMapOf(
"battle" to battle.struct,
@@ -33,6 +34,7 @@ data class FormeChangeEvent(
"npcs" to battle.actors.filter { it.type == ActorType.NPC }.asArrayValue { it.struct },
"wild_pokemon" to battle.actors.filter { it.type == ActorType.WILD }.asArrayValue { it.struct },
"pokemon" to pokemon.struct,
"forme" to StringValue(formeName)
"forme" to StringValue(formeName),
"pnx" to StringValue(pnx)
)
}
}
@@ -9,6 +9,7 @@
package com.cobblemon.mod.common.api.interaction
import com.cobblemon.mod.common.Cobblemon
import com.cobblemon.mod.common.api.conditional.RegistryLikeCondition
import com.cobblemon.mod.common.api.data.JsonDataRegistry
import com.cobblemon.mod.common.api.molang.ExpressionLike
import com.cobblemon.mod.common.api.pokemon.PokemonProperties
@@ -29,6 +30,11 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.packs.PackType
import net.minecraft.util.LowerCaseEnumTypeAdapterFactory
import net.minecraft.world.item.Item
import net.minecraft.world.level.biome.Biome
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.levelgen.structure.Structure
import net.minecraft.world.level.material.Fluid
object PokemonInteractions : JsonDataRegistry<PokemonInteractionSet> {
override val id = cobblemonResource("pokemon_interactions")
@@ -43,6 +49,11 @@ object PokemonInteractions : JsonDataRegistry<PokemonInteractionSet> {
.registerTypeAdapter(Requirement::class.java, CobblemonRequirementAdapter)
.registerTypeAdapter(InteractionEffect::class.java, InteractionEffectAdapter)
.registerTypeAdapter(ExpressionLike::class.java, ExpressionLikeAdapter)
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Biome::class.java).type, BiomeLikeConditionAdapter)
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Block::class.java).type, BlockLikeConditionAdapter)
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Item::class.java).type, ItemLikeConditionAdapter)
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Structure::class.java).type, StructureLikeConditionAdapter)
.registerTypeAdapter(TypeToken.getParameterized(RegistryLikeCondition::class.java, Fluid::class.java).type, FluidLikeConditionAdapter)
.registerTypeAdapter(IntRange::class.java, IntRangeAdapter)
.registerTypeAdapterFactory(LowerCaseEnumTypeAdapterFactory())
.setPrettyPrinting()
@@ -17,6 +17,7 @@ import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.net.messages.client.sound.UnvalidatedPlaySoundS2CPacket
import com.cobblemon.mod.common.pokemon.adapters.CobblemonRequirementAdapter
import com.cobblemon.mod.common.util.*
import com.google.gson.annotations.SerializedName
import net.minecraft.core.registries.Registries
import net.minecraft.network.FriendlyByteBuf
import net.minecraft.resources.ResourceLocation
@@ -143,11 +144,12 @@ class GiveItemEffect(val item: ResourceLocation, val amount: IntRange?) : Intera
class PlaySoundEffect(
val sound: ResourceLocation,
val soundSource: SoundSource?,
val playAround: Boolean = true,
val distance: Double = 64.0,
val volume: Float = 1.0F,
val pitch: Float = 1.0F
@SerializedName("playAround") private val _playAround: Boolean?,
@SerializedName("distance") private val _distance: Double?,
@SerializedName("volume") private val _volume: Float?,
@SerializedName("pitch") private val _pitch: Float?,
) : InteractionEffect {
override fun applyEffect(
pokemon: PokemonEntity,
player: ServerPlayer
@@ -161,6 +163,7 @@ class PlaySoundEffect(
volume,
pitch
)
if (playAround) {
packet.sendToPlayersAround(pokemon.x, pokemon.y, pokemon.z, distance, pokemon.level().dimension())
} else {
@@ -168,6 +171,18 @@ class PlaySoundEffect(
}
}
val playAround: Boolean
get() = _playAround != false
val distance: Double
get() = _distance ?: 64.0
val volume: Float
get() = _volume ?: 1.0F
val pitch: Float
get() = _pitch ?: 1.0F
companion object {
val ID = "play_sound"
}
@@ -324,13 +324,24 @@ object MoLangFunctions {
runtime.environment.context = params.environment.context
val expression = params.getString(0).asExpressionLike()
val delayInSeconds = params.getDoubleOrNull(1)?.toFloat() ?: 0.0f
fun evaluate(): MoValue {
return try {
runtime.resolve(expression)
} catch (ex: Exception) {
Cobblemon.LOGGER.warn("Failed to evaluate MoLang expression${if (delayInSeconds > 0.0f) " (delayed)" else ""}: $expression", ex)
DoubleValue.ZERO
}
}
if (delayInSeconds > 0.0f) {
val tracker = if (Cobblemon.implementation.environment() == Environment.SERVER) ServerTaskTracker else ClientTaskTracker
tracker.after(delayInSeconds) {
runtime.resolve(expression)
evaluate()
}
DoubleValue.ONE
} else {
runtime.resolve(expression)
evaluate()
}
},
"system_time_millis" to java.util.function.Function { _ ->
@@ -340,19 +351,19 @@ object MoLangFunctions {
"date_local_time" to java.util.function.Function { _ ->
val time = System.currentTimeMillis()
val date = java.util.Date(time)
val formatted = java.text.SimpleDateFormat("DD/MM/YYYY").format(date)
val formatted = java.text.SimpleDateFormat("dd/MM/yyyy").format(date)
StringValue(formatted)
},
"date_of" to java.util.function.Function { params ->
val time = params.getDouble(0).toLong()
val date = java.util.Date(time)
val formatted = java.text.SimpleDateFormat("DD/MM/YYYY").format(date)
val formatted = java.text.SimpleDateFormat("dd/MM/yyyy").format(date)
StringValue(formatted)
},
"date_is_after" to java.util.function.Function { params ->
val dateA = params.getString(0)
val dateB = params.getString(1)
val format = java.text.SimpleDateFormat("DD/MM/YYYY")
val format = java.text.SimpleDateFormat("dd/MM/yyyy")
val a = format.parse(dateA)
val b = format.parse(dateB)
DoubleValue(a.after(b))
@@ -102,6 +102,12 @@ object SpeciesFeatures : JsonDataRegistry<SpeciesFeatureProvider<*>> {
@JvmStatic
fun register(name: String, provider: SpeciesFeatureProvider<*>) = register(name, provider, isCoded = true)
@JvmStatic
fun registerType(key: String, clazz: Class<out SpeciesFeatureProvider<*>>) {
types[key] = clazz
}
private fun registerFromAssets(identifier: ResourceLocation, provider: SpeciesFeatureProvider<*>) = register(identifier.path, provider, isCoded = false)
@JvmStatic
@@ -11,6 +11,7 @@ package com.cobblemon.mod.common.api.reactive
import com.cobblemon.mod.common.api.events.Cancelable
open class EventObservable<T> : SimpleObservable<T>() {
@JvmOverloads
inline fun post(vararg events: T, then: (T) -> Unit = {}) {
// Issuing generic-typed pass-throughs to varargs doesn't work
// properly unless the source is a vararg as well, complicated story.
@@ -258,17 +258,22 @@ open class PartyStore(override val uuid: UUID) : PokemonStore<PartyPosition>() {
@JvmOverloads
fun toBattleTeam(clone: Boolean = false, healPokemon: Boolean = false, leadingPokemon: UUID? = null) : List<BattlePokemon> {
var leadingPokemonId = leadingPokemon
val result = this.mapNotNull {
return@mapNotNull if (clone) {
BattlePokemon.safeCopyOf(it)
BattlePokemon.safeCopyOf(it).also { copy ->
if (leadingPokemon != null && it.uuid == leadingPokemonId) {
leadingPokemonId = copy.uuid
}
}
} else {
BattlePokemon.playerOwned(it)
}.also { if (healPokemon) it.effectedPokemon.heal() }
}.toMutableList()
// reposition lead to front of the party
if (leadingPokemon != null && result.first().uuid != leadingPokemon) {
result.find { it.uuid == leadingPokemon }?.let { lead ->
if (leadingPokemonId != null && result.first().uuid != leadingPokemonId) {
result.find { it.uuid == leadingPokemonId }?.let { lead ->
result.remove(lead)
result.add(0, lead)
}
@@ -154,12 +154,12 @@ open class PlayerPartyStore(
// Metabolism for Fullness
if (pokemon.currentFullness > 0) {
pokemon.tickMetabolism()
pokemon.tickMetabolism(20)
}
// Interaction Cooldown
if (pokemon.interactionCooldowns.any()) {
pokemon.tickInteractionCooldown()
pokemon.tickInteractionCooldown(20)
}
pokemon.features.filterIsInstance<TickingSpeciesFeature>().forEach { it.onSecondPassed(player.serverLevel(), pokemon, null) }
@@ -42,6 +42,7 @@ object CobblemonItemTags {
@JvmField val DAWN_STONE_ORES = create("dawn_stone_ores")
@JvmField val POTTERY_SHERDS = create("decorated_pot_sherds")
@JvmField val DEEP_SEAS = create("deep_seas")
@JvmField val DISPLAY_CASE_ITEMS = create("display_case_items")
@JvmField val DUSK_STONE_ORES = create("dusk_stone_ores")
@JvmField val ETHERS = create("ethers")
@JvmField val EVOLUTION_ITEMS = create("evolution_items")
@@ -57,6 +58,7 @@ object CobblemonItemTags {
@JvmField val HANGING_SIGNS = create("hanging_signs")
@JvmField val HERBS = create("herbs")
@JvmField val ICE_STONE_ORES = create("ice_stone_ores")
@JvmField val ITEM_BLOCKS = create("item_blocks")
@JvmField val LEAF_STONE_ORES = create("leaf_stone_ores")
@JvmField val MACHINES = create("machines")
@JvmField val MINT_LEAF = create("mint_leaf")
@@ -65,6 +67,7 @@ object CobblemonItemTags {
@JvmField val MOCHIS = create("mochis")
@JvmField val MOON_STONE_ORES = create("moon_stone_ores")
@JvmField val MUTATED_BERRIES = create("mutated_berries")
@JvmField val PLAQUES = create("plaques")
@JvmField val PLANTS = create("plants")
@JvmField val POKE_BALLS = create("poke_balls")
@JvmField val POKE_RODS = create("poke_rods")
@@ -63,8 +63,8 @@ object BattleBuilder {
): BattleStartResult {
val adjustLevel = battleFormat.adjustLevel
val team1 = partyAccessor(player1).toBattleTeam(clone = cloneParties || adjustLevel > 0, healPokemon = healFirst, leadingPokemonPlayer1).sortedBy { it.health <= 0 }
val team2 = partyAccessor(player2).toBattleTeam(clone = cloneParties || adjustLevel > 0, healPokemon = healFirst, leadingPokemonPlayer2).sortedBy { it.health <= 0 }
val team1 = partyAccessor(player1).toBattleTeam(clone = cloneParties || adjustLevel > 0, healPokemon = healFirst, leadingPokemonPlayer1)
val team2 = partyAccessor(player2).toBattleTeam(clone = cloneParties || adjustLevel > 0, healPokemon = healFirst, leadingPokemonPlayer2)
val battlePartyStores = mutableListOf<PlayerPartyStore>()
@@ -105,12 +105,18 @@ data class BattleFormat(
}
fun toFormatJSON(): String {
/*
Bag clause does not exist in showdown as a rule because showdown simply has no concept of a 'bag'.
If we try sending it, the battle will error. So this simply omits that from ever getting sent.
If we ever find a case where we are doing this for more than just bag clause, we should make a proper abstraction.
*/
val rulesToSendToShowdown = ruleSet.filter { it != BattleRules.BAG_CLAUSE }
return """
{
"mod": "$mod",
"gameType": "${battleType.name}",
"gen": $gen,
"ruleset": [${ruleSet.joinToString { "\"$it\"" }}],
"ruleset": [${rulesToSendToShowdown.joinToString { "\"$it\"" }}],
"effectType": "Format"
}
""".trimIndent().replace("\n", "")
@@ -12,6 +12,7 @@ object BattleRules {
const val OBTAINABLE = "Obtainable"
const val PAST = "+Past"
const val UNOBTAINABLE = "+Unobtainable"
const val BAG_CLAUSE = "Bag Clause"
const val TEAM_PREVIEW = "Team Preview"
const val ENDLESS_BATTLE_CLAUSE = "Endless Battle Clause"
const val CANCEL_MOD = "Cancel Mod"
@@ -289,6 +289,8 @@ class ShowdownMoveset {
var canDynamax = false
var maxMoves: List<InBattleGimmickMove?>? = null
var canTerastallize: String? = null
/** This stores a list of gimmicks that have already been used this turn by a previous Pokemon, but the full turn has not been processed (ie. double battles). */
val pendingGimmickUsedThisTurn = mutableListOf<Gimmick>()
fun saveToBuffer(buffer: RegistryFriendlyByteBuf) {
buffer.writeSizedInt(IntSize.U_BYTE, moves.size)
@@ -300,4 +300,35 @@ object ShowdownInterpreter {
} ?:
MissingContext()
}
}
/**
* Registers a new update instruction parser.
* @param id The ID of the instruction to register.
* @param callback The callback function to create the instruction.
*/
@JvmStatic
fun registerUpdateInstructionParser(id: String, callback: (PokemonBattle, InstructionSet, BattleMessage, Iterator<BattleMessage>) -> InterpreterInstruction) {
updateInstructionParser[id] = callback
}
/**
* Registers a new split instruction parser.
* @param id The ID of the instruction to register.
* @param callback The callback function to create the instruction.
*/
@JvmStatic
fun registerSplitInstructionParser(id: String, callback: (PokemonBattle, BattleActor, InstructionSet, BattleMessage, BattleMessage, Iterator<BattleMessage>) -> InterpreterInstruction) {
splitInstructionParser[id] = callback
}
/**
* Registers a new side instruction parser.
* @param id The ID of the instruction to register.
* @param callback The callback function to create the instruction.
*/
@JvmStatic
fun registerSideInstructionParser(id: String, callback: (PokemonBattle, BattleActor, InstructionSet, BattleMessage) -> InterpreterInstruction) {
sideInstructionParser[id] = callback
}
}
@@ -1,671 +0,0 @@
package com.cobblemon.mod.common.battles.ai
import com.cobblemon.mod.common.api.battles.interpreter.BattleContext
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
import com.cobblemon.mod.common.api.battles.model.ai.BattleAI
import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.api.moves.Moves
import com.cobblemon.mod.common.Cobblemon
import com.cobblemon.mod.common.battles.*
import com.cobblemon.mod.common.battles.ai.competitive.*
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.net.messages.client.battle.BattleHealthChangePacket
import kotlin.random.Random
class CompetitiveBattleAI(private val skill: Int) : BattleAI {
companion object {
private const val DEBUG_TOP_MOVES = 4
}
private val skillLevel = skill.coerceIn(0, 5)
private val aiDebugEnabled = isAiDebugEnabled()
private val battleTracker = EnhancedActiveTracker()
private val opponentPredictor = OpponentPredictor()
private val strategyAnalyzer = StrategyAnalyzer()
private lateinit var damageCalculator: DamageCalculator
private lateinit var moveEvaluator: MoveEvaluator
private lateinit var switchDecisionMaker: SwitchDecisionMaker
private lateinit var doublesDecisionMaker: DoublesDecisionMaker
private var currentBattle: PokemonBattle? = null
private var currentGamePlan: GamePlan? = null
private var battleState: BattleState? = null
private var lastMoveEvaluation: MoveEvaluator.MoveEvaluation? = null
private var isDoublesMode: Boolean = false
private var currentSlot: Int = 0
private var currentTurn: Int = -1
private val turnDecisions: MutableMap<Int, DoublesDecisionMaker.MoveTargetPair> = mutableMapOf()
private var firstSlotDecided: Boolean = false
override fun choose(
activeBattlePokemon: ActiveBattlePokemon,
battle: PokemonBattle,
aiSide: BattleSide,
moveset: ShowdownMoveset?,
forceSwitch: Boolean
): ShowdownActionResponse {
try {
initializeComponents(battle)
updateBattleState(activeBattlePokemon, battle)
if (currentGamePlan == null) {
val npcTeam = battle.side2.actors.first().pokemonList.map { it.effectedPokemon }
currentGamePlan = strategyAnalyzer.analyzeTeamComposition(npcTeam)
}
if (battle.turn != currentTurn) {
currentTurn = battle.turn
turnDecisions.clear()
firstSlotDecided = false
}
if (forceSwitch || activeBattlePokemon.isGone()) {
return handleForcedSwitch(activeBattlePokemon, battle)
}
if (!passesSkillCheck()) {
debugLog("Skill check failed; selecting random move.")
return makeRandomMove(moveset, activeBattlePokemon)
}
updateOpponentModel(battle)
if (isDoublesMode) {
return chooseForDoubles(activeBattlePokemon, battle, moveset)
}
if (shouldAttemptSwitch() && shouldSwitch(activeBattlePokemon, battle)) {
val switchTarget = findBestSwitch(activeBattlePokemon, battle)
if (switchTarget != null) {
switchTarget.willBeSwitchedIn = true
logSwitchDecision("voluntary_switch", battle, listOf(switchTarget), switchTarget)
return SwitchActionResponse(switchTarget.uuid)
}
}
val bestMove = chooseBestMove(moveset, activeBattlePokemon, battle)
logMoveDecision("move_select", bestMove, activeBattlePokemon)
return executeMove(bestMove, activeBattlePokemon)
} catch (e: Exception) {
e.printStackTrace()
return PassActionResponse
}
}
private fun chooseForDoubles(
activeBattlePokemon: ActiveBattlePokemon,
battle: PokemonBattle,
moveset: ShowdownMoveset?
): ShowdownActionResponse {
val state = battleState ?: return PassActionResponse
val plan = currentGamePlan ?: return PassActionResponse
val myPokemon = battleTracker.p2Active.getActiveAt(currentSlot) ?: return PassActionResponse
val partnerSlot = 1 - currentSlot
val partner = battleTracker.p2Active.getActiveAt(partnerSlot)
val opponents = battleTracker.p1Active.getAllActive()
val decision = doublesDecisionMaker.findBestMoveAndTarget(
moveset,
activeBattlePokemon,
myPokemon,
opponents,
partner,
state,
plan
)
if (decision == null) {
debugLog("Doubles: no evaluated option; selecting random move.")
return makeRandomMove(moveset, activeBattlePokemon)
}
turnDecisions[currentSlot] = decision
firstSlotDecided = true
debugLog(
"Doubles: chose move=${decision.move.id} target=${decision.targetPNX ?: "auto"} " +
"score=${"%.2f".format(decision.evaluation.totalScore)} " +
"expectedDamage=${"%.1f".format(decision.evaluation.expectedDamage)} " +
"strategic=${"%.1f".format(decision.evaluation.strategicValue)} " +
"risk=${"%.2f".format(decision.evaluation.riskFactor)}"
)
return executeDoublesMove(decision, activeBattlePokemon)
}
private fun executeDoublesMove(
decision: DoublesDecisionMaker.MoveTargetPair,
activeBattlePokemon: ActiveBattlePokemon
): ShowdownActionResponse {
return if (decision.targetPNX != null) {
MoveActionResponse(decision.move.id, decision.targetPNX)
} else {
MoveActionResponse(decision.move.id)
}
}
private fun initializeComponents(battle: PokemonBattle) {
if (currentBattle != battle) {
currentBattle = battle
isDoublesMode = battle.format.battleType.pokemonPerSide > 1
damageCalculator = DamageCalculator(battle)
moveEvaluator = MoveEvaluator(damageCalculator, opponentPredictor, isDoublesMode)
switchDecisionMaker = SwitchDecisionMaker(damageCalculator, opponentPredictor, strategyAnalyzer)
doublesDecisionMaker = DoublesDecisionMaker(moveEvaluator, damageCalculator)
}
}
private fun updateBattleState(activeBattlePokemon: ActiveBattlePokemon, battle: PokemonBattle) {
val request = activeBattlePokemon.actor.request ?: return
// Determine current slot from PNX (e.g., "p2a" = slot 0, "p2b" = slot 1)
val pnx = activeBattlePokemon.getPNX()
currentSlot = if (pnx.length >= 3) pnx[2] - 'a' else 0
if (isDoublesMode) {
battle.side1.activePokemon.forEachIndexed { index, active ->
active.battlePokemon?.let { pokemon ->
battleTracker.updatePokemonSlot(battleTracker.p1Active, index, pokemon)
}
}
battle.side2.activePokemon.forEachIndexed { index, active ->
active.battlePokemon?.let { pokemon ->
battleTracker.updatePokemonSlot(battleTracker.p2Active, index, pokemon)
}
}
battleTracker.p1Active.activePokemon =
battleTracker.p1Active.getActiveAt(currentSlot) ?: battleTracker.p1Active.activePokemon
battleTracker.p2Active.activePokemon =
battleTracker.p2Active.getActiveAt(currentSlot) ?: battleTracker.p2Active.activePokemon
} else {
battle.side1.activePokemon.firstOrNull()?.battlePokemon?.let { playerPokemon ->
battleTracker.updatePokemon(battleTracker.p1Active.activePokemon, playerPokemon)
battleTracker.updateParty(battleTracker.p1Active, battleTracker.p1Active.activePokemon)
}
activeBattlePokemon.battlePokemon?.let { aiPokemon ->
battleTracker.updatePokemon(battleTracker.p2Active.activePokemon, aiPokemon)
battleTracker.updateParty(battleTracker.p2Active, battleTracker.p2Active.activePokemon)
}
}
updateRevealedMoves(battle)
battleState = createBattleState(battle, activeBattlePokemon)
}
private fun createBattleState(battle: PokemonBattle, activeBattlePokemon: ActiveBattlePokemon): BattleState? {
val p1Actor = battle.side1.actors.firstOrNull() ?: return null
val p2Actor = battle.side2.actors.firstOrNull() ?: return null
val playerActiveTracker = if (isDoublesMode) {
battleTracker.p1Active.getActiveAt(currentSlot) ?: battleTracker.p1Active.activePokemon
} else {
battleTracker.p1Active.activePokemon
}
val npcActiveTracker = if (isDoublesMode) {
battleTracker.p2Active.getActiveAt(currentSlot) ?: battleTracker.p2Active.activePokemon
} else {
battleTracker.p2Active.activePokemon
}
val playerActive = playerActiveTracker.pokemon ?: return null
val npcActive = npcActiveTracker.pokemon ?: return null
val playerActiveSlots = battleTracker.p1Active.getAllActive()
.mapNotNull { it.pokemon }
.ifEmpty { listOf(playerActive) }
val npcActiveSlots = battleTracker.p2Active.getAllActive()
.mapNotNull { it.pokemon }
.ifEmpty { listOf(npcActive) }
val partnerSlot = if (isDoublesMode) {
val mySlot = currentSlot
1 - mySlot
} else {
null
}
return BattleState(
turn = battle.turn,
playerTeam = p1Actor.pokemonList.map { it.effectedPokemon },
npcTeam = p2Actor.pokemonList.map { it.effectedPokemon },
playerActive = playerActive,
npcActive = npcActive,
weather = getWeather(battle),
terrain = getTerrain(battle),
playerHazards = getHazards(battle.side1),
npcHazards = getHazards(battle.side2),
playerBoosts = battleTracker.p1Active.activePokemon.boosts,
npcBoosts = battleTracker.p2Active.activePokemon.boosts,
battleContext = battle.contextManager,
isDoubles = isDoublesMode,
playerActiveSlots = playerActiveSlots,
npcActiveSlots = npcActiveSlots,
mySlotIndex = currentSlot,
partnerSlotIndex = partnerSlot
)
}
private fun handleForcedSwitch(activeBattlePokemon: ActiveBattlePokemon, battle: PokemonBattle): ShowdownActionResponse {
val availableSwitches = getAvailableSwitches(activeBattlePokemon)
if (availableSwitches.isEmpty()) {
return ForfeitActionResponse()
}
val state = battleState
val plan = currentGamePlan
val bestSwitch = if (state != null && plan != null) {
switchDecisionMaker.findBestSwitch(
availableSwitches,
battleTracker.p1Active.activePokemon,
state,
plan
)
} else {
null
}
val switchTarget = bestSwitch ?: availableSwitches.first()
switchTarget.willBeSwitchedIn = true
logSwitchDecision("forced_switch", battle, availableSwitches, switchTarget)
return SwitchActionResponse(switchTarget.uuid)
}
private fun shouldSwitch(activeBattlePokemon: ActiveBattlePokemon, battle: PokemonBattle): Boolean {
val availableSwitches = getAvailableSwitches(activeBattlePokemon)
if (availableSwitches.isEmpty()) return false
val state = battleState ?: return false
val plan = currentGamePlan ?: return false
return switchDecisionMaker.shouldVoluntarilySwitch(
battleTracker.p2Active.activePokemon,
battleTracker.p1Active.activePokemon,
state,
plan,
availableSwitches
)
}
private fun findBestSwitch(activeBattlePokemon: ActiveBattlePokemon, battle: PokemonBattle): BattlePokemon? {
val availableSwitches = getAvailableSwitches(activeBattlePokemon)
val state = battleState ?: return null
val plan = currentGamePlan ?: return null
return switchDecisionMaker.findBestSwitch(
availableSwitches,
battleTracker.p1Active.activePokemon,
state,
plan
)
}
private fun chooseBestMove(
moveset: ShowdownMoveset?,
activeBattlePokemon: ActiveBattlePokemon,
battle: PokemonBattle
): InBattleMove? {
if (moveset == null) return null
val usableMoves = moveset.moves.filter { it.canBeUsed() }
if (usableMoves.isEmpty()) return null
val state = battleState ?: return null
val plan = currentGamePlan ?: return null
val evaluations = usableMoves.map { move ->
moveEvaluator.evaluateMove(
move,
battleTracker.p2Active.activePokemon,
battleTracker.p1Active.activePokemon,
state,
plan
)
}
val bestEvaluation = evaluations.maxByOrNull { it.totalScore }
logMoveRanking(evaluations)
lastMoveEvaluation = bestEvaluation
return bestEvaluation?.move
}
private fun executeMove(move: InBattleMove?, activeBattlePokemon: ActiveBattlePokemon): ShowdownActionResponse {
if (move == null) {
return makeRandomMove(null, activeBattlePokemon)
}
val target = if (move.mustBeUsed()) {
null
} else {
move.target.targetList(activeBattlePokemon)
}
return if (target == null) {
MoveActionResponse(move.id)
} else {
val chosenTarget = target.filter { !it.isAllied(activeBattlePokemon) }.randomOrNull()
?: target.random()
MoveActionResponse(move.id, (chosenTarget as ActiveBattlePokemon).getPNX())
}
}
private fun makeRandomMove(moveset: ShowdownMoveset?, activeBattlePokemon: ActiveBattlePokemon): ShowdownActionResponse {
if (moveset == null) return PassActionResponse
val usableMoves = moveset.moves.filter { it.canBeUsed() }
val move = usableMoves.randomOrNull() ?: return PassActionResponse
val target = if (move.mustBeUsed()) null else move.target.targetList(activeBattlePokemon)
return if (target == null) {
MoveActionResponse(move.id)
} else {
val chosenTarget = target.filter { !it.isAllied(activeBattlePokemon) }.randomOrNull()
?: target.random()
MoveActionResponse(move.id, (chosenTarget as ActiveBattlePokemon).getPNX())
}
}
private fun updateOpponentModel(battle: PokemonBattle) {
val situation = categorizeSituation(battleState ?: return)
val opponentActives = if (isDoublesMode) {
battleTracker.p1Active.getAllActive()
} else {
listOf(battleTracker.p1Active.activePokemon)
}
for (opponentActive in opponentActives) {
for (move in opponentActive.revealedMoves) {
opponentPredictor.updateMoveHistory(
opponentActive.species ?: "unknown",
move,
situation.name.lowercase()
)
}
}
}
override fun onHealthChange(packet: BattleHealthChangePacket) {
try {
val battle = currentBattle ?: return
val pnx = packet.pnx
val activePokemon = battle.activePokemon.find { it.getPNX() == pnx } ?: return
val newHealth = packet.newHealth.toInt()
val isPlayerPokemon = activePokemon.actor == battle.side1.actors.firstOrNull()
val teamTracker = if (isPlayerPokemon) {
battleTracker.p1Active
} else {
battleTracker.p2Active
}
val tracker = battleTracker.getTrackedPokemonByPNX(pnx, teamTracker) ?: teamTracker.activePokemon
val oldHealth = tracker.currentHp
val hpChange = newHealth - oldHealth
tracker.previousHp = oldHealth
tracker.currentHp = newHealth
tracker.lastHpChange = hpChange
tracker.currentHpPercent = if (tracker.maxHp > 0) newHealth.toDouble() / tracker.maxHp else 0.0
updateMomentum(hpChange, isPlayerPokemon)
detectCriticalThresholds(tracker, oldHealth, newHealth, isPlayerPokemon)
} catch (e: Exception) {
}
}
private fun updateMomentum(hpChange: Int, isPlayerPokemon: Boolean) {
val momentumChange = when {
hpChange > 0 -> -5.0 // Opponent healing shifts momentum toward them
hpChange < 0 -> kotlin.math.abs(hpChange) / 10.0 // Damage shifts momentum
else -> 0.0
}
if (isPlayerPokemon) {
// Player took damage = AI momentum increases
battleTracker.p2Active.momentum += momentumChange
battleTracker.p1Active.momentum -= momentumChange
} else {
// AI took damage = Player momentum increases
battleTracker.p2Active.momentum -= momentumChange
battleTracker.p1Active.momentum += momentumChange
}
// Clamp momentum to -100 to 100
battleTracker.p1Active.momentum = battleTracker.p1Active.momentum.coerceIn(-100.0, 100.0)
battleTracker.p2Active.momentum = battleTracker.p2Active.momentum.coerceIn(-100.0, 100.0)
}
private fun detectCriticalThresholds(
tracker: TrackedPokemon,
oldHealth: Int,
newHealth: Int,
isPlayerPokemon: Boolean
) {
if (newHealth <= 0 && oldHealth > 0) {
if (isPlayerPokemon) {
battleTracker.p2Active.momentum += 20.0
} else {
battleTracker.p1Active.momentum += 20.0
}
}
}
private fun categorizeSituation(battleState: BattleState): BattleSituation {
val myHP = battleState.npcActive.currentHealth.toDouble() / battleState.npcActive.maxHealth
val oppHP = battleState.playerActive.currentHealth.toDouble() / battleState.playerActive.maxHealth
return when {
myHP < 0.25 -> BattleSituation.DESPERATE
oppHP < 0.25 -> BattleSituation.WINNING
myHP > 0.8 && oppHP > 0.8 -> BattleSituation.EARLY_GAME
battleState.npcTeam.count { it.currentHealth > 0 } <= 2 -> BattleSituation.ENDGAME
battleState.playerBoosts.values.any { it >= 2 } -> BattleSituation.OPPONENT_SETUP
battleState.npcBoosts.values.any { it >= 2 } -> BattleSituation.MY_SETUP
battleState.weather != null -> BattleSituation.WEATHER_CONTROL
else -> BattleSituation.NEUTRAL
}
}
private fun getAvailableSwitches(activeBattlePokemon: ActiveBattlePokemon): List<BattlePokemon> {
val currentUuid = activeBattlePokemon.battlePokemon?.uuid
return activeBattlePokemon.actor.pokemonList.filter {
it.health > 0 &&
it.uuid != currentUuid &&
try { it.canBeSentOut() } catch (e: Exception) { true }
}
}
private fun passesSkillCheck(): Boolean {
if (skillLevel == 5) return true
if (skillLevel == 0) return false
val baseChance = skillLevel * 20
val turnBonus = if ((battleState?.turn ?: 0) > 10) 10 else 0
return Random.nextInt(100) < (baseChance + turnBonus)
}
private fun shouldAttemptSwitch(): Boolean {
return when (skillLevel) {
in 0..2 -> false
3 -> Random.nextDouble() < 0.25
4 -> Random.nextDouble() < 0.70
5 -> true
else -> false
}
}
private fun getWeather(battle: PokemonBattle): String? {
return try {
battle.contextManager.get(BattleContext.Type.WEATHER)
?.firstOrNull()?.id
} catch (e: Exception) {
null
}
}
private fun getTerrain(battle: PokemonBattle): String? {
return try {
battle.contextManager.get(BattleContext.Type.TERRAIN)
?.firstOrNull()?.id
} catch (e: Exception) {
null
}
}
private fun getHazards(side: BattleSide): List<String> {
return try {
side.contextManager.get(BattleContext.Type.HAZARD)
?.map { it.id } ?: emptyList()
} catch (e: Exception) {
emptyList()
}
}
private fun updateRevealedMoves(battle: PokemonBattle) {
updateTeamRevealedMoves(battle, battleTracker.p1Active)
updateTeamRevealedMoves(battle, battleTracker.p2Active)
}
private fun updateTeamRevealedMoves(battle: PokemonBattle, team: TeamTracker) {
val active = team.getAllActive().ifEmpty { listOf(team.activePokemon) }
for (tracked in active) {
val pokemon = tracked.pokemon ?: continue
val majorMessage = battle.majorBattleActions[pokemon.uuid]
val minorMessage = battle.minorBattleActions[pokemon.uuid]
val candidates = listOfNotNull(majorMessage, minorMessage)
for (message in candidates) {
val id = message.id.lowercase()
if (id != "move" && id != "-singlemove" && id != "singlemove") continue
val moveId = message.effectAt(1)?.id?.lowercase() ?: continue
tracked.revealedMoves.add(moveId)
}
}
}
private fun logMoveDecision(
reason: String,
move: InBattleMove?,
activeBattlePokemon: ActiveBattlePokemon
) {
if (!aiDebugEnabled || move == null) return
val eval = lastMoveEvaluation
val self = activeBattlePokemon.battlePokemon?.effectedPokemon?.species?.name ?: "unknown"
val opp = battleTracker.p1Active.activePokemon.species ?: "unknown"
val plan = currentGamePlan?.winCondition?.name ?: "unknown"
if (eval == null) {
debugLog("Decision=$reason self=$self opp=$opp move=${move.id} plan=$plan")
return
}
debugLog(
"Decision=$reason self=$self opp=$opp move=${move.id} plan=$plan " +
"score=${"%.2f".format(eval.totalScore)} " +
"expectedDamage=${"%.1f".format(eval.expectedDamage)} " +
"strategic=${"%.1f".format(eval.strategicValue)} " +
"risk=${"%.2f".format(eval.riskFactor)}"
)
}
private fun logMoveRanking(evaluations: List<MoveEvaluator.MoveEvaluation>) {
if (!aiDebugEnabled || evaluations.isEmpty()) return
val plan = currentGamePlan?.winCondition?.name ?: "unknown"
val situation = battleState?.let { categorizeSituation(it).name } ?: "unknown"
val top = evaluations.sortedByDescending { it.totalScore }.take(DEBUG_TOP_MOVES)
val state = battleState
val planData = currentGamePlan
val attacker = battleTracker.p2Active.activePokemon
val defender = battleTracker.p1Active.activePokemon
val details = top.joinToString(", ") { eval ->
val debug = if (state != null && planData != null) {
moveEvaluator.buildDebugDetails(eval.move, attacker, defender, state, planData)
} else {
null
}
val flags = if (debug != null) {
listOf(
"stab=${debug.hasStab}",
"eff=${"%.2f".format(debug.effectiveness)}",
"acc=${"%.2f".format(debug.accuracy)}",
"prio=${debug.priority}",
"status=${debug.isStatusMove}",
"setup=${debug.isSetup}",
"hazardSet=${debug.setsHazards}",
"hazardClear=${debug.removesHazards}",
"weather=${debug.setsWeather}",
"recovery=${debug.isRecovery}",
"pivot=${debug.isPivot}",
"risky=${debug.isRisky}"
).joinToString(" ")
} else {
"n/a"
}
"${eval.move.id}:" +
"score=${"%.2f".format(eval.totalScore)} " +
"raw=${"%.1f".format(eval.rawDamage)} " +
"dmg=${"%.1f".format(eval.expectedDamage)} " +
"strat=${"%.1f".format(eval.strategicValue)} " +
"align=${"%.1f".format(eval.gamePlanAlignment)} " +
"turn=${"%.1f".format(eval.turnAdvantage)} " +
"risk=${"%.2f".format(eval.riskFactor)} " +
flags
}
debugLog("MoveRank plan=$plan situation=$situation top=[$details]")
}
private fun logSwitchDecision(
reason: String,
battle: PokemonBattle,
availableSwitches: List<BattlePokemon>,
chosen: BattlePokemon?
) {
if (!aiDebugEnabled) return
val state = battleState
val plan = currentGamePlan
val opponent = battleTracker.p1Active.activePokemon
val ranked = if (state != null && plan != null) {
availableSwitches.map { candidate ->
val score = switchDecisionMaker.evaluateSwitchOption(
candidate.effectedPokemon,
opponent,
state,
plan
)
candidate to score
}.sortedByDescending { it.second }
.take(3)
.joinToString(", ") { (candidate, score) ->
"${candidate.effectedPokemon.species.name}:${"%.1f".format(score)}"
}
} else {
"n/a"
}
val chosenName = chosen?.effectedPokemon?.species?.name ?: "none"
debugLog("Decision=$reason chosen=$chosenName options=[$ranked]")
}
private fun debugLog(message: String) {
if (aiDebugEnabled) {
Cobblemon.LOGGER.info("[CompetitiveBattleAI] $message")
}
}
private fun isAiDebugEnabled(): Boolean {
return true
}
}
@@ -31,6 +31,7 @@ import kotlin.collections.associateWith
import kotlin.collections.partition
import kotlin.math.absoluteValue
/**
* AI that tries to choose the best move for the given situations. Based off of the Pokemon Trainer Tournament Simulator Github
* https://github.com/cRz-Shadows/Pokemon_Trainer_Tournament_Simulator/blob/main/pokemon-showdown/sim/examples/Simulation-test-1.ts#L330
@@ -271,6 +272,11 @@ class StrongBattleAI(skill: Int) : BattleAI {
}
activeTrackerPokemon.firstTurn = false
// If HP is below 30% and not switching out, always use the most damaging move
if (activeTrackerPokemon.currentHpPercent < 0.3 && !shouldSwitchOut(aiSide, battle, activeBattlePokemon, moveset)) {
findAndUseMostDamagingMove(activeBattlePokemon, activeTrackerPokemon, opponents, availableMoves, moveset, battle, aiSide)?.let { return it }
}
// Decision-making based on move availability and switch-out condition
if (!shouldSwitchOut(aiSide, battle, activeBattlePokemon, moveset)) {
val nRemainingMons = activeTracker.alliedSide.actors.sumOf { actor -> actor.party.filter { it.currentHpPercent > 0 }.size }
@@ -521,6 +527,19 @@ class StrongBattleAI(skill: Int) : BattleAI {
val opponentActiveTracker = activeTracker.opponentSide.activePokemon
val opponentSpeedEstimations = opponentActiveTracker.map { statEstimationActive(it, Stats.SPEED) }
// Only switch if a switch-in is significantly better than the current Pokémon
val currentScore = estimateMatchup(activeBattlePokemon, side, battle)
val bestSwitchScore = availableSwitches.maxOfOrNull { estimateMatchup(activeBattlePokemon, side, battle, it) } ?: currentScore
val improvementThreshold = currentScore.absoluteValue * 0.25 + 2
if (bestSwitchScore <= currentScore + improvementThreshold) {
return false
}
if(bestSwitchScore < 1) {
return false
}
// todo add some way to keep track of the player's boosting to see if it needs to switch out to something that can stop it
// if slower speed stat than the opposing pokemon and HP is less than 20% don't switch out
@@ -548,6 +567,8 @@ class StrongBattleAI(skill: Int) : BattleAI {
if (availableSwitches.isEmpty() || availableSwitches.none { estimateMatchup(activeBattlePokemon, side, battle, it) > 0 })
return false
// ...and a 'good' reason to switch out
if (opponentActiveTracker.any { it.boosts.getOrDefault(Stats.ACCURACY, 0) <= accuracySwitchThreshold } ||
opponentActiveTracker.any { it.boosts.getOrDefault(Stats.DEFENCE, 0) <= -3 } ||
@@ -1,20 +0,0 @@
package com.cobblemon.mod.common.battles.ai.competitive
object AiBattleUtils {
fun normalizeWeatherId(weather: String?): String? {
val id = weather?.lowercase() ?: return null
return when (id) {
"sun", "sunny", "sunnyday", "harshsunlight" -> "sunnyday"
"rain", "raindance", "heavyrain" -> "raindance"
"sand", "sandstorm" -> "sandstorm"
"hail" -> "hail"
"snow", "snowscape" -> "snow"
else -> id
}
}
fun hasStab(moveTypeName: String, pokemonTypes: List<String>): Boolean {
val moveType = moveTypeName.lowercase()
return pokemonTypes.any { it.lowercase() == moveType }
}
}
@@ -1,236 +0,0 @@
package com.cobblemon.mod.common.battles.ai.competitive
import com.cobblemon.mod.common.api.moves.Move
import com.cobblemon.mod.common.api.pokemon.stats.Stat
import com.cobblemon.mod.common.api.pokemon.stats.Stats
import com.cobblemon.mod.common.battles.interpreter.ContextManager
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.pokemon.Pokemon
data class BattleState(
val turn: Int,
val playerTeam: List<Pokemon>,
val npcTeam: List<Pokemon>,
val playerActive: Pokemon,
val npcActive: Pokemon,
val weather: String?,
val terrain: String?,
val playerHazards: List<String>,
val npcHazards: List<String>,
val playerBoosts: Map<Stat, Int>,
val npcBoosts: Map<Stat, Int>,
val battleContext: ContextManager,
val gamePhase: GamePhase = determineGamePhase(turn, npcTeam, playerTeam),
val isDoubles: Boolean = false,
val playerActiveSlots: List<Pokemon> = listOf(playerActive),
val npcActiveSlots: List<Pokemon> = listOf(npcActive),
val mySlotIndex: Int = 0,
val partnerSlotIndex: Int? = null
) {
companion object {
private fun determineGamePhase(turn: Int, npcTeam: List<Pokemon>, playerTeam: List<Pokemon>): GamePhase {
val npcAlive = npcTeam.count { it.currentHealth > 0 }
val playerAlive = playerTeam.count { it.currentHealth > 0 }
return when {
turn <= 3 -> GamePhase.EARLY_GAME
npcAlive <= 2 || playerAlive <= 2 -> GamePhase.ENDGAME
turn >= 15 -> GamePhase.LATE_GAME
else -> GamePhase.MID_GAME
}
}
}
}
enum class GamePhase {
EARLY_GAME,
MID_GAME,
LATE_GAME,
ENDGAME
}
data class TrackedPokemon(
var pokemon: Pokemon? = null,
var originalPokemon: Pokemon? = null,
var species: String? = null,
var currentHp: Int = 0,
var currentHpPercent: Double = 0.0,
var maxHp: Int = 0,
var previousHp: Int = 0,
var lastHpChange: Int = 0,
var boosts: Map<Stat, Int> = mapOf(),
var atkBoost: Int = 0,
var defBoost: Int = 0,
var spaBoost: Int = 0,
var spdBoost: Int = 0,
var speBoost: Int = 0,
var currentAbility: String? = null,
var currentTypes: MutableList<String>? = null,
var stats: Map<Stat, Int> = mapOf(),
var moves: List<Move> = listOf(),
var revealedMoves: MutableSet<String> = mutableSetOf(),
var cachedAttack: Double = 0.0,
var cachedDefense: Double = 0.0,
var cachedSpAttack: Double = 0.0,
var cachedSpDefense: Double = 0.0,
var cachedSpeed: Double = 0.0,
var sideConditions: Map<String, Any> = mapOf(),
var firstTurn: Int = 0,
var protectCount: Int = 0,
var lastMoveDamage: Int = 0,
var statusTurns: Int = 0,
var switchInTurn: Int = 0,
var predictedRole: PokemonRole = PokemonRole.UNKNOWN,
var threatLevel: Int = 0
)
enum class PokemonRole {
UNKNOWN,
SWEEPER,
SETUP_SWEEPER,
WALLBREAKER,
REVENGE_KILLER,
TANK,
SUPPORT,
PIVOT,
BALANCED
}
data class TeamTracker(
var party: MutableList<TrackedPokemon> = mutableListOf(),
var uuid: String? = null,
var activePokemon: TrackedPokemon = TrackedPokemon(),
var activeSlots: MutableList<TrackedPokemon> = mutableListOf(),
var nRemainingMons: Int = 0,
var hazardDamage: Int = 0,
var teamSynergy: Double = 0.0,
var momentum: Double = 0.0
) {
fun getActiveAt(slotIndex: Int): TrackedPokemon? = activeSlots.getOrNull(slotIndex)
fun getAllActive(): List<TrackedPokemon> = activeSlots.filter { it.currentHp > 0 }
fun syncLegacyActivePokemon() {
if (activeSlots.isNotEmpty()) {
activePokemon = activeSlots[0]
}
}
}
class EnhancedActiveTracker {
var p1Active: TeamTracker = TeamTracker()
var p2Active: TeamTracker = TeamTracker()
private var lastStateUpdateTurn: Int = -1
fun updatePokemonSlot(team: TeamTracker, slotIndex: Int, battlePokemon: BattlePokemon) {
while (team.activeSlots.size <= slotIndex) {
team.activeSlots.add(TrackedPokemon())
}
updatePokemon(team.activeSlots[slotIndex], battlePokemon)
team.syncLegacyActivePokemon()
}
fun getTrackedPokemonByPNX(pnx: String, team: TeamTracker): TrackedPokemon? {
if (pnx.length < 3) return null
val slotIndex = pnx[2] - 'a'
return team.getActiveAt(slotIndex)
}
fun updatePokemon(tracker: TrackedPokemon, battlePokemon: BattlePokemon) {
val pokemon = battlePokemon.effectedPokemon
tracker.pokemon = pokemon
tracker.originalPokemon = battlePokemon.originalPokemon
tracker.species = pokemon.species.name
tracker.currentHp = pokemon.currentHealth
tracker.maxHp = pokemon.maxHealth
tracker.currentHpPercent = pokemon.currentHealth.toDouble() / pokemon.maxHealth
tracker.currentTypes = pokemon.types.map { it.name.lowercase() }.toMutableList()
tracker.currentAbility = pokemon.ability.name
tracker.moves = pokemon.moveSet.getMoves()
tracker.boosts = battlePokemon.statChanges
tracker.atkBoost = battlePokemon.statChanges[Stats.ATTACK] ?: 0
tracker.defBoost = battlePokemon.statChanges[Stats.DEFENCE] ?: 0
tracker.spaBoost = battlePokemon.statChanges[Stats.SPECIAL_ATTACK] ?: 0
tracker.spdBoost = battlePokemon.statChanges[Stats.SPECIAL_DEFENCE] ?: 0
tracker.speBoost = battlePokemon.statChanges[Stats.SPEED] ?: 0
cacheStats(tracker)
}
private fun cacheStats(tracker: TrackedPokemon) {
val pokemon = tracker.pokemon ?: return
tracker.cachedAttack = calculateStat(pokemon, Stats.ATTACK)
tracker.cachedDefense = calculateStat(pokemon, Stats.DEFENCE)
tracker.cachedSpAttack = calculateStat(pokemon, Stats.SPECIAL_ATTACK)
tracker.cachedSpDefense = calculateStat(pokemon, Stats.SPECIAL_DEFENCE)
tracker.cachedSpeed = calculateStat(pokemon, Stats.SPEED)
}
private fun calculateStat(pokemon: Pokemon, stat: Stat): Double {
val base = pokemon.species.baseStats[stat] ?: 0
val iv = pokemon.ivs[stat] ?: 31
val ev = pokemon.evs[stat] ?: 0
val level = pokemon.level
return ((2.0 * base + iv + ev / 4.0) * level / 100.0 + 5.0)
}
fun updateParty(team: TeamTracker, pokemon: TrackedPokemon) {
val existingIndex = team.party.indexOfFirst { it.pokemon?.uuid == pokemon.pokemon?.uuid }
if (existingIndex == -1) {
team.party.add(pokemon)
} else {
team.party[existingIndex] = pokemon
}
}
}
data class FearThreat(
val pokemon: Pokemon,
val hasEndeavor: Boolean,
val hasPriorityMove: Boolean,
val hasFocusItem: Boolean,
val threatLevel: Int
)
enum class BattleSituation {
DESPERATE,
WINNING,
EARLY_GAME,
ENDGAME,
OPPONENT_SETUP,
MY_SETUP,
NEUTRAL,
HAZARD_ADVANTAGE,
WEATHER_CONTROL
}
data class MatchupEvaluation(
val offensiveAdvantage: Double,
val defensiveAdvantage: Double,
val speedAdvantage: Double,
val overallScore: Double,
val recommendation: MatchupRecommendation
)
enum class MatchupRecommendation {
STAY_IN_AND_ATTACK,
STAY_IN_AND_SETUP,
STAY_IN_AND_STATUS,
CONSIDER_SWITCHING,
SWITCH_OUT,
PIVOT_OUT
}
@@ -1,483 +0,0 @@
package com.cobblemon.mod.common.battles.ai.competitive
import com.cobblemon.mod.common.CobblemonItems
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
import com.cobblemon.mod.common.api.moves.MoveTemplate
import com.cobblemon.mod.common.api.moves.Moves
import com.cobblemon.mod.common.api.moves.categories.DamageCategories
import com.cobblemon.mod.common.api.pokemon.stats.Stat
import com.cobblemon.mod.common.api.pokemon.stats.Stats
import com.cobblemon.mod.common.api.types.ElementalType
import com.cobblemon.mod.common.api.types.ElementalTypes
import com.cobblemon.mod.common.battles.InBattleMove
import com.cobblemon.mod.common.pokemon.Pokemon
import net.minecraft.core.registries.BuiltInRegistries
import java.util.*
import kotlin.math.max
class DamageCalculator(
private val battle: PokemonBattle?,
private val consumedItems: MutableMap<UUID, MutableList<String>> = mutableMapOf()
) {
fun calculateDamage(
move: InBattleMove,
attacker: TrackedPokemon,
defender: TrackedPokemon,
weather: String? = null,
criticalHit: Boolean = false,
isSpreadMove: Boolean = false,
targetCount: Int = 1
): Double {
val moveData = Moves.getByName(move.id) ?: return 0.0
var power = moveData.power.toDouble()
if (power <= 0) return 0.0
if (isSpreadMove && targetCount > 1) {
power *= 0.75
}
val immunityMultiplier = checkAllImmunities(moveData, attacker, defender)
if (immunityMultiplier == 0.0) return 0.0
val level = attacker.pokemon?.level ?: 50
val attackStat = getAttackStat(moveData, attacker)
val defenseStat = getDefenseStat(moveData, defender)
var damage = ((2.0 * level / 5.0 + 2.0) * power * (attackStat / defenseStat)) / 50.0 + 2.0
damage *= calculateCriticalMultiplier(criticalHit)
damage *= calculateSTABMultiplier(attacker, moveData)
damage *= TypeEffectiveness.calculateTypeEffectiveness(moveData.elementalType, defender.currentTypes ?: listOf())
damage *= calculateWeatherMultiplier(moveData, AiBattleUtils.normalizeWeatherId(weather))
damage *= calculateAbilityMultiplier(attacker, defender, moveData)
damage *= calculateItemMultiplier(attacker, defender, moveData)
damage *= calculateBurnMultiplier(attacker, moveData)
damage *= calculateScreenMultiplier(attacker, defender, moveData)
damage *= calculateRandomFactor()
damage = calculateMultiHitDamage(moveData, damage)
val finalDamage = max(1.0, damage)
if (finalDamage > 0) {
trackConsumedItems(defender, moveData)
}
return finalDamage
}
private fun getAttackStat(moveData: MoveTemplate, attacker: TrackedPokemon): Double {
val pokemon = attacker.pokemon ?: return 100.0
val baseStat = if (moveData.damageCategory == DamageCategories.PHYSICAL) {
getEffectiveStat(pokemon, Stats.ATTACK)
} else {
getEffectiveStat(pokemon, Stats.SPECIAL_ATTACK)
}
val boost = if (moveData.damageCategory == DamageCategories.PHYSICAL) {
attacker.atkBoost
} else {
attacker.spaBoost
}
return applyStatBoosts(baseStat, boost)
}
private fun getDefenseStat(moveData: MoveTemplate, defender: TrackedPokemon): Double {
val pokemon = defender.pokemon ?: return 100.0
val baseStat = if (moveData.damageCategory == DamageCategories.PHYSICAL) {
getEffectiveStat(pokemon, Stats.DEFENCE)
} else {
getEffectiveStat(pokemon, Stats.SPECIAL_DEFENCE)
}
val boost = if (moveData.damageCategory == DamageCategories.PHYSICAL) {
defender.defBoost
} else {
defender.spdBoost
}
return applyStatBoosts(baseStat, boost)
}
private fun applyStatBoosts(baseStat: Double, boost: Int): Double {
val clampedBoost = boost.coerceIn(-6, 6)
return if (clampedBoost >= 0) {
baseStat * (2.0 + clampedBoost) / 2.0
} else {
baseStat * 2.0 / (2.0 - clampedBoost)
}
}
private fun getEffectiveStat(pokemon: Pokemon, stat: Stat): Double {
val base = pokemon.species.baseStats[stat] ?: 0
val iv = pokemon.ivs[stat] ?: 31
val ev = pokemon.evs[stat] ?: 0
val level = pokemon.level
return if (stat == Stats.HP) {
((2.0 * base + iv + ev / 4.0) * level / 100.0 + level + 10.0)
} else {
((2.0 * base + iv + ev / 4.0) * level / 100.0 + 5.0)
}
}
private fun checkAllImmunities(
moveData: MoveTemplate,
attacker: TrackedPokemon,
defender: TrackedPokemon
): Double {
if (checkTypeImmunity(moveData, defender)) return 0.0
if (checkAbilityImmunity(moveData, attacker, defender)) return 0.0
if (checkItemImmunity(moveData, defender)) return 0.0
if (checkMoveSpecificImmunity(moveData, defender)) return 0.0
return 1.0
}
private fun checkTypeImmunity(moveData: MoveTemplate, defender: TrackedPokemon): Boolean {
val defenderTypes = (defender.currentTypes ?: defender.pokemon?.types?.map { it.name } ?: listOf())
.map { it.lowercase() }
return when (moveData.elementalType) {
ElementalTypes.GROUND -> "flying" in defenderTypes
ElementalTypes.ELECTRIC -> "ground" in defenderTypes
ElementalTypes.NORMAL, ElementalTypes.FIGHTING -> "ghost" in defenderTypes
ElementalTypes.PSYCHIC -> "dark" in defenderTypes
ElementalTypes.POISON -> "steel" in defenderTypes
ElementalTypes.DRAGON -> "fairy" in defenderTypes
ElementalTypes.GHOST -> "normal" in defenderTypes
else -> false
}
}
private fun checkAbilityImmunity(
moveData: MoveTemplate,
attacker: TrackedPokemon,
defender: TrackedPokemon
): Boolean {
val defenderAbility = defender.currentAbility?.lowercase()
?: defender.pokemon?.ability?.name?.lowercase()
?: return false
val attackerAbility = attacker.currentAbility?.lowercase()
?: attacker.pokemon?.ability?.name?.lowercase()
if (attackerAbility in listOf("moldbreaker", "turboblaze", "teravolt")) {
if (defenderAbility != "wonderguard") return false
}
return when (defenderAbility) {
"levitate" -> moveData.elementalType == ElementalTypes.GROUND
"voltabsorb", "lightningrod", "motordrive" -> moveData.elementalType == ElementalTypes.ELECTRIC
"flashfire", "wellbakedbody" -> moveData.elementalType == ElementalTypes.FIRE
"waterabsorb", "stormdrain", "dryskin" -> moveData.elementalType == ElementalTypes.WATER
"sapsipper" -> moveData.elementalType == ElementalTypes.GRASS
"eartheater" -> moveData.elementalType == ElementalTypes.GROUND
"soundproof" -> isSoundMove(moveData)
"bulletproof" -> isBallOrBombMove(moveData)
"queenlymajesty", "dazzling" -> moveData.priority > 0
"wonderguard" -> {
val effectiveness = TypeEffectiveness.calculateTypeEffectiveness(
moveData.elementalType,
defender.currentTypes ?: listOf()
)
effectiveness <= 1.0
}
"goodasgold" -> moveData.power.toInt() == 0
else -> false
}
}
private fun checkItemImmunity(moveData: MoveTemplate, defender: TrackedPokemon): Boolean {
val defenderItem = defender.pokemon?.heldItem()?.item?.let {
BuiltInRegistries.ITEM.getKey(it).toString()
} ?: return false
return when (defenderItem) {
"cobblemon:air_balloon" -> {
val notConsumed = consumedItems[defender.pokemon?.uuid]?.contains("airballoon") != true
notConsumed && moveData.elementalType == ElementalTypes.GROUND
}
"cobblemon:safety_goggles" -> isPowderMove(moveData) || isWeatherDamageMove(moveData)
else -> false
}
}
private fun checkMoveSpecificImmunity(moveData: MoveTemplate, defender: TrackedPokemon): Boolean {
val defenderTypes = (defender.currentTypes ?: defender.pokemon?.types?.map { it.name } ?: listOf())
.map { it.lowercase() }
val defenderAbility = defender.currentAbility?.lowercase()
?: defender.pokemon?.ability?.name?.lowercase()
return when (moveData.name.lowercase()) {
"thunderwave" -> {
"electric" in defenderTypes || "ground" in defenderTypes ||
defenderAbility in listOf("limber", "volt absorb", "lightningrod", "motordrive")
}
"willowisp" -> {
"fire" in defenderTypes ||
defenderAbility in listOf("waterveil", "waterbubble", "flashfire")
}
"toxic", "poisonpowder", "poisongas" -> {
"poison" in defenderTypes || "steel" in defenderTypes ||
defenderAbility in listOf("immunity", "poisonheal", "pastelveil")
}
"sleeppowder", "spore", "hypnosis", "sing" -> {
defenderAbility in listOf("insomnia", "vitalspirit", "comatose", "sweetveil")
}
else -> false
}
}
private fun calculateCriticalMultiplier(criticalHit: Boolean): Double {
return if (criticalHit) 1.5 else 1.0
}
private fun calculateSTABMultiplier(attacker: TrackedPokemon, moveData: MoveTemplate): Double {
val pokemonTypes = attacker.currentTypes ?: attacker.pokemon?.types?.map { it.name } ?: return 1.0
return if (AiBattleUtils.hasStab(moveData.elementalType.name, pokemonTypes)) {
if (attacker.currentAbility?.lowercase() == "adaptability") 2.0 else 1.5
} else 1.0
}
private fun calculateWeatherMultiplier(moveData: MoveTemplate, weather: String?): Double {
return when (weather) {
"sunnyday" -> when {
moveData.elementalType == ElementalTypes.FIRE -> 1.5
moveData.elementalType == ElementalTypes.WATER && moveData.name != "hydrosteam" -> 0.5
moveData.name == "hydrosteam" -> 1.5
else -> 1.0
}
"raindance" -> when {
moveData.elementalType == ElementalTypes.WATER -> 1.5
moveData.elementalType == ElementalTypes.FIRE -> 0.5
else -> 1.0
}
"sandstorm", "hail", "snow" -> if (moveData.name == "weatherball") 2.0 else 1.0
else -> 1.0
}
}
private fun calculateAbilityMultiplier(
attacker: TrackedPokemon,
defender: TrackedPokemon,
moveData: MoveTemplate
): Double {
var multiplier = 1.0
when (attacker.currentAbility?.lowercase()) {
"hugepower", "purepower" -> {
if (moveData.damageCategory == DamageCategories.PHYSICAL) multiplier *= 2.0
}
"guts" -> {
if (attacker.pokemon?.status != null && moveData.damageCategory == DamageCategories.PHYSICAL) {
multiplier *= 1.5
}
}
"overgrow" -> {
if (moveData.elementalType == ElementalTypes.GRASS && attacker.currentHpPercent <= 0.33) {
multiplier *= 1.5
}
}
"blaze" -> {
if (moveData.elementalType == ElementalTypes.FIRE && attacker.currentHpPercent <= 0.33) {
multiplier *= 1.5
}
}
"torrent" -> {
if (moveData.elementalType == ElementalTypes.WATER && attacker.currentHpPercent <= 0.33) {
multiplier *= 1.5
}
}
"swarm" -> {
if (moveData.elementalType == ElementalTypes.BUG && attacker.currentHpPercent <= 0.33) {
multiplier *= 1.5
}
}
}
when (defender.currentAbility?.lowercase()) {
"thickfat" -> {
if (moveData.elementalType == ElementalTypes.FIRE || moveData.elementalType == ElementalTypes.ICE) {
multiplier *= 0.5
}
}
"filter", "solidrock" -> {
val effectiveness = TypeEffectiveness.calculateTypeEffectiveness(
moveData.elementalType,
defender.currentTypes ?: listOf()
)
if (effectiveness > 1.0) multiplier *= 0.75
}
}
return multiplier
}
private fun calculateItemMultiplier(
attacker: TrackedPokemon,
defender: TrackedPokemon,
moveData: MoveTemplate
): Double {
var multiplier = 1.0
val attackerItem = attacker.pokemon?.heldItem()?.item?.let {
BuiltInRegistries.ITEM.getKey(it).toString()
}
when (attackerItem) {
"cobblemon:choice_band" -> {
if (moveData.damageCategory == DamageCategories.PHYSICAL) multiplier *= 1.5
}
"cobblemon:choice_specs" -> {
if (moveData.damageCategory == DamageCategories.SPECIAL) multiplier *= 1.5
}
"cobblemon:life_orb" -> multiplier *= 1.3
}
return multiplier
}
private fun calculateBurnMultiplier(attacker: TrackedPokemon, moveData: MoveTemplate): Double {
return if (attacker.pokemon?.status?.status?.showdownName == "burn" &&
moveData.damageCategory == DamageCategories.PHYSICAL &&
attacker.currentAbility != "guts") {
0.5
} else {
1.0
}
}
private fun calculateScreenMultiplier(
attacker: TrackedPokemon,
defender: TrackedPokemon,
moveData: MoveTemplate
): Double {
val attackerAbility = attacker.currentAbility?.lowercase() ?: attacker.pokemon?.ability?.name?.lowercase()
if (attackerAbility == "infiltrator") {
return 1.0
}
val sideConditions = defender.sideConditions.keys.map { it.lowercase() }
val hasReflect = "reflect" in sideConditions
val hasLightScreen = "lightscreen" in sideConditions || "light screen" in sideConditions
val hasAuroraVeil = "auroraveil" in sideConditions || "aurora veil" in sideConditions
val multiplier = when (moveData.damageCategory) {
DamageCategories.PHYSICAL -> {
when {
hasAuroraVeil -> 0.5
hasReflect -> 0.5
else -> 1.0
}
}
DamageCategories.SPECIAL -> {
when {
hasAuroraVeil -> 0.5
hasLightScreen -> 0.5
else -> 1.0
}
}
else -> 1.0
}
return multiplier
}
private fun calculateRandomFactor(): Double = 0.925
private fun calculateMultiHitDamage(moveData: MoveTemplate, baseDamage: Double): Double {
val moveName = moveData.name.lowercase()
return when {
moveName == "populationbomb" -> {
val accuracy = moveData.accuracy / 100.0
var expectedDamage = 0.0
var probability = 1.0
for (hit in 1..10) {
expectedDamage += baseDamage * probability
probability *= accuracy
}
expectedDamage
}
moveName in listOf("triplekick", "tripleaxel") -> {
val accuracy = moveData.accuracy / 100.0
baseDamage * 1.0 +
baseDamage * 2.0 * accuracy +
baseDamage * 3.0 * accuracy * accuracy
}
moveName in MoveData.multiHitMoves.keys -> {
val hitRange = MoveData.multiHitMoves[moveName]!!
val minHits = hitRange.keys.minOrNull() ?: 1
val maxHits = hitRange.values.maxOrNull() ?: 1
when {
minHits == 2 && maxHits == 5 -> baseDamage * 3.0
minHits == 2 && maxHits == 2 -> baseDamage * 2.0
minHits == 3 && maxHits == 3 -> baseDamage * 3.0
else -> baseDamage * ((minHits + maxHits) / 2.0)
}
}
else -> baseDamage
}
}
private fun isSoundMove(moveData: MoveTemplate): Boolean {
return moveData.name.lowercase() in listOf(
"boomburst", "bugbuzz", "chatter", "clangoroussoul", "disarmingvoice",
"echoedvoice", "grasswhistle", "growl", "hypervoice", "metalsound",
"nobleroar", "overdrive", "perishsong", "relicsong", "roar", "round",
"screech", "sing", "snore", "sparklingaria", "supersonic", "uproar"
)
}
private fun isBallOrBombMove(moveData: MoveTemplate): Boolean {
return moveData.name.lowercase() in listOf(
"acidspray", "aurasphere", "barrage", "bulletseed", "eggbomb",
"electroball", "energyball", "focusblast", "gyroball", "iceball",
"magnetbomb", "mistball", "mudbomb", "octazooka", "pollenpuff",
"rockblast", "searingshot", "seedbomb", "shadowball", "sludgebomb",
"weatherball", "zapcannon"
)
}
private fun isPowderMove(moveData: MoveTemplate): Boolean {
return moveData.name.lowercase() in listOf(
"sleeppowder", "stunspore", "poisonpowder", "cottonspore",
"ragepowder", "spore"
)
}
private fun isWeatherDamageMove(moveData: MoveTemplate): Boolean {
return moveData.name.lowercase() in listOf("sandstorm", "hail")
}
private fun trackConsumedItems(defender: TrackedPokemon, moveData: MoveTemplate) {
val pokemon = defender.pokemon ?: return
val defenderItem = pokemon.heldItem()?.item?.let {
BuiltInRegistries.ITEM.getKey(it).toString()
} ?: return
if (defenderItem == "cobblemon:air_balloon") {
val alreadyConsumed = consumedItems[pokemon.uuid]?.contains("airballoon") == true
if (!alreadyConsumed) {
addConsumedItem(pokemon.uuid, "airballoon")
}
}
}
private fun addConsumedItem(pokemonUuid: UUID, item: String) {
val items = consumedItems.getOrPut(pokemonUuid) { mutableListOf() }
items.add(item)
}
}
@@ -1,135 +0,0 @@
package com.cobblemon.mod.common.battles.ai.competitive
import com.cobblemon.mod.common.api.moves.Moves
import com.cobblemon.mod.common.api.pokemon.stats.Stats
import com.cobblemon.mod.common.battles.ActiveBattlePokemon
import com.cobblemon.mod.common.battles.InBattleMove
import com.cobblemon.mod.common.battles.ShowdownMoveset
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
class DoublesDecisionMaker(
private val moveEvaluator: MoveEvaluator,
private val damageCalculator: DamageCalculator
) {
data class MoveTargetPair(
val move: InBattleMove,
val targetPNX: String?,
val evaluation: MoveEvaluator.MoveEvaluation
)
fun findBestMoveAndTarget(
moveset: ShowdownMoveset?,
activeBattlePokemon: ActiveBattlePokemon,
myPokemon: TrackedPokemon,
opponents: List<TrackedPokemon>,
partner: TrackedPokemon?,
battleState: BattleState,
gamePlan: GamePlan
): MoveTargetPair? {
if (moveset == null) return null
val usableMoves = moveset.moves.filter { it.canBeUsed() }
if (usableMoves.isEmpty()) return null
val allOptions = mutableListOf<MoveTargetPair>()
for (move in usableMoves) {
val moveData = Moves.getByName(move.id) ?: continue
val targetList = move.target.targetList(activeBattlePokemon)
if (targetList == null) {
val evaluation = moveEvaluator.evaluateMoveForDoubles(
move, myPokemon, opponents.firstOrNull() ?: TrackedPokemon(),
opponents, partner, battleState, gamePlan
)
allOptions.add(MoveTargetPair(move, null, evaluation))
} else {
val opponentTargets = targetList.filterIsInstance<ActiveBattlePokemon>()
.filter { !it.isAllied(activeBattlePokemon) }
for (target in opponentTargets) {
val targetPokemon = opponents.find {
it.pokemon?.uuid == target.battlePokemon?.uuid
} ?: continue
val evaluation = moveEvaluator.evaluateMoveForDoubles(
move, myPokemon, targetPokemon,
opponents, partner, battleState, gamePlan
)
allOptions.add(MoveTargetPair(move, target.getPNX(), evaluation))
}
}
}
return allOptions.maxByOrNull { it.evaluation.totalScore }
}
fun scoreTarget(
target: TrackedPokemon,
myPokemon: TrackedPokemon,
allOpponents: List<TrackedPokemon>,
battleState: BattleState
): Double {
var score = 0.0
score += target.threatLevel * 20.0
val mySpeed = myPokemon.cachedSpeed
val targetSpeed = target.cachedSpeed
if (targetSpeed > mySpeed && target.currentHpPercent < 0.5) {
score += 100.0
}
if (target.boosts.values.any { it >= 2 }) {
score += 120.0
}
if (target.cachedAttack > 100 || target.cachedSpAttack > 100) {
score += 40.0
}
if (target.currentHpPercent < 0.3) {
score += 80.0
}
return score
}
fun selectBestTarget(
move: InBattleMove,
activeBattlePokemon: ActiveBattlePokemon,
myPokemon: TrackedPokemon,
opponents: List<TrackedPokemon>,
battleState: BattleState
): String? {
val targetList = move.target.targetList(activeBattlePokemon) ?: return null
val opponentTargets = targetList.filterIsInstance<ActiveBattlePokemon>()
.filter { !it.isAllied(activeBattlePokemon) }
if (opponentTargets.isEmpty()) return null
val targetScores = opponentTargets.mapNotNull { target ->
val targetPokemon = opponents.find {
it.pokemon?.uuid == target.battlePokemon?.uuid
}
if (targetPokemon != null) {
val damage = damageCalculator.calculateDamage(
move, myPokemon, targetPokemon, battleState.weather
)
val targetScore = scoreTarget(targetPokemon, myPokemon, opponents, battleState)
val totalScore = damage + targetScore
target to totalScore
} else {
null
}
}
return targetScores.maxByOrNull { it.second }?.first?.getPNX()
}
}
@@ -1,178 +0,0 @@
package com.cobblemon.mod.common.battles.ai.competitive
import com.cobblemon.mod.common.api.moves.MoveTemplate
import com.cobblemon.mod.common.api.moves.Moves
import com.cobblemon.mod.common.api.pokemon.stats.Stat
import com.cobblemon.mod.common.api.pokemon.stats.Stats
import com.cobblemon.mod.common.api.pokemon.status.Statuses
object MoveData {
val multiHitMoves: Map<String, Map<Int, Int>> = mapOf(
"armthrust" to mapOf(2 to 5),
"barrage" to mapOf(2 to 5),
"bonerush" to mapOf(2 to 5),
"bulletseed" to mapOf(2 to 5),
"cometpunch" to mapOf(2 to 5),
"doubleslap" to mapOf(2 to 5),
"furyattack" to mapOf(2 to 5),
"furyswipes" to mapOf(2 to 5),
"iciclespear" to mapOf(2 to 5),
"pinmissile" to mapOf(2 to 5),
"rockblast" to mapOf(2 to 5),
"scaleshot" to mapOf(2 to 5),
"spikecannon" to mapOf(2 to 5),
"tailslap" to mapOf(2 to 5),
"watershuriken" to mapOf(2 to 5),
"bonemerang" to mapOf(2 to 2),
"doublehit" to mapOf(2 to 2),
"doubleironbash" to mapOf(2 to 2),
"doublekick" to mapOf(2 to 2),
"dragondarts" to mapOf(2 to 2),
"dualchop" to mapOf(2 to 2),
"dualwingbeat" to mapOf(2 to 2),
"geargrind" to mapOf(2 to 2),
"twinbeam" to mapOf(2 to 2),
"twineedle" to mapOf(2 to 2),
"surgingstrikes" to mapOf(3 to 3),
"tripledive" to mapOf(3 to 3),
"tripleaxel" to mapOf(1 to 3),
"triplekick" to mapOf(1 to 3),
"populationbomb" to mapOf(1 to 10)
)
val statusMoves: Map<MoveTemplate?, String> = mapOf(
Moves.getByName("willowisp") to Statuses.BURN.showdownName,
Moves.getByName("scald") to Statuses.BURN.showdownName,
Moves.getByName("scorchingsands") to Statuses.BURN.showdownName,
Moves.getByName("flamethrower") to Statuses.BURN.showdownName,
Moves.getByName("sacredfire") to Statuses.BURN.showdownName,
Moves.getByName("glare") to Statuses.PARALYSIS.showdownName,
Moves.getByName("nuzzle") to Statuses.PARALYSIS.showdownName,
Moves.getByName("stunspore") to Statuses.PARALYSIS.showdownName,
Moves.getByName("thunderwave") to Statuses.PARALYSIS.showdownName,
Moves.getByName("bodyslam") to Statuses.PARALYSIS.showdownName,
Moves.getByName("discharge") to Statuses.PARALYSIS.showdownName,
Moves.getByName("spark") to Statuses.PARALYSIS.showdownName,
Moves.getByName("darkvoid") to Statuses.SLEEP.showdownName,
Moves.getByName("hypnosis") to Statuses.SLEEP.showdownName,
Moves.getByName("lovelykiss") to Statuses.SLEEP.showdownName,
Moves.getByName("relicsong") to Statuses.SLEEP.showdownName,
Moves.getByName("sing") to Statuses.SLEEP.showdownName,
Moves.getByName("sleeppowder") to Statuses.SLEEP.showdownName,
Moves.getByName("spore") to Statuses.SLEEP.showdownName,
Moves.getByName("yawn") to Statuses.SLEEP.showdownName,
Moves.getByName("chatter") to "confusion",
Moves.getByName("confuseray") to "confusion",
Moves.getByName("dynamicpunch") to "confusion",
Moves.getByName("flatter") to "confusion",
Moves.getByName("supersonic") to "confusion",
Moves.getByName("swagger") to "confusion",
Moves.getByName("sweetkiss") to "confusion",
Moves.getByName("teeterdance") to "confusion",
Moves.getByName("poisongas") to Statuses.POISON.showdownName,
Moves.getByName("poisonpowder") to Statuses.POISON.showdownName,
Moves.getByName("poisonjab") to Statuses.POISON.showdownName,
Moves.getByName("sludgebomb") to Statuses.POISON.showdownName,
Moves.getByName("crosspoison") to Statuses.POISON.showdownName,
Moves.getByName("toxic") to Statuses.POISON_BADLY.showdownName,
Moves.getByName("toxicthread") to Statuses.POISON.showdownName,
Moves.getByName("curse") to "cursed",
Moves.getByName("leechseed") to "leech"
)
val boostFromMoves: Map<String, Map<Stat, Int>> = mapOf(
"bellydrum" to mapOf(Stats.ATTACK to 6),
"swordsdance" to mapOf(Stats.ATTACK to 2),
"honeclaws" to mapOf(Stats.ATTACK to 1, Stats.ACCURACY to 1),
"bulkup" to mapOf(Stats.ATTACK to 1, Stats.DEFENCE to 1),
"curse" to mapOf(Stats.ATTACK to 1, Stats.DEFENCE to 1, Stats.SPEED to -1),
"howl" to mapOf(Stats.ATTACK to 1),
"meditate" to mapOf(Stats.ATTACK to 1),
"sharpen" to mapOf(Stats.ATTACK to 1),
"workup" to mapOf(Stats.ATTACK to 1, Stats.SPECIAL_ATTACK to 1),
"acidarmor" to mapOf(Stats.DEFENCE to 2),
"barrier" to mapOf(Stats.DEFENCE to 2),
"cottonguard" to mapOf(Stats.DEFENCE to 3),
"defensecurl" to mapOf(Stats.DEFENCE to 1),
"irondefense" to mapOf(Stats.DEFENCE to 2),
"stockpile" to mapOf(Stats.DEFENCE to 1, Stats.SPECIAL_DEFENCE to 1),
"stuffcheeks" to mapOf(Stats.DEFENCE to 2),
"shelter" to mapOf(Stats.DEFENCE to 2, Stats.EVASION to 1),
"withdraw" to mapOf(Stats.DEFENCE to 1),
"harden" to mapOf(Stats.DEFENCE to 1),
"nastyplot" to mapOf(Stats.SPECIAL_ATTACK to 2),
"calmmind" to mapOf(Stats.SPECIAL_ATTACK to 1, Stats.SPECIAL_DEFENCE to 1),
"quiverdance" to mapOf(Stats.SPECIAL_ATTACK to 1, Stats.SPECIAL_DEFENCE to 1, Stats.SPEED to 1),
"tailglow" to mapOf(Stats.SPECIAL_ATTACK to 3),
"takeheart" to mapOf(Stats.SPECIAL_ATTACK to 1, Stats.SPECIAL_DEFENCE to 1),
"geomancy" to mapOf(Stats.SPECIAL_ATTACK to 2, Stats.SPECIAL_DEFENCE to 2, Stats.SPEED to 2),
"growth" to mapOf(Stats.SPECIAL_ATTACK to 1),
"amnesia" to mapOf(Stats.SPECIAL_DEFENCE to 2),
"agility" to mapOf(Stats.SPEED to 2),
"autotomize" to mapOf(Stats.SPEED to 2),
"rockpolish" to mapOf(Stats.SPEED to 2),
"dragondance" to mapOf(Stats.ATTACK to 1, Stats.SPEED to 1),
"shiftgear" to mapOf(Stats.ATTACK to 1, Stats.SPEED to 2),
"clangoroussoul" to mapOf(Stats.ATTACK to 1, Stats.DEFENCE to 1, Stats.SPECIAL_ATTACK to 1, Stats.SPECIAL_DEFENCE to 1, Stats.SPEED to 1),
"extremeevoboost" to mapOf(Stats.ATTACK to 2, Stats.DEFENCE to 2, Stats.SPECIAL_ATTACK to 2, Stats.SPECIAL_DEFENCE to 2, Stats.SPEED to 2),
"clangoroussoulblaze" to mapOf(Stats.ATTACK to 1, Stats.DEFENCE to 1, Stats.SPECIAL_ATTACK to 1, Stats.SPECIAL_DEFENCE to 1, Stats.SPEED to 1),
"filletaway" to mapOf(Stats.ATTACK to 2, Stats.SPECIAL_ATTACK to 2, Stats.SPEED to 2),
"noretreat" to mapOf(Stats.ATTACK to 1, Stats.DEFENCE to 1, Stats.SPECIAL_ATTACK to 1, Stats.SPECIAL_DEFENCE to 1, Stats.SPEED to 1),
"shellsmash" to mapOf(Stats.ATTACK to 2, Stats.DEFENCE to -1, Stats.SPECIAL_ATTACK to 2, Stats.SPECIAL_DEFENCE to -1, Stats.SPEED to 2),
"tidyup" to mapOf(Stats.ATTACK to 1, Stats.SPEED to 1),
"victorydance" to mapOf(Stats.ATTACK to 1, Stats.DEFENCE to 1, Stats.SPEED to 1),
"coil" to mapOf(Stats.ATTACK to 1, Stats.DEFENCE to 1, Stats.ACCURACY to 1),
"minimize" to mapOf(Stats.EVASION to 2),
"doubleteam" to mapOf(Stats.EVASION to 1)
)
val weatherMoves: Map<String, String> = mapOf(
"raindance" to "rain",
"sunnyday" to "sun",
"sandstorm" to "sand",
"hail" to "hail",
"snowscape" to "snow"
)
val weatherDependentMoves: Map<String, String> = mapOf(
"thunder" to "rain",
"hurricane" to "rain",
"blizzard" to "hail",
"solarbeam" to "sun",
"hydrosteam" to "sun",
"weatherball" to "any"
)
val weatherAbilities: Map<String, String> = mapOf(
"swiftswim" to "rain",
"raindish" to "rain",
"dryskin" to "rain",
"chlorophyll" to "sun",
"leafguard" to "sun",
"flowergift" to "sun",
"solarpower" to "sun",
"sandrush" to "sand",
"sandveil" to "sand",
"sandforce" to "sand",
"icebody" to "hail",
"snowcloak" to "hail"
)
val entryHazards = listOf("spikes", "stealthrock", "stickyweb", "toxicspikes")
val antiHazardsMoves = listOf("rapidspin", "defog", "tidyup")
val antiBoostMoves = listOf("clearsmog", "haze", "roar", "whirlwind")
val pivotMoves = listOf("uturn", "flipturn", "partingshot", "batonpass", "voltswitch", "teleport")
val setupMoves = setOf("tailwind", "trickroom", "auroraveil", "lightscreen", "reflect")
val selfRecoveryMoves = listOf("healorder", "milkdrink", "recover", "rest", "roost", "slackoff", "softboiled")
val priorityMoves = listOf(
"quickattack", "extremespeed", "bulletpunch", "machpunch",
"aquajet", "shadowsneak", "accelerock", "iceshard",
"suckerpunch", "firstimpression", "fakeout"
)
val recoilMoves = listOf(
"doubleedge", "bravebird", "closecombat", "superpower",
"overheat", "dracometeor", "leafstorm", "flareblitz"
)
}
@@ -1,737 +0,0 @@
package com.cobblemon.mod.common.battles.ai.competitive
import com.cobblemon.mod.common.api.moves.Moves
import com.cobblemon.mod.common.api.pokemon.stats.Stats
import com.cobblemon.mod.common.battles.InBattleMove
import com.cobblemon.mod.common.battles.MoveTarget
import com.cobblemon.mod.common.pokemon.Pokemon
import kotlin.math.abs
import kotlin.math.max
class MoveEvaluator(
private val damageCalculator: DamageCalculator,
private val opponentPredictor: OpponentPredictor,
private val isDoublesMode: Boolean = false
) {
data class MoveEvaluation(
val move: InBattleMove,
val rawDamage: Double,
val expectedDamage: Double,
val strategicValue: Double,
val riskFactor: Double,
val priority: Int,
val turnAdvantage: Double,
val gamePlanAlignment: Double
) {
val totalScore: Double = (expectedDamage + strategicValue + gamePlanAlignment + turnAdvantage) / riskFactor
}
data class MoveDebugDetails(
val moveId: String,
val moveType: String,
val accuracy: Double,
val rawDamage: Double,
val expectedDamage: Double,
val effectiveness: Double,
val hasStab: Boolean,
val priority: Int,
val isStatusMove: Boolean,
val setsWeather: Boolean,
val setsHazards: Boolean,
val removesHazards: Boolean,
val isRecovery: Boolean,
val isPivot: Boolean,
val isSetup: Boolean,
val isRisky: Boolean
)
fun buildDebugDetails(
move: InBattleMove,
attacker: TrackedPokemon,
defender: TrackedPokemon,
battleState: BattleState,
gamePlan: GamePlan
): MoveDebugDetails? {
val moveData = Moves.getByName(move.id) ?: return null
val rawDamage = damageCalculator.calculateDamage(move, attacker, defender, battleState.weather)
val accuracy = getEffectiveAccuracy(move, attacker, defender, battleState.weather)
val expectedDamage = rawDamage * accuracy
val effectiveness = TypeEffectiveness.calculateTypeEffectiveness(
moveData.elementalType,
defender.currentTypes ?: listOf()
)
val attackerTypes = attacker.currentTypes ?: attacker.pokemon?.types?.map { it.name } ?: listOf()
val hasStab = AiBattleUtils.hasStab(moveData.elementalType.name, attackerTypes)
val moveId = move.id.lowercase()
val isStatusMove = MoveData.statusMoves.keys.any { it?.name?.lowercase() == moveId }
val setsWeather = moveId in MoveData.weatherMoves.keys
val setsHazards = moveId in MoveData.entryHazards
val removesHazards = moveId in MoveData.antiHazardsMoves
val isRecovery = moveId in MoveData.selfRecoveryMoves
val isPivot = moveId in MoveData.pivotMoves
val isSetup = moveId in MoveData.boostFromMoves.keys
val isRisky = moveId in gamePlan.riskyMoves
return MoveDebugDetails(
moveId = move.id,
moveType = moveData.elementalType.name,
accuracy = accuracy,
rawDamage = rawDamage,
expectedDamage = expectedDamage,
effectiveness = effectiveness,
hasStab = hasStab,
priority = moveData.priority,
isStatusMove = isStatusMove,
setsWeather = setsWeather,
setsHazards = setsHazards,
removesHazards = removesHazards,
isRecovery = isRecovery,
isPivot = isPivot,
isSetup = isSetup,
isRisky = isRisky
)
}
fun evaluateMove(
move: InBattleMove,
attacker: TrackedPokemon,
defender: TrackedPokemon,
battleState: BattleState,
gamePlan: GamePlan
): MoveEvaluation {
val moveData = Moves.getByName(move.id)
?: return MoveEvaluation(move, 0.0, 0.0, 0.0, 1.0, 0, 0.0, 0.0)
val rawDamage = damageCalculator.calculateDamage(move, attacker, defender, battleState.weather)
val accuracy = getEffectiveAccuracy(move, attacker, defender, battleState.weather)
val expectedDamage = rawDamage * accuracy
val strategicValue = calculateStrategicValue(move, attacker, defender, battleState, gamePlan)
val riskFactor = calculateRiskFactor(move, attacker, defender, battleState, gamePlan)
val turnAdvantage = calculateTurnAdvantage(move, attacker, defender, battleState)
val gamePlanAlignment = calculateGamePlanAlignment(move, attacker, defender, battleState, gamePlan)
return MoveEvaluation(
move = move,
rawDamage = rawDamage,
expectedDamage = expectedDamage,
strategicValue = strategicValue,
riskFactor = riskFactor,
priority = moveData.priority,
turnAdvantage = turnAdvantage,
gamePlanAlignment = gamePlanAlignment
)
}
private fun getEffectiveAccuracy(
move: InBattleMove,
attacker: TrackedPokemon,
defender: TrackedPokemon,
weather: String?
): Double {
val moveData = Moves.getByName(move.id) ?: return 0.0
var accuracy = if (moveData.accuracy <= 0) 1.0 else moveData.accuracy / 100.0
val normalizedWeather = AiBattleUtils.normalizeWeatherId(weather)
when (normalizedWeather) {
"raindance" -> {
if (move.id.lowercase() in listOf("thunder", "hurricane")) accuracy = 1.0
}
"hail", "snow" -> {
if (move.id.lowercase() == "blizzard") accuracy = 1.0
}
"sunnyday" -> {
if (move.id.lowercase() in listOf("thunder", "hurricane")) accuracy *= 0.5
}
}
when (attacker.currentAbility?.lowercase()) {
"compoundeyes" -> accuracy *= 1.3
"noguard" -> accuracy = 1.0
}
when (defender.currentAbility?.lowercase()) {
"noguard" -> accuracy = 1.0
"sandveil" -> if (normalizedWeather == "sandstorm") accuracy *= 0.8
"snowcloak" -> if (normalizedWeather in listOf("hail", "snow")) accuracy *= 0.8
}
val accuracyBoost = attacker.boosts.getOrDefault(Stats.ACCURACY, 0)
val evasionBoost = defender.boosts.getOrDefault(Stats.EVASION, 0)
val netBoost = accuracyBoost - evasionBoost
if (netBoost != 0) {
accuracy *= if (netBoost > 0) {
(3.0 + netBoost) / 3.0
} else {
3.0 / (3.0 - netBoost)
}
}
return accuracy.coerceIn(0.0, 1.0)
}
private fun calculateStrategicValue(
move: InBattleMove,
attacker: TrackedPokemon,
defender: TrackedPokemon,
battleState: BattleState,
gamePlan: GamePlan
): Double {
var value = 0.0
if (move.id.lowercase() in MoveData.weatherMoves.keys) {
value += evaluateWeatherSetting(move, gamePlan, battleState)
}
if (move.id.lowercase() in MoveData.boostFromMoves.keys) {
value += evaluateSetupMove(move, attacker, defender, battleState, gamePlan)
}
val moveId = move.id.lowercase()
val isStatusMove = MoveData.statusMoves.keys.any { it?.name?.lowercase() == moveId }
if (isStatusMove) {
value += evaluateStatusMove(move, attacker, defender, battleState, gamePlan)
}
if (move.id.lowercase() in MoveData.entryHazards) {
value += evaluateHazardSetting(battleState, gamePlan)
}
if (move.id.lowercase() in MoveData.antiHazardsMoves) {
value += evaluateHazardRemoval(battleState, gamePlan)
}
val moveData = Moves.getByName(move.id)
if (moveData != null && moveData.priority > 0) {
value += evaluatePriorityMove(move, attacker, defender, battleState)
}
if (move.id.lowercase() in MoveData.selfRecoveryMoves) {
value += evaluateRecoveryMove(attacker, battleState, gamePlan)
}
if (move.id.lowercase() in MoveData.pivotMoves) {
value += evaluatePivotMove(move, attacker, defender, battleState)
}
if (battleState.gamePhase == GamePhase.ENDGAME) {
value += evaluateEndgameMove(move, battleState)
}
return value
}
private fun calculateGamePlanAlignment(
move: InBattleMove,
attacker: TrackedPokemon,
defender: TrackedPokemon,
battleState: BattleState,
gamePlan: GamePlan
): Double {
val moveData = Moves.getByName(move.id) ?: return 0.0
var alignment = 0.0
val normalizedWeather = AiBattleUtils.normalizeWeatherId(battleState.weather)
if (move.id.lowercase() in gamePlan.riskyMoves) {
alignment -= 100.0
}
alignment += when (gamePlan.winCondition) {
WinCondition.RAIN_OFFENSE -> {
var score = 0.0
if (move.id.lowercase() == "raindance") score += 200.0
if (normalizedWeather == "raindance") {
if (moveData.elementalType.name.lowercase() == "water") score += 50.0
if (move.id.lowercase() in listOf("thunder", "hurricane")) score += 100.0
}
score
}
WinCondition.SUN_OFFENSE -> {
var score = 0.0
if (move.id.lowercase() == "sunnyday") score += 200.0
if (normalizedWeather == "sunnyday") {
if (moveData.elementalType.name.lowercase() == "fire") score += 50.0
if (move.id.lowercase() == "solarbeam") score += 100.0
}
score
}
WinCondition.SETUP_SWEEP -> {
var score = 0.0
if (move.id.lowercase() in MoveData.boostFromMoves.keys &&
attacker.species in gamePlan.keyPokemon
) {
score += 150.0
}
if (attacker.boosts.values.any { it >= 2 } && moveData.power > 80) {
score += 100.0
}
score
}
WinCondition.AGGRESSIVE_SWEEP -> {
var score = 0.0
if (moveData.power >= 90) score += 60.0
if (moveData.priority > 0 && defender.currentHpPercent < 0.5) score += 80.0
score
}
WinCondition.DEFENSIVE_STALL -> {
var score = 0.0
if (MoveData.statusMoves.keys.any { it?.name?.lowercase() == move.id.lowercase() }) score += 70.0
if (move.id.lowercase() in MoveData.selfRecoveryMoves) score += 60.0
if (moveData.power > 80) score -= 30.0
score
}
WinCondition.HAZARD_CONTROL -> {
var score = 0.0
if (move.id.lowercase() == "stealthrock" && "stealthrock" !in battleState.playerHazards) {
score += 250.0
}
if (move.id.lowercase() in MoveData.entryHazards) score += 100.0
score
}
WinCondition.REVENGE_KILLING -> {
var score = 0.0
if (moveData.priority > 0) score += 120.0
if (defender.currentHp > 50 && moveData.power >= 40 && moveData.power <= 80) score += 40.0
score
}
else -> 0.0
}
if (moveData.power > 0) {
alignment += moveData.power * gamePlan.aggressionLevel * 0.3
} else {
alignment += (1.0 - gamePlan.aggressionLevel) * 30.0
}
return alignment
}
private fun calculateRiskFactor(
move: InBattleMove,
attacker: TrackedPokemon,
defender: TrackedPokemon,
battleState: BattleState,
gamePlan: GamePlan
): Double {
val moveData = Moves.getByName(move.id) ?: return 1.0
var risk = 1.0
val accuracy = getEffectiveAccuracy(move, attacker, defender, battleState.weather)
risk += (1.0 - accuracy) * 0.5
if (move.id.lowercase() in MoveData.recoilMoves) {
risk += if (attacker.currentHpPercent < 0.5) 0.5 else 0.2
}
if (move.id.lowercase() in listOf("explosion", "selfdestruct", "memento", "healingwish")) {
if (attacker.species in gamePlan.keyPokemon) {
risk += 2.0
} else if (attacker.currentHpPercent < 0.3) {
risk += 0.2
} else {
risk += 0.8
}
}
if (move.pp <= 1) {
risk += 0.3
}
val mySpeed = attacker.pokemon?.let { getEffectiveStat(it, Stats.SPEED) } ?: 0.0
val oppSpeed = defender.pokemon?.let { getEffectiveStat(it, Stats.SPEED) } ?: 0.0
if (abs(mySpeed - oppSpeed) < 5) {
risk += 0.1
}
val teamAdvantage = calculateTeamAdvantage(battleState)
if (teamAdvantage > 0) {
risk *= 0.8
} else if (teamAdvantage < -1) {
risk *= 1.2
}
return max(0.1, risk)
}
private fun calculateTurnAdvantage(
move: InBattleMove,
attacker: TrackedPokemon,
defender: TrackedPokemon,
battleState: BattleState
): Double {
val moveData = Moves.getByName(move.id) ?: return 0.0
var advantage = 0.0
val mySpeed = attacker.pokemon?.let { getEffectiveStat(it, Stats.SPEED) } ?: 0.0
val oppSpeed = defender.pokemon?.let { getEffectiveStat(it, Stats.SPEED) } ?: 0.0
if (mySpeed > oppSpeed) advantage += 15.0
if (moveData.priority > 0) advantage += moveData.priority * 25.0
if (battleState.gamePhase == GamePhase.ENDGAME && moveData.power > 90) {
advantage += 20.0
}
return advantage
}
private fun evaluateWeatherSetting(move: InBattleMove, gamePlan: GamePlan, battleState: BattleState): Double {
val moveName = move.id.lowercase()
val weatherType = MoveData.weatherMoves[moveName] ?: return 0.0
return when (gamePlan.winCondition) {
WinCondition.RAIN_OFFENSE -> if (weatherType == "rain") 300.0 else 0.0
WinCondition.SUN_OFFENSE -> if (weatherType == "sun") 300.0 else 0.0
WinCondition.SAND_OFFENSE -> if (weatherType == "sand") 300.0 else 0.0
WinCondition.WEATHER_CONTROL -> 150.0
else -> 30.0
}
}
private fun evaluateSetupMove(
move: InBattleMove,
attacker: TrackedPokemon,
defender: TrackedPokemon,
battleState: BattleState,
gamePlan: GamePlan
): Double {
val boosts = MoveData.boostFromMoves[move.id.lowercase()] ?: return 0.0
var value = 0.0
val totalBoosts = boosts.values.sum()
value += totalBoosts * 40.0 * gamePlan.setupPriority
val relevantBoosts = boosts.keys.mapNotNull { stat -> attacker.boosts[stat] }
if (relevantBoosts.any { it >= 3 }) value *= 0.2
val predictedMoves = opponentPredictor.predictMoveHeuristically(defender, attacker)
val dangerLevel = predictedMoves.count { (moveName, _) ->
(Moves.getByName(moveName)?.power ?: 0.0) > 80
}
if (dangerLevel > 0 && attacker.currentHpPercent < 0.7) {
value *= 0.4
}
return value
}
private fun evaluateStatusMove(
move: InBattleMove,
attacker: TrackedPokemon,
defender: TrackedPokemon,
battleState: BattleState,
gamePlan: GamePlan
): Double {
if (defender.pokemon?.status != null) return 0.0
return when (move.id.lowercase()) {
"thunderwave", "stunspore", "glare" -> {
if (defender.predictedRole == PokemonRole.SWEEPER) 90.0 else 50.0
}
"willowisp" -> {
if (defender.predictedRole in listOf(PokemonRole.WALLBREAKER, PokemonRole.SWEEPER)) {
80.0
} else 40.0
}
"toxic" -> {
if (gamePlan.winCondition == WinCondition.DEFENSIVE_STALL) 100.0 else 60.0
}
"spore", "sleeppowder" -> 120.0
else -> 30.0
}
}
private fun evaluateHazardSetting(battleState: BattleState, gamePlan: GamePlan): Double {
val remainingOpponents = battleState.playerTeam.count { it.currentHealth > 0 }
if (remainingOpponents < 2) return 15.0
var value = remainingOpponents * 20.0
if (gamePlan.winCondition == WinCondition.HAZARD_CONTROL) value *= 1.8
return value
}
private fun evaluateHazardRemoval(battleState: BattleState, gamePlan: GamePlan): Double {
val myHazards = battleState.npcHazards.size
if (myHazards == 0) return 5.0
var value = myHazards * 40.0
val remainingTeam = battleState.npcTeam.count { it.currentHealth > 0 }
if (remainingTeam >= 3) value *= 1.3
return value
}
private fun evaluatePriorityMove(
move: InBattleMove,
attacker: TrackedPokemon,
defender: TrackedPokemon,
battleState: BattleState
): Double {
val moveData = Moves.getByName(move.id) ?: return 0.0
var value = moveData.priority * 20.0
if (defender.currentHpPercent < 0.5) {
val damage = damageCalculator.calculateDamage(move, attacker, defender, battleState.weather)
if (damage >= defender.currentHp) value += 150.0
}
val mySpeed = attacker.pokemon?.let { getEffectiveStat(it, Stats.SPEED) } ?: 0.0
val oppSpeed = defender.pokemon?.let { getEffectiveStat(it, Stats.SPEED) } ?: 0.0
if (abs(mySpeed - oppSpeed) < 10) value += 50.0
return value
}
private fun evaluateRecoveryMove(
attacker: TrackedPokemon,
battleState: BattleState,
gamePlan: GamePlan
): Double {
if (attacker.currentHpPercent > 0.8) return 5.0
var value = (1.0 - attacker.currentHpPercent) * 140.0
if (gamePlan.winCondition == WinCondition.DEFENSIVE_STALL) value *= 1.5
return value
}
private fun evaluatePivotMove(
move: InBattleMove,
attacker: TrackedPokemon,
defender: TrackedPokemon,
battleState: BattleState
): Double {
var value = 40.0
val damage = damageCalculator.calculateDamage(move, attacker, defender, battleState.weather)
value += damage * 0.3
return value
}
private fun evaluateEndgameMove(move: InBattleMove, battleState: BattleState): Double {
val moveData = Moves.getByName(move.id) ?: return 0.0
var bonus = 0.0
if (moveData.power > 0 && moveData.accuracy >= 90) {
bonus += 35.0
}
if (moveData.accuracy < 80) {
bonus -= 30.0
}
if (moveData.priority > 0) {
bonus += 50.0
}
return bonus
}
private fun calculateTeamAdvantage(battleState: BattleState): Int {
val npcAlive = battleState.npcTeam.count { it.currentHealth > 0 }
val playerAlive = battleState.playerTeam.count { it.currentHealth > 0 }
return npcAlive - playerAlive
}
private fun getEffectiveStat(pokemon: Pokemon, stat: Stats): Double {
val base = pokemon.species.baseStats[stat] ?: 0
val iv = pokemon.ivs[stat] ?: 31
val ev = pokemon.evs[stat] ?: 0
val level = pokemon.level
return if (stat == Stats.HP) {
((2.0 * base + iv + ev / 4.0) * level / 100.0 + level + 10.0)
} else {
((2.0 * base + iv + ev / 4.0) * level / 100.0 + 5.0)
}
}
fun evaluateMoveForDoubles(
move: InBattleMove,
attacker: TrackedPokemon,
primaryTarget: TrackedPokemon,
allOpponents: List<TrackedPokemon>,
partner: TrackedPokemon?,
battleState: BattleState,
gamePlan: GamePlan
): MoveEvaluation {
val moveData = Moves.getByName(move.id)
?: return MoveEvaluation(move, 0.0, 0.0, 0.0, 1.0, 0, 0.0, 0.0)
if (isSpreadMove(moveData.target)) {
return evaluateSpreadMove(move, attacker, allOpponents, partner, battleState, gamePlan)
}
val baseEvaluation = evaluateMove(move, attacker, primaryTarget, battleState, gamePlan)
var targetingBonus = 0.0
if (primaryTarget.threatLevel > 5) {
targetingBonus += 20.0
}
return MoveEvaluation(
move = baseEvaluation.move,
rawDamage = baseEvaluation.rawDamage,
expectedDamage = baseEvaluation.expectedDamage,
strategicValue = baseEvaluation.strategicValue + targetingBonus,
riskFactor = baseEvaluation.riskFactor,
priority = baseEvaluation.priority,
turnAdvantage = baseEvaluation.turnAdvantage,
gamePlanAlignment = baseEvaluation.gamePlanAlignment
)
}
private fun evaluateSpreadMove(
move: InBattleMove,
attacker: TrackedPokemon,
allOpponents: List<TrackedPokemon>,
partner: TrackedPokemon?,
battleState: BattleState,
gamePlan: GamePlan
): MoveEvaluation {
val moveData = Moves.getByName(move.id)
?: return MoveEvaluation(move, 0.0, 0.0, 0.0, 1.0, 0, 0.0, 0.0)
var totalDamage = 0.0
var totalStrategicValue = 0.0
val activeOpponents = allOpponents.filter { it.currentHp > 0 }
val targetCount = activeOpponents.size + (if (hitsPartner(moveData.target) && partner != null) 1 else 0)
for (opponent in activeOpponents) {
val damage = damageCalculator.calculateDamage(
move, attacker, opponent, battleState.weather,
isSpreadMove = true,
targetCount = targetCount
)
totalDamage += damage
if (damage >= opponent.currentHp) {
totalStrategicValue += 150.0
}
}
val multiTargetBonus = activeOpponents.size * 40.0
totalStrategicValue += multiTargetBonus
var partnerPenalty = 0.0
if (hitsPartner(moveData.target) && partner != null && partner.currentHp > 0) {
val partnerDamage = damageCalculator.calculateDamage(
move, attacker, partner, battleState.weather,
isSpreadMove = true,
targetCount = targetCount
)
partnerPenalty = when {
partnerDamage >= partner.currentHp -> -999999.0
partner.species in gamePlan.keyPokemon -> -partnerDamage * 5.0
partner.currentHpPercent < 0.3 -> -partnerDamage * 4.0
else -> -partnerDamage * 2.0
}
totalStrategicValue += partnerPenalty
}
val accuracy =
getEffectiveAccuracy(move, attacker, activeOpponents.firstOrNull() ?: TrackedPokemon(), battleState.weather)
val expectedDamage = totalDamage * accuracy
val riskFactor = if (partnerPenalty < -1000) {
999.0
} else if (partnerPenalty < 0) {
max(1.5, 1.0 + abs(partnerPenalty) / 100.0)
} else {
1.0
}
val gamePlanAlignment = if (activeOpponents.isNotEmpty()) {
calculateGamePlanAlignment(move, attacker, activeOpponents.first(), battleState, gamePlan)
} else {
0.0
}
return MoveEvaluation(
move = move,
rawDamage = totalDamage,
expectedDamage = expectedDamage,
strategicValue = totalStrategicValue,
riskFactor = riskFactor,
priority = moveData.priority,
turnAdvantage = 0.0,
gamePlanAlignment = gamePlanAlignment
)
}
private fun isSpreadMove(target: MoveTarget): Boolean {
return target in listOf(
MoveTarget.allAdjacent,
MoveTarget.allAdjacentFoes,
MoveTarget.all
)
}
private fun hitsPartner(target: MoveTarget): Boolean {
return target == MoveTarget.allAdjacent
}
}
@@ -1,157 +0,0 @@
package com.cobblemon.mod.common.battles.ai.competitive
import com.cobblemon.mod.common.api.moves.Moves
import com.cobblemon.mod.common.pokemon.Pokemon
import kotlin.math.min
class OpponentPredictor {
private val moveHistory = mutableMapOf<String, MutableList<String>>()
private val switchHistory = mutableMapOf<String, MutableList<String>>()
private val situationResponses = mutableMapOf<String, MutableMap<String, Int>>()
private val aggressionLevel = mutableMapOf<String, Double>()
private val setupTendency = mutableMapOf<String, Double>()
private val switchFrequency = mutableMapOf<String, Double>()
fun updateMoveHistory(pokemon: String, move: String, situation: String) {
moveHistory.getOrPut(pokemon) { mutableListOf() }.add(move)
situationResponses.getOrPut(situation) { mutableMapOf() }.merge(move, 1, Int::plus)
val moveData = Moves.getByName(move)
if (moveData != null) {
val currentAggression = aggressionLevel[pokemon] ?: 0.5
val newAggression = if (moveData.power > 0) {
currentAggression * 0.9 + 0.8 * 0.1
} else {
currentAggression * 0.9 + 0.2 * 0.1
}
aggressionLevel[pokemon] = newAggression
if (move in MoveData.boostFromMoves.keys) {
val currentSetup = setupTendency[pokemon] ?: 0.3
setupTendency[pokemon] = min(1.0, currentSetup + 0.15)
}
}
}
fun updateSwitchPattern(fromPokemon: String, toPokemon: String, reason: String) {
switchHistory.getOrPut(fromPokemon) { mutableListOf() }.add(toPokemon)
situationResponses.getOrPut("switch_$reason") { mutableMapOf() }.merge(toPokemon, 1, Int::plus)
val totalActions = (moveHistory[fromPokemon]?.size ?: 0) + (switchHistory[fromPokemon]?.size ?: 0)
if (totalActions > 0) {
switchFrequency[fromPokemon] = (switchHistory[fromPokemon]?.size ?: 0).toDouble() / totalActions
}
}
fun predictNextMove(pokemon: String, situation: String): Map<String, Double> {
val responses = situationResponses[situation] ?: return emptyMap()
val total = responses.values.sum().toDouble()
return if (total > 0) {
responses.mapValues { it.value / total }
} else {
emptyMap()
}
}
fun getSwitchProbability(pokemon: String, situation: String): Double {
val switches = switchHistory[pokemon]?.size ?: 0
val totalActions = (moveHistory[pokemon]?.size ?: 0) + switches
if (totalActions < 5) return 0.2
return min(0.8, switches.toDouble() / totalActions + 0.1)
}
private fun getAggressionLevel(pokemon: String): Double = aggressionLevel[pokemon] ?: 0.5
private fun getSetupTendency(pokemon: String): Double = setupTendency[pokemon] ?: 0.3
private fun getSwitchFrequency(pokemon: String): Double = switchFrequency[pokemon] ?: 0.2
fun predictMoveHeuristically(
opponent: TrackedPokemon,
myPokemon: TrackedPokemon
): Map<String, Double> {
val predictions = mutableMapOf<String, Double>()
val aggression = getAggressionLevel(opponent.species ?: "unknown")
for (moveName in opponent.revealedMoves) {
val moveData = Moves.getByName(moveName) ?: continue
var probability = 0.25
probability *= if (moveData.power > 0) {
aggression + 0.3
} else {
(1.0 - aggression) + 0.3
}
val myTypes = myPokemon.currentTypes ?: listOf()
val effectiveness = TypeEffectiveness.calculateTypeEffectiveness(moveData.elementalType, myTypes)
probability *= (0.5 + effectiveness)
predictions[moveName] = probability
}
val total = predictions.values.sum()
return if (total > 0) {
predictions.mapValues { it.value / total }
} else {
emptyMap()
}
}
fun predictSwitchTarget(
fromPokemon: String,
myActivePokemon: TrackedPokemon
): Map<String, Double> {
val pastSwitches = switchHistory[fromPokemon] ?: return emptyMap()
val switchCounts = mutableMapOf<String, Int>()
for (target in pastSwitches) {
switchCounts.merge(target, 1, Int::plus)
}
val total = switchCounts.values.sum().toDouble()
return if (total > 0) {
switchCounts.mapValues { it.value / total }
} else {
emptyMap()
}
}
fun categorizePlaystyle(pokemon: String): OpponentPlaystyle {
val aggression = getAggressionLevel(pokemon)
val setupTend = getSetupTendency(pokemon)
val switchFreq = getSwitchFrequency(pokemon)
return when {
setupTend > 0.5 -> OpponentPlaystyle.SETUP_ORIENTED
aggression > 0.7 && switchFreq < 0.3 -> OpponentPlaystyle.HYPER_OFFENSIVE
switchFreq > 0.5 -> OpponentPlaystyle.MOMENTUM_BASED
aggression < 0.4 -> OpponentPlaystyle.DEFENSIVE_STALL
else -> OpponentPlaystyle.BALANCED
}
}
fun reset() {
moveHistory.clear()
switchHistory.clear()
situationResponses.clear()
aggressionLevel.clear()
setupTendency.clear()
switchFrequency.clear()
}
}
enum class OpponentPlaystyle {
HYPER_OFFENSIVE,
SETUP_ORIENTED,
MOMENTUM_BASED,
DEFENSIVE_STALL,
BALANCED
}
@@ -1,340 +0,0 @@
package com.cobblemon.mod.common.battles.ai.competitive
import com.cobblemon.mod.common.api.pokemon.stats.Stats
import com.cobblemon.mod.common.pokemon.Pokemon
import kotlin.math.max
class StrategyAnalyzer {
fun analyzeTeamComposition(team: List<Pokemon>): GamePlan {
val roles = team.map { identifyPokemonRole(it) }
val sweepers = roles.count { it == PokemonRole.SWEEPER }
val setupSweepers = roles.count { it == PokemonRole.SETUP_SWEEPER }
val wallbreakers = roles.count { it == PokemonRole.WALLBREAKER }
val supports = roles.count { it in listOf(PokemonRole.SUPPORT, PokemonRole.TANK) }
val revengeKillers = roles.count { it == PokemonRole.REVENGE_KILLER }
val weatherStrategy = identifyWeatherStrategy(team)
if (weatherStrategy != null) {
return createWeatherGamePlan(weatherStrategy, team)
}
val hazardStrategy = identifyHazardStrategy(team)
if (hazardStrategy != null) {
return createHazardGamePlan(team)
}
val winCondition = when {
setupSweepers >= 2 && supports >= 2 -> WinCondition.SETUP_SWEEP
sweepers + wallbreakers >= 4 -> WinCondition.AGGRESSIVE_SWEEP
supports >= 3 -> WinCondition.DEFENSIVE_STALL
revengeKillers >= 2 -> WinCondition.REVENGE_KILLING
else -> WinCondition.BALANCED
}
return createGamePlan(winCondition, team, roles)
}
private fun identifyWeatherStrategy(team: List<Pokemon>): WinCondition? {
val rainSetters = team.count { hasWeatherSettingMove(it, "rain") || hasWeatherSettingAbility(it, "rain") }
val rainAbusers = team.count { hasWeatherAbility(it, "rain") || hasWeatherMoves(it, "rain") }
val sunSetters = team.count { hasWeatherSettingMove(it, "sun") || hasWeatherSettingAbility(it, "sun") }
val sunAbusers = team.count { hasWeatherAbility(it, "sun") || hasWeatherMoves(it, "sun") }
val sandSetters = team.count { hasWeatherSettingMove(it, "sand") || hasWeatherSettingAbility(it, "sand") }
val sandAbusers = team.count { hasWeatherAbility(it, "sand") }
return when {
rainSetters >= 1 && rainAbusers >= 2 -> WinCondition.RAIN_OFFENSE
sunSetters >= 1 && sunAbusers >= 2 -> WinCondition.SUN_OFFENSE
sandSetters >= 1 && sandAbusers >= 2 -> WinCondition.SAND_OFFENSE
rainSetters >= 1 || sunSetters >= 1 || sandSetters >= 1 -> WinCondition.WEATHER_CONTROL
else -> null
}
}
private fun identifyHazardStrategy(team: List<Pokemon>): Boolean {
val hazardSetters = team.count { pokemon ->
pokemon.moveSet.getMoves().any { it.name.lowercase() in MoveData.entryHazards }
}
val hazardRemovers = team.count { pokemon ->
pokemon.moveSet.getMoves().any { it.name.lowercase() in MoveData.antiHazardsMoves }
}
return hazardSetters >= 2 && hazardRemovers >= 1
}
private fun createWeatherGamePlan(winCondition: WinCondition, team: List<Pokemon>): GamePlan {
val weatherType = when (winCondition) {
WinCondition.RAIN_OFFENSE -> "rain"
WinCondition.SUN_OFFENSE -> "sun"
WinCondition.SAND_OFFENSE -> "sand"
else -> "any"
}
val setters =
team.filter { hasWeatherSettingMove(it, weatherType) || hasWeatherSettingAbility(it, weatherType) }
val abusers = team.filter { hasWeatherAbility(it, weatherType) || hasWeatherMoves(it, weatherType) }
val keyPokemon = (setters + abusers).distinct().map { it.species.name }
val priorities = when (winCondition) {
WinCondition.RAIN_OFFENSE -> listOf(
"set_rain_immediately",
"preserve_rain_setter",
"sweep_with_rain_abusers",
"use_perfect_accuracy_moves",
"prevent_weather_changes"
)
WinCondition.SUN_OFFENSE -> listOf(
"set_sun_immediately",
"preserve_sun_setter",
"sweep_with_chlorophyll",
"use_solar_beam",
"prevent_weather_changes"
)
WinCondition.SAND_OFFENSE -> listOf(
"set_sandstorm",
"abuse_sand_rush",
"chip_damage_from_sand",
"prevent_weather_changes"
)
else -> listOf("maintain_weather", "use_weather_abusers")
}
val riskyMoves = listOf(
"explosion",
"selfdestruct",
"memento"
)
return GamePlan(
winCondition = winCondition,
keyPokemon = keyPokemon,
priorities = priorities,
riskyMoves = riskyMoves,
aggressionLevel = 0.8,
setupPriority = 0.9
)
}
private fun createHazardGamePlan(team: List<Pokemon>): GamePlan {
val hazardSetters = team.filter { pokemon ->
pokemon.moveSet.getMoves().any { it.name.lowercase() in MoveData.entryHazards }
}.map { it.species.name }
return GamePlan(
winCondition = WinCondition.HAZARD_CONTROL,
keyPokemon = hazardSetters,
priorities = listOf(
"set_stealth_rock_early",
"stack_hazards_if_safe",
"remove_opponent_hazards",
"force_switches",
"preserve_hazard_setters"
),
riskyMoves = listOf("explosion"),
aggressionLevel = 0.6,
setupPriority = 0.7
)
}
private fun createGamePlan(winCondition: WinCondition, team: List<Pokemon>, roles: List<PokemonRole>): GamePlan {
val keyPokemon = identifyKeyPokemon(winCondition, team, roles)
val priorities = when (winCondition) {
WinCondition.SETUP_SWEEP -> listOf(
"create_setup_opportunity",
"execute_setup_moves",
"sweep_after_setup",
"preserve_setup_sweeper",
"remove_priority_threats"
)
WinCondition.AGGRESSIVE_SWEEP -> listOf(
"maintain_offensive_pressure",
"use_coverage_moves",
"preserve_sweepers",
"use_priority_to_finish",
"momentum_over_setup"
)
WinCondition.DEFENSIVE_STALL -> listOf(
"spread_status_conditions",
"use_recovery_moves",
"set_up_hazards",
"stall_out_threats",
"remove_opponent_hazards"
)
WinCondition.REVENGE_KILLING -> listOf(
"preserve_revenge_killer",
"use_priority_strategically",
"chip_into_priority_range",
"scout_with_protect",
"maintain_momentum"
)
WinCondition.HAZARD_CONTROL -> listOf(
"set_stealth_rock_early",
"stack_hazards_safely",
"remove_opponent_hazards",
"force_switches"
)
else -> listOf(
"maintain_balance",
"adapt_to_opponent",
"resource_management",
"take_calculated_risks"
)
}
val riskyMoves = when (winCondition) {
WinCondition.SETUP_SWEEP -> listOf("explosion", "memento", "healingwish", "lunardance")
WinCondition.REVENGE_KILLING -> listOf("doubleedge", "bravebird", "flareblitz")
WinCondition.DEFENSIVE_STALL -> MoveData.recoilMoves
else -> listOf("explosion", "memento")
}
val aggressionLevel = when (winCondition) {
WinCondition.AGGRESSIVE_SWEEP -> 0.9
WinCondition.SETUP_SWEEP -> 0.7
WinCondition.REVENGE_KILLING -> 0.75
WinCondition.DEFENSIVE_STALL -> 0.3
else -> 0.6
}
val setupPriority = when (winCondition) {
WinCondition.SETUP_SWEEP -> 0.95
WinCondition.DEFENSIVE_STALL -> 0.6
else -> 0.5
}
return GamePlan(
winCondition = winCondition,
keyPokemon = keyPokemon,
priorities = priorities,
riskyMoves = riskyMoves,
aggressionLevel = aggressionLevel,
setupPriority = setupPriority
)
}
private fun identifyKeyPokemon(
winCondition: WinCondition,
team: List<Pokemon>,
roles: List<PokemonRole>
): List<String> {
return when (winCondition) {
WinCondition.SETUP_SWEEP -> {
team.filterIndexed { index, _ -> roles[index] == PokemonRole.SETUP_SWEEPER }
.map { it.species.name }
}
WinCondition.AGGRESSIVE_SWEEP -> {
team.filterIndexed { index, _ -> roles[index] in listOf(PokemonRole.SWEEPER, PokemonRole.WALLBREAKER) }
.map { it.species.name }
}
WinCondition.REVENGE_KILLING -> {
team.filterIndexed { index, _ -> roles[index] == PokemonRole.REVENGE_KILLER }
.map { it.species.name }
}
WinCondition.DEFENSIVE_STALL -> {
team.filterIndexed { index, _ -> roles[index] in listOf(PokemonRole.TANK, PokemonRole.SUPPORT) }
.map { it.species.name }
}
else -> team.take(2).map { it.species.name }
}
}
fun identifyPokemonRole(pokemon: Pokemon): PokemonRole {
val attack = pokemon.species.baseStats[Stats.ATTACK] ?: 0
val spAttack = pokemon.species.baseStats[Stats.SPECIAL_ATTACK] ?: 0
val defense = pokemon.species.baseStats[Stats.DEFENCE] ?: 0
val spDefense = pokemon.species.baseStats[Stats.SPECIAL_DEFENCE] ?: 0
val speed = pokemon.species.baseStats[Stats.SPEED] ?: 0
val hp = pokemon.species.baseStats[Stats.HP] ?: 0
val maxAttack = max(attack, spAttack)
val avgDefense = (defense + spDefense) / 2.0
val bulk = hp + avgDefense
val hasSetupMoves = pokemon.moveSet.getMoves().any { it.name.lowercase() in MoveData.boostFromMoves.keys }
val hasPriorityMoves = pokemon.moveSet.getMoves().any { it.name.lowercase() in MoveData.priorityMoves }
val hasPivotMoves = pokemon.moveSet.getMoves().any { it.name.lowercase() in MoveData.pivotMoves }
val hasRecoveryMoves = pokemon.moveSet.getMoves().any { it.name.lowercase() in MoveData.selfRecoveryMoves }
return when {
hasPivotMoves -> PokemonRole.PIVOT
hasSetupMoves && speed >= 90 && maxAttack >= 90 -> PokemonRole.SETUP_SWEEPER
speed >= 110 && hasPriorityMoves -> PokemonRole.REVENGE_KILLER
speed >= 100 && maxAttack >= 100 -> PokemonRole.SWEEPER
maxAttack >= 120 -> PokemonRole.WALLBREAKER
bulk >= 180 && maxAttack < 80 -> PokemonRole.TANK
hasRecoveryMoves || hasSetupMoves -> PokemonRole.SUPPORT
else -> PokemonRole.BALANCED
}
}
private fun hasWeatherSettingMove(pokemon: Pokemon, weather: String): Boolean {
val moves = pokemon.moveSet.getMoves().map { it.name.lowercase() }
return when (weather) {
"rain" -> "raindance" in moves
"sun" -> "sunnyday" in moves
"sand" -> "sandstorm" in moves
else -> moves.any { it in MoveData.weatherMoves.keys }
}
}
private fun hasWeatherSettingAbility(pokemon: Pokemon, weather: String): Boolean {
val ability = pokemon.ability.name.lowercase()
return when (weather) {
"rain" -> ability == "drizzle"
"sun" -> ability == "drought"
"sand" -> ability == "sandstream"
else -> false
}
}
private fun hasWeatherAbility(pokemon: Pokemon, weather: String): Boolean {
val ability = pokemon.ability.name.lowercase()
return when (weather) {
"rain" -> ability in listOf("swiftswim", "raindish", "dryskin")
"sun" -> ability in listOf("chlorophyll", "leafguard", "flowergift", "solarpower")
"sand" -> ability in listOf("sandrush", "sandveil", "sandforce")
else -> MoveData.weatherAbilities[ability] == weather
}
}
private fun hasWeatherMoves(pokemon: Pokemon, weather: String): Boolean {
val moves = pokemon.moveSet.getMoves().map { it.name.lowercase() }
return when (weather) {
"rain" -> moves.any { it in listOf("thunder", "hurricane") }
"sun" -> moves.any { it in listOf("solarbeam", "hydrosteam") }
else -> false
}
}
}
enum class WinCondition {
AGGRESSIVE_SWEEP,
SETUP_SWEEP,
DEFENSIVE_STALL,
HAZARD_CONTROL,
REVENGE_KILLING,
BALANCED,
RAIN_OFFENSE,
SUN_OFFENSE,
SAND_OFFENSE,
WEATHER_CONTROL
}
data class GamePlan(
val winCondition: WinCondition,
val keyPokemon: List<String>,
val priorities: List<String>,
val riskyMoves: List<String>,
val aggressionLevel: Double = 0.6,
val setupPriority: Double = 0.5
)
@@ -1,324 +0,0 @@
package com.cobblemon.mod.common.battles.ai.competitive
import com.cobblemon.mod.common.api.pokemon.stats.Stats
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.pokemon.Pokemon
import kotlin.math.max
class SwitchDecisionMaker(
private val damageCalculator: DamageCalculator,
private val opponentPredictor: OpponentPredictor,
private val strategyAnalyzer: StrategyAnalyzer
) {
fun shouldVoluntarilySwitch(
myPokemon: TrackedPokemon,
opponentPokemon: TrackedPokemon,
battleState: BattleState,
gamePlan: GamePlan,
availableSwitches: List<BattlePokemon>
): Boolean {
if (availableSwitches.isEmpty()) return false
val currentMatchup = evaluateMatchup(myPokemon, opponentPokemon, battleState)
val bestSwitchScore = availableSwitches.maxOfOrNull { switchOption ->
evaluateSwitchOption(
switchOption.effectedPokemon,
opponentPokemon,
battleState,
gamePlan
)
} ?: 0.0
val switchThreshold = 40.0
if (bestSwitchScore > currentMatchup.overallScore + switchThreshold) {
return true
}
val shouldSwitch = checkSwitchConditions(
myPokemon,
opponentPokemon,
battleState,
gamePlan,
currentMatchup
)
return shouldSwitch
}
fun findBestSwitch(
availableSwitches: List<BattlePokemon>,
opponentPokemon: TrackedPokemon,
battleState: BattleState,
gamePlan: GamePlan
): BattlePokemon? {
if (availableSwitches.isEmpty()) return null
return availableSwitches.maxByOrNull { switchOption ->
evaluateSwitchOption(
switchOption.effectedPokemon,
opponentPokemon,
battleState,
gamePlan
)
}
}
fun evaluateSwitchOption(
candidate: Pokemon,
opponent: TrackedPokemon,
battleState: BattleState,
gamePlan: GamePlan
): Double {
var score = 0.0
val candidateTracker = createTrackerPokemon(candidate)
val matchup = evaluateMatchup(candidateTracker, opponent, battleState)
score += matchup.overallScore
val hpFactor = candidateTracker.currentHpPercent
if (hpFactor < 0.5) {
score -= (1.0 - hpFactor) * 40.0
}
if (gamePlan.keyPokemon.contains(candidate.species.name)) {
score += 20.0
}
val mySpeed = getEffectiveStat(candidate, Stats.SPEED)
val oppSpeed = opponent.pokemon?.let { getEffectiveStat(it, Stats.SPEED) } ?: 0.0
if (mySpeed > oppSpeed) score += 25.0
val hazardDamage = calculateEntryHazardDamage(candidate, battleState.npcHazards)
score -= hazardDamage * 0.5
val role = strategyAnalyzer.identifyPokemonRole(candidate)
score += evaluateRoleSynergy(role, gamePlan, battleState)
return score
}
private fun evaluateMatchup(
myPokemon: TrackedPokemon,
opponent: TrackedPokemon,
battleState: BattleState
): MatchupEvaluation {
val ourBestEffectiveness = calculateBestMoveEffectiveness(myPokemon, opponent)
val offensiveAdvantage = (ourBestEffectiveness - 1.0) * 40.0
val theirBestEffectiveness = calculateBestMoveEffectiveness(opponent, myPokemon)
val defensiveAdvantage = -(theirBestEffectiveness - 1.0) * 35.0
val mySpeed = myPokemon.pokemon?.let { getEffectiveStat(it, Stats.SPEED) } ?: 0.0
val oppSpeed = opponent.pokemon?.let { getEffectiveStat(it, Stats.SPEED) } ?: 0.0
val speedAdvantage = if (mySpeed > oppSpeed) 20.0 else -15.0
val overallScore = offensiveAdvantage + defensiveAdvantage + speedAdvantage
val recommendation = when {
overallScore > 60 && myPokemon.currentHpPercent > 0.7 -> MatchupRecommendation.STAY_IN_AND_SETUP
overallScore > 30 -> MatchupRecommendation.STAY_IN_AND_ATTACK
overallScore > 0 -> MatchupRecommendation.CONSIDER_SWITCHING
overallScore > -30 -> MatchupRecommendation.PIVOT_OUT
else -> MatchupRecommendation.SWITCH_OUT
}
return MatchupEvaluation(
offensiveAdvantage = offensiveAdvantage,
defensiveAdvantage = defensiveAdvantage,
speedAdvantage = speedAdvantage,
overallScore = overallScore,
recommendation = recommendation
)
}
private fun checkSwitchConditions(
myPokemon: TrackedPokemon,
opponent: TrackedPokemon,
battleState: BattleState,
gamePlan: GamePlan,
matchup: MatchupEvaluation
): Boolean {
val theirBestEffectiveness = calculateBestMoveEffectiveness(opponent, myPokemon)
if (theirBestEffectiveness >= 2.0 && myPokemon.currentHpPercent > 0.3) {
return true
}
if (myPokemon.currentHpPercent < 0.3 && matchup.overallScore < 30) {
return true
}
if (opponent.boosts.values.any { it >= 2 } && matchup.overallScore < 20) {
return true
}
if (myPokemon.species in gamePlan.keyPokemon &&
myPokemon.currentHpPercent < 0.5 &&
theirBestEffectiveness > 1.0
) {
return true
}
return false
}
private fun calculateBestMoveEffectiveness(
attacker: TrackedPokemon,
defender: TrackedPokemon
): Double {
val moves = attacker.pokemon?.moveSet?.getMoves() ?: return 1.0
return moves.maxOfOrNull { move ->
TypeEffectiveness.calculateTypeEffectiveness(
move.type,
defender.currentTypes ?: listOf()
)
} ?: 1.0
}
private fun calculateEntryHazardDamage(pokemon: Pokemon, hazards: List<String>): Double {
var damage = 0.0
val maxHP = getEffectiveStat(pokemon, Stats.HP)
for (hazard in hazards) {
when (hazard.lowercase()) {
"stealthrock" -> {
val rockEffectiveness = pokemon.types.fold(1.0) { acc, type ->
acc * TypeEffectiveness.getDamageMultiplier(
com.cobblemon.mod.common.api.types.ElementalTypes.ROCK,
type
)
}
damage += maxHP * rockEffectiveness * 0.125
}
"spikes" -> damage += maxHP * 0.125
"toxicspikes" -> {
if (!pokemon.types.any { it.name.lowercase() in listOf("poison", "steel") }) {
damage += maxHP * 0.15
}
}
"stickyweb" -> damage += 10.0
}
}
return damage
}
private fun evaluateRoleSynergy(
role: PokemonRole,
gamePlan: GamePlan,
battleState: BattleState
): Double {
return when (gamePlan.winCondition) {
WinCondition.SETUP_SWEEP -> {
when (role) {
PokemonRole.SETUP_SWEEPER -> 50.0
PokemonRole.SUPPORT -> if (battleState.gamePhase == GamePhase.EARLY_GAME) 30.0 else 10.0
else -> 0.0
}
}
WinCondition.AGGRESSIVE_SWEEP -> {
when (role) {
PokemonRole.SWEEPER, PokemonRole.WALLBREAKER -> 40.0
PokemonRole.REVENGE_KILLER -> 30.0
else -> 0.0
}
}
WinCondition.DEFENSIVE_STALL -> {
when (role) {
PokemonRole.TANK, PokemonRole.SUPPORT -> 45.0
else -> -10.0
}
}
WinCondition.REVENGE_KILLING -> {
when (role) {
PokemonRole.REVENGE_KILLER -> 60.0
PokemonRole.PIVOT -> 25.0
else -> 0.0
}
}
WinCondition.RAIN_OFFENSE, WinCondition.SUN_OFFENSE, WinCondition.SAND_OFFENSE -> {
when (role) {
PokemonRole.SWEEPER -> 35.0
else -> 0.0
}
}
else -> 0.0
}
}
private fun createTrackerPokemon(pokemon: Pokemon): TrackedPokemon {
val tracker = TrackedPokemon(
pokemon = pokemon,
originalPokemon = pokemon,
species = pokemon.species.name,
currentHp = pokemon.currentHealth,
maxHp = pokemon.maxHealth,
currentHpPercent = pokemon.currentHealth.toDouble() / pokemon.maxHealth,
currentTypes = pokemon.types.map { it.name.lowercase() }.toMutableList(),
currentAbility = pokemon.ability.name,
moves = pokemon.moveSet.getMoves(),
predictedRole = strategyAnalyzer.identifyPokemonRole(pokemon),
cachedAttack = getEffectiveStat(pokemon, Stats.ATTACK),
cachedDefense = getEffectiveStat(pokemon, Stats.DEFENCE),
cachedSpAttack = getEffectiveStat(pokemon, Stats.SPECIAL_ATTACK),
cachedSpDefense = getEffectiveStat(pokemon, Stats.SPECIAL_DEFENCE),
cachedSpeed = getEffectiveStat(pokemon, Stats.SPEED)
)
return tracker
}
private fun getEffectiveStat(pokemon: Pokemon, stat: Stats): Double {
val base = pokemon.species.baseStats[stat] ?: 0
val iv = pokemon.ivs[stat] ?: 31
val ev = pokemon.evs[stat] ?: 0
val level = pokemon.level
return if (stat == Stats.HP) {
((2.0 * base + iv + ev / 4.0) * level / 100.0 + level + 10.0)
} else {
((2.0 * base + iv + ev / 4.0) * level / 100.0 + 5.0)
}
}
}
@@ -1,403 +0,0 @@
package com.cobblemon.mod.common.battles.ai.competitive
import com.cobblemon.mod.common.api.types.ElementalType
import com.cobblemon.mod.common.api.types.ElementalTypes
object TypeEffectiveness {
val typeEffectivenessMap: Map<ElementalType, Map<ElementalType, Double>> = mapOf(
ElementalTypes.NORMAL to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 1.0,
ElementalTypes.WATER to 1.0,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 1.0,
ElementalTypes.ICE to 1.0,
ElementalTypes.FIGHTING to 1.0,
ElementalTypes.POISON to 1.0,
ElementalTypes.GROUND to 1.0,
ElementalTypes.FLYING to 1.0,
ElementalTypes.PSYCHIC to 1.0,
ElementalTypes.BUG to 1.0,
ElementalTypes.ROCK to 0.5,
ElementalTypes.GHOST to 0.0,
ElementalTypes.DRAGON to 1.0,
ElementalTypes.DARK to 1.0,
ElementalTypes.STEEL to 0.5,
ElementalTypes.FAIRY to 1.0
),
ElementalTypes.FIRE to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 0.5,
ElementalTypes.WATER to 0.5,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 2.0,
ElementalTypes.ICE to 2.0,
ElementalTypes.FIGHTING to 1.0,
ElementalTypes.POISON to 1.0,
ElementalTypes.GROUND to 1.0,
ElementalTypes.FLYING to 1.0,
ElementalTypes.PSYCHIC to 1.0,
ElementalTypes.BUG to 2.0,
ElementalTypes.ROCK to 0.5,
ElementalTypes.GHOST to 1.0,
ElementalTypes.DRAGON to 0.5,
ElementalTypes.DARK to 1.0,
ElementalTypes.STEEL to 2.0,
ElementalTypes.FAIRY to 1.0
),
ElementalTypes.WATER to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 2.0,
ElementalTypes.WATER to 0.5,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 0.5,
ElementalTypes.ICE to 1.0,
ElementalTypes.FIGHTING to 1.0,
ElementalTypes.POISON to 1.0,
ElementalTypes.GROUND to 2.0,
ElementalTypes.FLYING to 1.0,
ElementalTypes.PSYCHIC to 1.0,
ElementalTypes.BUG to 1.0,
ElementalTypes.ROCK to 2.0,
ElementalTypes.GHOST to 1.0,
ElementalTypes.DRAGON to 0.5,
ElementalTypes.DARK to 1.0,
ElementalTypes.STEEL to 1.0,
ElementalTypes.FAIRY to 1.0
),
ElementalTypes.ELECTRIC to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 1.0,
ElementalTypes.WATER to 2.0,
ElementalTypes.ELECTRIC to 0.5,
ElementalTypes.GRASS to 0.5,
ElementalTypes.ICE to 1.0,
ElementalTypes.FIGHTING to 1.0,
ElementalTypes.POISON to 1.0,
ElementalTypes.GROUND to 0.0,
ElementalTypes.FLYING to 2.0,
ElementalTypes.PSYCHIC to 1.0,
ElementalTypes.BUG to 1.0,
ElementalTypes.ROCK to 1.0,
ElementalTypes.GHOST to 1.0,
ElementalTypes.DRAGON to 0.5,
ElementalTypes.DARK to 1.0,
ElementalTypes.STEEL to 1.0,
ElementalTypes.FAIRY to 1.0
),
ElementalTypes.GRASS to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 0.5,
ElementalTypes.WATER to 2.0,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 0.5,
ElementalTypes.ICE to 1.0,
ElementalTypes.FIGHTING to 1.0,
ElementalTypes.POISON to 0.5,
ElementalTypes.GROUND to 2.0,
ElementalTypes.FLYING to 0.5,
ElementalTypes.PSYCHIC to 1.0,
ElementalTypes.BUG to 0.5,
ElementalTypes.ROCK to 2.0,
ElementalTypes.GHOST to 1.0,
ElementalTypes.DRAGON to 0.5,
ElementalTypes.DARK to 1.0,
ElementalTypes.STEEL to 0.5,
ElementalTypes.FAIRY to 1.0
),
ElementalTypes.ICE to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 0.5,
ElementalTypes.WATER to 0.5,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 2.0,
ElementalTypes.ICE to 0.5,
ElementalTypes.FIGHTING to 1.0,
ElementalTypes.POISON to 1.0,
ElementalTypes.GROUND to 2.0,
ElementalTypes.FLYING to 2.0,
ElementalTypes.PSYCHIC to 1.0,
ElementalTypes.BUG to 1.0,
ElementalTypes.ROCK to 1.0,
ElementalTypes.GHOST to 1.0,
ElementalTypes.DRAGON to 2.0,
ElementalTypes.DARK to 1.0,
ElementalTypes.STEEL to 0.5,
ElementalTypes.FAIRY to 1.0
),
ElementalTypes.FIGHTING to mapOf(
ElementalTypes.NORMAL to 2.0,
ElementalTypes.FIRE to 1.0,
ElementalTypes.WATER to 1.0,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 1.0,
ElementalTypes.ICE to 2.0,
ElementalTypes.FIGHTING to 1.0,
ElementalTypes.POISON to 0.5,
ElementalTypes.GROUND to 1.0,
ElementalTypes.FLYING to 0.5,
ElementalTypes.PSYCHIC to 0.5,
ElementalTypes.BUG to 0.5,
ElementalTypes.ROCK to 2.0,
ElementalTypes.GHOST to 0.0,
ElementalTypes.DRAGON to 1.0,
ElementalTypes.DARK to 2.0,
ElementalTypes.STEEL to 2.0,
ElementalTypes.FAIRY to 0.5
),
ElementalTypes.POISON to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 1.0,
ElementalTypes.WATER to 1.0,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 2.0,
ElementalTypes.ICE to 1.0,
ElementalTypes.FIGHTING to 1.0,
ElementalTypes.POISON to 0.5,
ElementalTypes.GROUND to 0.5,
ElementalTypes.FLYING to 1.0,
ElementalTypes.PSYCHIC to 1.0,
ElementalTypes.BUG to 1.0,
ElementalTypes.ROCK to 0.5,
ElementalTypes.GHOST to 0.5,
ElementalTypes.DRAGON to 1.0,
ElementalTypes.DARK to 1.0,
ElementalTypes.STEEL to 0.0,
ElementalTypes.FAIRY to 2.0
),
ElementalTypes.GROUND to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 2.0,
ElementalTypes.WATER to 1.0,
ElementalTypes.ELECTRIC to 2.0,
ElementalTypes.GRASS to 0.5,
ElementalTypes.ICE to 1.0,
ElementalTypes.FIGHTING to 1.0,
ElementalTypes.POISON to 2.0,
ElementalTypes.GROUND to 1.0,
ElementalTypes.FLYING to 0.0,
ElementalTypes.PSYCHIC to 1.0,
ElementalTypes.BUG to 0.5,
ElementalTypes.ROCK to 2.0,
ElementalTypes.GHOST to 1.0,
ElementalTypes.DRAGON to 1.0,
ElementalTypes.DARK to 1.0,
ElementalTypes.STEEL to 2.0,
ElementalTypes.FAIRY to 1.0
),
ElementalTypes.FLYING to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 1.0,
ElementalTypes.WATER to 1.0,
ElementalTypes.ELECTRIC to 0.5,
ElementalTypes.GRASS to 2.0,
ElementalTypes.ICE to 1.0,
ElementalTypes.FIGHTING to 2.0,
ElementalTypes.POISON to 1.0,
ElementalTypes.GROUND to 1.0,
ElementalTypes.FLYING to 1.0,
ElementalTypes.PSYCHIC to 1.0,
ElementalTypes.BUG to 2.0,
ElementalTypes.ROCK to 0.5,
ElementalTypes.GHOST to 1.0,
ElementalTypes.DRAGON to 1.0,
ElementalTypes.DARK to 1.0,
ElementalTypes.STEEL to 0.5,
ElementalTypes.FAIRY to 1.0
),
ElementalTypes.PSYCHIC to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 1.0,
ElementalTypes.WATER to 1.0,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 1.0,
ElementalTypes.ICE to 1.0,
ElementalTypes.FIGHTING to 2.0,
ElementalTypes.POISON to 2.0,
ElementalTypes.GROUND to 1.0,
ElementalTypes.FLYING to 1.0,
ElementalTypes.PSYCHIC to 0.5,
ElementalTypes.BUG to 1.0,
ElementalTypes.ROCK to 1.0,
ElementalTypes.GHOST to 1.0,
ElementalTypes.DRAGON to 1.0,
ElementalTypes.DARK to 0.0,
ElementalTypes.STEEL to 0.5,
ElementalTypes.FAIRY to 1.0
),
ElementalTypes.BUG to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 0.5,
ElementalTypes.WATER to 1.0,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 2.0,
ElementalTypes.ICE to 1.0,
ElementalTypes.FIGHTING to 0.5,
ElementalTypes.POISON to 0.5,
ElementalTypes.GROUND to 1.0,
ElementalTypes.FLYING to 0.5,
ElementalTypes.PSYCHIC to 2.0,
ElementalTypes.BUG to 1.0,
ElementalTypes.ROCK to 1.0,
ElementalTypes.GHOST to 0.5,
ElementalTypes.DRAGON to 1.0,
ElementalTypes.DARK to 2.0,
ElementalTypes.STEEL to 0.5,
ElementalTypes.FAIRY to 0.5
),
ElementalTypes.ROCK to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 2.0,
ElementalTypes.WATER to 1.0,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 1.0,
ElementalTypes.ICE to 2.0,
ElementalTypes.FIGHTING to 0.5,
ElementalTypes.POISON to 1.0,
ElementalTypes.GROUND to 0.5,
ElementalTypes.FLYING to 2.0,
ElementalTypes.PSYCHIC to 1.0,
ElementalTypes.BUG to 2.0,
ElementalTypes.ROCK to 1.0,
ElementalTypes.GHOST to 1.0,
ElementalTypes.DRAGON to 1.0,
ElementalTypes.DARK to 1.0,
ElementalTypes.STEEL to 0.5,
ElementalTypes.FAIRY to 1.0
),
ElementalTypes.GHOST to mapOf(
ElementalTypes.NORMAL to 0.0,
ElementalTypes.FIRE to 1.0,
ElementalTypes.WATER to 1.0,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 1.0,
ElementalTypes.ICE to 1.0,
ElementalTypes.FIGHTING to 1.0,
ElementalTypes.POISON to 1.0,
ElementalTypes.GROUND to 1.0,
ElementalTypes.FLYING to 1.0,
ElementalTypes.PSYCHIC to 2.0,
ElementalTypes.BUG to 1.0,
ElementalTypes.ROCK to 1.0,
ElementalTypes.GHOST to 2.0,
ElementalTypes.DRAGON to 1.0,
ElementalTypes.DARK to 0.5,
ElementalTypes.STEEL to 1.0,
ElementalTypes.FAIRY to 1.0
),
ElementalTypes.DRAGON to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 1.0,
ElementalTypes.WATER to 1.0,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 1.0,
ElementalTypes.ICE to 1.0,
ElementalTypes.FIGHTING to 1.0,
ElementalTypes.POISON to 1.0,
ElementalTypes.GROUND to 1.0,
ElementalTypes.FLYING to 1.0,
ElementalTypes.PSYCHIC to 1.0,
ElementalTypes.BUG to 1.0,
ElementalTypes.ROCK to 1.0,
ElementalTypes.GHOST to 1.0,
ElementalTypes.DRAGON to 2.0,
ElementalTypes.DARK to 1.0,
ElementalTypes.STEEL to 0.5,
ElementalTypes.FAIRY to 0.0
),
ElementalTypes.DARK to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 1.0,
ElementalTypes.WATER to 1.0,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 1.0,
ElementalTypes.ICE to 1.0,
ElementalTypes.FIGHTING to 0.5,
ElementalTypes.POISON to 1.0,
ElementalTypes.GROUND to 1.0,
ElementalTypes.FLYING to 1.0,
ElementalTypes.PSYCHIC to 2.0,
ElementalTypes.BUG to 1.0,
ElementalTypes.ROCK to 1.0,
ElementalTypes.GHOST to 2.0,
ElementalTypes.DRAGON to 1.0,
ElementalTypes.DARK to 0.5,
ElementalTypes.STEEL to 1.0,
ElementalTypes.FAIRY to 0.5
),
ElementalTypes.STEEL to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 0.5,
ElementalTypes.WATER to 0.5,
ElementalTypes.ELECTRIC to 0.5,
ElementalTypes.GRASS to 1.0,
ElementalTypes.ICE to 2.0,
ElementalTypes.FIGHTING to 1.0,
ElementalTypes.POISON to 1.0,
ElementalTypes.GROUND to 1.0,
ElementalTypes.FLYING to 1.0,
ElementalTypes.PSYCHIC to 1.0,
ElementalTypes.BUG to 1.0,
ElementalTypes.ROCK to 2.0,
ElementalTypes.GHOST to 1.0,
ElementalTypes.DRAGON to 1.0,
ElementalTypes.DARK to 1.0,
ElementalTypes.STEEL to 0.5,
ElementalTypes.FAIRY to 2.0
),
ElementalTypes.FAIRY to mapOf(
ElementalTypes.NORMAL to 1.0,
ElementalTypes.FIRE to 0.5,
ElementalTypes.WATER to 1.0,
ElementalTypes.ELECTRIC to 1.0,
ElementalTypes.GRASS to 1.0,
ElementalTypes.ICE to 1.0,
ElementalTypes.FIGHTING to 2.0,
ElementalTypes.POISON to 0.5,
ElementalTypes.GROUND to 1.0,
ElementalTypes.FLYING to 1.0,
ElementalTypes.PSYCHIC to 1.0,
ElementalTypes.BUG to 1.0,
ElementalTypes.ROCK to 1.0,
ElementalTypes.GHOST to 1.0,
ElementalTypes.DRAGON to 2.0,
ElementalTypes.DARK to 2.0,
ElementalTypes.STEEL to 0.5,
ElementalTypes.FAIRY to 1.0
)
)
fun getDamageMultiplier(attackerType: ElementalType, defenderType: ElementalType): Double {
return typeEffectivenessMap[attackerType]?.get(defenderType) ?: 1.0
}
fun calculateTypeEffectiveness(moveType: ElementalType, defenderTypes: List<String>): Double {
var multiplier = 1.0
for (typeString in defenderTypes) {
val defenderType = ElementalTypes.get(typeString.lowercase())
if (defenderType != null) {
multiplier *= getDamageMultiplier(moveType, defenderType)
}
}
return multiplier
}
fun getEffectivenessCategory(effectiveness: Double): EffectivenessCategory {
return when {
effectiveness == 0.0 -> EffectivenessCategory.IMMUNE
effectiveness < 1.0 -> EffectivenessCategory.NOT_VERY_EFFECTIVE
effectiveness == 1.0 -> EffectivenessCategory.NEUTRAL
else -> EffectivenessCategory.SUPER_EFFECTIVE
}
}
enum class EffectivenessCategory {
IMMUNE, NOT_VERY_EFFECTIVE, NEUTRAL, SUPER_EFFECTIVE
}
}
@@ -114,7 +114,14 @@ class ActivateInstruction(val instructionSet: InstructionSet, val message: Battl
}
"maxguard", "protect" -> battleLang("activate.protect", pokemonName)
"shadowforce", "hyperspacefury", "hyperspacehole" -> battleLang("activate.phantomforce", pokemonName)
else -> battleLang("activate.${effect.id}", pokemonName, sourceName, extraEffect)
else -> {
val msgVariant = message.optionalArgument("msg")
if (msgVariant != null) {
battleLang("activate.${effect.id}.$msgVariant", pokemonName, sourceName, extraEffect)
} else {
battleLang("activate.${effect.id}", pokemonName, sourceName, extraEffect)
}
}
}
battle.broadcastChatMessage(lang)
//We check holds here so the chat msg + particle effect happen more concurrently, instead of sequentially
@@ -52,7 +52,7 @@ class FaintInstruction(battle: PokemonBattle, val message: BattleMessage) : Inte
preamble.thenAccept {
faintingPokemon.effectedPokemon.currentHealth = 0
faintingPokemon.sendUpdate()
CobblemonEvents.BATTLE_FAINTED.post(BattleFaintedEvent(battle, pokemon, context))
CobblemonEvents.BATTLE_FAINTED.post(BattleFaintedEvent(battle, pokemon, context, pnx))
battle.getActorAndActiveSlotFromPNX(pnx).second.battlePokemon = null
faintingPokemon.contextManager.add(context)
faintingPokemon.contextManager.clear(BattleContext.Type.STATUS, BattleContext.Type.VOLATILE, BattleContext.Type.BOOST, BattleContext.Type.UNBOOST)
@@ -26,6 +26,7 @@ import com.cobblemon.mod.common.util.battleLang
class FormeChangeInstruction(val message: BattleMessage): InterpreterInstruction {
override fun invoke(battle: PokemonBattle) {
val (pnx, _) = message.pnxAndUuid(0) ?: return
val battlePokemon = message.battlePokemon(0, battle) ?: return
val details = message.argumentAt(1)?.split(',')?.get(0)?.lowercase() ?: return
val speciesName = details.substringBefore('-')
@@ -37,7 +38,7 @@ class FormeChangeInstruction(val message: BattleMessage): InterpreterInstruction
battle.dispatchWaiting {
battle.minorBattleActions[battlePokemon.uuid] = message
CobblemonEvents.FORME_CHANGE.post(FormeChangeEvent(battle, battlePokemon, formName))
CobblemonEvents.FORME_CHANGE.post(FormeChangeEvent(battle, battlePokemon, formName, pnx))
val pokemonName = battlePokemon.getName()
val lang = when(formName) {
"busted", "hero", "complete" -> return@dispatchWaiting
@@ -166,6 +166,11 @@ class SwitchInstruction(val instructionSet: InstructionSet, val battleActor: Bat
// If we can't find the entity for some reason then we're going to skip the recall animation
val sendOutFuture = CompletableFuture<Unit>()
(pokemonEntity?.recallWithAnimation() ?: CompletableFuture.completedFuture(Unit)).thenApply {
if (battle.ended) {
sendOutFuture.complete(Unit)
return@thenApply
}
// Queue actual swap and send-in after the animation has ended
actor.pokemonList.swap(actor.activePokemon.indexOf(activePokemon), actor.pokemonList.indexOf(newPokemon))
activePokemon.battlePokemon = newPokemon
@@ -31,6 +31,7 @@ class WeatherInstruction(val message: BattleMessage): InterpreterInstruction {
val weather = message.effectAt(0)?.id ?: return
val source = message.battlePokemonFromOptional(battle)
source?.let { ShowdownInterpreter.broadcastOptionalAbility(battle, message.effect(), source) }
battle.dispatchWaiting(1.5F) {
val lang = when {
message.hasOptionalArgument("upkeep") -> battleLang("weather.$weather.upkeep")
@@ -43,17 +43,17 @@ class WinInstruction(val message: BattleMessage): InterpreterInstruction {
val losersText = losers.map { it.getName() }.reduce { acc, next -> acc + " & " + next }
val wasCaught = battle.showdownMessages.any { "capture" in it }
battle.dispatch {
// If the battle was a PvW battle, we need to set the killer of the wild Pokémon to the player
if (battle.isPvW) {
val nonPlayerActor = battle.actors.first { it.type == ActorType.WILD }
val wildPokemon: BattlePokemon = nonPlayerActor.pokemonList.first()
// If the battle was a PvW battle, we need to set the killer of the wild Pokémon to the player
if (battle.isPvW) {
val nonPlayerActor = battle.actors.first { it.type == ActorType.WILD }
val wildPokemon: BattlePokemon = nonPlayerActor.pokemonList.first()
if (!wasCaught && losers.any { it.uuid == wildPokemon.uuid }) {
wildPokemon.effectedPokemon.entity?.killer = (battle.actors.firstOrNull { it.type == ActorType.PLAYER } as? PlayerBattleActor)?.entity
}
if (!wasCaught && losers.any { it.uuid == wildPokemon.uuid }) {
wildPokemon.effectedPokemon.entity?.killer = (battle.actors.firstOrNull { it.type == ActorType.PLAYER } as? PlayerBattleActor)?.entity
}
}
battle.dispatch {
// broadcast victory / defeat
if (!wasCaught) {
val blackedOut = battle.isPvW && losers.any { it is PlayerBattleActor }
@@ -36,10 +36,18 @@ import java.util.function.Function
open class BattlePokemon(
val originalPokemon: Pokemon,
val effectedPokemon: Pokemon = originalPokemon,
val postBattleEntityOperation: (PokemonEntity) -> Unit = {}
var postBattlePokemonOperations: MutableList<(BattlePokemon) -> Unit> = mutableListOf(),
var postBattleEntityOperations: MutableList<(PokemonEntity) -> Unit> = mutableListOf()
) {
lateinit var actor: BattleActor
constructor(originalPokemon: Pokemon, effectedPokemon: Pokemon, postBattleEntityOperation: (PokemonEntity) -> Unit) : this(
originalPokemon = originalPokemon,
effectedPokemon = effectedPokemon,
postBattlePokemonOperations = mutableListOf<(BattlePokemon) -> Unit>(),
postBattleEntityOperations = mutableListOf(postBattleEntityOperation)
)
companion object {
fun safeCopyOf(pokemon: Pokemon): BattlePokemon {
//TOOD figure out a closer registry access (might have to break some method signatures for this (1.7?)
@@ -19,6 +19,7 @@ import net.minecraft.world.InteractionResult
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.BlockItem
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.Level
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.block.BaseEntityBlock
@@ -110,6 +111,8 @@ class DisplayCaseBlock(settings: Properties) : BaseEntityBlock(settings) {
override fun getRenderShape(state: BlockState) = RenderShape.MODEL
override fun getShadeBrightness(state: BlockState, level: BlockGetter, pos: BlockPos): Float = 0.75F
override fun getAnalogOutputSignal(state: BlockState, world: Level, pos: BlockPos): Int {
val stack = (world.getBlockEntity(pos) as DisplayCaseBlockEntity).getStack()
@@ -29,6 +29,7 @@ import net.minecraft.world.level.block.SoundType
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockStateProperties
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf
import net.minecraft.world.level.block.state.properties.EnumProperty
import net.minecraft.world.level.block.state.properties.IntegerProperty
@@ -43,7 +44,6 @@ class HeartyGrainsBlock(settings: Properties) : CropBlock(settings), SimpleWater
val CODEC = simpleCodec(::HeartyGrainsBlock)
const val MATURE_AGE = 6
const val AGE_AFTER_HARVEST = 3 // Last single block stage
val WATERLOGGED = BlockStateProperties.WATERLOGGED
val AGE: IntegerProperty = IntegerProperty.create("age", 0, MATURE_AGE)
val HALF: EnumProperty<DoubleBlockHalf> = BlockStateProperties.DOUBLE_BLOCK_HALF
@@ -21,6 +21,7 @@ import com.cobblemon.mod.common.util.isInBattle
import com.cobblemon.mod.common.util.playSoundServer
import com.cobblemon.mod.common.util.toVec3d
import com.cobblemon.mod.common.util.voxelShape
import com.cobblemon.mod.common.util.rotateShape
import com.mojang.serialization.MapCodec
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
@@ -71,10 +72,10 @@ class PastureBlock(settings: Properties): BaseEntityBlock(settings), SimpleWater
private val WEST_AABB_TOP = buildCollider(top = true, Direction.WEST)
private val EAST_AABB_TOP = buildCollider(top = true, Direction.EAST)
private val SOUTH_AABB_BOTTOM = buildCollider(top = false, Direction.SOUTH)
private val NORTH_AABB_BOTTOM = buildCollider(top = false, Direction.NORTH)
private val WEST_AABB_BOTTOM = buildCollider(top = false, Direction.WEST)
private val EAST_AABB_BOTTOM = buildCollider(top = false, Direction.EAST)
private val SOUTH_AABB_BOTTOM = rotateShape(Direction.EAST, Direction.SOUTH, EAST_AABB_BOTTOM)
private val NORTH_AABB_BOTTOM = rotateShape(Direction.EAST, Direction.NORTH, EAST_AABB_BOTTOM)
private val WEST_AABB_BOTTOM = rotateShape(Direction.EAST, Direction.WEST, EAST_AABB_BOTTOM)
private fun buildCollider(top: Boolean, direction: Direction): VoxelShape {
if (top) {
@@ -0,0 +1,128 @@
/*
* Copyright (C) 2023 Cobblemon Contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.common.block
import com.cobblemon.mod.common.util.rotateShape
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.LevelReader
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.Blocks
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock
import net.minecraft.world.level.block.SimpleWaterloggedBlock
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.AttachFace
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.level.material.Fluids
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
class PlaqueBlock(properties : Properties) : FaceAttachedHorizontalDirectionalBlock(properties), SimpleWaterloggedBlock {
companion object {
val CODEC: MapCodec<PlaqueBlock> = RecordCodecBuilder.mapCodec {
it.group(propertiesCodec()).apply(it, ::PlaqueBlock)
}
val FLOOR_NORTH = Shapes.or(
Shapes.box(0.0625, 0.25, 0.4375, 0.9375, 1.0, 0.5625),
Shapes.box(0.125, 0.0, 0.4375, 0.25, 0.25, 0.5625),
Shapes.box(0.75, 0.0, 0.4375, 0.875, 0.25, 0.5625),
)
val WALL_NORTH = Shapes.box(0.0625, 0.125, 0.9375, 0.9375, 0.875, 1.0)
val CEILING_NORTH = Shapes.box(0.0625, 0.0, 0.4375, 0.9375, 0.75, 0.5625)
}
init {
registerDefaultState(stateDefinition.any()
.setValue(FACING, Direction.NORTH)
.setValue(FACE, AttachFace.WALL)
.setValue(WATERLOGGED, false)
)
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(FACING, FACE, WATERLOGGED)
}
override fun getFluidState(blockState: BlockState): FluidState? {
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState);
}
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
val fluidState = context.level.getFluidState(context.clickedPos)
for (direction in context.nearestLookingDirections) {
val blockState: BlockState
if (direction.getAxis() === Direction.Axis.Y) {
blockState = (defaultBlockState()
.setValue(FACE, if (direction == Direction.UP) AttachFace.CEILING else AttachFace.FLOOR) as BlockState)
.setValue(FACING, context.horizontalDirection.opposite)
.setValue(WATERLOGGED, fluidState.type === Fluids.WATER
) as BlockState
} else {
blockState = (defaultBlockState()
.setValue(FACE, AttachFace.WALL) as BlockState)
.setValue(FACING, direction.opposite)
.setValue(WATERLOGGED, fluidState.type === Fluids.WATER
) as BlockState
}
if (blockState.canSurvive(context.getLevel(), context.getClickedPos())) {
return blockState
}
}
return null
}
override fun codec(): MapCodec<PlaqueBlock> = CODEC
override fun getShape(state: BlockState, blockGetter: BlockGetter, pos: BlockPos, collisionContext: CollisionContext): VoxelShape {
val direction = state.getValue(FACING)
return when (state.getValue(FACE)) {
AttachFace.FLOOR ->
if (direction.axis === Direction.Axis.X) {
rotateShape(Direction.NORTH, Direction.WEST, FLOOR_NORTH)
} else FLOOR_NORTH
AttachFace.WALL ->
when (direction) {
Direction.NORTH, Direction.UP, Direction.DOWN -> WALL_NORTH
else -> rotateShape(Direction.NORTH, direction, WALL_NORTH)
}
AttachFace.CEILING ->
if (direction.axis === Direction.Axis.X) {
rotateShape(Direction.NORTH, Direction.WEST, CEILING_NORTH)
} else CEILING_NORTH
}
}
override fun updateShape(state: BlockState, direction: Direction, neighborState: BlockState, world: LevelAccessor, pos: BlockPos, neighborPos: BlockPos): BlockState {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
}
return if (getConnectedDirection(state).opposite == direction && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
}
override fun canSurvive(state: BlockState, level: LevelReader, pos: BlockPos): Boolean {
return if (state.getValue(FACE) == AttachFace.CEILING) {
val direction = getConnectedDirection(state)
canSupportCenter(level, pos.relative(direction.opposite), direction)
} else {
super.canSurvive(state, level, pos)
}
}
}
@@ -0,0 +1,189 @@
/*
* Copyright (C) 2023 Cobblemon Contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.common.block
import com.cobblemon.mod.common.util.rotateShape
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.util.StringRepresentable
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.HorizontalDirectionalBlock
import net.minecraft.world.level.block.SimpleWaterloggedBlock
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.block.state.properties.IntegerProperty
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
import kotlin.math.min
class StackableItemBlock(settings: Properties, val type: StackableItemBlockType): HorizontalDirectionalBlock(settings), SimpleWaterloggedBlock {
enum class StackableItemBlockType: StringRepresentable {
BATTLE_ITEM,
ETHER,
MAX_POTION,
POTION,
STATUS_RESTORE;
override fun getSerializedName(): String = this.name.lowercase()
companion object {
val CODEC = StringRepresentable.fromEnum(::values)
}
}
companion object {
val MAX_AMOUNT: Int = 8
val AMOUNT: IntegerProperty = IntegerProperty.create("amount", 1, MAX_AMOUNT)
val CODEC: MapCodec<StackableItemBlock> = RecordCodecBuilder.mapCodec { it.group(
propertiesCodec(),
StackableItemBlockType.CODEC.fieldOf("type").forGetter(StackableItemBlock::type)
).apply(it, ::StackableItemBlock) }
val northShapeMap: Map<StackableItemBlockType, List<VoxelShape>> = mapOf(
StackableItemBlockType.BATTLE_ITEM to listOf(
Shapes.box(0.34375, 0.0, 0.34375, 0.65625, 0.4375, 0.65625),
Shapes.or(
Shapes.box(0.09375, 0.0, 0.34375, 0.40625, 0.4375, 0.65625),
Shapes.box(0.59375, 0.0, 0.40625, 0.90625, 0.4375, 0.71875)
),
Shapes.or(
Shapes.box(0.59375, 0.0, 0.59375, 0.90625, 0.4375, 0.90625),
Shapes.box(0.09375, 0.0, 0.53125, 0.40625, 0.4375, 0.84375),
Shapes.box(0.34375, 0.0, 0.09375, 0.65625, 0.4375, 0.40625)
),
Shapes.or(
Shapes.box(0.09375, 0.0, 0.09375, 0.40625, 0.4375, 0.40625),
Shapes.box(0.59375, 0.0, 0.15625, 0.90625, 0.4375, 0.46875),
Shapes.box(0.65625, 0.0, 0.59375, 0.96875, 0.4375, 0.90625),
Shapes.box(0.15625, 0.0, 0.53125, 0.46875, 0.4375, 0.84375)
)
),
StackableItemBlockType.ETHER to listOf(
Shapes.box(0.375, 0.0, 0.3125, 0.625, 0.5, 0.6875),
Shapes.or(
Shapes.box(0.625, 0.0, 0.375, 0.875, 0.5, 0.75),
Shapes.box(0.125, 0.0, 0.3125, 0.375, 0.5, 0.6875)
),
Shapes.or(
Shapes.box(0.375, 0.0, 0.125, 0.625, 0.5, 0.5),
Shapes.box(0.125, 0.0, 0.5625, 0.375, 0.5, 0.9375),
Shapes.box(0.625, 0.0, 0.625, 0.875, 0.5, 1.0)
),
Shapes.or(
Shapes.box(0.125, 0.0, 0.0625, 0.375, 0.5, 0.4375),
Shapes.box(0.625, 0.0, 0.125, 0.875, 0.5, 0.5),
Shapes.box(0.6875, 0.0, 0.625, 0.9375, 0.5, 1.0),
Shapes.box(0.1875, 0.0, 0.5625, 0.4375, 0.5, 0.9375)
)
),
StackableItemBlockType.MAX_POTION to listOf(
Shapes.box(0.34375, 0.0, 0.3125, 0.65625, 0.5, 0.6875),
Shapes.or(
Shapes.box(0.09375, 0.0, 0.3125, 0.40625, 0.5, 0.6875),
Shapes.box(0.59375, 0.0, 0.375, 0.90625, 0.5, 0.75)
),
Shapes.or(
Shapes.box(0.34375, 0.0, 0.0625, 0.65625, 0.5, 0.4375),
Shapes.box(0.09375, 0.0, 0.5625, 0.40625, 0.5, 0.9375),
Shapes.box(0.59375, 0.0, 0.625, 0.90625, 0.5, 1.0)
),
Shapes.or(
Shapes.box(0.09375, 0.0, 0.0625, 0.40625, 0.5, 0.4375),
Shapes.box(0.15625, 0.0, 0.5625, 0.46875, 0.5, 0.9375),
Shapes.box(0.65625, 0.0, 0.625, 0.96875, 0.5, 1.0),
Shapes.box(0.59375, 0.0, 0.125, 0.90625, 0.5, 0.5)
).singleEncompassing()
),
StackableItemBlockType.POTION to listOf(
Shapes.box(0.375, 0.0, 0.3125, 0.625, 0.5625, 0.75),
Shapes.or(
Shapes.box(0.125, 0.0, 0.3125, 0.375, 0.5625, 0.75),
Shapes.box(0.625, 0.0, 0.375, 0.875, 0.5625, 0.8125)
),
Shapes.or(
Shapes.box(0.375, 0.0, 0.0625, 0.625, 0.5625, 0.5),
Shapes.box(0.625, 0.0, 0.5625, 0.875, 0.5625, 1.0),
Shapes.box(0.125, 0.0, 0.5, 0.375, 0.5625, 0.9375)
),
Shapes.or(
Shapes.box(0.125, 0.0, 0.0, 0.375, 0.5625, 0.4375),
Shapes.box(0.625, 0.0, 0.0625, 0.875, 0.5625, 0.5),
Shapes.box(0.6875, 0.0, 0.5625, 0.9375, 0.5625, 1.0),
Shapes.box(0.1875, 0.0, 0.5, 0.4375, 0.5625, 0.9375)
)
),
StackableItemBlockType.STATUS_RESTORE to listOf(
Shapes.box(0.375, 0.0, 0.3125, 0.625, 0.4375, 0.6875),
Shapes.or(
Shapes.box(0.125, 0.0, 0.3125, 0.375, 0.4375, 0.75),
Shapes.box(0.625, 0.0, 0.375, 0.875, 0.4375, 0.75)
),
Shapes.or(
Shapes.box(0.125, 0.0, 0.5, 0.375, 0.4375, 0.875),
Shapes.box(0.625, 0.0, 0.5625, 0.875, 0.4375, 0.9375),
Shapes.box(0.375, 0.0, 0.0625, 0.625, 0.4375, 0.4375)
),
Shapes.or(
Shapes.box(0.1875, 0.0, 0.5, 0.4375, 0.4375, 0.875),
Shapes.box(0.125, 0.0, 0.0, 0.375, 0.4375, 0.375),
Shapes.box(0.625, 0.0, 0.0625, 0.875, 0.4375, 0.4375),
Shapes.box(0.6875, 0.0, 0.5625, 0.9375, 0.4375, 0.9375)
)
)
)
fun getShape(type: StackableItemBlockType, count: Int): VoxelShape = northShapeMap[type]?.let { list -> list[(count - 1).coerceIn(0, list.lastIndex)] } ?: Shapes.block()
fun getMaxAmount(type: StackableItemBlockType): Int = min(northShapeMap[type]?.size ?: 1 , MAX_AMOUNT)
}
init {
registerDefaultState(stateDefinition.any()
.setValue(HORIZONTAL_FACING, Direction.NORTH)
.setValue(AMOUNT, 1)
.setValue(WATERLOGGED, false))
}
override fun codec(): MapCodec<StackableItemBlock> = CODEC
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(HORIZONTAL_FACING, AMOUNT, WATERLOGGED)
}
override fun getCollisionShape(state: BlockState, level: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape {
val direction = state.getValue(HORIZONTAL_FACING)
val count = state.getValue(AMOUNT)
return rotateShape(Direction.NORTH, direction, getShape(type, count))
}
override fun getShape(state: BlockState, level: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape {
return getCollisionShape(state, level, pos, context).singleEncompassing()
}
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
val blockState = context.level.getBlockState(context.clickedPos)
return if (blockState.`is`(this)) blockState.setValue(AMOUNT, min(getMaxAmount(type), (blockState.getValue(AMOUNT) + 1)))
else super.getStateForPlacement(context)?.setValue(HORIZONTAL_FACING, context.horizontalDirection.opposite)
}
override fun canBeReplaced(state: BlockState, useContext: BlockPlaceContext): Boolean {
return if (
!useContext.isSecondaryUseActive
&& useContext.itemInHand.`is`(this.asItem())
&& state.getValue(AMOUNT) <= getMaxAmount(type)
) true else super.canBeReplaced(state, useContext)
}
}
@@ -0,0 +1,81 @@
/*
* Copyright (C) 2023 Cobblemon Contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.common.block
import com.mojang.serialization.MapCodec
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.LevelReader
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.Blocks
import net.minecraft.world.level.block.HorizontalDirectionalBlock
import net.minecraft.world.level.block.SimpleWaterloggedBlock
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.level.material.Fluids
open class WallAttachedDirectionalBlock(settings: Properties): HorizontalDirectionalBlock(settings), SimpleWaterloggedBlock {
companion object {
val CODEC = simpleCodec(::WallAttachedDirectionalBlock)
}
init {
registerDefaultState(stateDefinition.any()
.setValue(HORIZONTAL_FACING, Direction.NORTH)
.setValue(WATERLOGGED, false))
}
override fun codec(): MapCodec<out WallAttachedDirectionalBlock> = CODEC
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(HORIZONTAL_FACING, WATERLOGGED)
}
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
var direction = context.clickedFace
if (direction === null || direction.axis === Direction.Axis.Y) {
direction = context.horizontalDirection.opposite
}
val fluidState = context.level.getFluidState(context.clickedPos)
val blockState = this.defaultBlockState()
.setValue(HORIZONTAL_FACING, direction)
.setValue(WATERLOGGED, fluidState.type === Fluids.WATER
) as BlockState
if (blockState.canSurvive(context.getLevel(), context.getClickedPos())) {
return blockState
}
return null
}
override fun getFluidState(blockState: BlockState): FluidState? = if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState)
override fun updateShape(state: BlockState, direction: Direction, neighborState: BlockState, world: LevelAccessor, pos: BlockPos, neighborPos: BlockPos): BlockState {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
}
return if (state.getValue(HORIZONTAL_FACING).opposite == direction && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
}
override fun canSurvive(state: BlockState, level: LevelReader, pos: BlockPos): Boolean {
return canAttach(level, pos, state.getValue(HORIZONTAL_FACING))
}
fun canAttach(reader: LevelReader, pos: BlockPos, direction: Direction): Boolean {
val blockPos = pos.relative(direction.opposite)
return reader.getBlockState(blockPos).isFaceSturdy(reader, blockPos, direction)
}
}
@@ -0,0 +1,68 @@
/*
* Copyright (C) 2023 Cobblemon Contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.common.block
import com.cobblemon.mod.common.util.rotateShape
import com.mojang.serialization.Codec
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
class WallAttachedDirectionalShapeBlock(settings: Properties, val width: Int = 16, val height: Int = 16, val depth: Int = 16): WallAttachedDirectionalBlock(settings) {
companion object {
/**
* Calculates a [VoxelShape] based on a center point of (8, 8, 16).
*
* The resulting shape is centered X horizontally and Y vertically
* expanding inwards/North along the Z-axis from the South face (16).
*
* @param width The width of the shape from 0-16, along the X-axis.
* @param height The height of the shape from 0-16 along the Y-axis.
* @param depth The depth of the shape from 0-16 along the Z-axis, extending inwards from 16.
* @return A VoxelShape.
*/
fun convertToShape(sizeX: Int, sizeY: Int, sizeZ: Int): VoxelShape {
val x = sizeX.coerceIn(0, 16).toDouble()
val y = sizeY.coerceIn(0, 16).toDouble()
val z = sizeZ.coerceIn(0, 16).toDouble()
val minX = (8.0 - (x / 2.0)) / 16.0
val maxX = (8.0 + (x / 2.0)) / 16.0
val minY = (8.0 - (y / 2.0)) / 16.0
val maxY = (8.0 + (y / 2.0)) / 16.0
val minZ = (16.0 - z) / 16.0
return Shapes.box(minX, minY, minZ, maxX, maxY, 1.0)
}
}
override fun codec(): MapCodec<WallAttachedDirectionalShapeBlock> = RecordCodecBuilder.mapCodec { instance ->
instance.group(
propertiesCodec(),
Codec.INT.fieldOf("width").forGetter { it.width },
Codec.INT.fieldOf("height").forGetter { it.height },
Codec.INT.fieldOf("depth").forGetter { it.depth }
).apply(instance, { properties, width, height, depth ->
WallAttachedDirectionalShapeBlock(properties, width, height, depth)
})
}
override fun getShape(state: BlockState, level: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape {
val direction = state.getValue(FACING)
return rotateShape(Direction.NORTH, direction, convertToShape(width, height, depth))
}
}
@@ -0,0 +1,98 @@
/*
* Copyright (C) 2023 Cobblemon Contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.common.block
import com.cobblemon.mod.common.block.StackableItemBlock.Companion.AMOUNT
import com.cobblemon.mod.common.block.StackableItemBlock.Companion.MAX_AMOUNT
import com.cobblemon.mod.common.util.rotateShape
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.util.StringRepresentable
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
import kotlin.math.min
class WallAttachedStackableItemBlock(settings: Properties, val type: WallStackableItemBlockType): WallAttachedDirectionalBlock(settings) {
enum class WallStackableItemBlockType: StringRepresentable {
TAG;
override fun getSerializedName(): String = this.name.lowercase()
companion object {
val CODEC = StringRepresentable.fromEnum(::values)
}
}
companion object {
val CODEC: MapCodec<WallAttachedStackableItemBlock> = RecordCodecBuilder.mapCodec { it.group(
propertiesCodec(),
WallStackableItemBlockType.CODEC.fieldOf("type").forGetter(WallAttachedStackableItemBlock::type)
).apply(it, ::WallAttachedStackableItemBlock) }
val northShapeMap: Map<WallStackableItemBlockType, List<VoxelShape>> = mapOf(
WallStackableItemBlockType.TAG to listOf(
Shapes.box(0.375, 0.25, 0.9375, 0.625, 0.6875, 1.0),
Shapes.box(0.375, 0.0625, 0.9375, 1.0, 0.6875, 1.0),
Shapes.box(0.0, 0.0625, 0.9375, 1.0, 0.9375, 1.0),
Shapes.box(0.0, 0.0625, 0.9375, 1.0, 1.0, 1.0),
Shapes.box(0.0, 0.0, 0.9375, 1.0, 1.0, 1.0),
Shapes.box(0.0, 0.0, 0.9375, 1.0, 1.0, 1.0),
Shapes.box(0.0, 0.0, 0.9375, 1.0, 1.0, 1.0),
Shapes.box(0.0, 0.0, 0.9375, 1.0, 1.0, 1.0)
)
)
fun getShape(type: WallStackableItemBlockType, count: Int): VoxelShape = northShapeMap[type]?.let { list -> list[(count - 1).coerceIn(0, list.lastIndex)] } ?: Shapes.block()
fun getMaxAmount(type: WallStackableItemBlockType): Int = min(northShapeMap[type]?.size ?: 1 , MAX_AMOUNT)
}
init {
registerDefaultState(stateDefinition.any()
.setValue(HORIZONTAL_FACING, Direction.NORTH)
.setValue(AMOUNT, 1)
.setValue(WATERLOGGED, false))
}
override fun codec(): MapCodec<WallAttachedStackableItemBlock> = CODEC
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
super.createBlockStateDefinition(builder)
builder.add(AMOUNT)
}
override fun getShape(state: BlockState, level: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape {
val direction = state.getValue(HORIZONTAL_FACING)
val count = state.getValue(AMOUNT)
return rotateShape(Direction.NORTH, direction, getShape(type, count))
}
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
val blockState = context.level.getBlockState(context.clickedPos)
return if (blockState.`is`(this)) blockState.setValue(AMOUNT, min(getMaxAmount(type), (blockState.getValue(AMOUNT) + 1)))
else super.getStateForPlacement(context)
}
override fun canBeReplaced(state: BlockState, useContext: BlockPlaceContext): Boolean {
return if (
!useContext.isSecondaryUseActive
&& useContext.itemInHand.`is`(this.asItem())
&& state.getValue(AMOUNT) <= getMaxAmount(type)
) true else super.canBeReplaced(state, useContext)
}
}
@@ -17,7 +17,6 @@ import com.cobblemon.mod.common.api.pasture.PastureLinkManager
import com.cobblemon.mod.common.api.scheduling.afterOnServer
import com.cobblemon.mod.common.api.text.italicise
import com.cobblemon.mod.common.api.text.red
import com.cobblemon.mod.common.api.text.textClickHandlers
import com.cobblemon.mod.common.block.PastureBlock
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.net.messages.client.effect.SpawnSnowstormEntityParticlePacket
@@ -110,10 +109,10 @@ class PokemonPastureBlockEntity(pos: BlockPos, state: BlockState) :
for (tetheredPokemon in tetheredPokemonList) {
val pokemon = tetheredPokemon.getPokemon()!!
if (pokemon.currentFullness > 0) {
pokemon.tickMetabolism()
pokemon.tickMetabolism(1)
}
if (pokemon.interactionCooldowns.any()) {
pokemon.tickInteractionCooldown()
pokemon.tickInteractionCooldown(1)
}
}
blockEntity.togglePastureOn(blockEntity.getInRangeViewerCount(world, blockEntity.blockPos) > 0)
@@ -319,7 +319,48 @@ object CobblemonClient {
CobblemonBlocks.PINK_CAMPFIRE_POT,
CobblemonBlocks.RED_CAMPFIRE_POT,
CobblemonBlocks.WHITE_CAMPFIRE_POT,
CobblemonBlocks.YELLOW_CAMPFIRE_POT
CobblemonBlocks.YELLOW_CAMPFIRE_POT,
CobblemonBlocks.WHITE_PLAQUE,
CobblemonBlocks.LIGHT_GRAY_PLAQUE,
CobblemonBlocks.GRAY_PLAQUE,
CobblemonBlocks.BLACK_PLAQUE,
CobblemonBlocks.BROWN_PLAQUE,
CobblemonBlocks.RED_PLAQUE,
CobblemonBlocks.ORANGE_PLAQUE,
CobblemonBlocks.YELLOW_PLAQUE,
CobblemonBlocks.LIME_PLAQUE,
CobblemonBlocks.GREEN_PLAQUE,
CobblemonBlocks.CYAN_PLAQUE,
CobblemonBlocks.LIGHT_BLUE_PLAQUE,
CobblemonBlocks.BLUE_PLAQUE,
CobblemonBlocks.PURPLE_PLAQUE,
CobblemonBlocks.MAGENTA_PLAQUE,
CobblemonBlocks.PINK_PLAQUE,
CobblemonBlocks.BLUNDER_POLICY,
CobblemonBlocks.WEAKNESS_POLICY,
CobblemonBlocks.POTION,
CobblemonBlocks.SUPER_POTION,
CobblemonBlocks.HYPER_POTION,
CobblemonBlocks.MAX_POTION,
CobblemonBlocks.FULL_RESTORE,
CobblemonBlocks.ANTIDOTE,
CobblemonBlocks.AWAKENING,
CobblemonBlocks.BURN_HEAL,
CobblemonBlocks.ICE_HEAL,
CobblemonBlocks.PARALYZE_HEAL,
CobblemonBlocks.FULL_HEAL,
CobblemonBlocks.ETHER,
CobblemonBlocks.MAX_ETHER,
CobblemonBlocks.ELIXIR,
CobblemonBlocks.MAX_ELIXIR,
CobblemonBlocks.DIRE_HIT,
CobblemonBlocks.GUARD_SPEC,
CobblemonBlocks.X_ACCURACY,
CobblemonBlocks.X_ATTACK,
CobblemonBlocks.X_DEFENSE,
CobblemonBlocks.X_SP_ATK,
CobblemonBlocks.X_SP_DEF,
CobblemonBlocks.X_SPEED
)
this.createBoatModelLayers()
@@ -11,10 +11,11 @@ package com.cobblemon.mod.common.client.battle
import com.cobblemon.mod.common.CobblemonNetwork
import com.cobblemon.mod.common.api.battles.model.actor.ActorType
import com.cobblemon.mod.common.api.pokedex.PokedexEntryProgress
import com.cobblemon.mod.common.api.pokemon.PokemonSpecies
import com.cobblemon.mod.common.battles.BattleFormat
import com.cobblemon.mod.common.battles.ForcePassActionResponse
import com.cobblemon.mod.common.battles.MoveActionResponse
import com.cobblemon.mod.common.battles.PassActionResponse
import com.cobblemon.mod.common.battles.ShowdownMoveset
import com.cobblemon.mod.common.client.CobblemonClient
import com.cobblemon.mod.common.net.messages.server.battle.BattleSelectActionsPacket
import com.cobblemon.mod.common.util.asIdentifierDefaultingNamespace
@@ -61,8 +62,15 @@ class ClientBattle(
if (index != -1) {
while(index < pendingActionRequests.size) {
val request = pendingActionRequests[index]
if (request.response != PassActionResponse && request.response !is ForcePassActionResponse)
if (request.response != PassActionResponse && request.response !is ForcePassActionResponse) {
val response = request.response
// If we're cancelling a turn that used a gimmick, we re-enable the ability for that gimmick to be used.
if (response is MoveActionResponse && response.gimmickID != null) {
val gimmick = ShowdownMoveset.Gimmick.entries.find { it.id == response.gimmickID }
pendingActionRequests.forEach { it.moveSet?.pendingGimmickUsedThisTurn?.remove(gimmick) }
}
request.response = null
}
index++
}
}
@@ -68,7 +68,7 @@ class BattleMoveSelection(
var moveTiles = baseTiles
val backButton = BattleBackButton(x - 11F, Minecraft.getInstance().window.guiScaledHeight - 22F)
val gimmickButtons = moveSet.getGimmicks().mapIndexed { index, gimmick ->
val gimmickButtons = moveSet.getGimmicks().filter { it !in moveSet.pendingGimmickUsedThisTurn }.mapIndexed { index, gimmick ->
val initOff = BattleBackButton.WIDTH * 0.65F
val xOff = initOff + BattleGimmickButton.SPACING * index
BattleGimmickButton.create(gimmick, this, backButton.x + xOff, backButton.y)
@@ -17,6 +17,7 @@ import com.cobblemon.mod.common.api.text.text
import com.cobblemon.mod.common.battles.InBattleGimmickMove
import com.cobblemon.mod.common.battles.InBattleMove
import com.cobblemon.mod.common.battles.MoveActionResponse
import com.cobblemon.mod.common.battles.ShowdownMoveset
import com.cobblemon.mod.common.client.CobblemonClient
import com.cobblemon.mod.common.client.CobblemonResources
import com.cobblemon.mod.common.client.battle.ActiveClientBattlePokemon
@@ -127,7 +128,7 @@ class BattleTargetSelection(
private val isMultiTarget = multiTargetList?.firstOrNull { it.getPNX() == target.getPNX() } != null
private val isCurrentPokemon = request.activePokemon.battlePokemon?.uuid == target.battlePokemon!!.uuid
open val response: MoveActionResponse get() = MoveActionResponse(targetSelection.move.id, responseTarget)
open val response: MoveActionResponse get() = MoveActionResponse(targetSelection.move.id, responseTarget, gimmickID)
val state = FloatingState()
open val selectable: Boolean get() = isMultiTarget || (responseTarget != null)
@@ -311,6 +312,13 @@ class BattleTargetSelection(
fun onClick() {
if (!selectable) return
targetSelection.playDownSound(Minecraft.getInstance().soundManager)
// If a gimmick is used, remove the ability to use it on any pending action requests ahead of it
if (response.gimmickID != null) {
val gimmick = ShowdownMoveset.Gimmick.entries.first { it.id == response.gimmickID }
CobblemonClient.battle?.pendingActionRequests?.forEach {
it.moveSet?.pendingGimmickUsedThisTurn?.add(gimmick)
}
}
targetSelection.battleGUI.selectAction(targetSelection.request, response)
}
}
@@ -23,7 +23,7 @@ import net.minecraft.world.phys.Vec3
object CalculateSeatPositionsHandler : ClientNetworkPacketHandler<CalculateSeatPositionsPacket> {
private const val FORMAT = "%.2f"
private const val SEAT_PREFIX = "seat"
private const val SEAT_PREFIX = "seat_"
private const val SIMULATION_PERIOD_TICKS = 15 * 20F
class SeatRanges(
@@ -160,6 +160,7 @@ class DisplayCaseRenderer(ctx: BlockEntityRendererProvider.Context) : BlockEntit
stack.item is BedItem -> PositioningType.BED
stack.item is BannerItem -> PositioningType.BANNER
stack.`is`(CobblemonItemTags.POKE_BALLS) -> PositioningType.POKE_BALL
stack.`is`(CobblemonItemTags.PLAQUES) -> PositioningType.ITEM_MODEL
stack.item is PokedexItem -> PositioningType.POKEDEX
stack.item == CobblemonItems.RELIC_COIN_POUCH -> PositioningType.COIN_POUCH
stack.item == CobblemonItems.PASTURE -> PositioningType.PASTURE
@@ -39,7 +39,11 @@ class PoseAdapter(
override fun deserialize(json: JsonElement, type: Type, ctx: JsonDeserializationContext): Pose {
val model = modelFinder()
val obj = json as JsonObject
val pose = JsonPose(model, obj)
val pose = try {
JsonPose(model, obj)
} catch (e: Exception) {
throw IllegalArgumentException("Failed to deserialize pose from JSON: $json", e)
}
val conditionsList = mutableListOf<(PosableState) -> Boolean>()
@@ -100,4 +104,4 @@ class PoseAdapter(
)
}
}
}
}
@@ -206,7 +206,7 @@ fun generateAdditionalRideBoostsTooltip(stack: ItemStack): MutableList<Component
val resultLines = mutableListOf<Component>()
resultLines.add(rideBoostSeasoningHeader)
for ((stat, value) in boosts) {
for ((stat, value) in boosts.toSortedMap()) {
val statName = stat.displayName.also { it.style = it.style.withColor(stat.flavour.colour) }
val valueText = if (value < 0) {
Component.literal("$value").red()
@@ -14,7 +14,6 @@ import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.api.battles.model.actor.EntityBackedBattleActor
import com.cobblemon.mod.common.api.net.NetworkPacket
import com.cobblemon.mod.common.api.storage.party.PartyStore
import com.cobblemon.mod.common.battles.ai.CompetitiveBattleAI
import com.cobblemon.mod.common.battles.ai.StrongBattleAI
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.net.messages.client.battle.BattleEndPacket
@@ -31,7 +30,7 @@ class NPCBattleActor(
) : AIBattleActor(
gameId = npc.uuid,
pokemonList = pokemonList.let { if (npc.npc.randomizePartyOrder) it.shuffled() else it },
battleAI = CompetitiveBattleAI(skill)
battleAI = StrongBattleAI(skill)
), EntityBackedBattleActor<NPCEntity> {
override val entity = npc
override val type = ActorType.NPC
@@ -78,6 +78,7 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.server.level.ServerEntity
import net.minecraft.server.level.ServerLevel
import net.minecraft.server.level.ServerPlayer
import net.minecraft.tags.DamageTypeTags.BYPASSES_INVULNERABILITY
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult
import net.minecraft.world.damagesource.DamageSource
@@ -604,7 +605,7 @@ class NPCEntity(world: Level) : AgeableMob(CobblemonEntities.NPC, world), Posabl
}
override fun isPushable() = isMovable ?: npc.isMovable
override fun isInvulnerableTo(source: DamageSource) = isInvulnerable ?: npc.isInvulnerable
override fun isInvulnerableTo(source: DamageSource) = (isInvulnerable ?: npc.isInvulnerable) && !source.`is`(BYPASSES_INVULNERABILITY)
override fun canBeLeashed() = isLeashable ?: npc.isLeashable
override fun canBeHitByProjectile() = allowProjectileHits ?: npc.allowProjectileHits
@@ -14,7 +14,7 @@ import juuxel.adorn.block.variant.CompatBlockVariantSet
class AdornCompatibility : CompatBlockVariantSet() {
override fun getWoodVariants(): List<BlockVariant?>? {
return this.createVariants({ BlockVariant.Wood(it) }, "apricorn")
return this.createVariants({ BlockVariant.Wood(it) }, "apricorn", "saccharine")
}
override fun getModId(): String? {
@@ -13,6 +13,7 @@ import com.cobblemon.mod.common.advancement.criterion.PokemonInteractContext
import com.cobblemon.mod.common.api.text.red
import com.cobblemon.mod.common.battles.BagItemActionResponse
import com.cobblemon.mod.common.battles.BagItems
import com.cobblemon.mod.common.battles.BattleRules
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.util.battleLang
import net.minecraft.core.registries.BuiltInRegistries
@@ -41,7 +42,7 @@ interface BagItemLike {
fun handleInteraction(player: ServerPlayer, battlePokemon: BattlePokemon, stack: ItemStack): Boolean {
val battle = battlePokemon.actor.battle
val bagItem = getBagItem(stack) ?: return false
if (!battlePokemon.actor.canFitForcedAction()) {
if (!battlePokemon.actor.canFitForcedAction() || battle.format.ruleSet.contains(BattleRules.BAG_CLAUSE)) {
player.sendSystemMessage(battleLang("bagitem.cannot").red())
return false
}
@@ -11,12 +11,13 @@ package com.cobblemon.mod.common.item.battle
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.item.CobblemonItem
import net.minecraft.world.item.ItemNameBlockItem
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.level.block.Block
class DireHitItem : CobblemonItem(Properties()), SimpleBagItemLike {
class DireHitItem(block: Block) : ItemNameBlockItem(block, Properties()), SimpleBagItemLike {
override val bagItem = object : BagItem {
override val itemName = "item.cobblemon.dire_hit"
override val returnItem = Items.AIR
@@ -11,11 +11,12 @@ package com.cobblemon.mod.common.item.battle
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.item.CobblemonItem
import net.minecraft.world.item.ItemNameBlockItem
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.level.block.Block
class GuardSpecItem : CobblemonItem(Properties()), SimpleBagItemLike {
class GuardSpecItem(block: Block) : ItemNameBlockItem(block, Properties()), SimpleBagItemLike {
override val bagItem = object : BagItem {
override val itemName = "item.cobblemon.guard_spec"
override val returnItem = Items.AIR
@@ -12,11 +12,12 @@ import com.cobblemon.mod.common.api.battles.model.PokemonBattle
import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.api.pokemon.stats.Stat
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.item.CobblemonItem
import net.minecraft.world.item.ItemNameBlockItem
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.level.block.Block
class XStatItem(val stat: Stat, stages: Int = 2) : CobblemonItem(Properties()), SimpleBagItemLike {
class XStatItem(val stat: Stat, stages: Int = 2, block: Block) : ItemNameBlockItem(block, Properties()), SimpleBagItemLike {
override val bagItem = object : BagItem {
override val itemName = "item.cobblemon.x_${stat.identifier.path}"
override val returnItem = Items.AIR
@@ -66,6 +66,7 @@ object CobblemonItemGroups {
@JvmStatic val EVOLUTION_ITEMS get() = BuiltInRegistries.CREATIVE_MODE_TAB.get(EVOLUTION_ITEMS_KEY)
@JvmStatic val BUILDING_BLOCKS_INJECTIONS = this.inject(ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.parse("building_blocks")), this::blocksInjections)
@JvmStatic val COLORED_BLOCKS_INJECTIONS = this.inject(ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.parse("colored_blocks")), this::coloredBlocksInjections)
@JvmStatic val FOOD_INJECTIONS = this.inject(ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.parse("food_and_drinks")), this::foodInjections)
@JvmStatic val TOOLS_AND_UTILITIES_INJECTIONS = this.inject(ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.parse("tools_and_utilities")), this::toolsAndUtilitiesInjections)
@JvmStatic val INGREDIENTS_INJECTIONS = this.inject(ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.parse("ingredients")), this::ingredientsInjections)
@@ -381,6 +382,23 @@ object CobblemonItemGroups {
entries.accept(CobblemonItems.THUNDER_STONE_BLOCK)
entries.accept(CobblemonItems.WATER_STONE_BLOCK)
entries.accept(CobblemonItems.WHITE_PLAQUE)
entries.accept(CobblemonItems.LIGHT_GRAY_PLAQUE)
entries.accept(CobblemonItems.GRAY_PLAQUE)
entries.accept(CobblemonItems.BLACK_PLAQUE)
entries.accept(CobblemonItems.BROWN_PLAQUE)
entries.accept(CobblemonItems.RED_PLAQUE)
entries.accept(CobblemonItems.ORANGE_PLAQUE)
entries.accept(CobblemonItems.YELLOW_PLAQUE)
entries.accept(CobblemonItems.LIME_PLAQUE)
entries.accept(CobblemonItems.GREEN_PLAQUE)
entries.accept(CobblemonItems.CYAN_PLAQUE)
entries.accept(CobblemonItems.LIGHT_BLUE_PLAQUE)
entries.accept(CobblemonItems.BLUE_PLAQUE)
entries.accept(CobblemonItems.PURPLE_PLAQUE)
entries.accept(CobblemonItems.MAGENTA_PLAQUE)
entries.accept(CobblemonItems.PINK_PLAQUE)
CobblemonItems.campfire_pots.forEach(entries::accept)
}
@@ -765,6 +783,25 @@ object CobblemonItemGroups {
}
}
private fun coloredBlocksInjections(injector: Injector) {
injector.putLast(CobblemonItems.WHITE_PLAQUE)
injector.putAfter(CobblemonItems.LIGHT_GRAY_PLAQUE, CobblemonItems.WHITE_PLAQUE)
injector.putAfter(CobblemonItems.GRAY_PLAQUE, CobblemonItems.LIGHT_GRAY_PLAQUE)
injector.putAfter(CobblemonItems.BLACK_PLAQUE, CobblemonItems.GRAY_PLAQUE)
injector.putAfter(CobblemonItems.BROWN_PLAQUE, CobblemonItems.BLACK_PLAQUE)
injector.putAfter(CobblemonItems.RED_PLAQUE, CobblemonItems.BROWN_PLAQUE)
injector.putAfter(CobblemonItems.ORANGE_PLAQUE, CobblemonItems.RED_PLAQUE)
injector.putAfter(CobblemonItems.YELLOW_PLAQUE, CobblemonItems.ORANGE_PLAQUE)
injector.putAfter(CobblemonItems.LIME_PLAQUE, CobblemonItems.YELLOW_PLAQUE)
injector.putAfter(CobblemonItems.GREEN_PLAQUE, CobblemonItems.LIME_PLAQUE)
injector.putAfter(CobblemonItems.CYAN_PLAQUE, CobblemonItems.GREEN_PLAQUE)
injector.putAfter(CobblemonItems.LIGHT_BLUE_PLAQUE, CobblemonItems.CYAN_PLAQUE)
injector.putAfter(CobblemonItems.BLUE_PLAQUE, CobblemonItems.LIGHT_BLUE_PLAQUE)
injector.putAfter(CobblemonItems.PURPLE_PLAQUE, CobblemonItems.BLUE_PLAQUE)
injector.putAfter(CobblemonItems.MAGENTA_PLAQUE, CobblemonItems.PURPLE_PLAQUE)
injector.putAfter(CobblemonItems.PINK_PLAQUE, CobblemonItems.MAGENTA_PLAQUE)
}
private fun foodInjections(injector: Injector) {
injector.putAfter(CobblemonItems.TART_APPLE, Items.ENCHANTED_GOLDEN_APPLE)
injector.putAfter(CobblemonItems.SWEET_APPLE, CobblemonItems.TART_APPLE)
@@ -13,7 +13,6 @@ import com.cobblemon.mod.common.api.battles.model.PokemonBattle
import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.api.item.PokemonSelectingItem
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.item.CobblemonItem
import com.cobblemon.mod.common.item.battle.BagItem
import com.cobblemon.mod.common.pokemon.Pokemon
import com.cobblemon.mod.common.util.giveOrDropItemStack
@@ -25,8 +24,10 @@ import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.level.ServerLevel
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.item.ItemNameBlockItem
import net.minecraft.world.item.Rarity
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
/**
* Items for recovering PP in all moves at once.
@@ -34,9 +35,7 @@ import net.minecraft.world.level.Level
* @author Hiroku
* @since June 30th, 2023
*/
class ElixirItem(
val max: Boolean
) : CobblemonItem(Properties().apply {
class ElixirItem(val max: Boolean, block: Block) : ItemNameBlockItem(block, Properties().apply {
if (max) rarity(Rarity.UNCOMMON)
}), PokemonSelectingItem {
override val bagItem = object : BagItem {
@@ -14,7 +14,6 @@ import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.api.item.PokemonAndMoveSelectingItem
import com.cobblemon.mod.common.api.moves.Move
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.item.CobblemonItem
import com.cobblemon.mod.common.item.battle.BagItem
import com.cobblemon.mod.common.pokemon.Pokemon
import com.cobblemon.mod.common.util.giveOrDropItemStack
@@ -26,8 +25,10 @@ import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.level.ServerLevel
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.item.ItemNameBlockItem
import net.minecraft.world.item.Rarity
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
/**
* Item for recovering PP for a specific move in a Pokémon's move list. Opens a move selection GUI.
@@ -35,9 +36,7 @@ import net.minecraft.world.level.Level
* @author Hiroku
* @since June 30th, 2023
*/
class EtherItem(
val max: Boolean
) : CobblemonItem(Properties().apply {
class EtherItem(val max: Boolean, block: Block) : ItemNameBlockItem(block, Properties().apply {
if (max) rarity(Rarity.UNCOMMON)
}), PokemonAndMoveSelectingItem {
override val bagItem = object : BagItem {
@@ -34,8 +34,9 @@ class FreshStartMochiItem : CobblemonItem(Properties()), PokemonSelectingItem {
}
pokemon.feedPokemon(1)
pokemon.evs.forEach {
pokemon.evs[it.key] = 0
pokemon.setEV(it.key, 0)
}
//pokemon.entity?.playSound(CobblemonSounds.MOCHI_USE, 1F, 1F) todo use mochi sounds for fullness levels and replace above
@@ -17,7 +17,6 @@ import com.cobblemon.mod.common.api.item.HealingSource
import com.cobblemon.mod.common.api.item.PokemonSelectingItem
import com.cobblemon.mod.common.api.molang.ExpressionLike
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.item.CobblemonItem
import com.cobblemon.mod.common.item.battle.BagItem
import com.cobblemon.mod.common.pokemon.Pokemon
import com.cobblemon.mod.common.util.asExpressionLike
@@ -31,12 +30,12 @@ import net.minecraft.world.item.Items
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.item.ItemNameBlockItem
import net.minecraft.world.item.Rarity
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
class PotionItem(
val type: PotionType
) : CobblemonItem(Properties().apply {
class PotionItem(val type: PotionType, block: Block) : ItemNameBlockItem(block, Properties().apply {
when (type.name) {
PotionType.MAX_POTION.name -> rarity(Rarity.UNCOMMON)
PotionType.FULL_RESTORE.name -> rarity(Rarity.UNCOMMON)
@@ -14,7 +14,6 @@ import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.api.item.PokemonSelectingItem
import com.cobblemon.mod.common.api.pokemon.status.Status
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.item.CobblemonItem
import com.cobblemon.mod.common.item.battle.BagItem
import com.cobblemon.mod.common.pokemon.Pokemon
import com.cobblemon.mod.common.util.giveOrDropItemStack
@@ -24,7 +23,9 @@ import net.minecraft.world.item.Items
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.item.ItemNameBlockItem
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
/**
* An item that cures statuses. Based on the [status] parameter it can be either specific [Status]es or all statuses (none specified).
@@ -32,7 +33,7 @@ import net.minecraft.world.level.Level
* @author Hiroku
* @since June 30th, 2023
*/
class StatusCureItem(val itemName: String, vararg val status: Status) : CobblemonItem(Properties()), PokemonSelectingItem {
class StatusCureItem(val itemName: String, vararg val status: Status, block: Block) : ItemNameBlockItem(block, Properties()), PokemonSelectingItem {
override val bagItem = object : BagItem {
override val itemName = this@StatusCureItem.itemName
override val returnItem = Items.AIR
@@ -29,8 +29,7 @@ class FormUpdatePacket(pokemon: () -> Pokemon?, form: FormData) : SingleUpdatePa
val ID: ResourceLocation = cobblemonResource("packets/form-update")
fun decode(buffer: RegistryFriendlyByteBuf): FormUpdatePacket {
val pokemon = decodePokemon(buffer)
val form = FormData()
form.species = pokemon()!!.species
val form = FormData().also { it.initialize(pokemon()!!.species) }
form.decode(buffer)
return FormUpdatePacket(pokemon, form)
}
@@ -199,6 +199,9 @@ open class Pokemon : ShowdownIdentifiable {
var form = species.standardForm
set(value) {
// If nothing actually changed, avoid running heavy logic (e.g. updateMovesOnFormChange when the form hasn't really "changed")
if (field == value) return
// Species updates already update HP but just a form change may require it
// Moved to before the field was set else it won't actually do the hp calc proper <3
val quotient = clamp(currentHealth / maxHealth.toFloat(), 0F, 1F)
@@ -996,7 +999,7 @@ open class Pokemon : ShowdownIdentifiable {
this.currentFullness = max(0, this.currentFullness - value)
}
// Amount of seconds that need to pass for the pokemon to lose 1 fullness value
// Amount of ticks that need to pass for the pokemon to lose 1 fullness value
fun getMetabolismRate(): Int {
val speed = this.species.baseStats.getOrDefault(Stats.SPEED,0)
@@ -1009,16 +1012,12 @@ open class Pokemon : ShowdownIdentifiable {
//base berry count
val baseBerryCount = 20
//rate of metabolism in seconds
val metabolismRate = ((baseBerryCount.toDouble() - ((speed.toDouble() / BST.toDouble()) * baseBerryCount.toDouble()) * multiplier.toDouble()) * 60.0).toInt()
// returns value in seconds for the onSecondPassed function
// check for below 0 value and set to minimum to 1 minute
return if (metabolismRate <= 0) {
1 * 60
} else {
metabolismRate
var metabolismRateInSeconds = ((baseBerryCount.toDouble() - ((speed.toDouble() / BST.toDouble()) * baseBerryCount.toDouble()) * multiplier.toDouble()) * 60.0).toInt()
if (metabolismRateInSeconds <= 0) {
metabolismRateInSeconds = 1 * 60
}
return metabolismRateInSeconds * 20
}
// Boolean function that checks if a Pokemon can eat food based on fedTimes
@@ -1037,13 +1036,18 @@ open class Pokemon : ShowdownIdentifiable {
this.interactionCooldowns.remove(group)
}
open fun tickInteractionCooldown() {
this.interactionCooldowns.entries.forEach { (key, value) ->
val newValue = value - 1
if(newValue <= 0)
this.interactionCooldowns.remove(key)
else
this.interactionCooldowns.put(key, newValue)
open fun tickInteractionCooldown(ticksPassed: Int) {
val iterator = interactionCooldowns.entries.iterator()
while (iterator.hasNext()) {
val entry = iterator.next()
val newValue = entry.value - ticksPassed.coerceAtLeast(1)
if (newValue <= 0) {
iterator.remove()
} else {
entry.setValue(newValue)
}
}
}
@@ -1054,9 +1058,8 @@ open class Pokemon : ShowdownIdentifiable {
/**
* Called every second on Player owned and Pastured Pokémon for their fullness
*/
open fun tickMetabolism() {
// have metabolism cycle increase each second
metabolismCycle += 1
open fun tickMetabolism(ticksPassed: Int) {
metabolismCycle += ticksPassed.coerceAtLeast(1)
// if the metabolismCycle value equals the Pokemon's metabolism rate then decrease Fullness by 1
if (metabolismCycle >= this.getMetabolismRate()) {
@@ -2144,16 +2147,26 @@ open class Pokemon : ShowdownIdentifiable {
*/
open fun self(): Pokemon = this
/**
* Function that sanitizes specific form-related moves when the form of this Pokémon changes.
* We only want to sanitize `form_change` moves here so that intended illegalities from the user are preserved.
*
* E.g, Removing Overheat from Rotom when it is no longer Rotom-Heat and the target form is not compatible with Overheat.
*/
private fun updateMovesOnFormChange(newForm: FormData) {
if (this.isClient) {
return
}
if (this.isClient) return
val oldFormChangeMoves = this.form.moves.formChangeMoves.toSet()
// Only remove moves that were provided by the old form's form-change moves AND are not learnable by the new form
for (i in 0 until MoveSet.MOVE_COUNT) {
val move = this.moveSet[i]
if (move != null && !LearnsetQuery.ANY.canLearn(move.template, newForm.moves)) {
if (move != null && move.template in oldFormChangeMoves) {
this.moveSet.setMove(i, null)
}
}
val benchedIterator = this.benchedMoves.iterator()
while (benchedIterator.hasNext()) {
val benchedMove = benchedIterator.next()
@@ -2161,11 +2174,18 @@ open class Pokemon : ShowdownIdentifiable {
benchedIterator.remove()
}
}
// Add form change moves
// Add new form's form-change moves
newForm.moves.formChangeMoves.forEach { move ->
// Under the hood these check if the moves already exist
this.benchedMoves.add(BenchedMove(move, 0))
if (this.moveSet.filterNotNull().none { it.template == move }) {
if (this.moveSet.hasSpace()) {
this.moveSet.add(move.create())
} else {
this.benchedMoves.add(BenchedMove(move, 0))
}
}
}
// If moveset is empty try to find one valid move to fill it
if (this.moveSet.filterNotNull().isEmpty()) {
val benchedMove = this.benchedMoves.firstOrNull()
@@ -10,13 +10,14 @@ package com.cobblemon.mod.common.world.feature
import com.cobblemon.mod.common.Cobblemon
import com.cobblemon.mod.common.CobblemonBlocks
import com.cobblemon.mod.common.api.pokemon.PokemonProperties
import com.cobblemon.mod.common.api.tags.CobblemonBiomeTags
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.core.Direction.UP
import net.minecraft.nbt.CompoundTag
import net.minecraft.tags.BlockTags
import net.minecraft.util.RandomSource
import net.minecraft.world.item.component.CustomData
import net.minecraft.world.level.WorldGenLevel
import net.minecraft.world.level.block.Block.UPDATE_ALL
import net.minecraft.world.level.block.Block.UPDATE_CLIENTS
@@ -227,12 +228,20 @@ class SaccharineTreeFeature : Feature<BlockStateConfiguration>(BlockStateConfigu
val i: Int = 2 + randomSource.nextInt(2)
for (j in 0..<i) {
if (isCombee > 0) {
beehiveBlockEntity!!.storeBee(BeehiveBlockEntity.Occupant.create(randomSource.nextInt(599)))
beehiveBlockEntity?.storeBee(BeehiveBlockEntity.Occupant.create(randomSource.nextInt(599)))
} else {
// We want to create a Pokemon entity here and turn it into a compound tag to store in the hive.
// But creating a Pokemon entity during world generation can cause issues.
// So instead we create custom compound tag that is a placeholder for an incomplete Pokemon.
// This is caught and handled by BeeOccupantMixin.java, which turns it into a complete entity.
val properties = "${POKEMON_ARGS} lvl=${LEVEL_RANGE.random()}"
val pokemon = PokemonProperties.parse(properties)
val entity = pokemon.createEntity(worldGenLevel.level)
beehiveBlockEntity!!.addOccupant(entity)
val compoundTag = CompoundTag()
compoundTag.putString("id", POKEMON_PLACEHOLD_ID)
compoundTag.putString("pokemonProperties", properties)
val occupant = BeehiveBlockEntity.Occupant(
CustomData.of(compoundTag), randomSource.nextInt(599), 600
)
beehiveBlockEntity?.storeBee(occupant)
}
}
})
@@ -351,5 +360,6 @@ class SaccharineTreeFeature : Feature<BlockStateConfiguration>(BlockStateConfigu
companion object {
val POKEMON_ARGS = "combee"
val LEVEL_RANGE = 5..15
val POKEMON_PLACEHOLD_ID = "cobblemon_pokemon_entity_placeholder"
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/antidote_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/antidote_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/antidote_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/antidote_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/antidote_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/antidote_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/antidote_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/antidote_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/antidote_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/antidote_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/antidote_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/antidote_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/antidote_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/antidote_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/antidote_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/antidote_3",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/awakening_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/awakening_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/awakening_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/awakening_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/awakening_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/awakening_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/awakening_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/awakening_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/awakening_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/awakening_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/awakening_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/awakening_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/awakening_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/awakening_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/awakening_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/awakening_3",
"y": 270
}
}
}
@@ -0,0 +1,49 @@
{
"variants": {
"face=ceiling,facing=east": {
"model": "cobblemon:block/black_plaque_hanging",
"y": 90
},
"face=ceiling,facing=north": {
"model": "cobblemon:block/black_plaque_hanging"
},
"face=ceiling,facing=south": {
"model": "cobblemon:block/black_plaque_hanging",
"y": 180
},
"face=ceiling,facing=west": {
"model": "cobblemon:block/black_plaque_hanging",
"y": 270
},
"face=floor,facing=east": {
"model": "cobblemon:block/black_plaque_floor",
"y": 90
},
"face=floor,facing=north": {
"model": "cobblemon:block/black_plaque_floor"
},
"face=floor,facing=south": {
"model": "cobblemon:block/black_plaque_floor",
"y": 180
},
"face=floor,facing=west": {
"model": "cobblemon:block/black_plaque_floor",
"y": 270
},
"face=wall,facing=east": {
"model": "cobblemon:block/black_plaque_wall",
"y": 90
},
"face=wall,facing=north": {
"model": "cobblemon:block/black_plaque_wall"
},
"face=wall,facing=south": {
"model": "cobblemon:block/black_plaque_wall",
"y": 180
},
"face=wall,facing=west": {
"model": "cobblemon:block/black_plaque_wall",
"y": 270
}
}
}
@@ -0,0 +1,49 @@
{
"variants": {
"face=ceiling,facing=east": {
"model": "cobblemon:block/blue_plaque_hanging",
"y": 90
},
"face=ceiling,facing=north": {
"model": "cobblemon:block/blue_plaque_hanging"
},
"face=ceiling,facing=south": {
"model": "cobblemon:block/blue_plaque_hanging",
"y": 180
},
"face=ceiling,facing=west": {
"model": "cobblemon:block/blue_plaque_hanging",
"y": 270
},
"face=floor,facing=east": {
"model": "cobblemon:block/blue_plaque_floor",
"y": 90
},
"face=floor,facing=north": {
"model": "cobblemon:block/blue_plaque_floor"
},
"face=floor,facing=south": {
"model": "cobblemon:block/blue_plaque_floor",
"y": 180
},
"face=floor,facing=west": {
"model": "cobblemon:block/blue_plaque_floor",
"y": 270
},
"face=wall,facing=east": {
"model": "cobblemon:block/blue_plaque_wall",
"y": 90
},
"face=wall,facing=north": {
"model": "cobblemon:block/blue_plaque_wall"
},
"face=wall,facing=south": {
"model": "cobblemon:block/blue_plaque_wall",
"y": 180
},
"face=wall,facing=west": {
"model": "cobblemon:block/blue_plaque_wall",
"y": 270
}
}
}
@@ -0,0 +1,19 @@
{
"variants": {
"facing=north": {
"model": "cobblemon:block/blunder_policy"
},
"facing=east": {
"model": "cobblemon:block/blunder_policy",
"y": 90
},
"facing=south": {
"model": "cobblemon:block/blunder_policy",
"y": 180
},
"facing=west": {
"model": "cobblemon:block/blunder_policy",
"y": 270
}
}
}
@@ -0,0 +1,49 @@
{
"variants": {
"face=ceiling,facing=east": {
"model": "cobblemon:block/brown_plaque_hanging",
"y": 90
},
"face=ceiling,facing=north": {
"model": "cobblemon:block/brown_plaque_hanging"
},
"face=ceiling,facing=south": {
"model": "cobblemon:block/brown_plaque_hanging",
"y": 180
},
"face=ceiling,facing=west": {
"model": "cobblemon:block/brown_plaque_hanging",
"y": 270
},
"face=floor,facing=east": {
"model": "cobblemon:block/brown_plaque_floor",
"y": 90
},
"face=floor,facing=north": {
"model": "cobblemon:block/brown_plaque_floor"
},
"face=floor,facing=south": {
"model": "cobblemon:block/brown_plaque_floor",
"y": 180
},
"face=floor,facing=west": {
"model": "cobblemon:block/brown_plaque_floor",
"y": 270
},
"face=wall,facing=east": {
"model": "cobblemon:block/brown_plaque_wall",
"y": 90
},
"face=wall,facing=north": {
"model": "cobblemon:block/brown_plaque_wall"
},
"face=wall,facing=south": {
"model": "cobblemon:block/brown_plaque_wall",
"y": 180
},
"face=wall,facing=west": {
"model": "cobblemon:block/brown_plaque_wall",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/burn_heal_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/burn_heal_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/burn_heal_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/burn_heal_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/burn_heal_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/burn_heal_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/burn_heal_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/burn_heal_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/burn_heal_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/burn_heal_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/burn_heal_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/burn_heal_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/burn_heal_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/burn_heal_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/burn_heal_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/burn_heal_3",
"y": 270
}
}
}
@@ -0,0 +1,124 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/cleanse_tag_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/cleanse_tag_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/cleanse_tag_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/cleanse_tag_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/cleanse_tag_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/cleanse_tag_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/cleanse_tag_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/cleanse_tag_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/cleanse_tag_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/cleanse_tag_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/cleanse_tag_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/cleanse_tag_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/cleanse_tag_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/cleanse_tag_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/cleanse_tag_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/cleanse_tag_3",
"y": 270
},
"facing=north,amount=5": {
"model": "cobblemon:block/cleanse_tag_4"
},
"facing=east,amount=5": {
"model": "cobblemon:block/cleanse_tag_4",
"y": 90
},
"facing=south,amount=5": {
"model": "cobblemon:block/cleanse_tag_4",
"y": 180
},
"facing=west,amount=5": {
"model": "cobblemon:block/cleanse_tag_4",
"y": 270
},
"facing=north,amount=6": {
"model": "cobblemon:block/cleanse_tag_5"
},
"facing=east,amount=6": {
"model": "cobblemon:block/cleanse_tag_5",
"y": 90
},
"facing=south,amount=6": {
"model": "cobblemon:block/cleanse_tag_5",
"y": 180
},
"facing=west,amount=6": {
"model": "cobblemon:block/cleanse_tag_5",
"y": 270
},
"facing=north,amount=7": {
"model": "cobblemon:block/cleanse_tag_6"
},
"facing=east,amount=7": {
"model": "cobblemon:block/cleanse_tag_6",
"y": 90
},
"facing=south,amount=7": {
"model": "cobblemon:block/cleanse_tag_6",
"y": 180
},
"facing=west,amount=7": {
"model": "cobblemon:block/cleanse_tag_6",
"y": 270
},
"facing=north,amount=8": {
"model": "cobblemon:block/cleanse_tag_7"
},
"facing=east,amount=8": {
"model": "cobblemon:block/cleanse_tag_7",
"y": 90
},
"facing=south,amount=8": {
"model": "cobblemon:block/cleanse_tag_7",
"y": 180
},
"facing=west,amount=8": {
"model": "cobblemon:block/cleanse_tag_7",
"y": 270
}
}
}
@@ -0,0 +1,49 @@
{
"variants": {
"face=ceiling,facing=east": {
"model": "cobblemon:block/cyan_plaque_hanging",
"y": 90
},
"face=ceiling,facing=north": {
"model": "cobblemon:block/cyan_plaque_hanging"
},
"face=ceiling,facing=south": {
"model": "cobblemon:block/cyan_plaque_hanging",
"y": 180
},
"face=ceiling,facing=west": {
"model": "cobblemon:block/cyan_plaque_hanging",
"y": 270
},
"face=floor,facing=east": {
"model": "cobblemon:block/cyan_plaque_floor",
"y": 90
},
"face=floor,facing=north": {
"model": "cobblemon:block/cyan_plaque_floor"
},
"face=floor,facing=south": {
"model": "cobblemon:block/cyan_plaque_floor",
"y": 180
},
"face=floor,facing=west": {
"model": "cobblemon:block/cyan_plaque_floor",
"y": 270
},
"face=wall,facing=east": {
"model": "cobblemon:block/cyan_plaque_wall",
"y": 90
},
"face=wall,facing=north": {
"model": "cobblemon:block/cyan_plaque_wall"
},
"face=wall,facing=south": {
"model": "cobblemon:block/cyan_plaque_wall",
"y": 180
},
"face=wall,facing=west": {
"model": "cobblemon:block/cyan_plaque_wall",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/dire_hit_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/dire_hit_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/dire_hit_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/dire_hit_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/dire_hit_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/dire_hit_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/dire_hit_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/dire_hit_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/dire_hit_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/dire_hit_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/dire_hit_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/dire_hit_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/dire_hit_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/dire_hit_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/dire_hit_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/dire_hit_3",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/elixir_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/elixir_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/elixir_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/elixir_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/elixir_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/elixir_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/elixir_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/elixir_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/elixir_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/elixir_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/elixir_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/elixir_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/elixir_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/elixir_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/elixir_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/elixir_3",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/ether_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/ether_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/ether_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/ether_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/ether_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/ether_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/ether_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/ether_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/ether_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/ether_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/ether_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/ether_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/ether_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/ether_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/ether_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/ether_3",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/full_heal_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/full_heal_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/full_heal_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/full_heal_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/full_heal_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/full_heal_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/full_heal_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/full_heal_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/full_heal_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/full_heal_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/full_heal_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/full_heal_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/full_heal_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/full_heal_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/full_heal_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/full_heal_3",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/full_restore_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/full_restore_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/full_restore_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/full_restore_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/full_restore_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/full_restore_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/full_restore_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/full_restore_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/full_restore_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/full_restore_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/full_restore_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/full_restore_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/full_restore_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/full_restore_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/full_restore_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/full_restore_3",
"y": 270
}
}
}
@@ -0,0 +1,49 @@
{
"variants": {
"face=ceiling,facing=east": {
"model": "cobblemon:block/gray_plaque_hanging",
"y": 90
},
"face=ceiling,facing=north": {
"model": "cobblemon:block/gray_plaque_hanging"
},
"face=ceiling,facing=south": {
"model": "cobblemon:block/gray_plaque_hanging",
"y": 180
},
"face=ceiling,facing=west": {
"model": "cobblemon:block/gray_plaque_hanging",
"y": 270
},
"face=floor,facing=east": {
"model": "cobblemon:block/gray_plaque_floor",
"y": 90
},
"face=floor,facing=north": {
"model": "cobblemon:block/gray_plaque_floor"
},
"face=floor,facing=south": {
"model": "cobblemon:block/gray_plaque_floor",
"y": 180
},
"face=floor,facing=west": {
"model": "cobblemon:block/gray_plaque_floor",
"y": 270
},
"face=wall,facing=east": {
"model": "cobblemon:block/gray_plaque_wall",
"y": 90
},
"face=wall,facing=north": {
"model": "cobblemon:block/gray_plaque_wall"
},
"face=wall,facing=south": {
"model": "cobblemon:block/gray_plaque_wall",
"y": 180
},
"face=wall,facing=west": {
"model": "cobblemon:block/gray_plaque_wall",
"y": 270
}
}
}
@@ -0,0 +1,49 @@
{
"variants": {
"face=ceiling,facing=east": {
"model": "cobblemon:block/green_plaque_hanging",
"y": 90
},
"face=ceiling,facing=north": {
"model": "cobblemon:block/green_plaque_hanging"
},
"face=ceiling,facing=south": {
"model": "cobblemon:block/green_plaque_hanging",
"y": 180
},
"face=ceiling,facing=west": {
"model": "cobblemon:block/green_plaque_hanging",
"y": 270
},
"face=floor,facing=east": {
"model": "cobblemon:block/green_plaque_floor",
"y": 90
},
"face=floor,facing=north": {
"model": "cobblemon:block/green_plaque_floor"
},
"face=floor,facing=south": {
"model": "cobblemon:block/green_plaque_floor",
"y": 180
},
"face=floor,facing=west": {
"model": "cobblemon:block/green_plaque_floor",
"y": 270
},
"face=wall,facing=east": {
"model": "cobblemon:block/green_plaque_wall",
"y": 90
},
"face=wall,facing=north": {
"model": "cobblemon:block/green_plaque_wall"
},
"face=wall,facing=south": {
"model": "cobblemon:block/green_plaque_wall",
"y": 180
},
"face=wall,facing=west": {
"model": "cobblemon:block/green_plaque_wall",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/guard_spec_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/guard_spec_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/guard_spec_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/guard_spec_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/guard_spec_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/guard_spec_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/guard_spec_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/guard_spec_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/guard_spec_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/guard_spec_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/guard_spec_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/guard_spec_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/guard_spec_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/guard_spec_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/guard_spec_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/guard_spec_3",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/hyper_potion_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/hyper_potion_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/hyper_potion_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/hyper_potion_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/hyper_potion_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/hyper_potion_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/hyper_potion_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/hyper_potion_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/hyper_potion_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/hyper_potion_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/hyper_potion_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/hyper_potion_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/hyper_potion_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/hyper_potion_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/hyper_potion_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/hyper_potion_3",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/ice_heal_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/ice_heal_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/ice_heal_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/ice_heal_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/ice_heal_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/ice_heal_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/ice_heal_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/ice_heal_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/ice_heal_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/ice_heal_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/ice_heal_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/ice_heal_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/ice_heal_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/ice_heal_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/ice_heal_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/ice_heal_3",
"y": 270
}
}
}
@@ -0,0 +1,49 @@
{
"variants": {
"face=ceiling,facing=east": {
"model": "cobblemon:block/light_blue_plaque_hanging",
"y": 90
},
"face=ceiling,facing=north": {
"model": "cobblemon:block/light_blue_plaque_hanging"
},
"face=ceiling,facing=south": {
"model": "cobblemon:block/light_blue_plaque_hanging",
"y": 180
},
"face=ceiling,facing=west": {
"model": "cobblemon:block/light_blue_plaque_hanging",
"y": 270
},
"face=floor,facing=east": {
"model": "cobblemon:block/light_blue_plaque_floor",
"y": 90
},
"face=floor,facing=north": {
"model": "cobblemon:block/light_blue_plaque_floor"
},
"face=floor,facing=south": {
"model": "cobblemon:block/light_blue_plaque_floor",
"y": 180
},
"face=floor,facing=west": {
"model": "cobblemon:block/light_blue_plaque_floor",
"y": 270
},
"face=wall,facing=east": {
"model": "cobblemon:block/light_blue_plaque_wall",
"y": 90
},
"face=wall,facing=north": {
"model": "cobblemon:block/light_blue_plaque_wall"
},
"face=wall,facing=south": {
"model": "cobblemon:block/light_blue_plaque_wall",
"y": 180
},
"face=wall,facing=west": {
"model": "cobblemon:block/light_blue_plaque_wall",
"y": 270
}
}
}
@@ -0,0 +1,49 @@
{
"variants": {
"face=ceiling,facing=east": {
"model": "cobblemon:block/light_gray_plaque_hanging",
"y": 90
},
"face=ceiling,facing=north": {
"model": "cobblemon:block/light_gray_plaque_hanging"
},
"face=ceiling,facing=south": {
"model": "cobblemon:block/light_gray_plaque_hanging",
"y": 180
},
"face=ceiling,facing=west": {
"model": "cobblemon:block/light_gray_plaque_hanging",
"y": 270
},
"face=floor,facing=east": {
"model": "cobblemon:block/light_gray_plaque_floor",
"y": 90
},
"face=floor,facing=north": {
"model": "cobblemon:block/light_gray_plaque_floor"
},
"face=floor,facing=south": {
"model": "cobblemon:block/light_gray_plaque_floor",
"y": 180
},
"face=floor,facing=west": {
"model": "cobblemon:block/light_gray_plaque_floor",
"y": 270
},
"face=wall,facing=east": {
"model": "cobblemon:block/light_gray_plaque_wall",
"y": 90
},
"face=wall,facing=north": {
"model": "cobblemon:block/light_gray_plaque_wall"
},
"face=wall,facing=south": {
"model": "cobblemon:block/light_gray_plaque_wall",
"y": 180
},
"face=wall,facing=west": {
"model": "cobblemon:block/light_gray_plaque_wall",
"y": 270
}
}
}
@@ -0,0 +1,49 @@
{
"variants": {
"face=ceiling,facing=east": {
"model": "cobblemon:block/lime_plaque_hanging",
"y": 90
},
"face=ceiling,facing=north": {
"model": "cobblemon:block/lime_plaque_hanging"
},
"face=ceiling,facing=south": {
"model": "cobblemon:block/lime_plaque_hanging",
"y": 180
},
"face=ceiling,facing=west": {
"model": "cobblemon:block/lime_plaque_hanging",
"y": 270
},
"face=floor,facing=east": {
"model": "cobblemon:block/lime_plaque_floor",
"y": 90
},
"face=floor,facing=north": {
"model": "cobblemon:block/lime_plaque_floor"
},
"face=floor,facing=south": {
"model": "cobblemon:block/lime_plaque_floor",
"y": 180
},
"face=floor,facing=west": {
"model": "cobblemon:block/lime_plaque_floor",
"y": 270
},
"face=wall,facing=east": {
"model": "cobblemon:block/lime_plaque_wall",
"y": 90
},
"face=wall,facing=north": {
"model": "cobblemon:block/lime_plaque_wall"
},
"face=wall,facing=south": {
"model": "cobblemon:block/lime_plaque_wall",
"y": 180
},
"face=wall,facing=west": {
"model": "cobblemon:block/lime_plaque_wall",
"y": 270
}
}
}
@@ -0,0 +1,49 @@
{
"variants": {
"face=ceiling,facing=east": {
"model": "cobblemon:block/magenta_plaque_hanging",
"y": 90
},
"face=ceiling,facing=north": {
"model": "cobblemon:block/magenta_plaque_hanging"
},
"face=ceiling,facing=south": {
"model": "cobblemon:block/magenta_plaque_hanging",
"y": 180
},
"face=ceiling,facing=west": {
"model": "cobblemon:block/magenta_plaque_hanging",
"y": 270
},
"face=floor,facing=east": {
"model": "cobblemon:block/magenta_plaque_floor",
"y": 90
},
"face=floor,facing=north": {
"model": "cobblemon:block/magenta_plaque_floor"
},
"face=floor,facing=south": {
"model": "cobblemon:block/magenta_plaque_floor",
"y": 180
},
"face=floor,facing=west": {
"model": "cobblemon:block/magenta_plaque_floor",
"y": 270
},
"face=wall,facing=east": {
"model": "cobblemon:block/magenta_plaque_wall",
"y": 90
},
"face=wall,facing=north": {
"model": "cobblemon:block/magenta_plaque_wall"
},
"face=wall,facing=south": {
"model": "cobblemon:block/magenta_plaque_wall",
"y": 180
},
"face=wall,facing=west": {
"model": "cobblemon:block/magenta_plaque_wall",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/max_elixir_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/max_elixir_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/max_elixir_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/max_elixir_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/max_elixir_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/max_elixir_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/max_elixir_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/max_elixir_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/max_elixir_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/max_elixir_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/max_elixir_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/max_elixir_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/max_elixir_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/max_elixir_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/max_elixir_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/max_elixir_3",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/max_ether_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/max_ether_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/max_ether_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/max_ether_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/max_ether_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/max_ether_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/max_ether_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/max_ether_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/max_ether_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/max_ether_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/max_ether_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/max_ether_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/max_ether_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/max_ether_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/max_ether_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/max_ether_3",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/max_potion_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/max_potion_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/max_potion_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/max_potion_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/max_potion_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/max_potion_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/max_potion_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/max_potion_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/max_potion_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/max_potion_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/max_potion_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/max_potion_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/max_potion_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/max_potion_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/max_potion_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/max_potion_3",
"y": 270
}
}
}
@@ -0,0 +1,49 @@
{
"variants": {
"face=ceiling,facing=east": {
"model": "cobblemon:block/orange_plaque_hanging",
"y": 90
},
"face=ceiling,facing=north": {
"model": "cobblemon:block/orange_plaque_hanging"
},
"face=ceiling,facing=south": {
"model": "cobblemon:block/orange_plaque_hanging",
"y": 180
},
"face=ceiling,facing=west": {
"model": "cobblemon:block/orange_plaque_hanging",
"y": 270
},
"face=floor,facing=east": {
"model": "cobblemon:block/orange_plaque_floor",
"y": 90
},
"face=floor,facing=north": {
"model": "cobblemon:block/orange_plaque_floor"
},
"face=floor,facing=south": {
"model": "cobblemon:block/orange_plaque_floor",
"y": 180
},
"face=floor,facing=west": {
"model": "cobblemon:block/orange_plaque_floor",
"y": 270
},
"face=wall,facing=east": {
"model": "cobblemon:block/orange_plaque_wall",
"y": 90
},
"face=wall,facing=north": {
"model": "cobblemon:block/orange_plaque_wall"
},
"face=wall,facing=south": {
"model": "cobblemon:block/orange_plaque_wall",
"y": 180
},
"face=wall,facing=west": {
"model": "cobblemon:block/orange_plaque_wall",
"y": 270
}
}
}
@@ -0,0 +1,64 @@
{
"variants": {
"facing=north,amount=1": {
"model": "cobblemon:block/paralyze_heal_0"
},
"facing=east,amount=1": {
"model": "cobblemon:block/paralyze_heal_0",
"y": 90
},
"facing=south,amount=1": {
"model": "cobblemon:block/paralyze_heal_0",
"y": 180
},
"facing=west,amount=1": {
"model": "cobblemon:block/paralyze_heal_0",
"y": 270
},
"facing=north,amount=2": {
"model": "cobblemon:block/paralyze_heal_1"
},
"facing=east,amount=2": {
"model": "cobblemon:block/paralyze_heal_1",
"y": 90
},
"facing=south,amount=2": {
"model": "cobblemon:block/paralyze_heal_1",
"y": 180
},
"facing=west,amount=2": {
"model": "cobblemon:block/paralyze_heal_1",
"y": 270
},
"facing=north,amount=3": {
"model": "cobblemon:block/paralyze_heal_2"
},
"facing=east,amount=3": {
"model": "cobblemon:block/paralyze_heal_2",
"y": 90
},
"facing=south,amount=3": {
"model": "cobblemon:block/paralyze_heal_2",
"y": 180
},
"facing=west,amount=3": {
"model": "cobblemon:block/paralyze_heal_2",
"y": 270
},
"facing=north,amount=4": {
"model": "cobblemon:block/paralyze_heal_3"
},
"facing=east,amount=4": {
"model": "cobblemon:block/paralyze_heal_3",
"y": 90
},
"facing=south,amount=4": {
"model": "cobblemon:block/paralyze_heal_3",
"y": 180
},
"facing=west,amount=4": {
"model": "cobblemon:block/paralyze_heal_3",
"y": 270
}
}
}

Some files were not shown because too many files have changed in this diff Show More