def t_START(self, camp): if self.intro_ready and camp.scene is self.elements["DUNGEON_ENTRANCE"]: pbge.alert("You are dropped into a deep underground chamber. You're not sure whether this is inside Kerberos or some adjoining complex.") self.intro_ready = False if self.elements["ENTRANCE"].dest_wp is not self.elements["MISSION_GATE"]: print("Fixing Kerberos dungeon...") self.elements["ENTRANCE"].dest_wp = self.elements["MISSION_GATE"]
def __call__(self, camp, alpha_card, beta_card=None, transform_card=None): """ :type alpha_card: TarotCard """ nart = GHNarrativeRequest(camp, plot_list=PLOT_LIST) pstate = pbge.plots.PlotState() pstate.elements[ME_AUTOREVEAL] = True pstate.rank = alpha_card.rank if self.alpha_params: for pp in self.alpha_params: pstate.elements[pp] = alpha_card.elements.get(pp) if self.beta_params and beta_card: for pp in self.beta_params: pstate.elements[pp] = beta_card.elements.get(pp) if transform_card: pstate.elements[ME_TAROTPOSITION] = transform_card.elements[ ME_TAROTPOSITION] pstate.elements[ME_TAROTSCOPE] = transform_card.elements[ ME_TAROTSCOPE] else: pstate.elements[ME_TAROTSCOPE] = alpha_card.elements[ME_TAROTSCOPE] newcard = nart.request_tarot_card_by_name(self.new_card_name, pstate) if not newcard: pbge.alert("New tarot card failed for {}".format( self.new_card_name)) else: nart.story.visible = True nart.build()
def mutate_cards(self, alpha_card, beta_card, camp): nart = GHNarrativeRequest(camp, plot_list=PLOT_LIST) end_these_plots = list() for t in range(3): if self.results[t]: # Replace this card. pstate = pbge.plots.PlotState() pstate.elements[ME_AUTOREVEAL] = True if self.passparams[t]: if self.passparams[t][0]: for pp in self.passparams[t][0]: pstate.elements[pp] = alpha_card.elements.get(pp) if self.passparams[t][1]: for pp in self.passparams[t][1]: pstate.elements[pp] = beta_card.elements.get(pp) if t == 0: pstate.elements[ME_TAROTPOSITION] = alpha_card.elements[ME_TAROTPOSITION] pstate.elements[ME_TAROTSCOPE] = alpha_card.elements[ME_TAROTSCOPE] end_these_plots.append(alpha_card) elif t == 1: pstate.elements[ME_TAROTPOSITION] = beta_card.elements[ME_TAROTPOSITION] pstate.elements[ME_TAROTSCOPE] = alpha_card.elements[ME_TAROTSCOPE] end_these_plots.append(beta_card) newcard = nart.request_tarot_card_by_name(self.results[t], pstate) if not newcard: pbge.alert("New tarot card failed for {}".format(self.results[t])) else: nart.story.visible = True nart.build() for p in end_these_plots: p.end_plot(camp)
def prep_eggs_for_steam(tsrd): if not pickle.HIGHEST_PROTOCOL > 4: pbge.my_state.view = tsrd pbge.alert( "Can't prep eggs for Steam since the version of GearHead Caramel you're running appears to be the Steam version. You need to do this from a non-Steam build." ) return pbge.please_stand_by() myfiles = glob.glob(pbge.util.user_dir("egg_*.sav")) for fname in myfiles: try: with open(fname, "rb") as f: # Why deepcopy the freshly loaded pickle? Because that will update any gears involved # to the latest version, and at this point in time it'll hopefully keep save games working # despite rapid early-development changes. egg = copy.deepcopy(pickle.load(f)) egg.save() except Exception as err: print(err) myfiles = glob.glob(pbge.util.user_dir("rpg_*.sav")) for fname in myfiles: try: args = gears.GearHeadCampaign.load(fname) args[-1].save() except Exception as err: print(err)
def t_ENDCOMBAT(self, camp): myteam = self.elements["_eteam"] if len(myteam.get_members_in_play(camp)) < 1: self.obj.win(camp, 100) if not self.combat_finished: pbge.alert("You stopped the delivery of modified mecha.") self.combat_finished = True
def unlocked_use(self, camp): # Perform this waypoint's special action. if self.dest_scene and self.dest_entrance: camp.destination = self.dest_scene camp.entrance = self.dest_entrance else: pbge.alert("This door doesn't seem to go anywhere.")
def import_arena_character(tsrd): pbge.please_stand_by() myfiles = gears.oldghloader.GH1Loader.seek_gh1_files() mymenu = pbge.rpgmenu.Menu(TitleScreenRedraw.MENU_DEST.dx, TitleScreenRedraw.MENU_DEST.dy, TitleScreenRedraw.MENU_DEST.w, TitleScreenRedraw.MENU_DEST.h, predraw=tsrd, font=pbge.my_state.huge_font) for f in myfiles: try: mygears = gears.oldghloader.GH1Loader(f) mygears.load() egg = mygears.get_egg() mymenu.add_item(str(egg.pc), egg) except Exception as e: pbge.alert("Warning: File {} can't be parsed. {}".format(f, e)) mymenu.sort() if not mymenu.items: mymenu.add_item('[No GH1 characters found]', None) myegg = mymenu.query() if myegg: myegg.save() pbge.BasicNotification("{} has been imported.".format(myegg.pc.name))
def __call__(self, camp, this_card, other_card=None): """ :type this_card: TarotCard """ # Activating a transformation gives XP. camp.dole_xp(100) nart = GHNarrativeRequest(camp, plot_list=PLOT_LIST) pstate = pbge.plots.PlotState() pstate.elements[ME_AUTOREVEAL] = True pstate.rank = this_card.rank for p in self.auto_params: pstate.elements[p] = this_card.elements.get(p) pstate.elements.update(self.this_card_params.get_elements(this_card)) pstate.elements.update(self.other_card_params.get_elements(other_card)) newcard = nart.request_tarot_card_by_name(self.new_card_name, pstate) if not newcard: pbge.alert("New tarot card failed for {}".format( self.new_card_name)) else: newcard.tarot_position = this_card.tarot_position nart.story.visible = True nart.build() if other_card: other_card.invoke(camp, this_card) this_card.end_plot(camp, True)
def LOCALE_ENTER(self, camp: gears.GearHeadCampaign): if self.choice_ready: self.choice_ready = False # Allow the PC to decide whether or not to respond to the distress call. npc = self.elements["PILOT"] pbge.alert( "While traveling, you receive a distress call from {}.".format( npc)) mymenu = game.content.ghcutscene.SimpleMonologueMenu( "[DISTRESS_CALL]", self.elements["SURVIVOR"], camp) self.intimidating_npc = game.content.ghcutscene.AddSkillBasedLancemateMenuItem( mymenu, "Those [enemy_meks] don't look so brave to me. Follow my lead and we can end this quickly.", self.do_intimidation, camp, gears.stats.Ego, gears.stats.MechaFighting, self.rank, gears.stats.DIFFICULTY_HARD) mymenu.add_item("Go help {}".format(npc), None) mymenu.add_item("Ignore distress call", self.abandon_distress_call) choice = mymenu.query() if choice: choice(camp)
def LOCALE_ENTER(self, camp: gears.GearHeadCampaign): if self.choice_ready: self.choice_ready = False # Allow the PC to decide whether or not to respond to the distress call. npc = self.elements["PILOT"] pbge.alert( "While traveling, you receive a distress call from {}.".format( npc)) mymenu = game.content.ghcutscene.SimpleMonologueMenu( "[DISTRESS_CALL]", self.elements["SURVIVOR"], camp) if npc.faction and camp.is_unfavorable_to_pc(npc.faction): game.content.ghcutscene.AddTagBasedLancemateMenuItem( mymenu, "We have no duty to aid an enemy combatant.", self.cancel_the_adventure, camp, (gears.personality.Duty, )) self.glory_npc = game.content.ghcutscene.AddTagBasedLancemateMenuItem( mymenu, "You realize there'll probably be a cash reward for helping out.", self.go_for_glory, camp, (gears.personality.Glory, )) self.fellowship_npc = game.content.ghcutscene.AddTagBasedLancemateMenuItem( mymenu, "Helping {} is the right thing to do.".format(npc), self.go_for_fellowship, camp, (gears.personality.Fellowship, )) mymenu.add_item("Go help {}".format(npc), None) mymenu.add_item("Ignore distress call", self.abandon_distress_call) choice = mymenu.query() if choice: choice(camp)
def __init__(self,camp,metroscene,metro): creds = camp.totally_restore_party() self.did_recovery = False if creds > 0: pbge.alert("Repair/Reload: ${}".format(creds)) camp.credits -= creds camp.day += 1 if camp.incapacitated_party or camp.dead_party or any([pc for pc in camp.get_lancemates() if not camp.get_pc_mecha(pc)]): # Go through the injured/dead lists and see who needs help. if camp.pc not in camp.party: # This is serious. init = pbge.plots.PlotState(elements={"METRO":metro,"METROSCENE":metroscene}) nart = GHNarrativeRequest(camp,init,adv_type="RECOVER_PC",plot_list=PLOT_LIST) if nart.story: nart.build() nart.story.start_recovery(camp) self.did_recovery = True else: print(nart.errors) else: init = pbge.plots.PlotState(elements={"METRO":metro,"METROSCENE":metroscene}) nart = GHNarrativeRequest(camp,init,adv_type="RECOVER_LANCE",plot_list=PLOT_LIST) if nart.story: nart.build() nart.story.start_recovery(camp) self.did_recovery = True
def HOSPITAL_ENTER(self, camp): pbge.alert("You wake up in the hospital.") for p in self.plots_to_run: p.start_recovery(camp) self.end_plot(camp)
def _fix_generator(self, camp: gears.GearHeadCampaign): pbge.alert( "You identify and solve the system error. The computer reboots without a hitch." ) self.fixed_computer = True camp.dole_xp(100, gears.stats.Repair) camp.dole_xp(100, gears.stats.Computers)
def _fix_generator(self, camp: gears.GearHeadCampaign): pbge.alert( "You repair the terminal. Soon the generator coils beneath your feet begin to hum with energy once more." ) self.fixed_generator = True camp.dole_xp(100, gears.stats.Repair) camp.dole_xp(100, gears.stats.Science)
def _try_to_fix_mkill(self, party, mkpc: gears.base.Mecha): total = 0 if mkpc.material is gears.materials.Biotech: used_skill = gears.stats.Biotechnology else: used_skill = gears.stats.Repair for pc in party: if pc.get_current_mental() > 0: pc.spend_mental(random.randint(1,4)+random.randint(1,4)) total += max(pc.get_skill_score(gears.stats.Craft, used_skill), random.randint(1, 5)) my_invo = pbge.effects.Invocation( name = 'Repair', fx=gears.geffects.DoHealing( 1, max(total,5), repair_type=mkpc.material.repair_type, anim = gears.geffects.RepairAnim, ), area=pbge.scenes.targetarea.SingleTarget(), targets=1) my_invo.invoke(self.camp, None, [mkpc.pos], pbge.my_state.view.anim_list) pbge.my_state.view.handle_anim_sequence() mkpc.gear_up(self.scene) if mkpc.get_current_speed() > 0: pbge.alert("The repairs are successful; {} is able to move again.".format(mkpc.get_pilot())) else: pbge.alert("The repairs failed. You are forced to leave {} behind.".format(mkpc.get_pilot())) self.scene.contents.remove(mkpc)
def t_COMBATLOOP(self, camp: gears.GearHeadCampaign): myteam = self.elements["_eteam"] if self.cetus.current_health < (self.cetus.max_health // 2) or not self.cetus.is_operational(): self.cetus.restore_all() pbge.alert( "The eye of Cetus glows brightly for a moment, and then unleashes a wave of energy." ) pbge.my_state.view.play_anims( gears.geffects.BiotechnologyAnim(pos=self.cetus.pos)) my_invo = pbge.effects.Invocation( fx=gears.geffects.DoDamage(3, 6, anim=gears.geffects.DeathWaveAnim, scale=gears.scale.MechaScale, is_brutal=True), area=pbge.scenes.targetarea.SelfCentered(radius=5, delay_from=-1, exclude_middle=True)) pbge.my_state.view.anim_list.append( gears.geffects.InvokeDeathWaveAnim(pos=self.cetus.pos)) my_invo.invoke(camp, self.cetus, [ self.cetus.pos, ], pbge.my_state.view.anim_list) pbge.my_state.view.handle_anim_sequence() pbge.alert( "Cetus rockets into the air and quickly disappears from sight." ) pbge.my_state.view.play_anims( gears.geffects.SmokePoof(pos=self.cetus.pos), pbge.scenes.animobs.BlastOffAnim(model=self.cetus)) camp.scene.contents.remove(self.cetus)
def unlocked_use( self, camp ): # Perform this waypoint's special action. if self.dest_scene and self.dest_entrance: camp.destination = self.dest_scene camp.entrance = self.dest_entrance else: pbge.alert("This door doesn't seem to go anywhere.")
def METROSCENE_ENTER(self,camp: gears.GearHeadCampaign): if not self.started_convo: npc: gears.base.Character = self.elements["NPC"] pbge.alert("As you enter {METROSCENE}, {NPC} pulls you aside for a private talk.".format(**self.elements)) if npc.get_reaction_score(camp.pc, camp) > 20: ghcutscene.SimpleMonologueDisplay( "When we started, I was suspicious of you. I didn't know what kind of person you were. But now, after all we've been through, I do know. I want you to know that I believe in you and I'm glad to be your lancemate.", npc )(camp) npc.relationship.role = relationships.R_COLLEAGUE npc.relationship.attitude = relationships.A_FRIENDLY camp.dole_xp(200) self.proper_end_plot(camp) else: ghcutscene.SimpleMonologueDisplay( "When we started, I was suspicious of you. I didn't know what kind of person you were. But now, I do know, and I no longer want anything to do with you. If we ever meet again, it will be on opposite sides of the battlefield.", npc )(camp) npc.relationship.role = relationships.R_ADVERSARY npc.relationship.attitude = relationships.A_RESENT if relationships.RT_LANCEMATE in npc.relationship.tags: npc.relationship.tags.remove(relationships.RT_LANCEMATE) plotutility.AutoLeaver(npc)(camp) camp.freeze(npc) npc.relationship.history.append(gears.relationships.Memory( "I quit your lance", "you quit my lance", -10, (gears.relationships.MEM_Ideological,) )) self.proper_end_plot(camp) self.started_convo = True
def get_item(self): pc = self.camp.pc.get_root() candidates = [i for i in self.scene.contents if isinstance(i,gears.base.BaseGear) and i.pos == pc.pos and pc.can_equip(i)] if candidates: i = candidates.pop() pc.inv_com.append(i) pbge.alert("{} picks up {}.".format(pc,i)) self.camp.check_trigger("GET",i)
def LOCALE_ENTER(self, camp: gears.GearHeadCampaign): if self.intro_ready and not camp.campdata.get(DDBAMO_ENCOUNTER_ZOMBOTS, False): self.intro_ready = False camp.campdata[DDBAMO_ENCOUNTER_ZOMBOTS] = True pbge.alert( "The road ahead is blocked by hostile mecha. Ominously, your sensors cannot detect any energy readings from them, though they are clearly moving." )
def t_UPDATE(self, camp): if self.adv.is_completed() and not self.gave_ending_message: if self.adv.is_won(): if "WIN_MESSAGE" in self.elements: pbge.alert(self.elements["WIN_MESSAGE"]) elif "LOSS_MESSAGE" in self.elements: pbge.alert(self.elements["LOSS_MESSAGE"]) self.gave_ending_message = True
def _eteam_ACTIVATETEAM(self,camp): if self.intro_ready: npc = self.elements["NPC"] pbge.alert("As you approach the supposed crash site, the true nature of the falling star becomes clear: it's a lone mecha, having descended to Earth with an atmospheric drop chute. And from the look of things {}'s going to need your help.".format(npc.gender.subject_pronoun)) self.eteam_activated = True if not self.pilot_left: ghdialogue.start_conversation(camp,camp.pc,npc,cue=ghdialogue.HELLO_STARTER) camp.fight.active.append(self.elements["SURVIVOR"]) self.intro_ready = False
def _smash(self, camp: gears.GearHeadCampaign): pbge.alert( "You smash the computer until the lights stop blinking. Then you smash it a bit more just to be safe. If that doesn't take care of the zombie mecha problem, you're not sure what will.") self.zombots_active = False self.subplots["OUTENCOUNTER"].end_plot(camp) camp.check_trigger("WIN", self) BiotechDiscovery(camp, "I found an old zombot-infested biotech laboratory.", "[THATS_INTERESTING] I'll get one of our hazmat recovery teams to check it out. Here is the {cash} you've earned.", self.rank//2)
def t_START(self, camp): if self.intro_ready: myfac = self.elements.get("ENEMY_FACTION") if myfac: pbge.alert( "Without warning, you are ambushed by {}!".format(myfac)) else: pbge.alert("Without warning, you are ambushed by enemy mecha!") self.intro_ready = False
def start_adventure(self,camp): init = pbge.plots.PlotState(rank=1,elements={"ADVENTURE_EXIT":(self.elements["HOME_SCENE"],self.elements["HOME_BASE"])}) nart = NarrativeRequest(camp,init,adv_type="TEST_ADVENTURE",plot_list=PLOT_LIST) if nart.story: nart.build() #nart.story.start(camp) camp.check_trigger('UPDATE') else: pbge.alert("Narrative build failed. Bummer.")
def MISSION_WIN(self,camp): if not self.mission_finished: enemy_fac = self.elements.get(dd_tarot.ME_FACTION) if enemy_fac: pbge.alert("You approach the campsite of the Lunar refugees, and see that it has been utterly destroyed by {}.".format(enemy_fac)) else: pbge.alert("You approach the campsite of the Lunar refugees, and see that it has been utterly destroyed.") camp.check_trigger("WIN", self) self.mission_finished = True
def t_UPDATE(self, camp): # If the adventure has ended, get rid of it. if self.adventure_seed and self.adventure_seed.ended: if self.adventure_seed.is_won(): pbge.alert(self.adventure_seed.data["win_message"]) self.adventure_seed.data["win"](camp) else: pbge.alert(self.adventure_seed.data["lose_message"]) self.adventure_seed.data["lose"](camp) self.adventure_seed = None
def start_recovery(self, camp): dead_names = [str(npc) for npc in camp.dead_party] if len(camp.dead_party) > 2: msg = ', '.join(dead_names[:-2]) + ', and ' + dead_names[-1] elif len(camp.dead_party) > 1: msg = ' and '.join(dead_names) else: msg = dead_names[0] pbge.alert('{} did not survive the last mission.'.format(msg)) camp.dead_party = list()
def t_ENDCOMBAT(self,camp): myteam = self.elements["_eteam"] cargoteam = self.elements["_cargoteam"] if len(cargoteam.get_active_members(camp)) < 1: self.obj.failed = True elif len(myteam.get_active_members(camp)) < 1: self.obj.win(camp,(sum([(100-c.get_percent_damage_over_health()) for c in cargoteam.get_active_members(camp)]))//self.starting_number_of_containers ) if not self.combat_finished: pbge.alert("You have captured the cargo.") self.combat_finished = True
def t_ENDCOMBAT(self,camp): myteam = self.elements["_eteam"] cargoteam = self.elements["_cargoteam"] if len(cargoteam.get_active_members(camp)) < 1: self.obj.failed = True elif len(myteam.get_active_members(camp)) < 1: self.obj.win((sum([(100-c.get_total_damage_status()) for c in cargoteam.get_active_members(camp)]))//self.starting_number_of_containers ) if not self.combat_finished: pbge.alert("The missing cargo has been secured.") self.combat_finished = True
def _choose_peace(self, camp: gears.GearHeadCampaign): self.peace_npc.relationship.reaction_mod += random.randint(1, 10) npc = self.elements["_commander"] if camp.make_skill_roll(gears.stats.Ego, gears.stats.Negotiation, npc.renown): ghcutscene.SimpleMonologueDisplay("[CHANGE_MIND_AND_RETREAT]", npc) pbge.alert("Your challengers flee the battlefield.") self.elements["_eteam"].retreat(camp) camp.check_trigger("ENDCOMBAT")
def _shutdown(self, camp: gears.GearHeadCampaign): pbge.alert( "You activate the emergency shutdown. For the first time in nearly two hundred years, the computer powers off and comes to a rest.") self.zombots_active = False self.safe_shutdown = True if self.beta_full: self.set_collector = True self.subplots["OUTENCOUNTER"].end_plot(camp) camp.check_trigger("WIN", self) BiotechDiscovery(camp, "I found a PreZero lab where they were developing self-repair technology", "[THATS_INTERESTING] This could be a very important discovery; I'd say it's easily worth {cash}.", self.rank+15)
def _eteam_ACTIVATETEAM(self, camp): if not self.combat_entered: pbge.alert( "As you approach the supposed crash site, it becomes clear what the meteor actually was: a cargo pod dropped from low orbit. It also becomes clear who the cargo belongs to..." ) npc = self.elements["_commander"] ghdialogue.start_conversation(camp, camp.pc, npc, cue=ghdialogue.ATTACK_STARTER) self.combat_entered = True
def _eteam_ACTIVATETEAM(self, camp): if not self.combat_entered: pbge.alert( "As you approach the supposed crash site, it becomes clear what the meteor actually was: it's a cargo pod containing a few souped-up mecha. And the recipients of the delivery have already claimed it..." ) npc = self.elements["_commander"] ghdialogue.start_conversation(camp, camp.pc, npc, cue=ghdialogue.ATTACK_STARTER) self.combat_entered = True
def find_clue_from_puzzleitem(self, beta, camp): pbge.alert("You discover evidence that {} {}.".format(self.elements[ME_PERSON], beta.elements[ME_CRIMED]))
def _RevealEvidence_WIN(self, camp): if not self.visible: pbge.alert( "You discover evidence linking {} to {}.".format(self.elements[ME_PERSON], self.elements[ME_CRIME])) self.memo = "You discovered evidence that {} {}.".format(self.elements[ME_PERSON], self.elements[ME_CRIMED]) self.reveal(camp)