Project

General

Profile

Feature #549 » 0067-Unhardcode-wld.map-from-action_prob_vs_unit.patch

main, S3_2 - Marko Lindqvist, 05/04/2024 01:52 PM

View differences:

ai/default/aidiplomat.c
pf_path_destroy(path);
}
if (action_prob_possible(action_prob_vs_unit(punit,
if (action_prob_possible(action_prob_vs_unit(nmap, punit,
ACTION_SPY_BRIBE_UNIT,
pvictim))) {
unit_do_action(pplayer, punit->id,
......
} else {
return FALSE;
}
} else if (action_prob_possible(action_prob_vs_unit(punit,
} else if (action_prob_possible(action_prob_vs_unit(nmap, punit,
ACTION_SPY_SABOTAGE_UNIT_ESC,
pvictim))
&& threat) {
ai/default/aiferry.c
action_by_result_iterate(paction, ACTRES_TRANSPORT_BOARD) {
enum gen_action act_id = action_id(paction);
if (action_prob_possible(action_prob_vs_unit(punit, act_id,
if (action_prob_possible(action_prob_vs_unit(nmap, punit, act_id,
ferryboat))) {
if (unit_perform_action(pplayer,
punit->id, ferryboat->id, 0, "",
......
action_by_result_iterate(paction, ACTRES_TRANSPORT_BOARD) {
enum gen_action act_id = action_id(paction);
if (action_prob_possible(action_prob_vs_unit(bodyguard,
if (action_prob_possible(action_prob_vs_unit(nmap, bodyguard,
act_id,
ferryboat))) {
if (unit_perform_action(pplayer,
client/control.c
struct client_disband_unit_data *next;
struct client_disband_unit_data *data = p;
int act;
const struct civ_map *nmap = &(wld.map);
fc_assert_ret(can_client_issue_orders());
......
switch (action_id_get_target_kind(act)) {
case ATK_CITY:
if ((pcity = tile_city(unit_tile(punit)))
&& action_prob_possible(action_prob_vs_city(&(wld.map), punit,
&& action_prob_possible(action_prob_vs_city(nmap, punit,
act, pcity))) {
request_do_action(act, punit->id, pcity->id, 0, "");
}
break;
case ATK_UNIT:
if (action_prob_possible(action_prob_vs_unit(punit, act, punit))) {
if (action_prob_possible(action_prob_vs_unit(nmap, punit, act, punit))) {
request_do_action(act, punit->id, punit->id, 0, "");
}
break;
......
: ACTRES_TRANSPORT_EMBARK) {
enum gen_action act_id = action_id(paction);
if (action_prob_possible(action_prob_vs_unit(pcargo, act_id,
if (action_prob_possible(action_prob_vs_unit(&(wld.map), pcargo, act_id,
ptrans))) {
/* Try the first action that may be legal. */
/* Implement something like do_disband_alternative() if a ruleset
common/actions.c
Get the actor unit's probability of successfully performing the chosen
action on the target unit.
**************************************************************************/
struct act_prob action_prob_vs_unit(const struct unit *actor_unit,
struct act_prob action_prob_vs_unit(const struct civ_map *nmap,
const struct unit *actor_unit,
const action_id act_id,
const struct unit *target_unit)
{
const struct civ_map *nmap = &(wld.map);
return action_prob_vs_unit_full(nmap, actor_unit,
unit_home(actor_unit),
unit_tile(actor_unit),
......
break;
case ATK_UNIT:
if (tgt_unit) {
prob = action_prob_vs_unit(act_unit, paction->id, tgt_unit);
prob = action_prob_vs_unit(nmap, act_unit, paction->id, tgt_unit);
}
break;
case ATK_SELF:
common/actions.h
const action_id act_id,
const struct city *victim);
struct act_prob action_prob_vs_unit(const struct unit* actor,
struct act_prob action_prob_vs_unit(const struct civ_map *nmap,
const struct unit *actor,
const action_id act_id,
const struct unit* victim);
const struct unit *victim);
struct act_prob action_prob_vs_stack(const struct unit* actor,
const action_id act_id,
common/unit.c
ptrans, pcargo));
} else {
return (action_prob_possible(
action_prob_vs_unit(pcargo, ACTION_TRANSPORT_DEBOARD, ptrans))
action_prob_vs_unit(nmap, pcargo, ACTION_TRANSPORT_DEBOARD, ptrans))
|| action_prob_possible(
action_prob_vs_unit(ptrans, ACTION_TRANSPORT_UNLOAD,
action_prob_vs_unit(nmap, ptrans, ACTION_TRANSPORT_UNLOAD,
pcargo)));
}
}
server/actiontools.c
static bool may_unit_act_vs_unit(struct unit *actor, struct unit *target,
bool accept_all_actions)
{
const struct civ_map *nmap = &(wld.map);
if (actor == NULL || target == NULL) {
/* Can't do any actions if actor or target are missing. */
return FALSE;
......
continue;
}
if (action_prob_possible(action_prob_vs_unit(actor, act, target))) {
if (action_prob_possible(action_prob_vs_unit(nmap, actor, act, target))) {
/* The actor unit may be able to do this action to the target
* unit. */
return TRUE;
......
case ATK_UNIT:
if (tgt_unit
&& is_action_enabled_unit_on_unit(nmap, act, actor, tgt_unit)) {
current = action_prob_vs_unit(actor, act, tgt_unit);
current = action_prob_vs_unit(nmap, actor, act, tgt_unit);
}
break;
case ATK_SELF:
server/unithand.c
case ATK_UNIT:
if (target_unit) {
/* Calculate the probabilities. */
probabilities[act] = action_prob_vs_unit(actor_unit, act,
probabilities[act] = action_prob_vs_unit(nmap, actor_unit, act,
target_unit);
} else {
/* No target to act against. */
server/unittools.c
tgt_id = tgt_city->id;
break;
case ATK_UNIT:
prob = action_prob_vs_unit(punit, order.action,
prob = action_prob_vs_unit(nmap, punit, order.action,
tgt_unit);
tgt_id = tgt_unit->id;
(1-1/2)