This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

FlagAsset.FindCaptureReward

By: mikeyy on Jul 25th, 2011  |  syntax: Lua  |  size: 2.97 KB  |  views: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     FindCaptureReward = function(self, flag)
  2.         local brainName = self.Brain.Name
  3.  
  4.         local captureReward = 0
  5.  
  6.         --Mithy: Default capture reward weights
  7.         local captureWeights = {
  8.             ugbdefense02 = 0.5,
  9.             ugbfort01 = 0.5,
  10.             ugbresource01 = 0.5, # 0.27.04 changed value from 1.75 to 0.5
  11.             ugbportal01 = 0.5, # 0.27.04 changed value from 1.75 to 0.5
  12.             unbidol01 = 0.75, # 0.26.54 dropped to 0.75 from 1.5
  13.             ugbshop05 = 0.75, # 0.27.05 dropped to 0.75 from 1.25
  14.             unbflagcooldown01 = 0.75, # 0.27.05 dropped to 0.75 from 1.5
  15.             unbflagdamageamp01 = 0.75, # 0.27.05 dropped to 0.75 from 1.5
  16.             unbflaghealthregen01 = 0.75,
  17.             unbflagmanaregen01 = 0.75,
  18.             unbflagmaxhealth01 = 1.25, # 0.27.05 increased from 1.0 to 1.25
  19.             unbflagmaxmana01 = 1.25,  # 0.27.05 increased from 1.0 to 1.25
  20.             unbflagexperience01 = 1.0, # 0.26.54 dropped to 1.0 from 1.75
  21.             ugbhealthstatue01 = 1.5,
  22.             ugbartillery01 = 0.75,
  23.         }
  24.  
  25.         --Mithy: Scenario-specific capture weight overrides
  26.         local scenarioWeights = {
  27.             none = {},
  28.             --Mandala
  29.             map04 = {},
  30.             --Cataract
  31.             map05 = {
  32.                 ugbresource01 = 0.75,
  33.                 unbflagmaxmana01 = 1.0,
  34.             },
  35.             --Zikurat
  36.             map07 = {},
  37.             --Leviathan
  38.             map09 = {},
  39.             --Crucible
  40.             map10 = {},
  41.             --The Brothers
  42.             map11 = {},
  43.             --Exile
  44.             map12 = {},
  45.             --Prison
  46.             map13 = {},
  47.         }
  48.         local scenName = import('/lua/common/commonutils.lua').GetScenarioName() or 'none'
  49.         local scenWeights = scenarioWeights[scenName] or {}
  50.         local currentWeights = table.merged(captureWeights, scenWeights)
  51.         --Debug output - remove/block-comment once this works
  52.         if not ScenarioWeightsDoOnce then
  53.             ScenarioWeightsDoOnce = true
  54.             LOG("\n*AI DEBUG: FindCaptureReward debug--\n    Scenario name: "..scenName.."\n    Scenario capture weight overrides:")
  55.             for k, v in scenWeights do
  56.                 LOG("\t"..k.." = "..v.."\t(default = "..captureWeights[k]..")")
  57.             end
  58.             LOG("\n ")
  59.         end
  60.  
  61.         if flag then
  62.             local captureUnits = flag:GetCaptureList()
  63.             for k, v in captureUnits do
  64.                 --Mithy: Significantly streamlined weight determination
  65.                 captureReward = math.max(captureReward, currentWeights[v] or 0)
  66.             end
  67.  
  68.             if captureReward <= 0 then
  69.                 WARN( '*AI ERROR: No good reward found at flag - ' .. flag.UnitName )
  70.                 captureReward = 0.5
  71.             end
  72.  
  73.             LOG('*AI DEBUG: Capture Reward for - ' .. flag.UnitName .. ' = ' .. captureReward)
  74.         end
  75.  
  76.         self.CaptureReward = captureReward
  77.     end,
clone this paste RAW Paste Data