Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/effects.h Source File

Freeciv-3.1

Loading...
Searching...
No Matches
effects.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13#ifndef FC__EFFECTS_H
14#define FC__EFFECTS_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* utility */
21#include "support.h" /* bool type */
22
23/* common */
24#include "connection.h"
25#include "fc_types.h"
26#include "multipliers.h"
27
28#include "requirements.h"
29
30/* Type of effects. Add new values via SPECENUM_VALUE%d and
31 * SPECENUM_VALUE%dNAME at the end of the list.
32 * Used in the network protocol.
33 *
34 */
35#define SPECENUM_NAME effect_type
36#define SPECENUM_VALUE0 EFT_TECH_PARASITE
37#define SPECENUM_VALUE0NAME "Tech_Parasite"
38#define SPECENUM_VALUE1 EFT_AIRLIFT
39#define SPECENUM_VALUE1NAME "Airlift"
40#define SPECENUM_VALUE2 EFT_ANY_GOVERNMENT
41#define SPECENUM_VALUE2NAME "Any_Government"
42#define SPECENUM_VALUE3 EFT_CAPITAL_CITY
43#define SPECENUM_VALUE3NAME "Capital_City"
44#define SPECENUM_VALUE4 EFT_ENABLE_NUKE
45#define SPECENUM_VALUE4NAME "Enable_Nuke"
46#define SPECENUM_VALUE5 EFT_ENABLE_SPACE
47#define SPECENUM_VALUE5NAME "Enable_Space"
48#define SPECENUM_VALUE6 EFT_SPECIALIST_OUTPUT
49#define SPECENUM_VALUE6NAME "Specialist_Output"
50#define SPECENUM_VALUE7 EFT_OUTPUT_BONUS
51#define SPECENUM_VALUE7NAME "Output_Bonus"
52#define SPECENUM_VALUE8 EFT_OUTPUT_BONUS_2
53#define SPECENUM_VALUE8NAME "Output_Bonus_2"
54/* add to each worked tile */
55#define SPECENUM_VALUE9 EFT_OUTPUT_ADD_TILE
56#define SPECENUM_VALUE9NAME "Output_Add_Tile"
57/* add to each worked tile that already has output */
58#define SPECENUM_VALUE10 EFT_OUTPUT_INC_TILE
59#define SPECENUM_VALUE10NAME "Output_Inc_Tile"
60/* increase tile output by given % */
61#define SPECENUM_VALUE11 EFT_OUTPUT_PER_TILE
62#define SPECENUM_VALUE11NAME "Output_Per_Tile"
63#define SPECENUM_VALUE12 EFT_OUTPUT_WASTE_PCT
64#define SPECENUM_VALUE12NAME "Output_Waste_Pct"
65#define SPECENUM_VALUE13 EFT_FORCE_CONTENT
66#define SPECENUM_VALUE13NAME "Force_Content"
67/* TODO: EFT_FORCE_CONTENT_PCT */
68#define SPECENUM_VALUE14 EFT_GIVE_IMM_TECH
69#define SPECENUM_VALUE14NAME "Give_Imm_Tech"
70#define SPECENUM_VALUE15 EFT_GROWTH_FOOD
71#define SPECENUM_VALUE15NAME "Growth_Food"
72/* reduced illness due to buildings ... */
73#define SPECENUM_VALUE16 EFT_HEALTH_PCT
74#define SPECENUM_VALUE16NAME "Health_Pct"
75#define SPECENUM_VALUE17 EFT_HAVE_EMBASSIES
76#define SPECENUM_VALUE17NAME "Have_Embassies"
77#define SPECENUM_VALUE18 EFT_MAKE_CONTENT
78#define SPECENUM_VALUE18NAME "Make_Content"
79#define SPECENUM_VALUE19 EFT_MAKE_CONTENT_MIL
80#define SPECENUM_VALUE19NAME "Make_Content_Mil"
81#define SPECENUM_VALUE20 EFT_MAKE_CONTENT_MIL_PER
82#define SPECENUM_VALUE20NAME "Make_Content_Mil_Per"
83/* TODO: EFT_MAKE_CONTENT_PCT */
84#define SPECENUM_VALUE21 EFT_MAKE_HAPPY
85#define SPECENUM_VALUE21NAME "Make_Happy"
86#define SPECENUM_VALUE22 EFT_NO_ANARCHY
87#define SPECENUM_VALUE22NAME "No_Anarchy"
88#define SPECENUM_VALUE23 EFT_NUKE_PROOF
89#define SPECENUM_VALUE23NAME "Nuke_Proof"
90/* TODO: EFT_POLLU_ADJ */
91/* TODO: EFT_POLLU_PCT */
92/* TODO: EFT_POLLU_POP_ADJ */
93#define SPECENUM_VALUE24 EFT_POLLU_POP_PCT
94#define SPECENUM_VALUE24NAME "Pollu_Pop_Pct"
95#define SPECENUM_VALUE25 EFT_POLLU_POP_PCT_2
96#define SPECENUM_VALUE25NAME "Pollu_Pop_Pct_2"
97/* TODO: EFT_POLLU_PROD_ADJ */
98#define SPECENUM_VALUE26 EFT_POLLU_PROD_PCT
99#define SPECENUM_VALUE26NAME "Pollu_Prod_Pct"
100/* TODO: EFT_PROD_PCT */
101#define SPECENUM_VALUE27 EFT_REVEAL_CITIES
102#define SPECENUM_VALUE27NAME "Reveal_Cities"
103#define SPECENUM_VALUE28 EFT_REVEAL_MAP
104#define SPECENUM_VALUE28NAME "Reveal_Map"
105/* TODO: EFT_INCITE_DIST_ADJ */
106#define SPECENUM_VALUE29 EFT_INCITE_COST_PCT
107#define SPECENUM_VALUE29NAME "Incite_Cost_Pct"
108#define SPECENUM_VALUE30 EFT_SIZE_ADJ
109#define SPECENUM_VALUE30NAME "Size_Adj"
110#define SPECENUM_VALUE31 EFT_SIZE_UNLIMIT
111#define SPECENUM_VALUE31NAME "Size_Unlimit"
112#define SPECENUM_VALUE32 EFT_SS_STRUCTURAL
113#define SPECENUM_VALUE32NAME "SS_Structural"
114#define SPECENUM_VALUE33 EFT_SS_COMPONENT
115#define SPECENUM_VALUE33NAME "SS_Component"
116#define SPECENUM_VALUE34 EFT_SS_MODULE
117#define SPECENUM_VALUE34NAME "SS_Module"
118#define SPECENUM_VALUE35 EFT_SPY_RESISTANT
119#define SPECENUM_VALUE35NAME "Spy_Resistant"
120#define SPECENUM_VALUE36 EFT_MOVE_BONUS
121#define SPECENUM_VALUE36NAME "Move_Bonus"
122#define SPECENUM_VALUE37 EFT_UNIT_NO_LOSE_POP
123#define SPECENUM_VALUE37NAME "Unit_No_Lose_Pop"
124#define SPECENUM_VALUE38 EFT_UNIT_RECOVER
125#define SPECENUM_VALUE38NAME "Unit_Recover"
126#define SPECENUM_VALUE39 EFT_UPGRADE_UNIT
127#define SPECENUM_VALUE39NAME "Upgrade_Unit"
128#define SPECENUM_VALUE40 EFT_UPKEEP_FREE
129#define SPECENUM_VALUE40NAME "Upkeep_Free"
130#define SPECENUM_VALUE41 EFT_TECH_UPKEEP_FREE
131#define SPECENUM_VALUE41NAME "Tech_Upkeep_Free"
132#define SPECENUM_VALUE42 EFT_NO_UNHAPPY
133#define SPECENUM_VALUE42NAME "No_Unhappy"
134#define SPECENUM_VALUE43 EFT_VETERAN_BUILD
135#define SPECENUM_VALUE43NAME "Veteran_Build"
136#define SPECENUM_VALUE44 EFT_VETERAN_COMBAT
137#define SPECENUM_VALUE44NAME "Veteran_Combat"
138#define SPECENUM_VALUE45 EFT_HP_REGEN
139#define SPECENUM_VALUE45NAME "HP_Regen"
140#define SPECENUM_VALUE46 EFT_CITY_VISION_RADIUS_SQ
141#define SPECENUM_VALUE46NAME "City_Vision_Radius_Sq"
142#define SPECENUM_VALUE47 EFT_UNIT_VISION_RADIUS_SQ
143#define SPECENUM_VALUE47NAME "Unit_Vision_Radius_Sq"
144/* Interacts with UTYF_BADWALLATTACKER */
145#define SPECENUM_VALUE48 EFT_DEFEND_BONUS
146#define SPECENUM_VALUE48NAME "Defend_Bonus"
147#define SPECENUM_VALUE49 EFT_TRADE_ROUTE_PCT
148/* FIXME: -> "Trade_Route_Pct" */
149#define SPECENUM_VALUE49NAME "Traderoute_Pct"
150#define SPECENUM_VALUE50 EFT_GAIN_AI_LOVE
151#define SPECENUM_VALUE50NAME "Gain_AI_Love"
152#define SPECENUM_VALUE51 EFT_TURN_YEARS
153#define SPECENUM_VALUE51NAME "Turn_Years"
154#define SPECENUM_VALUE52 EFT_SLOW_DOWN_TIMELINE
155#define SPECENUM_VALUE52NAME "Slow_Down_Timeline"
156#define SPECENUM_VALUE53 EFT_CIVIL_WAR_CHANCE
157#define SPECENUM_VALUE53NAME "Civil_War_Chance"
158/* change of the migration score */
159#define SPECENUM_VALUE54 EFT_MIGRATION_PCT
160#define SPECENUM_VALUE54NAME "Migration_Pct"
161/* +1 unhappy when more than this cities */
162#define SPECENUM_VALUE55 EFT_EMPIRE_SIZE_BASE
163#define SPECENUM_VALUE55NAME "Empire_Size_Base"
164/* adds additional +1 unhappy steps to above */
165#define SPECENUM_VALUE56 EFT_EMPIRE_SIZE_STEP
166#define SPECENUM_VALUE56NAME "Empire_Size_Step"
167#define SPECENUM_VALUE57 EFT_MAX_RATES
168#define SPECENUM_VALUE57NAME "Max_Rates"
169#define SPECENUM_VALUE58 EFT_MARTIAL_LAW_EACH
170#define SPECENUM_VALUE58NAME "Martial_Law_Each"
171#define SPECENUM_VALUE59 EFT_MARTIAL_LAW_MAX
172#define SPECENUM_VALUE59NAME "Martial_Law_Max"
173#define SPECENUM_VALUE60 EFT_RAPTURE_GROW
174#define SPECENUM_VALUE60NAME "Rapture_Grow"
175#define SPECENUM_VALUE61 EFT_REVOLUTION_UNHAPPINESS
176#define SPECENUM_VALUE61NAME "Revolution_Unhappiness"
177#define SPECENUM_VALUE62 EFT_HAS_SENATE
178#define SPECENUM_VALUE62NAME "Has_Senate"
179#define SPECENUM_VALUE63 EFT_INSPIRE_PARTISANS
180#define SPECENUM_VALUE63NAME "Inspire_Partisans"
181#define SPECENUM_VALUE64 EFT_HAPPINESS_TO_GOLD
182#define SPECENUM_VALUE64NAME "Happiness_To_Gold"
183/* stupid special case; we hate it */
184#define SPECENUM_VALUE65 EFT_FANATICS
185#define SPECENUM_VALUE65NAME "Fanatics"
186#define SPECENUM_VALUE66 EFT_NO_DIPLOMACY
187#define SPECENUM_VALUE66NAME "No_Diplomacy"
188#define SPECENUM_VALUE67 EFT_TRADE_REVENUE_BONUS
189#define SPECENUM_VALUE67NAME "Trade_Revenue_Bonus"
190/* multiply unhappy upkeep by this effect */
191#define SPECENUM_VALUE68 EFT_UNHAPPY_FACTOR
192#define SPECENUM_VALUE68NAME "Unhappy_Factor"
193/* multiply upkeep by this effect */
194#define SPECENUM_VALUE69 EFT_UPKEEP_FACTOR
195#define SPECENUM_VALUE69NAME "Upkeep_Factor"
196/* this many units are free from upkeep */
197#define SPECENUM_VALUE70 EFT_UNIT_UPKEEP_FREE_PER_CITY
198#define SPECENUM_VALUE70NAME "Unit_Upkeep_Free_Per_City"
199#define SPECENUM_VALUE71 EFT_OUTPUT_WASTE
200#define SPECENUM_VALUE71NAME "Output_Waste"
201#define SPECENUM_VALUE72 EFT_OUTPUT_WASTE_BY_DISTANCE
202#define SPECENUM_VALUE72NAME "Output_Waste_By_Distance"
203/* -1 penalty to tiles producing more than this */
204#define SPECENUM_VALUE73 EFT_OUTPUT_PENALTY_TILE
205#define SPECENUM_VALUE73NAME "Output_Penalty_Tile"
206#define SPECENUM_VALUE74 EFT_OUTPUT_INC_TILE_CELEBRATE
207#define SPECENUM_VALUE74NAME "Output_Inc_Tile_Celebrate"
208/* all citizens after this are unhappy */
209#define SPECENUM_VALUE75 EFT_CITY_UNHAPPY_SIZE
210#define SPECENUM_VALUE75NAME "City_Unhappy_Size"
211/* add to default squared city radius */
212#define SPECENUM_VALUE76 EFT_CITY_RADIUS_SQ
213#define SPECENUM_VALUE76NAME "City_Radius_Sq"
214/* number of build slots for units */
215#define SPECENUM_VALUE77 EFT_CITY_BUILD_SLOTS
216#define SPECENUM_VALUE77NAME "City_Build_Slots"
217#define SPECENUM_VALUE78 EFT_UPGRADE_PRICE_PCT
218#define SPECENUM_VALUE78NAME "Upgrade_Price_Pct"
219/* City should use walls gfx */
220#define SPECENUM_VALUE79 EFT_VISIBLE_WALLS
221#define SPECENUM_VALUE79NAME "Visible_Walls"
222#define SPECENUM_VALUE80 EFT_TECH_COST_FACTOR
223#define SPECENUM_VALUE80NAME "Tech_Cost_Factor"
224/* [x%] gold upkeep instead of [1] shield upkeep for units */
225#define SPECENUM_VALUE81 EFT_SHIELD2GOLD_FACTOR
226#define SPECENUM_VALUE81NAME "Shield2Gold_Factor"
227#define SPECENUM_VALUE82 EFT_TILE_WORKABLE
228#define SPECENUM_VALUE82NAME "Tile_Workable"
229/* The index for the city image of the given city style. */
230#define SPECENUM_VALUE83 EFT_CITY_IMAGE
231#define SPECENUM_VALUE83NAME "City_Image"
232#define SPECENUM_VALUE84 EFT_IMPR_BUILD_COST_PCT
233#define SPECENUM_VALUE84NAME "Building_Build_Cost_Pct"
234#define SPECENUM_VALUE85 EFT_MAX_TRADE_ROUTES
235#define SPECENUM_VALUE85NAME "Max_Trade_Routes"
236#define SPECENUM_VALUE86 EFT_GOV_CENTER
237#define SPECENUM_VALUE86NAME "Gov_Center"
238#define SPECENUM_VALUE87 EFT_COMBAT_ROUNDS
239#define SPECENUM_VALUE87NAME "Combat_Rounds"
240#define SPECENUM_VALUE88 EFT_IMPR_BUY_COST_PCT
241#define SPECENUM_VALUE88NAME "Building_Buy_Cost_Pct"
242#define SPECENUM_VALUE89 EFT_UNIT_BUILD_COST_PCT
243#define SPECENUM_VALUE89NAME "Unit_Build_Cost_Pct"
244#define SPECENUM_VALUE90 EFT_UNIT_BUY_COST_PCT
245#define SPECENUM_VALUE90NAME "Unit_Buy_Cost_Pct"
246#define SPECENUM_VALUE91 EFT_NOT_TECH_SOURCE
247#define SPECENUM_VALUE91NAME "Not_Tech_Source"
248#define SPECENUM_VALUE92 EFT_ENEMY_CITIZEN_UNHAPPY_PCT
249#define SPECENUM_VALUE92NAME "Enemy_Citizen_Unhappy_Pct"
250#define SPECENUM_VALUE93 EFT_IRRIGATION_PCT
251#define SPECENUM_VALUE93NAME "Irrigation_Pct"
252#define SPECENUM_VALUE94 EFT_MINING_PCT
253#define SPECENUM_VALUE94NAME "Mining_Pct"
254#define SPECENUM_VALUE95 EFT_OUTPUT_TILE_PUNISH_PCT
255#define SPECENUM_VALUE95NAME "Output_Tile_Punish_Pct"
256#define SPECENUM_VALUE96 EFT_UNIT_BRIBE_COST_PCT
257#define SPECENUM_VALUE96NAME "Unit_Bribe_Cost_Pct"
258#define SPECENUM_VALUE97 EFT_VICTORY
259#define SPECENUM_VALUE97NAME "Victory"
260#define SPECENUM_VALUE98 EFT_PERFORMANCE
261#define SPECENUM_VALUE98NAME "Performance"
262#define SPECENUM_VALUE99 EFT_HISTORY
263#define SPECENUM_VALUE99NAME "History"
264#define SPECENUM_VALUE100 EFT_NATION_PERFORMANCE
265#define SPECENUM_VALUE100NAME "National_Performance"
266#define SPECENUM_VALUE101 EFT_NATION_HISTORY
267#define SPECENUM_VALUE101NAME "National_History"
268#define SPECENUM_VALUE102 EFT_TURN_FRAGMENTS
269#define SPECENUM_VALUE102NAME "Turn_Fragments"
270#define SPECENUM_VALUE103 EFT_MAX_STOLEN_GOLD_PM
271#define SPECENUM_VALUE103NAME "Max_Stolen_Gold_Pm"
272#define SPECENUM_VALUE104 EFT_THIEFS_SHARE_PM
273#define SPECENUM_VALUE104NAME "Thiefs_Share_Pm"
274#define SPECENUM_VALUE105 EFT_RETIRE_PCT
275#define SPECENUM_VALUE105NAME "Retire_Pct"
276#define SPECENUM_VALUE106 EFT_ILLEGAL_ACTION_MOVE_COST
277#define SPECENUM_VALUE106NAME "Illegal_Action_Move_Cost"
278#define SPECENUM_VALUE107 EFT_HAVE_CONTACTS
279#define SPECENUM_VALUE107NAME "Have_Contacts"
280#define SPECENUM_VALUE108 EFT_CASUS_BELLI_CAUGHT
281#define SPECENUM_VALUE108NAME "Casus_Belli_Caught"
282#define SPECENUM_VALUE109 EFT_CASUS_BELLI_SUCCESS
283#define SPECENUM_VALUE109NAME "Casus_Belli_Success"
284#define SPECENUM_VALUE110 EFT_ACTION_ODDS_PCT
285#define SPECENUM_VALUE110NAME "Action_Odds_Pct"
286#define SPECENUM_VALUE111 EFT_BORDER_VISION
287#define SPECENUM_VALUE111NAME "Border_Vision"
288#define SPECENUM_VALUE112 EFT_STEALINGS_IGNORE
289#define SPECENUM_VALUE112NAME "Stealings_Ignore"
290#define SPECENUM_VALUE113 EFT_OUTPUT_WASTE_BY_REL_DISTANCE
291#define SPECENUM_VALUE113NAME "Output_Waste_By_Rel_Distance"
292#define SPECENUM_VALUE114 EFT_SABOTEUR_RESISTANT
293#define SPECENUM_VALUE114NAME "Building_Saboteur_Resistant"
294#define SPECENUM_VALUE115 EFT_UNIT_SLOTS
295#define SPECENUM_VALUE115NAME "Unit_Slots"
296#define SPECENUM_VALUE116 EFT_ATTACK_BONUS
297#define SPECENUM_VALUE116NAME "Attack_Bonus"
298#define SPECENUM_VALUE117 EFT_CONQUEST_TECH_PCT
299#define SPECENUM_VALUE117NAME "Conquest_Tech_Pct"
300#define SPECENUM_VALUE118 EFT_ACTION_SUCCESS_MOVE_COST
301#define SPECENUM_VALUE118NAME "Action_Success_Actor_Move_Cost"
302#define SPECENUM_VALUE119 EFT_ACTION_SUCCESS_TARGET_MOVE_COST
303#define SPECENUM_VALUE119NAME "Action_Success_Target_Move_Cost"
304#define SPECENUM_VALUE120 EFT_INFRA_POINTS
305#define SPECENUM_VALUE120NAME "Infra_Points"
306#define SPECENUM_VALUE121 EFT_FORTIFY_DEFENSE_BONUS
307#define SPECENUM_VALUE121NAME "Fortify_Defense_Bonus"
308#define SPECENUM_VALUE122 EFT_MAPS_STOLEN_PCT
309#define SPECENUM_VALUE122NAME "Maps_Stolen_Pct"
310#define SPECENUM_VALUE123 EFT_UNIT_SHIELD_VALUE_PCT
311#define SPECENUM_VALUE123NAME "Unit_Shield_Value_Pct"
312#define SPECENUM_VALUE124 EFT_CASUS_BELLI_COMPLETE
313#define SPECENUM_VALUE124NAME "Casus_Belli_Complete"
314#define SPECENUM_VALUE125 EFT_ILLEGAL_ACTION_HP_COST
315#define SPECENUM_VALUE125NAME "Illegal_Action_HP_Cost"
316#define SPECENUM_VALUE126 EFT_POPCOST_FREE
317#define SPECENUM_VALUE126NAME "Popcost_Free"
318#define SPECENUM_VALUE127 EFT_HEAL_UNIT_PCT
319#define SPECENUM_VALUE127NAME "Heal_Unit_Pct"
320#define SPECENUM_VALUE128 EFT_MIN_HP_PCT
321#define SPECENUM_VALUE128NAME "Min_HP_Pct"
322#define SPECENUM_VALUE129 EFT_HP_REGEN_2
323#define SPECENUM_VALUE129NAME "HP_Regen_2"
324/* Ruleset specific effects for use from Lua scripts */
325#define SPECENUM_VALUE130 EFT_USER_EFFECT_1
326#define SPECENUM_VALUE130NAME "User_Effect_1"
327#define SPECENUM_VALUE131 EFT_USER_EFFECT_2
328#define SPECENUM_VALUE131NAME "User_Effect_2"
329#define SPECENUM_VALUE132 EFT_USER_EFFECT_3
330#define SPECENUM_VALUE132NAME "User_Effect_3"
331#define SPECENUM_VALUE133 EFT_USER_EFFECT_4
332#define SPECENUM_VALUE133NAME "User_Effect_4"
333/* keep this last */
334#define SPECENUM_COUNT EFT_COUNT
335#include "specenum_gen.h"
336
337/* An effect is provided by a source. If the source is present, and the
338 * other conditions (described below) are met, the effect will be active.
339 * Note the difference between effect and effect_type. */
340 struct effect {
341 enum effect_type type;
342
343 /* pointer to multipliers (NULL means that this effect has no multiplier */
344 struct multiplier *multiplier;
345
346 /* The "value" of the effect. The meaning of this varies between
347 * effects. When get_xxx_bonus() is called the value of all applicable
348 * effects will be summed up. */
349 int value;
350
351 /* An effect can have multiple requirements. The effect will only be
352 * active if all of these requirement are met. */
353 struct requirement_vector reqs;
354
355 /* Only relevant for ruledit and other rulesave users. Indicates that
356 * this effect is deleted and shouldn't be saved. */
357 bool ruledit_do_not_save;
358};
359
360/* A callback type that takes an individual effect and a context for it
361 * and tells its weighted (by probability or something) value.
362 */
363 typedef double
364 (*eft_value_filter_cb)(const struct effect *eft,
365 const struct req_context *context,
366 const struct player *other_player,
367 void *data, int n_data);
368
369/* An effect_list is a list of effects. */
370#define SPECLIST_TAG effect
371#define SPECLIST_TYPE struct effect
372#include "speclist.h"
373#define effect_list_iterate(effect_list, peffect) \
374 TYPED_LIST_ITERATE(struct effect, effect_list, peffect)
375#define effect_list_iterate_end LIST_ITERATE_END
376
377struct effect *effect_new(enum effect_type type, int value,
378 struct multiplier *pmul);
379struct effect *effect_copy(struct effect *old);
380void effect_remove(struct effect *peffect);
381void effect_req_append(struct effect *peffect, struct requirement req);
382
383struct astring;
384void get_effect_req_text(const struct effect *peffect,
385 char *buf, size_t buf_len);
386void get_effect_list_req_text(const struct effect_list *plist,
387 struct astring *astr);
388
389/* ruleset cache creation and communication functions */
390struct packet_ruleset_effect;
391
392void ruleset_cache_init(void);
393void ruleset_cache_free(void);
394void recv_ruleset_effect(const struct packet_ruleset_effect *packet);
395void send_ruleset_cache(struct conn_list *dest);
396
397int effect_cumulative_max(enum effect_type type, struct universal *unis,
398 size_t n_unis);
399int effect_cumulative_min(enum effect_type type, struct universal *for_uni);
400
401int effect_value_from_universals(enum effect_type type,
402 struct universal *unis, size_t n_unis);
403
404bool effect_universals_value_never_below(enum effect_type type,
405 struct universal *unis,
406 size_t n_unis,
407 int min_value);
408
409int effect_value_will_make_positive(enum effect_type type);
410
411bool is_building_replaced(const struct city *pcity,
412 const struct impr_type *pimprove,
413 const enum req_problem_type prob_type);
414
415/* functions to know the bonuses a certain effect is granting */
416int get_world_bonus(enum effect_type effect_type);
417int get_player_bonus(const struct player *plr, enum effect_type effect_type);
418int get_city_bonus(const struct city *pcity, enum effect_type effect_type);
419int get_city_specialist_output_bonus(const struct city *pcity,
420 const struct specialist *pspecialist,
421 const struct output_type *poutput,
422 enum effect_type effect_type);
423int get_city_tile_output_bonus(const struct city *pcity,
424 const struct tile *ptile,
425 const struct output_type *poutput,
426 enum effect_type effect_type);
427int get_tile_output_bonus(const struct city *pcity,
428 const struct tile *ptile,
429 const struct output_type *poutput,
430 enum effect_type effect_type);
431int get_player_output_bonus(const struct player *pplayer,
432 const struct output_type *poutput,
433 enum effect_type effect_type);
434int get_city_output_bonus(const struct city *pcity,
435 const struct output_type *poutput,
436 enum effect_type effect_type);
437int get_building_bonus(const struct city *pcity,
438 const struct impr_type *building,
439 enum effect_type effect_type);
440int get_unittype_bonus(const struct player *pplayer,
441 const struct tile *ptile, /* pcity is implied */
442 const struct unit_type *punittype,
443 const struct action *paction,
444 enum effect_type effect_type);
445int get_unit_bonus(const struct unit *punit, enum effect_type effect_type);
446int get_unit_vs_tile_bonus(const struct tile *ptile,
447 const struct unit *punit,
448 enum effect_type etype);
449
450/* miscellaneous auxiliary effects functions */
451struct effect_list *get_req_source_effects(struct universal *psource);
452
453int get_player_bonus_effects(struct effect_list *plist,
454 const struct player *pplayer,
455 enum effect_type effect_type);
456int get_city_bonus_effects(struct effect_list *plist,
457 const struct city *pcity,
458 const struct output_type *poutput,
459 enum effect_type effect_type);
460
461int get_target_bonus_effects(struct effect_list *plist,
462 const struct req_context *context,
463 const struct player *other_player,
464 enum effect_type effect_type);
465double get_effect_expected_value(const struct req_context *context,
466 const struct player *other_player,
467 enum effect_type effect_type,
468 eft_value_filter_cb weighter,
469 void *data, int n_data)
470 fc__attribute((nonnull (4)));
471
472bool building_has_effect(const struct impr_type *pimprove,
473 enum effect_type effect_type);
474int get_current_construction_bonus(const struct city *pcity,
475 enum effect_type effect_type,
476 const enum req_problem_type prob_type);
477int get_potential_improvement_bonus(const struct impr_type *pimprove,
478 const struct city *pcity,
479 enum effect_type effect_type,
480 const enum req_problem_type prob_type,
481 bool consider_multipliers);
482
483struct effect_list *get_effects(enum effect_type effect_type);
484
485 typedef bool (*iec_cb)(struct effect*, void *data);
486bool iterate_effect_cache(iec_cb cb, void *data);
487
488#ifdef __cplusplus
489}
490#endif /* __cplusplus */
491
492#endif /* FC__EFFECTS_H */
connection.h
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
effect_remove
void effect_remove(struct effect *peffect)
Definition effects.c:205
recv_ruleset_effect
void recv_ruleset_effect(const struct packet_ruleset_effect *packet)
Definition effects.c:534
effect_universals_value_never_below
bool effect_universals_value_never_below(enum effect_type type, struct universal *unis, size_t n_unis, int min_value)
Definition effects.c:488
get_req_source_effects
struct effect_list * get_req_source_effects(struct universal *psource)
Definition effects.c:146
get_tile_output_bonus
int get_tile_output_bonus(const struct city *pcity, const struct tile *ptile, const struct output_type *poutput, enum effect_type effect_type)
Definition effects.c:862
get_player_output_bonus
int get_player_output_bonus(const struct player *pplayer, const struct output_type *poutput, enum effect_type effect_type)
Definition effects.c:883
get_city_specialist_output_bonus
int get_city_specialist_output_bonus(const struct city *pcity, const struct specialist *pspecialist, const struct output_type *poutput, enum effect_type effect_type)
Definition effects.c:807
is_building_replaced
bool is_building_replaced(const struct city *pcity, const struct impr_type *pimprove, const enum req_problem_type prob_type)
Definition effects.c:641
get_target_bonus_effects
int get_target_bonus_effects(struct effect_list *plist, const struct req_context *context, const struct player *other_player, enum effect_type effect_type)
Definition effects.c:691
get_player_bonus_effects
int get_player_bonus_effects(struct effect_list *plist, const struct player *pplayer, enum effect_type effect_type)
Definition effects.c:1052
iterate_effect_cache
bool iterate_effect_cache(iec_cb cb, void *data)
Definition effects.c:1245
get_city_bonus
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:789
get_current_construction_bonus
int get_current_construction_bonus(const struct city *pcity, enum effect_type effect_type, const enum req_problem_type prob_type)
Definition effects.c:1104
get_city_bonus_effects
int get_city_bonus_effects(struct effect_list *plist, const struct city *pcity, const struct output_type *poutput, enum effect_type effect_type)
Definition effects.c:1075
effect_copy
struct effect * effect_copy(struct effect *old)
Definition effects.c:214
eft_value_filter_cb
double(* eft_value_filter_cb)(const struct effect *eft, const struct req_context *context, const struct player *other_player, void *data, int n_data)
Definition effects.h:364
get_unit_vs_tile_bonus
int get_unit_vs_tile_bonus(const struct tile *ptile, const struct unit *punit, enum effect_type etype)
Definition effects.c:1016
get_unit_bonus
int get_unit_bonus(const struct unit *punit, enum effect_type effect_type)
Definition effects.c:992
get_effect_expected_value
double get_effect_expected_value(const struct req_context *context, const struct player *other_player, enum effect_type effect_type, eft_value_filter_cb weighter, void *data, int n_data) fc__attribute((nonnull(4)))
Definition effects.c:736
get_city_output_bonus
int get_city_output_bonus(const struct city *pcity, const struct output_type *poutput, enum effect_type effect_type)
Definition effects.c:906
get_potential_improvement_bonus
int get_potential_improvement_bonus(const struct impr_type *pimprove, const struct city *pcity, enum effect_type effect_type, const enum req_problem_type prob_type, bool consider_multipliers)
Definition effects.c:1126
send_ruleset_cache
void send_ruleset_cache(struct conn_list *dest)
Definition effects.c:553
get_effect_req_text
void get_effect_req_text(const struct effect *peffect, char *buf, size_t buf_len)
Definition effects.c:1197
iec_cb
bool(* iec_cb)(struct effect *, void *data)
Definition effects.h:485
get_player_bonus
int get_player_bonus(const struct player *plr, enum effect_type effect_type)
Definition effects.c:771
ruleset_cache_free
void ruleset_cache_free(void)
Definition effects.c:271
effect_new
struct effect * effect_new(enum effect_type type, int value, struct multiplier *pmul)
Definition effects.c:179
get_building_bonus
int get_building_bonus(const struct city *pcity, const struct impr_type *building, enum effect_type effect_type)
Definition effects.c:930
effect_value_from_universals
int effect_value_from_universals(enum effect_type type, struct universal *unis, size_t n_unis)
Definition effects.c:402
get_city_tile_output_bonus
int get_city_tile_output_bonus(const struct city *pcity, const struct tile *ptile, const struct output_type *poutput, enum effect_type effect_type)
Definition effects.c:838
effect_cumulative_max
int effect_cumulative_max(enum effect_type type, struct universal *unis, size_t n_unis)
Definition effects.c:331
ruleset_cache_init
void ruleset_cache_init(void)
Definition effects.c:245
get_world_bonus
int get_world_bonus(enum effect_type effect_type)
Definition effects.c:759
effect_cumulative_min
int effect_cumulative_min(enum effect_type type, struct universal *for_uni)
Definition effects.c:367
get_effects
struct effect_list * get_effects(enum effect_type effect_type)
Definition effects.c:136
building_has_effect
bool building_has_effect(const struct impr_type *pimprove, enum effect_type effect_type)
Definition effects.c:587
effect_req_append
void effect_req_append(struct effect *peffect, struct requirement req)
Definition effects.c:229
get_unittype_bonus
int get_unittype_bonus(const struct player *pplayer, const struct tile *ptile, const struct unit_type *punittype, const struct action *paction, enum effect_type effect_type)
Definition effects.c:957
get_effect_list_req_text
void get_effect_list_req_text(const struct effect_list *plist, struct astring *astr)
Definition effects.c:1225
effect_value_will_make_positive
int effect_value_will_make_positive(enum effect_type type)
Definition effects.c:525
fc_types.h
req_problem_type
req_problem_type
Definition fc_types.h:584
type
GType type
Definition repodlgs.c:1312
multipliers.h
requirements.h
specenum_gen.h
speclist.h
action
Definition actions.h:379
astring
Definition astring.h:36
city
Definition city.h:309
effect
Definition effects.h:340
effect::value
int value
Definition effects.h:349
effect::multiplier
struct multiplier * multiplier
Definition effects.h:344
effect::ruledit_do_not_save
bool ruledit_do_not_save
Definition effects.h:357
effect::reqs
struct requirement_vector reqs
Definition effects.h:353
effect::type
enum effect_type type
Definition effects.h:341
impr_type
Definition improvement.h:68
multiplier
Definition multipliers.h:31
output_type
Definition city.h:251
packet_ruleset_effect
Definition packets_gen.h:1590
packet_ruleset_effect::effect_type
enum effect_type effect_type
Definition packets_gen.h:1591
player
Definition player.h:249
req_context
Definition requirements.h:99
requirement
Definition requirements.h:80
specialist
Definition specialist.h:29
tile
Definition tile.h:49
unit_type
Definition unittype.h:481
unit
Definition unit.h:138
universal
Definition fc_types.h:756
support.h
fc__attribute
#define fc__attribute(x)
Definition support.h:89
bool
#define bool
Definition support.h:61