Logo Search packages:      
Sourcecode: freecraft version File versions

_unit_ Struct Reference

#include <unit.h>

List of all members.


Detailed Description

The big unit structure.

#include "unit.h"

typedef struct _unit_ Unit;

Everything belonging to an unit. FIXME: rearrange for less memory.

This structure contains all informations about an unit in game. An unit could be everything, a man, a vehicle, a ship or a building. Currently only a tile, an unit or a missile could be placed on the map.

The unit structure members:

Unit::Refs

The reference counter of the unit. If the pointer to the unit is stored the counter must be incremented and if this reference is destroyed the counter must be decremented. Alternative it would be possible to implement a garbage collector for this.

Unit::Slot

This is the unique slot number. It is not possible that two units have the same slot number at the same time. The slot numbers are reused. This field could be accessed by the macro UnitNumber(Unit*). Maximal 65535 (=MAX_UNIT_SLOTS) simultaneous units are supported.

Unit::UnitSlot

This is the pointer into Units[], where the unit pointer is stored. Units[] is a table of all units currently active in game. This pointer is only needed to speed up, the remove of the unit pointer from Units[], it didn't must be searched in the table.

Unit::PlayerSlot

A pointer into Player::Units[], where the unit pointer is stored. Player::Units[] is a table of all units currently belonging to a player. This pointer is only needed to speed up, the remove of the unit pointer from Player::Units[].

Unit::Next

A generic link pointer. This member is currently used, if an unit is on the map, to link all units on the same map field together. This member points the the unit that the current is onboard/inside when a unit is removed (see Unit::Removed). F.E.: A worker is removed, if he is in a mine or depot. Or an unit is on board a transporter.

Unit::Name

Name of the unit.

Unit::X Unit::Y

The tile map coordinates of the unit. 0,0 is the upper left on the map. To convert the map coordinates into pixels, they must be multiplicated with the TileSizeX and TileSizeY. To get the pixel coordinates of an unit, calculate Unit::X*TileSize+UnitIX , Unit::Y*TileSizeY+UnitIY.

Unit::Type

Pointer to the unit-type (UnitType). The unit-type contains all informations that all units of the same type shares. (Animations, Name, Stats, ...)

Unit::SeenType Pointer to the unit-type that this unit was, when last seen. Currently only used by buildings.

Unit::Player

Pointer to the owner of this unit (Player). An unit could only be owned by one player.

Unit::Stats

Pointer to the current status (UnitStats) of an unit. The units of the same player and the same type could share the same stats. The status contains all values which could be different for each player. This f.e. the upgradeable abilities of an unit. (Unit::Stats::SightRange, Unit::Stats::Armor, Unit::Stats::HitPoints, ...)

Unit::CurrentSightRange

Current sight range of a unit, this changes when a unit enters a transporter or building or exits one of these.

Unit::Colors

