Skip to content

Commit

Permalink
Custom item support
Browse files Browse the repository at this point in the history
Required mains supported for Missiles/PB
Unlimited Missiles/PBs are supported now
Spring Ball has its own item now
  • Loading branch information
UltiNaruto committed Aug 24, 2024
1 parent 0881b63 commit dbb3e8d
Show file tree
Hide file tree
Showing 10 changed files with 588 additions and 193 deletions.
6 changes: 6 additions & 0 deletions ppcasm/ppcasm_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ decl_instrs! {
addc[o][.], (r:d), (r:a), (r:b) => (6;31) | d | a | b | (?o) | (9;10) | (?.);
addi, (r:d), (r:a), (i:imm) => (6;14) | d | a | (16;imm);
addic[.], (r:d), (r:a), (i:imm) => (5;6) | (?.) | d | a | (16;imm);
and[.], (r:d), (r:a), (r:b) => (6;31) | d | a | b | (10;28) | (?.);
andi, (r:d), (r:a), (i:imm) => (6;28) | d | a | (16;imm);
andis, (r:d), (r:a), (i:imm) => (6;29) | d | a | (16;imm);
b[l][a], (l:li) => (6;18) | (24;li) | (?a) | (?l);
Expand Down Expand Up @@ -409,11 +410,16 @@ decl_instrs! {
mr, (r:a), (r:s) => (6;31) | s | a | s | (10;444) | (1;0);
mtlr, (r:d) => (6;31) | d | (10;0x100) | (10;467) | (1;0);
mullw[o][.],(r:d), (r:a), (r:b) => (6;31) | d | a | b | (?o) | (9;235) | (?.);
neg, (r:d), (r:a) => (6;31) | d | a | (16;208);
nop => (32;0x60000000);
nor[.], (r:d), (r:a), (r:b) => (6;31) | d | a | b | (10;124) | (?.);
not, (r:a), (r:s) => (6;31) | s | a | s | (10;124) | (1;0);
or[.], (r:d), (r:a), (r:b) => (6;31) | d | a | b | (10;444) | (?.);
ori, (r:d), (r:a), (i:imm) => (6;24) | d | a | (16;imm);
oris, (r:d), (r:a), (i:imm) => (6;25) | d | a | (16;imm);
slw[.], (r:d), (r:a), (r:b) => (6;31) | d | a | b | (10;24) | (?.);
slwi, (r:a), (r:s), (i:n) => (6;21) | s | a | (5;{#n}) | (5;0) |(5;{31 - #n}) | (1;0);
srw[.], (r:d), (r:a), (r:b) => (6;31) | d | a | b | (10;536) | (?.);
srwi, (r:a), (r:s), (i:n) => (6;21) | s | a | (5;{32 - #n}) | (5;n) |(5;31) | (1;0);
rlwimi[.], (r:a), (r:s), (i:sh), (i:mb), (i:me) =>
(6;20) | s | a | (5;sh) | (5;mb) |(5;me) | (?.);
Expand Down
80 changes: 72 additions & 8 deletions schema/randomprime.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,15 @@
"type": "string"
},
"springBall": {
"description": "Restores the Spring Ball feature from Metroid Prime Trilogy. Use C-Stick Up while being morphed to use Spring Ball. NOTE: You need Morph Ball Bombs to use Spring Ball just like in Metroid Prime Trilogy.",
"description": "[Deprecated] Restores the Spring Ball feature from Metroid Prime Trilogy. Use C-Stick Up while being morphed to use Spring Ball. NOTE: You need Morph Ball Bombs to use Spring Ball just like in Metroid Prime Trilogy.",
"type": "boolean",
"default": false
"default": false,
"deprecated": true
},
"springBallItem": {
"description": "Spring Ball will require this item to be obtained before being able to use it.",
"type": "string",
"default": "Spring Ball"
},
"warpToStart": {
"description": "Refusing to save at any Save Station while holding L + R will warp you to the starting location (by default, Samus' Ship in Tallon Overworld: Landing Site)",
Expand Down Expand Up @@ -470,9 +476,10 @@
"default": false
},
"enableIceTraps": {
"description": "Set to true if Ice Traps items are used in this layout.",
"description": "[Deprecated] Does not do anything anymore",
"type": "boolean",
"default": false
"default": false,
"deprecated": true
},
"missileStationPbRefill": {
"description": "If enabled, Missile Stations also refill Power Bomb ammunition.",
Expand Down Expand Up @@ -2492,6 +2499,12 @@
"type": "boolean",
"default": false
},
"powerSuit": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295,
"default": 0
},
"variaSuit": {
"type": "boolean",
"default": false
Expand Down Expand Up @@ -2535,6 +2548,32 @@
"flamethrower": {
"type": "boolean",
"default": false
},
"unknownItem1": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295,
"default": 0
},
"unlimitedMissiles": {
"type": "boolean",
"default": false
},
"unlimitedPowerBombs": {
"type": "boolean",
"default": false
},
"missileLauncher": {
"type": "boolean",
"default": true
},
"powerBombLauncher": {
"type": "boolean",
"default": true
},
"springBall": {
"type": "boolean",
"default": false
}
},
"required": [
Expand All @@ -2552,6 +2591,7 @@
"bombs",
"spiderBall",
"boostBall",
"powerSuit",
"variaSuit",
"gravitySuit",
"phazonSuit",
Expand All @@ -2562,7 +2602,13 @@
"superMissile",
"wavebuster",
"iceSpreader",
"flamethrower"
"flamethrower",
"unknownItem1",
"unlimitedMissiles",
"unlimitedPowerBombs",
"missileLauncher",
"powerBombLauncher",
"springBall"
],
"default": {
"combatVisor": true,
Expand All @@ -2579,6 +2625,7 @@
"bombs": false,
"spiderBall": false,
"boostBall": false,
"powerSuit": 0,
"variaSuit": false,
"gravitySuit": false,
"phazonSuit": false,
Expand All @@ -2589,7 +2636,13 @@
"superMissile": false,
"wavebuster": false,
"iceSpreader": false,
"flamethrower": false
"flamethrower": false,
"unknownItem1": 0,
"unlimitedMissiles": false,
"unlimitedPowerBombs": false,
"missileLauncher": true,
"powerBombLauncher": true,
"springBall": false
},
"additionalProperties": false
},
Expand Down Expand Up @@ -2738,7 +2791,12 @@
"Artifact of Newborn",
"Nothing",
"Floaty Jump",
"Ice Trap"
"Ice Trap",
"Unlimited Missiles",
"Unlimited Power Bombs",
"Missile Launcher",
"Main Power Bomb",
"Spring Ball"
],
"default": "Nothing"
},
Expand Down Expand Up @@ -3918,6 +3976,7 @@
"default": 0
},
"itemId": {
"description": "Any custom items will be stored in UnknownItem2",
"type": "string",
"enum": [
"PowerBeam",
Expand Down Expand Up @@ -3960,7 +4019,12 @@
"ArtifactOfSun",
"ArtifactOfWorld",
"ArtifactOfSpirit",
"ArtifactOfNewborn"
"ArtifactOfNewborn",
"UnlimitedMissiles",
"UnlimitedPowerBombs",
"MissileLauncher",
"PowerBombLauncher",
"SpringBall"
],
"default": "PowerBeam"
},
Expand Down
4 changes: 2 additions & 2 deletions src/add_modify_obj_patches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@ pub fn patch_add_spawn_point(
varia_suit: 0,
phazon_suit: 0,
energy_tanks: 0,
unknown0: 0,
unknown_item_1: 0,
health_refill: 0,
unknown1: 0,
unknown_item_2: 0,
wavebuster: 0,
default_spawn: config.default_spawn.unwrap_or(false) as u8,
active: config.active.unwrap_or(true) as u8,
Expand Down
18 changes: 8 additions & 10 deletions src/custom_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,16 +1367,14 @@ pub fn collect_game_resources<'r>(
];
looking_for.extend(custom_scan_point_deps);

