Feature #461 » 0047-Unhardcode-wld.map-from-is_action_enabled_unit_on_se.patch
ai/default/daicity.c | ||
---|---|---|
/* Try to disband even if all shields will be wasted. */
|
||
if (unit_can_do_action(punit, ACTION_DISBAND_UNIT)) {
|
||
if (is_action_enabled_unit_on_self(ACTION_DISBAND_UNIT, punit)) {
|
||
if (is_action_enabled_unit_on_self(nmap, ACTION_DISBAND_UNIT, punit)) {
|
||
if (unit_perform_action(owner, punit->id, punit->id,
|
||
0, NULL, ACTION_DISBAND_UNIT, requester)) {
|
||
/* All shields wasted. The unit did Disband Unit. */
|
common/actions.c | ||
---|---|---|
}
|
||
break;
|
||
case ATK_SELF:
|
||
if (is_action_enabled_unit_on_self(blocker->id, actor_unit)) {
|
||
if (is_action_enabled_unit_on_self(nmap, blocker->id, actor_unit)) {
|
||
return blocker;
|
||
}
|
||
break;
|
||
... | ... | |
See note in is_action_enabled() for why the action still may be
|
||
disabled.
|
||
**************************************************************************/
|
||
bool is_action_enabled_unit_on_self(const action_id wanted_action,
|
||
bool is_action_enabled_unit_on_self(const struct civ_map *nmap,
|
||
const action_id wanted_action,
|
||
const struct unit *actor_unit)
|
||
{
|
||
const struct civ_map *nmap = &(wld.map);
|
||
return is_action_enabled_unit_on_self_full(nmap, wanted_action, actor_unit,
|
||
unit_home(actor_unit),
|
||
unit_tile(actor_unit));
|
common/actions.h | ||
---|---|---|
const struct tile *target,
|
||
const struct extra_type *tgt_extra);
|
||
bool is_action_enabled_unit_on_self(const action_id wanted_action,
|
||
bool is_action_enabled_unit_on_self(const struct civ_map *nmap,
|
||
const action_id wanted_action,
|
||
const struct unit *actor_unit);
|
||
struct act_prob action_prob_vs_city(const struct unit* actor,
|
common/unit.c | ||
---|---|---|
/* The call below doesn't support actor tile speculation. */
|
||
fc_assert_msg(unit_tile(punit) == ptile,
|
||
"Please use action_speculate_unit_on_self()");
|
||
return is_action_enabled_unit_on_self(ACTION_FORTIFY,
|
||
return is_action_enabled_unit_on_self(nmap, ACTION_FORTIFY,
|
||
punit);
|
||
case ACTIVITY_FORTIFIED:
|
||
... | ... | |
/* The call below doesn't support actor tile speculation. */
|
||
fc_assert_msg(unit_tile(punit) == ptile,
|
||
"Please use action_speculate_unit_on_self()");
|
||
return is_action_enabled_unit_on_self(ACTION_CONVERT, punit);
|
||
return is_action_enabled_unit_on_self(nmap, ACTION_CONVERT, punit);
|
||
case ACTIVITY_LAST:
|
||
break;
|
server/actiontools.c | ||
---|---|---|
break;
|
||
case ATK_SELF:
|
||
if (actor
|
||
&& is_action_enabled_unit_on_self(act, actor)) {
|
||
&& is_action_enabled_unit_on_self(nmap, act, actor)) {
|
||
perform_action_to(act, actor, actor->id, EXTRA_NONE);
|
||
}
|
||
break;
|
||
... | ... | |
break;
|
||
case ATK_SELF:
|
||
if (actor
|
||
&& is_action_enabled_unit_on_self(act, actor)) {
|
||
&& is_action_enabled_unit_on_self(nmap, act, actor)) {
|
||
current = action_prob_self(actor, act);
|
||
}
|
||
break;
|
server/scripting/api_server_edit.c | ||
---|---|---|
bool api_edit_perform_action_unit_vs_self(lua_State *L, Unit *punit,
|
||
Action *paction)
|
||
{
|
||
const struct civ_map *nmap = &(wld.map);
|
||
LUASCRIPT_CHECK_STATE(L, FALSE);
|
||
LUASCRIPT_CHECK_ARG_NIL(L, punit, 2, Unit, FALSE);
|
||
LUASCRIPT_CHECK_ARG_NIL(L, paction, 3, Action, FALSE);
|
||
... | ... | |
fc_assert_ret_val(action_get_actor_kind(paction) == AAK_UNIT, FALSE);
|
||
fc_assert_ret_val(action_get_target_kind(paction) == ATK_SELF, FALSE);
|
||
fc_assert_ret_val(!action_has_result(paction, ACTRES_FOUND_CITY), FALSE);
|
||
if (is_action_enabled_unit_on_self(paction->id, punit)) {
|
||
if (is_action_enabled_unit_on_self(nmap, paction->id, punit)) {
|
||
return unit_perform_action(unit_owner(punit), punit->id,
|
||
IDENTITY_NUMBER_ZERO, IDENTITY_NUMBER_ZERO,
|
||
"",
|
server/unithand.c | ||
---|---|---|
#define ACTION_PERFORM_UNIT_SELF(action, actor, action_performer) \
|
||
if (actor_unit \
|
||
&& is_action_enabled_unit_on_self(action_type, actor_unit)) { \
|
||
&& is_action_enabled_unit_on_self(nmap, action_type, actor_unit)) { \
|
||
bool success; \
|
||
script_server_signal_emit("action_started_unit_self", \
|
||
action_by_number(action), actor); \
|
server/unittools.c | ||
---|---|---|
const struct veteran_system *vsystem;
|
||
const struct veteran_level *vlevel;
|
||
int chance;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
fc_assert_ret_val(punit != NULL, FALSE);
|
||
... | ... | |
fc_assert_ret_val(vlevel != NULL, FALSE);
|
||
if (punit->veteran + 1 >= vsystem->levels
|
||
|| !is_action_enabled_unit_on_self(ACTION_GAIN_VETERANCY, punit)) {
|
||
|| !is_action_enabled_unit_on_self(nmap, ACTION_GAIN_VETERANCY, punit)) {
|
||
return FALSE;
|
||
} else if (!settler) {
|
||
int mod = base_chance + get_unit_bonus(punit, EFT_VETERAN_COMBAT);
|
||
... | ... | |
bool escaped;
|
||
bool flagless_killer = unit_has_type_flag(pkiller, UTYF_FLAGLESS);
|
||
bool flagless_victim = unit_has_type_flag(punit, UTYF_FLAGLESS);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
sz_strlcpy(pkiller_link, unit_link(pkiller));
|
||
sz_strlcpy(punit_link, unit_tile_link(punit));
|
||
... | ... | |
&& is_unit_reachable_at(vunit, pkiller, deftile)) {
|
||
escaped = FALSE;
|
||
if (is_action_enabled_unit_on_self(ACTION_ESCAPE, vunit)
|
||
if (is_action_enabled_unit_on_self(nmap, ACTION_ESCAPE, vunit)
|
||
&& !unit_has_type_flag(pkiller, UTYF_CANKILLESCAPING)
|
||
&& vunit->hp > 0
|
||
&& vunit->moves_left > pkiller->moves_left
|
||
... | ... | |
fc_assert(vunit->hp > 0);
|
||
adjc_iterate(&(wld.map), deftile, ptile2) {
|
||
if (can_exist_at_tile(&(wld.map), vunit->utype, ptile2)
|
||
adjc_iterate(nmap, deftile, ptile2) {
|
||
if (can_exist_at_tile(nmap, vunit->utype, ptile2)
|
||
&& NULL == tile_city(ptile2)) {
|
||
move_cost = map_move_cost_unit(&(wld.map), vunit, ptile2);
|
||
move_cost = map_move_cost_unit(nmap, vunit, ptile2);
|
||
if (pkiller->moves_left <= vunit->moves_left - move_cost
|
||
&& (is_allied_unit_tile(ptile2, pvictim)
|
||
|| unit_list_size(ptile2->units)) == 0) {
|