Returns an integer representing a % damage reduction
()
| 568 | |
| 569 | // Returns an integer representing a % damage reduction |
| 570 | func (c *Character) GetDefense() int { |
| 571 | |
| 572 | reduction := 0 |
| 573 | for _, slot := range AllSlots() { |
| 574 | reduction += c.Equipment.Get(slot).GetDefense() |
| 575 | } |
| 576 | |
| 577 | //reduction = int(float64(reduction) / 9) |
| 578 | |
| 579 | // If wearing an offhand item like a shield, defense gets a 50% boost |
| 580 | // Holdables are not considered "shield" type items. |
| 581 | // Anything held in the offhand that provides a damage reduction is considered a shield. |
| 582 | if c.Equipment.Offhand.ItemId != 0 && c.Equipment.Offhand.GetSpec().Type != items.Weapon && c.Equipment.Offhand.GetSpec().DamageReduction > 0 { |
| 583 | reduction = int(float64(reduction) * 1.5) |
| 584 | } |
| 585 | |
| 586 | if reduction > 100 { |
| 587 | reduction = 100 |
| 588 | } |
| 589 | |
| 590 | return reduction |
| 591 | } |
| 592 | |
| 593 | func (c *Character) GetMobName(viewingUserId int, renderFlags ...NameRenderFlag) FormattedName { |
| 594 | return c.getFormattedName(viewingUserId, `mobname`, renderFlags...) |
no test coverage detected