Skip to content

Commit

Permalink
Added Break Through mission objective
Browse files Browse the repository at this point in the history
  • Loading branch information
jwvhewitt committed Jan 22, 2024
1 parent be004bc commit ab0b75a
Show file tree
Hide file tree
Showing 17 changed files with 451 additions and 44 deletions.
4 changes: 2 additions & 2 deletions design/Secutor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ Mecha
reach=1
damage=3
accuracy=2
penetration=3
penetration=4
attributes = (Flail,Brutal)
END
Mount
name = "Right Arm Mount"
INV
BallisticWeapon
name = "Arena Cannon"
reach = 6
reach = 5
damage = 3
accuracy = 2
penetration = 2
Expand Down
6 changes: 5 additions & 1 deletion game/combat/targetingui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from .. import invoker



class WeaponMenuDesc( pbge.frects.Frect ):
def __init__(self, dx, dy, w, h, anchor):
super(WeaponMenuDesc, self).__init__(dx, dy, w, h, anchor=anchor)
Expand All @@ -17,11 +16,13 @@ def __call__( self, menu_item ):
myrect = self.get_rect()
self.library[menu_item.value.source].render(myrect.x,myrect.y)


class AttackWidget(invoker.InvocationsWidget):
DESC_CLASS = WeaponMenuDesc
IMAGE_NAME = 'sys_tacticsinterface_attackwidget.png'
MENU_POS = (-420,15,200,180)
DESC_POS = (-200, 15, 180, 180)

def __init__(self, camp, pc, build_library_function, update_callback, start_source=None, **kwargs):
super().__init__(camp, pc, build_library_function, update_callback, start_source, **kwargs)
self.ammo_label = pbge.widgets.LabelWidget(26, self.label.dy+self.label.h, 212, 14,
Expand All @@ -30,6 +31,7 @@ def __init__(self, camp, pc, build_library_function, update_callback, start_sour
parent=self,anchor=pbge.frects.ANCHOR_UPPERLEFT,
justify=0, on_click=self.pop_invo_menu)
self.children.append(self.ammo_label)

def _get_ammo_str(self,wid):
if self.shelf and self.shelf.source and hasattr(self.shelf.source,"get_ammo_string"):
return self.shelf.source.get_ammo_string()
Expand All @@ -41,9 +43,11 @@ class TargetingUI(invoker.InvocationUI):
LIBRARY_WIDGET = AttackWidget
def __init__(self,camp,attacker,**kwargs):
super().__init__(camp,attacker,attacker.get_attack_library,**kwargs)

def activate( self ):
super(TargetingUI,self).activate()
self.my_widget.maybe_select_shelf_with_this_source(self.camp.fight.cstat[self.pc].last_weapon_used)

def launch(self):
self.camp.fight.cstat[self.pc].last_weapon_used = self.my_widget.shelf.source
super(TargetingUI,self).launch()
Expand Down
2 changes: 2 additions & 0 deletions game/content/ghplots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from . import localproblems
from . import military_places
from . import missionbuilder
from . import mission_bigobs
from . import mission_conversations
from . import mission_stubs
from . import mission_teamups
Expand Down Expand Up @@ -100,6 +101,7 @@ def harvest(mod):
harvest(localproblems)
harvest(military_places)
harvest(missionbuilder)
harvest(mission_bigobs)
harvest(mission_conversations)
harvest(mission_stubs)
harvest(mission_teamups)
Expand Down
195 changes: 195 additions & 0 deletions game/content/ghplots/mission_bigobs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
# bigobs are Big Objectives.
# These are not normally combined with other objectives, but form a complete mission in themselves.

from pbge.plots import Plot
import game
import gears
import pbge
import pygame
import random
from game import teams, ghdialogue
from game.content import gharchitecture, ghterrain, ghwaypoints, plotutility
from pbge.dialogue import Offer, ContextTag, Reply
from game.ghdialogue import context
from game.content.ghcutscene import SimpleMonologueDisplay
from game.content import adventureseed, ghcutscene, ghrooms
from .missionbuilder import MAIN_OBJECTIVE_VALUE, BAMO_TEST_MISSION, CONVO_CANT_WITHDRAW
from gears import champions
from game.content.dungeonmaker import DG_NAME, DG_ARCHITECTURE, DG_SCENE_TAGS, DG_MONSTER_TAGS, DG_TEMPORARY, \
DG_PARENT_SCENE, DG_EXPLO_MUSIC, DG_COMBAT_MUSIC, DG_DECOR
import copy

BAMO_BREAK_THROUGH = "BAMO_BREAK_THROUGH"


class BAM_ToTheOtherSide(Plot):
LABEL = BAMO_BREAK_THROUGH
active = True
scope = "LOCALE"

DEST_ANCHORS = {
pbge.randmaps.anchors.north: (
(pbge.randmaps.anchors.south, pbge.randmaps.anchors.southeast, pbge.randmaps.anchors.southwest),
(pbge.randmaps.anchors.south, pbge.randmaps.anchors.east, pbge.randmaps.anchors.southwest),
(pbge.randmaps.anchors.south, pbge.randmaps.anchors.southeast, pbge.randmaps.anchors.west),
),
pbge.randmaps.anchors.south: (
(pbge.randmaps.anchors.north, pbge.randmaps.anchors.northeast, pbge.randmaps.anchors.northwest),
(pbge.randmaps.anchors.north, pbge.randmaps.anchors.east, pbge.randmaps.anchors.northwest),
(pbge.randmaps.anchors.north, pbge.randmaps.anchors.northeast, pbge.randmaps.anchors.west),
),
pbge.randmaps.anchors.east: (
(pbge.randmaps.anchors.west, pbge.randmaps.anchors.northwest, pbge.randmaps.anchors.southwest),
(pbge.randmaps.anchors.west, pbge.randmaps.anchors.north, pbge.randmaps.anchors.southwest),
(pbge.randmaps.anchors.west, pbge.randmaps.anchors.northwest, pbge.randmaps.anchors.south),
),
pbge.randmaps.anchors.west: (
(pbge.randmaps.anchors.east, pbge.randmaps.anchors.northeast, pbge.randmaps.anchors.southeast),
(pbge.randmaps.anchors.east, pbge.randmaps.anchors.north, pbge.randmaps.anchors.southeast),
(pbge.randmaps.anchors.east, pbge.randmaps.anchors.northeast, pbge.randmaps.anchors.south),
),
pbge.randmaps.anchors.northeast: (
(pbge.randmaps.anchors.south, pbge.randmaps.anchors.southeast, pbge.randmaps.anchors.southwest),
(pbge.randmaps.anchors.south, pbge.randmaps.anchors.southeast, pbge.randmaps.anchors.west),
(pbge.randmaps.anchors.west, pbge.randmaps.anchors.northwest, pbge.randmaps.anchors.southwest),
(pbge.randmaps.anchors.west, pbge.randmaps.anchors.northwest, pbge.randmaps.anchors.south),
),
pbge.randmaps.anchors.northwest: (
(pbge.randmaps.anchors.south, pbge.randmaps.anchors.southeast, pbge.randmaps.anchors.southwest),
(pbge.randmaps.anchors.south, pbge.randmaps.anchors.east, pbge.randmaps.anchors.southwest),
(pbge.randmaps.anchors.east, pbge.randmaps.anchors.northeast, pbge.randmaps.anchors.southeast),
(pbge.randmaps.anchors.east, pbge.randmaps.anchors.northeast, pbge.randmaps.anchors.south),
),
pbge.randmaps.anchors.southeast: (
(pbge.randmaps.anchors.north, pbge.randmaps.anchors.northeast, pbge.randmaps.anchors.northwest),
(pbge.randmaps.anchors.north, pbge.randmaps.anchors.northeast, pbge.randmaps.anchors.west),
(pbge.randmaps.anchors.west, pbge.randmaps.anchors.northwest, pbge.randmaps.anchors.southwest),
(pbge.randmaps.anchors.west, pbge.randmaps.anchors.north, pbge.randmaps.anchors.southwest),
),
pbge.randmaps.anchors.southwest: (
(pbge.randmaps.anchors.north, pbge.randmaps.anchors.northeast, pbge.randmaps.anchors.northwest),
(pbge.randmaps.anchors.north, pbge.randmaps.anchors.east, pbge.randmaps.anchors.northwest),
(pbge.randmaps.anchors.east, pbge.randmaps.anchors.northeast, pbge.randmaps.anchors.southeast),
(pbge.randmaps.anchors.east, pbge.randmaps.anchors.north, pbge.randmaps.anchors.southeast),
),
}

def custom_init(self, nart):
myscene = self.elements["LOCALE"]
myfac = self.elements.get("ENEMY_FACTION")
entry_room: pbge.randmaps.rooms.Room = self.elements.get("ENTRANCE_ROOM")
entry_anchor = entry_room.anchor
dest_anchors = random.choice(self.DEST_ANCHORS[entry_anchor])

destroom = self.register_element("DESTINATION", ghrooms.IndicatedRoom(5, 5, anchor=dest_anchors[0]),
dident="LOCALE")
team2: teams.Team = self.register_element("_eteam", teams.Team(enemies=(myscene.player_team,)))

self.reinforcement_rooms = list()
for t in range(1, 3):
roomtype = self.elements["ARCHITECTURE"].get_a_room()
myroom = self.register_element("CORNER_ROOM_{}".format(t), roomtype(10, 10, anchor=dest_anchors[t]),
dident="LOCALE")
self.reinforcement_rooms.append(myroom)
myunit = gears.selector.RandomMechaUnit(self.rank, 100, myfac, myscene.environment, add_commander=False)
team2.deploy_in_room(myscene, myroom, myunit.mecha_list)

if random.randint(1, 3) != 3:
for t in range(random.randint(1, 2)):
roomtype = self.elements["ARCHITECTURE"].get_a_room()
self.register_element("DUD_ROOM_{}".format(t), roomtype(5, 5), dident="LOCALE")

myunit = gears.selector.RandomMechaUnit(self.rank, 150, myfac, myscene.environment, add_commander=True)
myroom = self.register_element("CENTER_ROOM",
pbge.randmaps.rooms.FuzzyRoom(10, 10, anchor=pbge.randmaps.anchors.middle),
dident="LOCALE")
team2.deploy_in_room(myscene, myroom, myunit.mecha_list)
if myfac:
commander = self.register_element(
"_commander", nart.camp.cast_a_combatant(myfac, self.rank + 20, allow_allies=True, myplot=self),
lock=True
)
plotutility.CharacterMover(nart.camp, self, commander, myscene, team2)
else:
self.register_element("_commander", myunit.commander)

self.obj = adventureseed.MissionObjective("Guide lance to end zone", MAIN_OBJECTIVE_VALUE * 3)
self.adv.objectives.append(self.obj)
self.obj2 = adventureseed.MissionObjective("Avoid taking damage", MAIN_OBJECTIVE_VALUE)
self.adv.objectives.append(self.obj2)

self.intro_ready = True
self.init_ready = True
self.party_size = 1
self.reinforcements_counter = 2

return True

def _eteam_ACTIVATETEAM(self, camp):
if self.intro_ready:
npc = self.elements["_commander"]
ghdialogue.start_conversation(camp, camp.pc, npc, cue=ghdialogue.ATTACK_STARTER)
self.intro_ready = False

def _commander_offers(self, camp):
mylist = list()
mylist.append(Offer("[HALT] [THIS_AREA_IS_UNDER_OUR_CONTROL] [LEAVE_THIS_BATTLE]",
context=ContextTag([context.ATTACK, ])))
mylist.append(Offer("I must [objective_ep]. [CHALLENGE]",
context=ContextTag([context.CHALLENGE, ])))
if not self.elements.get(CONVO_CANT_WITHDRAW, False):
mylist.append(Offer("[WITHDRAW]", effect=camp.scene.player_team.retreat,
context=ContextTag([context.WITHDRAW, ])))

return mylist

def t_START(self, camp: gears.GearHeadCampaign):
if self.init_ready:
myroom = self.elements["DESTINATION"]
for x in range(myroom.area.x, myroom.area.x + myroom.area.width):
for y in range(myroom.area.y, myroom.area.y + myroom.area.height):
camp.scene.set_visible(x, y, True)

self.party_size = len(camp.get_active_party())
self.init_ready = False

def t_PCMOVE(self, camp: gears.GearHeadCampaign):
in_end_zone = list()
outta_end_zone = list()
end_zone: pygame.Rect = self.elements["DESTINATION"].area
for pc in camp.get_active_party():
if end_zone.collidepoint(*pc.pos):
in_end_zone.append(pc)
else:
outta_end_zone.append(pc)
# Remove mobility kills from the list of mecha that haven't made it to the end zone. They aren't making it.
# Because this check is expensive, only do it if at least some mecha are in the end zone.
if in_end_zone:
for pc in list(outta_end_zone):
if pc.get_current_speed() < 10:
pc.gear_up(camp.scene)
if pc.get_current_speed() < 10:
outta_end_zone.remove(pc)

if in_end_zone and not outta_end_zone:
self.obj.win(camp, len(in_end_zone) * 100 / self.party_size)
self.obj2.win(camp, sum([100 - pc.get_percent_damage_over_health() for pc in in_end_zone]
) // self.party_size)
camp.check_trigger("FORCE_EXIT")

def t_COMBATROUND(self, camp):
if self.reinforcements_counter > 0:
self.reinforcements_counter -= 1
else:
myunit = gears.selector.RandomMechaUnit(self.rank, 50, self.elements.get("ENEMY_FACTION"),
camp.scene.environment, add_commander=False)
team2 = self.elements["_eteam"]
team2.deploy_in_room(camp.scene, random.choice(self.reinforcement_rooms), myunit.mecha_list)

def t_ENDCOMBAT(self, camp):
myteam = self.elements["_eteam"]

if len(myteam.get_members_in_play(camp)) < 1:
self.obj.win(camp, 100)
self.obj2.win(camp, sum([100 - pc.get_percent_damage_over_health() for pc in camp.get_active_party()]
) // self.party_size)
4 changes: 4 additions & 0 deletions game/content/ghplots/missionbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ def t_ENDCOMBAT(self, camp):
if not camp.first_active_pc():
self.exit_the_mission(camp)

def t_FORCE_EXIT(self, camp):
# If the player leaves the scene for whatever reason, end the mission.
self.exit_the_mission(camp)

def t_EXIT(self, camp):
# If the player leaves the scene for whatever reason, end the mission.
self.exit_the_mission(camp)
Expand Down
15 changes: 15 additions & 0 deletions game/content/ghrooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ class ToxicSludgeRoom(ClumpyRoom):
CLUMP_FLOOR = ghterrain.ToxicSludge


class IndicatedRoom(OpenRoom):
def build(self, gb: gears.GearHeadScene, archi):
super().build(gb, archi)
for x in range(self.area.x+1, self.area.x + self.area.width-1):
gb.set_decor(x, self.area.y, ghterrain.BorderMarkerN)
gb.set_decor(x, self.area.y + self.area.height - 1, ghterrain.BorderMarkerS)
for y in range(self.area.y+1, self.area.y + self.area.height-1):
gb.set_decor(self.area.x, y, ghterrain.BorderMarkerW)
gb.set_decor(self.area.x + self.area.width - 1, y, ghterrain.BorderMarkerE)
gb.set_decor(self.area.x, self.area.y, ghterrain.BorderMarkerNW)
gb.set_decor(self.area.x, self.area.y+self.area.height-1, ghterrain.BorderMarkerSW)
gb.set_decor(self.area.x+self.area.width-1, self.area.y, ghterrain.BorderMarkerNE)
gb.set_decor(self.area.x+self.area.width-1, self.area.y+self.area.height-1, ghterrain.BorderMarkerSE)


class LakeRoom(FuzzyRoom):
def build(self, gb, archi):
super().build(gb, archi)
Expand Down
56 changes: 56 additions & 0 deletions game/content/ghterrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,62 @@ class Water(pbge.scenes.terrain.AnimTerrain):
border_priority = 1000


class BorderMarkerSW(pbge.scenes.terrain.AnimTerrain):
image_bottom = 'terrain_decor_areaborder.png'
frames = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
anim_delay = 1
position_dependent = False


class BorderMarkerW(pbge.scenes.terrain.AnimTerrain):
image_bottom = 'terrain_decor_areaborder.png'
frames = (10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
anim_delay = 1
position_dependent = False


class BorderMarkerNW(pbge.scenes.terrain.AnimTerrain):
image_bottom = 'terrain_decor_areaborder.png'
frames = (20, 21, 22, 23, 24, 25, 26, 27, 28, 29)
anim_delay = 1
position_dependent = False


class BorderMarkerN(pbge.scenes.terrain.AnimTerrain):
image_bottom = 'terrain_decor_areaborder.png'
frames = (30, 31, 32, 33, 34, 35, 36, 37, 38, 39)
anim_delay = 1
position_dependent = False


class BorderMarkerNE(pbge.scenes.terrain.AnimTerrain):
image_bottom = 'terrain_decor_areaborder.png'
frames = (40, 41, 42, 43, 44, 45, 46, 47, 48, 49)
anim_delay = 1
position_dependent = False


class BorderMarkerE(pbge.scenes.terrain.AnimTerrain):
image_bottom = 'terrain_decor_areaborder.png'
frames = (50, 51, 52, 53, 54, 55, 56, 57, 58, 59)
anim_delay = 1
position_dependent = False


class BorderMarkerSE(pbge.scenes.terrain.AnimTerrain):
image_bottom = 'terrain_decor_areaborder.png'
frames = (60, 61, 62, 63, 64, 65, 66, 67, 68, 69)
anim_delay = 1
position_dependent = False


class BorderMarkerS(pbge.scenes.terrain.AnimTerrain):
image_bottom = 'terrain_decor_areaborder.png'
frames = (70, 71, 72, 73, 74, 75, 76, 77, 78, 79)
anim_delay = 1
position_dependent = False


class ToxicSludge(pbge.scenes.terrain.VariableTerrain):
image_bottom = 'terrain_floor_sludge.png'
blocks = (Walking, Rolling)
Expand Down
5 changes: 5 additions & 0 deletions game/geareditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ class WeaponEditWidget(ComponentEditWidget):
def __init__(self, mygear, editor, **kwargs):
super().__init__(mygear, editor, **kwargs)

if pbge.util.config.getboolean("GENERAL", "dev_mode_on"):
self.add_interior(pbge.widgets.LabelWidget(0,0,0,0,text_fun=self._get_shop_rank))
self.add_interior(PlusMinusWidget(mygear,"reach",mygear.MIN_REACH,mygear.MAX_REACH,active=editor.mode==MODE_CREATIVE))
self.add_interior(PlusMinusWidget(mygear,"damage",mygear.MIN_DAMAGE,mygear.MAX_DAMAGE,active=editor.mode==MODE_CREATIVE))
self.add_interior(PlusMinusWidget(mygear,"accuracy",mygear.MIN_ACCURACY,mygear.MAX_ACCURACY,active=editor.mode==MODE_CREATIVE))
Expand All @@ -273,6 +275,9 @@ def __init__(self, mygear, editor, **kwargs):
self.stat_menu.menu.set_item_by_value(self.mygear.attack_stat)
self.add_interior(self.stat_menu)

def _get_shop_rank(self, *args, **kwargs):
return str(self.mygear.shop_rank())

def _set_attack_stat(self,result):
if result:
self.mygear.attack_stat = result
Expand Down
Loading

0 comments on commit ab0b75a

Please sign in to comment.