Armordefs.lua: Difference between revisions

From Spring
Jump to navigationJump to search
Jk (talk | contribs)
m minor style
Jk (talk | contribs)
Line 26: Line 26:
}
}


for categoryName, categoryTable in pairs(armorDefs) do
--NOTE: only needed for <95.0 (before engine was expecting a cryptic format)
  local t = {}
if not(Game) or not(Game.version) then
  for _, unitName in pairs(categoryTable) do
  for categoryName, categoryTable in pairs(armorDefs) do
    t[unitName] = 1
    local t = {}
    for _, unitName in pairs(categoryTable) do
      t[unitName] = 1
    end
    armorDefs[categoryName] = t
   end
   end
  armorDefs[categoryName] = t
end
end


return armorDefs</pre></code>
return armorDefs</pre></code>
Note:<br>
The cryptic looking loop at the end is required to convert the table to a different format. Just copy & paste it.
<span class="warning">NOTE: Since 95.0 You MUST NOT include these converter loop OR ARMOR CLASSES WILL NOT WORK</span>


=Weapon Example=
=Weapon Example=

Revision as of 13:01, 2 December 2013

This file sorts units into different armor classes. Weapons can deal different amount of damage to different armor classes.

Location

armordefs.lua is a file in the Gamedata/ directory of a Spring Game.

Source

The engine source code which parses the data from this file is viewable here:

Details

By default a damage class named "default" exists and every unit is in it. So if all your weapons only deal "default" damage then this file is not needed.

Example

local armorDefs = {
	tanks = {
		"supertank",
		"megatank",
	},

	infantry = {
		"dude",
	},
}

--NOTE: only needed for <95.0 (before engine was expecting a cryptic format)
if not(Game) or not(Game.version) then
  for categoryName, categoryTable in pairs(armorDefs) do
    local t = {}
    for _, unitName in pairs(categoryTable) do
      t[unitName] = 1
    end
    armorDefs[categoryName] = t
  end
end

return armorDefs

Weapon Example

Goes with above example, a weapon that deals 60 damage to infantry but only 5 damage to tanks:

...
damage = {
	infantry = 60,
	tanks = 5,
},
...

Links to more Examples

zero-K
Contains scripting to take into account various things like EMP damage.

Tutorial Game
Uses default damage class, except for one unit that is "armored."

MechCommander: Legacy
Automatically assigns units to an armor class based on UnitDef tags and custom params.