Advertisement
Guest User

Randomize weapon element

a guest
Aug 12th, 2018
681
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Item.setRandomElement(self)
  2.     if self:getType():getWeaponType() == WEAPON_NONE then
  3.         return
  4.     end
  5.     local elements = {COMBAT_FIREDAMAGE, COMBAT_ICEDAMAGE, COMBAT_DROWNDAMAGE, COMBAT_EARTHDAMAGE, COMBAT_ENERGYDAMAGE, COMBAT_DEATHDAMAGE, COMBAT_HOLYDAMAGE}
  6.     self:setAbility(ITEM_ABILITY_ELEMENTTYPE, elements[math.random(#elements)])
  7.     self:setAbility(ITEM_ABILITY_ELEMENTDAMAGE, math.random(50, 250))
  8. end
  9.  
  10. local weapon = player:getSlotItem(CONST_SLOT_LEFT)
  11. weapon:setRandomElement() -- picks a random element with 50-250 damage, all attacks from then on
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement