_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
Diplomacy states for CommandDiplomacy. More...
#include <player.h>
Public Member Functions | |
void | SetStartView (const Vec2i &pos) |
map tile start position More... | |
std::vector< CUnit * >::iterator | UnitBegin () |
std::vector< CUnit * >::iterator | UnitEnd () |
const std::vector< CUnit * > & | GetUnits () const |
std::vector< CUnit * >::iterator | FreeWorkersBegin () |
std::vector< CUnit * >::iterator | FreeWorkersEnd () |
void void bool | IsEnemy (const int index) const |
bool | IsAllied (const int index) const |
const std::set< uint8_t > & | GetSharedVision () const |
const std::set< uint8_t > & | GetGaveVisionTo () const |
bool | HasSharedVisionWith (const CPlayer &player) const |
bool | IsRevealed () const |
script_player.cpp - The player ccl functions. | |
void | Load (lua_State *l) |
Static Public Member Functions | |
static const bool | IsRevelationEnabled () |
type of revelation (when player lost their last main facility) More... | |
static const std::vector< const CPlayer * > & | GetRevealedPlayers () |
Get revealed players list. More... | |
Public Attributes | |
int | Index |
std::string | Name |
player as number More... | |
PlayerTypes | Type |
name of non computer More... | |
int | Race |
type of player (human,computer,...) More... | |
std::string | AiName |
race of player (orc,human,...) More... | |
int | Team |
AI for computer. More... | |
Vec2i | StartPos |
team of player More... | |
int | Resources [MaxCosts] |
int | MaxResources [MaxCosts] |
resources in overall store More... | |
int | StoredResources [MaxCosts] |
max resources can be stored More... | |
int | LastResources [MaxCosts] |
resources in store buildings (can't exceed MaxResources) More... | |
int | Incomes [MaxCosts] |
last values for revenue More... | |
int | Revenue [MaxCosts] |
income of the resources More... | |
int | SpeedResourcesHarvest [MaxCosts] |
income rate of the resources More... | |
int | SpeedResourcesReturn [MaxCosts] |
speed factor for harvesting resources More... | |
int | SpeedBuild |
speed factor for returning resources More... | |
int | SpeedTrain |
speed factor for building More... | |
int | SpeedUpgrade |
speed factor for training More... | |
int | SpeedResearch |
speed factor for upgrading More... | |
int | UnitTypesCount [UnitTypeMax] |
speed factor for researching More... | |
int | UnitTypesAiActiveCount [UnitTypeMax] |
total units of unit-type More... | |
bool | AiEnabled |
total units of unit-type that have their AI set to active More... | |
PlayerAi * | Ai |
handle AI on local computer More... | |
int | NumBuildings |
Ai structure pointer. More... | |
int | Supply |
int | Demand |
supply available/produced More... | |
int | UnitLimit |
demand of player More... | |
int | BuildingLimit |
int | TotalUnitLimit |
int | Score |
int | TotalUnits |
Points for killing ... More... | |
int | TotalBuildings |
int | TotalResources [MaxCosts] |
int | TotalRazings |
int | TotalKills |
int | LostMainFacilityTimer { 0 } |
How many unit killed. More... | |
IntColor | Color |
(to make the player's units be revealed) More... | |
CAllow | Allow |
color of units on minimap More... | |
CUpgradeTimers | UpgradeTimers |
Allowed for player. More... | |
Static Public Attributes | |
static RevealTypes | RevelationFor { RevealTypes::cNoRevelation } |
Friends | |
void | CleanPlayers () |
whether the player has been revealed (i.e. after losing the last Town Hall) More... | |
player.cpp - The players. | |
static void | SetRevelationType (const RevealTypes type) |
Change revelation type. More... | |
void | SetName (const std::string &name) |
Timer for the upgrades. More... | |
void | Clear () |
Clear turn related player data. More... | |
std::vector< CUnit * >::const_iterator | UnitBegin () const |
std::vector< CUnit * >::const_iterator | UnitEnd () const |
CUnit & | GetUnit (int index) const |
int | GetUnitCount () const |
void | AddUnit (CUnit &unit) |
void | RemoveUnit (CUnit &unit) |
std::vector< CUnit * >::const_iterator | FreeWorkersBegin () const |
std::vector< CUnit * >::const_iterator | FreeWorkersEnd () const |
CUnit * | GetFreeWorker (int index) const |
int | GetFreeWorkersCount () const |
void | UpdateFreeWorkers () |
void | ClearUnitColors () |
void | SetUnitColors (std::vector< CColor > &colors) |
int | GetResource (const int resource, const int type) |
Get a resource of the player. More... | |
void | ChangeResource (const int resource, const int value, const bool store=false) |
Adds/subtracts some resources to/from the player store. More... | |
void | SetResource (const int resource, const int value, const int type=STORE_OVERALL) |
Set a resource of the player. More... | |
bool | CheckResource (const int resource, const int value) |
Check, if there enough resources for action. More... | |
int | GetUnitTotalCount (const CUnitType &type) const |
Returns count of specified unittype. More... | |
int | CheckLimits (const CUnitType &type) const |
Check if the unit-type didn't break any unit limits and supply/demand. More... | |
int | CheckCosts (const int *costs, bool notify=true) const |
Check if enough resources are available for costs. More... | |
int | CheckUnitType (const CUnitType &type) const |
Check if enough resources are available for a new unit-type. More... | |
void | AddCosts (const int *costs) |
Add costs to the resources. More... | |
void | AddUnitType (const CUnitType &type) |
Add costs for an unit-type to the resources. More... | |
void | AddCostsFactor (const int *costs, int factor) |
Add a factor of costs to the resources. More... | |
void | SubCosts (const int *costs) |
Remove costs from the resources. More... | |
void | SubUnitType (const CUnitType &type) |
Remove costs for an unit-type from the resources. More... | |
void | SubCostsFactor (const int *costs, int factor) |
Remove a factor of costs from the resources. More... | |
int | HaveUnitTypeByType (const CUnitType &type) const |
Does the player have units of that type. More... | |
int | HaveUnitTypeByIdent (const std::string &ident) const |
Does the player have units of that type. More... | |
void | Notify (int type, const Vec2i &pos, const char *fmt,...) const PRINTF_VAARG_ATTRIBUTE(4 |
Notify player about a problem. More... | |
void void | Notify (const char *fmt,...) const PRINTF_VAARG_ATTRIBUTE(2 |
Notify player about a problem. More... | |
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 | 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 (CPlayer &player) |
void | EnableSharedVisionFrom (const CPlayer &player) |
void | UnshareVisionWith (CPlayer &player) |
void | DisableSharedVisionFrom (const CPlayer &player) |
void | Init (PlayerTypes type) |
void | Save (CFile &file) const |
void | SetRevealed (const bool revealed) |
Diplomacy states for CommandDiplomacy.
Player structure
#include "player.h"
This structure contains all information 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.
CPlayer::RaceName
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.
CPlayer::Enemy
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.
CPlayer::Allied
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.
CPlayer::SharedVision
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 information.
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.
CPlayer::FoodUnitLimit
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+CPlayer::NumBuildings=CPlayer::TotalNumUnits 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.
Total number of buildings destroyed.
Total number of kills.
Color of units of this player on the minimap. Index number into the global palette.
CPlayer::UnitColors
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:
Timer for the upgrades. One timer for all possible upgrades. Initial 0 counted up by the upgrade action, until it reaches the upgrade time.
void CPlayer::AddCosts | ( | const int * | costs | ) |
Add costs to the resources.
Add costs to the resources
costs | How many costs. |
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. |
Add costs for an unit-type to the resources.
Add the costs of an unit type to resources
type | Type of unit. |
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. |
int CPlayer::CheckCosts | ( | const int * | costs, |
bool | notify = true |
||
) | const |
Check if enough resources are available for costs.
Check if enough resources for are available.
costs | How many costs. |
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. |
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::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::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.
void CPlayer::ClearUnitColors | ( | ) |
std::vector<CUnit *>::iterator CPlayer::FreeWorkersBegin | ( | ) |
std::vector< CUnit * >::iterator CPlayer::FreeWorkersBegin | ( | ) | const |
std::vector<CUnit *>::iterator CPlayer::FreeWorkersEnd | ( | ) |
std::vector< CUnit * >::iterator CPlayer::FreeWorkersEnd | ( | ) | const |
CUnit * CPlayer::GetFreeWorker | ( | int | index | ) | const |
int CPlayer::GetFreeWorkersCount | ( | ) | const |
|
inline |
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 |
|
inlinestatic |
Get revealed players list.
|
inline |
CUnit & CPlayer::GetUnit | ( | int | index | ) | const |
int CPlayer::GetUnitCount | ( | ) | const |
|
inline |
int CPlayer::GetUnitTotalCount | ( | const CUnitType & | type | ) | const |
Returns count of specified unittype.
|
inline |
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. |
int CPlayer::HaveUnitTypeByType | ( | const CUnitType & | type | ) | const |
Does the player have units of that type.
Have unit of type.
type | Type of unit. |
void CPlayer::Init | ( | PlayerTypes | type | ) |
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
|
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
Check if the player index is an enemy
|
inline |
|
inlinestatic |
type of revelation (when player lost their last main facility)
Check if relevation enabled
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
bool CPlayer::IsVisionSharing | ( | ) | const |
void CPlayer::Load | ( | lua_State * | l | ) |
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 |
Notify player about a problem.
Notify player about a problem.
type | Problem type |
pos | Map tile position |
fmt | Message format |
... | Message varargs |
void CPlayer::SetName | ( | const std::string & | name | ) |
Timer for the upgrades.
Change player name
Change player name.
name | New name. |
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 |
void CPlayer::SetRevealed | ( | const bool | revealed | ) |
Add/remove players to/from list of revealed players
Remove element from vector;
|
static |
Change revelation type.
Change revelation type
void CPlayer::SubCosts | ( | const int * | costs | ) |
Remove costs from the resources.
Subtract costs from the resources
costs | How many costs. |
void CPlayer::SubCostsFactor | ( | const int * | costs, |
int | factor | ||
) |
Remove a factor of costs from the resources.
Subtract a factor of costs from the resources
costs | How many costs. |
factor | Factor of the costs to apply. |
Remove costs for an unit-type from the resources.
Subtract the costs of new unit from resources
type | Type of unit. |
std::vector<CUnit *>::iterator CPlayer::UnitBegin | ( | ) |
std::vector< CUnit * >::iterator CPlayer::UnitBegin | ( | ) | const |
std::vector<CUnit *>::iterator CPlayer::UnitEnd | ( | ) |
std::vector< CUnit * >::iterator CPlayer::UnitEnd | ( | ) | const |
void CPlayer::UpdateFreeWorkers | ( | ) |
|
friend |
whether the player has been revealed (i.e. after losing the last Town Hall)
Clean up players.
PlayerAi* CPlayer::Ai |
handle AI on local computer
bool CPlayer::AiEnabled |
total units of unit-type that have their AI set to active
std::string CPlayer::AiName |
race of player (orc,human,...)
CAllow CPlayer::Allow |
color of units on minimap
IntColor CPlayer::Color |
(to make the player's units be revealed)
The timer for when the player lost the last town hall
int CPlayer::Demand |
supply available/produced
int CPlayer::Incomes[MaxCosts] |
last values for revenue
int CPlayer::Index |
int CPlayer::LastResources[MaxCosts] |
resources in store buildings (can't exceed MaxResources)
int CPlayer::LostMainFacilityTimer { 0 } |
How many unit killed.
int CPlayer::MaxResources[MaxCosts] |
resources in overall store
std::string CPlayer::Name |
player as number
int CPlayer::NumBuildings |
Ai structure pointer.
int CPlayer::Race |
type of player (human,computer,...)
int CPlayer::Resources[MaxCosts] |
|
inlinestatic |
int CPlayer::Revenue[MaxCosts] |
income of the resources
int CPlayer::SpeedBuild |
speed factor for returning resources
int CPlayer::SpeedResearch |
speed factor for upgrading
int CPlayer::SpeedResourcesHarvest[MaxCosts] |
income rate of the resources
int CPlayer::SpeedResourcesReturn[MaxCosts] |
speed factor for harvesting resources
int CPlayer::SpeedTrain |
speed factor for building
int CPlayer::SpeedUpgrade |
speed factor for training
Vec2i CPlayer::StartPos |
team of player
int CPlayer::StoredResources[MaxCosts] |
max resources can be stored
int CPlayer::Team |
AI for computer.
int CPlayer::TotalBuildings |
int CPlayer::TotalKills |
int CPlayer::TotalRazings |
int CPlayer::TotalResources[MaxCosts] |
int CPlayer::TotalUnits |
Points for killing ...
PlayerTypes CPlayer::Type |
name of non computer
int CPlayer::UnitLimit |
demand of player
int CPlayer::UnitTypesAiActiveCount[UnitTypeMax] |
total units of unit-type
int CPlayer::UnitTypesCount[UnitTypeMax] |
speed factor for researching
CUpgradeTimers CPlayer::UpgradeTimers |
Allowed for player.