Skip to content

Commit

Permalink
Merge branch 'main' into main-plaza-dt-render
Browse files Browse the repository at this point in the history
  • Loading branch information
toasterparty authored Apr 11, 2024
2 parents f814f78 + a308024 commit 5b7bd3d
Show file tree
Hide file tree
Showing 9 changed files with 404 additions and 73 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ To give you a taste of what's implemented, here are some highlighted features wh

## Usage

- The application which best makes use of this program is [randovania](https://github.com/randovania/randovania). It's a full-GUI application centered around randomizing the game with various settings, even supporting co-operative multiworld.
- The application which best makes use of this program is [randovania](https://github.com/randovania/randovania). It's a full-GUI application centered around randomizing the game with various settings, even supporting co-operative multiworld. It's implemented via the py-randomprime wrapper (described below)
- Some "fanhacks" have been made utilizing the features exposed by this program more directly. They can be found in the [metroid-prime-fanhacks](https://github.com/toasterparty/metroid-prime-fanhacks) repository. Be sure to check out the [Creator's Guide](https://github.com/toasterparty/metroid-prime-fanhacks/blob/main/doc/readme.md) for an in-depth dive into the patcher API and how to use it.
- [py-randomprime](https://github.com/randovania/py-randomprime) implements Python bindings for this project's feature set making it much more portable.
- [py-randomprime](https://github.com/randovania/py-randomprime) implements Python bindings for this project's feature set making it much more portable. The py-randomprime repository also builds standalone windows executable files (`.exe`) and attaches them to each release.

## Documentation

Expand Down
25 changes: 19 additions & 6 deletions schema/randomprime.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3172,6 +3172,12 @@
"description": "Position of the point",
"$ref": "#/$defs/vector3"
},
"layer": {
"description": "Layer # to place the lockOnPoint at",
"type": "integer",
"minimum": 0,
"maximum": 63
},
"isGrapple": {
"description": "If true, adds grapple functionality to this point.",
"type": "boolean",
Expand Down Expand Up @@ -3738,11 +3744,21 @@
},
"position": {
"description": "Position of the trigger.",
"$ref": "#/$defs/vector3"
"$ref": "#/$defs/vector3",
"default": [
0.0,
0.0,
0.0
]
},
"scale": {
"description": "Extent of the trigger.",
"$ref": "#/$defs/vector3Positive"
"$ref": "#/$defs/vector3Positive",
"default": [
5,
5,
5
]
},
"force": {
"description": "If the apply force flag is enabled, this is the force applied.",
Expand Down Expand Up @@ -3781,10 +3797,7 @@
"default": false
}
},
"required": [
"position",
"scale"
],
"required": [],
"additionalProperties": false
}
},
Expand Down
53 changes: 27 additions & 26 deletions src/add_modify_obj_patches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,8 @@ pub fn patch_add_trigger<'r>(
() => {
structs::Trigger {
name: b"my trigger\0".as_cstr(),
position: config.position.into(),
scale: config.scale.into(),
position: config.position.unwrap_or([0.0, 0.0, 0.0]).into(),
scale: config.scale.unwrap_or([5.0, 5.0, 5.0]).into(),
damage_info: structs::scly_structs::DamageInfo {
weapon_type: config.damage_type.unwrap_or(DamageType::Power) as u32,
damage: config.damage_amount.unwrap_or(0.0),
Expand All @@ -577,16 +577,16 @@ pub fn patch_add_trigger<'r>(
($obj:expr) => {
let property_data = $obj.property_data.as_trigger_mut().unwrap();

property_data.position = config.position.into();
property_data.scale = config.scale.into();

if let Some(active ) = config.active { property_data.active = active as u8 }
if let Some(damage_type ) = config.damage_type { property_data.damage_info .weapon_type = damage_type as u32 }
if let Some(damage_amount ) = config.damage_amount { property_data.damage_info .damage = damage_amount }
if let Some(force ) = config.force { property_data.force = force .into() }
if let Some(flags ) = config.flags { property_data.flags = flags }
if let Some(deactivate_on_enter) = config.deactivate_on_enter { property_data.deactivate_on_enter = deactivate_on_enter as u8 }
if let Some(deactivate_on_exit ) = config.deactivate_on_exit { property_data.deactivate_on_exit = deactivate_on_exit as u8 }
if let Some(active ) = config.active { property_data.active = active as u8 }
if let Some(position ) = config.position { property_data.position = position .into() }
if let Some(scale ) = config.scale { property_data.scale = scale .into() }
if let Some(damage_type ) = config.damage_type { property_data.damage_info .weapon_type = damage_type as u32 }
if let Some(damage_type ) = config.damage_type { property_data.damage_info .weapon_type = damage_type as u32 }
if let Some(damage_amount ) = config.damage_amount { property_data.damage_info .damage = damage_amount }
if let Some(force ) = config.force { property_data.force = force .into() }
if let Some(flags ) = config.flags { property_data.flags = flags }
if let Some(deactivate_on_enter ) = config.deactivate_on_enter { property_data.deactivate_on_enter = deactivate_on_enter as u8 }
if let Some(deactivate_on_exit ) = config.deactivate_on_exit { property_data.deactivate_on_exit = deactivate_on_exit as u8 }
};
}

Expand Down Expand Up @@ -2444,6 +2444,7 @@ pub fn patch_lock_on_point<'r>(
let is_grapple = config.is_grapple.unwrap_or(false);
let no_lock = config.no_lock.unwrap_or(false);
let position = config.position;
let layer = config.layer.unwrap_or(0) as usize;

if is_grapple {
let deps = vec![
Expand All @@ -2467,7 +2468,7 @@ pub fn patch_lock_on_point<'r>(
area.add_dependencies(game_resources, 0, deps_iter);
}

let actor_id = config.id1.unwrap_or(area.new_object_id_from_layer_name("Default"));
let actor_id = config.id1.unwrap_or(area.new_object_id_from_layer_id(layer));
let mut grapple_point_id = 0;
let mut special_function_id = 0;
let mut timer_id = 0;
Expand All @@ -2477,20 +2478,20 @@ pub fn patch_lock_on_point<'r>(
let mut add_scan_point = false;

if is_grapple {
grapple_point_id = config.id2.unwrap_or(area.new_object_id_from_layer_name("Default"));
grapple_point_id = config.id2.unwrap_or(area.new_object_id_from_layer_id(layer));
add_scan_point = true; // We don't actually need the scan points, just their assets. Could save on objects by making this false via config
if add_scan_point {
special_function_id = area.new_object_id_from_layer_name("Default");
timer_id = area.new_object_id_from_layer_name("Default");
poi_pre_id = area.new_object_id_from_layer_name("Default");
poi_post_id = area.new_object_id_from_layer_name("Default");
special_function_id = area.new_object_id_from_layer_id(layer);
timer_id = area.new_object_id_from_layer_id(layer);
poi_pre_id = area.new_object_id_from_layer_id(layer);
poi_post_id = area.new_object_id_from_layer_id(layer);
}
} else if !no_lock {
damageable_trigger_id = config.id2.unwrap_or(area.new_object_id_from_layer_name("Default"));
damageable_trigger_id = config.id2.unwrap_or(area.new_object_id_from_layer_id(layer));
}

let layers = area.mrea().scly_section_mut().layers.as_mut_vec();
layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: actor_id,
property_data: structs::Actor {
Expand Down Expand Up @@ -2569,7 +2570,7 @@ pub fn patch_lock_on_point<'r>(
);

if is_grapple {
layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: grapple_point_id,
property_data: structs::GrapplePoint {
Expand Down Expand Up @@ -2598,7 +2599,7 @@ pub fn patch_lock_on_point<'r>(
);

if add_scan_point {
layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: special_function_id,
connections: vec![
Expand Down Expand Up @@ -2636,7 +2637,7 @@ pub fn patch_lock_on_point<'r>(
}
);

layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: timer_id,
connections: vec![
Expand All @@ -2657,7 +2658,7 @@ pub fn patch_lock_on_point<'r>(
}
);

layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: poi_pre_id,
connections: vec![].into(),
Expand All @@ -2676,7 +2677,7 @@ pub fn patch_lock_on_point<'r>(
}
);

layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: poi_post_id,
connections: vec![].into(),
Expand All @@ -2696,7 +2697,7 @@ pub fn patch_lock_on_point<'r>(
);
}
} else if !no_lock {
layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: damageable_trigger_id,
property_data: structs::DamageableTrigger {
Expand Down
19 changes: 19 additions & 0 deletions src/bin/resource_tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,25 @@ fn main()
}

let mut deps: Vec<_> = pickup_table[&pm].deps.iter().collect();

let res = ResourceKey::new(0x29782CA6, FourCC::from_bytes(b"TXTR"));
deps.push(&res);

let res = ResourceKey::new(0xA0DA476B, FourCC::from_bytes(b"PART"));
deps.push(&res);

let res = ResourceKey::new(0x5E027EA1, FourCC::from_bytes(b"TXTR"));
deps.push(&res);

let res = ResourceKey::new(0x79B5BD15, FourCC::from_bytes(b"TXTR"));
deps.push(&res);

let res = ResourceKey::new(0xE224FF03, FourCC::from_bytes(b"TXTR"));
deps.push(&res);

let res = ResourceKey::new(0x57fe7e67, FourCC::from_bytes(b"AGSC"));
deps.push(&res);

deps.sort();
println!(" PickupModel::{:?} => {{", pm);
println!(" const DATA: &[(u32, FourCC)] = &[");
Expand Down
3 changes: 2 additions & 1 deletion src/custom_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ pub fn custom_assets<'r>(
Vec::new(),
Vec::new(),
Vec::new(),
Vec::new(),
];

