Files
dockipelago/worlds/earthbound/modules/enemizer/randomize_enemy_stats.py
PinkSwitch 55c70a5ba8 EarthBound: Implement New Game (#5159)
* Add the world

* doc update

* docs

* Fix Blast/Missile not clearing Reflect

* Update worlds/earthbound/__init__.py

Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com>

* Update worlds/earthbound/__init__.py

remove unused import

Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com>

* Update worlds/earthbound/__init__.py

Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com>

* Update worlds/earthbound/modules/dungeon_er.py

make bool optional

Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com>

* Update worlds/earthbound/modules/boss_shuffle.py

typing update

Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com>

* Update worlds/earthbound/modules/boss_shuffle.py

Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com>

* Filter events out of item name to id

* we call it a glorp

* Update worlds/earthbound/Regions.py

Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com>

* Update worlds/earthbound/__init__.py

Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com>

* Update worlds/earthbound/Items.py

Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com>

* Update worlds/earthbound/Regions.py

Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com>

* Fix missing optional import

* hint stuff

* -Fix Apple Kid text being wrong
-Fix Slimy Pile text being wrong

* -Fix some sprite corruption if PSI was used when an enemy loaded another enemy
-Fixed a visible artifact tile during some cutscenes

* Update ver

* Update docs

* Fix some money scripting issues

* Add argument to PSI fakeout attack

* Updated monkey caves shop description

* Remove closing markdown from doc

* Add new flavors

* Make flavors actually work

* Update platforms

* Fix common gear getting duplicated

* Split region initialization

* Condense checks for start inventory + some other junk

* Fix some item groups - change receiver phone to warp pad

* wow that one was really bad :glorp:

* blah

* Fix cutoff option text

* switch start inventory concatenation to itertools

* Fix sky runner scripting bug - added some new comm suggestions

* Fix crash when generating with spoiler_only

* Fix happy-happy teleport not unlocking after beating carpainter

* Hint man hints can now use CreateHint packets to create hints in other games

* Adjust some filler rarity

* Update world to use CreateHints and deprecate old method

* Fix epilogue skip being offset

* Rearrange a couple regions

* Fix tendapants getting deleted in battle

* update doc

* i got scared and forgot i had multiple none checks and am worried about this triggering but tested and it works

* Fix mostly typing errors from silvris

* More type checks

* More typing

* Typema

* Type

* Fix enemy levels overwriting music

* Fix gihugic blunder

* Fix Lumine Hall enabling OSS

* del world

* Rel 4.2.7

* Remove some debug logs

* Fix vanilla bug with weird ambush detection

* Fix Starman Junior having an unscaled Freeze

* Change shop scaling

* Fix shops using the wrong thankful script

* Update some bosses in boss shuffle

* Loc group adjustment

* Update some boss shuffle stuff | Fix Enemizer attacks getting overwritten by Shuffle data | Fix flunkies not updating and still being used with enemizer

* Get rid of some debug stuff

* Get boss shuffle running, dont merge

* Fix json and get boss shuffle no plando back up

* Fix Magicant Boost not initializing to Ness if party count = 4

* Fix belch shop using wrong logic

* Don't re-send goal status

* EBitem

* remove :

* idk if this is whatvi wanted

* All client messagesnow only send when relevant instead of constantly

* Patch up the rest of boss plando

* Fix Giygas being not excluded from enemizer

* Fix epilogue again

* adjust the sphere scaling name

* add the things

* Fix Ness being placed onto monotoli when monotoli was in sea of eden

* Fix prefill properly

* Fix boss shuffle on vanilla slots.

* rename this, apparently

* Update archipelago.json

---------

Co-authored-by: Duck <31627079+duckboycool@users.noreply.github.com>
Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
2025-12-19 14:52:27 +01:00

69 lines
3.5 KiB
Python

from .enemy_attributes import excluded_enemies
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ... import EarthBoundWorld
from ...Rom import LocalRom
class EnemyStatCopy:
def __init__(self, hp: int, exp: int, money: int, speed: int, offense: int,
defense: int, level: int, guts: int, luck: int):
self.hp = hp
self.exp = exp
self.money = money
self.speed = speed
self.offense = offense
self.defense = defense
self.level = level
self.guts = guts
self.luck = luck
def randomize_enemy_stats(world: "EarthBoundWorld", rom: "LocalRom") -> None:
"""Randomizes enemy stats. It does not actually randomize them, rather it gives enemies the stats of a random other enemy.
Enemies have a 19% chance to have PP."""
stat_copies = {}
for enemy in world.enemies:
if enemy not in excluded_enemies:
stat_copies[enemy] = EnemyStatCopy(
hp=world.enemies[enemy].hp,
exp=world.enemies[enemy].exp,
money=world.enemies[enemy].money,
speed=world.enemies[enemy].speed,
offense=world.enemies[enemy].offense,
defense=world.enemies[enemy].defense,
level=world.enemies[enemy].level,
guts=world.enemies[enemy].guts,
luck=world.enemies[enemy].luck
)
for enemy in world.enemies:
if enemy not in excluded_enemies:
copied_stat_base = world.random.choice(list(stat_copies))
world.enemies[enemy].hp = stat_copies[copied_stat_base].hp
if world.random.randint(1, 100) < 20:
world.enemies[enemy].pp = int(world.random.randint(10, 500) / 2)
else:
world.enemies[enemy].pp = 0
world.enemies[enemy].offense = stat_copies[copied_stat_base].offense
world.enemies[enemy].defense = stat_copies[copied_stat_base].defense
world.enemies[enemy].speed = stat_copies[copied_stat_base].speed
world.enemies[enemy].level = stat_copies[copied_stat_base].level
world.enemies[enemy].exp = stat_copies[copied_stat_base].exp
world.enemies[enemy].money = stat_copies[copied_stat_base].money
world.enemies[enemy].guts = stat_copies[copied_stat_base].guts
world.enemies[enemy].luck = stat_copies[copied_stat_base].luck
rom.write_bytes(world.enemies[enemy].address + 0x3D, bytearray([world.enemies[enemy].guts]))
rom.write_bytes(world.enemies[enemy].address + 0x3E, bytearray([world.enemies[enemy].luck]))
if world.enemies[enemy].attack_extensions > 0:
world.enemies[f"{enemy} (2)"].hp = world.enemies[enemy].hp
world.enemies[f"{enemy} (2)"].pp = world.enemies[enemy].pp
world.enemies[f"{enemy} (2)"].offense = world.enemies[enemy].offense
world.enemies[f"{enemy} (2)"].defense = world.enemies[enemy].defense
world.enemies[f"{enemy} (2)"].speed = world.enemies[enemy].speed
world.enemies[f"{enemy} (2)"].level = world.enemies[enemy].level
world.enemies[f"{enemy} (2)"].exp = world.enemies[enemy].exp
world.enemies[f"{enemy} (2)"].money = world.enemies[enemy].money
rom.write_bytes(world.enemies[f"{enemy} (2)"].address + 0x3D, bytearray([world.enemies[enemy].guts]))
rom.write_bytes(world.enemies[f"{enemy} (2)"].address + 0x3E, bytearray([world.enemies[enemy].luck]))