Feature #2183 ยป 0066-Add-actres-type-Scout.patch
| ai/default/daicity.c | ||
|---|---|---|
|
/* Could be worse */
|
||
|
case ACTRES_ESTABLISH_EMBASSY:
|
||
|
case ACTRES_SPY_INVESTIGATE_CITY:
|
||
|
case ACTRES_SCOUT:
|
||
|
case ACTRES_MARKETPLACE:
|
||
|
case ACTRES_SPY_ESCAPE:
|
||
|
/* TODO: Individual and well balanced values */
|
||
| ai/default/daidiplomacy.c | ||
|---|---|---|
|
case ACTRES_TRANSPORT_EMBARK:
|
||
|
case ACTRES_HUT_ENTER:
|
||
|
case ACTRES_HUT_FRIGHTEN:
|
||
|
case ACTRES_SCOUT:
|
||
|
case ACTRES_ENABLER_CHECK:
|
||
|
case ACTRES_NONE:
|
||
|
/* Various */
|
||
| common/actions.c | ||
|---|---|---|
|
case ACTRES_UNIT_MOVE:
|
||
|
case ACTRES_TELEPORT:
|
||
|
case ACTRES_TELEPORT_CONQUER:
|
||
|
case ACTRES_SCOUT:
|
||
|
case ACTRES_ENABLER_CHECK:
|
||
|
case ACTRES_NONE:
|
||
|
/* No hard unit type requirements. */
|
||
| ... | ... | |
|
case ACTRES_SPY_ATTACK:
|
||
|
case ACTRES_HUT_ENTER:
|
||
|
case ACTRES_HUT_FRIGHTEN:
|
||
|
case ACTRES_SCOUT:
|
||
|
case ACTRES_ENABLER_CHECK:
|
||
|
case ACTRES_NONE:
|
||
|
/* No hard unit requirements. */
|
||
| ... | ... | |
|
case ACTRES_TELEPORT_CONQUER:
|
||
|
chance = ACTPROB_CERTAIN;
|
||
|
break;
|
||
|
case ACTRES_SCOUT:
|
||
|
chance = ACTPROB_CERTAIN;
|
||
|
break;
|
||
|
/* Not UI action, so chance is meaningless */
|
||
|
case ACTRES_ENABLER_CHECK:
|
||
|
chance = ACTPROB_CERTAIN;
|
||
| common/actres.c | ||
|---|---|---|
|
{ ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TELEPORT_CONQUER */
|
||
|
FALSE, ACTIVITY_LAST, DRT_NONE,
|
||
|
EC_NONE, ERM_NONE, ATK_TILE },
|
||
|
{ ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_SCOUT */
|
||
|
FALSE, ACTIVITY_LAST, DRT_NONE,
|
||
|
EC_NONE, ERM_NONE, ATK_TILE },
|
||
|
{ ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_ENABLER_CHECK */
|
||
|
FALSE, ACTIVITY_LAST, DRT_NONE,
|
||
|
EC_NONE, ERM_NONE, ATK_SELF }
|
||
| ... | ... | |
|
case ACTRES_JOIN_CITY:
|
||
|
case ACTRES_STEAL_MAPS:
|
||
|
case ACTRES_BOMBARD:
|
||
|
case ACTRES_SCOUT:
|
||
|
case ACTRES_SPY_NUKE:
|
||
|
case ACTRES_DESTROY_CITY:
|
||
|
case ACTRES_EXPEL_UNIT:
|
||
| ... | ... | |
|
case ACTRES_DISBAND_UNIT_RECOVER:
|
||
|
return RS_DEFAULT_ACTION_MAX_RANGE;
|
||
|
case ACTRES_BOMBARD:
|
||
|
case ACTRES_SCOUT:
|
||
|
return RS_DEFAULT_ACTION_MAX_RANGE;
|
||
|
case ACTRES_NUKE:
|
||
|
return RS_DEFAULT_EXPLODE_NUCLEAR_MAX_RANGE;
|
||
| ... | ... | |
|
case ACTRES_UNIT_MOVE:
|
||
|
case ACTRES_TELEPORT:
|
||
|
case ACTRES_TELEPORT_CONQUER:
|
||
|
case ACTRES_SCOUT:
|
||
|
return tgt_kind == ATK_TILE;
|
||
|
case ACTRES_CONQUER_EXTRAS:
|
||
|
return tgt_kind == ATK_EXTRAS;
|
||
| ... | ... | |
|
case ACTRES_UNIT_MOVE:
|
||
|
case ACTRES_TELEPORT:
|
||
|
case ACTRES_TELEPORT_CONQUER:
|
||
|
case ACTRES_SCOUT:
|
||
|
case ACTRES_ENABLER_CHECK:
|
||
|
case ACTRES_SPY_ESCAPE:
|
||
|
return ASTK_NONE;
|
||
| ... | ... | |
|
case ACTRES_STRIKE_PRODUCTION:
|
||
|
case ACTRES_FORTIFY:
|
||
|
case ACTRES_HOMELESS:
|
||
|
case ACTRES_SCOUT:
|
||
|
case ACTRES_ENABLER_CHECK:
|
||
|
case ACTRES_NONE:
|
||
|
/* No known hard coded requirements. */
|
||
| common/unit.c | ||
|---|---|---|
|
punit->server.ord_city = 0;
|
||
|
punit->server.vision = nullptr; /* No vision. */
|
||
|
punit->server.scout_vision = nullptr;
|
||
|
punit->server.action_timestamp = 0;
|
||
|
/* Must be an invalid turn number, and an invalid previous turn
|
||
|
* number. */
|
||
| common/unit.h | ||
|---|---|---|
|
int ord_city;
|
||
|
struct vision *vision;
|
||
|
struct vision *scout_vision;
|
||
|
time_t action_timestamp;
|
||
|
int action_turn;
|
||
|
struct unit_move_data *moving;
|
||
| gen_headers/enums/fc_types_enums.def | ||
|---|---|---|
|
/* TODO: Move close to "Move" */
|
||
|
TELEPORT "Teleport"
|
||
|
TELEPORT_CONQUER "Teleport Conquer"
|
||
|
SCOUT "Scout"
|
||
|
/* Hardcoded action that's just controlled by enablers */
|
||
|
ENABLER_CHECK
|
||
| server/advisors/advdata.c | ||
|---|---|---|
|
case ACTRES_UNIT_MOVE:
|
||
|
case ACTRES_TELEPORT:
|
||
|
case ACTRES_TELEPORT_CONQUER:
|
||
|
case ACTRES_SCOUT:
|
||
|
case ACTRES_ENABLER_CHECK:
|
||
|
case ACTRES_MARKETPLACE:
|
||
|
case ACTRES_FOUND_CITY:
|
||
| server/unithand.c | ||
|---|---|---|
|
static bool do_action_activity_targeted(struct unit *punit,
|
||
|
const struct action *paction,
|
||
|
struct extra_type **new_target);
|
||
|
static bool do_scout(struct unit *punit, struct tile *ptile,
|
||
|
const struct action *paction);
|
||
|
static inline bool
|
||
|
non_allied_not_listed_at(const struct player *pplayer,
|
||
|
const int *list, int n, const struct tile *ptile);
|
||
| ... | ... | |
|
case ACTRES_PARADROP_CONQUER:
|
||
|
/* Target is a tile but a city can block it. */
|
||
|
fc_assert_action(action_get_target_kind(paction) == ATK_TILE, break);
|
||
|
if (target_tile != nullptr
|
||
|
&& map_is_known_and_seen(target_tile, actor_player, V_MAIN)) {
|
||
|
/* Seen tile unit savers */
|
||
| ... | ... | |
|
case ACTRES_UNIT_MOVE:
|
||
|
case ACTRES_TELEPORT:
|
||
|
case ACTRES_TELEPORT_CONQUER:
|
||
|
case ACTRES_SCOUT:
|
||
|
case ACTRES_ENABLER_CHECK:
|
||
|
case ACTRES_SPY_ESCAPE:
|
||
|
case ACTRES_NONE:
|
||
| ... | ... | |
|
paction->result == ACTRES_TELEPORT_CONQUER,
|
||
|
FALSE, FALSE));
|
||
|
break;
|
||
|
case ACTRES_SCOUT:
|
||
|
ACTION_PERFORM_UNIT_TILE(action_type, actor_unit, target_tile,
|
||
|
do_scout(actor_unit, target_tile, paction));
|
||
|
break;
|
||
|
case ACTRES_TRANSFORM_TERRAIN:
|
||
|
ACTION_PERFORM_UNIT_TILE(action_type, actor_unit, target_tile,
|
||
|
do_action_activity(actor_unit, paction));
|
||
| ... | ... | |
|
}
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Perform a scout action.
|
||
|
Returns TRUE iff action could be done, FALSE if it couldn't. Even if
|
||
|
this returns TRUE, unit may have died during the action.
|
||
|
**************************************************************************/
|
||
|
static bool do_scout(struct unit *punit, struct tile *ptile,
|
||
|
const struct action *paction)
|
||
|
{
|
||
|
struct player *owner = unit_owner(punit);
|
||
|
if (punit->server.scout_vision != nullptr
|
||
|
&& punit->server.scout_vision->tile != ptile) {
|
||
|
vision_free(punit->server.scout_vision);
|
||
|
punit->server.scout_vision = nullptr;
|
||
|
}
|
||
|
if (punit->server.scout_vision == nullptr) {
|
||
|
const v_radius_t radius_sq = V_RADIUS(5, 0, 0);
|
||
|
punit->server.scout_vision = vision_new(owner, ptile);
|
||
|
vision_reveal_tiles(punit->server.scout_vision, TRUE);
|
||
|
vision_change_sight(punit->server.scout_vision, radius_sq);
|
||
|
}
|
||
|
return TRUE;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Receives route packages.
|
||
|
**************************************************************************/
|
||
| server/unittools.c | ||
|---|---|---|
|
punit->changed_from = punit->activity;
|
||
|
punit->changed_from_target = punit->activity_target;
|
||
|
punit->changed_from_count = punit->activity_count;
|
||
|
if (punit->server.scout_vision != nullptr) {
|
||
|
vision_clear_sight(punit->server.scout_vision);
|
||
|
vision_free(punit->server.scout_vision);
|
||
|
punit->server.scout_vision = nullptr;
|
||
|
}
|
||
|
send_unit_info(nullptr, punit);
|
||
|
} unit_list_iterate_end;
|
||
|
}
|
||
| ... | ... | |
|
vision_free(punit->server.vision);
|
||
|
punit->server.vision = nullptr;
|
||
|
}
|
||
|
if (punit->server.scout_vision != nullptr) {
|
||
|
vision_clear_sight(punit->server.scout_vision);
|
||
|
vision_free(punit->server.scout_vision);
|
||
|
punit->server.scout_vision = nullptr;
|
||
|
}
|
||
|
packet.unit_id = punit->id;
|
||
|
/* Send to onlookers. */
|
||