weapons.lua 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. -- Globally reduce all weapon damage to provide longer reaction time in PvP.
  2. -- Normal damage scaling would be 500.
  3. local SCALE = 250
  4. local KNB = 100
  5. -- Damage groups for all weapons.
  6. -- Warning: Minetest will round all values to nearest integer; DO NOT expect
  7. -- float values to work!
  8. --
  9. -- Note: knockback represents meters per second, times 100.
  10. -- For reference, the HAND does 'knockback=100'.
  11. -- Hammers do 3*KNB (300).
  12. sysdmg.damage_groups = {
  13. ["anvil:hammer"] = {cracky=6.0*SCALE, fleshy=0.2*SCALE, knockback=3*KNB},
  14. ["xdecor:hammer"] = {cracky=6.0*SCALE, fleshy=0.2*SCALE, knockback=3*KNB},
  15. ["shears:shears"] = {fleshy=2.0*SCALE},
  16. ["default:pick_wood"] = {snappy= 1.0*SCALE, fleshy=1.2*SCALE, knockback=1.1*KNB},
  17. ["default:pick_stone"] = {snappy= 1.0*SCALE, crush=0.2*SCALE, fleshy=0.2*SCALE, knockback=2.5*KNB},
  18. ["default:pick_steel"] = {snappy=8.0*SCALE, fleshy=5.2*SCALE, knockback= 2*KNB},
  19. ["default:pick_bronze"] = {snappy=8.0*SCALE, fleshy=5.2*SCALE, knockback= 2*KNB},
  20. ["default:pick_bronze2"] = {snappy=8.0*SCALE, fleshy=5.2*SCALE, knockback= 2*KNB},
  21. ["default:pick_mese"] = {crumbly=16.0*SCALE, fleshy=0.4*SCALE, knockback= 2*KNB},
  22. ["default:pick_diamond"] = {snappy=12.0*SCALE, fleshy=5.2*SCALE, knockback= 1.5*KNB},
  23. ["moreores:pick_silver"] = {snappy=12.0*SCALE, crumbly=0.2*SCALE, fleshy=0.2*SCALE, knockback= 1.5*KNB},
  24. ["moreores:pick_mithril"] = {snappy=16.0*SCALE, fleshy=5.2*SCALE, knockback= 1.5*KNB},
  25. ["titanium:pick"] = {snappy=10.0*SCALE, fleshy=5.2*SCALE, knockback= 2.5*KNB},
  26. ["gems:pick_ruby"] = {snappy=12.1*SCALE, fleshy=5.2*SCALE, knockback= 2.6*KNB},
  27. ["gems:rf_pick_ruby"] = {snappy=12.0*SCALE, fleshy=5.1*SCALE, knockback= 2.6*KNB},
  28. ["gems:pick_amethyst"] = {snappy=11.1*SCALE, fleshy=5.2*SCALE, knockback= 2.9*KNB},
  29. ["gems:rf_pick_amethyst"] = {snappy=11.0*SCALE, fleshy=5.1*SCALE, knockback= 2.7*KNB},
  30. ["gems:pick_sapphire"] = {snappy=12.1*SCALE, fleshy=5.2*SCALE, knockback= 2.8*KNB},
  31. ["gems:rf_pick_sapphire"] = {snappy=12.0*SCALE, fleshy=5.1*SCALE, knockback= 2.7*KNB},
  32. ["gems:pick_emerald"] = {snappy=11.1*SCALE, fleshy=5.2*SCALE, knockback= 2.8*KNB},
  33. ["gems:rf_pick_emerald"] = {snappy=11.0*SCALE, fleshy=5.1*SCALE, knockback= 2.7*KNB},
  34. ["default:shovel_stone"] = {cracky=1.0*SCALE, fleshy=0.1*SCALE, crush=0.4*SCALE, knockback=3.1*KNB},
  35. ["default:shovel_steel"] = {cracky=2.0*SCALE, fleshy=0.1*SCALE, crush=0.2*SCALE, knockback= 3*KNB},
  36. ["default:shovel_bronze"] = {cracky=2.0*SCALE, fleshy=0.1*SCALE, crush=0.2*SCALE, knockback= 3*KNB},
  37. ["default:shovel_bronze2"] = {cracky=2.0*SCALE, fleshy=0.1*SCALE, crush=0.2*SCALE, knockback= 3*KNB},
  38. ["default:shovel_mese"] = {cracky=2.5*SCALE, crumbly=2.5*SCALE, fleshy=0.1*SCALE, crush=0.2*SCALE, knockback= 3*KNB},
  39. ["default:shovel_diamond"] = {cracky=6.0*SCALE, fleshy=0.1*SCALE, crush=0.2*SCALE, knockback= 2.7*KNB},
  40. ["moreores:shovel_silver"] = {cracky=2.0*SCALE, crumbly=0.2*SCALE, fleshy=0.1*SCALE, crush=0.2*SCALE, knockback= 2.7*KNB},
  41. ["moreores:shovel_mithril"] = {cracky=8.0*SCALE, fleshy=0.1*SCALE, crush=0.2*SCALE, knockback= 2.7*KNB},
  42. ["titanium:shovel"] = {cracky=2.0*SCALE, fleshy=0.1*SCALE, crush=0.2*SCALE, knockback= 3.1*KNB},
  43. ["gems:shovel_ruby"] = {cracky=5.1*SCALE, fleshy=0.1*SCALE, crush=0.2*SCALE, knockback=2.5*KNB},
  44. ["gems:rf_shovel_ruby"] = {cracky=5.0*SCALE, fleshy=0.05*SCALE, crush=0.2*SCALE, knockback= 2.5*KNB},
  45. ["gems:shovel_amethyst"] = {cracky=6.1*SCALE, fleshy=0.1*SCALE, crush=0.2*SCALE, knockback=3.1*KNB},
  46. ["gems:rf_shovel_amethyst"] = {cracky=6.0*SCALE, fleshy=0.05*SCALE, crush=0.2*SCALE, knockback= 3.1*KNB},
  47. ["gems:shovel_sapphire"] = {cracky=5.1*SCALE, fleshy=0.1*SCALE, crush=0.2*SCALE, knockback=3.1*KNB},
  48. ["gems:rf_shovel_sapphire"] = {cracky=5.0*SCALE, fleshy=0.05*SCALE, crush=0.2*SCALE, knockback=2.9*KNB},
  49. ["gems:shovel_emerald"] = {cracky=6.1*SCALE, fleshy=0.1*SCALE, crush=0.2*SCALE, knockback=2.7*KNB},
  50. ["gems:rf_shovel_emerald"] = {cracky=6.0*SCALE, fleshy=0.05*SCALE, crush=0.2*SCALE, knockback=2.6*KNB},
  51. ["default:axe_stone"] = {choppy=1.0*SCALE, crush=0.2*SCALE, snappy=0.2*SCALE, knockback=3.5*KNB},
  52. ["default:axe_steel"] = {choppy=5.0*SCALE, snappy=0.2*SCALE, knockback=3*KNB},
  53. ["default:axe_bronze"] = {choppy=4.0*SCALE, snappy=0.2*SCALE, knockback=3*KNB},
  54. ["default:axe_bronze2"] = {choppy=4.0*SCALE, snappy=0.2*SCALE, knockback=3*KNB},
  55. ["default:axe_mese"] = {crumbly=6.0*SCALE, choppy=0.2*SCALE, snappy=0.2*SCALE, knockback=2.9*KNB},
  56. ["default:axe_diamond"] = {choppy=7.0*SCALE, snappy=0.2*SCALE, knockback=2.9*KNB},
  57. ["moreores:axe_silver"] = {electrocute=2.0*SCALE, choppy=0.2*SCALE, crumbly=0.2*SCALE, snappy=0.2*SCALE, knockback=2.9*KNB},
  58. ["moreores:axe_mithril"] = {choppy=9.0*SCALE, snappy=0.2*SCALE, knockback=2.9*KNB},
  59. ["titanium:axe"] = {choppy=5.0*SCALE, snappy=0.2*SCALE, knockback=3.8*KNB},
  60. ["gems:axe_ruby"] = {choppy=6.1*SCALE, snappy=0.2*SCALE, knockback=3.0*KNB},
  61. ["gems:rf_axe_ruby"] = {choppy=6.0*SCALE, snappy=0.1*SCALE, knockback=2.9*KNB},
  62. ["gems:axe_amethyst"] = {choppy=6.1*SCALE, snappy=0.2*SCALE, knockback=3.1*KNB},
  63. ["gems:rf_axe_amethyst"] = {choppy=6.0*SCALE, snappy=0.1*SCALE, knockback=2.9*KNB},
  64. ["gems:axe_sapphire"] = {choppy=7.1*SCALE, snappy=0.2*SCALE, knockback=3.0*KNB},
  65. ["gems:rf_axe_sapphire"] = {choppy=7.0*SCALE, snappy=0.1*SCALE, knockback=2.7*KNB},
  66. ["gems:axe_emerald"] = {choppy=7.1*SCALE, snappy=0.2*SCALE, knockback=3.0*KNB},
  67. ["gems:rf_axe_emerald"] = {choppy=7.0*SCALE, snappy=0.1*SCALE, knockback=2.7*KNB},
  68. ["default:sword_stone"] = {cracky= 4.0*SCALE, crush=0.2*SCALE, fleshy=0.2*SCALE, knockback=3.5*KNB},
  69. ["default:sword_steel"] = {fleshy= 6.0*SCALE, snappy=0.2*SCALE, knockback=1.5*KNB},
  70. ["default:sword_bronze"] = {fleshy=10.0*SCALE, snappy=0.2*SCALE, knockback=1.5*KNB},
  71. ["default:sword_bronze2"] = {fleshy=10.0*SCALE, snappy=0.2*SCALE, knockback=1.5*KNB},
  72. ["default:sword_mese"] = {crumbly= 8.0*SCALE, fleshy=0.2*SCALE, snappy=0.2*SCALE, knockback=1.3*KNB},
  73. ["default:sword_diamond"] = {fleshy= 8.0*SCALE, snappy=0.2*SCALE, knockback=1.3*KNB},
  74. ["moreores:sword_silver"] = {electrocute=6.0*SCALE, fleshy=0.2*SCALE, crumbly=0.2*SCALE, snappy=0.2*SCALE, knockback=1.3*KNB},
  75. ["moreores:sword_mithril"] = {fleshy=10.0*SCALE, snappy=0.2*SCALE, knockback=1.3*KNB},
  76. ["titanium:sword"] = {fleshy= 8.0*SCALE, snappy=0.2*SCALE, knockback=3.5*KNB},
  77. ["gems:sword_ruby"] = {fleshy= 8.1*SCALE, snappy=0.3*SCALE, knockback=1.7*KNB},
  78. ["gems:rf_sword_ruby"] = {fleshy= 8.0*SCALE, snappy=0.1*SCALE, knockback=1.6*KNB},
  79. ["gems:sword_amethyst"] = {fleshy= 9.1*SCALE, snappy=0.3*SCALE, knockback=3.5*KNB},
  80. ["gems:rf_sword_amethyst"] = {fleshy= 9.0*SCALE, snappy=0.1*SCALE, knockback=3.1*KNB},
  81. ["gems:sword_sapphire"] = {fleshy= 7.1*SCALE, snappy=0.3*SCALE, knockback=1.7*KNB},
  82. ["gems:rf_sword_sapphire"] = {fleshy= 7.0*SCALE, snappy=0.1*SCALE, knockback=1.6*KNB},
  83. ["gems:sword_emerald"] = {fleshy= 7.1*SCALE, snappy=0.3*SCALE, knockback=1.7*KNB},
  84. ["gems:rf_sword_emerald"] = {fleshy= 7.0*SCALE, snappy=0.1*SCALE, knockback=1.6*KNB},
  85. ["stoneworld:oerkki_scepter"] = {heat=4*SCALE, knockback=4, lava=1*SCALE, knockback=1.8*KNB},
  86. }
  87. -- Make calculating the "hard meta" rather difficult.
  88. do
  89. local pr = PcgRandom(os.time())
  90. for weapon, groups in pairs(sysdmg.damage_groups) do
  91. for damage, amount in pairs(groups) do
  92. -- Skip special types.
  93. if damage ~= "knockback" then
  94. amount = math.max(1, (amount + pr:next(-50, 50)))
  95. groups[damage] = amount
  96. end
  97. end
  98. end
  99. end
  100. -- Shall return a damage-groups table.
  101. -- To be called at load-time only; shall return nil as needed.
  102. function sysdmg.get_damage_groups_for(name2, groups)
  103. local name = name2
  104. if name:sub(1, 1) == ":" then
  105. name = name:sub(2)
  106. end
  107. --minetest.log('getting damage groups for: ' .. name)
  108. if sysdmg.damage_groups[name] then
  109. local g = table.copy(sysdmg.damage_groups[name])
  110. if groups then
  111. for k, v in pairs(groups) do
  112. g[k] = v
  113. end
  114. end
  115. return g
  116. end
  117. -- May return nil if 'groups' is nil.
  118. return groups
  119. end