Player colors of the unit. Contains the hardware dependent pixel values for the player colors (palette index #208-#211). Setup from the global palette.

Note:
Index #208-#211 are various SHADES of the team color (#208 is brightest shade, #211 is darkest shade) .... these numbers are NOT red=#208, blue=#209, etc
Unit::IX Unit::IY

Coordinate displacement in pixels or coordinates inside a tile. Currently only !=0, if the unit is moving from one tile to another (0-32 and for ships/flyers 0-64).

Unit::Frame

Current graphic image of the animation sequence. The high bit (128) is used to flip this image horizontal (x direction). This also limits the number of different frames/image to 126.

Unit::SeenFrame

Graphic image (see Unit::Frame) what the player on this computer has last seen. If UnitNotSeen the player haven't seen this unit yet.

Unit::Direction

Contains the binary angle (0-255) in which the direction the unit looks. 0, 32, 64, 128, 160, 192, 224, 256 corresponds to 0, 45, 90, 135, 180, 225, 270, 315, 360 or north, north-east, east, south-east, south, south-west, west, north-west, north. Currently only 8 directions are used, this is more for the future.

Unit::Attacked

If Attacked is non-zero, the unit is attacked. This member is counted down.

Unit::Burning

If Burning is non-zero, the unit is burning.

Unit::Visible

Used for submarines. It is a bit field for all players. If Unit::Visible&(1<<player-nr) is non-zero, the unit could be seen on the map.

Unit::Destroyed

FIXME:

Todo:
If you need more informations, please send me an email or write it self.
Unit::Removed

This flag means the unit is not active on map. This flag have workers set if they are inside a building, units that are on board of a transporter.

Unit::Selected

Unit::Constructed Set when a building is under construction, and still using the generic building animation.

Unit::SeenConstructed Last seen state of construction. Used to draw correct building frame. See Unit::Constructed for more information.

Unit::SeenState The Seen State of the building. 01 The building in being built when last seen. 10 The building was been upgraded when last seen.

Unit::Mana

Unit::HP

Unit::XP

Unit::Kills

Unit::Bloodlust

Unit::Haste

Unit::Slow

Unit::Invisible

Unit::FlameShield

Unit::UnholyArmor

Unit::GroupId

Number of the group to that the unit belongs. This is the main group showed on map, an unit can belong to many groups.

Unit::LastGroup

Automatic group number, to reselect the same units. When the user selects more than one unit all units is given the next same number. (Used for ALT-CLICK)

Unit::Value

This values hold the amount of gold in a goldmine, amount of oil in an oil patch or oil platform. FIXME: continue documentation

Unit::SubAction

This is an action private variable, it is zero on the first entry of an action. Must be set to zero, if an action finishes. It should only be used inside of actions.

Unit::Wait

FIXME: continue documentation

Unit::State

Animation state, currently position in the animation script. 0 if an animation has just started, it should only be changed inside of actions.

Unit::Reset

FIXME: continue documentation

Unit::Blink

Unit::Moving

Unit::Rs

Unit::Revealer

`revealer' is unit that has to keep the fog of war revealed for some time, this unit cannot be used in usual manner. JOHNS: Should be moved into unit-type!

Unit::OnBoard[MAX_UNITS_ONBOARD]

A table of units on board. This can be units in a transporter or units in a tower.

Unit::OrderCount

The number of the orders unit to process. An unit has atleast one order. Unit::OrderCount should be a number between 1 and MAX_ORDERS. The orders are in Unit::Orders[].

Unit::OrderFlush

A flag, which tells the unit to stop with the current order and immediately start with the next order.

Unit::Orders

Contains all orders of the unit. Slot 0 is always used. Up to MAX_ORDERS can be stored.

Unit::SavedOrder

This order is executed, if the current order is finished. This is used for attacking units, to return to the old place or for patrolling units to return to patrol after killing some enemies. Any new order given to the unit, clears this saved order.

Unit::NewOrder

This field is only used by buildings and this order is assigned to any by this building new trained unit. This is can be used to set the exit or gathering point of a building.

Unit::Data

FIXME: continue documentation

Unit::Goal

Generic goal pointer. Used by teleporters to point to circle of power.

Unit::Retreating

FIXME: continue documentation

Definition at line 471 of file unit.h.


Public Attributes

unsigned Active: 1
 Unit seen destroyed or not.
unsigned Attacked: 4
 angle (0-255) unit looking
struct _spell_type_AutoCastSpell
 order for new trained units
unsigned Blink: 3
 can process new command
int Bloodlust
 time to life
unsigned Burning: 1
 unit is attacked
UnitColors Colors
 Current unit stats.
unsigned Constructed: 1
 Unit is visible (submarine).
union _unit_::_order_data_ Data
 spell to auto cast
unsigned Destroyed: 1
 unit is burning
unsigned Direction: 8
 seen Y image displacement to map position
int FlameShield
 ticks invisible
int Frame
 Y image displacement to map position.
UnitGoal
 Storage room for different commands.
int GroupId
 ticks unholy armor
int Haste
 ticks bloodlust
int HP
 mana points
int Invisible
 ticks slow (disables haste)
signed char IX
 Player colors.
signed char IY
 X image displacement to map position.
int Kills
 experience points
int LastGroup
 unit belongs to this group id
unsigned Mana: 8
unsigned Moving: 1
 Let selection rectangle blink.
char * Name
 Generic link pointer (on map).
Order NewOrder
 order to continue after current
UnitNext
 Slot pointer of Player->Units.
UnitOnBoard [MAX_UNITS_ONBOARD]
char OrderCount
char OrderFlush
 how many orders in queue
Order Orders [MAX_ORDERS]
 cancel current order, take next
PlayerPlayer
 Pointer to last seen unit-type.
Unit ** PlayerSlot
 Slot pointer of Units.
int Refs
unsigned Removed: 1
 unit is destroyed pending reference
unsigned Rescued: 1
 Unit is active for AI.
unsigned Reset: 1
unsigned Revealer: 1
unsigned Rs: 8
 The unit is moving.
Order SavedOrder
 orders to process
unsigned SeenConstructed: 1
 Unit is in construction.
unsigned SeenDestroyed: 1
 Unit seen build/upgrade state.
int SeenFrame
 Image frame: <0 is mirrored.
signed char SeenIX
 last seen frame/stage of buildings
signed char SeenIY
 Seen X image displacement to map position.
unsigned SeenState: 3
 Unit seen construction.
UnitTypeSeenType
 Pointer to unit-type (peon,...).
unsigned Selected: 1
 unit is removed (not on map)
int Slot
 Reference counter.
int Slow
 ticks haste (disables slow)
unsigned State: 8
UnitStatsStats
 Owner of this unit.
unsigned SubAction: 8
 value used for much
unsigned long TTL
 how many unit has this unit killed
UnitTypeType
 Map position Y.
int UnholyArmor
 ticks flame shield
Unit ** UnitSlot
 Assigned slot number.
int Value
 unit belongs to this last group
unsigned Visible: 16
 unit is selected
unsigned Wait: 8
 sub-action of unit
int X
 Unit own name.
int XP
 hit points
int Y
 Map position X.

Classes

union  _order_data_
 spell to auto cast More...

The documentation for this struct was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index