Skip to content

Commit

Permalink
wh3 4.0 update
Browse files Browse the repository at this point in the history
  • Loading branch information
Cpecific committed Sep 3, 2023
1 parent d778815 commit 0755d1b
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 53 deletions.
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Ultimate Ancillary Guide</title>
<link rel="stylesheet" href="output/html/style.css?10" />
<link rel="stylesheet" href="output/html/style.css?11" />
</head>
<body>
<div id="root">
Expand Down Expand Up @@ -58,7 +58,7 @@
</div>
</div>
</div>
<script src="output/html/warhammer_3.js?10"></script>
<script src="output/html/entry.js?10"></script>
<script src="output/html/warhammer_3.js?11"></script>
<script src="output/html/entry.js?11"></script>
</body>
</html>
5 changes: 3 additions & 2 deletions input/warhammer_3/wh3_campaign_followers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3275,7 +3275,7 @@ local followers = {
["condition"] =
function(context)
local character = context:character();
return not character:has_ancillary("wh3_main_anc_follower_ksl_priest_of_taal") and cm:character_won_battle_against_culture(character, {"wh_main_chs_chaos", "wh_dlc08_nor_norsca", "wh_dlc03_bst_beastmen", "wh3_main_dae_daemons", "wh3_main_kho_khorne", "wh3_main_nur_nurgle", "wh3_main_sla_slaanesh", "wh3_main_tze_tzeentch"});
return has_devotion_pooled_resource(character:faction()) and not character:has_ancillary("wh3_main_anc_follower_ksl_priest_of_taal") and cm:character_won_battle_against_culture(character, {"wh_main_chs_chaos", "wh_dlc08_nor_norsca", "wh_dlc03_bst_beastmen", "wh3_main_dae_daemons", "wh3_main_kho_khorne", "wh3_main_nur_nurgle", "wh3_main_sla_slaanesh", "wh3_main_tze_tzeentch"});
end,
["chance"] = 5
},
Expand All @@ -3285,7 +3285,8 @@ local followers = {
["condition"] =
function(context)
local target_character_culture = context:target_character():faction():culture();
return not context:character():has_ancillary("wh3_main_anc_follower_ksl_priest_of_ursun") and (target_character_culture == "wh_main_chs_chaos" or target_character_culture == "wh_dlc08_nor_norsca" or target_character_culture == "wh_dlc03_bst_beastmen" or target_character_culture == "wh3_main_dae_daemons" or target_character_culture == "wh3_main_kho_khorne" or target_character_culture == "wh3_main_nur_nurgle" or target_character_culture == "wh3_main_sla_slaanesh" or target_character_culture == "wh3_main_tze_tzeentch") and (context:mission_result_success() or context:mission_result_critial_success()) and context:ability() ~= "assist_army";
local character = context:character();
return has_devotion_pooled_resource(character:faction()) and not character:has_ancillary("wh3_main_anc_follower_ksl_priest_of_ursun") and (target_character_culture == "wh_main_chs_chaos" or target_character_culture == "wh_dlc08_nor_norsca" or target_character_culture == "wh_dlc03_bst_beastmen" or target_character_culture == "wh3_main_dae_daemons" or target_character_culture == "wh3_main_kho_khorne" or target_character_culture == "wh3_main_nur_nurgle" or target_character_culture == "wh3_main_sla_slaanesh" or target_character_culture == "wh3_main_tze_tzeentch") and (context:mission_result_success() or context:mission_result_critial_success()) and context:ability() ~= "assist_army";
end,
["chance"] = 5
},
Expand Down
3 changes: 1 addition & 2 deletions input/warhammer_3/wh3_campaign_magic_items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ local ancillary_list = {
"wh3_main_anc_weapon_dawn_glaive",
"wh3_main_anc_weapon_hellblade",
"wh3_dlc20_anc_weapon_aether_sword",
"wh3_dlc20_anc_weapon_axe_of_khorne",
"wh3_dlc20_anc_weapon_rapier_of_ecstacy"
"wh3_dlc20_anc_weapon_rapier_of_ecstasy"
},
},

