_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

unittype.cpp File Reference
#include "stratagus.h"
#include "unittype.h"
#include "animation.h"
#include "animation/animation_exactframe.h"
#include "animation/animation_frame.h"
#include "construct.h"
#include "iolib.h"
#include "luacallback.h"
#include "map.h"
#include "missile.h"
#include "player.h"
#include "script.h"
#include "sound.h"
#include "spells.h"
#include "tileset.h"
#include "translate.h"
#include "ui.h"
#include "unitsound.h"
#include "util.h"
#include "video.h"
#include <ctype.h>
#include <string>
#include <map>

unittype.cpp - The unit types.

std::vector< CUnitType * > UnitTypes
std::map< std::string, CUnitType * > UnitTypeMap
 unit-types definition More...
 All unit-types. More...
 Human wall. More...
int DefaultIncomes [MaxCosts]
 Orc wall. More...
std::string DefaultActions [MaxCosts]
std::string DefaultResourceNames [MaxCosts]
int DefaultResourceAmounts [MaxCosts]
int DefaultResourceMaxAmounts [MaxCosts]
std::string ExtraDeathTypes [ANIMATIONS_DEATHTYPES]
int GetResourceIdByName (const char *resourceName)
int GetResourceIdByName (lua_State *l, const char *resourceName)
void UpdateUnitStats (CUnitType &type, int reset)
 Register ccl features. More...
void UpdateStats (int reset)
 Update unit stats. More...
static bool SaveUnitStats (const CUnitStats &stats, const CUnitType &type, int plynr, CFile &file)
void SaveUnitTypes (CFile &file)
 Get unit-type by ident. More...
CUnitTypeUnitTypeByIdent (const std::string &ident)
 Update unit stats. More...
CUnitTypeNewUnitTypeSlot (const std::string &ident)
 Save the unit-type table. More...
void DrawUnitType (const CUnitType &type, CPlayerColorGraphic *sprite, int colorIndex, int frame, const PixelPos &screenPos)
 Draw the sprite frame of unit-type. More...
static int GetStillFrame (const CUnitType &type)
void InitUnitTypes (int reset_player_stats)
void LoadUnitTypeSprite (CUnitType &type)
 Init unit-type table. More...
void LoadUnitTypes ()
 Load the sprite for a unittype. More...
void CleanUnitTypes ()
 Load the unit-type data. More...

Function Documentation

◆ CleanUnitTypes()

void CleanUnitTypes ( )

Load the unit-type data.

Cleanup the unit-type module.

◆ DrawUnitType()

void DrawUnitType ( const CUnitType type,
CPlayerColorGraphic sprite,
int  colorIndex,
int  frame,
const PixelPos screenPos 

Draw the sprite frame of unit-type.

Draw unit-type on map.

typeUnit-type pointer.
spriteSprite to use for drawing
playerPlayer number for color substitution.
frameAnimation frame of unit-type.
screenPosScreen pixel (top left) position to draw unit-type.
Do screen position caculation in high level. Better way to handle in x mirrored sprites.

◆ GetResourceIdByName() [1/2]

int GetResourceIdByName ( const char *  resourceName)

◆ GetResourceIdByName() [2/2]

int GetResourceIdByName ( lua_State *  l,
const char *  resourceName 

◆ GetStillFrame()

static int GetStillFrame ( const CUnitType type)

Get the still animation frame

◆ InitUnitTypes()

void InitUnitTypes ( int  reset_player_stats)

Init unit types.

◆ LoadUnitTypes()

void LoadUnitTypes ( )

Load the sprite for a unittype.

Load the graphics for the unit-types.

◆ LoadUnitTypeSprite()

void LoadUnitTypeSprite ( CUnitType type)

Init unit-type table.

Loads the Sprite for a unit type

typetype of unit to load

◆ NewUnitTypeSlot()

CUnitType* NewUnitTypeSlot ( const std::string &  ident)

Save the unit-type table.

Allocate an empty unit-type slot.

identIdentifier to identify the slot (malloced by caller!).
New allocated (zeroed) unit-type pointer.

◆ SaveUnitStats()

static bool SaveUnitStats ( const CUnitStats stats,
const CUnitType type,
int  plynr,
CFile file 

Save state of an unit-stats to file.

statsUnit-stats to save.
identUnit-type ident.
plynrPlayer number.
fileOutput file.

◆ SaveUnitTypes()

void SaveUnitTypes ( CFile file)

Get unit-type by ident.

Save state of the unit-type table to file.

fileOutput file.

◆ UnitTypeByIdent()

CUnitType* UnitTypeByIdent ( const std::string &  ident)

Update unit stats.

Find unit-type by identifier.

identThe unit-type identifier.
Unit-type pointer.

◆ UpdateStats()

void UpdateStats ( int  reset)

Update unit stats.

Update the player stats for changed unit types.

resetindicates wether default value should be set to each stat (level, upgrades)

◆ UpdateUnitStats()

void UpdateUnitStats ( CUnitType type,
int  reset 

Register ccl features.

Variable Documentation

◆ DefaultActions

std::string DefaultActions[MaxCosts]

Default action for the resources.

◆ DefaultIncomes

int DefaultIncomes[MaxCosts]

Orc wall.

Default incomes for a new player.

◆ DefaultResourceAmounts

int DefaultResourceAmounts[MaxCosts]

Default amounts for the resources.

◆ DefaultResourceMaxAmounts

int DefaultResourceMaxAmounts[MaxCosts]

Default max amounts for the resources.

◆ DefaultResourceNames

std::string DefaultResourceNames[MaxCosts]

Default names for the resources.

◆ ExtraDeathTypes

std::string ExtraDeathTypes[ANIMATIONS_DEATHTYPES]

Default names for the resources.

◆ UnitTypeHumanWall

CUnitType* UnitTypeHumanWall

All unit-types.

Next unit type are used hardcoded in the source.

find a way to make it configurable!

◆ UnitTypeMap

std::map<std::string, CUnitType *> UnitTypeMap

unit-types definition

◆ UnitTypeOrcWall

CUnitType* UnitTypeOrcWall

Human wall.

◆ UnitTypes

std::vector<CUnitType *> UnitTypes
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.