Class that handles all town related functions. More...
#include <script_town.hpp>
Public Types | |
enum | TownAction { TOWN_ACTION_ADVERTISE_SMALL = 0, TOWN_ACTION_ADVERTISE_MEDIUM = 1, TOWN_ACTION_ADVERTISE_LARGE = 2, TOWN_ACTION_ROAD_REBUILD = 3, TOWN_ACTION_BUILD_STATUE = 4, TOWN_ACTION_FUND_BUILDINGS = 5, TOWN_ACTION_BUY_RIGHTS = 6, TOWN_ACTION_BRIBE = 7 } |
Actions that one can perform on a town. More... | |
enum | TownRating { TOWN_RATING_NONE, TOWN_RATING_APPALLING, TOWN_RATING_VERY_POOR, TOWN_RATING_POOR, TOWN_RATING_MEDIOCRE, TOWN_RATING_GOOD, TOWN_RATING_VERY_GOOD, TOWN_RATING_EXCELLENT, TOWN_RATING_OUTSTANDING, TOWN_RATING_INVALID = -1 } |
Different ratings one could have in a town. More... | |
enum | RoadLayout { ROAD_LAYOUT_ORIGINAL = ::TL_ORIGINAL, ROAD_LAYOUT_BETTER_ROADS = ::TL_BETTER_ROADS, ROAD_LAYOUT_2x2 = ::TL_2X2_GRID, ROAD_LAYOUT_3x3 = ::TL_3X3_GRID, ROAD_LAYOUT_INVALID = -1 } |
Possible layouts for the roads in a town. More... | |
Static Public Member Functions | |
static int32 | GetTownCount () |
Gets the number of towns. | |
static bool | IsValidTown (TownID town_id) |
Checks whether the given town index is valid. | |
static char * | GetName (TownID town_id) |
Get the name of the town. | |
static bool | SetText (TownID town_id, Text *text) |
Set the custom text of a town, shown in the GUI. | |
static int32 | GetPopulation (TownID town_id) |
Gets the number of inhabitants in the town. | |
static int32 | GetHouseCount (TownID town_id) |
Gets the number of houses in the town. | |
static TileIndex | GetLocation (TownID town_id) |
Gets the location of the town. | |
static int32 | GetLastMonthProduction (TownID town_id, CargoID cargo_id) |
Get the total last month's production of the given cargo at a town. | |
static int32 | GetLastMonthSupplied (TownID town_id, CargoID cargo_id) |
Get the total amount of cargo supplied from a town last month. | |
static int32 | GetLastMonthTransportedPercentage (TownID town_id, CargoID cargo_id) |
Get the percentage of transported production of the given cargo at a town. | |
static int32 | GetLastMonthReceived (TownID town_id, ScriptCargo::TownEffect towneffect_id) |
Get the total amount of cargo effects received by a town last month. | |
static bool | SetCargoGoal (TownID town_id, ScriptCargo::TownEffect towneffect_id, uint32 goal) |
Set the goal of a cargo for this town. | |
static uint32 | GetCargoGoal (TownID town_id, ScriptCargo::TownEffect towneffect_id) |
Get the amount of cargo that needs to be delivered (per TownEffect) for a town to grow. | |
static bool | SetGrowthRate (TownID town_id, uint16 days_between_town_growth) |
Set the amount of days between town growth. | |
static int32 | GetGrowthRate (TownID town_id) |
Get the amount of days between town growth. | |
static int32 | GetDistanceManhattanToTile (TownID town_id, TileIndex tile) |
Get the manhattan distance from the tile to the ScriptTown::GetLocation() of the town. | |
static int32 | GetDistanceSquareToTile (TownID town_id, TileIndex tile) |
Get the square distance from the tile to the ScriptTown::GetLocation() of the town. | |
static bool | IsWithinTownInfluence (TownID town_id, TileIndex tile) |
Find out if this tile is within the rating influence of a town. | |
static bool | HasStatue (TownID town_id) |
Find out if this town has a statue for the current company. | |
static bool | IsCity (TownID town_id) |
Find out if the town is a city. | |
static int | GetRoadReworkDuration (TownID town_id) |
Find out how long the town is undergoing road reconstructions. | |
static ScriptCompany::CompanyID | GetExclusiveRightsCompany (TownID town_id) |
Find out which company currently has the exclusive rights of this town. | |
static int32 | GetExclusiveRightsDuration (TownID town_id) |
Find out how long the town is under influence of the exclusive rights. | |
static bool | IsActionAvailable (TownID town_id, TownAction town_action) |
Find out if an action can currently be performed on the town. | |
static bool | PerformTownAction (TownID town_id, TownAction town_action) |
Perform a town action on this town. | |
static bool | ExpandTown (TownID town_id, int houses) |
Expand the town. | |
static TownRating | GetRating (TownID town_id, ScriptCompany::CompanyID company_id) |
Get the rating of a company within a town. | |
static int | GetAllowedNoise (TownID town_id) |
Get the maximum level of noise that still can be added by airports before the town start to refuse building a new airport. | |
static RoadLayout | GetRoadLayout (TownID town_id) |
Get the road layout for a town. |
Class that handles all town related functions.
ai game
Definition at line 24 of file script_town.hpp.
Possible layouts for the roads in a town.
Definition at line 98 of file script_town.hpp.
Actions that one can perform on a town.
Definition at line 29 of file script_town.hpp.
Different ratings one could have in a town.
Definition at line 82 of file script_town.hpp.
bool ScriptTown::ExpandTown | ( | TownID | town_id, | |
int | houses | |||
) | [static] |
Expand the town.
town_id | The town to expand. | |
houses | The amount of houses to grow the town with. |
Definition at line 235 of file script_town.cpp.
References CMD_EXPAND_TOWN, ScriptObject::DoCommand(), EnforcePrecondition, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), ScriptObject::GetCompany(), IsValidTown(), and OWNER_DEITY.
int ScriptTown::GetAllowedNoise | ( | TownID | town_id | ) | [static] |
Get the maximum level of noise that still can be added by airports before the town start to refuse building a new airport.
town_id | The town to get the allowed noise from. |
Definition at line 272 of file script_town.cpp.
References _settings_game, AT_OILRIG, GameSettings::economy, FACIL_AIRPORT, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), IsValidTown(), max(), Town::MaxTownNoise(), Town::noise_reached, and EconomySettings::station_noise_level.
uint32 ScriptTown::GetCargoGoal | ( | TownID | town_id, | |
ScriptCargo::TownEffect | towneffect_id | |||
) | [static] |
Get the amount of cargo that needs to be delivered (per TownEffect) for a town to grow.
All goals need to be reached before a town will grow.
town_id | The index of the town. | |
towneffect_id | The index of the towneffect. |
Definition at line 124 of file script_town.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), GetSnowLine(), GetTropicZone(), Town::goal, IsValidTown(), ScriptCargo::IsValidTownEffect(), Town::population, TileHeight(), TOWN_GROWTH_DESERT, TOWN_GROWTH_WINTER, TROPICZONE_DESERT, and Town::xy.
Get the manhattan distance from the tile to the ScriptTown::GetLocation() of the town.
town_id | The town to get the distance to. | |
tile | The tile to get the distance to. |
Definition at line 163 of file script_town.cpp.
References DistanceManhattan(), and GetLocation().
Get the square distance from the tile to the ScriptTown::GetLocation() of the town.
town_id | The town to get the distance to. | |
tile | The tile to get the distance to. |
Definition at line 168 of file script_town.cpp.
References DistanceSquare(), and GetLocation().
Referenced by IsWithinTownInfluence().
ScriptCompany::CompanyID ScriptTown::GetExclusiveRightsCompany | ( | TownID | town_id | ) | [static] |
Find out which company currently has the exclusive rights of this town.
town_id | The town to check. |
Definition at line 203 of file script_town.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), ScriptObject::GetCompany(), IsValidTown(), and OWNER_DEITY.
int32 ScriptTown::GetExclusiveRightsDuration | ( | TownID | town_id | ) | [static] |
Find out how long the town is under influence of the exclusive rights.
town_id | The town to check. |
Definition at line 211 of file script_town.cpp.
References IsValidTown().
int32 ScriptTown::GetGrowthRate | ( | TownID | town_id | ) | [static] |
Get the amount of days between town growth.
town_id | The index of the town. |
Definition at line 154 of file script_town.cpp.
References DAY_TICKS, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), Town::growth_rate, IsValidTown(), and TOWN_GROWTH_TICKS.
int32 ScriptTown::GetHouseCount | ( | TownID | town_id | ) | [static] |
Gets the number of houses in the town.
town_id | The town to get the number of houses of. |
Definition at line 63 of file script_town.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), IsValidTown(), and Town::num_houses.
Get the total last month's production of the given cargo at a town.
town_id | The index of the town. | |
cargo_id | The index of the cargo. |
Definition at line 77 of file script_town.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), ScriptCargo::IsValidCargo(), IsValidTown(), TransportedCargoStat< Tstorage >::old_max, and Town::supplied.
int32 ScriptTown::GetLastMonthReceived | ( | TownID | town_id, | |
ScriptCargo::TownEffect | towneffect_id | |||
) | [static] |
Get the total amount of cargo effects received by a town last month.
town_id | The index of the town. | |
towneffect_id | The index of the cargo. |
Definition at line 106 of file script_town.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), IsValidTown(), ScriptCargo::IsValidTownEffect(), TransportedCargoStat< Tstorage >::old_act, and Town::received.
Get the total amount of cargo supplied from a town last month.
town_id | The index of the town. | |
cargo_id | The index of the cargo. |
Definition at line 87 of file script_town.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), ScriptCargo::IsValidCargo(), IsValidTown(), TransportedCargoStat< Tstorage >::old_act, and Town::supplied.
Get the percentage of transported production of the given cargo at a town.
town_id | The index of the town. | |
cargo_id | The index of the cargo. |
Definition at line 97 of file script_town.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), ScriptCargo::IsValidCargo(), IsValidTown(), and ToPercent8().
Gets the location of the town.
town_id | The town to get the location of. |
Definition at line 70 of file script_town.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), INVALID_TILE, IsValidTown(), and Town::xy.
Referenced by GetDistanceManhattanToTile(), and GetDistanceSquareToTile().
char * ScriptTown::GetName | ( | TownID | town_id | ) | [static] |
Get the name of the town.
town_id | The town to get the name of. |
Definition at line 34 of file script_town.cpp.
References IsValidTown(), and SetDParam().
int32 ScriptTown::GetPopulation | ( | TownID | town_id | ) | [static] |
Gets the number of inhabitants in the town.
town_id | The town to get the population of. |
Definition at line 56 of file script_town.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), IsValidTown(), and Town::population.
ScriptTown::TownRating ScriptTown::GetRating | ( | TownID | town_id, | |
ScriptCompany::CompanyID | company_id | |||
) | [static] |
Get the rating of a company within a town.
town_id | The town to get the rating for. | |
company_id | The company to get the rating for. |
Definition at line 244 of file script_town.cpp.
References ScriptCompany::COMPANY_INVALID, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), HasBit(), Town::have_ratings, IsValidTown(), Town::ratings, and ScriptCompany::ResolveCompanyID().
ScriptTown::RoadLayout ScriptTown::GetRoadLayout | ( | TownID | town_id | ) | [static] |
Get the road layout for a town.
town_id | The town to get the road layout from. |
Definition at line 289 of file script_town.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), and IsValidTown().
int ScriptTown::GetRoadReworkDuration | ( | TownID | town_id | ) | [static] |
Find out how long the town is undergoing road reconstructions.
town_id | The town to check. |
Definition at line 196 of file script_town.cpp.
References IsValidTown().
int32 ScriptTown::GetTownCount | ( | ) | [static] |
Gets the number of towns.
Definition at line 24 of file script_town.cpp.
bool ScriptTown::HasStatue | ( | TownID | town_id | ) | [static] |
Find out if this town has a statue for the current company.
town_id | The town to check. |
Definition at line 181 of file script_town.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), ScriptObject::GetCompany(), HasBit(), IsValidTown(), and OWNER_DEITY.
bool ScriptTown::IsActionAvailable | ( | TownID | town_id, | |
TownAction | town_action | |||
) | [static] |
Find out if an action can currently be performed on the town.
town_id | The town to perform the action on. | |
town_action | The action to perform on the town. |
Definition at line 218 of file script_town.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), ScriptObject::GetCompany(), GetMaskOfTownActions(), HasBit(), IsValidTown(), and OWNER_DEITY.
Referenced by PerformTownAction().
bool ScriptTown::IsCity | ( | TownID | town_id | ) | [static] |
Find out if the town is a city.
town_id | The town to check. |
Definition at line 189 of file script_town.cpp.
References IsValidTown().
bool ScriptTown::IsValidTown | ( | TownID | town_id | ) | [static] |
Checks whether the given town index is valid.
town_id | The index to check. |
Definition at line 29 of file script_town.cpp.
Referenced by ScriptSubsidy::Create(), ExpandTown(), GetAllowedNoise(), GetCargoGoal(), GetExclusiveRightsCompany(), GetExclusiveRightsDuration(), GetGrowthRate(), GetHouseCount(), GetLastMonthProduction(), GetLastMonthReceived(), GetLastMonthSupplied(), GetLastMonthTransportedPercentage(), GetLocation(), GetName(), GetPopulation(), GetRating(), GetRoadLayout(), GetRoadReworkDuration(), HasStatue(), IsActionAvailable(), IsCity(), IsWithinTownInfluence(), ScriptGoal::New(), PerformTownAction(), SetCargoGoal(), SetGrowthRate(), and SetText().
Find out if this tile is within the rating influence of a town.
If a station sign would be on this tile, the servicing quality of the station would influence the rating of the town.
town_id | The town to check. | |
tile | The tile to check. |
Definition at line 173 of file script_town.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), GetDistanceSquareToTile(), IsValidTown(), and Town::squared_town_zone_radius.
bool ScriptTown::PerformTownAction | ( | TownID | town_id, | |
TownAction | town_action | |||
) | [static] |
Perform a town action on this town.
town_id | The town to perform the action on. | |
town_action | The action to perform on the town. |
Definition at line 226 of file script_town.cpp.
References CMD_DO_TOWN_ACTION, ScriptObject::DoCommand(), EnforcePrecondition, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), ScriptObject::GetCompany(), IsActionAvailable(), IsValidTown(), and OWNER_DEITY.
bool ScriptTown::SetCargoGoal | ( | TownID | town_id, | |
ScriptCargo::TownEffect | towneffect_id, | |||
uint32 | goal | |||
) | [static] |
Set the goal of a cargo for this town.
town_id | The index of the town. | |
towneffect_id | The index of the cargo. | |
goal | The new goal. |
Definition at line 116 of file script_town.cpp.
References CMD_TOWN_CARGO_GOAL, ScriptObject::DoCommand(), EnforcePrecondition, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), IsValidTown(), and ScriptCargo::IsValidTownEffect().
bool ScriptTown::SetGrowthRate | ( | TownID | town_id, | |
uint16 | days_between_town_growth | |||
) | [static] |
Set the amount of days between town growth.
town_id | The index of the town. | |
days_between_town_growth | The amont of days between town growth. |
Definition at line 144 of file script_town.cpp.
References CMD_TOWN_GROWTH_RATE, DAY_TICKS, ScriptObject::DoCommand(), EnforcePrecondition, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), IsValidTown(), TOWN_GROW_RATE_CUSTOM, and TOWN_GROWTH_TICKS.
Set the custom text of a town, shown in the GUI.
town_id | The town to set the custom text of. | |
text | The text to set it to (can be either a raw string, or a ScriptText object). |
Definition at line 46 of file script_town.cpp.
References CMD_TOWN_SET_TEXT, ScriptObject::DoCommand(), EnforcePrecondition, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), Text::GetEncodedText(), and IsValidTown().