Advertisement
Guest User

Untitled

a guest
May 24th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. module AresMUSH
  2. class Npc < Ohm::Model
  3. include ObjectModel
  4.  
  5. attribute :name
  6. attribute :name_upcase
  7. attribute :level
  8.  
  9. collection :damage, "AresMUSH::Damage"
  10. reference :combat, "AresMUSH::Combat"
  11.  
  12. before_save :save_upcase
  13. before_delete :clear_damage
  14.  
  15. def save_upcase
  16. self.name_upcase = self.name ? self.name.upcase : ""
  17. end
  18.  
  19. def clear_damage
  20. self.damage.each { |d| d.delete }
  21. end
  22.  
  23. def roll_ability(ability, mod = 0)
  24. rating = self.ability_rating(ability)
  25. Global.logger.info "#{self.name} rolling #{ability} skill=#{rating} mod=#{mod}"
  26. FS3Skills.one_shot_die_roll(rating + mod)
  27. end
  28.  
  29. def ability_rating(ability)
  30. stats = FS3Combat.npc_type(self.level)
  31. stats[ability] || stats["Default"]
  32. end
  33.  
  34. Global.logger.info "Heading for scale"
  35.  
  36. def scale
  37. stats = FS3Combat.npc_type(self.level)
  38. stats['Scale'] || 'M'
  39. end
  40.  
  41. def wound_modifier
  42. self.ability_rating("Wounds") || 0
  43. end
  44. end
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement