def custom_init(self, nart): myscene = self.elements["LOCALE"] myroom = self.register_element("ROOM", pbge.randmaps.rooms.FuzzyRoom(10, 10), dident="LOCALE") myfac = self.elements.get("ENEMY_FACTION") team2 = self.register_element( "_eteam", teams.Team(enemies=(myscene.player_team, )), dident="ROOM") for i in range(4): mek = gears.selector.generate_ace(self.rank, myfac, myscene.environment) champions.upgrade_to_champion(mek) team2.contents.append(mek) if i == 0: self.register_element("_commander", mek.get_pilot()) self.obj = adventureseed.MissionObjective( "Investigate the meteor", missionbuilder.MAIN_OBJECTIVE_VALUE * 2) self.adv.objectives.append(self.obj) self.combat_entered = False self.combat_finished = False return True
def _pick_an_item(self, itype, rank, camp): candidates = [item for item in gears.selector.DESIGN_LIST if itype in item.shop_tags and self.item_matches_shop(item, camp)] if candidates: # Step one: Sort the candidates by cost. random.shuffle(candidates) candidates.sort(key=lambda i: i.cost) # Step two: Determine this store's ideal index position. ideal_index = len(candidates) * min(max(rank,0),100) / 100.0 # Step three: Create a new list sorted by distance from ideal_index. sorted_candidates = candidates.copy() sorted_candidates.sort(key=lambda i: abs(candidates.index(i) - ideal_index)) # Step four: Choose an item, the lower the better. max_i = min(len(candidates)-1,max(5,len(candidates)//3)) i = min(random.randint(0,max_i),random.randint(0,max_i),random.randint(0,max_i)) it = copy.deepcopy(sorted_candidates[i]) if isinstance(it, gears.base.Mecha): it.colors = self.mecha_colors if self.sell_champion_equipment and random.randint(1,3) == 1: if isinstance(it, gears.base.Mecha): champions.upgrade_to_champion(it) elif it.scale == gears.scale.MechaScale and isinstance(it, (gears.base.Component, gears.base.Shield, gears.base.Launcher)): champions.upgrade_item_to_champion(it) return it
def custom_init(self, nart): if super().custom_init(nart): myteam = self.elements["_eteam"] if myteam.contents: champions.upgrade_to_champion(random.choice(myteam.contents)) return True else: return False
def custom_init(self, nart): myscene = self.elements["LOCALE"] myscene.attributes.add(gears.tags.SCENE_SOLO) self.register_element("ROOM", pbge.randmaps.rooms.FuzzyRoom(10, 10), dident="LOCALE") team2 = self.register_element( "_eteam", teams.Team(enemies=(myscene.player_team, )), dident="ROOM") fac = self.elements["ENEMY_FACTION"] npc = self.seek_element(nart, "_champion", self.adv.is_good_enemy_npc, must_find=False, lock=True) if npc: plotutility.CharacterMover(nart.camp, self, npc, myscene, team2) self.add_sub_plot(nart, "MC_ENEMY_DEVELOPMENT", elements={"NPC": npc}) else: mek = gears.selector.generate_ace(self.rank, fac, myscene.environment) npc = mek.get_pilot() self.register_element("_champion", npc) team2.contents.append(mek) champions.upgrade_to_champion(mek) self.obj = adventureseed.MissionObjective( "Defeat the {}'s champion {}".format(fac, npc), missionbuilder.MAIN_OBJECTIVE_VALUE * 2) self.adv.objectives.append(self.obj) self.intro_ready = True return True