SnootGame/game/storyline.rpy

89 lines
2.7 KiB
Text
Raw Normal View History

# Store the general chapters inside an array for easy manipulation
default chapter_list = [
"chapter_1", "chapter_2", "chapter_3", "chapter_4", "chapter_5",
"chapter_6", "chapter_7", "chapter_8", "chapter_9", "chapter_10", "chapter_11"
]
define ending_routes = {
4: ["chapter_11D", "chapter_12D", "chapter_12_5D", "chapter_13D", "chapter_14D"],
3: ["chapter_11C", "chapter_12C", "chapter_12_5C", "chapter_13C", "chapter_14C"],
2: ["chapter_11B", "chapter_12B", "chapter_13B", "chapter_14B"],
1: ["chapter_11A", "chapter_12A", "chapter_12_5D", "chapter_13A", "chapter_14A"]
}
default chapter_list_length = len(chapter_list) - 1
default chapter_list_index = 0 # Index number for the current position of the general chapters array
2024-08-17 02:01:55 +02:00
# This stores the name of the label as a string
# When starting a new game, it takes the first element of the chapter_list array
default current_chapter = chapter_list[chapter_list_index]
default ending_route_number = None
default is_end_reached = False
2021-09-23 01:06:37 +02:00
init -1 python:
2021-09-23 00:39:56 +02:00
def ending_image():
#0b0000, DCBA, flash the bits with |=, check with &
2021-09-23 00:39:56 +02:00
endings = 0b0000
_e = 0b1
for i in range(1, 5):
fn = "e"+str(i)+"of4"
2021-09-23 00:39:56 +02:00
endings |= (_e * renpy.seen_image(fn))
_e = _e << 0b1
2021-10-16 19:25:12 +02:00
persistent.old_endings = persistent.endings
2021-09-23 00:39:56 +02:00
persistent.endings = endings
init python:
def next_story_chapter():
global chapter_list_index, current_chapter, ending_route_number
# Add check "is_end_reached" to have this if statement be executed only once when finishing the general chapters
if not is_end_reached and is_end_of_chapters():
process_ending()
if chapter_list_index < chapter_list_length:
chapter_list_index += 1
current_chapter = chapter_list[chapter_list_index]
renpy.call(current_chapter)
else:
end_story()
def is_end_of_chapters():
return chapter_list_index >= chapter_list_length
def process_ending():
global ending_route_number
ending_route_number = get_ending()
add_ending_chapters()
update_ending_variables()
def add_ending_chapters():
global chapter_list
if ending_route_number in ending_routes:
chapter_list.extend(ending_routes[ending_route_number])
def update_ending_variables():
global chapter_list_length
global is_end_reached
# chapter_list_length is updated to reflect the addition to the chapter_list array
chapter_list_length = len(chapter_list) - 1
is_end_reached = True
def end_story():
ending_image()
renpy.call("lending")