eri000n

Untitled

May 10th, 2023
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #ifdef ENABLE_SPECIAL_SWITCHERS
  2. bool CItemAddonManager::SwitchAddonTo(LPITEM pkItem, bool bMaxAttr)
  3. {
  4. if (!pkItem)
  5. {
  6. sys_err("ITEM pointer null");
  7. return false;
  8. }
  9.  
  10. int iFKSIndex = pkItem->FindAttribute(APPLY_SKILL_DAMAGE_BONUS);
  11. int iDSSIndex = pkItem->FindAttribute(APPLY_NORMAL_HIT_DAMAGE_BONUS);
  12.  
  13. if (iFKSIndex == -1 && iDSSIndex == -1)
  14. return false;
  15.  
  16. int iFKS, iDSS = 0;
  17. //The value of "e_special_attr" adds to the value of iDSS.
  18. int iSpecialAttrEvent = quest::CQuestManager::instance().GetEventFlag("e_special_attr");
  19.  
  20. if (bMaxAttr)
  21. {
  22. iFKS = 30;
  23. iDSS = 60 + iSpecialAttrEvent;
  24. }
  25. else
  26. {
  27. iFKS = MINMAX(-30, (int)(gauss_random(0, 5) + 0.5f), 30);
  28. iDSS = 0;
  29. if (abs(iFKS) <= 20)
  30. iDSS = -2 * iFKS + abs(number(-8, 8) + number(-8, 8)) + number(1, 4);
  31. else
  32. iDSS = -2 * iFKS + number(1, 5);
  33. }
  34.  
  35. if (iFKSIndex > -1)
  36. pkItem->SetAttribute(iFKSIndex, APPLY_SKILL_DAMAGE_BONUS, (iFKS == 0 ? 1 : iFKS));
  37.  
  38. if (iDSSIndex > -1)
  39. pkItem->SetAttribute(iDSSIndex, APPLY_NORMAL_HIT_DAMAGE_BONUS, (iDSS == 0 ? 1 : iDSS));
  40.  
  41. return true;
  42. }
  43. #endif
  44.  
Advertisement
Add Comment
Please, Sign In to add comment