$treeview $search $mathjax
Stratagus
2.2.7
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include <player.h>
Public Member Functions | |
void | SetStartView (const Vec2i &pos) |
map tile start position | |
void void bool | IsEnemy (const int index) const |
player.cpp - The players. | |
void | SetName (const std::string &name) |
Timer for the upgrades. | |
void | Clear () |
Clear turn related player data. | |
std::vector< CUnit * > ::const_iterator | UnitBegin () const |
std::vector< CUnit * >::iterator | UnitBegin () |
std::vector< CUnit * > ::const_iterator | UnitEnd () const |
std::vector< CUnit * >::iterator | UnitEnd () |
CUnit & | GetUnit (int index) const |
int | GetUnitCount () const |
void | AddUnit (CUnit &unit) |
void | RemoveUnit (CUnit &unit) |
int | GetResource (const int resource, const int type) |
Get a resource of the player. | |
void | ChangeResource (const int resource, const int value, const bool store=false) |
Adds/subtracts some resources to/from the player store. | |
void | SetResource (const int resource, const int value, const int type=STORE_OVERALL) |
Set a resource of the player. | |
bool | CheckResource (const int resource, const int value) |
Check, if there enough resources for action. | |
int | CheckLimits (const CUnitType &type) const |
Check if the unit-type didn't break any unit limits and supply/demand. | |
int | CheckCosts (const int *costs) const |
Check if enough resources are available for costs. | |
int | CheckUnitType (const CUnitType &type) const |
Check if enough resources are available for a new unit-type. | |
void | AddCosts (const int *costs) |
Add costs to the resources. | |
void | AddUnitType (const CUnitType &type) |
Add costs for an unit-type to the resources. | |
void | AddCostsFactor (const int *costs, int factor) |
Add a factor of costs to the resources. | |
void | SubCosts (const int *costs) |
Remove costs from the resources. | |
void | SubUnitType (const CUnitType &type) |
Remove costs for an unit-type from the resources. | |
void | SubCostsFactor (const int *costs, int factor) |
Remove a factor of costs from the resources. | |
int | HaveUnitTypeByType (const CUnitType &type) const |
Does the player have units of that type. | |
int | HaveUnitTypeByIdent (const std::string &ident) const |
Does the player have units of that type. | |
void | Notify (int type, const Vec2i &pos, const char *fmt,...) const PRINTF_VAARG_ATTRIBUTE(4 |
Notify player about a problem. | |
void void | Notify (const char *fmt,...) const PRINTF_VAARG_ATTRIBUTE(2 |
Notify player about a problem. | |
bool | IsEnemy (const CPlayer &player) const |
bool | IsEnemy (const CUnit &unit) const |
bool | IsAllied (const CPlayer &player) const |
bool | IsAllied (const CUnit &unit) const |
bool | IsVisionSharing () const |
bool | IsSharedVision (const CPlayer &player) const |
bool | IsSharedVision (const CUnit &unit) const |
bool | IsBothSharedVision (const CPlayer &player) const |
bool | IsBothSharedVision (const CUnit &unit) const |
bool | IsTeamed (const CPlayer &player) const |
bool | IsTeamed (const CUnit &unit) const |
void | SetDiplomacyNeutralWith (const CPlayer &player) |
void | SetDiplomacyAlliedWith (const CPlayer &player) |
void | SetDiplomacyEnemyWith (const CPlayer &player) |
void | SetDiplomacyCrazyWith (const CPlayer &player) |
void | ShareVisionWith (const CPlayer &player) |
void | UnshareVisionWith (const CPlayer &player) |
void | Init (int type) |
void | Save (CFile &file) const |
script_player.cpp - The player ccl functions. | |
void | Load (lua_State *l) |
Public Attributes | |
int | Index |
std::string | Name |
player as number | |
int | Type |
name of non computer | |
int | Race |
type of player (human,computer,...) | |
std::string | AiName |
race of player (orc,human,...) | |
int | Team |
AI for computer. | |
Vec2i | StartPos |
team of player | |
int | Resources [MaxCosts] |
int | MaxResources [MaxCosts] |
resources in overall store | |
int | StoredResources [MaxCosts] |
max resources can be stored | |
int | LastResources [MaxCosts] |
resources in store buildings (can't exceed MaxResources) | |
int | Incomes [MaxCosts] |
last values for revenue | |
int | Revenue [MaxCosts] |
income of the resources | |
int | SpeedResourcesHarvest [MaxCosts] |
income rate of the resources | |
int | SpeedResourcesReturn [MaxCosts] |
speed factor for harvesting resources | |
int | SpeedBuild |
speed factor for returning resources | |
int | SpeedTrain |
speed factor for building | |
int | SpeedUpgrade |
speed factor for training | |
int | SpeedResearch |
speed factor for upgrading | |
int | UnitTypesCount [UnitTypeMax] |
speed factor for researching | |
bool | AiEnabled |
total units of unit-type | |
PlayerAi * | Ai |
handle AI on local computer | |
int | NumBuildings |
Ai structure pointer. | |
int | Supply |
# buildings | |
int | Demand |
supply available/produced | |
int | UnitLimit |
demand of player | |
int | BuildingLimit |
# food units allowed | |
int | TotalUnitLimit |
# buildings allowed | |
int | Score |
# total unit number allowed | |
int | TotalUnits |
Points for killing ... | |
int | TotalBuildings |
int | TotalResources [MaxCosts] |
int | TotalRazings |
int | TotalKills |
Uint32 | Color |
How many unit killed. | |
CUnitColors | UnitColors |
color of units on minimap | |
CAllow | Allow |
Unit colors for new units. | |
CUpgradeTimers | UpgradeTimers |
Allowed for player. |
Player structure
#include "player.h"
This structure contains all informations about a player in game.
The player structure members:
CPlayer::Player
This is the unique slot number. It is not possible that two players have the same slot number at the same time. The slot numbers are reused in the future. This means if a player is defeated, a new player can join using this slot. Currently PlayerMax (16) players are supported. This member is used to access bit fields. Slot PlayerNumNeutral (15) is reserved for the neutral units like gold-mines or critters.
Name of the player used for displays and network game. It is restricted to 15 characters plus final zero.
Type of the player. This field is setup from the level (map). We support currently PlayerNeutral, PlayerNobody, PlayerComputer, PlayerPerson, PlayerRescuePassive and PlayerRescueActive.
Name of the race to which the player belongs, used to select the user interface and the AI. We have 'orc', 'human', 'alliance' or 'mythical'. Should only be used during configuration and not during runtime.
Race number of the player. This field is setup from the level map. This number is mapped with PlayerRaces to the symbolic name CPlayer::RaceName.
AI name for computer. This field is setup from the map. Used to select the AI for the computer player.
Team of player. Selected during network game setup. All players of the same team are allied and enemy to all other teams.
A bit field which contains the enemies of this player. If CPlayer::Enemy & (1<<CPlayer::Player) != 0 its an enemy. Setup during startup using the CPlayer::Team, can later be changed with diplomacy. CPlayer::Enemy and CPlayer::Allied are combined, if none bit is set, the player is neutral.
A bit field which contains the allies of this player. If CPlayer::Allied & (1<<CPlayer::Player) != 0 its an allied. Setup during startup using the Player:Team, can later be changed with diplomacy. CPlayer::Enemy and CPlayer::Allied are combined, if none bit is set, the player is neutral.
A bit field which contains shared vision for this player. Shared vision only works when it's activated both ways. Really.
CPlayer::StartX CPlayer::StartY
The tile map coordinates of the player start position. 0,0 is the upper left on the map. This members are setup from the map and only important for the game start. Ignored if game starts with level settings. Used to place the initial workers if you play with 1 or 3 workers.
How many resources the player owns. Needed for building units and structures.
CPlayer::MaxResources[MaxCosts]How many resources the player can store at the moment.
Income of the resources, when they are delivered at a store.
CPlayer::LastResources[MaxCosts]Keeps track of resources in time (used for calculating CPlayer::Revenue, see below)
Production of resources per minute (or estimates) Used just as information (statistics) for the player...
CPlayer::UnitTypesCount[UnitTypeMax]
Total count for each different unit type. Used by the AI and for dependencies checks. The addition of all counts should be CPlayer::TotalNumUnits.
If the player is controlled by the computer and this flag is true, than the player is handled by the AI on this local computer.
AI structure pointer. Please look at PlayerAi for more informations.
CPlayer::Units
A table of all (CPlayer::TotalNumUnits) units of the player.
CPlayer::TotalNumUnits
Total number of units (incl. buildings) in the CPlayer::Units table.
Total unit demand, used to demand limit. A player can only build up to CPlayer::Food units and not more than CPlayer::FoodUnitLimit units.
Total number buildings, units that don't need food.
CPlayer::Food
Number of food available/produced. Player can't train more CPlayer::NumFoodUnits than this.
Number of food units allowed. Player can't train more CPlayer::NumFoodUnits than this.
Number of buildings allowed. Player can't build more CPlayer::NumBuildings than this.
Number of total units allowed. Player can't have more CPlayer::NumFoodUnits+CPlayerNumBuildings=CPlayerTotalNumUnits this.
Total number of points. You can get points for killing units, destroying buildings ...
Total number of units made.
Total number of buildings made.
CPlayer::TotalResources[MaxCosts]
Total number of resources collected.
CPlayer::TotalRazingsTotal number of buildings destroyed.
Total number of kills.
Color of units of this player on the minimap. Index number into the global palette.
Unit colors of this player. Contains the hardware dependent pixel values for the player colors (palette index #208-#211). Setup from the global palette.
Contains which unit-types and upgrades are allowed for the player. Possible values are:
void CPlayer::SetStartView | ( | const Vec2i & | pos | ) | [inline] |
map tile start position
void CPlayer::SetName | ( | const std::string & | name | ) |
Timer for the upgrades.
Change player name
Change player name.
name | New name. |
void CPlayer::Clear | ( | ) |
Clear turn related player data.
Clear all player data excepts members which don't change.
The fields that are not cleared are UnitLimit, BuildingLimit, TotalUnitLimit and Allow.
std::vector< CUnit * >::const_iterator CPlayer::UnitBegin | ( | ) | const |
std::vector< CUnit * >::iterator CPlayer::UnitBegin | ( | ) |
std::vector< CUnit * >::const_iterator CPlayer::UnitEnd | ( | ) | const |
std::vector< CUnit * >::iterator CPlayer::UnitEnd | ( | ) |
CUnit & CPlayer::GetUnit | ( | int | index | ) | const |
int CPlayer::GetUnitCount | ( | ) | const |
void CPlayer::AddUnit | ( | CUnit & | unit | ) |
void CPlayer::RemoveUnit | ( | CUnit & | unit | ) |
int CPlayer::GetResource | ( | const int | resource, | |
const int | type | |||
) |
Get a resource of the player.
Gets the player resource.
resource | Resource to get. | |
type | Storing type |
void CPlayer::ChangeResource | ( | const int | resource, | |
const int | value, | |||
const bool | store = false | |||
) |
Adds/subtracts some resources to/from the player store.
Adds/subtracts some resources to/from the player store
resource | Resource to add/subtract. | |
value | How many of this resource (can be negative). | |
store | If true, sets the building store resources, else the overall resources. |
void CPlayer::SetResource | ( | const int | resource, | |
const int | value, | |||
const int | type = STORE_OVERALL | |||
) |
Set a resource of the player.
Change the player resource.
resource | Resource to change. | |
value | How many of this resource. | |
type | Resource types: 0 - overall store, 1 - store buildings, 2 - both |
bool CPlayer::CheckResource | ( | const int | resource, | |
const int | value | |||
) |
Check, if there enough resources for action.
Check, if there enough resources for action.
resource | Resource to change. | |
value | How many of this resource. |
int CPlayer::CheckLimits | ( | const CUnitType & | type | ) | const |
Check if the unit-type didn't break any unit limits and supply/demand.
Check if the unit-type didn't break any unit limits.
type | Type of unit. |
int CPlayer::CheckCosts | ( | const int * | costs | ) | const |
Check if enough resources are available for costs.
Check if enough resources for are available.
costs | How many costs. |
int CPlayer::CheckUnitType | ( | const CUnitType & | type | ) | const |
Check if enough resources are available for a new unit-type.
Check if enough resources for new unit is available.
type | Type of unit. |
void CPlayer::AddCosts | ( | const int * | costs | ) |
Add costs to the resources.
Add costs to the resources
costs | How many costs. |
void CPlayer::AddUnitType | ( | const CUnitType & | type | ) |
Add costs for an unit-type to the resources.
Add the costs of an unit type to resources
type | Type of unit. |
void CPlayer::AddCostsFactor | ( | const int * | costs, | |
int | factor | |||
) |
Add a factor of costs to the resources.
Add a factor of costs to the resources
costs | How many costs. | |
factor | Factor of the costs to apply. |
void CPlayer::SubCosts | ( | const int * | costs | ) |
Remove costs from the resources.
Subtract costs from the resources
costs | How many costs. |
void CPlayer::SubUnitType | ( | const CUnitType & | type | ) |
Remove costs for an unit-type from the resources.
Substract the costs of new unit from resources
type | Type of unit. |
void CPlayer::SubCostsFactor | ( | const int * | costs, | |
int | factor | |||
) |
Remove a factor of costs from the resources.
Substract a factor of costs from the resources
costs | How many costs. | |
factor | Factor of the costs to apply. |
int CPlayer::HaveUnitTypeByType | ( | const CUnitType & | type | ) | const |
Does the player have units of that type.
Have unit of type.
type | Type of unit. |
int CPlayer::HaveUnitTypeByIdent | ( | const std::string & | ident | ) | const |
Does the player have units of that type.
Have unit of type.
ident | Identifier of unit-type that should be lookuped. |
void CPlayer::Notify | ( | int | type, | |
const Vec2i & | pos, | |||
const char * | fmt, | |||
... | ||||
) | const |
Notify player about a problem.
Notify player about a problem.
type | Problem type | |
pos | Map tile position | |
fmt | Message format | |
... | Message varargs |
void CPlayer::Notify | ( | const char * | fmt, | |
... | ||||
) | const |
Notify player about a problem.
Notify player about a problem.
type | Problem type | |
pos | Map tile position | |
fmt | Message format | |
... | Message varargs |
void void bool CPlayer::IsEnemy | ( | const int | index | ) | const [inline] |
Check if the player index is an enemy
bool CPlayer::IsEnemy | ( | const CPlayer & | player | ) | const |
Check if the player is an enemy
bool CPlayer::IsEnemy | ( | const CUnit & | unit | ) | const |
Check if the unit is an enemy
bool CPlayer::IsAllied | ( | const CPlayer & | player | ) | const |
Check if the player is an ally
bool CPlayer::IsAllied | ( | const CUnit & | unit | ) | const |
Check if the unit is an ally
bool CPlayer::IsVisionSharing | ( | ) | const |
bool CPlayer::IsSharedVision | ( | const CPlayer & | player | ) | const |
Check if the player shares vision with the player
bool CPlayer::IsSharedVision | ( | const CUnit & | unit | ) | const |
Check if the player shares vision with the unit
bool CPlayer::IsBothSharedVision | ( | const CPlayer & | player | ) | const |
Check if the both players share vision
bool CPlayer::IsBothSharedVision | ( | const CUnit & | unit | ) | const |
Check if the player and the unit share vision
bool CPlayer::IsTeamed | ( | const CPlayer & | player | ) | const |
Check if the player is teamed
bool CPlayer::IsTeamed | ( | const CUnit & | unit | ) | const |
Check if the unit is teamed
void CPlayer::SetDiplomacyNeutralWith | ( | const CPlayer & | player | ) |
void CPlayer::SetDiplomacyAlliedWith | ( | const CPlayer & | player | ) |
void CPlayer::SetDiplomacyEnemyWith | ( | const CPlayer & | player | ) |
void CPlayer::SetDiplomacyCrazyWith | ( | const CPlayer & | player | ) |
void CPlayer::ShareVisionWith | ( | const CPlayer & | player | ) |
void CPlayer::UnshareVisionWith | ( | const CPlayer & | player | ) |
void CPlayer::Init | ( | int | type | ) |
void CPlayer::Save | ( | CFile & | file | ) | const |
void CPlayer::Load | ( | lua_State * | l | ) |
int CPlayer::Index |
std::string CPlayer::Name |
player as number
int CPlayer::Type |
name of non computer
int CPlayer::Race |
type of player (human,computer,...)
std::string CPlayer::AiName |
race of player (orc,human,...)
int CPlayer::Team |
AI for computer.
team of player
int CPlayer::Resources[MaxCosts] |
int CPlayer::MaxResources[MaxCosts] |
resources in overall store
int CPlayer::StoredResources[MaxCosts] |
max resources can be stored
int CPlayer::LastResources[MaxCosts] |
resources in store buildings (can't exceed MaxResources)
int CPlayer::Incomes[MaxCosts] |
last values for revenue
int CPlayer::Revenue[MaxCosts] |
income of the resources
int CPlayer::SpeedResourcesHarvest[MaxCosts] |
income rate of the resources
int CPlayer::SpeedResourcesReturn[MaxCosts] |
speed factor for harvesting resources
speed factor for returning resources
speed factor for building
speed factor for training
speed factor for upgrading
int CPlayer::UnitTypesCount[UnitTypeMax] |
speed factor for researching
bool CPlayer::AiEnabled |
total units of unit-type
handle AI on local computer
Ai structure pointer.
int CPlayer::Supply |
# buildings
int CPlayer::Demand |
supply available/produced
demand of player
# food units allowed
# buildings allowed
int CPlayer::Score |
# total unit number allowed
Points for killing ...
int CPlayer::TotalResources[MaxCosts] |
Uint32 CPlayer::Color |
How many unit killed.
color of units on minimap
Unit colors for new units.
Allowed for player.