diff --git a/cdtweaks/languages/english/infravision.tra b/cdtweaks/languages/english/infravision.tra new file mode 100644 index 00000000..af6d452e --- /dev/null +++ b/cdtweaks/languages/english/infravision.tra @@ -0,0 +1 @@ +@0 = "Lack of Infravision" \ No newline at end of file diff --git a/cdtweaks/languages/english/weidu.tra b/cdtweaks/languages/english/weidu.tra index 06daf4ee..f522721c 100644 --- a/cdtweaks/languages/english/weidu.tra +++ b/cdtweaks/languages/english/weidu.tra @@ -463,7 +463,7 @@ The uninstall messages above are normal and expected. @267000 = "Dual-Wield feat for Rangers [Luke]" -@268000 = ~"Force" the Archer kit to use bows [Luke]~ +@268000 = ~PnP: -4 to hit in darkness (Dungeon or night areas) without the Infravision ability [Luke (EEex)]~ @269000 = "NWN-ish Armor vs. Dexterity [Luke]" diff --git a/cdtweaks/languages/italian/infravision.tra b/cdtweaks/languages/italian/infravision.tra new file mode 100644 index 00000000..fa882907 --- /dev/null +++ b/cdtweaks/languages/italian/infravision.tra @@ -0,0 +1 @@ +@0 = "Senza Infravisione" \ No newline at end of file diff --git a/cdtweaks/languages/italian/weidu.tra b/cdtweaks/languages/italian/weidu.tra index 738ea95a..59c1084f 100644 --- a/cdtweaks/languages/italian/weidu.tra +++ b/cdtweaks/languages/italian/weidu.tra @@ -416,6 +416,8 @@ o rimpiazzata da - un'altra facente parte di uno dei mods installati.~ @267000 = "Aggiungi talento Doppia-Presa per i Ranger [Luke]" +@268000 = "PnP: -4 ai tiri per colpire nelle aree buie (Dungeon) e di notte se non si ha l'Infravisione [Luke (EEex)]" + @269000 = "Armatura vs. Destrezza in stile NWN [Luke]" @270000 = "Aggiungi talento Tiro Difensivo per i ladri [Luke]" diff --git a/cdtweaks/lib/comp_2680.tpa b/cdtweaks/lib/comp_2680.tpa index d47a86f2..0b3f7af0 100644 --- a/cdtweaks/lib/comp_2680.tpa +++ b/cdtweaks/lib/comp_2680.tpa @@ -1,15 +1,17 @@ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -///// \\\\\ -///// "Force" the Archer kit to use bows \\\\\ -///// \\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +///// \\\\\ +///// PnP: -4 to hit in darkness (Dungeon or night areas) without the Infravision ability \\\\\ +///// \\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ WITH_SCOPE BEGIN - INCLUDE "cdtweaks\ardanis\functions.tph" - INCLUDE "cdtweaks\lib\revised_archer.tph" - WITH_TRA "cdtweaks\languages\english\revised_archer.tra" "cdtweaks\languages\%LANGUAGE%\revised_archer.tra" BEGIN - LAF "REVISED_ARCHER" END + INCLUDE "cdtweaks\luke\misc.tph" + // + INCLUDE "cdtweaks\lib\infravision.tph" + // + WITH_TRA "cdtweaks\languages\english\infravision.tra" "cdtweaks\languages\%LANGUAGE%\infravision.tra" BEGIN + LAF "LACK_OF_INFRAVISION" END END END \ No newline at end of file diff --git a/cdtweaks/lib/infravision.tph b/cdtweaks/lib/infravision.tph new file mode 100644 index 00000000..3b8ae155 --- /dev/null +++ b/cdtweaks/lib/infravision.tph @@ -0,0 +1,16 @@ +DEFINE_ACTION_FUNCTION "LACK_OF_INFRAVISION" +BEGIN + WITH_SCOPE BEGIN + COPY "cdtweaks\luke\bam\rule_changes\no_infravision.bam" "override\gtrule02.bam" + END + // + WITH_SCOPE BEGIN + LAF "ADD_STATDESC_ENTRY" INT_VAR "description" = RESOLVE_STR_REF (@0) STR_VAR "bam_file" = "gtrule02" RET "feedback_icon" = "index" END + // Listener: run 'func' each time a sprite has finished evaluating its effects + LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Misc Tweaks (Rule Changes)" "sourceFileSpec" = "cdtweaks\luke\lua\rule_changes\infravision.lua" "destRes" = "m_gtrule" END + // + ACTION_IF !(FILE_EXISTS_IN_GAME "m_gttbls.lua") BEGIN + COPY "cdtweaks\luke\lua\m_gttbls.lua" "override" + END + END +END \ No newline at end of file diff --git a/cdtweaks/luke/bam/rule_changes/no_infravision.bam b/cdtweaks/luke/bam/rule_changes/no_infravision.bam new file mode 100644 index 00000000..b5f4d955 Binary files /dev/null and b/cdtweaks/luke/bam/rule_changes/no_infravision.bam differ diff --git a/cdtweaks/luke/lua/m_gttbls.lua b/cdtweaks/luke/lua/m_gttbls.lua index 6861a6c6..4de5ef09 100644 --- a/cdtweaks/luke/lua/m_gttbls.lua +++ b/cdtweaks/luke/lua/m_gttbls.lua @@ -7,7 +7,7 @@ GT_Resource_SymbolToIDS = {} EEex_GameState_AddInitializedListener(function() -- 2DA EEex_Utility_NewScope(function() - local resources = { "STRMOD", "STRMODEX", "DEXMOD", "STYLBONU", "SNEAKATT" } + local resources = { "STRMOD", "STRMODEX", "DEXMOD", "STYLBONU", "SNEAKATT", "RACEFEAT" } -- for _, v in ipairs(resources) do local data = EEex_Resource_Load2DA(v) diff --git a/cdtweaks/luke/lua/rule_changes/infravision.lua b/cdtweaks/luke/lua/rule_changes/infravision.lua new file mode 100644 index 00000000..d30786ae --- /dev/null +++ b/cdtweaks/luke/lua/rule_changes/infravision.lua @@ -0,0 +1,83 @@ +--[[ ++--------------------------------------------------------------------------------+ +| cdtweaks, lack of infravision (-4 to hit in darkness (Dungeon or night areas)) | ++--------------------------------------------------------------------------------+ +--]] + +EEex_Opcode_AddListsResolvedListener(function(sprite) + -- Sanity check + if not EEex_GameObject_IsSprite(sprite) or not sprite.m_pArea then + return + end + -- internal function that applies the actual penalty + local apply = function() + -- Mark the creature as 'condition applied' + sprite:setLocalInt("cdtweaksNoInfravision", 1) + -- + local effectCodes = { + {["op"] = 321, ["res"] = "GTRULE02"}, -- Remove effects by resource + {["op"] = 54, ["p1"] = -4}, -- Base thac0 bonus + {["op"] = 142, ["p2"] = %feedback_icon%}, -- Display portrait icon + } + -- + for _, attributes in ipairs(effectCodes) do + sprite:applyEffect({ + ["effectID"] = attributes["op"] or EEex_Error("opcode number not specified"), + ["effectAmount"] = attributes["p1"] or 0, + ["dwFlags"] = attributes["p2"] or 0, + ["durationType"] = 9, + ["res"] = attributes["res"] or "", + ["m_sourceRes"] = "GTRULE02", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + end + end + -- + local playableRaces = { + ["HUMAN"] = true, + ["ELF"] = true, + ["HALF_ELF"] = true, + ["DWARF"] = true, + ["GNOME"] = true, + ["HALFLING"] = true, + ["HALFORC"] = true, + } + -- Check creature's race / state + local spriteRaceStr = GT_Resource_IDSToSymbol["race"][sprite.m_typeAI.m_Race] + local racefeat = GT_Resource_2DA["racefeat"] + local hasInnateInfravision = (GT_LuaTool_KeyExists(GT_Resource_2DA, "racefeat", spriteRaceStr, "VALUE") and tonumber(racefeat[spriteRaceStr]["VALUE"]) == 1) and true or false + -- since ``EEex_Opcode_AddListsResolvedListener`` is running after the effect lists have been evaluated, ``m_bonusStats`` has already been added to ``m_derivedStats`` by the engine + local spriteGeneralState = sprite.m_derivedStats.m_generalState + -- + local isDungeon = EEex_IsBitSet(sprite.m_pArea.m_header.m_areaType, 0x5) + local isOutdoor = EEex_IsBitSet(sprite.m_pArea.m_header.m_areaType, 0x0) + local isDayNight = EEex_IsBitSet(sprite.m_pArea.m_header.m_areaType, 0x1) + local isNight = EEex_Trigger_ParseConditionalString('TimeOfDay(NIGHT)') + -- + local applyCondition = not (hasInnateInfravision or EEex_IsBitSet(spriteGeneralState, 17)) and (isDungeon or (isOutdoor and isDayNight and isNight:evalConditionalAsAIBase(sprite))) + -- + if playableRaces[spriteRaceStr] then + if sprite:getLocalInt("cdtweaksNoInfravision") == 0 then + if applyCondition then + apply() + end + else + if applyCondition then + -- do nothing + else + -- Mark the creature as 'condition removed' + sprite:setLocalInt("cdtweaksNoInfravision", 0) + -- + sprite:applyEffect({ + ["effectID"] = 321, -- Remove effects by resource + ["res"] = "GTRULE02", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + end + end + end + -- + isNight:free() +end) diff --git a/cdtweaks/readme-cdtweaks.html b/cdtweaks/readme-cdtweaks.html index 84c933fc..8103d4b7 100644 --- a/cdtweaks/readme-cdtweaks.html +++ b/cdtweaks/readme-cdtweaks.html @@ -1011,22 +1011,11 @@
Dual-Wield feat for Rangers [Luke]
EEex
This component simply forces Rangers to wield light armors (or no armor) in order to benefit from Two-Weapon Fighting.
- NWN-ish Armor vs. Dexterity [Luke]
+
PnP: -4 THAC0 in darkness (Dungeon / night areas) [Luke]
EEex
This component simply "forces" characters to wield light armors (or no armor) if they have high Dexterity. - In particular:
-dexmod.2da
)
- 18
DEX equipped with a Chain Mail Armor will suffer a -4 / 2 = -2
AC penalty.dexmod.2da
)
- 18
DEX equipped with a Plate Mail will suffer a -4
AC penalty.+ All creatures without the Infravision ability will incur a -4 penalty to THAC0 in darkness (Dungeon or night areas), as per AD&D rules. +
Defensive Roll feat for Thieves [Luke]
EEex
This component aims at implementing the NWN feat Defensive Roll. As a result, after installing it, if the character is struck by a potentially lethal blow, he makes a Save vs. Breath. If successful, he takes only half damage from the blow.
diff --git a/cdtweaks/setup-cdtweaks.tp2 b/cdtweaks/setup-cdtweaks.tp2 index 5e97fb6f..50e0131a 100644 --- a/cdtweaks/setup-cdtweaks.tp2 +++ b/cdtweaks/setup-cdtweaks.tp2 @@ -2836,19 +2836,20 @@ REQUIRE_PREDICATE MOD_IS_INSTALLED ~EEex.tp2~ 0 @29 REQUIRE_PREDICATE FILE_EXISTS ~cdtweaks/languages/%LANGUAGE%/dual_wield.tra~ @7 LABEL ~cd_tweaks_dual_wield~ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -///// \\\\\ -///// "Force" the Archer kit to use bows \\\\\ -///// \\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +///// \\\\\ +///// PnP: -4 to hit in darkness (Dungeon or night areas) without the Infravision ability \\\\\ +///// \\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ BEGIN @268000 DESIGNATED 2680 GROUP @9 +REQUIRE_PREDICATE GAME_IS "bgee bg2ee eet iwdee" @25 REQUIRE_PREDICATE MOD_IS_INSTALLED ~EEex.tp2~ 0 @29 -REQUIRE_PREDICATE FILE_EXISTS ~cdtweaks/languages/%LANGUAGE%/revised_archer.tra~ @7 -LABEL ~cd_tweaks_revised_archer~ +REQUIRE_PREDICATE FILE_EXISTS ~cdtweaks/languages/%LANGUAGE%/infravision.tra~ @7 +LABEL ~cd_tweaks_infravision~ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\