Debian Codegraph @

test-scripting/species/species_macros/influence.py

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