Genie unit

From GenieWiki

(Redirected from Genie units)
Jump to: navigation, search

Here is the (incomplete) structure that Genie uses to store its unit data (using C syntax). A 'g' preceding a variable means that it refers to a graphic, 's' means that it is the resource ID for a string, 'snd' means that it refers to a sound, 'u' refers to another unit index, and "len" means that it is the length of a string of the same name. "Unused" variables have had a value of -1 in all units investigated so far.

struct UnitData
{
	char metatype;
	short lenInternalName;
	short typeid;
	short sName;
	short sTrain;
	short class;
	short gStanding;
	short unused1;
	short gDying;
	short unused2;
	char unk3;
	short hp;
	float los;
	char garrison;
	float sizex, sizey;
	float hpbar1;
	short sndCreation;
	short unk5;
	short uDead;
	short unk6;
	short icon;
	bool hide;
	short unk7[6];
	float eselx, esely;
	bool unk8;
	bool fog;
	short terrain;
	bool fly;
	short rescarry;
	float unk9;
	char unk10;
	float unk11;
	char unk12[17];
	char mask;
	char unk13[2];
	char ua;
	char civ;
	char unk14[2];
	bool hideHpbar;
	char unk15;
	float selx, sely;
	float hpbar2;
	res1 storage[3];
	
	char grDamage_count;
	damage grDamage[grDamage_count];

	short sndSelect;
	short sndSelect2; //unused, but probably original use
	short unk16;
	char *internalName[lenInternalName];

	/* These next four values are only present in version 5.9 of the datafiles */
	short	lenName2;
	char*	name2;
	short	unitline_id;
	char	mintechlevel;

	short id2, id3;

	/* Only present if metatype is not 10 */
	float speed;
};

/* Only present if metatype >= 30 */
struct UnitData2
{
	short	grWalk;
	short	grWalk2;
	float	unknown19_02;
	char	unknown19_03;
	short	uTrack;
	char	unknown19_05;
	float	unknown19_06[2];
	char	unknown19_07[9];
	float	unknown19_08;
	char	unknown19_09[4];
};

/* Only present if metatype >= 60 */
struct UnitData3
{	/* Size: 40 */
	short	unknown20;
	float	search_radius;
	float	workrate;
	char	unknown22[4];
	char	villager_mode;
	short	sound_move;
	short	sound_stop;
	char	unknown24;
	short	unknown25;
	short   attacks_length;
	short   attacks[attacks_length];
	short   armors_length;
	short   armors[armors_length];
	short   unknown27;
	float   range_max;
	float   radius;
	float   reload1;
	short   unit_projectile;
	char    accuracy;
	short   unknown32;
	short   delay;
	float   dis1, dis2, dis3;
	char    unknown32b;
	float   range_min;
	float   grrate;	//garrison recovery rate
	short   graphic_attack;
	short   displayed_armour;
	short   displayed_attack;
	float   displayed_range;
	float   reload2;
};

It is also convenient to define other structures that are used for resource data.

struct res1
{
	short type;
	float amount;
	bool enabled;
};

struct res2
{
	short type, amount, enabled;
};

struct damage
{
	short graphic;
	short when;
	char unknown;
};

Contents

Common properties

All units have these values in their structure.

metatype

This value is the overall type associated with the unit that affects its property set. Possible values follow.

  • 10: These are the most basic units, including only rubble and flares. Their only difference from metatype 20 units is the lack of movement speed.
  • 20: The same as metatype 10 except the units have a movement speed. The metatype contains mostly flags, so the purpose of the movement speed property is unknown.
  • 25: Contains only one unit in AOK, DOPL (id 243). There is no difference in properties from metatype 20.
  • 30: Dead units. It seems to be unused in SWGB as units just explode and do not leave carcasses.
  • 40: Unused in AOK. No information available.
  • 60: Projectiles.
  • 70: Living units.
  • 80: Buildings.

typeid

Also referred to as the "unit constant." Each unit (Militia, Man-at-Arms, etc.) has this as a unique identifier. The game uses this both internally and for storage in saved games and scenario files.

sName

The name of the unit displayed in-game.

class

This is the class the unit is part of, which gives it certain properties. See AOK:List of units for AoK classes.

gStanding

The graphic displayed when the unit is in the default state (standing).

gDying

The graphic displayed while the unit is dying. (This is not to be confused with the dead unit.)

unk3

This byte has had a value of 0 in every unit investigated so far.

hp

Unit's hitpoints.

los

Unit's default line of sight.

garrison

Maximum number of units that can be garrisonned at the same time.

sizex, sizey

These two values control the size of a unit, which determines the area taken by the unit. No other unit can move into the taken area with the exception of flying units. Most units have equal x and y dimensions, but some gates and bridges do not.

hpbar1

Height of hitpoints bar?

sndCreation

Sound played when unit is created.

uDead

Genie creates the specified unit when this one dies. Almost every unit has a dead body unit associated with it, contributing a fair amount to the size of the data file.

icon

This is the icon associated with the unit. Genie displays this icon in the bottom panel both when the unit is selected and when building a unit.

hide

This boolean determines whether the unit is "hidden" in the editor, meaning that it cannot be placed.

eselx, esely

These values determine the size of the selection circle or square of the unit in the scenario editor.

fog

This boolean determines whether the unit is visible (non-zero) or invisible (zero) under fog-of-war.

terrain

This short determines what terrain restrictions are imposed on the unit. Known values are:

  • 0x00 All Terrains
  • 0x01 Shoreline
  • 0x02 Water
  • 0x03 Water (for ships)
  • 0x04 Open Ground (used for buildings)
  • 0x05 Nowhere
  • 0x06 Light Water (used for buildings such as docks)
  • 0x07 Ground
  • 0x08 Non-ice ground
  • 0x0B Nature Ground (for trees)
  • 0x0D Water (for Great fish)
  • 0x0F Water (for nets, Transport Ships)
  • 0x10 Grass and Shoreline only (gates and walls)
  • 0x13 Water, no ice (used for fish)

fly

This boolean determines whether the unit can "fly" over other units. Used for birds and FLDOG in AoK.

rescarry

Determines what resources the unit can carry. (?)

hideHpbar

This boolean determines whether genie hides the unit's hp bar, primarily used for trees. The standard non-zero value seems to be 2, so more investigation is required.

selx, sely

These values determine the size of the selection circle or square of the unit during gameplay.

storage[3]

These structures are used for the resource costs of a unit. The three games usually use the third cost for population (that is, every "living" unit costs 1 population).

grDamage

These structures define damage graphics (flames) for buildings.

sndSelect

The identified sound will be played when a player selects the unit.

unk16

This value was previously labeled as a sound index, but is probably not.

internalName

A name used to identify the unit internally. Genie displays this name if the unit's language string is unavailable.

id2, id3

These identifiers are duplicates of typeid. Their use is unknown.

speed

Note: This property is only present if the metatype is not 10.

The unit's movement speed.

uTrack

The specified unit is created as the tracks of the unit. This is used for trade carts and for the fire ship projectiles (the flames).

villager_mode

This is a boolean value determining whether the unit switches villager types.

accuracy

Percentage value determining probability of an attack hitting.

grrate

Garrison recovery rate.

To be continued...

See Also

Personal tools