Skip to content

Commit

Permalink
Added priority outcomes; did more work on quest system
Browse files Browse the repository at this point in the history
  • Loading branch information
jwvhewitt committed Jan 18, 2024
1 parent 0aede91 commit be004bc
Show file tree
Hide file tree
Showing 7 changed files with 433 additions and 91 deletions.
1 change: 1 addition & 0 deletions game/content/ghchallenges.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def __init__(self, objective, mission_desc,
# challenge_subject = A list of subjects to be used when asking about the rumor; noun phrase
# mission_intros = A list of rough descriptions of mission for mission-giver to give; primary clause
# mission_builder = A function with signature (camp, npc) that builds the mission
# priority_mission = Mission rumors will be delivered more directly than normal if this value is truthy.
#


Expand Down
20 changes: 17 additions & 3 deletions game/content/ghplots/challengeplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from game.content.ghcutscene import SimpleMonologueDisplay
from game.content import adventureseed, GHNarrativeRequest
from . import missionbuilder, rwme_objectives, campfeatures, randomplots
import collections


class TimeAndChallengeExpiration(object):
Expand Down Expand Up @@ -824,17 +825,20 @@ def custom_init(self, nart: GHNarrativeRequest):
self.register_element("ENEMY_FACTION", mychallenge.key[0])
self.expiration = TimeAndChallengeExpiration(nart.camp, mychallenge, time_limit=5)

rumor_text = random.choice(mychallenge.data["challenge_rumors"])
self.rumor_text = random.choice(mychallenge.data["challenge_rumors"])
self.RUMOR = Rumor(
rumor_text,
self.rumor_text,
offer_msg="{NPC} at {NPC_SCENE} is looking for someone to " + random.choice(mychallenge.data["challenge_summaries"])+". [IF_YOU_WANT_MISSION_GO_ASK_ABOUT_IT]",
offer_subject=rumor_text,
offer_subject=self.rumor_text,
offer_subject_data=random.choice(mychallenge.data["challenge_subject"]),
memo="{NPC} at {NPC_SCENE} is looking for someone to " + random.choice(mychallenge.data["challenge_summaries"])+".",
prohibited_npcs=("NPC",),
npc_is_prohibited_fun=plotutility.ProhibitFactionAndPCIfAllied("ENEMY_FACTION")
)

# See whether to prioritize this mission.
self.prioritize = mychallenge.data.get("priority_mission", False)

# Create the mission seed.
self.mission_seed = mychallenge.data["mission_builder"](nart.camp, npc)

Expand Down Expand Up @@ -884,6 +888,16 @@ def NPC_offers(self, camp: gears.GearHeadCampaign):

return mylist

def _get_dialogue_grammar(self, npc, camp):
# The secret private function that returns custom grammar.
mygram = collections.defaultdict(list)
if self.prioritize and not self._rumor_memo_delivered:
plot_npc = self.elements["NPC"]
my_challenge = self.elements["CHALLENGE"]
if npc is not plot_npc and camp.is_not_lancemate(npc) and my_challenge.is_involved(camp, npc):
mygram["[CURRENT_EVENTS]"].append("[chat_lead_in] {}.".format(self.rumor_text))
return mygram

def t_UPDATE(self,camp):
if self.mission_seed.ended:
self.end_plot(camp)
Expand Down
2 changes: 1 addition & 1 deletion game/content/ghplots/dd_homebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def custom_init(self, nart):
)

self.add_sub_plot(nart, "DZD_SKIPPYSNIGHTOUT")
self.add_sub_plot(nart, "WMWO_IRON_FIST", elements={"OCCUPIER": gears.factions.BioCorp, "RESISTANCE_FACTION": gears.factions.TerranFederation})
self.add_sub_plot(nart, "WMWO_IRON_FIST", elements={"OCCUPIER": gears.factions.TerranFederation, "RESISTANCE_FACTION": gears.factions.BioCorp})

self.intro_ready = True

Expand Down
428 changes: 348 additions & 80 deletions game/content/ghplots/ghquests.py

Large diffs are not rendered by default.

31 changes: 25 additions & 6 deletions game/content/ghplots/warplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def custom_init(self, nart):
self.elements["METROSCENE"], self.elements["OCCUPIER"]
), priority=True
),
]
], prioritize_lore=True
)

oc2 = quests.QuestOutcome(
Expand All @@ -93,7 +93,7 @@ def custom_init(self, nart):
self.elements["METROSCENE"], self.elements["OCCUPIER"]
), priority=True
)
]
], prioritize_lore=False
)

