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

script_player.cpp File Reference
#include "stratagus.h"
#include "player.h"
#include "actions.h"
#include "ai.h"
#include "commands.h"
#include "map.h"
#include "script.h"
#include "unittype.h"
#include "unit.h"
#include "unit_find.h"
#include "upgrade.h"
#include "video.h"

Functions

script_player.cpp - The player ccl functions.
CUnitCclGetUnitFromRef (lua_State *l)
 For saving lua state. More...
 
static CPlayerCclGetPlayer (lua_State *l)
 
static int CclPlayer (lua_State *l)
 
static int CclChangeUnitsOwner (lua_State *l)
 
static int CclGiveUnitsToPlayer (lua_State *l)
 
static int CclGetThisPlayer (lua_State *l)
 
static int CclSetThisPlayer (lua_State *l)
 
static int CclSetMaxSelectable (lua_State *l)
 
static int CclSetAllPlayersUnitLimit (lua_State *l)
 
static int CclSetAllPlayersBuildingLimit (lua_State *l)
 
static int CclSetAllPlayersTotalUnitLimit (lua_State *l)
 
static int CclSetDiplomacy (lua_State *l)
 
static int CclDiplomacy (lua_State *l)
 
static int CclGetDiplomacy (lua_State *l)
 
static int CclSetSharedVision (lua_State *l)
 
static int CclSharedVision (lua_State *l)
 
static int CclSetRevelationType (lua_State *l)
 
static int CclDefineNewRaceNames (lua_State *l)
 
static int CclDefineRaceNames (lua_State *l)
 
static int CclDefinePlayerColors (lua_State *l)
 
static int CclNewPlayerColors (lua_State *l)
 
static int CclDefinePlayerColorIndex (lua_State *l)
 
static int CclGetPlayerData (lua_State *l)
 
static int CclSetPlayerData (lua_State *l)
 
static int CclSetAiType (lua_State *l)
 
void PlayerCclRegister ()
 register ccl features More...
 

Function Documentation

◆ CclChangeUnitsOwner()

static int CclChangeUnitsOwner ( lua_State *  l)
static

Description

Change all units owned by one player or change only specific units owned by one player

Parameters
lLua state.

Example:

– Changes all units owned by player 0 and give to player 1 ChangeUnitsOwner({16, 17}, {30, 32}, 0, 1) – Changes all farms owned by player 0 and give to player 1 ChangeUnitsOwner({16, 17}, {30, 32}, 0, 1, "unit-farm")

◆ CclDefineNewRaceNames()

static int CclDefineNewRaceNames ( lua_State *  l)
static

Description

Define race names in addition to those already there.

Parameters
lLua state.

◆ CclDefinePlayerColorIndex()

static int CclDefinePlayerColorIndex ( lua_State *  l)
static

Define player color indexes

Parameters
lLua state.

◆ CclDefinePlayerColors()

static int CclDefinePlayerColors ( lua_State *  l)
static

Description

Define player colors. Pass "false" as an optional second argument to add the colors to the existing ones.

Parameters
lLua state.

Example:

DefinePlayerColors({ "red", {{164, 0, 0}, {124, 0, 0}, {92, 4, 0}, {68, 4, 0}}, "blue", {{12, 72, 204}, {4, 40, 160}, {0, 20, 116}, {0, 4, 76}}, "green", {{44, 180, 148}, {20, 132, 92}, {4, 84, 44}, {0, 40, 12}}, "violet", {{152, 72, 176}, {116, 44, 132}, {80, 24, 88}, {44, 8, 44}}, "orange", {{248, 140, 20}, {200, 96, 16}, {152, 60, 16}, {108, 32, 12}}, "black", {{40, 40, 60}, {28, 28, 44}, {20, 20, 32}, {12, 12, 20}}, "white", {{224, 224, 224}, {152, 152, 180}, {84, 84, 128}, {36, 40, 76}}, "yellow", {{252, 252, 72}, {228, 204, 40}, {204, 160, 16}, {180, 116, 0}}, "red", {{164, 0, 0}, {124, 0, 0}, {92, 4, 0}, {68, 4, 0}}, "blue", {{12, 72, 204}, {4, 40, 160}, {0, 20, 116}, {0, 4, 76}}, "green", {{44, 180, 148}, {20, 132, 92}, {4, 84, 44}, {0, 40, 12}}, "violet", {{152, 72, 176}, {116, 44, 132}, {80, 24, 88}, {44, 8, 44}}, "orange", {{248, 140, 20}, {200, 96, 16}, {152, 60, 16}, {108, 32, 12}}, "black", {{40, 40, 60}, {28, 28, 44}, {20, 20, 32}, {12, 12, 20}}, "white", {{224, 224, 224}, {152, 152, 180}, {84, 84, 128}, {36, 40, 76}}, "yellow", {{252, 252, 72}, {228, 204, 40}, {204, 160, 16}, {180, 116, 0}}, })

◆ CclDefineRaceNames()

static int CclDefineRaceNames ( lua_State *  l)
static

Define race names

Parameters
lLua state.

◆ CclDiplomacy()

static int CclDiplomacy ( lua_State *  l)
static

Change the diplomacy from ThisPlayer to another player.

Parameters
lLua state.

◆ CclGetDiplomacy()

static int CclGetDiplomacy ( lua_State *  l)
static

Get diplomacy from one player to another. Returns the strings "allied", "enemy", "neutral", or "crazy".

◆ CclGetPlayer()

static CPlayer* CclGetPlayer ( lua_State *  l)
static

