SHARE
TWEET

Untitled

a guest May 23rd, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local CloverFunctions = {
  2.     --{item, value to set on damager, value to check on parent, chance (0 to 1), bonus proc chance per stack (0 to 1)}
  3.     missile1 = {item = Item.find("AtG Missile Mk. 1", "vanilla"), damagerVar = "missile", parentVar = "missile", chance = 0.1, chanceBonus = 0.1},
  4.     missile2 = {item = Item.find("AtG Missile Mk. 2", "vanilla"), damagerVar = "missile_tri", parentVar = "missile_tri", chance = 0.07, chanceBonus = 0.07},
  5.     gloves = {item = Item.find("Boxing Gloves", "vanilla"), damagerVar = "knockback_glove", parentVar = "knockback", chance = 0.06, chanceBonus = 0.05},
  6.     ifrit = {item = Item.find("Ifrit's Horn", "vanilla"), damagerVar = "horn", parentVar = "horn", chance = 0.08, chanceBonus = 0},
  7.     --spark = {item = Item.find("Legendary Spark", "vanilla"), damagerVar = "spark", parentVar = "spark", chance = 0.08, chanceBonus = 0},
  8.     mortar = {item = Item.find("Mortar Tube", "vanilla"), damagerVar = "mortar", parentVar = "mortar", chance = 0.09, chanceBonus = 0},
  9.     plasma = {item = Item.find("Plasma Chain", "vanilla"), damagerVar = "plasma", parentVar = "plasma", chance = 0.05, chanceBonus = 0},
  10.     knife = {item = Item.find("Rusty Knife", "vanilla"), damagerVar = "bleed", parentVar = "bleed", chance = 0.15, chanceBonus = 0.15},
  11.     sticky = {item = Item.find("Sticky Bomb", "vanilla"), damagerVar = "sticky", parentVar = "sticky", chance = 0.08, chanceBonus = 0},
  12.     instakill = {item = Item.find("Telescopic Sight", "vanilla"), damagerVar = "scope", parentVar = "scope", chance = 0.01, chanceBonus = 0.005},
  13.     thallium = {item = Item.find("Thallium", "vanilla"), damagerVar = "thallium", parentVar = "thallium", chance = 0.1, chanceBonus = 0},
  14.     ukulele = {item = Item.find("Ukulele", "vanilla"), damagerVar = "lightning", parentVar = "lightning", chance = 0.2, chanceBonus = 0},
  15.     willOWisp = {item = Item.find("Will-o'-the-wisp", "vanilla"), damagerVar = "missile", parentVar = "", chance = 0, chanceBonus = 0},
  16.     nug = {item = Item.find("Meat Nugget", "vanilla"), damagerVar = "missile", parentVar = "", chance = 0, chanceBonus = 0},
  17.     otherClover = {item = Item.find("56 Leaf Clover", "vanilla"), damagerVar = "missile", parentVar = "", chance = 0, chanceBonus = 0},
  18.     armsRace = {item = Item.find("Arms Race", "vanilla"), damagerVar = "missile", parentVar = "", chance = 0, chanceBonus = 0},
  19.     embryo = {item = Item.find("Beating Embryo", "vanilla"), damagerVar = "missile", parentVar = "", chance = 0, chanceBonus = 0},
  20.     grenade = {item = Item.find("Concussion Grenade", "vanilla"), damagerVar = "missile", parentVar = "", chance = 0, chanceBonus = 0},
  21.     scarf = {item = Item.find("Hermit's Scarf", "vanilla"), damagerVar = "missile", parentVar = "", chance = 0, chanceBonus = 0},
  22.     icecube = {item = Item.find("Permafrost", "vanilla"), damagerVar = "missile", parentVar = "", chance = 0, chanceBonus = 0},
  23.     taser = {item = Item.find("Taser", "vanilla"), damagerVar = "missile", parentVar = "", chance = 0, chanceBonus = 0}
  24. }
  25.  
  26. local clover = Item("57 Leaf Clover")
  27. clover.pickupText = "Luck is on your side."
  28.  
  29. clover.sprite = Sprite.load("Items/clover.png", 1, 16, 16)
  30.  
  31. local cloverSound = Sound.find("Use", "vanilla")
  32.  
  33. clover:setTier("rare")
  34. clover:setLog{
  35.     group = "rare",
  36.     description = "All random effects are rolled +1 time(s) for a better outcome.",
  37.     story = "DUDE. HOLY ****",
  38.     destination = "777,\nLucky Drop,\nEarth",
  39.     date = "--/--/2056"
  40. }
  41.  
  42. registercallback("onActorInit", function(actor)
  43.     actor:set("luck", 0)
  44. end)
  45.  
  46. clover:addCallback("pickup", function(player)
  47.     player:set("luck", player:get("luck") + 1)
  48. end)
  49.  
  50. local CloverCheck = function(actor)
  51.     local hasClover = false
  52.     if actor ~= nil then
  53.         if isa(actor, "PlayerInstance") then
  54.             if actor:countItem(clover) > 0 then
  55.                 hasClover = true
  56.             end
  57.         end
  58.     end
  59.     return hasClover
  60. end
  61.  
  62. local CloverReRoll = function(damager, damagerVar, parentVar, chance, chanceBonus, itemCount)
  63.     local parent = damager:getParent()
  64.     if CloverCheck(parent) then
  65.         if math.random() <= (chance + (chanceBonus * (itemCount - 1))) then
  66.             cloverSound:play(0.8 + math.random()*0.2)
  67.             if type(parentVar) == "String" then
  68.                 damager:set(damagerVar, parent:get(parentVar) or 0)
  69.             else
  70.                 damager:set(damagerVar, parentVar)
  71.             end
  72.         end
  73.     end
  74.    
  75. end
  76.  
  77. registercallback("preHit", function(damager)
  78.     local parent = damager:getParent()
  79.     if CloverCheck(parent) then
  80.         if damager:get("critical") ~= 1 then
  81.             for i = 0, parent:get("luck") or 0 do
  82.                 if math.random() * 100 <= parent:get("critical_chance") then
  83.                     cloverSound:play(0.8 + math.random()*0.2)
  84.                     damager:set("critical", 1)
  85.                     damager:set("damage", damager:get("damage") * 2)
  86.                     damager:set("damage_fake", damager:get("damage_fake") * 2)
  87.                 end
  88.             end
  89.         end
  90.         --On Hit Items--
  91.         for _, itemCheck in pairs(CloverFunctions) do
  92.             if itemCheck.item ~= nil then
  93.                 if parent:countItem(itemCheck.item) > 0 then
  94.                     if damager:get(itemCheck.damagerVar) ~= itemCheck.parentVar then
  95.                         for i = 0, parent:get("luck") or 1 do
  96.                             CloverReRoll(damager, itemCheck.damagerVar, itemCheck.parentVar, itemCheck.chance, itemCheck.chanceBonus, parent:countItem(itemCheck.item))
  97.                         end
  98.                     end
  99.                 end
  100.             end
  101.         end
  102.     end
  103. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top