_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include <string>
#include <vector>
#include <map>
#include "stratagus.h"
#include "upgrade.h"
#include "action/action_train.h"
#include "commands.h"
#include "depend.h"
#include "interface.h"
#include "iolib.h"
#include "map.h"
#include "player.h"
#include "script.h"
#include "unit.h"
#include "unit_find.h"
#include "unittype.h"
#include "util.h"
upgrade.cpp - The upgrade/allow functions. | |
std::vector< CUpgrade * > | AllUpgrades |
CUpgradeModifier * | UpgradeModifiers [UPGRADE_MODIFIERS_MAX] |
The main user useable upgrades. More... | |
int | NumUpgradeModifiers |
Number of upgrades modifiers used. More... | |
std::map< std::string, CUpgrade * > | Upgrades |
static void | AllowUnitId (CPlayer &player, int id, int units) |
void | InitUpgrades () |
init upgrade/allow structures More... | |
void | CleanUpgrades () |
cleanup upgrade module More... | |
void | SaveUpgrades (CFile &file) |
save the upgrades More... | |
static int | CclDefineModifier (lua_State *l) |
static int | CclDefineUnitAllow (lua_State *l) |
static int | CclDefineAllow (lua_State *l) |
void | UpgradesCclRegister () |
Register CCL features for upgrades. More... | |
int | UnitTypeIdByIdent (const std::string &ident) |
int | UpgradeIdByIdent (const std::string &ident) |
static void | ConvertUnitTypeTo (CPlayer &player, const CUnitType &src, CUnitType &dst) |
static void | ApplyUpgradeModifier (CPlayer &player, const CUpgradeModifier *um) |
static void | RemoveUpgradeModifier (CPlayer &player, const CUpgradeModifier *um) |
void | ApplyIndividualUpgradeModifier (CUnit &unit, const CUpgradeModifier *um) |
static void | RemoveIndividualUpgradeModifier (CUnit &unit, const CUpgradeModifier *um) |
void | UpgradeAcquire (CPlayer &player, const CUpgrade *upgrade) |
Upgrade will be acquired. More... | |
void | UpgradeLost (CPlayer &player, int id) |
Upgrade will be lost. More... | |
void | ApplyUpgrades () |
Apply researched upgrades when map is loading. More... | |
void | IndividualUpgradeAcquire (CUnit &unit, const CUpgrade *upgrade) |
Apply upgrade modifier of an individual upgrade. More... | |
void | IndividualUpgradeLost (CUnit &unit, const CUpgrade *upgrade) |
Make a unit acquire in individual upgrade. More... | |
void | AllowUpgradeId (CPlayer &player, int id, char af) |
int | UnitIdAllowed (const CPlayer &player, int id) |
Make a unit lose in individual upgrade. More... | |
char | UpgradeIdAllowed (const CPlayer &player, int id) |
char | UpgradeIdentAllowed (const CPlayer &player, const std::string &ident) |
Change allow for an unit-type.
player | Player to change |
id | unit type id |
units | maximum amount of units allowed |
Change allow for an upgrade.
player | Player to change |
id | upgrade id |
af | A'llow/ F'orbid/`R'eseached |
void ApplyIndividualUpgradeModifier | ( | CUnit & | unit, |
const CUpgradeModifier * | um | ||
) |
Apply the modifiers of an individual upgrade.
unit | Unit that will get the modifier applied |
um | Upgrade modifier that does the effects |
|
static |
Apply the modifiers of an upgrade.
This function will mark upgrade done and do all required modifications to unit types and will modify allow/forbid maps
player | Player that get all the upgrades. |
um | Upgrade modifier that do the effects |
void ApplyUpgrades | ( | ) |
Apply researched upgrades when map is loading.
Apply researched upgrades when map is loading
|
static |
Description
Define which units/upgrades are allowed.
Example:
DefineAllow("unit-town-hall","AAAAAAAAAAAAAAAA") – Available for everybody DefineAllow("unit-stables","FFFFFFFFFFFFFFFF") – Not available DefineAllow("upgrade-sword1","RRRRRRRRRRRRRRRR") – Upgrade already researched.
How many units supported
|
static |
Define a new upgrade modifier.
l | List of modifiers. |
|
static |
Define which units are allowed and how much.
void CleanUpgrades | ( | ) |
cleanup upgrade module
Cleanup the upgrade module.
Convert unit-type to.
player | For this player. |
src | From this unit-type. |
dst | To this unit-type. |
Apply upgrade modifier of an individual upgrade.
Make a unit acquire in individual upgrade.
void InitUpgrades | ( | ) |
init upgrade/allow structures
Init upgrade/allow structures
|
static |
|
static |
Remove the modifiers of an upgrade.
This function will unmark upgrade as done and undo all required modifications to unit types and will modify allow/forbid maps back
player | Player that get all the upgrades. |
um | Upgrade modifier that do the effects |
save the upgrades
Save state of the dependencies to file.
file | Output file. |
int UnitIdAllowed | ( | const CPlayer & | player, |
int | id | ||
) |
Make a unit lose in individual upgrade.
Return the allow state of the unit.
player | Check state of this player. |
id | Unit identifier. |
int UnitTypeIdByIdent | ( | const std::string & | ident | ) |
UnitType ID by identifier.
ident | The unit-type identifier. |
Upgrade will be acquired.
Handle that an upgrade was acquired.
player | Player researching the upgrade. |
upgrade | Upgrade ready researched. |
char UpgradeIdAllowed | ( | const CPlayer & | player, |
int | id | ||
) |
Return the allow state of an upgrade.
player | Check state for this player. |
id | Upgrade identifier. |
int UpgradeIdByIdent | ( | const std::string & | ident | ) |
Upgrade ID by identifier.
ident | The upgrade identifier. |
char UpgradeIdentAllowed | ( | const CPlayer & | player, |
const std::string & | ident | ||
) |
Return the allow state of an upgrade.
player | Check state for this player. |
ident | Upgrade identifier. |
Upgrade will be lost.
Upgrade will be lost
player | Player researching the upgrade. |
id | Upgrade to be lost. |
void UpgradesCclRegister | ( | ) |
Register CCL features for upgrades.
Register CCL features for upgrades.
std::vector<CUpgrade *> AllUpgrades |
int NumUpgradeModifiers |
Number of upgrades modifiers used.
CUpgradeModifier* UpgradeModifiers[UPGRADE_MODIFIERS_MAX] |
The main user useable upgrades.
Upgrades modifiers
std::map<std::string, CUpgrade *> Upgrades |