/* Mapping of strings and their corresponding scan_id. Use this to avoid
Expand Down Expand Up @@ -650,7 +651,7 @@ pub fn custom_assets<'r>(
vec![
"Chozo script translated.\0".to_string(),
"Racing\0".to_string(),
"As we have done for millennia, we Chozo work constantly on our speed. Our fastest are our sentinels; They are, and have always been, repositories for our most precious secrets and strongest powers.\n\n2024 (CGC) - TheGingerChris + BajaBlood\n2023 - Cosmonawt\n2022 (CGC) - Cosmo + Cestrion\n2021 - Dinopony\n2020 - Interslice\n2019 - TheWeakestLink64\0".to_string(),
"As we have done for millennia, we Chozo work constantly on our speed. Our fastest are our sentinels; They are, and have always been, repositories for our most precious secrets and strongest powers.\n\n2023 (CGC) - TheGingerChris + BajaBlood\n2023 - Cosmonawt\n2022 (CGC) - Cosmo + Cestrion\n2021 - Dinopony\n2020 - Interslice\n2019 - TheWeakestLink64\0".to_string(),
],
1,
0,
Expand Down
4 changes: 3 additions & 1 deletion src/mlvl_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ impl<'r, 'mlvl, 'cursor, 'list> MlvlArea<'r, 'mlvl, 'cursor, 'list>
}

self.mrea().scly_section_mut().layers.as_mut_vec().push(SclyLayer::new());

assert!(self.layer_names.len() as u32 == self.layer_flags.layer_count);
assert!(self.layer_flags.layer_count as u32 == self.mrea().scly_section().layers.len() as u32);
}

pub fn add_dependencies<I>(&mut self, pickup_resources: &HashMap<(u32, FourCC), Resource<'r>>,
Expand All @@ -228,4 +231,3 @@ impl<'r, 'mlvl, 'cursor, 'list> MlvlArea<'r, 'mlvl, 'cursor, 'list>
self.mrea_cursor.insert_after(iter);
}
}

5 changes: 3 additions & 2 deletions src/patch_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ pub struct CameraHintConfig
pub struct LockOnPoint
{
pub id1: Option<u32>,
pub layer: Option<u32>,
pub active1: Option<bool>,
pub id2: Option<u32>,
pub active2: Option<bool>,
Expand Down Expand Up @@ -393,8 +394,8 @@ pub struct TriggerConfig
pub id: Option<u32>,
pub layer: Option<u32>,
pub active: Option<bool>,
pub position: [f32;3],
pub scale: [f32;3],
pub position: Option<[f32;3]>,
pub scale: Option<[f32;3]>,
pub force: Option<[f32;3]>,
pub damage_type: Option<DamageType>,
pub damage_amount: Option<f32>,
Expand Down
Loading

0 comments on commit 5b7bd3d

Please sign in to comment.