Skip to content

Commit

Permalink
Added corporate mission; MissionText now used
Browse files Browse the repository at this point in the history
  • Loading branch information
jwvhewitt committed Nov 20, 2024
1 parent 859bfa0 commit 865f993
Show file tree
Hide file tree
Showing 14 changed files with 309 additions and 51 deletions.
4 changes: 2 additions & 2 deletions design/Monster_Bugs.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Monster
name = "Sun Scarab"
statline = {Reflexes = 16, Body=13, Speed=11, Perception=8, Craft=2, Knowledge=1, Ego=15, Charm = 5,
CloseCombat = 5, RangedCombat = 3, Dodge = 8
CloseCombat = 5, RangedCombat = 3, Dodge = 6
}
scale = HumanScale
imagename = 'mon_bugs.png'
Expand Down Expand Up @@ -82,7 +82,7 @@ Monster
Monster
name = "Black Scarab"
statline = {Reflexes = 10, Body=12, Speed=9, Perception=7, Craft=2, Knowledge=1, Ego=15, Charm = 2,
CloseCombat = 4, Dodge = 4
CloseCombat = 4, Dodge = 3
}
scale = HumanScale
imagename = 'mon_bugs.png'
Expand Down
2 changes: 1 addition & 1 deletion design/Monster_Dinosaurs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Monster
imagename = 'mon_dinosaurs_ps.png'
frame = 0
colors = (AceScarlet,Cream,Malachite,Avocado,Saffron)
threat = 30
threat = 35
type_tags = ("DINOSAUR", ""EXOTIC", "CAVE", "DESERT", "REPTILE",)
families = ("DINOSAUR",)
environment_list = (GroundEnv,UrbanEnv)
Expand Down
2 changes: 1 addition & 1 deletion design/Monster_Robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ Monster
Monster
name = "Forgebot"
statline = {Reflexes = 8, Body=24, Speed=8, Perception=8, Craft=13, Knowledge=1, Ego=1, Charm = 1,
CloseCombat = 4, RangedCombat = 4, Dodge = 9, Vitality = 10, Athletics = 8, Concentration=5
CloseCombat = 4, RangedCombat = 4, Dodge = 7, Vitality = 10, Athletics = 8, Concentration=5
}
scale = HumanScale
material = Metal
Expand Down
6 changes: 3 additions & 3 deletions design/Monster_Synths.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Monster
Monster
name = "Hunter-Drone"
statline = {Reflexes = 16, Body=15, Speed=16, Perception=10, Craft=6, Knowledge=5, Ego=7, Charm = 4,
CloseCombat = 7, RangedCombat=4, Dodge = 8, Biotechnology = 4
CloseCombat = 7, RangedCombat=4, Dodge = 4, Biotechnology = 4
}
scale = HumanScale
imagename = 'mon_synth.png'
Expand Down Expand Up @@ -178,7 +178,7 @@ Monster
Monster
name = "Hunter-Scout"
statline = {Reflexes = 16, Body=14, Speed=18, Perception=17, Craft=7, Knowledge=5, Ego=8, Charm = 4,
CloseCombat = 6, RangedCombat=7, Dodge = 7, Scouting = 6, Stealth = 8
CloseCombat = 6, RangedCombat=7, Dodge = 5, Scouting = 6, Stealth = 8
}
scale = HumanScale
imagename = 'mon_synth.png'
Expand Down Expand Up @@ -394,7 +394,7 @@ Monster
Monster
name = "Servitor"
statline = {Reflexes = 14, Body=16, Speed=15, Perception=17, Craft=17, Knowledge=18, Ego=23, Charm = 12,
CloseCombat = 5, RangedCombat=5, Dodge = 8, Concentration = 5, Biotechnology = 7
CloseCombat = 5, RangedCombat=5, Dodge = 6, Concentration = 5, Biotechnology = 7
}
scale = HumanScale
imagename = 'mon_synth.png'
Expand Down
2 changes: 1 addition & 1 deletion design/Monster_Zombots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Monster
name = "Cyber Arm"
statline = {Reflexes = 13, Body=6, Speed=13, Perception=5, Craft=6, Knowledge=3, Ego=12, Charm = 5,
CloseCombat = 8, RangedCombat = 3, Dodge = 4
CloseCombat = 8, RangedCombat = 3, Dodge = 3
}
scale = HumanScale
material = Metal
Expand Down
13 changes: 13 additions & 0 deletions game/content/ghplots/campfeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ def t_START(self, camp):
self._resolve_unfound_plot(camp)
break

# Attempt to load the test plot.
if self.should_load_test(camp):
myplot = game.content.load_dynamic_plot(
camp, "TEST_RANDOM_PLOT", pstate=PlotState(
rank=self.calc_rank(camp)
).based_on(self)
)

def _resolve_unfound_plot(self, camp):
# Do whatever needs to be done when a plot could not be found. Not used here, but might get used in subclasses.
pass
Expand All @@ -247,6 +255,11 @@ def should_load_plot(self, camp):
lp = len([p for p in mymetro.scripts if p.LABEL in self.ALL_RANDOM_PLOT_TYPES])
return lp < self.MAX_PLOTS

def should_load_test(self, camp):
mymetro: gears.MetroData = self.elements["METRO"]
lp = len([p for p in mymetro.scripts if p.LABEL == "TEST_RANDOM_PLOT"])
return lp < 1

def calc_rank(self, camp: gears.GearHeadCampaign):
if self.elements.get("USE_PLOT_RANK", False):
# If the player's renown is higher than this plot rank, adjust things upward, but not all the way.
Expand Down
56 changes: 42 additions & 14 deletions game/content/ghplots/dd_homebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import game.content.gharchitecture
import pbge
import game.content.plotutility
from game.content import ghwaypoints, gharchitecture, plotutility, ghrooms, dungeonmaker, ghchallenges, ghcutscene
from game.content import ghwaypoints, gharchitecture, plotutility, ghrooms, dungeonmaker, ghchallenges, ghcutscene, missiontext
import game.content.ghterrain
from game.content.ghplots.dd_combatmission import CombatMissionSeed
import random
Expand Down Expand Up @@ -903,9 +903,9 @@ class DZD_BlueFortressHQ(Plot):

active = True
scope = "METRO"

# Compatibility var- for v0.540
got_tutorial = False
mission_active = False
mission_description = "go fight someone"

def custom_init(self, nart):
# Create a building within the town.
Expand Down Expand Up @@ -975,7 +975,7 @@ def custom_init(self, nart):
return True

def MISSION_GATE_menu(self, camp, thingmenu):
if self.adventure_seed:
if self.adventure_seed and self.mission_active:
thingmenu.add_item(self.adventure_seed.name, self.adventure_seed)

ENEMY_FACTIONS = (factions.AegisOverlord, factions.AegisOverlord, factions.ClanIronwind, factions.ClanIronwind,
Expand All @@ -985,14 +985,30 @@ def generate_enemy_faction(self):
# Randomly determine an enemy faction.
return random.choice(self.ENEMY_FACTIONS)

OBJECTIVES = (
missionbuilder.BAMO_LOCATE_ENEMY_FORCES, missionbuilder.BAMO_DEFEAT_COMMANDER,
missionbuilder.BAMO_EXTRACT_ALLIED_FORCES, missionbuilder.BAMO_RESPOND_TO_DISTRESS_CALL,
missionbuilder.BAMO_RECOVER_CARGO
)

def register_adventure(self, camp):
self.adventure_seed = CombatMissionSeed(camp, "{}'s mission against {}".format(self.elements["DISPATCHER"], self.next_enemy_faction),
self.elements["LOCALE"], self.elements["MISSION_GATE"],
enemy_faction=self.next_enemy_faction,
allied_faction=factions.TerranDefenseForce,
architecture=gharchitecture.MechaScaleGreenzone(),
on_win=self._win_mission)
objectives = random.sample(self.OBJECTIVES, 2)
mission_text = missiontext.MissionText(camp, objectives, self.elements["LOCALE"], allied_faction=factions.TerranDefenseForce, enemy_faction=self.next_enemy_faction)
self.mission_description = mission_text.mission_description
self.adventure_seed = missionbuilder.BuildAMissionSeed(
camp, "{}'s mission against {}".format(self.elements["DISPATCHER"], self.next_enemy_faction),
self.elements["LOCALE"], self.elements["MISSION_GATE"],
enemy_faction=self.next_enemy_faction,
allied_faction=factions.TerranDefenseForce,
objectives=objectives, rank=max(camp.pc.renown + 1, 10),
mission_grammar = missionbuilder.MissionGrammar(**mission_text.get_mission_grammar_dict()),
architecture=gharchitecture.MechaScaleGreenzone(),
on_win=self._win_mission
)

def _activate_mission(self, camo):
missionbuilder.NewMissionNotification(self.adventure_seed.name, self.elements["MISSION_GATE"])
self.mission_active = True

def _win_mission(self, camp: gears.GearHeadCampaign):
self.total_mission_wins += 1
Expand All @@ -1009,6 +1025,7 @@ def t_UPDATE(self, camp):
# If the adventure has ended, get rid of it.
if self.adventure_seed and self.adventure_seed.ended:
self.adventure_seed = None
self.mission_active = False
self.next_enemy_faction = self.generate_enemy_faction()

def DISPATCHER_offers(self, camp: gears.GearHeadCampaign):
Expand All @@ -1018,12 +1035,22 @@ def DISPATCHER_offers(self, camp: gears.GearHeadCampaign):
if self.not_yet_told_no_missions_left and not self.adventure_seed:
mylist.append(
Offer(
"Sorry, but you've done such a good job defending Wujung, there aren't any missions left for you to do.",
"Sorry, but you've done such a good job defending Wujung, I don't have anything else for you to do. Maybe one of the other officers here has a job available.",
context=ContextTag([context.MISSION, ]), effect=self._tell_no_missions,
)
)

elif camp.time >= self.next_mission_date and not self.adventure_seed:
elif camp.time >= self.next_mission_date and not (self.mission_active and self.adventure_seed):
if not self.adventure_seed:
self.register_adventure(camp)

mylist.append(
Offer(
"[HELLO] If you're looking for a mission, you've come to the right place.",
context=ContextTag([context.HELLO, context.MISSION ])
)
)

mylist.append(
Offer(
"The Defense Force is short handed at the moment, so there are almost always missions available. [MechaMissionVsEnemyFaction].",
Expand All @@ -1034,8 +1061,8 @@ def DISPATCHER_offers(self, camp: gears.GearHeadCampaign):

mylist.append(
Offer(
"[IWillSendMissionDetails]. You can start the mission by heading to the West Gate.",
context=ContextTag([context.ACCEPT, ]), subject=self, effect=self.register_adventure,
"{}. You can start the mission by heading to the West Gate.".format(self.mission_description),
context=ContextTag([context.ACCEPT, ]), subject=self, effect=self._activate_mission,
data={"enemy_faction": self.next_enemy_faction.name}
)
)
Expand Down Expand Up @@ -1820,6 +1847,7 @@ def _tell_about_services(self, camp: gears.GearHeadCampaign):
camp.check_trigger("UPDATE")
self._asked_about_construction = True
camp.campdata["CONSTRUCTION_ARRANGED"] = True
#self.locked_elements.remove(self.elements["REGEXNPC"])

def DISPATCHER_offers(self, camp):
mylist = list()
Expand Down
2 changes: 1 addition & 1 deletion game/content/ghplots/missionbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def __init__(self, camp, name, metroscene, return_wp, enemy_faction=None, allied
self.solo_mission = solo_mission
if not mission_grammar:
mission_grammar = MissionGrammar(**missiontext.MissionText(
camp, self.objectives, metroscene, allied_faction, enemy_faction).get_mission_grammar_dict()
camp, objectives, metroscene, allied_faction, enemy_faction).get_mission_grammar_dict()
)
self.mission_grammar = mission_grammar
self.make_enemies = make_enemies
Expand Down
109 changes: 105 additions & 4 deletions game/content/ghplots/randomplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pygame
import random
from game import teams, ghdialogue
from game.content import gharchitecture, ghterrain, ghwaypoints, plotutility, ghcutscene
from game.content import gharchitecture, ghterrain, ghwaypoints, plotutility, ghcutscene, missiontext
from pbge.dialogue import Offer, ContextTag, Reply
from game.ghdialogue import context
from game.content.ghcutscene import SimpleMonologueDisplay
Expand Down Expand Up @@ -182,6 +182,104 @@ def _get_dialogue_grammar(self, npc, camp):
return {"[News]": ["{NPC} likes cookies".format(**self.elements)]}


class CorpMissionRandom(Plot):
LABEL = "RANDOM_PLOT"
active = True
scope = "METRO"
RUMOR = Rumor(
"{NPC} needs a cavalier to do some kind of mission for {ALLIED_FACTION}",
offer_msg="You need to talk to {NPC} at {NPC_SCENE}. [IF_YOU_WANT_MISSION_GO_ASK_ABOUT_IT]",
offer_subject="{NPC} needs a cavalier to do some kind of mission for {ALLIED_FACTION}",
offer_subject_data="{NPC}'s mission",
memo="{NPC} is looking for a pilot to do a mission for {ALLIED_FACTION}.",
prohibited_npcs=("NPC",)
)

OBJECTIVES = (
missionbuilder.BAMO_LOCATE_ENEMY_FORCES, missionbuilder.BAMO_DEFEAT_COMMANDER,
missionbuilder.BAMO_CAPTURE_BUILDINGS, missionbuilder.BAMO_EXTRACT_ALLIED_FORCES,
missionbuilder.BAMO_RECOVER_CARGO, missionbuilder.BAMO_PROTECT_BUILDINGS,
missionbuilder.BAMO_CAPTURE_THE_MINE
)

def custom_init(self, nart):
npc = self.seek_element(nart, "NPC", self._is_good_npc, lock=True, scope=self.elements["METROSCENE"])
self.register_element("ALLIED_FACTION", npc.faction)
self.register_element("NPC_SCENE", npc.scene)
ef = self.register_element("ENEMY_FACTION", nart.camp.get_enemy_faction(self.elements["NPC"]))
if ef:
self.expiration = TimeExpiration(nart.camp)

sgen, archi = gharchitecture.get_mecha_encounter_scenegen_and_architecture(self.elements["METROSCENE"])
objectives=random.sample(self.OBJECTIVES, 2)
mission_text = missiontext.MissionText(nart.camp, objectives, self.elements["METROSCENE"], allied_faction=npc.faction, enemy_faction=ef)
# Create the mission seed.
self.mission_seed = missionbuilder.BuildAMissionSeed(
nart.camp, "{NPC}'s Mission for {ALLIED_FACTION}".format(**self.elements),
self.elements["METROSCENE"], self.elements["MISSION_GATE"],
allied_faction=npc.faction,
enemy_faction=self.elements["ENEMY_FACTION"], rank=self.rank,
objectives=objectives,
one_chance=True, mission_grammar=missionbuilder.MissionGrammar(**mission_text.get_mission_grammar_dict()),
scenegen=sgen, architecture=archi,
cash_reward=90, make_enemies=False
)

set_npc_recharge(npc, nart.camp, time=10)
self.mission_active = False
return True

def _is_good_npc(self, nart, candidate):
if npc_is_ready_for_plot(candidate, nart.camp) and nart.camp.is_not_lancemate(candidate):
faction_ok = candidate.faction and gears.tags.CorporateWorker in candidate.faction.factags
scene_ok = gears.tags.SCENE_PUBLIC in candidate.scene.attributes
return faction_ok and scene_ok

def NPC_offers(self, camp):
mylist = list()

if not self.mission_active:
mylist.append(Offer(
"[LOOKING_FOR_CAVALIER] [CORPORATE_JOB_SPIEL]",
ContextTag([context.HELLO, context.MISSION]),
data={"corporate_faction": self.elements["ALLIED_FACTION"]}
))

mylist.append(Offer(
"[VAGUE_MISSION_DESCRIPTION] [DOYOUACCEPTMISSION]".format(
**self.elements),
ContextTag([context.MISSION]), data={"enemy_faction": self.elements["ENEMY_FACTION"]},
subject=self, subject_start=True
))

mylist.append(Offer(
"[IWillSendMissionDetails]. [PLEASURE_DOING_BUSINESS]",
ContextTag([context.ACCEPT]), effect=self.activate_mission,
subject=self
))

mylist.append(Offer(
"[UNDERSTOOD] [GOODBYE]",
ContextTag([context.DENY]), effect=self.end_plot,
subject=self
))

return mylist

def t_UPDATE(self, camp):
if self.mission_seed.ended:
self.end_plot(camp)

def activate_mission(self, camp):
self.mission_active = True
self.expiration = None
missionbuilder.NewMissionNotification(self.mission_seed.name, self.elements["MISSION_GATE"])

def MISSION_GATE_menu(self, camp, thingmenu):
if self.mission_seed and self.mission_active:
thingmenu.add_item(self.mission_seed.name, self.mission_seed)


class Entropy(Plot):
# Nothing is happening. I am just wasting a plot slot so the player can't stay in the same place and milk plots
# forever.
Expand Down Expand Up @@ -237,14 +335,17 @@ def custom_init(self, nart):
self.expiration = TimeExpiration(nart.camp)

sgen, archi = gharchitecture.get_mecha_encounter_scenegen_and_architecture(self.elements["METROSCENE"])
objectives=random.sample(self.OBJECTIVES, 2)
mission_text = missiontext.MissionText(nart.camp, objectives, self.elements["METROSCENE"], allied_faction=npc.faction, enemy_faction=ef)
self.elements["MISSION_DESC"] = mission_text.mission_description
# Create the mission seed.
self.mission_seed = missionbuilder.BuildAMissionSeed(
nart.camp, "{NPC}'s Mission against {ENEMY_FACTION}".format(**self.elements),
self.elements["METROSCENE"], self.elements["MISSION_GATE"],
allied_faction=npc.faction,
enemy_faction=self.elements["ENEMY_FACTION"], rank=self.rank,
objectives=random.sample(self.OBJECTIVES, 2),
one_chance=True,
objectives=objectives,
one_chance=True, mission_grammar=missionbuilder.MissionGrammar(**mission_text.get_mission_grammar_dict()),
scenegen=sgen, architecture=archi,
cash_reward=100
)
Expand All @@ -269,7 +370,7 @@ def NPC_offers(self, camp):
))

mylist.append(Offer(
"Mecha from {ENEMY_FACTION} have been operating near {METROSCENE}. [DOYOUACCEPTMISSION]".format(
"Mecha from {ENEMY_FACTION} have been operating near {METROSCENE}. {MISSION_DESC}. [DOYOUACCEPTMISSION]".format(
**self.elements),
ContextTag([context.MISSION]), data={"enemy_faction": self.elements["ENEMY_FACTION"]},
subject=self, subject_start=True
Expand Down
Loading

0 comments on commit 865f993

Please sign in to comment.