Skip to content

Commit

Permalink
hotfix weapon levels and ps file read
Browse files Browse the repository at this point in the history
  • Loading branch information
clayamore committed Mar 25, 2024
1 parent 922f83d commit 6604d45
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 12 deletions.
16 changes: 9 additions & 7 deletions src/save/common/user_data_10.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ pub struct ProfileSummaryEquipmentGaitem {
impl Read for ProfileSummaryEquipmentGaitem {
fn read(br: &mut BinaryReader) -> Result<Self, io::Error> {
let mut equipment = ProfileSummaryEquipmentGaitem::default();

equipment.unk = br.read_u32()?;
equipment.unk1 = br.read_u32()?;

Expand Down Expand Up @@ -91,7 +90,6 @@ impl Read for ProfileSummaryEquipmentGaitem {
equipment._0x4_2 = br.read_u32()?;
for i in 0..4 { equipment.talismans[i] = br.read_u32()?; }
equipment._0x4_3 = br.read_u32()?;

Ok(equipment)
}
}
Expand Down Expand Up @@ -135,16 +133,17 @@ impl Write for ProfileSummaryEquipmentGaitem {
pub struct ProfileSummaryEquipmentItem {
pub left_hand_armaments: [u32; 3],
pub right_hand_armaments: [u32; 3],
_0x4: u32,
pub arrows: [u32; 2],
pub bolts: [u32; 2],
pub _0x4: u32,
_0x8: u64,
pub head: u32,
pub chest: u32,
pub arms: u32,
pub legs: u32,
pub _0x4_2: u32,
_0x4_2: u32,
pub talismans: [u32; 4],
pub _0x4_3: [u32; 6]
_0x4_3: [u32; 6]
}
impl Read for ProfileSummaryEquipmentItem {
fn read(br: &mut BinaryReader) -> Result<Self, io::Error> {
Expand All @@ -156,16 +155,18 @@ impl Read for ProfileSummaryEquipmentItem {
equipment.right_hand_armaments[1] = br.read_u32()?;
equipment.left_hand_armaments[2] = br.read_u32()?;
equipment.right_hand_armaments[2] = br.read_u32()?;
equipment._0x4 = br.read_u32()?;
equipment.arrows[0] = br.read_u32()?;
equipment.bolts[0] = br.read_u32()?;
equipment.arrows[1] = br.read_u32()?;
equipment.bolts[1] = br.read_u32()?;
equipment._0x4 = br.read_u32()?;
equipment._0x8 = br.read_u64()?;
equipment.head = br.read_u32()?;
equipment.chest = br.read_u32()?;
equipment.arms = br.read_u32()?;
equipment.legs = br.read_u32()?;
equipment._0x4_2 = br.read_u32()?;

for i in 0..4 { equipment.talismans[i] = br.read_u32()?; }
for i in 0..6 { equipment._0x4_3[i] = br.read_u32()?; }

Expand All @@ -182,11 +183,12 @@ impl Write for ProfileSummaryEquipmentItem {
bytes.extend(self.right_hand_armaments[1].to_le_bytes());
bytes.extend(self.left_hand_armaments[2].to_le_bytes());
bytes.extend(self.right_hand_armaments[2].to_le_bytes());
bytes.extend(self._0x4.to_le_bytes());
bytes.extend(self.arrows[0].to_le_bytes());
bytes.extend(self.bolts[0].to_le_bytes());
bytes.extend(self.arrows[1].to_le_bytes());
bytes.extend(self.bolts[1].to_le_bytes());
bytes.extend(self._0x4.to_le_bytes());
bytes.extend(self._0x8.to_le_bytes());
bytes.extend(self.head.to_le_bytes());
bytes.extend(self.chest.to_le_bytes());
bytes.extend(self.arms.to_le_bytes());
Expand Down
8 changes: 7 additions & 1 deletion src/ui/inventory/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,13 @@ fn single_item_customization(ui: &mut Ui, inventory_vm: &mut InventoryViewModel,
});
}
else {
let max_upgrade = if item.data.reinforceTypeId != 0 && item.data.reinforceTypeId % 2200 == 0 {10} else {25};
let max_upgrade = if item.data.reinforceTypeId != 0 &&(
item.data.reinforceTypeId % 2200 == 0 ||
item.data.reinforceTypeId % 2400 == 0 ||
item.data.reinforceTypeId % 3200 == 0 ||
item.data.reinforceTypeId % 3300 == 0 ||
item.data.reinforceTypeId % 8300 == 0 ||
item.data.reinforceTypeId % 8500 == 0) {10} else {25};
let field = egui::DragValue::new(regulation_vm.selected_item.upgrade.as_mut().unwrap())
.clamp_range(0..=max_upgrade)
.custom_formatter(|n, _| {
Expand Down
2 changes: 1 addition & 1 deletion src/util/regulation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, io::Error, path::PathBuf, str::FromStr, sync::{Mutex, RwLock}};
use std::{collections::HashMap, io::Error, str::FromStr, sync::{Mutex, RwLock}};

use aes::cipher::{block_padding::NoPadding, BlockDecryptMut, KeyIvInit};
use binary_reader::{BinaryReader, Endian};
Expand Down
8 changes: 7 additions & 1 deletion src/vm/inventory/add_bulk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ impl InventoryViewModel {
}
else {None};

let is_somber = weapon_param.data.reinforceTypeId != 0 && weapon_param.data.reinforceTypeId % 2200 == 0;
let is_somber = weapon_param.data.reinforceTypeId != 0 && (
weapon_param.data.reinforceTypeId % 2200 == 0 ||
weapon_param.data.reinforceTypeId % 2400 == 0 ||
weapon_param.data.reinforceTypeId % 3200 == 0 ||
weapon_param.data.reinforceTypeId % 3300 == 0 ||
weapon_param.data.reinforceTypeId % 8300 == 0 ||
weapon_param.data.reinforceTypeId % 8500 == 0);
let upgrade_level = if !is_projectile {
if is_somber {
Some(((self.bulk_items_weapon_level as f32 + 0.5)/2.5) as i16)
Expand Down
18 changes: 16 additions & 2 deletions src/vm/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,14 @@ pub mod vm {
match held_weapon_res {
Some(weapon_param) => {
// Check if weapon is somber
let is_somber = weapon_param.data.reinforceTypeId != 0 && weapon_param.data.reinforceTypeId % 2200 == 0;
let is_somber = weapon_param.data.reinforceTypeId != 0 && (
weapon_param.data.reinforceTypeId % 2200 == 0 ||
weapon_param.data.reinforceTypeId % 2400 == 0 ||
weapon_param.data.reinforceTypeId % 3200 == 0 ||
weapon_param.data.reinforceTypeId % 3300 == 0 ||
weapon_param.data.reinforceTypeId % 8300 == 0 ||
weapon_param.data.reinforceTypeId % 8500 == 0
);

// Extract weapon level based on wether weapon is somber or not
let weapon_level = if is_somber{
Expand All @@ -209,7 +216,14 @@ pub mod vm {
match storage_weapon_res {
Some(weapon_param) => {
// Check if weapon is somber
let is_somber = weapon_param.data.reinforceTypeId != 0 && weapon_param.data.reinforceTypeId % 2200 == 0;
let is_somber = weapon_param.data.reinforceTypeId != 0 && (
weapon_param.data.reinforceTypeId % 2200 == 0 ||
weapon_param.data.reinforceTypeId % 2400 == 0 ||
weapon_param.data.reinforceTypeId % 3200 == 0 ||
weapon_param.data.reinforceTypeId % 3300 == 0 ||
weapon_param.data.reinforceTypeId % 8300 == 0 ||
weapon_param.data.reinforceTypeId % 8500 == 0
);

// Extract weapon level based on wether weapon is somber or not
let weapon_level = if is_somber{
Expand Down

0 comments on commit 6604d45

Please sign in to comment.