コード例 #1
0
 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))
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
 def __init__(self):
     super().__init__(t.DOOM_BUNNY, mobs.DoomBunny(), item_id=i.DOOM_BUNNY)
     self.add_drop(i.DOOM_BUNNY, 1)
コード例 #5
0
 def __init__(self):
     super().__init__(t.ZOMBIE, mobs.Zombie(), item_id=i.ZOMBIE)
     self.add_drop(i.ZOMBIE, 1)
コード例 #6
0
 def __init__(self):
     super().__init__(t.CAT, mobs.Cat(), item_id=i.CAT)
     self.add_drop(i.CAT, 1)
コード例 #7
0
 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
コード例 #8
0
 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()])