Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rust/maprando-game/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,7 @@ pub struct GameData {
pub vertex_isv: IndexedVec<VertexKey>,
pub grey_lock_map: HashMap<(RoomId, NodeId), JsonValue>,
pub item_locations: Vec<(RoomId, NodeId)>,
pub vanilla_items: HashMap<(RoomId, NodeId), Item>,
pub item_vertex_ids: Vec<Vec<VertexId>>,
pub flag_ids: Vec<FlagId>,
pub flag_vertex_ids: Vec<Vec<VertexId>>,
Expand Down Expand Up @@ -3816,7 +3817,10 @@ impl GameData {

for (&(room_id, node_id), node_json) in &self.node_json_map {
if node_json["nodeType"] == "item" {
let item_type = &node_json["nodeItem"];
let item: Item = item_type.as_str().expect("Missing?").parse().unwrap();
self.item_locations.push((room_id, node_id));
self.vanilla_items.insert((room_id, node_id), item);
}
if node_json.has_key("utility") {
if node_json["utility"].members().any(|x| x == "save") {
Expand Down
1 change: 1 addition & 0 deletions rust/maprando-web/src/logic_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ fn get_difficulty_config(preset: &PresetData) -> DifficultyConfig {
speed_ball_tiles: preset.preset.speed_ball_tiles as f32,
shinecharge_leniency_frames: preset.preset.shinecharge_leniency_frames as Capacity,
progression_rate: maprando::randomize::ProgressionRate::Fast,
item_location_restriction: maprando::randomize::ItemLocationRestriction::None,
random_tank: true,
spazer_before_plasma: true,
stop_item_placement_early: false,
Expand Down
9 changes: 9 additions & 0 deletions rust/maprando-web/src/web/randomize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ struct RandomizeRequest {
progression_rate: Text<String>,
item_placement_style: Text<String>,
item_priority_strength: Text<String>,
item_location_restriction: Text<String>,
random_tank: Text<String>,
spazer_before_plasma: Text<String>,
stop_item_placement_early: Text<String>,
Expand Down Expand Up @@ -301,6 +302,14 @@ async fn randomize(
req.progression_rate.0.as_str()
),
},
item_location_restriction: match req.item_location_restriction.0.as_str() {
"None" => maprando::randomize::ItemLocationRestriction::None,
"Vanilla" => maprando::randomize::ItemLocationRestriction::Vanilla,
_ => panic!(
"Unrecognized item location restriction {}",
req.item_location_restriction.0.as_str()
),
},
item_priority_strength: match req.item_priority_strength.0.as_str() {
"Moderate" => ItemPriorityStrength::Moderate,
"Heavy" => ItemPriorityStrength::Heavy,
Expand Down
3 changes: 3 additions & 0 deletions rust/maprando-web/src/web/randomize/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub struct SeedHeaderTemplate<'a> {
semi_filler_items: Vec<String>,
early_filler_items: Vec<String>,
item_placement_style: String,
item_location_restriction: String,
difficulty: &'a DifficultyConfig,
_notable_strats: Vec<String>,
quality_of_life_preset: String,
Expand Down Expand Up @@ -258,6 +259,7 @@ pub fn get_difficulty_tiers(
preset.shinecharge_leniency_frames as Capacity,
),
progression_rate: difficulty.progression_rate,
item_location_restriction: difficulty.item_location_restriction,
random_tank: difficulty.random_tank,
spazer_before_plasma: difficulty.spazer_before_plasma,
stop_item_placement_early: difficulty.stop_item_placement_early,
Expand Down Expand Up @@ -518,6 +520,7 @@ pub fn render_seed(
.map(|x| format!("{:?}", x))
.collect(),
item_placement_style: format!("{:?}", seed_data.difficulty.item_placement_style),
item_location_restriction: format!("{:?}", seed_data.difficulty.item_location_restriction),
difficulty: &seed_data.difficulty,
_notable_strats: notable_strats,
quality_of_life_preset: seed_data
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!-- Button trigger modal -->
<button type="button" class="btn mr-1 px-2 py-1" data-bs-toggle="modal" data-bs-target="#itemLocationRestrictionModal">
<i class="bi bi-question-circle"></i>
</button>
<!-- Modal -->
<div class="modal" id="itemLocationRestrictionModal" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5">Item location restriction</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body"> This setting restricts what locations items can be placed at.<p>
<ul>
<li>
<p><strong>None</strong>: No extra restrictions.</p>
<li>
<p><strong>Vanilla</strong>: Items can only be placed at the locations where they would appear in the vanilla game.</p>
</li>
</ul>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
22 changes: 22 additions & 0 deletions rust/maprando-web/templates/generate/item_progression.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@
</div>
</div>

<div class="form-group row">
<div class="col-lg-3 m-2">
{% include "help/progression/item_location_restriction.html" %}
<label for="preset">Item location restriction</label>
</div>
<div class="col-lg-3 btn-group m-2" role="group">
{% for name in ["None", "Vanilla"] %}
<input type="radio"
class="btn-check"
name="item_location_restriction"
id="itemLocationRestriction{{+ name }}"
value="{{+ name}}"
onclick="itemProgressionChanged()"
autocomplete="off"
{% if name == "None"|as_ref %}
checked
{% endif %}>
<label class="btn btn-outline-primary" for="itemLocationRestriction{{+ name }}">{{+ name }}</label>
{% endfor %}
</div>
</div>

<div class="form-group row">
<div class="col-lg-3 m-2">
{% include "help/progression/random_tank.html" %}
Expand Down
6 changes: 5 additions & 1 deletion rust/maprando-web/templates/generate/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
function itemProgressionPresetChanged() {
if (document.getElementById("itemProgressionPresetNormal").checked) {
document.getElementById("progressionRateFast").checked = true;
document.getElementById("itemLocationRestrictionNone").checked = true;
document.getElementById("itemPlacementStyleNeutral").checked = true;
document.getElementById("itemPriorityStrengthModerate").checked = true;
document.getElementById("randomTankYes").checked = true;
Expand Down Expand Up @@ -282,6 +283,7 @@
}
if (document.getElementById("itemProgressionPresetTricky").checked) {
document.getElementById("progressionRateUniform").checked = true;
document.getElementById("itemLocationRestrictionNone").checked = true;
document.getElementById("itemPlacementStyleForced").checked = true;
document.getElementById("itemPriorityStrengthModerate").checked = true;
document.getElementById("randomTankYes").checked = true;
Expand Down Expand Up @@ -312,6 +314,7 @@
}
if (document.getElementById("itemProgressionPresetChallenge").checked) {
document.getElementById("progressionRateSlow").checked = true;
document.getElementById("itemLocationRestrictionNone").checked = true;
document.getElementById("itemPlacementStyleForced").checked = true;
document.getElementById("itemPriorityStrengthModerate").checked = true;
document.getElementById("randomTankYes").checked = true;
Expand All @@ -337,6 +340,7 @@
}
if (document.getElementById("itemProgressionPresetDesolate").checked) {
document.getElementById("progressionRateSlow").checked = true;
document.getElementById("itemLocationRestrictionNone").checked = true;
document.getElementById("itemPlacementStyleForced").checked = true;
document.getElementById("itemPriorityStrengthModerate").checked = true;
document.getElementById("randomTankYes").checked = true;
Expand Down Expand Up @@ -367,7 +371,7 @@
document.getElementById("itemProgressionPresetNormal").checked = false;
document.getElementById("itemProgressionPresetTricky").checked = false;
document.getElementById("itemProgressionPresetChallenge").checked = false;
document.getElementById("itemProgressionPresetDesolate").checked = false;
document.getElementById("itemProgressionPresetDesolate").checked = false;
}
function processStartingItemsPreset() {
if (document.getElementById("startingItemsPresetNone").checked) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<div class="col-6 col-sm-5 col-md-4 col-lg-3">Item placement:</div>
<div class="col-6 col-sm-7 col-md-8 col-lg-9">{{+ item_placement_style }}</div>
</div>
<div class="row">
<div class="col-6 col-sm-5 col-md-4 col-lg-3">Item location restriction:</div>
<div class="col-6 col-sm-7 col-md-8 col-lg-9">{{+ item_location_restriction }}</div>
</div>
<div class="row">
<div class="col-6 col-sm-5 col-md-4 col-lg-3">Item priority strength:</div>
<div class="col-6 col-sm-7 col-md-8 col-lg-9">{% let difficulty = difficulty %}{{+ format!("{:?}", difficulty.item_priority_strength) }}</div>
Expand Down
5 changes: 3 additions & 2 deletions rust/maprando/src/bin/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use anyhow::Result;
use hashbrown::HashMap;
use maprando::{
randomize::{
AreaAssignment, DifficultyConfig, DoorsMode, ItemDotChange, ItemMarkers,
ItemPlacementStyle, ItemPriorityGroup, ItemPriorityStrength, MapStationReveal,
AreaAssignment, DifficultyConfig, DoorsMode, ItemDotChange, ItemLocationRestriction,
ItemMarkers, ItemPlacementStyle, ItemPriorityGroup, ItemPriorityStrength, MapStationReveal,
MapsRevealed, MotherBrainFight, ProgressionRate, SaveAnimals, WallJump,
},
traverse::{apply_requirement, LockedDoorData},
Expand Down Expand Up @@ -87,6 +87,7 @@ fn run_scenario(
speed_ball_tiles: 24.0,
shinecharge_leniency_frames: 15,
progression_rate: ProgressionRate::Uniform,
item_location_restriction: ItemLocationRestriction::None,
random_tank: true,
spazer_before_plasma: true,
stop_item_placement_early: false,
Expand Down
39 changes: 13 additions & 26 deletions rust/maprando/src/bin/maprando-cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use maprando::customize::{customize_rom, ControllerConfig, CustomizeSettings, Mu
use maprando::patch::ips_write::create_ips_patch;
use maprando::patch::Rom;
use maprando::randomize::{
randomize_doors, AreaAssignment, DoorsMode, ItemDotChange, ItemMarkers, ItemPlacementStyle,
ItemPriorityGroup, ItemPriorityStrength, MapStationReveal, MotherBrainFight, ProgressionRate,
Randomization, Randomizer, SaveAnimals, StartLocationMode,
randomize_doors, AreaAssignment, DoorsMode, ItemDotChange, ItemLocationRestriction,
ItemMarkers, ItemPlacementStyle, ItemPriorityGroup, ItemPriorityStrength, MapStationReveal,
MotherBrainFight, ProgressionRate, Randomization, Randomizer, SaveAnimals, StartLocationMode,
};
use maprando::spoiler_map;
use maprando::{patch::make_rom, randomize::DifficultyConfig};
Expand Down Expand Up @@ -54,30 +54,17 @@ fn get_randomization(args: &Args, game_data: &GameData) -> Result<Randomization>
name: None,
tech: game_data.tech_isv.keys.clone(),
notable_strats: vec![],
shine_charge_tiles: 16.0,
heated_shine_charge_tiles: 16.0,
speed_ball_tiles: 24.0,
shinecharge_leniency_frames: 15,
shine_charge_tiles: 13.0,
heated_shine_charge_tiles: 14.0,
speed_ball_tiles: 15.0,
shinecharge_leniency_frames: 0,
progression_rate: ProgressionRate::Fast,
item_location_restriction: ItemLocationRestriction::Vanilla,
random_tank: true,
spazer_before_plasma: true,
stop_item_placement_early: false,
item_pool: vec![],
starting_items: vec![
(Item::Gravity, 1),
(Item::Varia, 1),
(Item::Morph, 1),
(Item::Missile, 1),
(Item::Super, 1),
(Item::PowerBomb, 1),
(Item::SpeedBooster, 1),
(Item::SpaceJump, 1),
(Item::ScrewAttack, 1),
(Item::HiJump, 1),
(Item::Grapple, 1),
(Item::ETank, 1),
(Item::ReserveTank, 1),
],
starting_items: vec![],
semi_filler_items: vec![],
filler_items: vec![Item::Missile],
early_filler_items: vec![],
Expand All @@ -104,7 +91,7 @@ fn get_randomization(args: &Args, game_data: &GameData) -> Result<Randomization>
},
],
resource_multiplier: 1.0,
escape_timer_multiplier: 3.0,
escape_timer_multiplier: 1.0,
gate_glitch_leniency: 0,
door_stuck_leniency: 0,
phantoon_proficiency: 1.0,
Expand All @@ -113,9 +100,9 @@ fn get_randomization(args: &Args, game_data: &GameData) -> Result<Randomization>
botwoon_proficiency: 1.0,
mother_brain_proficiency: 1.0,
supers_double: true,
mother_brain_fight: MotherBrainFight::Skip,
escape_enemies_cleared: true,
escape_refill: true,
mother_brain_fight: MotherBrainFight::Vanilla,
escape_enemies_cleared: false,
escape_refill: false,
escape_movement_items: true,
mark_map_stations: true,
room_outline_revealed: true,
Expand Down
8 changes: 5 additions & 3 deletions rust/maprando/src/bin/maprando-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ use maprando::patch::ips_write::create_ips_patch;
use maprando::patch::Rom;
use maprando::preset::Preset;
use maprando::randomize::{
randomize_doors, randomize_map_areas, AreaAssignment, DoorsMode, ItemDotChange, ItemMarkers,
ItemPlacementStyle, ItemPriorityGroup, ItemPriorityStrength, MotherBrainFight, Objective,
ProgressionRate, Randomization, Randomizer, SaveAnimals, StartLocationMode,
randomize_doors, randomize_map_areas, AreaAssignment, DoorsMode, ItemDotChange,
ItemLocationRestriction, ItemMarkers, ItemPlacementStyle, ItemPriorityGroup,
ItemPriorityStrength, MotherBrainFight, Objective, ProgressionRate, Randomization, Randomizer,
SaveAnimals, StartLocationMode,
};
use maprando::spoiler_map;
use maprando::{patch::make_rom, randomize::DifficultyConfig};
Expand Down Expand Up @@ -63,6 +64,7 @@ fn create_difficulty_from_preset(preset: &Preset) -> DifficultyConfig {
mother_brain_proficiency: preset.mother_brain_proficiency,
// Progression options, Normal preset
progression_rate: ProgressionRate::Fast,
item_location_restriction: ItemLocationRestriction::None,
random_tank: true,
spazer_before_plasma: true,
stop_item_placement_early: false,
Expand Down
Loading