|
Defines |
#define | DEF_ACTION(name, code, args, prepfn, netprepfn, DOFN, checkfn, ARGDECL, doc) extern int DOFN ARGDECL; |
#define | DEF_ACTION(NAME, CODE, ARGS, prepfn, netprepfn, dofn, checkfn, argdecl, doc) { CODE, NAME, ARGS }, |
Functions |
int | could_take_from_treasury (int u, int m) |
| Could u take m from treasury, assuming side has treasury?
|
int | could_take_from_treasury (int u, Side *side, int m) |
| Could u on a given side take m from treasury?
|
int | could_take_directly_from_treasury (int u, int m) |
| Could u take m directly from treasury, assuming side has treasury?
|
int | could_take_directly_from_treasury (int u, Side *side, int m) |
| Could u on a given side take m directly from treasury?
|
int | could_give_to_treasury (int u, int m) |
| Could u give m to treasury, assuming side has treasury?
|
int | could_give_to_treasury (int u, Side *side, int m) |
| Could u on a given side give m to treasury?
|
int | could_give_directly_to_treasury (int u, int m) |
| Could u give m directly to treasury, assuming side has treasury?
|
int | could_give_directly_to_treasury (int u, Side *side, int m) |
| Could u on a given side give m directly to treasury?
|
void | get_materials_availability (Unit *actor, Unit *agent, long *p_mavail, long *p_mavailmax, int flags) |
| What are current and max materials availabilities for an actor-agent pair?
|
int | can_meet_materials_requirement (long *p_mreq, long *p_mavail, long *p_mavailmax) |
| Is materials requirement satisfied by availabilities?
|
void | consume_materials (Unit *actor, Unit *consumer, int(*getter)(int u, int m), int u3, int mult) |
| Consume materials of a given unit with a given consumption getter.
|
void | consume_materials (Unit *actor, Unit *consumer, long *p_mreq) |
| Consume materials of a given unit according to given consumption vector.
|
int | has_supply_to_act (Unit *unit) |
| Does unit has enough of each material needed to act?
|
int | can_act (Unit *actor, Unit *agent) |
int | has_enough_tooling (Unit *constructor, int u2) |
| Does the constructor have enough tooling to construct u2?
|
int | could_toolup_for (int u, int u2) |
| Could u toolup for u2?
|
int | could_toolup_for_any (int u) |
| Could u toolup for any utype?
|
int | can_toolup_for (Unit *actor, Unit *constructor, int u3) |
| Can given actor-constructor pair toolup for given utype?
|
int | could_create (int u, int u2) |
| Could u create u2?
|
int | could_create_any (int u) |
| Could u create any utype?
|
int | can_create_common (Unit *actor, Unit *creator, int u3, int x, int y, int could, int acpcost_spcl, long *p_mreq_spcl) |
| Can given actor-creator pair create given utype?
|
int | could_build (int u, int u2) |
| Could u build u2?
|
int | could_build_any (int u) |
| Could u build any utype?
|
int | can_build (Unit *actor, Unit *builder, int u3) |
| Can given actor-builder pair build on a given utype?
|
int | can_build (Unit *actor, Unit *builder, Unit *buildee, int could, int acpcost_spcl, long *p_mreq_spcl) |
| Can given actor-builder pair build on a given unit?
|
int | could_auto_repair (int u, int u2) |
| Could u auto-repair u2?
|
int | can_auto_repair (Unit *repairer, Unit *repairee) |
| Can given repairer auto-repair given repairee?
|
int | could_repair (int u, int u2) |
| Could u explicitly repair u2?
|
int | can_repair (Unit *actor, Unit *repairer, int u3) |
| Can given actor-repairer pair explicitly repair given utype?
|
int | can_repair (Unit *actor, Unit *repairer, Unit *repairee) |
| Can given repairer explicitly repair given repairee?
|
int | can_change_type_to (int u, int u2, Side *side) |
int | can_change_type_to (Unit *actor, Unit *morpher, int u3) |
| Can given unit change into given utype?
|
void | init_actions (void) |
| Action Initialization.
|
int | prep_none_action (Unit *unit, Unit *actee) |
| Prepare for No Action.
|
int | do_none_action (Unit *unit, Unit *actee) |
| Do No Action.
|
int | check_none_action (Unit *unit, Unit *actee) |
| Check for No Action.
|
int | prep_produce_action (Unit *unit, Unit *producer, int m, int amount) |
| Prepare for Material Production Action.
|
int | do_produce_action (Unit *unit, Unit *producer, int m, int amount) |
| Do Material Production Action.
|
int | check_produce_action (Unit *unit, Unit *producer, int m, int amount) |
| Check for Material Production Action.
|
int | prep_extract_action (Unit *unit, Unit *extractor, int x, int y, int m, int amount) |
| Prepare for Terrain Extraction Action.
|
int | do_extract_action (Unit *unit, Unit *extractor, int x, int y, int m, int amount) |
| Do Terrain Material Extraction Action.
|
int | check_extract_action (Unit *unit, Unit *extractor, int x, int y, int m, int amount) |
| Check for Terrain Material Estraction Action.
|
int | prep_transfer_action (Unit *unit, Unit *from, int m, int amount, Unit *to) |
| Prepare for Material Transfer Action.
|
int | do_transfer_action (Unit *unit, Unit *from, int m, int amount, Unit *to) |
| Do Material Transfer Action.
|
int | check_transfer_action (Unit *unit, Unit *from, int m, int amount, Unit *to) |
| Check for Material Transfer Action.
|
int | transfer_supply (Unit *from, Unit *to, int m, int amount) |
| Transfer Supply.
|
int | prep_develop_action (Unit *unit, Unit *developer, int new_u) |
| Prepare for technical Development Action.
|
int | do_develop_action (Unit *unit, Unit *developer, int new_u) |
| Do Technical Development Action.
|
int | check_develop_action (Unit *unit, Unit *developer, int new_u) |
| Check for Technical Development Action.
|
int | prep_toolup_action (Unit *actor, Unit *constructor, int u3) |
| Prepare for Toolup Action.
|
int | do_toolup_action (Unit *actor, Unit *constructor, int u3) |
| Do Toolup Action.
|
int | check_toolup_action (Unit *actor, Unit *constructor, int u3) |
| Check Toolup Action.
|
int | prep_create_in_action (Unit *unit, Unit *creator, int new_u, Unit *dest) |
| Prepare for Create In Unit Action.
|
int | do_create_in_action (Unit *actor, Unit *creator, int u3, Unit *transport) |
| Do Create In Unit Action.
|
int | check_create_in_action (Unit *actor, Unit *creator, int uc, Unit *transport) |
| Check for Create in Unit Action.
|
int | prep_create_at_action (Unit *unit, Unit *creator, int new_u, int x, int y, int z) |
| Prepare for Create Unit at Location.
|
int | do_create_at_action (Unit *actor, Unit *creator, int u3, int x, int y, int z) |
| Do Create Unit at Location.
|
int | check_create_at_action (Unit *actor, Unit *creator, int u3, int x, int y, int z) |
| Check for Create Unit at Location.
|
int | prep_build_action (Unit *unit, Unit *builder, Unit *newunit) |
| Prepare to Build Unit in Unit.
|
int | do_build_action (Unit *actor, Unit *builder, Unit *newunit) |
| Do Build Unit in Unit Action.
|
void | garrison_unit (Unit *builder, Unit *newunit) |
| Garrison Unit.
|
int | check_build_action (Unit *actor, Unit *builder, Unit *buildee) |
| Check for Build Unit in Unit Action.
|
void | grant_occs_on_completion (Unit *unit) |
void | make_unit_complete (Unit *unit) |
| Complete Unit.
|
int | prep_repair_action (Unit *actor, Unit *repairer, Unit *repairee) |
| Prepare for Unit Repair Action.
|
int | do_repair_action (Unit *acpsrc, Unit *repairer, Unit *repairee) |
| Do Repair Unit Action.
|
int | check_repair_action (Unit *actor, Unit *repairer, Unit *repairee) |
| Check for Repair Unit Action.
|
int | prep_disband_action (Unit *unit, Unit *disbanded) |
| Prepare for Unit Disband Action.
|
int | do_disband_action (Unit *unit, Unit *disbanded) |
| Do Unit Disband Action.
|
int | check_disband_action (Unit *unit, Unit *disbanded) |
int | prep_change_type_action (Unit *unit, Unit *unit2, int u3) |
int | do_change_type_action (Unit *unit, Unit *unit2, int u3) |
int | check_change_type_action (Unit *unit, Unit *unit2, int u3) |
| Check the 'change-type' action.
|
int | prep_change_side_action (Unit *unit, Unit *unit2, Side *side) |
int | do_change_side_action (Unit *unit, Unit *unit2, Side *side) |
int | check_change_side_action (Unit *unit, Unit *unit2, Side *side) |
int | prep_alter_cell_action (Unit *unit, Unit *unit2, int x, int y, int t) |
int | do_alter_cell_action (Unit *unit, Unit *unit2, int x, int y, int t) |
int | check_alter_cell_action (Unit *unit, Unit *unit2, int x, int y, int t) |
int | prep_add_terrain_action (Unit *unit, Unit *unit2, int x, int y, int dir, int t) |
int | do_add_terrain_action (Unit *unit, Unit *unit2, int x, int y, int dir, int t) |
int | check_add_terrain_action (Unit *unit, Unit *unit2, int x, int y, int dir, int t) |
int | prep_remove_terrain_action (Unit *unit, Unit *unit2, int x, int y, int dir, int t) |
int | do_remove_terrain_action (Unit *unit, Unit *unit2, int x, int y, int dir, int t) |
int | check_remove_terrain_action (Unit *unit, Unit *unit2, int x, int y, int dir, int t) |
int | should_play_movies (void) |
| Should action movies be played?
|
int | execute_action (Unit *unit, Action *action) |
int | can_have_enough_acp (Unit *unit, int acp) |
int | type_can_have_enough_acp (int u, int acp) |
int | has_enough_acp (Unit *unit, int acp) |
int | type_max_night_acp_from_any_terrains (int u) |
int | type_max_acp_from_any_occs (int u) |
int | type_max_acp (int u) |
void | use_up_acp (Unit *unit, int acp) |
| Make the consumed acp disappear, but not go below the minimum possible.
|
int | construction_possible (int u2) |
int | any_construction_possible (void) |
int | storage_possible (int m) |
int | any_storage_possible (void) |
char * | action_desig (Action *act) |
Variables |
int | at_turn_start |
ActionDefn | actiondefns [] |
| Action function table.
|
int | retreating |
| Retreat flag.
|
int | retreating_from = NONUTYPE |
| Type of Unit from which a Unit is retreating.
|
char * | actiondesigbuf = NULL |
| Action description buffer.
|
Action * | latest_action |
int * | cache__type_max_night_acp_from_any_terrains = NULL |
int * | cache__type_max_acp_from_any_occs = NULL |
int * | cache__type_max_acp = NULL |
The general theory of actions is that interface or AI code calls, for an action foo, the routine prep_foo_action, which just records the action for later execution. The action loop in run_game eventually calls do_foo_action, which first calls check_foo_action to confirm that the action will succeed. If check_foo_action does not find any errors, then the action cannot fail. The main body of do_foo_action then implements the effects of the action. Interfaces may call check_foo_action freely, but should never call do_foo_action directly.
action.def is used to declare the actions as extern int, as well as defining the action default function array, actiondefns. A macro, ACTION_DEF is redefined to use different portions of it's arguments to define the different types of information to this module.
Each action has an acting unit, which is the unit that schedules the action and supplies the ACP to perform the action. Each action also has an "actee", a unit that actually performs the action (extractor, builder, creator, etc). The two units are currently always identical, but the theoretical possibility of splitting the work in this way is supported by two separate unit arguments in all action functions. It is the status, position, capabilities and available supplies of the "actee" that determines if, how and to what extent the action can be performed, but the action is also limited by the ACPs that are available to the acting unit. Note that the "actee" is called so for historical reasons - a better name would be "actor" since it in most cases is the active unit. One exception is the materials transfer code, where the "actee" is the donor (not necessarily active) of the transferred materials. Another example is the disband action where the "actee" is the unit being disbanded. Other parameters may be defined.