about summary refs log tree commit diff stats
path: root/data/maps/the_double_sided/rooms/Flipped Purple Area.txtpb
blob: be9ee3f785b3f3237974bd1bf679782d9a83f7bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
name: "Flipped Purple Area"
display_name: "Maze"
panels {
  name: "CEILING"
  path: "Panels/Maze/panel_8"
  clue: "ceiling"
  answer: "floor"
  symbols: "sun"
}
panels {
  name: "LEAVES"
  path: "Panels/Maze/panel_19"
  clue: "leaves"
  answer: "roots"
  symbols: "boxes"
}
} /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * BUGS:
 * Shipwreck vault is solved reversed?
 * Swamp <-> symmetry has non-invisible background
 * Tutorial sounds don't always play
 * FEATURES:
 * Speed up some of the slow things (like swamp)
 * Prevent re-randomization (?)
 * Clear "Randomized" state on NG (?) -- Or on a short delay
 * Randomize audio logs -- Hard, seem to be unloaded some times?
 * Swap sounds in jungle (along with panels) -- maybe impossible
 * Make orange 7 (all of oranges?) hard. Like big = hard.
 * Start the game if it isn't running?
 * SETTINGS:
 * Speeds of certain things
 * Speedrunner mode
 * Increase odds of mountain oranges garbage on other panels
*/
#include "Memory.h"
#include "Randomizer.h"
#include "Panels.h"
#include <string>
#include <iostream>
#include <numeric>
#include <chrono>

template <class T>
int find(const std::vector<T> &data, T search, size_t startIndex = 0) {
	for (size_t i=startIndex ; i<data.size(); i++) {
		if (data[i] == search) return static_cast<int>(i);
	}
	std::cout << "Couldn't find " << search << " in data!" << std::endl;
	exit(-1);
}

void Randomizer::Randomize()
{
	// Content swaps -- must happen before squarePanels
	_core.Randomize(upDownPanels, SWAP_LINES);
	_core.Randomize(leftForwardRightPanels, SWAP_LINES);

	_core.Randomize(squarePanels, SWAP_LINES);

	// Individual area modifications
	RandomizeTutorial();
	RandomizeSymmetry();
	RandomizeDesert();
	RandomizeQuarry();
	RandomizeTreehouse();
	RandomizeKeep();
	RandomizeShadows();
	RandomizeTown();
	RandomizeMonastery();
	RandomizeBunker();
	RandomizeJungle();
	RandomizeSwamp();
	RandomizeMountain();
	// RandomizeChallenge();
	// RandomizeAudioLogs();
}

void Randomizer::AdjustSpeed() {

}

void Randomizer::RandomizeTutorial() {
	// Disable tutorial cursor speed modifications (not working?)
	_core.WritePanelData<float>(0x00295, CURSOR_SPEED_SCALE, {1.0});
	_core.WritePanelData<float>(0x0C373, CURSOR_SPEED_SCALE, {1.0});
	_core.WritePanelData<float>(0x00293, CURSOR_SPEED_SCALE, {1.0});
	_core.WritePanelData<float>(0x002C2, CURSOR_SPEED_SCALE, {1.0});
}

void Randomizer::RandomizeSymmetry() {
}

void Randomizer::RandomizeDesert() {
	_core.Randomize(desertPanels, SWAP_LINES);

	// Turn off desert surface 8
	_core.WritePanelData<float>(0x09F94, POWER, {0.0, 0.0});
	// Turn off desert flood final
	_core.WritePanelData<float>(0x18076, POWER, {0.0, 0.0});
	// Change desert floating target to desert flood final
	_core.WritePanelData<int>(0x17ECA, TARGET, {0x18077});
}

void Randomizer::RandomizeQuarry() {
}

void Randomizer::RandomizeTreehouse() {
	// Ensure that whatever pivot panels we have are flagged as "pivotable"
	int panelFlags = _core.ReadPanelData<int>(0x17DD1, STYLE_FLAGS, 1)[0];
	_core.WritePanelData<int>(0x17DD1, STYLE_FLAGS, {panelFlags | 0x8000});
	panelFlags = _core.ReadPanelData<int>(0x17CE3, STYLE_FLAGS, 1)[0];
	_core.WritePanelData<int>(0x17CE3, STYLE_FLAGS, {panelFlags | 0x8000});
	panelFlags = _core.ReadPanelData<int>(0x17DB7, STYLE_FLAGS, 1)[0];
	_core.WritePanelData<int>(0x17DB7, STYLE_FLAGS, {panelFlags | 0x8000});
	panelFlags = _core.ReadPanelData<int>(0x17E52, STYLE_FLAGS, 1)[0];
	_core.WritePanelData<int>(0x17E52, STYLE_FLAGS, {panelFlags | 0x8000});
}

void Randomizer::RandomizeKeep() {
}

void Randomizer::RandomizeShadows() {
	// Distance-gate shadows laser to prevent sniping through the bars
	_core.WritePanelData<float>(0x19650, MAX_BROADCAST_DISTANCE, {2.5});
	// Change the shadows tutorial cable to only activate avoid
	_core.WritePanelData<int>(0x319A8, CABLE_TARGET_2, {0});
	// Change shadows avoid 8 to power shadows follow
	_core.WritePanelData<int>(0x1972F, TARGET, {0x1C34C});

	std::vector<int> randomOrder(shadowsPanels.size(), 0);
	std::iota(randomOrder.begin(), randomOrder.end(), 0);
	_core.RandomizeRange(randomOrder, SWAP_NONE, 0, 8); // Tutorial
	_core.RandomizeRange(randomOrder, SWAP_NONE, 8, 16); // Avoid
	_core.RandomizeRange(randomOrder, SWAP_NONE, 16, 21); // Follow
	_core.ReassignTargets(shadowsPanels, randomOrder);
	// Turn off original starting panel
	_core.WritePanelData<float>(shadowsPanels[0], POWER, {0.0f, 0.0f});
	// Turn on new starting panel
	_core.WritePanelData<float>(shadowsPanels[randomOrder[0]], POWER, {1.0f, 1.0f});
}

