Skip to content

Commit

Permalink
feat: specify more chapter info
Browse files Browse the repository at this point in the history
  • Loading branch information
gudzpoz committed Jun 27, 2024
1 parent 07b7bce commit 98f24dc
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 24 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,26 @@

剧情编辑器想要提供导出成能网页直接查看的游戏成品,这里用到了打包好的 `viewer.html`(打包成了一个网页文件),
`index.html` 导出的时候做的就是把编译好的剧情直接放到 `viewer.html` 里面去。

## 剧情归档

目前还有很多战斗中剧情、点位剧情没有归档,这里把目前找到的先记录下来:

- 主线:目前手动归档了 EP 0 ~ 13 的剧情。之后的包括双联乱数以及后面的都还没有处理,有一大堆。
- 第十一战役:11-10-4-point9292.txt
- 小型活动:
- 一币之遥
- 捩浪人
- 沙罗蚀相
- 焙炒爱意(这个点位剧情里有每个人形的送巧克力剧情)
- 里坎禁猎区
- 迷笼猜想
- 思域迷航(全是乱的)
- 许可!二次加载
- 联动
- 荣耀日
- 梦间剧
- 暗金潮
- 小邪神前线
- 雪浪映花颜
- 镜扉的永恒
12 changes: 9 additions & 3 deletions unpack/src/gfunpack/chapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
import hjson

from gfunpack.stories import Stories
from gfunpack.manual_chapters import Chapter, Story, add_extra_chapter_mappings, get_block_list, get_recorded_chapters, post_insert
from gfunpack.manual_chapters import (
Chapter, Story, add_extra_chapter_mappings,
get_block_list, get_recorded_chapters, post_insert,
is_manual_processed, manually_process,
)

_logger = logging.getLogger('gfunpack.prefabs')
_warning = _logger.warning
Expand Down Expand Up @@ -252,8 +256,10 @@ def _categorize_main_stories(self):
add_extra_chapter_mappings(id_mapping)

# 已经进入剧情回放的剧情录入对应章节
blocked = get_block_list()
for story in sorted(self.main_events, key=lambda e: (abs(e.campaign), e.id)):
files = self._parse_event_stories(story, mapped_files)
files = [f for f in self._parse_event_stories(story, mapped_files)
if not is_manual_processed(f) and f not in blocked]
if len(files) == 0:
continue
if story.campaign == -43: # 暗金潮命名有问题
Expand All @@ -270,11 +276,11 @@ def _categorize_main_stories(self):
))

post_insert(chapters, mapped_files)
manually_process(chapters, id_mapping, mapped_files)

others = set(self.stories.extracted.keys()) - mapped_files

# 其它的看起来命名比较规律的东西
blocked = get_block_list()
for file in sorted(others):
if file in blocked:
continue
Expand Down
114 changes: 94 additions & 20 deletions unpack/src/gfunpack/manual_chapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pathlib
import shutil
import subprocess
import typing


@dataclasses.dataclass
Expand Down Expand Up @@ -195,23 +196,27 @@ def get_recorded_chapters():
for f in story.files)
return chapters, id_mapping, recorded_files


_attached_stories = [
_attached_stories_motor_race = [
'-31-3c3-1.txt',
'battleavg/-31-specialbattletips-1.txt',
'battleavg/-31-specialbattletips-3.txt',
'battleavg/-31-specialbattletips-4.txt',
'battleavg/-31-specialbattletips-5.txt',
'battleavg/-31-specialbattletips-6.txt',
'battleavg/-31-specialbattletips-fly.txt',
'battleavg/-31-specialbattletips-spdup.txt',
'battleavg/-31-specialbattletips-lose.txt',
'battleavg/-31-specialbattletips-victory.txt',
]
_attached_stories: list[tuple[str, str, str]] = [
('0-2-1.txt', '0-2-3round2.txt'),
('-2-1-1.txt', '-2-1-4-point2207.txt'),

# 盲拆法则
('-7-1-3round1.txt', '-7-1-3round2.txt'),
('-7-1-3round2.txt', '-7-1-4-point3498.txt'),

('-7-2-3round1.txt', '-7-2-3round2.txt'),
('-7-2-3round2.txt', '-7-2-4-point3342.txt'),

('-7-3-3round1.txt', '-7-3-3round2.txt'),
('-7-3-3round2.txt', '-7-3-4-point3533.txt'),

('-7-4-3round1.txt', '-7-4-3round2.txt'),
('-7-4-3round2.txt', '-7-4-4-point3612.txt'),
# 盲拆法则:感觉应该是第二周目的变化?
('-7-1-3round1.txt', '-7-1-3round2.txt', '阶段2.5'),
('-7-2-3round1.txt', '-7-2-3round2.txt', '阶段2.5'),
('-7-3-3round1.txt', '-7-3-3round2.txt', '阶段2.5'),
('-7-4-3round1.txt', '-7-4-3round2.txt', '阶段2.5'),

# 有序紊流
('-24-2-1.txt', '-24-2-2.txt'),
Expand All @@ -228,6 +233,33 @@ def get_recorded_chapters():
('-24-14-2first.txt', '-24-14-2.txt'),
('-24-15-1.txt', '-24-15-2first.txt'),
('-24-15-2first.txt', '-24-15-2.txt'),

# 裂变链接
# ('-33-59-4-point13290.txt', '-33-59-4-point80174.txt'), # 两个点位事件一样
('-33-59-4-point13290.txt', 'battleavg/-33-24-1first.txt'),

# 偏振光
('-36-5-ex.txt', 'battleavg/-36-specialbattletips.txt'),
] + [ # 异构体飙车小游戏局内剧情
(prev, after)
for prev, after in zip(
_attached_stories_motor_race[:-1],
_attached_stories_motor_race[1:],
)
]
_attached_events = [
# 裂变链接:吞噬一切的花海-战斗
('-33-42-1first.txt', Story(
name="吞噬一切的花海-战斗",
description="小游戏说明",
files=['battleavg/-33-44-1first.txt'],
)),
# 愚人节
('1-1-1.txt', Story(
name="演习训练-愚人节版",
description="欢迎回来,父亲大人。",
files=['always-404-1-1-1.txt', 'always-404-1-1-3.txt'],
))
]


Expand All @@ -242,20 +274,39 @@ def add_extra_chapter_mappings(id_mapping: dict[str, int]):
for extra, mapping in _extra_chapter_mapping.items():
id_mapping[extra] = id_mapping[mapping]

_manual_processed = set().union(
)
def is_manual_processed(file: str):
return file in _manual_processed
def manually_process(chapters: dict[int, Chapter], id_mapping: dict[str, int], mapped_files: set[str]):
pass


def post_insert(chapters: dict[int, Chapter], mapped_files: set[str]):
stories: dict[str, Story] = {}
stories: dict[str, tuple[Chapter, Story]] = {}
for chapter in chapters.values():
for story in chapter.stories:
for file in story.files:
stories[file if isinstance(file, str) else file[0]] = story
for file, attached in _attached_stories:
stories[file if isinstance(file, str) else file[0]] = (chapter, story)
for attachment in _attached_stories:
file, attached = attachment[0:2]
assert attached not in mapped_files, attached
story = stories[file]
c, story = stories[file]
assert isinstance(story.files[0], str)
stories[attached] = story
story.files.append(attached)
stories[attached] = (c, story)
story.files.insert(
story.files.index(file) + 1,
attached if len(attachment) == 2 else (attached, attachment[2]),
)
mapped_files.add(attached)
for file, attached in _attached_events:
assert all(f not in mapped_files for f in attached.files)
c, story = stories[file]
c.stories.insert(c.stories.index(story) + 1, attached)
for f in attached.files:
file = typing.cast(str, f)
stories[file] = (c, attached)
mapped_files.add(file)


def get_block_list():
Expand All @@ -278,6 +329,29 @@ def get_block_list():
'-6-4-1.txt',
'-6-4-2end.txt',
'-6-4-2first.txt',

# 裂变链接,两个点位事件内容是一样的
'-33-59-4-point80174.txt',

# 各种秃洞复刻提示
'-39-ex1-4-point91502.txt',
'-55-ext.txt',
'-60-tips.txt',
'-63-tips.txt',
'-65-tips.txt',
'-65-tips2.txt',
'-404-ext-1-1.txt',
# 飓风营救复刻 (-45 -> -24)
"-45-ext-04.txt",
"-45-ext-01.txt",
"-45-ext-02.txt",
"-45-ext-03.txt",

# 盲拆法则:这些是英文版
'-7-1-4-point3498.txt',
'-7-2-4-point3342.txt',
'-7-3-4-point3533.txt',
'-7-4-4-point3612.txt',
]
)

Expand Down
2 changes: 1 addition & 1 deletion unpack/src/gfunpack/stories.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def _parse_narrators(self, narrators: str):
else:
attrs = self._parse_effects(narrator)
sprites.append((sprite.group(1), int(sprite.group(2)), attrs))
return sprites, ' & '.join(speakers)
return sprites, speakers[-1] if len(speakers) > 0 else ''

def _parse_effects(self, effects: str):
tags = re.findall(_effect_tag_regex, effects)
Expand Down

0 comments on commit 98f24dc

Please sign in to comment.