armor.lua 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. -- These groups get merged with the items's default groups table, so group
  2. -- names must be prefixed with "armor_".
  3. --
  4. -- Note: 'armor_heal' is actually "armor block chance" (1 .. 100). If block
  5. -- chance passes, then damage is completely blocked (becomes 0). The block
  6. -- chance is limited to a maximum of 90.
  7. --
  8. -- Note: 'armor_use' is the amount of wear added to armor whenever it gets
  9. -- damaged. Armor is destroyed once wear reaches max. Lower value is better.
  10. local BLOCK_MULT = 0.3
  11. sysdmg.default_groups = {
  12. ["shields:shield_wood"] = {armor_heal= 5*BLOCK_MULT, armor_use=2000},
  13. ["shields:shield_enhanced_wood"] = {armor_heal=10*BLOCK_MULT, armor_use=1000},
  14. ["3d_armor:helmet_wood"] = {armor_heal= 0*BLOCK_MULT, armor_use=1000},
  15. ["3d_armor:chestplate_wood"] = {armor_heal= 5*BLOCK_MULT, armor_use=1500},
  16. ["3d_armor:leggings_wood"] = {armor_heal= 0*BLOCK_MULT, armor_use=1500},
  17. ["3d_armor:boots_wood"] = {armor_heal= 0*BLOCK_MULT, armor_use=2000},
  18. ["shields:shield_steel"] = {armor_heal=10*BLOCK_MULT, armor_use=500},
  19. ["3d_armor:helmet_steel"] = {armor_heal= 0*BLOCK_MULT, armor_use=500},
  20. ["3d_armor:chestplate_steel"] = {armor_heal=10*BLOCK_MULT, armor_use=500},
  21. ["3d_armor:leggings_steel"] = {armor_heal= 0*BLOCK_MULT, armor_use=500},
  22. ["3d_armor:boots_steel"] = {armor_heal= 0*BLOCK_MULT, armor_use=500},
  23. ["shields:shield_carbon"] = {armor_heal=20*BLOCK_MULT, armor_use=200},
  24. ["3d_armor:helmet_carbon"] = {armor_heal= 0*BLOCK_MULT, armor_use=200},
  25. ["3d_armor:chestplate_carbon"] = {armor_heal=10*BLOCK_MULT, armor_use=200},
  26. ["3d_armor:leggings_carbon"] = {armor_heal= 0*BLOCK_MULT, armor_use=200},
  27. ["3d_armor:boots_carbon"] = {armor_heal= 0*BLOCK_MULT, armor_use=200},
  28. ["shields:shield_bronze"] = {armor_heal=10*BLOCK_MULT, armor_use=250},
  29. ["3d_armor:helmet_bronze"] = {armor_heal= 6*BLOCK_MULT, armor_use=250},
  30. ["3d_armor:chestplate_bronze"] = {armor_heal=15*BLOCK_MULT, armor_use=1000},
  31. ["3d_armor:leggings_bronze"] = {armor_heal= 6*BLOCK_MULT, armor_use=250},
  32. ["3d_armor:boots_bronze"] = {armor_heal= 6*BLOCK_MULT, armor_use=250},
  33. ["shields:shield_diamond"] = {armor_heal=15*BLOCK_MULT, armor_use=100},
  34. ["3d_armor:helmet_diamond"] = {armor_heal=20*BLOCK_MULT, armor_use=100},
  35. ["3d_armor:chestplate_diamond"] = {armor_heal=10*BLOCK_MULT, armor_use=100},
  36. ["3d_armor:leggings_diamond"] = {armor_heal= 0*BLOCK_MULT, armor_use=100},
  37. ["3d_armor:boots_diamond"] = {armor_heal= 0*BLOCK_MULT, armor_use=100},
  38. ["shields:shield_gold"] = {armor_heal=10*BLOCK_MULT, armor_use=250},
  39. ["3d_armor:helmet_gold"] = {armor_heal= 6*BLOCK_MULT, armor_use=250},
  40. ["3d_armor:chestplate_gold"] = {armor_heal=15*BLOCK_MULT, armor_use=1000},
  41. ["3d_armor:leggings_gold"] = {armor_heal= 6*BLOCK_MULT, armor_use=250},
  42. ["3d_armor:boots_gold"] = {armor_heal= 6*BLOCK_MULT, armor_use=250},
  43. ["shields:shield_mithril"] = {armor_heal= 8*BLOCK_MULT, armor_use=50},
  44. ["3d_armor:helmet_mithril"] = {armor_heal= 5*BLOCK_MULT, armor_use=50},
  45. ["3d_armor:chestplate_mithril"] = {armor_heal=10*BLOCK_MULT, armor_use=250},
  46. ["3d_armor:leggings_mithril"] = {armor_heal= 5*BLOCK_MULT, armor_use=50},
  47. ["3d_armor:boots_mithril"] = {armor_heal= 5*BLOCK_MULT, armor_use=50},
  48. }
  49. -- Wear multipliers for when armor gets damaged by something.
  50. sysdmg.wear_groups = {
  51. ["shields:shield_wood"] = {fall=0.5, crumbly=0.1, lava=4.0, heat=2.0, ground=0.0, boom=3.0},
  52. ["shields:shield_enhanced_wood"] = {fall=0.5, crumbly=0.1, lava=4.0, heat=2.0, ground=0.0, boom=3.0},
  53. ["3d_armor:helmet_wood"] = {fall=0.5, crumbly=0.1, lava=4.0, crush=3.0, heat=2.0, ground=0.0},
  54. ["3d_armor:chestplate_wood"] = {fall=0.5, crumbly=0.1, lava=4.0, heat=2.0, ground=0.0, boom=4.0},
  55. ["3d_armor:leggings_wood"] = {fall=1.25,crumbly=0.1, lava=4.0, heat=2.0},
  56. ["3d_armor:boots_wood"] = {fall=1.5, crumbly=0.1, lava=4.0, heat=2.0, ground=2.0},
  57. ["shields:shield_steel"] = {fall=0.5, fleshy=0.5, lava=2.0, crumbly=1.25, ground=0.0, boom=3.0},
  58. ["3d_armor:helmet_steel"] = {fall=0.5, fleshy=0.5, lava=2.0, crumbly=1.25, crush=3.0, ground=0.0},
  59. ["3d_armor:chestplate_steel"] = {fall=0.5, fleshy=0.5, lava=2.0, crumbly=1.5, ground=0.0, boom=4.0},
  60. ["3d_armor:leggings_steel"] = {fall=1.25,fleshy=0.5, lava=2.0, crumbly=1.25, },
  61. ["3d_armor:boots_steel"] = {fall=1.5, fleshy=0.5, lava=2.0, crumbly=1.25, ground=2.0},
  62. ["shields:shield_carbon"] = {fall=0.5, snappy=0.6, fleshy=0.4, lava=1.5, crumbly=1.25, ground=0.0, boom=3.0},
  63. ["3d_armor:helmet_carbon"] = {fall=0.5, snappy=0.6, fleshy=0.4, lava=1.5, crumbly=1.25, crush=3.0, ground=0.0},
  64. ["3d_armor:chestplate_carbon"] = {fall=0.5, snappy=0.6, fleshy=0.4, lava=1.5, crumbly=1.25, ground=0.0, boom=4.0},
  65. ["3d_armor:leggings_carbon"] = {fall=1.25,snappy=0.6, fleshy=0.4, lava=1.5, crumbly=1.25, },
  66. ["3d_armor:boots_carbon"] = {fall=1.5, snappy=0.6, fleshy=0.4, lava=1.5, crumbly=1.25, ground=2.0},
  67. ["shields:shield_bronze"] = {fall=0.5, crush=1.25, ground=0.0, boom=0.5},
  68. ["3d_armor:helmet_bronze"] = {fall=0.5, crush=3.0, ground=0.0, boom=0.5},
  69. ["3d_armor:chestplate_bronze"] = {fall=0.5, crush=1.5, ground=0.0, boom=0.5},
  70. ["3d_armor:leggings_bronze"] = {fall=1.25, crush=1.25, boom=0.5},
  71. ["3d_armor:boots_bronze"] = {fall=1.5, ground=2.0, crush=1.25, boom=0.5},
  72. ["shields:shield_diamond"] = {fall=0.5, cracky=2.0, ground=0.0, boom=3.0},
  73. ["3d_armor:helmet_diamond"] = {fall=0.5, cracky=2.0, crush=3.0, ground=0.0},
  74. ["3d_armor:chestplate_diamond"] = {fall=0.5, cracky=2.0, ground=0.0, boom=4.0},
  75. ["3d_armor:leggings_diamond"] = {fall=1.25,cracky=2.0, },
  76. ["3d_armor:boots_diamond"] = {fall=1.5, cracky=2.0, ground=2.0},
  77. ["shields:shield_gold"] = {fall=0.5, lava=0.3, heat=0.1, ground=0.0, boom=3.0},
  78. ["3d_armor:helmet_gold"] = {fall=0.5, lava=0.3, heat=0.1, crush=3.0, ground=0.0},
  79. ["3d_armor:chestplate_gold"] = {fall=0.5, lava=0.3, heat=0.1, ground=0.0, boom=4.0},
  80. ["3d_armor:leggings_gold"] = {fall=1.25,lava=0.3, heat=0.1, },
  81. ["3d_armor:boots_gold"] = {fall=1.5, lava=0.3, heat=0.1, ground=2.0},
  82. ["shields:shield_mithril"] = {fall=0.5, fleshy=0.5, snappy=0.1, ground=0.0, boom=3.0},
  83. ["3d_armor:helmet_mithril"] = {fall=0.5, fleshy=0.5, snappy=0.1, crush=3.0, ground=0.0},
  84. ["3d_armor:chestplate_mithril"] = {fall=0.5, fleshy=0.5, snappy=0.1, ground=0.0, boom=4.0},
  85. ["3d_armor:leggings_mithril"] = {fall=0.8, fleshy=0.5, snappy=0.1, },
  86. ["3d_armor:boots_mithril"] = {fall=0.9, fleshy=0.5, snappy=0.1, ground=2.0},
  87. }
  88. -- Resitance group values range from 0 .. 100.
  89. -- Higher values give more resistance.
  90. -- Note that the total resistance for a particular group cannot exceed 90.
  91. sysdmg.resist_groups = {
  92. ["shields:shield_wood"] = {fleshy=5, crumbly=10, },
  93. ["shields:shield_enhanced_wood"] = {fleshy=8, crumbly=20, },
  94. ["3d_armor:helmet_wood"] = {fleshy=5, crumbly=15, },
  95. ["3d_armor:chestplate_wood"] = {fleshy=10, crumbly=25, },
  96. ["3d_armor:leggings_wood"] = {fleshy=5, crumbly=10, },
  97. ["3d_armor:boots_wood"] = {fleshy=5, crumbly=15, },
  98. ["shields:shield_steel"] = {fleshy=10, cracky=15, snappy=10, crumbly=5},
  99. ["3d_armor:helmet_steel"] = {fleshy=10, cracky=15, snappy=10, crumbly=5},
  100. ["3d_armor:chestplate_steel"] = {fleshy=15, cracky=10, snappy=15, crumbly=5},
  101. ["3d_armor:leggings_steel"] = {fleshy=15, cracky=10, snappy=15, crumbly=5},
  102. ["3d_armor:boots_steel"] = {fleshy=10, cracky=10, snappy=10, crumbly=5},
  103. ["shields:shield_carbon"] = {fleshy=12, cracky=20, snappy=10, arrow=18},
  104. ["3d_armor:helmet_carbon"] = {fleshy=12, cracky=10, snappy=15, arrow=15},
  105. ["3d_armor:chestplate_carbon"] = {fleshy=17, cracky=20, fireball=20, snappy=15, arrow=20},
  106. ["3d_armor:leggings_carbon"] = {fleshy=17, cracky=10, snappy=15, arrow=15},
  107. ["3d_armor:boots_carbon"] = {fleshy=12, cracky=10, snappy=10, arrow=12},
  108. ["shields:shield_bronze"] = {fleshy=10, fireball=50, boom=20, heat=6},
  109. ["3d_armor:helmet_bronze"] = {fleshy=10, crumbly=12, boom=12, heat=6},
  110. ["3d_armor:chestplate_bronze"] = {fleshy=15, crumbly=20, boom=20, heat=16},
  111. ["3d_armor:leggings_bronze"] = {fleshy=15, crumbly=12, boom=10, heat=6},
  112. ["3d_armor:boots_bronze"] = {fleshy=10, crumbly=8, boom=10, heat=6},
  113. ["shields:shield_diamond"] = {fleshy=15, choppy=20, crush=15, arrow=15},
  114. ["3d_armor:helmet_diamond"] = {fleshy=15, choppy=10, crush=20, arrow=20},
  115. ["3d_armor:chestplate_diamond"] = {fleshy=20, choppy=15, crush=20, arrow=20},
  116. ["3d_armor:leggings_diamond"] = {fleshy=20, choppy=10, crush=15, arrow=6},
  117. ["3d_armor:boots_diamond"] = {fleshy=15, choppy=10, crush=15, arrow=6},
  118. ["shields:shield_gold"] = {fleshy=10, heat=8, lava=5},
  119. ["3d_armor:helmet_gold"] = {fleshy=10, heat=8, lava=10},
  120. ["3d_armor:chestplate_gold"] = {fleshy=15, heat=8, lava=15},
  121. ["3d_armor:leggings_gold"] = {fleshy=15, heat=8, lava=15},
  122. ["3d_armor:boots_gold"] = {fleshy=10, heat=8, lava=20},
  123. ["shields:shield_mithril"] = {boom=10, cracky=15, fleshy=15, fireball=50},
  124. ["3d_armor:helmet_mithril"] = {boom=5, cracky=8, fleshy=20, arrow=60},
  125. ["3d_armor:chestplate_mithril"] = {boom=10, cracky=15, fleshy=25, fireball=25},
  126. ["3d_armor:leggings_mithril"] = {boom=5, cracky=8, fleshy=25},
  127. ["3d_armor:boots_mithril"] = {boom=5, cracky=8, fleshy=20},
  128. }
  129. -- Make calculating the "hard meta" rather difficult.
  130. do
  131. local pr = PcgRandom(os.time())
  132. for armor, groups in pairs(sysdmg.resist_groups) do
  133. for damage, amount in pairs(groups) do
  134. amount = math.max(1, (amount + pr:next(-1, 1)))
  135. groups[damage] = amount
  136. end
  137. end
  138. end
  139. -- Shall return an armor resist-groups table.
  140. -- To be called at load-time only; shall NOT return nil.
  141. function sysdmg.get_armor_resist_for(name2)
  142. local name = name2
  143. if name:sub(1, 1) == ":" then
  144. name = name:sub(2)
  145. end
  146. if sysdmg.resist_groups[name] then
  147. return table.copy(sysdmg.resist_groups[name])
  148. end
  149. return {}
  150. end
  151. -- Shall return an armor wear-groups table.
  152. -- To be called at load-time only; shall NOT return nil.
  153. function sysdmg.get_armor_wear_for(name2)
  154. local name = name2
  155. if name:sub(1, 1) == ":" then
  156. name = name:sub(2)
  157. end
  158. if sysdmg.wear_groups[name] then
  159. return table.copy(sysdmg.wear_groups[name])
  160. end
  161. return {}
  162. end
  163. -- Shall return armor's default groups table.
  164. -- To be called at load-time only; shall NOT return nil.
  165. function sysdmg.get_armor_groups_for(name2, groups)
  166. local name = name2
  167. if name:sub(1, 1) == ":" then
  168. name = name:sub(2)
  169. end
  170. if sysdmg.default_groups[name] then
  171. local g = table.copy(sysdmg.default_groups[name])
  172. if groups then
  173. for k, v in pairs(groups) do
  174. g[k] = v
  175. end
  176. end
  177. return g
  178. end
  179. return groups or {}
  180. end