| 1 |
from focs._effects import ( |
| 2 |
AddSpecial, |
| 3 |
Conditional, |
| 4 |
ContainedBy, |
| 5 |
Contains, |
| 6 |
DesignHasPart, |
| 7 |
Destroy, |
| 8 |
DirectDistanceBetween, |
| 9 |
EffectsGroup, |
| 10 |
EnemyOf, |
| 11 |
Fleet, |
| 12 |
Focus, |
| 13 |
GenerateSitRepMessage, |
| 14 |
InSystem, |
| 15 |
IsBuilding, |
| 16 |
IsSource, |
| 17 |
LocalCandidate, |
| 18 |
MoveTo, |
| 19 |
MoveTowards, |
| 20 |
Number, |
| 21 |
Object, |
| 22 |
OwnedBy, |
| 23 |
Planet, |
| 24 |
Random, |
| 25 |
RootCandidate, |
| 26 |
SetMaxSupply, |
| 27 |
SetPopulation, |
| 28 |
SetStealth, |
| 29 |
SetTargetPopulation, |
| 30 |
Ship, |
| 31 |
Source, |
| 32 |
Stationary, |
| 33 |
System, |
| 34 |
Target, |
| 35 |
Turn, |
| 36 |
Unowned, |
| 37 |
Value, |
| 38 |
WithinDistance, |
| 39 |
WithinStarlaneJumps, |
| 40 |
) |
| 41 |
from macros.priorities import ( |
| 42 |
POPULATION_DEFAULT_PRIORITY, |
| 43 |
POPULATION_FIRST_PRIORITY, |
| 44 |
TARGET_POPULATION_AFTER_SCALING_PRIORITY, |
| 45 |
) |
| 46 |
|
| 47 |
PLANETARY_DRIVE_ACTIVATION = ( |
| 48 |
Planet() |
| 49 |
& Focus(type=["FOCUS_PLANET_DRIVE"]) |
| 50 |
& WithinStarlaneJumps( |
| 51 |
jumps=1, |
| 52 |
condition=System |
| 53 |
& Contains( |
| 54 |
( |
| 55 |
IsBuilding(name=["BLD_PLANET_BEACON"]) |
| 56 |
| ( |
| 57 |
Ship |
| 58 |
& DesignHasPart(low=1, high=999, name="SP_PLANET_BEACON") |
| 59 |
& Turn(low=LocalCandidate.ArrivedOnTurn + 1) |
| 60 |
) |
| 61 |
) |
| 62 |
& OwnedBy(empire=Source.Owner) |
| 63 |
) |
| 64 |
& ~Contains(IsSource), |
| 65 |
) |
| 66 |
) |
| 67 |
|
| 68 |
ADVANCED_FOCUS_EFFECTS = [ |
| 69 |
EffectsGroup( |
| 70 |
scope=IsSource, activation=Planet() & Focus(type=["FOCUS_STEALTH"]), effects=SetStealth(value=Value + 15) |
| 71 |
), |
| 72 |
EffectsGroup( |
| 73 |
scope=Planet() |
| 74 |
& OwnedBy(affiliation=EnemyOf, empire=Source.Owner) |
| 75 |
& WithinStarlaneJumps(jumps=4, condition=IsSource) |
| 76 |
& ~Number(low=1, condition=IsBuilding(name=["BLD_GENOME_BANK"]) & OwnedBy(empire=RootCandidate.Owner)), |
| 77 |
activation=Focus(type=["FOCUS_BIOTERROR"]), |
| 78 |
priority=TARGET_POPULATION_AFTER_SCALING_PRIORITY, |
| 79 |
effects=SetTargetPopulation(value=Value - 4), |
| 80 |
), |
| 81 |
EffectsGroup( |
| 82 |
scope=Fleet |
| 83 |
& OwnedBy(empire=Source.Owner) |
| 84 |
& ContainedBy(System & Contains(Planet() & OwnedBy(empire=Source.Owner) & Focus(type=["FOCUS_STARGATE_SEND"]))), |
| 85 |
activation=Planet() & Focus(type=["FOCUS_STARGATE_RECEIVE"]), |
| 86 |
stackinggroup="STARGATE_STACK", |
| 87 |
effects=[ |
| 88 |
GenerateSitRepMessage( |
| 89 |
message="EFFECT_STARGATE", |
| 90 |
label="EFFECT_STARGATE_LABEL", |
| 91 |
icon="icons/focus/stargate_receive.png", |
| 92 |
parameters={"fleet": Target.ID, "system": Source.SystemID}, |
| 93 |
empire=Source.Owner, |
| 94 |
), |
| 95 |
MoveTo(destination=Contains(IsSource) & System), |
| 96 |
], |
| 97 |
), |
| 98 |
EffectsGroup( |
| 99 |
scope=IsSource, |
| 100 |
activation=PLANETARY_DRIVE_ACTIVATION, |
| 101 |
# add the special with higher priority, so it can trigger with the same |
| 102 |
# priotity as the effect below |
| 103 |
priority=POPULATION_FIRST_PRIORITY, |
| 104 |
effects=AddSpecial(name="STARLANE_DRIVE_ACTIVATED_SPECIAL"), |
| 105 |
), |
| 106 |
EffectsGroup( |
| 107 |
scope=IsSource, |
| 108 |
activation=PLANETARY_DRIVE_ACTIVATION, |
| 109 |
priority=POPULATION_DEFAULT_PRIORITY, |
| 110 |
effects=[ |
| 111 |
MoveTo( |
| 112 |
destination=System |
| 113 |
& WithinStarlaneJumps(jumps=1, condition=IsSource) |
| 114 |
& Contains( |
| 115 |
( |
| 116 |
IsBuilding(name=["BLD_PLANET_BEACON"]) |
| 117 |
| ( |
| 118 |
Ship |
| 119 |
& DesignHasPart(low=1, high=999, name="SP_PLANET_BEACON") |
| 120 |
& Turn(low=LocalCandidate.ArrivedOnTurn + 1) |
| 121 |
) |
| 122 |
) |
| 123 |
& OwnedBy(empire=Source.Owner) |
| 124 |
) |
| 125 |
& ~Contains(IsSource) |
| 126 |
), |
| 127 |
GenerateSitRepMessage( |
| 128 |
message="EFFECT_PLANET_DRIVE", |
| 129 |
label="EFFECT_PLANET_DRIVE_LABEL", |
| 130 |
icon="icons/building/planetary_stardrive.png", |
| 131 |
parameters={"planet": Source.ID, "system": Source.SystemID}, |
| 132 |
empire=Source.Owner, |
| 133 |
), |
| 134 |
SetPopulation(value=Value / 2), |
| 135 |
], |
| 136 |
), |
| 137 |
EffectsGroup( |
| 138 |
scope=IsSource, |
| 139 |
activation=Random(probability=0.5) |
| 140 |
& Planet() |
| 141 |
& Focus(type=["FOCUS_PLANET_DRIVE"]) |
| 142 |
& WithinStarlaneJumps( |
| 143 |
jumps=1, |
| 144 |
condition=System |
| 145 |
& Contains( |
| 146 |
( |
| 147 |
IsBuilding(name=["BLD_PLANET_BEACON"]) |
| 148 |
| ( |
| 149 |
Ship |
| 150 |
& DesignHasPart(low=1, high=999, name="SP_PLANET_BEACON") |
| 151 |
& Turn(low=LocalCandidate.ArrivedOnTurn + 1) |
| 152 |
) |
| 153 |
) |
| 154 |
& OwnedBy(empire=Source.Owner) |
| 155 |
) |
| 156 |
& ~Contains(IsSource), |
| 157 |
) |
| 158 |
& ~WithinDistance(distance=200, condition=IsBuilding(name=["BLD_LIGHTHOUSE"])), |
| 159 |
effects=[ |
| 160 |
GenerateSitRepMessage( |
| 161 |
message="SITREP_PLANET_DRIVE_FAILURE", |
| 162 |
label="SITREP_PLANET_DRIVE_FAILURE_LABEL", |
| 163 |
icon="icons/sitrep/colony_destroyed.png", |
| 164 |
parameters={"planet": Source.ID, "system": Source.SystemID}, |
| 165 |
empire=Source.Owner, |
| 166 |
), |
| 167 |
Destroy, |
| 168 |
], |
| 169 |
), |
| 170 |
EffectsGroup( |
| 171 |
scope=Fleet |
| 172 |
& ~Stationary |
| 173 |
& ~InSystem() |
| 174 |
& (OwnedBy(affiliation=EnemyOf, empire=Source.Owner) | Unowned) |
| 175 |
& (Source.System.ID == LocalCandidate.NextSystemID), |
| 176 |
activation=Planet() & Focus(type=["FOCUS_DISTORTION"]), |
| 177 |
stackinggroup="DISTORTION_MOVEMENT_STACK", |
| 178 |
effects=Conditional( |
| 179 |
condition=WithinDistance(distance=40, condition=Object(id=RootCandidate.PreviousSystemID)), |
| 180 |
effects=[ |
| 181 |
GenerateSitRepMessage( |
| 182 |
message="EFFECT_FLEET_MOVED_TO", |
| 183 |
label="EFFECT_FLEET_MOVED_TO_LABEL", |
| 184 |
parameters={ |
| 185 |
"fleet": Target.ID, |
| 186 |
"system": Target.PreviousSystemID, |
| 187 |
"rawtext": DirectDistanceBetween(Target.ID, Target.PreviousSystemID), |
| 188 |
"planet": Source.ID, |
| 189 |
}, |
| 190 |
empire=Source.Owner, |
| 191 |
), |
| 192 |
MoveTo(destination=Object(id=Target.PreviousSystemID)), |
| 193 |
], |
| 194 |
else_=[ |
| 195 |
GenerateSitRepMessage( |
| 196 |
message="EFFECT_FLEET_MOVED_TOWARDS", |
| 197 |
label="EFFECT_FLEET_MOVED_TOWARDS_LABEL", |
| 198 |
parameters={ |
| 199 |
"fleet": Target.ID, |
| 200 |
"system": Target.PreviousSystemID, |
| 201 |
"rawtext": DirectDistanceBetween(Target.ID, Target.PreviousSystemID), |
| 202 |
"planet": Source.ID, |
| 203 |
}, |
| 204 |
empire=Source.Owner, |
| 205 |
), |
| 206 |
MoveTowards(speed=40, target=Object(id=Target.PreviousSystemID)), |
| 207 |
], |
| 208 |
), |
| 209 |
), |
| 210 |
EffectsGroup( |
| 211 |
scope=IsSource, |
| 212 |
activation=Focus(type=["FOCUS_LOGISTICS"]), |
| 213 |
accountinglabel="SHP_INTSTEL_LOG", |
| 214 |
effects=SetMaxSupply(value=Value + 3), |
| 215 |
), |
| 216 |
] |