| 2541 | } |
| 2542 | |
| 2543 | void RepairItem(ItemStruct *i, int lvl) |
| 2544 | { |
| 2545 | int rep, d; |
| 2546 | |
| 2547 | if (i->_iDurability == i->_iMaxDur) { |
| 2548 | return; |
| 2549 | } |
| 2550 | |
| 2551 | if (i->_iMaxDur <= 0) { |
| 2552 | i->_itype = ITYPE_NONE; |
| 2553 | return; |
| 2554 | } |
| 2555 | |
| 2556 | rep = 0; |
| 2557 | do { |
| 2558 | rep += lvl + random_(37, lvl); |
| 2559 | d = i->_iMaxDur / (lvl + 9); |
| 2560 | if (d < 1) |
| 2561 | d = 1; |
| 2562 | i->_iMaxDur = i->_iMaxDur - d; |
| 2563 | if (!i->_iMaxDur) { |
| 2564 | i->_itype = ITYPE_NONE; |
| 2565 | return; |
| 2566 | } |
| 2567 | } while (rep + i->_iDurability < i->_iMaxDur); |
| 2568 | |
| 2569 | i->_iDurability += rep; |
| 2570 | if (i->_iDurability > i->_iMaxDur) |
| 2571 | i->_iDurability = i->_iMaxDur; |
| 2572 | } |
| 2573 | |
| 2574 | void DoRecharge(int pnum, int cii) |
| 2575 | { |