58 int count,
int sq_radius)
65 "no partisans in ruleset");
75 City *homecity,
int moves_left)
78 homecity, moves_left, -1,
nullptr);
86 City *homecity,
int moves_left,
int hp_left,
117 "create_unit_full: '%s' cannot transport "
125 "create_unit_full: '%s' cannot exist at "
133 "create_unit_full: tile is occupied by "
141 "create_unit_full: tile is occupied by "
177 && (
unit_owner(punit)->ai_common.barbarian_type != ANIMAL_BARBARIAN)
185 wipe_unit(punit, ULR_NONNATIVE_TERR,
nullptr);
190 wipe_unit(punit, ULR_STACK_CONFLICT,
nullptr);
206 if (direction8_is_valid(dir)) {
211 qCritical(
"Illegal direction %d for unit from lua script", dir);
221 enum unit_loss_reason loss_reason;
227 loss_reason = unit_loss_reason_by_name(reason,
fc_strcasecmp);
230 "Invalid unit loss reason");
248 if (old_terrain == pterr
304 struct player *pplayer =
nullptr;
326 if (strlen(buf) > 0) {
375 }
else if (cost == -2) {
377 }
else if (cost == -3) {
386 if (notify && result !=
nullptr) {
393 Q_(
"?fromscript:You acquire %s."),
394 qUtf8Printable(adv_name));
398 Q_(
"?fromscript:The %s acquire %s and share this "
399 "advance with you."),
401 qUtf8Printable(adv_name));
406 Q_(
"?fromscript:The %s acquire %s."),
407 research_name, qUtf8Printable(adv_name));
532 2,
"invalid climate change type");
546 "must be a percentage",
nullptr);
552 if (probability == 0) {
559 if (
fc_rand(100) >= probability) {
591 punit, ptile, movecost,
603 && (
unit_owner(punit)->ai_common.barbarian_type != ANIMAL_BARBARIAN)
617 if (punit !=
nullptr) {
630 if (punit !=
nullptr) {
const char * default_ai_type_name()
Return name of default ai type.
Unit * api_edit_create_unit_full(lua_State *L, Player *pplayer, Tile *ptile, Unit_Type *ptype, int veteran_level, City *homecity, int moves_left, int hp_left, Unit *ptransport)
Create a new unit.
void api_edit_climate_change(lua_State *L, enum climate_change_type type, int effect)
Global climate change.
Player * api_edit_create_player(lua_State *L, const char *username, Nation_Type *pnation, const char *ai)
Create a new player.
void api_edit_resize_city(lua_State *L, City *pcity, int size, const char *reason)
Resizes a city.
void api_edit_unit_moving_allow(lua_State *L, Unit *punit)
Allow unit to move.
bool api_edit_trait_mod_set(lua_State *L, Player *pplayer, const char *tname, const int mod)
Modify player's trait value.
bool api_edit_unleash_barbarians(lua_State *L, Tile *ptile)
Unleash barbarians on a tile, for example from a hut.
Player * api_edit_civil_war(lua_State *L, Player *pplayer, int probability)
Provoke a civil war.
void api_edit_player_victory(lua_State *L, Player *pplayer)
Make player winner of the scenario.
void api_edit_create_extra(lua_State *L, Tile *ptile, const char *name)
Create a new extra.
void api_edit_player_add_history(lua_State *L, Player *pplayer, int amount)
Add history to a player.
bool api_edit_unit_teleport(lua_State *L, Unit *punit, Tile *dest)
Teleport unit to destination tile.
bool api_edit_change_terrain(lua_State *L, Tile *ptile, Terrain *pterr)
Change terrain on tile.
void api_edit_create_owned_extra(lua_State *L, Tile *ptile, const char *name, Player *pplayer)
Create a new owned extra.
Unit * api_edit_create_unit(lua_State *L, Player *pplayer, Tile *ptile, Unit_Type *ptype, int veteran_level, City *homecity, int moves_left)
Create a new unit.
void api_edit_unit_kill(lua_State *L, Unit *punit, const char *reason, Player *killer)
Kill the unit.
void api_edit_unit_turn(lua_State *L, Unit *punit, Direction dir)
Change unit orientation.
void api_edit_place_partisans(lua_State *L, Tile *ptile, Player *pplayer, int count, int sq_radius)
Place partisans for a player around a tile (normally around a city).
void api_edit_remove_extra(lua_State *L, Tile *ptile, const char *name)
Remove extra from tile, if present.
void api_edit_tile_set_label(lua_State *L, Tile *ptile, const char *label)
Set tile label text.
void api_edit_create_road(lua_State *L, Tile *ptile, const char *name)
Add a new road.
Tech_Type * api_edit_give_technology(lua_State *L, Player *pplayer, Tech_Type *ptech, int cost, bool notify, const char *reason)
Give pplayer technology ptech.
void api_edit_city_add_history(lua_State *L, City *pcity, int amount)
Add history to a city.
bool api_edit_unit_move(lua_State *L, Unit *punit, Tile *ptile, int movecost)
Move a unit.
void api_edit_unit_moving_disallow(lua_State *L, Unit *punit)
Prohibit unit from moving.
void api_edit_create_city(lua_State *L, Player *pplayer, Tile *ptile, const char *name)
Create a new city.
void api_edit_change_gold(lua_State *L, Player *pplayer, int amount)
Change pplayer's gold by amount.
void api_edit_create_base(lua_State *L, Tile *ptile, const char *name, Player *pplayer)
Create a new base.
@ CLIMATE_CHANGE_GLOBAL_WARMING
@ CLIMATE_CHANGE_NUCLEAR_WINTER
bool unleash_barbarians(struct tile *ptile)
Unleash barbarians means give barbarian player some units and move them out of the hut,...
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
bool city_change_size(struct city *pcity, citizens size, struct player *nationality, const char *reason)
Change the city size.
const struct ft_color ftc_server
constexpr auto LOG_NORMAL
void luascript_log(struct fc_lua *fcl, QtMsgType level, const char *format,...)
Print a message to the selected output handle.
struct fc_lua * luascript_get_fcl(lua_State *L)
Get the freeciv lua struct from a lua state.
#define LUASCRIPT_CHECK_STATE(L,...)
#define LUASCRIPT_CHECK_SELF(L, value,...)
#define LUASCRIPT_CHECK_ARG_NIL(L, value, narg, type,...)
#define LUASCRIPT_CHECK_ARG(L, check, narg, msg,...)
#define LUASCRIPT_CHECK(L, check, msg,...)
enum direction8 Direction
void assign_continent_numbers()
Assigns continent and ocean numbers to all tiles, and set map.num_continents and map....
void send_tile_info(struct conn_list *dest, struct tile *ptile, bool send_unknown)
Send tile information to all the clients in dest which know and see the tile.
void send_all_known_tiles(struct conn_list *dest)
Send all tiles known to specified clients.
bool need_to_reassign_continents(const struct terrain *oldter, const struct terrain *newter)
Returns TRUE if the terrain change from 'oldter' to 'newter' may require expensive reassignment of co...
void climate_change(bool warming, int effect)
Do a climate change.
void create_extra(struct tile *ptile, const extra_type *pextra, struct player *pplayer)
Create extra to tile.
void fix_tile_on_terrain_change(struct tile *ptile, struct terrain *oldter, bool extend_rivers)
Handles local side effects for a terrain change (tile and its surroundings).
void update_tile_knowledge(struct tile *ptile)
Update playermap knowledge for everybody who sees the tile, and send a packet to everyone whose info ...
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Return TRUE iff a unit of the given unit type can "exist" at this location.
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Return TRUE iff the unit can "exist" at this location.
const char * nation_plural_for_player(const struct player *pplayer)
Return the (translated) plural noun of the given nation of a player.
void notify_research(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
Sends a message to all players that share research.
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Similar to notify_conn_packet (see also), but takes player as "destination".
void notify_research_embassies(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
Sends a message to all players that have embassies with someone who shares research.
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players can attack each other.
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
void player_status_add(struct player *plr, enum player_status pstatus)
Add a status flag to a player.
struct player * civil_war(struct player *pplayer)
Capturing a nation's primary capital is a devastating blow.
bool civil_war_triggered(struct player *pplayer)
civil_war_triggered: The capture of a primary capital is not a sure fire way to throw and empire into...
bool civil_war_possible(struct player *pplayer, bool conquering_city, bool honour_server_option)
Check if civil war is possible for a player.
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
QString research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Store the translated name of the given tech (including A_FUTURE) in 'buf'.
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Returns state of the tech for current research.
int research_pretty_name(const struct research *presearch, char *buf, size_t buf_len)
Set in 'buf' the name of the research owner.
static void static sol::state * fcl
Lua virtual machine state.
bool game_was_started()
Returns iff the game was started once upon a time.
enum server_states server_state()
Return current server state.
enum rfc_status create_command_newcomer(const char *name, const char *ai, bool check, struct nation_type *pnation, struct player **newplayer, char *buf, size_t buflen)
Try to add a player to a running game in the following order:
enum rfc_status create_command_pregame(const char *name, const char *ai, bool check, struct player **newplayer, char *buf, size_t buflen)
Create player in pregame.
struct civ_game::@28::@32 server
std::vector< ai_trait > traits
struct player_ai ai_common
struct player_economic economic
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
bool is_future_tech(Tech_type_id tech)
Is the given tech a future tech.
struct advance * advance_by_number(const Tech_type_id atype)
Return the advance for the given advance index.
Tech_type_id advance_number(const struct advance *padvance)
Return the advance index.
#define terrain_has_flag(terr, flag)
void tile_change_terrain(struct tile *ptile, struct terrain *pterrain)
Change the terrain to the given type.
bool tile_extra_rm_apply(struct tile *ptile, struct extra_type *tgt)
Remove extra and adjust other extras accordingly.
bool tile_set_label(struct tile *ptile, const char *label)
Sets label for tile.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
#define tile_terrain(_tile)
#define tile_has_extra(ptile, pextra)
bool can_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Return TRUE iff the given unit can be loaded into the transporter.
struct unit * is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Is there an non-allied unit on this tile?
void unit_virtual_destroy(struct unit *punit)
Free the memory used by virtual unit.
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Create a virtual unit skeleton.
void unit_tile_set(struct unit *punit, struct tile *ptile)
Set the tile location of the unit.
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
struct unit_type * unit_type_array_first()
Return the first item of unit_types.
const struct unit_type * unit_type_array_last()
Return the last item of unit_types.
const char * utype_rule_name(const struct unit_type *punittype)
Return the (untranslated) rule name of the unit type.
int num_role_units(int role)
How many unit types have specified role/flag.
struct unit_class * unit_class_get(const struct unit *punit)
Returns unit class pointer for a unit.
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Return whether the unit has the given flag.
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)