Halbu
A .d2s file parsing library written in Rust.
⚠ NPCs and Items section are not yet supported.
Notes regarding D2R with some useful information regarding quests in particular.
This library uses the log crate to log parsing errors.
Usage
use halbu::{quests::QuestFlag, waypoints::Waypoint, Class, Save};
fn main() {
let save_file = std::fs::read("C:\\Users\\Example\\Saved Games\\Diablo II Resurrected\\Jamella.d2s").unwrap();
let mut save = Save::parse(&save_file);
save.character.class = Class::Paladin;
save.character.name = String::from("Halbu");
save.character.level = 47;
save.attributes.level.value = 47;
println!(
"{0}, Level {1} {2}",
save.character.name, save.character.level, save.character.class
);
save.character.mercenary.name_id = 3;
save.character.mercenary.variant_id = 34;
save.attributes.strength.value = 156;
save.attributes.newskills.value = 5;
save.attributes.maxmana.value = 200 * 256;
println!(
"Max mana: {}",
save.attributes.maxmana.value as f64 / 256f64
);
save.waypoints.normal.act1.set_all(true);
println!("Normal:\n{}", save.waypoints.normal.act1);
save.waypoints.hell.set_all(false);
save.waypoints.hell.act4.set_num(1, true);
println!("Hell Act IV WP 1: {}", save.waypoints.hell.act4.get_num(1));
save.waypoints.hell.act4.set(Waypoint::CityOfTheDamned, false);
println!(
"Hell Act IV WP 1: {}",
save.waypoints.hell.act4.get(Waypoint::CityOfTheDamned)
);
save.skills.set_all(20);
println!("{}", save.skills);
save.skills.set(17, 0);
println!("Skillpoints: {}", save.skills.get(17));
save.quests.hell.act1.q1.state.clear();
println!("Hell Act I Q1 State: {}", save.quests.hell.act1.q1);
save.quests.hell.act1.q1.state.insert(QuestFlag::RewardGranted);
println!(
"Hell Act I Q1 Completed: {}",
save.quests.hell.act1.q1.state.contains(&QuestFlag::RewardGranted)
);
std::fs::write("C:\\Users\\Example\\Saved Games\\Diablo II Resurrected\\Halbu.d2s", save.to_bytes()).unwrap();
}
Resources
These resources have helped me understand the .d2s format. Many thanks to their authors for the work they've done!