Project

General

Profile

Feature #579 » 0075-Unhardcode-wld.map-from-action_prob_vs_stack.patch

main, S3_2 - Marko Lindqvist, 05/09/2024 10:50 PM

View differences:

client/control.c
break;
case ATK_UNITS:
if ((ptile = unit_tile(punit))
&& action_prob_possible(action_prob_vs_stack(punit, act, ptile))) {
&& action_prob_possible(action_prob_vs_stack(nmap, punit, act, ptile))) {
request_do_action(act, punit->id, ptile->index, 0, "");
}
break;
common/actions.c
Get the actor unit's probability of successfully performing the chosen
action on all units at the target tile.
**************************************************************************/
struct act_prob action_prob_vs_stack(const struct unit *actor_unit,
struct act_prob action_prob_vs_stack(const struct civ_map *nmap,
const struct unit *actor_unit,
const action_id act_id,
const struct tile *target_tile)
{
const struct civ_map *nmap = &(wld.map);
return action_prob_vs_stack_full(nmap, actor_unit,
unit_home(actor_unit),
unit_tile(actor_unit),
......
switch (action_get_target_kind(paction)) {
case ATK_UNITS:
if (tgt_tile) {
prob = action_prob_vs_stack(act_unit, paction->id, tgt_tile);
prob = action_prob_vs_stack(nmap, act_unit, paction->id, tgt_tile);
}
break;
case ATK_TILE:
common/actions.h
const action_id act_id,
const struct unit *victim);
struct act_prob action_prob_vs_stack(const struct unit* actor,
struct act_prob action_prob_vs_stack(const struct civ_map *nmap,
const struct unit* actor,
const action_id act_id,
const struct tile* victims);
server/actiontools.c
const struct extra_type *target_extra,
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 NULL;
......
prob = action_prob_vs_extras(actor, act, target, target_extra);
break;
case ATK_UNITS:
prob = action_prob_vs_stack(actor, act, target);
prob = action_prob_vs_stack(nmap, actor, act, target);
break;
case ATK_CITY:
case ATK_UNIT:
......
case ATK_UNITS:
if (tgt_tile
&& is_action_enabled_unit_on_stack(nmap, act, actor, tgt_tile)) {
current = action_prob_vs_stack(actor, act, tgt_tile);
current = action_prob_vs_stack(nmap, actor, act, tgt_tile);
}
break;
case ATK_TILE:
server/unithand.c
case ATK_UNITS:
if (target_tile) {
/* Calculate the probabilities. */
probabilities[act] = action_prob_vs_stack(actor_unit, act,
probabilities[act] = action_prob_vs_stack(nmap, actor_unit, act,
target_tile);
} else {
/* No target to act against. */
server/unittools.c
switch (action_id_get_target_kind(order.action)) {
case ATK_UNITS:
prob = action_prob_vs_stack(punit, order.action,
prob = action_prob_vs_stack(nmap, punit, order.action,
dst_tile);
tgt_id = dst_tile->index;
break;
......
struct tile *dest = mapstep(&(wld.map), curtile, dirs[choice]);
if (dest != NULL) {
if (action_prob_possible(action_prob_vs_stack(punit, ACTION_ATTACK,
if (action_prob_possible(action_prob_vs_stack(nmap, punit, ACTION_ATTACK,
dest))) {
if (unit_perform_action(pplayer, id, tile_index(dest), NO_TARGET,
"", ACTION_ATTACK, ACT_REQ_RULES)) {
(1-1/2)