Last active
November 24, 2024 08:01
-
-
Save blepping/532a9f42107feccda82a8516218ed703 to your computer and use it in GitHub Desktop.
RiftWizard NoAnnoy mod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RiftWizard mod, should work with RiftWizard 1 and 2. Usage: | |
# 1. Find your mods directory. Right-click the game -> Properties -> Installed Files -> Browse -> Navigate to RiftWizard2/mods | |
# 2. Create a NoAnnoy directory (case-sensitive) and put NoAnnoy.py in there. | |
# 3. Restart Rift Wizard. You should see a message about the mod in the game console. | |
# | |
# You can use Steam's Launch Options to override settings instead of editing the mod. | |
# Right click the game -> Properties -> General. Example launch string: | |
# NOANNOY_MONSTER_BLACKLIST=SilentSpecter,FaeSniper NOANNOY_GAMEOVER_SPEED_FACTOR=100 %command% | |
### User configurable options: | |
# Speed factor for the gameover screen, set to 0 for default behavior. | |
# Can be overridden with environment variable NOANNOY_GAMEOVER_SPEED_FACTOR. | |
GAMEOVER_SPEED_FACTOR = 100 | |
# Monster blacklist by class name, comma separated. Look in Monsters.py for class names. | |
# Can be overridden with environment variable NOANNOY_MONSTER_BLACKLIST. | |
MONSTER_BLACKLIST = "SilentSpecter,FaeSniper" | |
# Limits immortal monsters from splitting into immortal children when their HP is above this threshold. | |
# Set to a negative value (i.e. -1) to disable the limit. | |
# Can be overridden with environment variable NOANNOY_IMMORTAL_SPLITTING_HP_MAX. | |
IMMORTAL_SPLITTING_HP_MAX = 64 | |
### End user configurable options. | |
import inspect, os | |
import Monsters, BossSpawns, Level, CommonContent | |
try: | |
# Inspect trick from Leximancer. Thanks! Ref: https://discord.com/channels/645130221435092992/1230272128205586532/1230272128205586532 | |
RiftWizard = inspect.getmodule(inspect.stack()[-1][0]) | |
class PGVFastGameover(RiftWizard.PyGameView): | |
def draw_gameover(self, *args, **kwargs): | |
if self.gameover_frames > 8: | |
self.gameover_frames += GAMEOVER_SPEED_FACTOR | |
return super(PGVFastGameover, self).draw_gameover(*args, **kwargs) | |
except Exception as exc: | |
print(f"!! NoAnnoy mod: Couldn't get main RiftWizard module! Exception: {exc}") | |
RiftWizard = None | |
def apply_fastgameover(): | |
if GAMEOVER_SPEED_FACTOR > 0 and RiftWizard is not None and not isinstance(RiftWizard.PyGameView, PGVFastGameover): | |
RiftWizard.PyGameView = PGVFastGameover | |
def apply_monster_blacklist(blacklist_names): | |
blacklist = set( | |
monster_fun | |
for monster_fun in ( | |
getattr(Monsters, monster_class_name, None) | |
for monster_class_name in blacklist_names | |
if monster_class_name | |
) | |
if monster_fun is not None | |
) | |
count = 0 | |
for spawn_option in Monsters.spawn_options: | |
if spawn_option[0] in blacklist: | |
Monsters.spawn_options.remove(spawn_option) | |
count += 1 | |
return count | |
orig_SplittingBuff_split = CommonContent.SplittingBuff.split | |
def limited_SplittingBuff_split(self, *args, **kwargs): | |
owner = self.owner | |
if owner is not None: | |
lives = getattr(owner.get_buff(CommonContent.ReincarnationBuff), "lives", 0) | |
if lives > 0 and owner.max_hp > IMMORTAL_SPLITTING_HP_MAX: | |
return | |
for result in orig_SplittingBuff_split(self, *args, **kwargs): | |
yield result | |
def apply_immortal_splitting_limit(): | |
if IMMORTAL_SPLITTING_HP_MAX < 0 or CommonContent.SplittingBuff.split == limited_SplittingBuff_split: | |
return | |
CommonContent.SplittingBuff.split = limited_SplittingBuff_split | |
def init_mod(): | |
global GAMEOVER_SPEED_FACTOR, MONSTER_BLACKLIST, IMMORTAL_SPLITTING_HP_MAX | |
MONSTER_BLACKLIST = os.environ.get("NOANNOY_MONSTER_BLACKLIST", MONSTER_BLACKLIST) | |
GAMEOVER_SPEED_FACTOR = int(os.environ.get("NOANNOY_GAMEOVER_SPEED_FACTOR", GAMEOVER_SPEED_FACTOR)) | |
IMMORTAL_SPLITTING_HP_MAX = int(os.environ.get("NOANNOY_IMMORTAL_SPLITTING_HP_MAX", IMMORTAL_SPLITTING_HP_MAX)) | |
monster_blacklist = set(name.strip() for name in MONSTER_BLACKLIST.split(",")) | |
removed_count = apply_monster_blacklist(monster_blacklist) | |
apply_fastgameover() | |
apply_immortal_splitting_limit() | |
print(f"* NoAnnoy mod loaded: gameover_speed: +{GAMEOVER_SPEED_FACTOR}x, splitting immortals HP cap: {IMMORTAL_SPLITTING_HP_MAX}, monster_blacklist(found={removed_count}/{len(monster_blacklist)}): {', '.join(tuple(monster_blacklist))}") | |
try: | |
init_mod() | |
except Exception as exc: | |
print(f"!! NoAnnoy mod: Init failed, exception: {exc}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment