Skip to content

Commit

Permalink
Merge pull request #68 from EnvyDragon/sc2-next
Browse files Browse the repository at this point in the history
SC2: Adding skip_cutscenes and disable_forced_camera options
  • Loading branch information
Ziktofel authored Oct 12, 2023
2 parents f78472b + c7465b1 commit f391f20
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
26 changes: 24 additions & 2 deletions worlds/sc2/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,22 @@ def _cmd_game_speed(self, game_speed: str = "") -> bool:
" or Default to select based on difficulty.")
return False

def _cmd_disable_forced_camera(self, toggle: bool) -> None:
if toggle:
self.output("Blocking campaign triggers from forcing camera movement; repeat this command with 'False' to allow it again.")
self.ctx.disable_forced_camera = 1
else:
self.output("Allowing campaign triggers to force camera movement; repeat this command with 'True' to block them again.")
self.ctx.disable_forced_camera = 0

def _cmd_skip_cutscenes(self, toggle: bool) -> None:
if toggle:
self.output("Skipping all cutscenes and overly long dialogues; repeat this command with 'False' to stop.")
self.ctx.skip_cutscenes = 1
else:
self.output("No longer skipping cutscenes or dialog; repeat this command with 'True' to skip them again.")
self.ctx.skip_cutscenes = 0

def _cmd_color(self, color: str = "") -> None:
player_colors = [
"White", "Red", "Blue", "Teal",
Expand Down Expand Up @@ -262,6 +278,8 @@ class SC2Context(CommonContext):
items_handling = 0b111
difficulty = -1
game_speed = -1
disable_forced_camera = 0
skip_cutscenes = 0
all_in_choice = 0
mission_order = 0
player_color = 2
Expand Down Expand Up @@ -303,6 +321,8 @@ def on_package(self, cmd: str, args: dict) -> None:
if cmd == "Connected":
self.difficulty = args["slot_data"]["game_difficulty"]
self.game_speed = args["slot_data"].get("game_speed", GameSpeed.option_default)
self.disable_forced_camera = args["slot_data"]["disable_forced_camera"]
self.skip_cutscenes = args["slot_data"]["skip_cutscenes"]
self.all_in_choice = args["slot_data"]["all_in_map"]
slot_req_table: dict = args["slot_data"]["mission_req"]

Expand Down Expand Up @@ -618,11 +638,13 @@ async def on_step(self, iteration: int):
game_speed = self.ctx.game_speed_override
else:
game_speed = self.ctx.game_speed
await self.chat_send("?SetOptions {} {} {} {}".format(
await self.chat_send("?SetOptions {} {} {} {} {} {}".format(
difficulty,
self.ctx.generic_upgrade_research,
self.ctx.all_in_choice,
game_speed
game_speed,
self.ctx.disable_forced_camera,
self.ctx.skip_cutscenes
))
await self.chat_send("?GiveResources {} {} {}".format(
start_items[SC2Race.ANY][0],
Expand Down
14 changes: 14 additions & 0 deletions worlds/sc2/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ class GameSpeed(Choice):
option_faster = 5
default = option_default

class DisableForcedCamera(Toggle):
"""
Prevents the game from moving or locking the camera without the player's consent.
"""
display_name = "Disable Forced Camera Movement"


class SkipCutscenes(Toggle):
"""
Skips all cutscenes and prevents dialog from blocking progress.
"""
display_name = "Skip Cutscenes"

class AllInMap(Choice):
"""Determines what version of All-In (final map) that will be generated for the campaign."""
Expand Down Expand Up @@ -474,6 +486,8 @@ class OptionalBossLocations(LocationInclusion):
sc2_options: Dict[str, Option] = {
"game_difficulty": GameDifficulty,
"game_speed": GameSpeed,
"disable_forced_camera": DisableForcedCamera,
"skip_cutscenes": SkipCutscenes,
"all_in_map": AllInMap,
"mission_order": MissionOrder,
"player_color_terran_raynor": PlayerColorTerranRaynor,
Expand Down

0 comments on commit f391f20

Please sign in to comment.