WildWeazel
Carthago Creanda Est
Discuss it here!
Summary TBA
Summary TBA
Last edited:
if (is_non_attack_city_tile(ptile, pplayer)
|| (is_non_allied_city_tile(ptile, pplayer)
&& (pplayer->ai_common.barbarian_type == ANIMAL_BARBARIAN
|| !uclass_has_flag(unit_class_get(punit),
UCF_CAN_OCCUPY_CITY)
|| unit_has_type_flag(punit, UTYF_CIVILIAN)))
|| is_non_allied_unit_tile(ptile, pplayer)) {
map_show_circle(pplayer, ptile, unit_type_get(punit)->vision_radius_sq);
maybe_make_contact(ptile, pplayer);
notify_player(pplayer, ptile, E_UNIT_LOST_MISC, ftc_server,
_("Your %s was killed by enemy units at the "
"paradrop destination."),
unit_tile_link(punit));
/* TODO: Should defender score.units_killed get increased too?
* What if there's units of several allied players? Should the
* city owner or owner of the first/random unit get the kill? */
pplayer->score.units_lost++;
server_remove_unit(punit, ULR_KILLED);
return TRUE;
}
/*************************************************************************//**
Move a unit.
*****************************************************************************/
bool api_edit_unit_move_old(lua_State *L, Unit *punit, Tile *ptile,
int movecost)
{
struct city *pcity;
deprecated_semantic_warning("edit.unit_move(unit, moveto, movecost)",
"Unit:move(moveto, movecost)", "3.1");
LUASCRIPT_CHECK_STATE(L, FALSE);
LUASCRIPT_CHECK_SELF(L, punit, FALSE);
LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, FALSE);
LUASCRIPT_CHECK_ARG(L, movecost >= 0, 4, "Negative move cost!", FALSE);
return unit_move(punit, ptile, movecost,
/* Auto embark kept for backward compatibility. I have
* no objection if you see the old behavior as a bug and
* remove auto embarking completely or for transports
* the unit can't legally board. -- Sveinung */
NULL, TRUE,
/* Backwards compatibility for old scripts in rulesets
* and (scenario) savegames. I have no objection if you
* see the old behavior as a bug and remove auto
* conquering completely or for cities the unit can't
* legally conquer. -- Sveinung */
((pcity = tile_city(ptile))
&& (unit_owner(punit)->ai_common.barbarian_type
!= ANIMAL_BARBARIAN)
&& uclass_has_flag(unit_class_get(punit),
UCF_CAN_OCCUPY_CITY)
&& !unit_has_type_flag(punit, UTYF_CIVILIAN)
&& pplayers_at_war(unit_owner(punit),
city_owner(pcity))),
(extra_owner(ptile) == NULL
|| pplayers_at_war(extra_owner(ptile),
unit_owner(punit)))
&& tile_has_claimable_base(ptile, unit_type_get(punit)),
/* Backwards compatibility: unit_enter_hut() would
* return without doing anything if the unit was
* HUT_NOTHING. Setting this parameter to FALSE makes
* sure unit_enter_hut() isn't called. */
unit_can_do_action_result(punit, ACTRES_HUT_ENTER),
unit_can_do_action_result(punit, ACTRES_HUT_FRIGHTEN));
}
/**********************************************************************//**
Moves a unit. No checks whatsoever! This is meant as a practical
function for other functions, like do_airline, which do the checking
themselves.
If you move a unit you should always use this function, as it also sets
the transport status of the unit correctly. Note that the source tile (the
current tile of the unit) and pdesttile need not be adjacent.
Returns TRUE iff unit still alive.
**************************************************************************/
bool unit_move(struct unit *punit, struct tile *pdesttile, int move_cost,
struct unit *embark_to, bool find_embark_target,
bool conquer_city_allowed, bool conquer_extras_allowed,
bool enter_hut, bool frighten_hut)
/**********************************************************************//**
Go by airline, if both cities have an airport and neither has been used this
turn the unit will be transported by it and have its moves set to 0
**************************************************************************/
bool do_airline(struct unit *punit, struct city *pdest_city,
const struct action *paction)
{
struct city *psrc_city = tile_city(unit_tile(punit));
notify_player(unit_owner(punit), city_tile(pdest_city),
E_UNIT_RELOCATED, ftc_server,
_("%s transported successfully."),
unit_link(punit));
unit_move(punit, pdest_city->tile, punit->moves_left,
NULL, BV_ISSET(paction->sub_results, ACT_SUB_RES_MAY_EMBARK),
/* Can only airlift to allied and domestic cities */
FALSE, FALSE,
BV_ISSET(paction->sub_results, ACT_SUB_RES_HUT_ENTER),
BV_ISSET(paction->sub_results, ACT_SUB_RES_HUT_FRIGHTEN));
/* Update airlift fields. */
if (!(game.info.airlifting_style & AIRLIFTING_UNLIMITED_SRC)) {
psrc_city->airlift--;
send_city_info(city_owner(psrc_city), psrc_city);
}
if (!(game.info.airlifting_style & AIRLIFTING_UNLIMITED_DEST)) {
pdest_city->airlift--;
send_city_info(city_owner(pdest_city), pdest_city);
}
return TRUE;
}
Hehe, that's my preference, too... There is an old saying, that describes it pretty well:I'd probably rather dive into a C codebase than C++