Debian Codegraph @

default/scripting/species/species_macros/influence.py

raw
1 from focs._effects import (
2 Abs,
3 Capital,
4 EffectsGroup,
5 EmpireHasAdoptedPolicy,
6 Focus,
7 GalaxyMaxAIAggression,
8 Happiness,
9 HasSpecies,
10 HasTag,
11 Homeworld,
12 IsBuilding,
13 IsHuman,
14 IsSource,
15 LocalCandidate,
16 NamedReal,
17 OwnedBy,
18 Planet,
19 ResourceSupplyConnected,
20 SetTargetInfluence,
21 Ship,
22 Source,
23 StatisticCount,
24 Target,
25 Turn,
26 Unowned,
27 Value,
28 )
29 from macros.misc import (
30 DESCRIPTION_EFFECTSGROUP_MACRO,
31 SUPPLY_DISCONNECTED_INFLUENCE_MALUS,
32 )
33 from macros.priorities import (
34 TARGET_EARLY_BEFORE_SCALING_PRIORITY,
35 TARGET_LAST_BEFORE_OVERRIDE_PRIORITY,
36 TARGET_SCALING_PRIORITY,
37 )
38
39 _BASE_INFLUENCE_COSTS = [
40 EffectsGroup( # colonies consume influence, proportional to square-root of how many populated planets and non-populated outposts the empire controls
41 scope=IsSource,
42 activation=Planet() & ~Unowned & ~Capital,
43 stackinggroup="IMPERIAL_PALACE_MANY_PLANETS_INFLUENCE_PENALTY",
44 accountinglabel="COLONY_ADMIN_COSTS_LABEL",
45 priority=TARGET_LAST_BEFORE_OVERRIDE_PRIORITY,
46 effects=SetTargetInfluence(
47 value=Value
48 - NamedReal(name="COLONY_ADMIN_COSTS_PER_PLANET", value=0.4)
49 * (
50 (
51 StatisticCount(
52 float,
53 condition=Planet()
54 & OwnedBy(empire=Source.Owner)
55 & HasSpecies()
56 & ~HasSpecies(name=["SP_EXOBOT"]),
57 )
58 + StatisticCount(
59 float,
60 condition=Ship & OwnedBy(empire=Source.Owner) & (LocalCandidate.OrderedColonizePlanetID != -1),
61 )
62 + StatisticCount(
63 float,
64 condition=IsBuilding()
65 & OwnedBy(empire=Source.Owner)
66 & IsBuilding(
67 name=[
68 "BLD_COL_SUPER_TEST",
69 "BLD_COL_ABADDONI",
70 "BLD_COL_BANFORO",
71 "BLD_COL_CHATO",
72 "BLD_COL_CRAY",
73 "BLD_COL_DERTHREAN",
74 "BLD_COL_EAXAW",
75 "BLD_COL_EGASSEM",
76 "BLD_COL_ETTY",
77 "BLD_COL_FULVER",
78 "BLD_COL_FURTHEST",
79 "BLD_COL_GEORGE",
80 "BLD_COL_GYSACHE",
81 "BLD_COL_HAPPY",
82 "BLD_COL_HHHOH",
83 "BLD_COL_HUMAN",
84 "BLD_COL_KILANDOW",
85 "BLD_COL_KOBUNTURA",
86 "BLD_COL_LAENFA",
87 "BLD_COL_MISIORLA",
88 "BLD_COL_MUURSH",
89 "BLD_COL_PHINNERT",
90 "BLD_COL_SCYLIOR",
91 "BLD_COL_SETINON",
92 "BLD_COL_SILEXIAN",
93 "BLD_COL_SLY",
94 "BLD_COL_SSLITH",
95 "BLD_COL_TAEGHIRUS",
96 "BLD_COL_TRITH",
97 "BLD_COL_REPLICON",
98 "BLD_COL_UGMORS",
99 ]
100 ),
101 )
102 + (
103 NamedReal(name="OUTPOST_RELATIVE_ADMIN_COUNT", value=0.25)
104 * (
105 StatisticCount(
106 float,
107 condition=Planet()
108 & OwnedBy(empire=Source.Owner)
109 & (~HasSpecies() | HasSpecies(name=["SP_EXOBOT"])),
110 )
111 )
112 )
113 )
114 ** 0.5
115 )
116 ),
117 ),
118 EffectsGroup( # species homeworlds consume more influence
119 scope=IsSource,
120 activation=Planet() & ~Unowned & ~Capital & Homeworld(name=[LocalCandidate.Species]),
121 accountinglabel="SPECIES_HOMEWORLD_INDEPENDENCE_DESIRE_LABEL",
122 priority=TARGET_LAST_BEFORE_OVERRIDE_PRIORITY,
123 effects=SetTargetInfluence(value=Value - 1),
124 ),
125 EffectsGroup( # colonies consume more influence if not supply connected to empire's capital
126 scope=IsSource,
127 activation=Planet()
128 & ~Unowned
129 & ~EmpireHasAdoptedPolicy(empire=Source.Owner, name="PLC_CONFEDERATION")
130 & ~ResourceSupplyConnected(
131 empire=LocalCandidate.Owner, condition=Planet() & OwnedBy(empire=Source.Owner) & Capital
132 )
133 & Turn(low=1),
134 accountinglabel="CAPITAL_DISCONNECTION_LABEL",
135 priority=TARGET_LAST_BEFORE_OVERRIDE_PRIORITY,
136 effects=SetTargetInfluence(
137 value=Value
138 - NamedReal(name="SUPPLY_DISCONNECTED_INFLUENCE_MALUS", value=SUPPLY_DISCONNECTED_INFLUENCE_MALUS)
139 ),
140 ),
141 EffectsGroup( # gives human bonuses when AI Aggression set to Beginner
142 scope=IsSource,
143 activation=Planet() & ~Unowned & IsHuman & (GalaxyMaxAIAggression == 0), # human player, not human species
144 accountinglabel="DIFFICULTY",
145 priority=TARGET_LAST_BEFORE_OVERRIDE_PRIORITY,
146 effects=SetTargetInfluence(value=Value + 1),
147 ),
148 ]
149
150 NO_INFLUENCE = [DESCRIPTION_EFFECTSGROUP_MACRO("NO_INFLUENCE_DESC"), *_BASE_INFLUENCE_COSTS]
151
152 _ARTISANS_INFLUENCE_STABILITY = [
153 EffectsGroup( # artistic species generate influence when artisans workshops policy adopted
154 scope=IsSource,
155 activation=HasTag(name="ARTISTIC")
156 & Happiness(low=NamedReal(name="ARTISANS_MIN_STABILITY_FOCUS", value=1))
157 & EmpireHasAdoptedPolicy(empire=Source.Owner, name="PLC_ARTISAN_WORKSHOPS")
158 & Focus(type=["FOCUS_INFLUENCE"]),
159 accountinglabel="PLC_ARTISAN_WORKSHOPS",
160 effects=SetTargetInfluence(value=Value + NamedReal(name="ARTISANS_INFLUENCE_FLAT_FOCUS", value=2.0)),
161 ),
162 EffectsGroup(
163 scope=IsSource,
164 activation=HasTag(name="ARTISTIC")
165 & Happiness(low=NamedReal(name="ARTISANS_MIN_STABILITY_NO_FOCUS", value=10))
166 & EmpireHasAdoptedPolicy(empire=Source.Owner, name="PLC_ARTISAN_WORKSHOPS")
167 & ~Focus(type=["FOCUS_INFLUENCE"]),
168 accountinglabel="PLC_ARTISAN_WORKSHOPS",
169 effects=SetTargetInfluence(value=Value + NamedReal(name="ARTISANS_INFLUENCE_FLAT_NO_FOCUS", value=0.5)),
170 ),
171 ]
172
173
174 _BASIC_INFLUENCE = [
175 EffectsGroup( # influence focus generates influence from planets, proportional to sqare-root of population
176 scope=IsSource,
177 activation=Planet() & Focus(type=["FOCUS_INFLUENCE"]),
178 accountinglabel="FOCUS_INFLUENCE_LABEL",
179 priority=TARGET_EARLY_BEFORE_SCALING_PRIORITY,
180 effects=SetTargetInfluence(
181 value=Value
182 + (Target.Population**0.5) * NamedReal(name="FOCUS_INFLUENCE_INFLUENCE_PER_SQRT_POP", value=1.0)
183 ),
184 ),
185 *_BASE_INFLUENCE_COSTS,
186 *_ARTISANS_INFLUENCE_STABILITY,
187 ]
188
189
190 VERY_BAD_INFLUENCE = [
191 *_BASIC_INFLUENCE,
192 EffectsGroup(
193 description="VERY_BAD_INFLUENCE_DESC",
194 scope=IsSource,
195 activation=Planet() & Focus(type=["FOCUS_INFLUENCE"]),
196 accountinglabel="VERY_BAD_INFLUENCE_LABEL",
197 priority=TARGET_SCALING_PRIORITY,
198 effects=SetTargetInfluence(value=Value + (-0.33) * Abs(float, Value)),
199 ),
200 ]
201
202
203 BAD_INFLUENCE = [
204 *_BASIC_INFLUENCE,
205 EffectsGroup(
206 description="BAD_INFLUENCE_DESC",
207 scope=IsSource,
208 activation=Planet() & Focus(type=["FOCUS_INFLUENCE"]),
209 accountinglabel="BAD_INFLUENCE_LABEL",
210 priority=TARGET_SCALING_PRIORITY,
211 effects=SetTargetInfluence(value=Value + (-0.2) * Abs(float, Value)),
212 ),
213 ]
214
215
216 AVERAGE_INFLUENCE = _BASIC_INFLUENCE
217
218
219 GOOD_INFLUENCE = [
220 *_BASIC_INFLUENCE,
221 EffectsGroup(
222 description="GOOD_INFLUENCE_DESC",
223 scope=IsSource,
224 activation=Planet() & Focus(type=["FOCUS_INFLUENCE"]),
225 accountinglabel="GOOD_INFLUENCE_LABEL",
226 priority=TARGET_SCALING_PRIORITY,
227 effects=SetTargetInfluence(value=Value + (0.25) * Abs(float, Value)),
228 ),
229 ]
230
231 GREAT_INFLUENCE = [
232 *_BASIC_INFLUENCE,
233 EffectsGroup(
234 description="GREAT_INFLUENCE_DESC",
235 scope=IsSource,
236 activation=Planet() & Focus(type=["FOCUS_INFLUENCE"]),
237 accountinglabel="GREAT_INFLUENCE_LABEL",
238 priority=TARGET_SCALING_PRIORITY,
239 effects=SetTargetInfluence(value=Value + (0.5) * Abs(float, Value)),
240 ),
241 ]
242
243
244 ULTIMATE_INFLUENCE = [
245 *_BASIC_INFLUENCE,
246 EffectsGroup(
247 description="ULTIMATE_INFLUENCE_DESC",
248 scope=IsSource,
249 activation=Planet() & Focus(type=["FOCUS_INFLUENCE"]),
250 accountinglabel="ULTIMATE_INFLUENCE_LABEL",
251 priority=TARGET_SCALING_PRIORITY,
252 effects=SetTargetInfluence(value=Value + (1.0) * Abs(float, Value)),
253 ),
254 ]