Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 69 - Crash due to missing proc_target when using "weapon trait" items #208

Open
SethSR opened this issue Mar 28, 2023 · 0 comments

Comments

@SethSR
Copy link

SethSR commented Mar 28, 2023

This line seems to crash the game if the player uses "weapon trait" generated weapons:

let effect_target = if weapon_info.proc_target.unwrap() == "Self" {

There doesn't seem to be anywhere that sets the correct proc_target in the generation code:

fn build_traited_weapons(&mut self, items_to_build : &[NewMagicItem]) {
items_to_build.iter().filter(|i| i.bonus > 0).for_each(|nmw| {
for wt in self.raws.weapon_traits.iter() {
let mut base_item_copy = self.build_base_magic_item(&nmw);
if let Some(mut weapon) = base_item_copy.weapon.as_mut() {
base_item_copy.name = format!("{} {}", wt.name, base_item_copy.name);
if let Some(base_value) = base_item_copy.base_value.as_mut() {
*base_value *= 2.0;
}
weapon.proc_chance = Some(0.25);
weapon.proc_effects = Some(wt.effects.clone());
let real_name = base_item_copy.name.clone();
self.raws.items.push(base_item_copy);
self.item_index.insert(real_name.clone(), self.raws.items.len()-1);
self.raws.spawn_table.push(super::SpawnTableEntry{
name : real_name.clone(),
weight : 9 - i32::abs(nmw.bonus),
min_depth : 2 + i32::abs((nmw.bonus-1)*3),
max_depth : 100,
add_map_depth_to_weight : None
});
}
}
});
}

My guess is this gets fixed in a later chapter, but it would be nice if that was mentioned here. If this wasn't intentional, I think either adding something like weapon.proc_target = Some("Target".to_string()); to rawmaster.rs or changing the line in melee_combat_system.rs to use unwrap_or_default() would fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant