Advertisement
mikeyy

Map-dynamic upgrade costs

May 25th, 2011
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. --Table of map-specific Citadel Upgrade cost multipliers
  2. --Format: MapName = { UpgradeName1 = Multiplier, UpgradeName2 = Multiplier }
  3. MapCostMults = {
  4.     MAP09 = { --Leviathan
  5.         CUpgradeStructure01 = 2.0, --2x cost mult for Trebuchets
  6.     },
  7. }
  8.  
  9. --Get map path
  10. local mapPath, luaState = false, false
  11. if IsUser() then
  12.     luaState = 'User'
  13.     mapPath = SessionGetScenarioInfo().map
  14. elseif IsSim() then
  15.     luaState = 'Sim'
  16.     mapPath = ScenarioInfo.map
  17. end
  18.  
  19. --Extract map name and apply cost modifications
  20. if mapPath and type(mapPath) == 'string' then
  21.     LOG("CitadelUpgrades: Applying map-dynamic upgrade costs for state: "..luaState)
  22.     local mapName = string.match(mapPath, '(MAP%d+)%.scmap$')
  23.     if not mapName then
  24.         WARN("\tCould not get map name from path '"..mapPath.."', aborting")
  25.     elseif MapCostMults[mapName] then
  26.         LOG("Map name: "..mapName)
  27.         for name, mult in MapCostMults[mapName] do
  28.             local upgrade = Upgrades.Tree[name]
  29.             if upgrade then
  30.                 local newCost = upgrade.Cost * mult
  31.                 LOG("\t"..name..", "..mult..":\t"..upgrade.Cost.." ->\t"..newCost)
  32.                 upgrade.Cost = newCost
  33.             else
  34.                 WARN("\tCould not find upgrade '"..name.."', skipping")
  35.             end
  36.         end
  37.     else
  38.         LOG("\tNo cost mult data for map name '"..mapName.."'")
  39.     end
  40. elseif not IsRuleInit() then
  41.     WARN("CitadelUpgrades: Could not get scenario data for state: "..luaState)
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement