ARK: Survival Evolved Wiki
Advertisement

Documentation for this module may be created at Module:TamingTableMobile/doc

local p = {}
function p.creature( f )
  local dlclink = require('Module:DLCLink').link
  local args = f:getParent().args
  local levels = {}
  local creature = args[1]
  -- if creature was not given, take it from PAGENAME
  if creature == nil then
    creature = f.args[1]
  end

  local creatureData = mw.loadData( 'Module:TamingTableMobile/creatures' )
  if creatureData[creature] ~= nil then
    for i, level in ipairs(args) do
      if i ~= 1 then
        table.insert(levels,level)
      end
    end

    if table.getn(levels) == 0 then
      levels = {1,30,75,150,300,450}
    end
    local foodData = mw.loadData( 'Module:TamingTable/food' )
    local tables = {}

    -- initialize taming variables
    local affinityNeeded, totalTorpor, torporDeplPS, foodPiecesNeeded, seconds, foodAffinity, foodValue, wakeAffinityMult, wakeFoodDeplMult, foodname = 0, 0, 0, 0, 0, 0, 0, 1, 1, ''

    -- test if creature is tamend non-violently, then use wakeTame multiplicators
    local nonViolent = false
    if (creatureData[creature].nonViolentTame ~= nil and creatureData[creature].nonViolentTame == 1) then
      nonViolent = true
      if creatureData[creature].wakeAffinityMult ~= nil then
        wakeAffinityMult = creatureData[creature].wakeAffinityMult
      end
      if creatureData[creature].wakeFoodDeplMult ~= nil then
        wakeFoodDeplMult = creatureData[creature].wakeFoodDeplMult
      end
    end
    -- creature need heavy weapon knockout? (like rock elemental, titnaosaur)
    local heavyWeaponKnockout = false
    if (creatureData[creature].heavyWeaponKnockout ~= nil and creatureData[creature].heavyWeaponKnockout == 1) then
      heavyWeaponKnockout = true
    end

    for _,level in ipairs(levels) do
      local headerCols = ''

      if nonViolent then
        headerCols = '! <span class="hover-text" title="The theoretically optimal minimum">Feeding Interval</span>\n! Time'
      else
        -- total torpor for level
        totalTorpor = creatureData[creature].torpor1 + creatureData[creature].torporIncrease * (level-1)

        -- torpor depletion per second for level
        -- here an exponential approximation of the torpor Depletion is used, credits to http://crumplecorn.com/content/taming-calculator
        if creatureData[creature].torporDepletionPS0 ~= nil then
          torporDeplPS = creatureData[creature].torporDepletionPS0 + math.exp(0.800403041 * math.log(level - 1)) / (22.39671632 / creatureData[creature].torporDepletionPS0);
        else
          torporDeplPS = 0
        end

        if torporDeplPS > 0 then
          headerCols = '! [[File:Narcoberry.png|30px|Narcoberry|link=Narcoberry]]\n! [[File:Narcotic.png|30px|Narcotic|link=Narcotic]]\n! [[File:Bio Toxin.png|30px|Bio Toxin|link=Bio Toxin]]\n! Time'
        else
          headerCols = '! Time'
        end
      end
      local rows = {'{| class="wikitable" data-description="Taming Table Level '..level..'"\n|-\n|-\n! [[File:Soothing Balm (Mobile).png|30px|Soothing Balm|link=Soothing Balm (Mobile)]]\n! colspan="2" | [[File:'..creature..'.png|30px]] Level '..level..'\n'..headerCols..''}

      if creatureData[creature].affinityNeeded0 ~= nil and creatureData[creature].affinityIncrease ~= nil and torporDeplPS ~= nil then
        affinityNeeded = creatureData[creature].affinityNeeded0 + creatureData[creature].affinityIncrease * level;

        -- mobile creatures are tamed 1.75 faster
        affinityNeeded = affinityNeeded * 0.57142857142

        local balmMultipliers = {1, 3, 10, 15}
        local balmNames = {"noBalm", "Minor Soothing Balm", "Regular Soothing Balm", "Major Soothing Balm"}
        local balmColumnRowSpans = {1, 1, 1, 1}

        for bi,balmMultiplier in ipairs(balmMultipliers) do
          -- if Soothing Balm is used, the needed affinity is less as specified in balmMultipliers
          affinityNeeded = affinityNeeded / balmMultiplier

          local balmColumnIconSet = false

          -- foodname for display
          foodname = ''

          -- how much food/resources of the different kinds that this creature eats is needed
          for _,food in ipairs(creatureData[creature].eats) do
            local cols = {}
            local colDefaultStyle = 'align="right" style="min-width:2.8em'
            foodAffinity = 0
            foodValue = 0
            if food == 'Kibble' then
              foodname = 'Kibble ('..creatureData[creature].favoriteKibble..' Egg)'
            else
              foodname = food
            end
            -- check if creature handles this food in a special way (e.g. scorpions not liking raw meat as much)
            if (creatureData[creature].specialFoodValues ~= nil and creatureData[creature].specialFoodValues[food] ~= nil) then
              if creatureData[creature].specialFoodValues[food].affinity ~= nil then
                foodAffinity = creatureData[creature].specialFoodValues[food].affinity
              end
              if creatureData[creature].specialFoodValues[food].value ~= nil then
                foodValue = creatureData[creature].specialFoodValues[food].value
              end
            end
            if foodData[food] ~= nil then
              if foodAffinity == 0 then
                foodAffinity = foodData[food].affinity
              end
              if foodValue == 0 then
                foodValue = foodData[food].foodValue
              end
            end
            if (foodAffinity > 0 and foodValue > 0) then
              -- consider wake taming multiplicators (non-violent taming)
              -- multiply by 2 to account for the x2 taming introduced in Dec-2016
              foodAffinity = foodAffinity * wakeAffinityMult * 2
              foodValue = foodValue * wakeFoodDeplMult

              -- amount of food
              foodPiecesNeeded = math.ceil(affinityNeeded/foodAffinity)
              -- time to eat needed food
              seconds = math.ceil(foodPiecesNeeded * foodValue / (creatureData[creature].foodConsumptionBase * creatureData[creature].foodConsumptionMult))
              -- hack to correct basilosaurus' taming times
              if creatureData[creature].resultCorrection ~= nil then
                seconds = seconds * creatureData[creature].resultCorrection
              end

              if balmColumnIconSet ~= true then
                if balmMultiplier ~= 1 then
                  table.insert(cols,'rowspan="__ROWSPAN'..bi..'__" | [[File:'..balmNames[bi]..' (Mobile).png|30px|link='..balmNames[bi]..' (Mobile)]]')
                else
                  table.insert(cols,'rowspan="__ROWSPAN'..bi..'__" | [[File:X mark.svg|30px|Values without Soothing Balm]]')
                end
                balmColumnIconSet = true
              else
                balmColumnRowSpans[bi] = balmColumnRowSpans[bi] + 1
              end

              local itemicon = ''
              -- changes Kibble icons
              if food == 'Kibble' then
                itemicon = '[[File:Kibble (Mobile).png|30px]]'
              else
                itemicon = '[[File:'..foodname..'.png|30px]]'
              end

              table.insert(cols,'style="border-right-width:0"| '..itemicon..' '..dlclink(foodname))
              table.insert(cols,colDefaultStyle..';border-left-width:0"|'..foodPiecesNeeded)
              if nonViolent then
                -- feeding intervall (only approximately (mean), exact numbers seem to be more complicated because of inital longer pause)
                -- the last feeded food grants the tame instantly, so subtract one of the needed pieces for the time
                local feedingInterval = 0
                if foodPiecesNeeded > 1 then
                  feedingInterval = seconds/(foodPiecesNeeded-1)
                end
                table.insert(cols,colDefaultStyle..'"|'..os.date("!%M:%S",feedingInterval))
              else
                -- extra needed torpor to eat needed food
                local torporNeeded = math.ceil(torporDeplPS * seconds - totalTorpor)
                if torporNeeded < 0 then
                  torporNeeded = 0
                end

                -- only display number of narcos if columns exist
                if torporDeplPS > 0 then
                  -- amount of Narcoberries (give 7.5 torpor each over 3s)
                  table.insert(cols,colDefaultStyle..'"|'..math.ceil(torporNeeded/(7.5+3*torporDeplPS)))
                  -- amount of Narcotics (give 40 each over 8s)
                  table.insert(cols,colDefaultStyle..'"|'..math.ceil(torporNeeded/(40+8*torporDeplPS)))
                  -- amount of Bio Toxins (give 80 each over 16s)
                  table.insert(cols,colDefaultStyle..'"|'..math.ceil(torporNeeded/(80+16*torporDeplPS)))
                end
              end
              -- needed Time to eat
              table.insert(cols,colDefaultStyle..'"|'..math.floor(seconds/3600)..':'..os.date("!%M:%S",seconds))

              table.insert(rows,'| '..table.concat(cols,'\n| '))
            end
          end
        end
        -- set rowspans for balm-columns
        for r,_ in ipairs(rows) do
          local bi = tonumber(string.match(rows[r],'__ROWSPAN(%d)__'))
          if bi ~= nil and bi > 0 then
            rows[r] = string.gsub(rows[r], '__ROWSPAN'..bi..'__', balmColumnRowSpans[bi])
          end
        end
      end

      local torporInfoRows = ''
      if not nonViolent then
        if heavyWeaponKnockout then
          --
          local ballistaTorpor = creatureData[creature].heavyWeaponTorporValue['ballistaBolt']
          local boulderTorpor = creatureData[creature].heavyWeaponTorporValue['boulder']
          local rocketTorpor = creatureData[creature].heavyWeaponTorporValue['rocket']
          local homingRocketTorpor = creatureData[creature].heavyWeaponTorporValue['homingRocket']
          local cannonballTorpor = creatureData[creature].heavyWeaponTorporValue['cannonball']
          -- 
          local ballistaBoltsNeeded = nil
          local bouldersNeeded = nil
          local rocketsNeeded = nil
          local homingRocketsNeeded = nil
          local cannonballsNeeded = nil

          if (totalTorpor/ballistaTorpor) then
            ballistaBoltsNeeded = '<span style="font-style:oblique;">N/A</span>'
          else
            ballistaBoltsNeeded = math.ceil(totalTorpor/ballistaTorpor)
          end
          --
          if (totalTorpor/boulderTorpor == 0) then
            bouldersNeeded = '<span style="font-style:oblique;">N/A</span>'
          else
            bouldersNeeded = math.ceil(totalTorpor/boulderTorpor)
          end
          --
          if (totalTorpor/rocketTorpor == 0) then
            rocketsNeeded = '<span style="font-style:oblique;">N/A</span>'
          else
            rocketsNeeded = math.ceil(totalTorpor/rocketTorpor)
          end
          --
          if (totalTorpor/homingRocketTorpor == 0) then
            homingRocketsNeeded = '<span style="font-style:oblique;">N/A</span>'
          else
            homingRocketsNeeded = math.ceil(totalTorpor/homingRocketTorpor)
          end
          --
          if (totalTorpor/cannonballTorpor == 0) then
            cannonballsNeeded = '<span style="font-style:oblique;">N/A</span>'
          else
            cannonballsNeeded = math.ceil(totalTorpor/cannonballTorpor)
          end
          torporInfoRows = '\n|-\n| colspan="6" align="right" | <span class="hover-text" title="Assuming the bow is fully-drawn and target is the unprotected body and Melee-damage is 100%. Hitting the head is more effective.">KO</span>: [[File:Ballista Bolt.png|20px|Ballista Hits|link=Ballista Bolt]] × '
          ..ballistaBoltsNeeded..
          '; [[File:Boulder.png|20px|Boulder Hits|link=Boulder]] × '
          ..bouldersNeeded..
          '; [[File:Rocket Propelled Grenade.png|20px|Rocket Propelled Grenade Shots|link=Rocket Propelled Grenade]] × '
          ..rocketsNeeded..
          '; [[File:Rocket Homing Missile (Scorched Earth).png|20px|Homing Missile Shots|link=Rocket Homing Missile (Scorched Earth)]] × '
          ..homingRocketsNeeded..
          '; [[File:Cannon Ball.png|20px|Cannon Shots|link=Cannon Ball]] × '
          ..cannonballsNeeded
          -- print torpor depletion per s
          if torporDeplPS > 0 then
            torporInfoRows = torporInfoRows .. '\n|- style="font-size:0.8em"\n| colspan="6" align="right" | [[Torpidity]]-depletion: <span class="hover-text" title="That is approx. one Narcoberry every '..(math.floor(75/torporDeplPS)/10 + 3)..' s, one Narcotic every '..(math.floor(400/torporDeplPS)/10 + 5)..' s or one Bio Toxin every '..(math.floor(800/torporDeplPS)/10 + 16)..' s">'..(math.ceil(100*torporDeplPS)/100)..' / s</span>, Time until all torpidity is depleted: '..os.date("!%X", totalTorpor/torporDeplPS)
          end

        elseif not heavyWeaponKnockout then
          -- print needed tranq arrows needed to ko creature. Bow-arrow causes 20 dmg, tranqMultiplier are 2+2.5=4.5 ==> 90 Torpor/arrow. (20 dmg)
          -- crossbow 35 dmg * 4.5 ==> 157.5 torpor (35 dmg)
          -- slingshot: 14 dmg, stone-tranq-mult: 1.75 ==> 24.5 torpor (14 dmg)
          -- wooden club: 10 torpor (5 dmg)
          -- longneck dart: 26 * 8.5 = 221 (26 dmg)
          torporInfoRows = '\n|-\n| colspan="7" align="right" | <span class="hover-text" title="Assuming the bow is fully-drawn and target is the unprotected body and Melee-damage is 100%. Hitting the head is more effective.">KO</span>: [[File:Wooden Club.png|20px|Wooden Club Hits|link=Wooden Club]] × '
          ..math.ceil(totalTorpor/10)..
          '; [[File:Slingshot.png|20px|Slingshot Hits|link=Slingshot]] × '
          ..math.ceil(totalTorpor/24.5)..
          '; [[File:TranqArrowBow.png|20px|Tranquilizer Arrows with a Bow|link=Bow]] × '
          ..math.ceil(totalTorpor/90)..
          '; [[File:TranqArrowCrossbow.png|20px|Tranquilizer Arrows with a Crossbow|link=Crossbow]] × '
          ..math.ceil(totalTorpor/157.5)..
          '; [[File:ToxicantArrowBow.png|20px|Toxicant Arrows with a Bow|link=Bow]] × '
          ..math.ceil(totalTorpor/180)..
          '; [[File:ToxicantArrowCompoundBow.png|20px|Toxicant Arrows with a Compound Bow|link=Compound Bow]] × '
          ..math.ceil(totalTorpor/240)..
          '; [[File:Tranquilizer Dart.png|20px|Tranquilizer Dart Shots|link=Tranquilizer Dart]] × '
          ..math.ceil(totalTorpor/221)..
          '; [[File:Shocking Tranquilizer Dart.png|20px|Shocking Tranquilizer Dart Shots|link=Shocking Tranquilizer Dart]] × '
          ..math.ceil(totalTorpor/442)
          -- print torpor depletion per s
          if torporDeplPS > 0 then
            torporInfoRows = torporInfoRows .. '\n|- style="font-size:0.8em"\n| colspan="7" align="right" | [[Torpidity]]-depletion: <span class="hover-text" title="That is approx. one Narcoberry every '..(math.floor(75/torporDeplPS)/10 + 3)..' s, one Narcotic every '..(math.floor(400/torporDeplPS)/10 + 5)..' s or one Bio Toxin every '..(math.floor(800/torporDeplPS)/10 + 16)..' s">'..(math.ceil(100*torporDeplPS)/100)..' / s</span>, Time until all torpidity is depleted: '..os.date("!%X", totalTorpor/torporDeplPS)
          end
        end	 
      end

      table.insert(tables,table.concat(rows,'\n|-\n')..torporInfoRows..'\n|}')
    end
    return '<div style="display:inline-block;margin:0 4px">\n'..table.concat(tables,'\n</div><div style="display:inline-block;margin:0 4px">\n')..'\n</div>'
  else
    return '<pre>Error: No taming-data for "'..creature..'" found. If the current page is not a creature-page, write the wanted creature as first parameter. Use only the common name, found on the creature\'s dossier.</pre>[[Category:Pages with broken TamingTable]]'
  end
end
return p
Advertisement