1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
from focs._effects import (
Abs,
EffectsGroup,
EmpireHasAdoptedPolicy,
HasEmpireStockpile,
HasSpecies,
Influence,
IsSource,
IsTarget,
MaxOf,
MinOf,
NumPoliciesAdopted,
OwnedBy,
Planet,
Population,
SetConstruction,
SetEmpireStockpile,
SetHappiness,
SetMaxTroops,
SetTargetConstruction,
Source,
StatisticIf,
Target,
Value,
)
from focs._tech import *
from macros.priorities import (
AFTER_ALL_TARGET_MAX_METERS_PRIORITY,
METER_OVERRIDE_PRIORITY,
TARGET_AFTER_2ND_SCALING_PRIORITY,
)
Tech(
name="CON_OUTPOST",
description="CON_OUTPOST_DESC",
short_description="CON_OUTPOST",
category="CONSTRUCTION_CATEGORY",
researchcost=1,
researchturns=1,
tags=["PEDIA_CONSTRUCTION_CATEGORY"],
unlock=Item(type=UnlockBuilding, name="BLD_ABANDON_OUTPOST"),
# Effects for outposts
effectsgroups=[
# Outposts only have 50% of troops
EffectsGroup(
scope=Planet()
& OwnedBy(empire=Source.Owner)
& Population(high=0)
& ~EmpireHasAdoptedPolicy(empire=Source.Owner, name="PLC_MARINE_RECRUITMENT"),
stackinggroup="OUTPOST_TROOPS_STACK",
priority=TARGET_AFTER_2ND_SCALING_PRIORITY,
effects=SetMaxTroops(value=Value * 0.5),
accountinglabel="OUTPOST_TROOP_LABEL",
),
# Ensure construction minimum value of one, as this is necessary for being attacked
EffectsGroup(
scope=Planet() & OwnedBy(empire=Source.Owner),
# has to happen after e.g. FORCE_ENERGY_STRC effects which also happens at AFTER_ALL_TARGET_MAX_METERS_PRIORITY
priority=METER_OVERRIDE_PRIORITY,
effects=[
SetTargetConstruction(value=MaxOf(float, Value, 1)),
SetConstruction(value=MaxOf(float, Value, 1)),
],
),
# Influence growth / reduction towards target, since outposts have no species to get this effect from
EffectsGroup(
scope=Planet() & OwnedBy(empire=Source.Owner) & (~HasSpecies()),
priority=AFTER_ALL_TARGET_MAX_METERS_PRIORITY,
effects=SetHappiness(
value=Value
+ MinOf(float, Abs(float, Value(Target.TargetHappiness) - Value), 1)
* (1 - 2 * (StatisticIf(float, condition=IsTarget & (Value > Value(Target.TargetHappiness)))))
),
),
# Reset influence to 0 if no policies adopted. Not really relevant to Outposts, but I need somewhere to put this...
EffectsGroup(
scope=IsSource,
activation=HasEmpireStockpile(empire=Source.Owner, resource=Influence, high=0)
& (NumPoliciesAdopted(empire=Source.Owner) == 0),
priority=METER_OVERRIDE_PRIORITY,
effects=SetEmpireStockpile(resource=Influence, value=0.0),
),
],
)
|