def summon(self, pos): data = game_vars.get_block_data(pos) if data: magic = int.from_bytes(data[:8], byteorder) # Must have at least 5 magic if magic < 5: return # Every X5 for magic increases max level by 1 max_level = math.log(magic, 5) chance = max(max_level % 1, .5) max_level = int(max_level) # Find chances for current level and up to two levels below if max_level == 1: chances = {1: 1} elif max_level == 2: chances = {2: chance, 1: 1 - chance} else: chances = { max_level: chance, max_level - 1: (1 - chance) * 2 / 3, max_level - 2: (1 - chance) / 3 } # Choose a random level num = uniform(0, 1) for lvl, chance in chances.items(): if num > chance: num -= chance else: # Summon mage # element = choice(list(ItemTypes.MagicContainer.ELEMENT_NAMES.keys())) game_vars.spawn_entity( mobs.Mage(ItemTypes.MagicContainer.FIRE, lvl), [p * BLOCK_W for p in pos]) break magic = int(magic / 2) game_vars.write_block_data(pos, magic.to_bytes(8, byteorder))
def __init__(self): super().__init__(t.BIRDIE, mobs.Birdie(), item_id=i.BIRDIE) self.add_drop(i.BIRDIE, 1) self.map_color = (0, 0, 80)
def __init__(self): super().__init__(t.HELICOPTER, mobs.Helicopter(), item_id=i.HELICOPTER) self.add_drop(i.HELICOPTER, 1) self.map_color = (0, 0, 80)
def __init__(self): super().__init__(t.DOOM_BUNNY, mobs.DoomBunny(), item_id=i.DOOM_BUNNY) self.add_drop(i.DOOM_BUNNY, 1)
def __init__(self): super().__init__(t.ZOMBIE, mobs.Zombie(), item_id=i.ZOMBIE) self.add_drop(i.ZOMBIE, 1)
def __init__(self): super().__init__(t.CAT, mobs.Cat(), item_id=i.CAT) self.add_drop(i.CAT, 1)
def on_break(self, pos): game_vars.spawn_entity(mobs.Dragon(), [ p + randint(10, 20) * BLOCK_W * c.random_sign() for p in game_vars.player_pos() ]) return False
def on_left_click(self): game_vars.spawn_entity(Mobs.MainBoss(), [p + randint(15, 30) * BLOCK_W * random_sign() for p in game_vars.player_pos()])