Expand Down
4 changes: 2 additions & 2 deletions output/html/warhammer_3.js
Original file line number Diff line number Diff line change
Expand Up @@ -3024,13 +3024,13 @@ null, "All Races"]
"Priest of Taal",
"Devotion gained from fighting Chaos: +5% (factionwide)",
[b,d],
5, ["(<u title=\"Main Lord - the one, who leads the attack/defense\">Lord</u>; against: Warriors of Chaos, Norsca, Beastmen, Daemons of Chaos, Khorne, Nurgle, Slaanesh, Tzeentch)\nWin battle", 3,
5, ["(<u title=\"Main Lord - the one, who leads the attack/defense\">Lord</u>; against: Warriors of Chaos, Norsca, Beastmen, Daemons of Chaos, Khorne, Nurgle, Slaanesh, Tzeentch)\nWin battle, and your faction must have resource <img src=\"output/html/wh3/ui/campaign ui/effect_bundles/devotion.png\" icon=\"icon_devotion.png\" /> “Devotion”", 3,
[false, "Function *character_won_battle_against_culture* will work, only if your faction is Main Attacker/Defender,\nonly compares cultures of the Main Attacker/Defender on both sides,\nand it will skip any rebels factions"]]],
["wh3/ui/campaign ui/ancillaries/wh3_main_anc_kislev_priest.png",
"Priest of Ursun",
"Devotion gained from successful <img src=\"output/html/wh3/ui/common ui/unit_category_icons/hero.png\" icon=\"icon_hero\" />Hero actions: +15%",
[d],
5, ["(against: Warriors of Chaos, Norsca, Beastmen, Daemons of Chaos, Khorne, Nurgle, Slaanesh, Tzeentch)\nPerform (critical) successfull action against another character other than “Assist Army”", 3]],
5, ["(against: Warriors of Chaos, Norsca, Beastmen, Daemons of Chaos, Khorne, Nurgle, Slaanesh, Tzeentch)\nPerform (critical) successfull action against another character other than “Assist Army”, and your faction must have resource <img src=\"output/html/wh3/ui/campaign ui/effect_bundles/devotion.png\" icon=\"icon_devotion.png\" /> “Devotion”", 3]],
["wh3/ui/campaign ui/ancillaries/wh3_main_anc_kislev_priest.png",
"Ritual Enforcer",
"Corruption: -2 <span class=\"nowr\">(local</span> <span class=\"nowr\">province)</span>",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 31 additions & 9 deletions src/build-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ export const findAncillary = (key: string): ICAncillary => {
};
const _getIconCache = new Map<string, string>();
const getIcon = async (icon: string): Promise<string> => {
if (/\.png$/.test(icon)) { icon = icon.substr(0, icon.length - 4); }
if (_getIconCache.has(icon)) {
return _getIconCache.get(icon)!;
}
Expand All @@ -421,6 +422,7 @@ const getIcon = async (icon: string): Promise<string> => {
const promiseList: Promise<boolean>[] = [];
const dirList: [string, boolean][] = [
['ui/skins/default/', false],
// ['ui/skins/warhammer_3/', false],
['ui/campaign ui/effect_bundles/', true],
['ui/common ui/unit_category_icons/', false],
['ui/common ui/unit_category_icons/', true],
Expand Down Expand Up @@ -798,12 +800,14 @@ export const printTextNode = (self: TextNode[], format: (v: TextNode) => string)
};
// TODO ancillary_to_included_agents
// TODO ancillaries_included_agent_subtypes
const buildTriggerDesc = () => {
const buildTriggerDesc = async () => {
const { trigger, group } = context;
const subcultureSubset = ctx_getSubcultureSubset();
// const ancillaryKey = ancData.key;
let { notObviousHeroEvent, onlyMainLord } = ctx_getEventData();
return trigger.condition.map((c, cIdx) => {
const ret = []
for (let cIdx = 0; cIdx < trigger.condition.length; ++cIdx) {
const c = trigger.condition[cIdx];
let allowed: TextNode[] = [];
let allowedGreenKnight = false; // c.allowed.default: case 'no-green-knight':
let allowedNormal = false; // c.allowed.default: case 'normal':
Expand Down Expand Up @@ -992,7 +996,14 @@ const buildTriggerDesc = () => {
hasEmpty: false,
};
context.condition = c;
let text = c.text().replace(/\{(.*?)\}(\s?)/g, (_, q: string, space: string) => {
let text;
let textValue = c.text()
if (typeof textValue === 'string') {
text = textValue;
} else {
text = await textValue;
}
text = text.replace(/\{(.*?)\}(\s?)/g, (_, q: string, space: string) => {
const qList = q.split(',');
const ret: string[] = [];
for (const val of qList) {
Expand Down Expand Up @@ -1035,16 +1046,17 @@ const buildTriggerDesc = () => {
if (c.unique) { c.prevent = true; }

const bug = TransformBug(c.bug);
return {
ret.push({
c,
impossible: !!bug.value,
top,
text,
flags: {
normal: allowedNormal,
},
};
});
});
}
return ret;
};

interface IParsedAncillaryInfo {
Expand Down Expand Up @@ -1186,7 +1198,7 @@ export interface IParsedTrigger {
trigger: ITrigger;
chance: number | null;
repeat?: number;
triggerDesc: ReturnType<typeof buildTriggerDesc>;
triggerDesc: ReturnType<typeof buildTriggerDesc> extends Promise<infer R> ? R : never;
}
export interface IParsed {
// subcultureSubset: SubCultureType[];
Expand All @@ -1195,7 +1207,7 @@ export interface IParsed {
tirggerList: IParsedTrigger[];
}
let context: IContext;
export const parseTrigger = (opts: {
export const parseTrigger = async (opts: {
// ancillaryKey > IParsed
// parsed: Map<string, Map<string, IParsed>>;
parsed: Map<string, IParsed>;
Expand Down Expand Up @@ -1237,7 +1249,7 @@ export const parseTrigger = (opts: {
const parsedAncillary = parsed.get(ancData.key)!;
if (parsedAncillary.tirggerList.some(v => v.trigger === trigger)) { continue; }

const triggerDesc = !trigger.event ? [] : buildTriggerDesc();
const triggerDesc = !trigger.event ? [] : await buildTriggerDesc();
let chance: number | undefined | null = null;
if (typeof ancData.chance === 'undefined') {
assert(!trigger.event);
Expand Down Expand Up @@ -1555,6 +1567,16 @@ export const unit = (keyList: string[], hideCaption?: boolean) => {
}
return `${hideCaption ? '' : 'unit '}${typical_output(ret)}`;
};
export const resource = async (keyList: string[], hideCaption?: boolean) => {
const ret: string[] = [];
for (const unitKey of keyList) {
const row = DB.pooled_resources.getEntry([unitKey])!;
const icon = row['optional_icon_path'] as string;
const path = await getIcon(icon);
ret.push(`<img src="${path}" icon="${icon}" /> “${row['@display_name']}”`);
}
return `${hideCaption ? '' : 'resource '}${typical_output(ret)}`;
};
export const agent = (keyList: AgentType[], hideCaption?: boolean) => {
const ret: string[] = [];
for (const unitKey of keyList) {
Expand Down
2 changes: 1 addition & 1 deletion src/data-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ export interface IDataCondition {
culture?: CultureType[];
subculture?: SubCultureType[];
}
text: () => string;
text: () => string | Promise<string>;
}
export interface IDataAncillary {
/** В условии допущена роковая ошибка, которая не позволит получить данный фолловер */
Expand Down
38 changes: 19 additions & 19 deletions src/data-warhammer_3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
region,
technology,
unit,
resource,
} from './build-data';

const alwaysFalse = true;
Expand Down Expand Up @@ -277,7 +278,7 @@ export const ca_ancillary_list = {
"wh3_main_anc_armour_weird_plate"
],
},

enchanted_item: {
common: [
"wh_main_anc_enchanted_item_featherfoe_torc",
Expand Down Expand Up @@ -306,7 +307,7 @@ export const ca_ancillary_list = {
"wh3_main_anc_enchanted_item_rock_eye",
"wh3_main_anc_enchanted_item_astromancers_spyglass"
],

uncommon: [
"wh_dlc05_anc_enchanted_item_hail_of_doom_arrow",
"wh_dlc07_anc_enchanted_item_holy_icon",
Expand Down Expand Up @@ -349,7 +350,7 @@ export const ca_ancillary_list = {
"wh3_dlc20_anc_enchanted_item_the_beguiling_gem",
"wh3_dlc20_anc_item_the_festering_shroud"
],

rare: [
"wh_dlc03_anc_enchanted_item_horn_of_the_first_beast",
"wh_dlc03_anc_enchanted_item_shard_of_the_herdstone",
Expand Down Expand Up @@ -382,7 +383,7 @@ export const ca_ancillary_list = {
"wh3_main_anc_enchanted_item_enthralling_musk"
],
},

banner: {
common: [
"wh_dlc03_anc_magic_standard_banner_of_outrage",
Expand Down Expand Up @@ -425,7 +426,7 @@ export const ca_ancillary_list = {
"wh3_main_anc_magic_standard_bull_standard",
"wh3_main_anc_magic_standard_standard_of_wei_jin"
],

uncommon: [
"wh_dlc03_anc_mark_of_chaos_slug_skin",
"wh_main_anc_magic_standard_banner_of_lost_holds",
Expand Down Expand Up @@ -468,7 +469,7 @@ export const ca_ancillary_list = {
"wh3_main_anc_magic_standard_standard_of_nan_gau",
"wh3_main_anc_magic_standard_standard_of_seeping_decay"
],

rare: [
"wh_dlc03_anc_magic_standard_manbane_standard",
"wh_dlc03_anc_magic_standard_the_beast_banner",
Expand Down Expand Up @@ -507,7 +508,7 @@ export const ca_ancillary_list = {
"wh3_main_anc_magic_standard_flag_of_grand_cathay"
],
},

talisman: {
common: [
"wh_main_anc_talisman_dragonbane_gem",
Expand All @@ -528,7 +529,7 @@ export const ca_ancillary_list = {
"wh3_main_anc_talisman_jade_blood_pendant",
"wh3_main_anc_talisman_spangleshard"
],

uncommon: [
"wh_dlc03_anc_talisman_chalice_of_dark_rain",
"wh_dlc07_anc_talisman_siriennes_locket",
Expand Down Expand Up @@ -557,7 +558,7 @@ export const ca_ancillary_list = {
"wh3_main_anc_talisman_jade_amulet",
"wh3_main_anc_talisman_gnoblar_thiefstone"
],

rare: [
"wh_main_anc_talisman_talisman_of_preservation",
"wh_main_anc_talisman_the_white_cloak_of_ulric",
Expand All @@ -582,7 +583,7 @@ export const ca_ancillary_list = {
"wh3_main_anc_talisman_warp_mirror"
],
},

weapon: {
common: [
"wh_dlc03_anc_weapon_everbleed",
Expand Down Expand Up @@ -616,7 +617,7 @@ export const ca_ancillary_list = {
"wh3_main_anc_weapon_the_tenderiser",
"wh3_main_anc_weapon_plague_flail"
],

uncommon: [
"wh_dlc03_anc_weapon_axes_of_khorgor",
"wh_dlc03_anc_weapon_hunting_spear",
Expand Down Expand Up @@ -647,7 +648,7 @@ export const ca_ancillary_list = {
"wh3_main_anc_weapon_vorpal_shard",
"wh3_dlc20_anc_weapon_sword_of_change",
],

rare: [
"wh_dlc03_anc_weapon_axe_of_men",
"wh_dlc03_anc_weapon_mangelder",
Expand Down Expand Up @@ -707,11 +708,10 @@ export const ca_ancillary_list = {
"wh3_main_anc_weapon_dawn_glaive",
"wh3_main_anc_weapon_hellblade",
"wh3_dlc20_anc_weapon_aether_sword",
"wh3_dlc20_anc_weapon_axe_of_khorne",
"wh3_dlc20_anc_weapon_rapier_of_ecstacy"
"wh3_dlc20_anc_weapon_rapier_of_ecstasy"
],
},

arcane_item: {
common: [
"wh_dlc07_anc_arcane_item_sacrament_of_the_lady",
Expand Down Expand Up @@ -741,7 +741,7 @@ export const ca_ancillary_list = {
"wh3_main_anc_arcane_item_bangstick",
"wh3_main_anc_arcane_item_wand_of_whimsey"
],

uncommon: [
"wh_main_anc_arcane_item_forbidden_rod",
"wh_main_anc_arcane_item_staff_of_damnation",
Expand All @@ -759,7 +759,7 @@ export const ca_ancillary_list = {
"wh3_main_anc_arcane_item_maw_shard",
"wh3_main_anc_arcane_item_scrolls_of_astromancy"
],

rare: [
"wh_main_anc_arcane_item_black_periapt",
"wh_main_anc_arcane_item_book_of_ashur",
Expand Down Expand Up @@ -4293,7 +4293,7 @@ otherwise will check in forces of attackers`
]
},
prevent,
text: () => `Win battle`
text: async () => `Win battle, and your faction must have ${await resource(['wh3_main_ksl_devotion'])}`
}],
ancillaryList: [{
chance: 5,
Expand All @@ -4315,7 +4315,7 @@ otherwise will check in forces of attackers`
]
},
prevent,
text: () => `Perform (critical) successfull action against another character other than “Assist Army”`
text: async () => `Perform (critical) successfull action against another character other than “Assist Army”, and your faction must have ${await resource(['wh3_main_ksl_devotion'])}`
}],
ancillaryList: [{
chance: 5,
Expand Down
Loading

0 comments on commit 0755d1b

Please sign in to comment.