Knowledgebase Article 54


Semantics of ASCTXT files

The syntax of ASCTXT files is documented in Article 33.

ASCTXT files support inheritance:

vehicletype {
  name = tank
  ID = 10
  armor = 500
  view = 40
  jamming = 5
  ... 
} vehicletype

vehicletype { name = heavy tank ID = 11 parent = 10 armor = 650 } vehicletype

This defines two units, a "tank" (which must have all definitions that are required for a vehicletype, indicated by the dots), and a "heavy tank" which is derived from "tank". The "heavy tank" inherits all properties of its parent unit except Name, ID, and Armor.

Modifying properties

Properties can not only be replaced, they can be modified too:

vehicletype {
  name = super heavy tank
  ID = 12
  parent = 10
  armor += 220
} vehicletype

The "super heavy tank" will have an armor of 720. Another operator is *= which multiplies a variable:

vehicletype {
  name = mega tank
  ID = 13
  parent = 12
  armor *= 1.2
} vehicletype

The "mega tank" inherits from "super heavy tank" and has 1.2 times the armor, which is 864.

Abstract parents

vehicletype {
  name = A1
  ID = 20
  view = 10
  abstract = true
} vehicletype

vehicletype { name = aircraft carrier ID = 21 parent = 20 view *= 3 ... } vehicletype

vehicletype { name = battleship ID = 22 parent = 20 view *= 4 ... } vehicletype

You will never find the unit A1 in ASC nor the mapeditor, because A1 is NOT a unit. It is an abstract base class which only provides data to derived units. If you derive all ships from A1, you can easily modify the view of all ships just by modifying A1. If you decide after some testing that your ships should have a 10% increase in view, just modify A1 to have a view of 11.

Multiple inheritance

vehicletype {
  name = trooper
  ID = 30
  view = 20
  ...
} vehicletype

vehicletype { name = binocular package ID = 31 abstract = true view = 100 } vehicletype

vehicletype { name = reconnaissance trooper ID = 32 parent = 31 30 } vehicletype

The "reconnaissance trooper" inherits from two base classes. The first one has precedence over the second one. This results in the "reconnaissance trooper" having all properties of the basic trooper except view, which is defined in the "binocular package".

Defining alias

TerrainType { 
   dry { 
      Picture = grass.pcx
      ...
   } dry
   much_snow { 
      Picture = snow.pcx
      ...
   } much_snow
   snow_and_ice {
      Picture -> TerrainType.much_snow.picture
      ...
   }  
   ...
} TerrainType 

This terrain will use the same picture for snow_and_ice as for much_snow. It is necessary that you specify the fully qualified property name, include the TerrainType. prefix !

The alias can reference ANY property:

TerrainType { 
   grass_image = grass.pcx
   water_image = water.pcx
   mud_image = mud1.pcx
   another_mud_image = mud2.pcx
   snow_image = snow.pcx
   abstract = true
   id = 100
} TerrainType 

TerrainType { parent = 100 dry { Picture -> TerrainType.grass_image ... } dry much_snow { Picture -> TerrainType.snow_image ... } much_snow snow_and_ice { Picture -> TerrainType.snow_image ... } ... } TerrainType

The alias-all operator

While the alias operator -> operates only on a single property, the alias-all operator ->* operates on a group of properties:

TerrainType { 
   dry { 
      Picture = grass.pcx
      ...
   } dry
   much_snow { 
      Picture = snow.pcx
      movemalus = 15
      TerrainProperties = deep_snow track_possible
      ...
   } much_snow
   snow_and_ice ->* TerrainType.much_snow
   ...
} TerrainType 

This all properties of the much_snow group will be copied into the snow_and_ice group.

Existing properties will not be replaced, as is shown in this example:

vehicletype {
  name = weapon definitions
  ID = 100
  abstract = true
  big_ground_to_ground_missile {
      Type = ground_missile shootable 
      shotFrom = ground_level 
      MaxRange = 42
      MinRange = 18
      Punch@MaxRange = 60
      Punch@MinRange = 70
      ...
  } ground_to_ground_missile
  small_ground_to_ground_missile {
      Type = ground_missile shootable 
      shotFrom = ground_level 
      MaxRange = 10
      MinRange = 10
      Punch@MaxRange = 40
      Punch@MinRange = 50
      ...
  } small_ground_to_ground_missile
} vehicletype

vehicletype { parent = 100 Weapons { Number = 2 Weapon0 ->* VehicleType.big_ground_to_ground_missile Weapon1 ->* VehicleType.small_ground_to_ground_missile Weapon1.MaxRange = 20 } Weapons ... } vehicletype

This unit has two weapon systems. The first one has all properties of the big_ground_to_ground_missile defined in the abstract weapon definition. The second one is based on the small_ground_to_ground_missile , but uses a different MaxRange: 20 instead of 10.

Last change: Tue, 2003-04-01 9:37


search knowledgebase
browse knowledgebase