if config.enable_ice_traps {
let player_freeze_deps: Vec<(u32, FourCC)> = vec![
resource_info!("breakFreezeVisor.PART").into(),
resource_info!("Frost1TXTR.TXTR").into(),
resource_info!("75DAC95C.PART").into(),
resource_info!("zorch1_snow3.TXTR").into(),
resource_info!("C28C7348.PART").into(),
];
looking_for.extend(player_freeze_deps);
}
let player_freeze_deps: Vec<(u32, FourCC)> = vec![
resource_info!("breakFreezeVisor.PART").into(),
resource_info!("Frost1TXTR.TXTR").into(),
resource_info!("75DAC95C.PART").into(),
resource_info!("zorch1_snow3.TXTR").into(),
resource_info!("C28C7348.PART").into(),
];
looking_for.extend(player_freeze_deps);

// Dependencies read from paks and custom assets will go here //
let mut found = HashMap::with_capacity(looking_for.len());
Expand Down
59 changes: 53 additions & 6 deletions src/patch_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ pub struct PatchConfig {
pub starting_visor: Visor,
pub starting_beam: Beam,
pub escape_sequence_counts_up: bool,
pub enable_ice_traps: bool,
pub enable_ice_traps: bool, // deprecated
pub missile_station_pb_refill: bool,
pub door_open_mode: DoorOpenMode,

Expand Down Expand Up @@ -2335,8 +2335,16 @@ impl PatchConfigPrivate {
if !item_max_capacity.contains_key(&PickupType::EnergyTank) && !force_vanilla_layout {
item_max_capacity.insert(PickupType::EnergyTank, 200);
}
if !item_max_capacity.contains_key(&PickupType::UnknownItem2) {
item_max_capacity.insert(PickupType::UnknownItem2, 2147483647);
}

if item_max_capacity.contains_key(&PickupType::Nothing)
if item_max_capacity.contains_key(&PickupType::UnlimitedMissiles)
|| item_max_capacity.contains_key(&PickupType::UnlimitedPowerBombs)
|| item_max_capacity.contains_key(&PickupType::MissileLauncher)
|| item_max_capacity.contains_key(&PickupType::PowerBombLauncher)
|| item_max_capacity.contains_key(&PickupType::SpringBall)
|| item_max_capacity.contains_key(&PickupType::Nothing)
|| item_max_capacity.contains_key(&PickupType::FloatyJump)
|| item_max_capacity.contains_key(&PickupType::IceTrap)
{
Expand Down Expand Up @@ -2400,9 +2408,43 @@ impl PatchConfigPrivate {
Some(items) => items.clone(),
None => {
if force_vanilla_layout {
StartingItems::from_u64(2188378143)
// from u64 2188378143
StartingItems {
power_beam: true,
combat_visor: true,
scan_visor: true,
missiles: 15,
energy_tanks: 0,
power_bombs: 0,
wave: false,
ice: false,
plasma: false,
charge: true,
morph_ball: true,
bombs: true,
spider_ball: false,
boost_ball: false,
power_suit: 0,
varia_suit: true,
gravity_suit: false,
phazon_suit: false,
thermal_visor: false,
xray: false,
space_jump: false,
grapple: true,
super_missile: false,
wavebuster: false,
ice_spreader: false,
flamethrower: false,
unknown_item_1: 0,
unlimited_missiles: false,
unlimited_power_bombs: false,
missile_launcher: true,
power_bomb_launcher: true,
spring_ball: false,
}
} else {
StartingItems::from_u64(1)
StartingItems::default()
}
}
}
Expand Down Expand Up @@ -2535,7 +2577,12 @@ impl PatchConfigPrivate {
let spring_ball_item = {
match self.game_config.spring_ball_item.as_deref() {
Some(s) => PickupType::from_str(s),
None => PickupType::MorphBallBomb,
None => PickupType::from_str({
match spring_ball {
false => "Spring Ball",
true => "Morph Ball Bomb",
}
}),
}
};

Expand Down Expand Up @@ -2674,7 +2721,7 @@ impl PatchConfigPrivate {
.unwrap_or_else(|| StartingItems::from_u64(1)),
disable_item_loss: self.game_config.disable_item_loss.unwrap_or(true),
escape_sequence_counts_up: self.game_config.escape_sequence_counts_up.unwrap_or(false),
enable_ice_traps: self.game_config.enable_ice_traps.unwrap_or(false),
enable_ice_traps: self.game_config.enable_ice_traps.unwrap_or(true),
missile_station_pb_refill: self.game_config.missile_station_pb_refill.unwrap_or(false),
door_open_mode: self
.game_config
Expand Down
Loading

0 comments on commit dbb3e8d

Please sign in to comment.