Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mods/ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,3 +435,5 @@
TYPE_GARRISON = 3
ATTR_MODIFIER_MULTIPLY = 5
ATTR_WORK_RATE = 13

TYPE_UNIT_VISION_GRANT_EFFECT = 204
61 changes: 60 additions & 1 deletion mods/rewarding_snipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,69 @@
from genieutils.datfile import DatFile

from mods.ids import KING, RELIC_CART, TYPE_POPULATION_HEADROOM, TYPE_GIVE_AND_TAKE, \
TYPE_BONUS_POPULATION_CAP
TYPE_BONUS_POPULATION_CAP, TYPE_UNIT_VISION_GRANT_EFFECT, TYPE_RESOURCE_MODIFIER

from genieutils.effect import EffectCommand, Effect

from genieutils.tech import Tech, ResearchResourceCost, ResearchLocation

from mods.util import clone

NAME = 'rewarding-snipes'


def add_tech_for_relic_cart_vision_to_each_civ(data: DatFile, relic_cart_unit_id: int, version: str):
effect_command = EffectCommand(
type=TYPE_RESOURCE_MODIFIER,
a=TYPE_UNIT_VISION_GRANT_EFFECT,
b=0, # mode
c=-1,
d=-(relic_cart_unit_id) # negative unit ID to grant vision always and not just on creation.
)

effect = Effect(
name='Give Relic Cart Vision to Civ',
effect_commands=[effect_command]
)
effect_id = len(data.effects)
data.effects.append(effect)

for civ_id, civ in enumerate(data.civs):
tech = Tech(
required_techs=(-1, -1, -1, -1, -1, -1),
resource_costs=(
ResearchResourceCost(type=-1, amount=0, flag=0),
ResearchResourceCost(type=-1, amount=0, flag=0),
ResearchResourceCost(type=-1, amount=0, flag=0),
),
required_tech_count=0,
civ=civ_id,
full_tech_mode=0,
research_location=-1, # no specific location
language_dll_name=0,
language_dll_description=0,
research_time=0,
effect_id=effect_id,
type=0,
icon_id=-1,
button_id=1,
language_dll_help=0,
language_dll_tech_tree=0,
hot_key=0,
Comment on lines +45 to +55
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, I just changed this in genieutils-py 0.1.0 so you don't have to give research_location, research_time, button_id and hot_key anymore since that's now in research_locations

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if you remove those four lines it should work again with the most recent genieutils-py version

name='Grant Civ Relic Cart Vision',
repeatable=1,
research_locations=[
ResearchLocation(
location_id=-1,
research_time=0,
button_id=0,
hot_key_id=-1,
)
]
)
logging.info(f'Adding relic cart vision tech for civ {civ.name} with id {len(data.techs)}')
data.techs.append(tech)

def clone_and_patch_relic_cart(civ: Civ, version: str):
clone_unit_id = len(civ.units)
cloned_unit = clone(civ.units[RELIC_CART], version)
Expand Down Expand Up @@ -39,6 +96,8 @@ def patch_kings(data: DatFile):
king.blood_unit_id = relic_cart_id # use blood unit so it does not conflict with exploding kings
logging.info(f'Patched king blood unit for civ {civ.name}')

add_tech_for_relic_cart_vision_to_each_civ(data, relic_cart_id, data.version)


def mod(data: DatFile):
patch_kings(data)