Feature #410 ยป 0057-Unhardcode-wld.map-from-is_action_enabled_unit_on_ex.patch
| ai/default/daitools.c | ||
|---|---|---|
|
unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
|
||
|
0, "", ACTION_TRANSPORT_DISEMBARK4);
|
||
|
} else if (tile_has_claimable_base(ptile, unit_type_get(punit))
|
||
|
&& is_action_enabled_unit_on_extras(ACTION_CONQUER_EXTRAS,
|
||
|
&& is_action_enabled_unit_on_extras(nmap, ACTION_CONQUER_EXTRAS,
|
||
|
punit, ptile, NULL)) {
|
||
|
/* Choose "Conquer Extras". */
|
||
|
unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
|
||
|
0, "", ACTION_CONQUER_EXTRAS);
|
||
|
} else if (tile_has_claimable_base(ptile, unit_type_get(punit))
|
||
|
&& is_action_enabled_unit_on_extras(ACTION_CONQUER_EXTRAS2,
|
||
|
&& is_action_enabled_unit_on_extras(nmap, ACTION_CONQUER_EXTRAS2,
|
||
|
punit, ptile, NULL)) {
|
||
|
/* Choose "Conquer Extras 2". */
|
||
|
unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
|
||
|
0, "", ACTION_CONQUER_EXTRAS2);
|
||
|
} else if (tile_has_claimable_base(ptile, unit_type_get(punit))
|
||
|
&& is_action_enabled_unit_on_extras(ACTION_CONQUER_EXTRAS3,
|
||
|
&& is_action_enabled_unit_on_extras(nmap, ACTION_CONQUER_EXTRAS3,
|
||
|
punit, ptile, NULL)) {
|
||
|
/* Choose "Conquer Extras 3". */
|
||
|
unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
|
||
|
0, "", ACTION_CONQUER_EXTRAS3);
|
||
|
} else if (tile_has_claimable_base(ptile, unit_type_get(punit))
|
||
|
&& is_action_enabled_unit_on_extras(ACTION_CONQUER_EXTRAS4,
|
||
|
&& is_action_enabled_unit_on_extras(nmap, ACTION_CONQUER_EXTRAS4,
|
||
|
punit, ptile, NULL)) {
|
||
|
/* Choose "Conquer Extras 4". */
|
||
|
unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
|
||
| common/actions.c | ||
|---|---|---|
|
/* Can't be enabled. No target. */
|
||
|
continue;
|
||
|
}
|
||
|
if (is_action_enabled_unit_on_extras(blocker->id,
|
||
|
if (is_action_enabled_unit_on_extras(nmap, blocker->id,
|
||
|
actor_unit, target_tile, NULL)) {
|
||
|
return blocker;
|
||
|
}
|
||
| ... | ... | |
|
See note in is_action_enabled() for why the action may still be disabled.
|
||
|
**************************************************************************/
|
||
|
bool is_action_enabled_unit_on_extras(const action_id wanted_action,
|
||
|
bool is_action_enabled_unit_on_extras(const struct civ_map *nmap,
|
||
|
const action_id wanted_action,
|
||
|
const struct unit *actor_unit,
|
||
|
const struct tile *target_tile,
|
||
|
const struct extra_type *target_extra)
|
||
|
{
|
||
|
const struct civ_map *nmap = &(wld.map);
|
||
|
return is_action_enabled_unit_on_extras_full(nmap, wanted_action, actor_unit,
|
||
|
unit_home(actor_unit),
|
||
|
unit_tile(actor_unit),
|
||
| common/actions.h | ||
|---|---|---|
|
const struct tile *target_tile,
|
||
|
const struct extra_type *target_extra);
|
||
|
bool is_action_enabled_unit_on_extras(const action_id wanted_action,
|
||
|
bool is_action_enabled_unit_on_extras(const struct civ_map *nmap,
|
||
|
const action_id wanted_action,
|
||
|
const struct unit *actor_unit,
|
||
|
const struct tile *target,
|
||
|
const struct extra_type *tgt_extra);
|
||
| common/unit.c | ||
|---|---|---|
|
return is_action_enabled_unit_on_tile(nmap, paction->id, \
|
||
|
punit, ptile, target); \
|
||
|
case ATK_EXTRAS: \
|
||
|
return is_action_enabled_unit_on_extras(paction->id, \
|
||
|
return is_action_enabled_unit_on_extras(nmap, paction->id, \
|
||
|
punit, ptile, target); \
|
||
|
case ATK_CITY: \
|
||
|
case ATK_UNIT: \
|
||
| server/actiontools.c | ||
|---|---|---|
|
break;
|
||
|
case ATK_EXTRAS:
|
||
|
if (tgt_tile
|
||
|
&& is_action_enabled_unit_on_extras(act, actor,
|
||
|
&& is_action_enabled_unit_on_extras(nmap, act, actor,
|
||
|
tgt_tile, target_extra)) {
|
||
|
perform_action_to(act, actor, tgt_tile->index,
|
||
|
target_extra ? extra_number(target_extra) : -1);
|
||
| ... | ... | |
|
break;
|
||
|
case ATK_EXTRAS:
|
||
|
if (tgt_tile
|
||
|
&& is_action_enabled_unit_on_extras(act, actor,
|
||
|
&& is_action_enabled_unit_on_extras(nmap, act, actor,
|
||
|
tgt_tile, target_extra)) {
|
||
|
current = action_prob_vs_extras(actor, act,
|
||
|
tgt_tile, target_extra);
|
||
| server/scripting/api_server_edit.c | ||
|---|---|---|
|
tgt, NULL);
|
||
|
break;
|
||
|
case ATK_EXTRAS:
|
||
|
enabled = is_action_enabled_unit_on_extras(paction->id, punit,
|
||
|
enabled = is_action_enabled_unit_on_extras(nmap, paction->id, punit,
|
||
|
tgt, NULL);
|
||
|
break;
|
||
|
case ATK_CITY:
|
||
| ... | ... | |
|
tgt, sub_target);
|
||
|
break;
|
||
|
case ATK_EXTRAS:
|
||
|
enabled = is_action_enabled_unit_on_extras(paction->id, punit,
|
||
|
enabled = is_action_enabled_unit_on_extras(nmap, paction->id, punit,
|
||
|
tgt, sub_target);
|
||
|
break;
|
||
|
case ATK_CITY:
|
||
| server/unithand.c | ||
|---|---|---|
|
#define ACTION_PERFORM_UNIT_EXTRAS(action, actor, target, action_performer)\
|
||
|
if (target_tile \
|
||
|
&& is_action_enabled_unit_on_extras(action_type, \
|
||
|
&& is_action_enabled_unit_on_extras(nmap, action_type, \
|
||
|
actor_unit, target_tile, \
|
||
|
target_extra)) { \
|
||
|
bool success; \
|
||