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
magical_attributes poison damage #12
Comments
I now analyzed the problem and the explanation at https://user.xmission.com/~trevin/DiabloIIv1.09_Magic_Properties.shtml seems to be pretty accurate on how poison damage has to be calculated. At least my tests with 8 different value/second combinations have been successful. Right now the transformation is done in _enhanceAttributeDescription which is problematic because
My proposal would be to treat those transformations as other transformations of values in the respective export function _readMagicProperties(reader: BinaryReader, start: number, offset: number, constants: types.IConstantData) {
...
//Transform poison damage values
if (id === 57) { //poisonmindam
let min = Math.floor((values[0] * values[2]) / 256);
let max = Math.floor((values[1] * values[2]) / 256);
let seconds = Math.floor(values[2] / 25);
values = [min, max, seconds];
}
magic_attributes.push({
id: id,
values: values,
name: constants.magical_properties[id].s
} as types.IMagicProperty)
... export function _writeMagicProperties(writer: BinaryWriter, properties: types.IMagicProperty[], start: number, offset: number, constants: types.IConstantData): number {
....
let num_of_properties = constants.magical_properties[property!.id].np || 1;
//Transform poison damage values
if (property.id === 57) { //poisonmindam
let seconds = Math.ceil(property.values[2] * 25);
let min = Math.ceil((property.values[0] / seconds) * 256);
let max = Math.ceil((property.values[1] / seconds) * 256);
property.values = [min, max, seconds];
}
... Pull request will be ready soon, please let me know your thoughts. thanks |
@dschu012 I would like to start the discussion here to talk about #17. Especially what you have said about the background of the current implementation and that it is implemented to be compatible with https://github.com/nokka/d2s. If I understand correctly your main goal is to keep it in a way that it can read json data produced by nokka's implementation and generate d2s files from that. It also seems that nokka's implementation does no transformation on the values at all, although I have not verified that. What I am trying to do is to make sure that when a .d2s file from the game is read and then the resulting json is written back to a .d2s file it should basically produce the same result because that would mean that the library is consistent in itself and I see a lot of potential to have such an api as this would allow lots of interesting use cases with the upcoming d2r release. Also this process of reading / writing should be repeatable (so the json should not be "destroyed" / "altered" in the progress). I think this would be important to use this library for other use cases. I see the following things to discuss here:
Open to discuss those things in more detail, as I really would like to contribute to that project and I'm glad that you already accepted some of my proposals. |
It's been awhile since I've actually touch most of this code a lot but I 100% agree w/ you on "reading / writing should be repeatable (so the json should not be "destroyed" / "altered" in the progress)". 1-2. I think the main reason I wrote the attribute_enhancer was to basically do these transformations to stats that nokkas library didn't do to put the stats in a more presentable format for consuming by some UI. Without the attribute_enhancer the library is compatible with nokkas json format. So, I feel like transformation for the psn dmg stat could happen in attribute_enhancer and just be stored on another field in
Feel free to make these changes, or suggest other alternatives. I'd like to myself but probably won't have time to spend on this library for a bit. |
add 1-2 thank you for the explanation, I will take a look into this as soon as I have more time and submit my proposal. I have created the issues #20 and #21 to keep track of the two issues which are not directly related to the poison damage thing. |
I also found another thing in this regard: attributeEnhancer sorts the magical properties which might result in a different output when the json gets written to a d2s file I can think of the following possible ways to solve this:
The reason why I'm really forcing this consistency between reading and writing is that this opens up a very easy way to create test cases which basically read an original game file (*.d2s, *.d2i, *.sss) convert it to json, convert it back to a game file and then the result can be compared with the original file. If this is guaranteed to work then this library can safely be used for all kind of purposes and it would also be very easy to have very extensive unit tests. I'm currently investigating some more differences but I think poison damage and attribute sorting are the two biggest things left so far. Curious to hear your thoughts on that 😇 |
Both 1 and 3 sound like good solutions to me. So whatever route you wanna take on this sounds good. |
Option 3 is implemented with #31 |
Hi,
wanted to start the discussion on how to fix the following in
attribute_enhancer.ts
During my usage of this api I discovered that poison damage is incorrect and that reading and writing i.e charms with poison damage results in 0 poison damage.
I have not yet took a deep dive into the problem, but I thought I'd raise it here to start the discussion.
The text was updated successfully, but these errors were encountered: