$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
#include <player.h>
Public Member Functions | |
void | SetStartView (int x, int y) |
map tile start Y position | |
bool | IsEnemy (const int index) const |
player.cpp - The players. | |
void | SetSide (int side) |
Current know autoattack targets. | |
void | SetName (const std::string &name) |
Change player name. | |
void | Clear () |
Clear turn related player data. | |
void | SetResource (int resource, int value) |
Set a resource of the player. | |
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, int x, int y, const char *fmt,...) const |
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 | 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 |
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. | |
unsigned int | Enemy |
team of player | |
unsigned int | Allied |
enemy bit field for this player | |
unsigned int | SharedVision |
allied bit field for this player | |
int | StartX |
shared vision bit field | |
int | StartY |
map tile start X position | |
int | Resources [MaxCosts] |
int | LastResources [MaxCosts] |
resources in store | |
int | Incomes [MaxCosts] |
last values for revenue | |
int | Revenue [MaxCosts] |
income of the resources | |
int | UnitTypesCount [UnitTypeMax] |
income rate of the resources | |
int | AiEnabled |
total units of unit-type | |
PlayerAi * | Ai |
handle AI on local computer | |
CUnit * | Units [UnitMax] |
Ai structure pointer. | |
int | TotalNumUnits |
units of this player | |
int | NumBuildings |
total # units for units' list | |
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. | |
CUnitCache | AutoAttackTargets |
Timer for the upgrades. |
#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::Incomes[MaxCosts]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.
A table of all (CPlayer::TotalNumUnits) units of the player.
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 | ( | int | x, | |
int | y | |||
) | [inline] |
map tile start Y position
void CPlayer::SetSide | ( | int | side | ) |
Current know autoattack targets.
Change player side
Change player side.
side | New side (Race). |
void CPlayer::SetName | ( | const std::string & | name | ) |
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.
void CPlayer::SetResource | ( | int | resource, | |
int | value | |||
) |
Set a resource of the player.
Change the player resource.
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, | |
int | x, | |||
int | y, | |||
const char * | fmt, | |||
... | ||||
) | const |
Notify player about a problem.
Notify player about a problem.
type | Problem type | |
x | Map X tile position | |
y | Map Y tile position | |
fmt | Message format | |
... | Message varargs |
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::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
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.
unsigned int CPlayer::Enemy |
team of player
unsigned int CPlayer::Allied |
enemy bit field for this player
unsigned int CPlayer::SharedVision |
allied bit field for this player
int CPlayer::StartX |
shared vision bit field
int CPlayer::StartY |
map tile start X position
int CPlayer::Resources[MaxCosts] |
int CPlayer::LastResources[MaxCosts] |
resources in store
int CPlayer::Incomes[MaxCosts] |
last values for revenue
int CPlayer::Revenue[MaxCosts] |
income of the resources
int CPlayer::UnitTypesCount[UnitTypeMax] |
income rate of the resources
total units of unit-type
handle AI on local computer
CUnit* CPlayer::Units[UnitMax] |
Ai structure pointer.
units of this player
total # units for units' list
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.
Timer for the upgrades.