| 1 |
from focs._effects import ( |
| 2 |
Contains, |
| 3 |
EffectsGroup, |
| 4 |
EmpireHasAdoptedPolicy, |
| 5 |
GiveEmpireTech, |
| 6 |
Good, |
| 7 |
HasSpecies, |
| 8 |
HasTag, |
| 9 |
IsBuilding, |
| 10 |
IsSource, |
| 11 |
IsTarget, |
| 12 |
JumpsBetween, |
| 13 |
LocalCandidate, |
| 14 |
MaxOf, |
| 15 |
NamedIntegerLookup, |
| 16 |
NamedReal, |
| 17 |
NamedRealLookup, |
| 18 |
Number, |
| 19 |
OwnedBy, |
| 20 |
Planet, |
| 21 |
RootCandidate, |
| 22 |
SetTargetHappiness, |
| 23 |
SetTargetPopulation, |
| 24 |
Source, |
| 25 |
Statistic, |
| 26 |
StatisticCount, |
| 27 |
Sum, |
| 28 |
Target, |
| 29 |
Turn, |
| 30 |
Value, |
| 31 |
VisibleToEmpire, |
| 32 |
WithinStarlaneJumps, |
| 33 |
) |
| 34 |
from macros.priorities import TARGET_AFTER_SCALING_PRIORITY, TARGET_POPULATION_LAST_BEFORE_OVERRIDE_PRIORITY |
| 35 |
|
| 36 |
|
| 37 |
def _condition_other_species_nearby(): |
| 38 |
return ( |
| 39 |
Planet() |
| 40 |
& HasSpecies() |
| 41 |
& ~HasSpecies(name=[Source.Species]) |
| 42 |
& ~HasTag(name="LOW_BRAINPOWER") |
| 43 |
& ~Contains(IsBuilding(name=["BLD_CONC_CAMP"])) |
| 44 |
& VisibleToEmpire(empire=Source.Owner) |
| 45 |
& (~OwnedBy(empire=Source.Owner) | ~EmpireHasAdoptedPolicy(empire=Source.Owner, name="PLC_RACIAL_PURITY")) |
| 46 |
& WithinStarlaneJumps(jumps=NamedIntegerLookup(name="XENOPHOBIC_MAX_JUMPS"), condition=IsSource) |
| 47 |
) |
| 48 |
|
| 49 |
|
| 50 |
def _xenophobic_selfsustaining_qualifying_planet_count(): |
| 51 |
return StatisticCount( |
| 52 |
int, |
| 53 |
condition=Planet() |
| 54 |
& HasSpecies() |
| 55 |
& ~(HasSpecies(name=[Source.Species]) | HasTag(name="LOW_BRAINPOWER")) |
| 56 |
& WithinStarlaneJumps(jumps=NamedIntegerLookup(name="XENOPHOBIC_MAX_JUMPS"), condition=IsSource), |
| 57 |
) |
| 58 |
|
| 59 |
|
| 60 |
XENOPHOBIC_SELF = [ |
| 61 |
# Give the concentration camp tech at game start |
| 62 |
EffectsGroup( |
| 63 |
scope=IsSource, |
| 64 |
activation=Turn(high=0), |
| 65 |
effects=GiveEmpireTech(name="CON_CONC_CAMP"), |
| 66 |
), |
| 67 |
# Xenophobic Frenzy: stability malus for xenophobic species nearby other species |
| 68 |
EffectsGroup( |
| 69 |
scope=IsSource, |
| 70 |
activation=Number(low=1, condition=_condition_other_species_nearby()), |
| 71 |
stackinggroup="XENOPHOBIC_LABEL_SELF", |
| 72 |
accountinglabel="XENOPHOBIC_LABEL_SELF", |
| 73 |
priority=TARGET_AFTER_SCALING_PRIORITY, |
| 74 |
effects=( |
| 75 |
SetTargetHappiness( |
| 76 |
value=Value |
| 77 |
+ NamedReal(name="XENOPHOBIC_TARGET_STABILITY_PERJUMP", value=-0.5) |
| 78 |
* Statistic( |
| 79 |
float, |
| 80 |
Sum, |
| 81 |
value=1 |
| 82 |
+ NamedIntegerLookup(name="XENOPHOBIC_MAX_JUMPS") |
| 83 |
- JumpsBetween(Target.ID, LocalCandidate.ID), |
| 84 |
condition=Planet() |
| 85 |
& VisibleToEmpire(empire=Source.Owner) |
| 86 |
& HasSpecies() |
| 87 |
& ~HasSpecies(name=[Source.Species]) |
| 88 |
& ~HasTag(name="LOW_BRAINPOWER") |
| 89 |
& ~Contains(IsBuilding(name=["BLD_CONC_CAMP"])) |
| 90 |
& ( |
| 91 |
~OwnedBy(empire=RootCandidate.Owner) |
| 92 |
| ~EmpireHasAdoptedPolicy(empire=Source.Owner, name="PLC_RACIAL_PURITY") |
| 93 |
) |
| 94 |
& WithinStarlaneJumps(jumps=NamedIntegerLookup(name="XENOPHOBIC_MAX_JUMPS"), condition=IsSource), |
| 95 |
) |
| 96 |
) |
| 97 |
), |
| 98 |
), |
| 99 |
# Pop malus for self-sustaining xenophobic species based on the number of nearby planets with other species |
| 100 |
EffectsGroup( |
| 101 |
scope=IsSource, |
| 102 |
activation=Planet(environment=[Good]) |
| 103 |
& HasTag(name="SELF_SUSTAINING") |
| 104 |
& (0 < _xenophobic_selfsustaining_qualifying_planet_count()), |
| 105 |
stackinggroup="XENOPHOBIC_POP_SELF", |
| 106 |
accountinglabel="XENOPHOBIC_LABEL_SELF", |
| 107 |
priority=TARGET_POPULATION_LAST_BEFORE_OVERRIDE_PRIORITY, |
| 108 |
effects=SetTargetPopulation( |
| 109 |
value=Value |
| 110 |
+ MaxOf( |
| 111 |
float, |
| 112 |
-3 * Target.HabitableSize, # Cap malus at the self-sustaining bonus |
| 113 |
Target.HabitableSize |
| 114 |
* NamedReal(name="XENOPHOBIC_TARGET_POPULATION_PERJUMP", value=-0.2) |
| 115 |
* Statistic( |
| 116 |
float, |
| 117 |
Sum, |
| 118 |
value=1 |
| 119 |
+ NamedIntegerLookup(name="XENOPHOBIC_MAX_JUMPS") |
| 120 |
- JumpsBetween(Target.ID, LocalCandidate.ID), |
| 121 |
condition=Planet() |
| 122 |
& HasSpecies() |
| 123 |
& ~HasSpecies(name=[Source.Species]) |
| 124 |
& ~HasTag(name="LOW_BRAINPOWER") |
| 125 |
& WithinStarlaneJumps(jumps=NamedIntegerLookup(name="XENOPHOBIC_MAX_JUMPS"), condition=IsSource), |
| 126 |
), |
| 127 |
) |
| 128 |
), |
| 129 |
), |
| 130 |
] |
| 131 |
|
| 132 |
|
| 133 |
# single argument should be the name of the species capitalized |
| 134 |
def XENOPHOBIC_OTHER(name): |
| 135 |
# Xenophobic Harassment: stability malus to non-exobot species nearby different, xenophobic species |
| 136 |
return EffectsGroup( |
| 137 |
scope=_condition_other_species_nearby(), |
| 138 |
activation=Planet(), |
| 139 |
stackinggroup=f"XENOPHOBIC_LABEL_{name}_OTHER", |
| 140 |
accountinglabel=f"XENOPHOBIC_LABEL_{name}_OTHER", |
| 141 |
priority=TARGET_AFTER_SCALING_PRIORITY, |
| 142 |
effects=SetTargetHappiness( |
| 143 |
value=Value |
| 144 |
+ NamedRealLookup(name="XENOPHOBIC_TARGET_STABILITY_PERJUMP") |
| 145 |
* Statistic( |
| 146 |
float, |
| 147 |
Sum, |
| 148 |
value=1 + NamedIntegerLookup(name="XENOPHOBIC_MAX_JUMPS") - JumpsBetween(Target.ID, LocalCandidate.ID), |
| 149 |
condition=Planet() |
| 150 |
& HasSpecies(name=[Source.Species]) |
| 151 |
& ( |
| 152 |
~OwnedBy(empire=Target.Owner) |
| 153 |
| ~EmpireHasAdoptedPolicy(empire=LocalCandidate.Owner, name="PLC_RACIAL_PURITY") |
| 154 |
) |
| 155 |
& WithinStarlaneJumps(jumps=NamedIntegerLookup(name="XENOPHOBIC_MAX_JUMPS"), condition=IsTarget), |
| 156 |
) |
| 157 |
), |
| 158 |
) |