Shahin 226 Posted November 6, 2020 Author Share Posted November 6, 2020 (edited) 51 minutes ago, Ikarus_ said: I've updated the code at the first message about void CPythonPlayer::__UpdateBattleStatus() copy it again from there and let me know. I think i ve solved both the problem you reported It is working PERFECT!! Also: The rounding bug was not a bug anymore after your serverside&clientside source fix. Thank you very very much ! One last question: I see i'm getting the server side value +.5 why is that? Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Shahin 226 Posted November 6, 2020 Author Share Posted November 6, 2020 (edited) One last question: I see i'm getting the server side value +.5 why is that? Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Developer Ikarus_ 2449 Posted November 6, 2020 Developer Share Posted November 6, 2020 (edited) On 11/2/2020 at 12:54 AM, Ikarus_ said: double AttBonusMax = static_cast<double>(pkItemAbsorbed->alValues[4] + pkItemAbsorbed->alValues[5]); AttBonusMax *= acceItem->GetSocket(ACCE_ABSORPTION_SOCKET); AttBonusMax /= 100; AttBonusMax += 0.5; double AttBonusMin = static_cast<double>(pkItemAbsorbed->alValues[3] + pkItemAbsorbed->alValues[5]); AttBonusMin *= acceItem->GetSocket(ACCE_ABSORPTION_SOCKET); AttBonusMin /= 100; AttBonusMin += 0.5; check how it is calculated and you will know why. I ve just used the identical formula on c++ (serverside and clientside) and in python so all values now should be aligned. Edited November 6, 2020 by Ikarus_ 1 My youtube channel on which you can see my works here Link to comment Share on other sites More sharing options...
Shahin 226 Posted November 6, 2020 Author Share Posted November 6, 2020 (edited) 5 hours ago, Ikarus_ said: check how it is calculated and you will know why. I ve just used the identical formula on c++ (serverside and clientside) and in python so all values now should be aligned. I have tried with different sashes as values, also i have tried with the attBonusMin and Max -= 0.5; Look: the values before the -.5 should be: 20 and 27 45.03 and 52.63 ^ this are The normal, calculated without round With normal round it should be : 20 and 27 & 45 and 53 In Client side the round calculations are working good as i see on the sashes, but the server side are not.. There is no round in server side.. [EDIT] Also the char_skill part is not rounded. Can you please help me with a formula to round them? Thank you Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Developer Ikarus_ 2449 Posted November 6, 2020 Developer Share Posted November 6, 2020 (edited) In my code i ve used the identical formula client-side and server-side, so the result values are equal. Also in python the formula is identical, so why are u trying to change the formula? 16 hours ago, Shahin said: With normal round it should be : 20 and 27 & 45 and 53 Also you can't define what is a 'normal round' and what isn't. for example a number like 15.5 can be consider in many cases as 15 and in other cases as 16. Doesn't exists a standard to apply in this case, that's why we have to add a + 0.5 every where, in order to round always to the upper integer number, both python and c++. without the +0.5 we may find different values on python rouding and on c++ rounding. Edited November 6, 2020 by Ikarus_ 1 My youtube channel on which you can see my works here Link to comment Share on other sites More sharing options...
Shahin 226 Posted November 6, 2020 Author Share Posted November 6, 2020 (edited) 7 minutes ago, Ikarus_ said: In my code i ve used the identical formula client-side and server-side, so the result values are equal. Also in python the formula is identical, so why are u trying to change the formula? Also you can't define what is a 'normal round' and what isn't. for example a number like 15.5 can be consider in many cases as 15 and in other cases as 16. Doesn't exists a standard to apply in this case, that's why we have to add a + 0.5 every where, in order to round always to the upper integer number, both python and c++. without the +0.5 we may find different values on python rouding and on c++ rounding. Ok, i understand that, but my squestion was: Why the serverside values are not rounded at all? Can you please check? I asked this because python was good, but c++ was normal float value all of that calculation and just added + 0.5 or -0.5 at the end. No rounding after getting the final value. Before telling you about the calculation, i was doing a 20% sash with Battle sword +0 which meant 100 min att, 140 max att. In the calculation, it should be an integer at the end. The values should be 20% of 100 = 20 min attack; 20% of 140 = 28 max attack; The server side is showing me: In which i mentioned not getting rounded at all. Excuse me if i'm being insistent on this, but i am afraid of getting problems with giving damage at the end, not having a normal integer. As you may remember, the client side in syserr was showing integer values (rounded), when we tested todebug. Also: Thank you for your effort and implications Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Developer Ikarus_ 2449 Posted November 6, 2020 Developer Share Posted November 6, 2020 (edited) double AttBonusMin = static_cast<double>(pkItemAbsorbed->alValues[3] + pkItemAbsorbed->alValues[5]); AttBonusMin *= acceItem->GetSocket(ACCE_ABSORPTION_SOCKET); AttBonusMin /= 100; AttBonusMin += 0.5; //todebug if(ch->IsPhase(PHASE_GAME)) ch->ChatPacket(CHAT_TYPE_INFO, "Going to add to your attack : min(%0.2f) max(%0.2f) ", AttBonusMin, AttBonusMax); *pdamMax += static_cast<int>(AttBonusMax); *pdamMin += static_cast<int>(AttBonusMin); They are just rounded to integer (throught static_cast<int>) after the chat packet, that's why you are getting them as float in your chat. but the way you may add more chat packets in this function to check step by step how it is calculating the values Edited November 6, 2020 by Ikarus_ 3 My youtube channel on which you can see my works here Link to comment Share on other sites More sharing options...
Shahin 226 Posted November 6, 2020 Author Share Posted November 6, 2020 (edited) 18 hours ago, Shahin said: One last question: I see i'm getting the server side value +.5 why is that? I understand now, thank you for the explanation, and also for the Implication. I couldn't do it without you Hope you have a nice evening. Kind regards, Shahin Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Xaleas 1 Posted November 12, 2020 Share Posted November 12, 2020 (edited) I inserted everything like in your updated post and the calculation is way too high, realy strange. battle.cpp: Spoiler #ifdef __SASH_SYSTEM__ //replace it with your define for sash static void ApplySashAttackValue(LPITEM pkItem, int* pdamMin, int* pdamMax) { LPCHARACTER ch = pkItem ? pkItem->GetOwner() : NULL; if (!ch) return; LPITEM sashItem = ch->GetWear(WEAR_COSTUME_SASH); if (!sashItem) return; TItemTable* pkItemAbsorbed = ITEM_MANAGER::instance().GetTable(sashItem->GetSocket(SASH_ABSORBED_SOCKET)); if (!pkItemAbsorbed) return; if (pkItemAbsorbed->bType != ITEM_WEAPON) return; double AttBonusMax = static_cast<double>(pkItemAbsorbed->alValues[4] + pkItemAbsorbed->alValues[5]); AttBonusMax *= sashItem->GetSocket(SASH_ABSORBED_SOCKET); AttBonusMax /= 100; AttBonusMax += 0.5; double AttBonusMin = static_cast<double>(pkItemAbsorbed->alValues[3] + pkItemAbsorbed->alValues[5]); AttBonusMin *= sashItem->GetSocket(SASH_ABSORBED_SOCKET); AttBonusMin /= 100; AttBonusMin += 0.5; //todebug if(ch->GetDesc()->IsPhase(PHASE_GAME)) ch->ChatPacket(CHAT_TYPE_INFO, "Going to add to your attack : min(%0.2f) max(%0.2f) ", AttBonusMin, AttBonusMax); *pdamMax += static_cast<int>(AttBonusMax); *pdamMin += static_cast<int>(AttBonusMin); } #endif void Item_GetDamage(LPITEM pkItem, int* pdamMin, int* pdamMax) { *pdamMin = 0; *pdamMax = 1; if (!pkItem) return; switch (pkItem->GetType()) { case ITEM_ROD: case ITEM_PICK: return; } if (pkItem->GetType() != ITEM_WEAPON) sys_err("Item_GetDamage - !ITEM_WEAPON vnum=%d, type=%d", pkItem->GetOriginalVnum(), pkItem->GetType()); *pdamMin = pkItem->GetValue(3); *pdamMax = pkItem->GetValue(4); #ifdef __SASH_SYSTEM__ //replace it with your define for sash ApplySashAttackValue(pkItem, pdamMin, pdamMax); #endif } Output from __UpdateBattleStatus(): 1112 09:50:16783 :: Going to add to your points : wep(min 92.000000 max 104.000000) mag(min 100.250000 max115.750000) 1112 09:53:16584 :: Going to add to your points : wep(min 92.000000 max 104.000000) mag(min 100.250000 max115.750000) Old calculation from item.cpp: Spoiler else if (pkItemAbsorbed->bType == ITEM_WEAPON) { long lAttGrade = pkItemAbsorbed->alValues[4] + long(pkItemAbsorbed->alValues[5] * 2); if (pkItemAbsorbed->alValues[3] > pkItemAbsorbed->alValues[4]) lAttGrade = pkItemAbsorbed->alValues[3] + long(pkItemAbsorbed->alValues[5] * 2); double dValue = lAttGrade * GetSocket(SASH_ABSORPTION_SOCKET); dValue = (double)dValue / 100; dValue = (double)dValue + .5; lAttGrade = (long) dValue; if (((pkItemAbsorbed->alValues[3] > 0) && (lAttGrade < 1)) || ((pkItemAbsorbed->alValues[4] > 0) && (lAttGrade < 1))) lAttGrade += 1; else if ((pkItemAbsorbed->alValues[3] > 0) || (pkItemAbsorbed->alValues[4] > 0)) lAttGrade += 1; m_pOwner->ApplyPoint(APPLY_ATT_GRADE_BONUS, bAdd ? lAttGrade : -lAttGrade); long lAttMagicGrade = pkItemAbsorbed->alValues[2] + long(pkItemAbsorbed->alValues[5] * 2); if (pkItemAbsorbed->alValues[1] > pkItemAbsorbed->alValues[2]) lAttMagicGrade = pkItemAbsorbed->alValues[1] + long(pkItemAbsorbed->alValues[5] * 2); dValue = lAttMagicGrade * GetSocket(SASH_ABSORPTION_SOCKET); dValue = (double)dValue / 100; dValue = (double)dValue + .5; lAttMagicGrade = (long) dValue; if (((pkItemAbsorbed->alValues[1] > 0) && (lAttMagicGrade < 1)) || ((pkItemAbsorbed->alValues[2] > 0) && (lAttMagicGrade < 1))) lAttMagicGrade += 1; else if ((pkItemAbsorbed->alValues[1] > 0) || (pkItemAbsorbed->alValues[2] > 0)) lAttMagicGrade += 1; m_pOwner->ApplyPoint(APPLY_MAGIC_ATT_GRADE, bAdd ? lAttMagicGrade : -lAttMagicGrade); } Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Premium WeedHex 636 Posted November 12, 2020 Premium Share Posted November 12, 2020 //Basic attack value from weapon if (pkItemAbsorbed->alValues[3] + pkItemAbsorbed->alValues[4] > 0) //Basic magic attack value from weapon if (pkItemAbsorbed->alValues[1] + pkItemAbsorbed->alValues[2] > 0) Item_proto weapons: VALUE0 = empty VALUE1 = MIN MAGIC ATTACK VALUE2 =MAX MAGIC ATTACK VALUE3 = MIN ATTACK VALUE VALUE4 = MAX ATTACK VALUE VALUE5 = ADDEND TO INCREASE VALUE Use brain that god gave you, thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now