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

src/unit/unittype.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "stratagus.h"
#include <string>
#include <map>
#include "video.h"
#include "tileset.h"
#include "map.h"
#include "sound.h"
#include "unitsound.h"
#include "construct.h"
#include "unittype.h"
#include "animation.h"
#include "player.h"
#include "missile.h"
#include "script.h"
#include "spells.h"
#include "iolib.h"
#include "luacallback.h"
#include "util.h"

unittype.cpp - The unit types.

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

Function Documentation

void CleanUnitTypes (  ) 

Load the unit-type data.

Cleanup the unit-type module.

void DrawUnitType ( const CUnitType type,
CPlayerColorGraphic sprite,
int  player,
int  frame,
int  x,
int  y 
)

Draw the sprite frame of unit-type.

Draw unit-type on map.

Parameters:
type Unit-type pointer.
sprite Sprite to use for drawing
player Player number for color substitution.
frame Animation frame of unit-type.
x Screen X pixel postion to draw unit-type.
y Screen Y pixel postion to draw unit-type.
Todo:
Do screen position caculation in high level. Better way to handle in x mirrored sprites.

void FreeAnimations (  ) 

static int GetStillFrame ( CUnitType type  )  [static]

Get the still animation frame

void InitUnitTypes ( int  reset_player_stats  ) 

Init unit types.

void LoadUnitTypes (  ) 

Load the sprite for a unittype.

Load the graphics for the unit-types.

void LoadUnitTypeSprite ( CUnitType type  ) 

Init unit-type table.

Loads the Sprite for a unit type

Parameters:
type type of unit to load

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

Save the unit-type table.

Allocate an empty unit-type slot.

Parameters:
ident Identifier to identify the slot (malloced by caller!).
Returns:
New allocated (zeroed) unit-type pointer.

static void SaveUnitStats ( const CUnitStats stats,
const std::string &  ident,
int  plynr,
CFile file 
) [static]

Save state of an unit-stats to file.

Parameters:
stats Unit-stats to save.
ident Unit-type ident.
plynr Player number.
file Output file.

void SaveUnitTypes ( CFile file  ) 

Get unit-type by ident.

Save state of the unit-type table to file.

Parameters:
file Output file.

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

Update unit stats.

Find unit-type by identifier.

Parameters:
ident The unit-type identifier.
Returns:
Unit-type pointer.

void UpdateStats ( int  reset  ) 

Register ccl features.

Update the player stats for changed unit types.

Parameters:
reset indicates wether default value should be set to each stat (level, upgrades)


Variable Documentation

std::string DefaultActions[MaxCosts]

Default action for the resources.

int DefaultIncomes[MaxCosts]

Orc wall.

Default incomes for a new player.

int DefaultResourceAmounts[MaxCosts]

Default amounts for the resources.

std::string DefaultResourceNames[MaxCosts]

Default names for the resources.

std::string ExtraDeathTypes[ANIMATIONS_DEATHTYPES]

Default names for the resources.

All unit-types.

Next unit type are used hardcoded in the source.

Todo:
find a way to make it configurable!

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

unit-types definition

Human wall.

std::vector<CUnitType *> UnitTypes

(C) Copyright 1998-2011 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.