Get a player pointer

Parameters
lLua state.
Returns
The player pointer

◆ CclGetPlayerData()

static int CclGetPlayerData ( lua_State *  l)
static

Description

Get player data.

Parameters
lLua state.

Example:

GetPlayerData(0,"TotalNumUnits")

◆ CclGetThisPlayer()

static int CclGetThisPlayer ( lua_State *  l)
static

Description

Get ThisPlayer.

Parameters
lLua state.

Example:

GetThisPlayer()

◆ CclGetUnitFromRef()

CUnit* CclGetUnitFromRef ( lua_State *  l)

For saving lua state.

Get a unit pointer from ref string

Parameters
lLua state.
Returns
The unit pointer

◆ CclGiveUnitsToPlayer()

static int CclGiveUnitsToPlayer ( lua_State *  l)
static

Description

GiveUnitsToPlayer(amount, type, fromPlayer, toPlayer) GiveUnitsToPlayer(amount, type, topLeft, bottomRight, fromPlayer, toPlayer) Give some units of a specific type from a player to another player. Optionally only inside a rectangle. Returns number of units actually assigned. This can be smaller than the requested amount if the fromPlayer did not have enough units.

Instead of a number you can pass "all" as the first argument, to hand over all units.

Instead of a unit type name, you can pass "any", "unit", "building" as the second argument, to hand over anything, and unit, or any building.

Parameters
lLua state.

Example:

– Give 2 peasants from player 4 to player 2 GiveUnitsToPlayer(2, "unit-peasant", 4, 2) – Give 4 knights from player 5 to player 1 inside the rectangle 2,2 - 14,14 GiveUnitsToPlayer(2, "unit-peasant", {2,2}, {14,14}, 4, 2) – Give any 4 units from player 5 to player 1 inside the rectangle 2,2 - 14,14 GiveUnitsToPlayer(2, "any", 4, 2)

◆ CclNewPlayerColors()

static int CclNewPlayerColors ( lua_State *  l)
static

Make new player colors

Parameters
lLua state.

◆ CclPlayer()

static int CclPlayer ( lua_State *  l)
static

Parse the player configuration.

Parameters
lLua state.

◆ CclSetAiType()

static int CclSetAiType ( lua_State *  l)
static

Description

Set ai player algo.

Parameters
lLua state.

Example:

– Player 1 has a passive A.I SetAiType(1, "Passive")

◆ CclSetAllPlayersBuildingLimit()

static int CclSetAllPlayersBuildingLimit ( lua_State *  l)
static

Description

Set players buildings limit.

Parameters
lLua state.

Example:

SetAllPlayersBuildingLimit(200)

◆ CclSetAllPlayersTotalUnitLimit()

static int CclSetAllPlayersTotalUnitLimit ( lua_State *  l)
static

Description

Set players total units limit.

Parameters
lLua state.

Example:

SetAllPlayersTotalUnitLimit(400)

◆ CclSetAllPlayersUnitLimit()

static int CclSetAllPlayersUnitLimit ( lua_State *  l)
static

Description

Set players units limit.

Parameters
lLua state.

Example:

SetAllPlayersUnitLimit(200)

◆ CclSetDiplomacy()

static int CclSetDiplomacy ( lua_State *  l)
static

Description

Change the diplomacy from player to another player.

Parameters
lLua state.
Returns
FIXME: should return old state.

Example:

SetDiplomacy(0,"allied",1) SetDiplomacy(1,"allied",0)
SetDiplomacy(0,"enemy",2) SetDiplomacy(1,"enemy",2)

◆ CclSetMaxSelectable()

static int CclSetMaxSelectable ( lua_State *  l)
static

Description

Set the maximum amount of units that can be selected.

Parameters
lLua state.

Example:

– 9 units can be selected together. SetMaxSelectable(9) – 18 units can be selected together. SetMaxSelectable(18) – 50 units can be selected together. SetMaxSelectable(50)

◆ CclSetPlayerData()

static int CclSetPlayerData ( lua_State *  l)
static

Description

Set player data.

Parameters
lLua state.

Example:

SetPlayerData(0,"Name","Nation of Stromgarde") – set the name of this player SetPlayerData(0,"RaceName","human") – the the race to human SetPlayerData(0,"Resources","gold",1700) – set the player to have 1700 gold SetPlayerData(0, "Allow", "upgrade-paladin", "R") – give the player the Paladin upgrade

◆ CclSetRevelationType()

static int CclSetRevelationType ( lua_State *  l)
static

Description

Change the players revelation type - reveal all units, only buidings or don't reveal anything

Parameters
lLua state.

Example:

SetRevelationType("no-revelation") SetRevelationType("buildings-only") SetRevelationType("all-units")

◆ CclSetSharedVision()

static int CclSetSharedVision ( lua_State *  l)
static

Description

Change the shared vision from player to another player.

Parameters
lLua state.
Returns
FIXME: should return old state.

Example:

SetSharedVision(0,true,1) SetSharedVision(1,true,0)
SetSharedVision(0,false,2) SetSharedVision(1,false,2)

◆ CclSetThisPlayer()

static int CclSetThisPlayer ( lua_State *  l)
static

Description

Set ThisPlayer.

Parameters
lLua state.

◆ CclSharedVision()

static int CclSharedVision ( lua_State *  l)
static

Change the shared vision from ThisPlayer to another player.

Parameters
lLua state.

◆ PlayerCclRegister()

void PlayerCclRegister ( )

register ccl features

Register CCL features for players.

(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.