diff options
Diffstat (limited to 'Source/Randomizer.cpp')
-rw-r--r-- | Source/Randomizer.cpp | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/Source/Randomizer.cpp b/Source/Randomizer.cpp index 14583f8..2545c8f 100644 --- a/Source/Randomizer.cpp +++ b/Source/Randomizer.cpp | |||
@@ -156,35 +156,35 @@ void Randomizer::Randomize() { | |||
156 | 156 | ||
157 | void Randomizer::AdjustSpeed() { | 157 | void Randomizer::AdjustSpeed() { |
158 | // Desert Surface Final Control | 158 | // Desert Surface Final Control |
159 | _memory->WritePanelData<float>(0x09F95, OPEN_RATE, {0.04f}); // 4x | 159 | _memory->WriteEntityData<float>(0x09F95, OPEN_RATE, {0.04f}); // 4x |
160 | // Swamp Sliding Bridge | 160 | // Swamp Sliding Bridge |
161 | _memory->WritePanelData<float>(0x0061A, OPEN_RATE, {0.1f}); // 4x | 161 | _memory->WriteEntityData<float>(0x0061A, OPEN_RATE, {0.1f}); // 4x |
162 | // Mountain 2 Elevator | 162 | // Mountain 2 Elevator |
163 | _memory->WritePanelData<float>(0x09EEC, OPEN_RATE, {0.075f}); // 3x | 163 | _memory->WriteEntityData<float>(0x09EEC, OPEN_RATE, {0.075f}); // 3x |
164 | } | 164 | } |
165 | 165 | ||
166 | void Randomizer::RandomizeLasers() { | 166 | void Randomizer::RandomizeLasers() { |
167 | Randomize(lasers, SWAP::TARGETS); | 167 | Randomize(lasers, SWAP::TARGETS); |
168 | // Read the target of keep front laser, and write it to keep back laser. | 168 | // Read the target of keep front laser, and write it to keep back laser. |
169 | std::vector<int> keepFrontLaserTarget = _memory->ReadPanelData<int>(0x0360E, TARGET, 1); | 169 | std::vector<int> keepFrontLaserTarget = _memory->ReadEntityData<int>(0x0360E, TARGET, 1); |
170 | _memory->WritePanelData<int>(0x03317, TARGET, keepFrontLaserTarget); | 170 | _memory->WriteEntityData<int>(0x03317, TARGET, keepFrontLaserTarget); |
171 | } | 171 | } |
172 | 172 | ||
173 | void Randomizer::PreventSnipes() | 173 | void Randomizer::PreventSnipes() |
174 | { | 174 | { |
175 | // Distance-gate swamp snipe 1 to prevent RNG swamp snipe | 175 | // Distance-gate swamp snipe 1 to prevent RNG swamp snipe |
176 | _memory->WritePanelData<float>(0x17C05, MAX_BROADCAST_DISTANCE, {15.0}); | 176 | _memory->WriteEntityData<float>(0x17C05, MAX_BROADCAST_DISTANCE, {15.0}); |
177 | // Distance-gate shadows laser to prevent sniping through the bars | 177 | // Distance-gate shadows laser to prevent sniping through the bars |
178 | _memory->WritePanelData<float>(0x19650, MAX_BROADCAST_DISTANCE, {2.5}); | 178 | _memory->WriteEntityData<float>(0x19650, MAX_BROADCAST_DISTANCE, {2.5}); |
179 | } | 179 | } |
180 | 180 | ||
181 | // Private methods | 181 | // Private methods |
182 | void Randomizer::RandomizeTutorial() { | 182 | void Randomizer::RandomizeTutorial() { |
183 | // Disable tutorial cursor speed modifications (not working?) | 183 | // Disable tutorial cursor speed modifications (not working?) |
184 | _memory->WritePanelData<float>(0x00295, CURSOR_SPEED_SCALE, {1.0}); | 184 | _memory->WriteEntityData<float>(0x00295, CURSOR_SPEED_SCALE, {1.0}); |
185 | _memory->WritePanelData<float>(0x0C373, CURSOR_SPEED_SCALE, {1.0}); | 185 | _memory->WriteEntityData<float>(0x0C373, CURSOR_SPEED_SCALE, {1.0}); |
186 | _memory->WritePanelData<float>(0x00293, CURSOR_SPEED_SCALE, {1.0}); | 186 | _memory->WriteEntityData<float>(0x00293, CURSOR_SPEED_SCALE, {1.0}); |
187 | _memory->WritePanelData<float>(0x002C2, CURSOR_SPEED_SCALE, {1.0}); | 187 | _memory->WriteEntityData<float>(0x002C2, CURSOR_SPEED_SCALE, {1.0}); |
188 | } | 188 | } |
189 | 189 | ||
190 | void Randomizer::RandomizeSymmetry() { | 190 | void Randomizer::RandomizeSymmetry() { |
@@ -198,11 +198,11 @@ void Randomizer::RandomizeDesert() { | |||
198 | Randomize(desertPanels, SWAP::LINES); | 198 | Randomize(desertPanels, SWAP::LINES); |
199 | 199 | ||
200 | // Turn off desert surface 8 | 200 | // Turn off desert surface 8 |
201 | _memory->WritePanelData<float>(0x09F94, POWER, {0.0, 0.0}); | 201 | _memory->WriteEntityData<float>(0x09F94, POWER, {0.0, 0.0}); |
202 | // Turn off desert flood final | 202 | // Turn off desert flood final |
203 | _memory->WritePanelData<float>(0x18076, POWER, {0.0, 0.0}); | 203 | _memory->WriteEntityData<float>(0x18076, POWER, {0.0, 0.0}); |
204 | // Change desert floating target to desert flood final | 204 | // Change desert floating target to desert flood final |
205 | _memory->WritePanelData<int>(0x17ECA, TARGET, {0x18077}); | 205 | _memory->WriteEntityData<int>(0x17ECA, TARGET, {0x18077}); |
206 | } | 206 | } |
207 | 207 | ||
208 | void Randomizer::RandomizeQuarry() { | 208 | void Randomizer::RandomizeQuarry() { |
@@ -210,14 +210,14 @@ void Randomizer::RandomizeQuarry() { | |||
210 | 210 | ||
211 | void Randomizer::RandomizeTreehouse() { | 211 | void Randomizer::RandomizeTreehouse() { |
212 | // Ensure that whatever pivot panels we have are flagged as "pivotable" | 212 | // Ensure that whatever pivot panels we have are flagged as "pivotable" |
213 | int panelFlags = _memory->ReadPanelData<int>(0x17DD1, STYLE_FLAGS, 1)[0]; | 213 | int panelFlags = _memory->ReadEntityData<int>(0x17DD1, STYLE_FLAGS, 1)[0]; |
214 | _memory->WritePanelData<int>(0x17DD1, STYLE_FLAGS, {panelFlags | 0x8000}); | 214 | _memory->WriteEntityData<int>(0x17DD1, STYLE_FLAGS, {panelFlags | 0x8000}); |
215 | panelFlags = _memory->ReadPanelData<int>(0x17CE3, STYLE_FLAGS, 1)[0]; | 215 | panelFlags = _memory->ReadEntityData<int>(0x17CE3, STYLE_FLAGS, 1)[0]; |
216 | _memory->WritePanelData<int>(0x17CE3, STYLE_FLAGS, {panelFlags | 0x8000}); | 216 | _memory->WriteEntityData<int>(0x17CE3, STYLE_FLAGS, {panelFlags | 0x8000}); |
217 | panelFlags = _memory->ReadPanelData<int>(0x17DB7, STYLE_FLAGS, 1)[0]; | 217 | panelFlags = _memory->ReadEntityData<int>(0x17DB7, STYLE_FLAGS, 1)[0]; |
218 | _memory->WritePanelData<int>(0x17DB7, STYLE_FLAGS, {panelFlags | 0x8000}); | 218 | _memory->WriteEntityData<int>(0x17DB7, STYLE_FLAGS, {panelFlags | 0x8000}); |
219 | panelFlags = _memory->ReadPanelData<int>(0x17E52, STYLE_FLAGS, 1)[0]; | 219 | panelFlags = _memory->ReadEntityData<int>(0x17E52, STYLE_FLAGS, 1)[0]; |
220 | _memory->WritePanelData<int>(0x17E52, STYLE_FLAGS, {panelFlags | 0x8000}); | 220 | _memory->WriteEntityData<int>(0x17E52, STYLE_FLAGS, {panelFlags | 0x8000}); |
221 | } | 221 | } |
222 | 222 | ||
223 | void Randomizer::RandomizeKeep() { | 223 | void Randomizer::RandomizeKeep() { |
@@ -225,9 +225,9 @@ void Randomizer::RandomizeKeep() { | |||
225 | 225 | ||
226 | void Randomizer::RandomizeShadows() { | 226 | void Randomizer::RandomizeShadows() { |
227 | // Change the shadows tutorial cable to only activate avoid | 227 | // Change the shadows tutorial cable to only activate avoid |
228 | _memory->WritePanelData<int>(0x319A8, CABLE_TARGET_2, {0}); | 228 | _memory->WriteEntityData<int>(0x319A8, CABLE_TARGET_2, {0}); |
229 | // Change shadows avoid 8 to power shadows follow | 229 | // Change shadows avoid 8 to power shadows follow |
230 | _memory->WritePanelData<int>(0x1972F, TARGET, {0x1C34C}); | 230 | _memory->WriteEntityData<int>(0x1972F, TARGET, {0x1C34C}); |
231 | 231 | ||
232 | std::vector<int> randomOrder(shadowsPanels.size(), 0); | 232 | std::vector<int> randomOrder(shadowsPanels.size(), 0); |
233 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | 233 | std::iota(randomOrder.begin(), randomOrder.end(), 0); |
@@ -236,9 +236,9 @@ void Randomizer::RandomizeShadows() { | |||
236 | RandomizeRange(randomOrder, SWAP::NONE, 16, 21); // Follow | 236 | RandomizeRange(randomOrder, SWAP::NONE, 16, 21); // Follow |
237 | ReassignTargets(shadowsPanels, randomOrder); | 237 | ReassignTargets(shadowsPanels, randomOrder); |
238 | // Turn off original starting panel | 238 | // Turn off original starting panel |
239 | _memory->WritePanelData<float>(shadowsPanels[0], POWER, {0.0f, 0.0f}); | 239 | _memory->WriteEntityData<float>(shadowsPanels[0], POWER, {0.0f, 0.0f}); |
240 | // Turn on new starting panel | 240 | // Turn on new starting panel |
241 | _memory->WritePanelData<float>(shadowsPanels[randomOrder[0]], POWER, {1.0f, 1.0f}); | 241 | _memory->WriteEntityData<float>(shadowsPanels[randomOrder[0]], POWER, {1.0f, 1.0f}); |
242 | } | 242 | } |
243 | 243 | ||
244 | void Randomizer::RandomizeTown() { | 244 | void Randomizer::RandomizeTown() { |
@@ -298,7 +298,7 @@ void Randomizer::RandomizeMountain() { | |||
298 | // Randomize final pillars order | 298 | // Randomize final pillars order |
299 | std::vector<int> targets = {pillars[0] + 1}; | 299 | std::vector<int> targets = {pillars[0] + 1}; |
300 | for (const int pillar : pillars) { | 300 | for (const int pillar : pillars) { |
301 | int target = _memory->ReadPanelData<int>(pillar, TARGET, 1)[0]; | 301 | int target = _memory->ReadEntityData<int>(pillar, TARGET, 1)[0]; |
302 | targets.push_back(target); | 302 | targets.push_back(target); |
303 | } | 303 | } |
304 | targets[5] = pillars[5] + 1; | 304 | targets[5] = pillars[5] + 1; |
@@ -309,17 +309,17 @@ void Randomizer::RandomizeMountain() { | |||
309 | RandomizeRange(randomOrder, SWAP::NONE, 5, 9); // Right Pillars 1-4 | 309 | RandomizeRange(randomOrder, SWAP::NONE, 5, 9); // Right Pillars 1-4 |
310 | ReassignTargets(pillars, randomOrder, targets); | 310 | ReassignTargets(pillars, randomOrder, targets); |
311 | // Turn off original starting panels | 311 | // Turn off original starting panels |
312 | _memory->WritePanelData<float>(pillars[0], POWER, {0.0f, 0.0f}); | 312 | _memory->WriteEntityData<float>(pillars[0], POWER, {0.0f, 0.0f}); |
313 | _memory->WritePanelData<float>(pillars[5], POWER, {0.0f, 0.0f}); | 313 | _memory->WriteEntityData<float>(pillars[5], POWER, {0.0f, 0.0f}); |
314 | // Turn on new starting panels | 314 | // Turn on new starting panels |
315 | _memory->WritePanelData<float>(pillars[randomOrder[0]], POWER, {1.0f, 1.0f}); | 315 | _memory->WriteEntityData<float>(pillars[randomOrder[0]], POWER, {1.0f, 1.0f}); |
316 | _memory->WritePanelData<float>(pillars[randomOrder[5]], POWER, {1.0f, 1.0f}); | 316 | _memory->WriteEntityData<float>(pillars[randomOrder[5]], POWER, {1.0f, 1.0f}); |
317 | } | 317 | } |
318 | 318 | ||
319 | void Randomizer::RandomizeChallenge() { | 319 | void Randomizer::RandomizeChallenge() { |
320 | ChallengeRandomizer cr(_memory, Random::RandInt(1, 0x7FFFFFFF)); // 0 will trigger an "RNG not initialized" block | 320 | ChallengeRandomizer cr(_memory, Random::RandInt(1, 0x7FFFFFFF)); // 0 will trigger an "RNG not initialized" block |
321 | for (int panel : challengePanels) { | 321 | for (int panel : challengePanels) { |
322 | _memory->WritePanelData<int>(panel, POWER_OFF_ON_FAIL, {0}); | 322 | _memory->WriteEntityData<int>(panel, POWER_OFF_ON_FAIL, {0}); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
@@ -420,10 +420,10 @@ void Randomizer::SwapPanels(int panel1, int panel2, int flags) { | |||
420 | } | 420 | } |
421 | 421 | ||
422 | for (auto const& [offset, size] : offsets) { | 422 | for (auto const& [offset, size] : offsets) { |
423 | std::vector<byte> panel1data = _memory->ReadPanelData<byte>(panel1, offset, size); | 423 | std::vector<byte> panel1data = _memory->ReadEntityData<byte>(panel1, offset, size); |
424 | std::vector<byte> panel2data = _memory->ReadPanelData<byte>(panel2, offset, size); | 424 | std::vector<byte> panel2data = _memory->ReadEntityData<byte>(panel2, offset, size); |
425 | _memory->WritePanelData<byte>(panel2, offset, panel1data); | 425 | _memory->WriteEntityData<byte>(panel2, offset, panel1data); |
426 | _memory->WritePanelData<byte>(panel1, offset, panel2data); | 426 | _memory->WriteEntityData<byte>(panel1, offset, panel2data); |
427 | } | 427 | } |
428 | } | 428 | } |
429 | 429 | ||
@@ -433,7 +433,7 @@ void Randomizer::ReassignTargets(const std::vector<int>& panels, const std::vect | |||
433 | // The first panel may not have a wire to power it, so we use the panel ID itself. | 433 | // The first panel may not have a wire to power it, so we use the panel ID itself. |
434 | targets = {panels[0] + 1}; | 434 | targets = {panels[0] + 1}; |
435 | for (const int panel : panels) { | 435 | for (const int panel : panels) { |
436 | int target = _memory->ReadPanelData<int>(panel, TARGET, 1)[0]; | 436 | int target = _memory->ReadEntityData<int>(panel, TARGET, 1)[0]; |
437 | targets.push_back(target); | 437 | targets.push_back(target); |
438 | } | 438 | } |
439 | } | 439 | } |
@@ -441,17 +441,17 @@ void Randomizer::ReassignTargets(const std::vector<int>& panels, const std::vect | |||
441 | for (size_t i=0; i<order.size() - 1; i++) { | 441 | for (size_t i=0; i<order.size() - 1; i++) { |
442 | // Set the target of order[i] to order[i+1], using the "real" target as determined above. | 442 | // Set the target of order[i] to order[i+1], using the "real" target as determined above. |
443 | const int panelTarget = targets[order[i+1]]; | 443 | const int panelTarget = targets[order[i+1]]; |
444 | _memory->WritePanelData<int>(panels[order[i]], TARGET, {panelTarget}); | 444 | _memory->WriteEntityData<int>(panels[order[i]], TARGET, {panelTarget}); |
445 | } | 445 | } |
446 | } | 446 | } |
447 | 447 | ||
448 | void Randomizer::ReassignNames(const std::vector<int>& panels, const std::vector<int>& order) { | 448 | void Randomizer::ReassignNames(const std::vector<int>& panels, const std::vector<int>& order) { |
449 | std::vector<int64_t> names; | 449 | std::vector<int64_t> names; |
450 | for (const int panel : panels) { | 450 | for (const int panel : panels) { |
451 | names.push_back(_memory->ReadPanelData<int64_t>(panel, AUDIO_LOG_NAME, 1)[0]); | 451 | names.push_back(_memory->ReadEntityData<int64_t>(panel, AUDIO_LOG_NAME, 1)[0]); |
452 | } | 452 | } |
453 | 453 | ||
454 | for (int i=0; i<panels.size(); i++) { | 454 | for (int i=0; i<panels.size(); i++) { |
455 | _memory->WritePanelData<int64_t>(panels[i], AUDIO_LOG_NAME, {names[order[i]]}); | 455 | _memory->WriteEntityData<int64_t>(panels[i], AUDIO_LOG_NAME, {names[order[i]]}); |
456 | } | 456 | } |
457 | } | 457 | } |