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

upgrade.cpp File Reference
#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
 
CUpgradeModifierUpgradeModifiers [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)
 

Function Documentation

◆ AllowUnitId()

static void AllowUnitId ( CPlayer player,
int  id,
int  units 
)
static

Change allow for an unit-type.

Parameters
playerPlayer to change
idunit type id
unitsmaximum amount of units allowed

◆ AllowUpgradeId()

void AllowUpgradeId ( CPlayer player,
int  id,
char  af 
)

Change allow for an upgrade.

Parameters
playerPlayer to change
idupgrade id
afA'llow/F'orbid/`R'eseached

◆ ApplyIndividualUpgradeModifier()

void ApplyIndividualUpgradeModifier ( CUnit unit,
const CUpgradeModifier um 
)

Apply the modifiers of an individual upgrade.

Parameters
unitUnit that will get the modifier applied
umUpgrade modifier that does the effects

◆ ApplyUpgradeModifier()

static void ApplyUpgradeModifier ( CPlayer player,
const CUpgradeModifier um 
)
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

Parameters
playerPlayer that get all the upgrades.
umUpgrade modifier that do the effects

◆ ApplyUpgrades()

void ApplyUpgrades ( )

Apply researched upgrades when map is loading.

Apply researched upgrades when map is loading

Returns
: void

◆ CclDefineAllow()

static int CclDefineAllow ( lua_State *  l)
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

◆ CclDefineModifier()

static int CclDefineModifier ( lua_State *  l)
static

Define a new upgrade modifier.

Parameters
lList of modifiers.

◆ CclDefineUnitAllow()

static int CclDefineUnitAllow ( lua_State *  l)
static

Define which units are allowed and how much.

◆ CleanUpgrades()

void CleanUpgrades ( )

cleanup upgrade module

Cleanup the upgrade module.

◆ ConvertUnitTypeTo()

static void ConvertUnitTypeTo ( CPlayer player,
const CUnitType src,
CUnitType dst 
)
static

Convert unit-type to.

Parameters
playerFor this player.
srcFrom this unit-type.
dstTo this unit-type.

◆ IndividualUpgradeAcquire()

void IndividualUpgradeAcquire ( CUnit unit,
const CUpgrade upgrade 
)

Apply upgrade modifier of an individual upgrade.

◆ IndividualUpgradeLost()

void IndividualUpgradeLost ( CUnit unit,
const CUpgrade upgrade 
)

Make a unit acquire in individual upgrade.

◆ InitUpgrades()

void InitUpgrades ( )

init upgrade/allow structures

Init upgrade/allow structures

◆ RemoveIndividualUpgradeModifier()

static void RemoveIndividualUpgradeModifier ( CUnit unit,
const CUpgradeModifier um 
)
static

◆ RemoveUpgradeModifier()

static void RemoveUpgradeModifier ( CPlayer player,
const CUpgradeModifier um 
)
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

Parameters
playerPlayer that get all the upgrades.
umUpgrade modifier that do the effects

◆ SaveUpgrades()

void SaveUpgrades ( CFile file)

save the upgrades

Save state of the dependencies to file.

Parameters
fileOutput file.

◆ UnitIdAllowed()

int UnitIdAllowed ( const CPlayer player,
int  id 
)

Make a unit lose in individual upgrade.

Return the allow state of the unit.

Parameters
playerCheck state of this player.
idUnit identifier.
Returns
the allow state of the unit.

◆ UnitTypeIdByIdent()

int UnitTypeIdByIdent ( const std::string &  ident)

UnitType ID by identifier.

Parameters
identThe unit-type identifier.
Returns
Unit-type ID (int) or -1 if not found.

◆ UpgradeAcquire()

void UpgradeAcquire ( CPlayer player,
const CUpgrade upgrade 
)

Upgrade will be acquired.

Handle that an upgrade was acquired.

Parameters
playerPlayer researching the upgrade.
upgradeUpgrade ready researched.

◆ UpgradeIdAllowed()

char UpgradeIdAllowed ( const CPlayer player,
int  id 
)

Return the allow state of an upgrade.

Parameters
playerCheck state for this player.
idUpgrade identifier.
Returns
the allow state of the upgrade.

◆ UpgradeIdByIdent()

int UpgradeIdByIdent ( const std::string &  ident)

Upgrade ID by identifier.

Parameters
identThe upgrade identifier.
Returns
Upgrade ID (int) or -1 if not found.

◆ UpgradeIdentAllowed()

char UpgradeIdentAllowed ( const CPlayer player,
const std::string &  ident 
)

Return the allow state of an upgrade.

Parameters
playerCheck state for this player.
identUpgrade identifier.
Note
This function shouldn't be used during runtime, it is only for setup.

◆ UpgradeLost()

void UpgradeLost ( CPlayer player,
int  id 
)

Upgrade will be lost.

Upgrade will be lost

Parameters
playerPlayer researching the upgrade.
idUpgrade to be lost.

◆ UpgradesCclRegister()

void UpgradesCclRegister ( )

Register CCL features for upgrades.

Register CCL features for upgrades.

Variable Documentation

◆ AllUpgrades

std::vector<CUpgrade *> AllUpgrades

◆ NumUpgradeModifiers

int NumUpgradeModifiers

Number of upgrades modifiers used.

◆ UpgradeModifiers

The main user useable upgrades.

Upgrades modifiers

◆ Upgrades

std::map<std::string, CUpgrade *> Upgrades
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.