myquest = self.register_element(quests.QUEST_ELEMENT_ID, quests.Quest(
Expand Down Expand Up @@ -148,8 +148,27 @@ def custom_init(self, nart):
}, involvement = ghchallenges.InvolvedMetroFactionNPCs(
self.elements["METROSCENE"], self.elements["OCCUPIER"]
), priority=True
),
quests.QuestLore(
ghquests.LORECAT_MOTIVE, texts={
quests.TEXT_LORE_HINT: "{RESISTANCE_FACTION} must be destroyed".format(
**self.elements),
quests.TEXT_LORE_INFO: "{OCCUPIER}'s control of {METROSCENE} will never be complete as long as {RESISTANCE_FACTION} exists".format(
**self.elements),
quests.TEXT_LORE_TOPIC: "the {RESISTANCE_FACTION} resistance".format(**self.elements),
quests.TEXT_LORE_SELFDISCOVERY: "You learned that {RESISTANCE_FACTION} has been trying to drive {OCCUPIER} from {METROSCENE}.".format(
**self.elements),
quests.TEXT_LORE_TARGET_TOPIC: "{OCCUPIER}'s control of {METROSCENE}".format(**self.elements),
quests.TEXT_LORE_MEMO: "{RESISTANCE_FACTION} is attempting to drive {OCCUPIER} out of {METROSCENE}.".format(
**self.elements),
ghquests.L_MOTIVE_CONFESSION: "{RESISTANCE_FACTION} will free {METROSCENE} from {OCCUPIER}".format(
**self.elements),
}, involvement=ghchallenges.InvolvedMetroFactionNPCs(
self.elements["METROSCENE"], self.elements["OCCUPIER"]
),
tags=(ghquests.LORETAG_ENEMY, ghquests.LORETAG_PRIMARY),
)
]
], prioritize_lore=True
)

oc2 = quests.QuestOutcome(
Expand Down Expand Up @@ -188,7 +207,7 @@ def custom_init(self, nart):
tags=(ghquests.LORETAG_ENEMY, ghquests.LORETAG_PRIMARY),
)

]
], prioritize_lore=False
)

myquest = self.register_element(quests.QUEST_ELEMENT_ID, quests.Quest(
Expand Down Expand Up @@ -249,7 +268,7 @@ def custom_init(self, nart):
self.elements["METROSCENE"], self.elements["OCCUPIER"]
), priority=True
)
]
], prioritize_lore=True
)

oc2 = quests.QuestOutcome(
Expand All @@ -269,7 +288,7 @@ def custom_init(self, nart):
self.elements["METROSCENE"], self.elements["OCCUPIER"]
), priority=True
)
]
], prioritize_lore=False
)

myquest = self.register_element(quests.QUEST_ELEMENT_ID, quests.Quest(
Expand Down
36 changes: 36 additions & 0 deletions game/ghdialogue/ghgrammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6122,6 +6122,42 @@
]
},

"[YOU_WILL_NEVER_DEFEAT_US]": {
# A final cry of defiance. Or a promise to be kept.
Default: ["You will never defeat us!",
"We cannot be defeated so easily!"
],
personality.Cheerful: [
"You look pretty smug for someone who doesn't realize the tacnuke of worms you've just unleashed!",
],
personality.Grim: [
"Some of us may die, but we will never be defeated!",
],
personality.Easygoing: [
"Yeah, you know we don't give up easy, right?",
],
personality.Passionate: [
"I pledge with my burning heart that we will never be defeated!",
],
personality.Sociable: [
"Our allegiance is unshakable; so long as one of us lives, we can never be defeated!",
],
personality.Shy: ["We aren't going to be defeated.",
],
personality.Peace: [
"We will never admit defeat to barbarians like you."
],
personality.Duty: [
"As long as I draw breath, I will not admit defeat."
],
personality.Fellowship: [
"We stand together, and together we will be victorious!"
],
personality.Glory: [
"You are not worthy of defeating us."
]
},

"[FORMAL_MECHA_DUEL]": {
Default: ["May your armor break, may your cockpit shatter, may who deserves to win, be who destroys the other."
],
Expand Down
6 changes: 5 additions & 1 deletion pbge/quests.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __call__(self, camp):


class QuestOutcome:
def __init__(self, verb=VERB_DEFEAT, target=None, involvement=None, win_effect=None, loss_effect=None, lore=()):
def __init__(self, verb=VERB_DEFEAT, target=None, involvement=None, win_effect=None, loss_effect=None, lore=(), prioritize_lore=True):
# verb is what's gonna happen in this outcome.
# target is the Quest Element ID of the object of the verb. Except you can't say object in Python because that
# word has a different meaning here than it does in English grammar.
Expand All @@ -117,6 +117,9 @@ def __init__(self, verb=VERB_DEFEAT, target=None, involvement=None, win_effect=N
# loss_effect is a callable of form "loss_effect(camp)" which is called if/when this outcome fails or
# bcomes unwinnable.
# lore is a list of lore that may be selected by a conclusion leading to this outcome.
# prioritize_lore is True if the lore should be pushed at the player as strongly as possible.
# Set this to True if you have a quest with narrow involvement and don't want the player to be chasing down
# rumors for a long time.
self.verb = verb
self.target = target
self.involvement = involvement
Expand All @@ -126,6 +129,7 @@ def __init__(self, verb=VERB_DEFEAT, target=None, involvement=None, win_effect=N
for l in self.lore:
if not l.outcome:
l.outcome = self
self.prioritize_lore = prioritize_lore

def is_involved(self, camp, npc):
if not self.involvement:
Expand Down

0 comments on commit be004bc

Please sign in to comment.