void Randomizer::RandomizeTown() {
}

void Randomizer::RandomizeMonastery() {
	std::vector<int> randomOrder(monasteryPanels.size(), 0);
	std::iota(randomOrder.begin(), randomOrder.end(), 0);
	_core.RandomizeRange(randomOrder, SWAP_NONE, 3, 9); // Outer 2 & 3, Inner 1-4
	_core.ReassignTargets(monasteryPanels, randomOrder);
}

void Randomizer::RandomizeBunker() {
	std::vector<int> randomOrder(bunkerPanels.size(), 0);
	std::iota(randomOrder.begin(), randomOrder.end(), 0);
	// Randomize Tutorial 2-Advanced Tutorial 4 + Glass 1
	// Tutorial 1 cannot be randomized, since no other panel can start on
	// Glass 1 will become door + glass 1, due to the targetting system
	_core.RandomizeRange(randomOrder, SWAP_NONE, 1, 10);
	// Randomize Glass 1-3 into everything after the door/glass 1
	const size_t glass1Index = find(randomOrder, 9);
	_core.RandomizeRange(randomOrder, SWAP_NONE, glass1Index + 1, 12);
	_core.ReassignTargets(bunkerPanels, randomOrder);
}

void Randomizer::RandomizeJungle() {
	std::vector<int> randomOrder(junglePanels.size(), 0);
	std::iota(randomOrder.begin(), randomOrder.end(), 0);
	// Waves 1 cannot be randomized, since no other panel can start on
	_core.RandomizeRange(randomOrder, SWAP_NONE, 1, 7); // Waves 2-7
	_core.RandomizeRange(randomOrder, SWAP_NONE, 8, 13); // Pitches 1-6
	_core.ReassignTargets(junglePanels, randomOrder);
}

void Randomizer::RandomizeSwamp() {
	// Distance-gate swamp snipe 1 to prevent RNG swamp snipe
	_core.WritePanelData<float>(0x17C05, MAX_BROADCAST_DISTANCE, {15.0});
}

void Randomizer::RandomizeMountain() {
	// Randomize lasers & some of mountain
	_core.Randomize(lasers, SWAP_TARGETS);
	_core.Randomize(mountainMultipanel, SWAP_LINES);

	// Randomize final pillars order
	std::vector<int> targets = {pillars[0] + 1};
	for (const int pillar : pillars) {
		int target = _core.ReadPanelData<int>(pillar, TARGET, 1)[0];
		targets.push_back(target);
	}
	targets[5] = pillars[5] + 1;

	std::vector<int> randomOrder(pillars.size(), 0);
	std::iota(randomOrder.begin(), randomOrder.end(), 0);
	_core.RandomizeRange(randomOrder, SWAP_NONE, 0, 4); // Left Pillars 1-4
	_core.RandomizeRange(randomOrder, SWAP_NONE, 5, 9); // Right Pillars 1-4
	_core.ReassignTargets(pillars, randomOrder, targets);
	// Turn off original starting panels
	_core.WritePanelData<float>(pillars[0], POWER, {0.0f, 0.0f});
	_core.WritePanelData<float>(pillars[5], POWER, {0.0f, 0.0f});
	// Turn on new starting panels
	_core.WritePanelData<float>(pillars[randomOrder[0]], POWER, {1.0f, 1.0f});
	_core.WritePanelData<float>(pillars[randomOrder[5]], POWER, {1.0f, 1.0f});

	// Read the target of keep front laser, and write it to keep back laser.
	std::vector<int> keepFrontLaserTarget = _core.ReadPanelData<int>(0x0360E, TARGET, 1);
	_core.WritePanelData<int>(0x03317, TARGET, keepFrontLaserTarget);
}

void Randomizer::RandomizeChallenge() {
	std::vector<int> randomOrder(challengePanels.size(), 0);
	std::iota(randomOrder.begin(), randomOrder.end(), 0);
	_core.RandomizeRange(randomOrder, SWAP_NONE, 1, 9); // Easy maze - Triple 2
	std::vector<int> triple1Target = _core.ReadPanelData<int>(0x00C80, TARGET, 1);
	_core.WritePanelData<int>(0x00CA1, TARGET, triple1Target);
	_core.WritePanelData<int>(0x00CB9, TARGET, triple1Target);
	std::vector<int> triple2Target = _core.ReadPanelData<int>(0x00C22, TARGET, 1);
	_core.WritePanelData<int>(0x00C59, TARGET, triple2Target);
	_core.WritePanelData<int>(0x00C68, TARGET, triple2Target);
	_core.ReassignTargets(challengePanels, randomOrder);
}

void Randomizer::RandomizeAudioLogs() {
	std::vector<int> randomOrder(audiologs.size(), 0);
	std::iota(randomOrder.begin(), randomOrder.end(), 0);
	_core.Randomize(randomOrder, SWAP_NONE);
	_core.ReassignNames(audiologs, randomOrder);
}