1-------------------------------------------------------------------------------- 2-------------------------------------------------------------------------------- 3-- 4-- file: setupdefs.lua 5-- brief: setup some custom UnitDefs parameters, 6-- and UnitDefNames, FeatureDefNames, WeaponDefNames 7-- author: Dave Rodgers 8-- 9-- Copyright (C) 2007. 10-- Licensed under the terms of the GNU GPL, v2 or later. 11-- 12-------------------------------------------------------------------------------- 13-------------------------------------------------------------------------------- 14 15for _,ud in pairs(UnitDefs) do 16 17 -- set the cost value (same as shown in the tooltip) 18 ud.cost = ud.metalCost + (ud.energyCost / 60.0) 19 20 -- add the custom weapons based parameters 21 ud.hasShield = false 22 ud.canParalyze = false 23 ud.canStockpile = false 24 ud.canAttackWater = false 25 for _,wt in ipairs(ud.weapons) do 26 local wd = WeaponDefs[wt.weaponDef] 27 if (wd) then 28 if (wd.weapontype == "Shield") then ud.hasShield = true end 29 if (wd.paralyzer) then ud.canParalyze = true end 30 if (wd.stockpile) then ud.canStockpile = true end 31 if (wd.waterWeapon) then ud.canAttackWater = true end 32 end 33 end 34end 35 36 37-------------------------------------------------------------------------------- 38-------------------------------------------------------------------------------- 39 40-- setup the UnitDefNames{} table 41do 42 local tbl = {} 43 for _,def in pairs(UnitDefs) do 44 tbl[def.name] = def 45 end 46 UnitDefNames = tbl 47end 48 49 50-- setup the FeatureDefNames{} table 51do 52 local tbl = {} 53 for _,def in pairs(FeatureDefs) do 54 tbl[def.name] = def 55 end 56 FeatureDefNames = tbl 57end 58 59 60-- setup the WeaponDefNames{} table 61do 62 local tbl = {} 63 for _,def in pairs(WeaponDefs) do 64 tbl[def.name] = def 65 end 66 WeaponDefNames = tbl 67end 68 69 70-------------------------------------------------------------------------------- 71-------------------------------------------------------------------------------- 72