Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New component: Better Infravision #120

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions cdtweaks/languages/english/infravision.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@0 = "Lack of Infravision"
2 changes: 1 addition & 1 deletion cdtweaks/languages/english/weidu.tra
Original file line number Diff line number Diff line change
Expand Up @@ -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]"

Expand Down
1 change: 1 addition & 0 deletions cdtweaks/languages/italian/infravision.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@0 = "Senza Infravisione"
2 changes: 2 additions & 0 deletions cdtweaks/languages/italian/weidu.tra
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand Down
24 changes: 13 additions & 11 deletions cdtweaks/lib/comp_2680.tpa
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions cdtweaks/lib/infravision.tph
Original file line number Diff line number Diff line change
@@ -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
Binary file added cdtweaks/luke/bam/rule_changes/no_infravision.bam
Binary file not shown.
2 changes: 1 addition & 1 deletion cdtweaks/luke/lua/m_gttbls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
83 changes: 83 additions & 0 deletions cdtweaks/luke/lua/rule_changes/infravision.lua
Original file line number Diff line number Diff line change
@@ -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)
19 changes: 4 additions & 15 deletions cdtweaks/readme-cdtweaks.html
Original file line number Diff line number Diff line change
Expand Up @@ -1011,22 +1011,11 @@ <h3> <a id="contents_rules" name="contents_rules"></a>Rule Changes </h3>
<p> <strong>Dual-Wield feat for Rangers [Luke]</strong><br />
<em><abbr title="Enhanced Edition">EEex</abbr></em></p>
<p> This component simply forces Rangers to wield light armors (or no armor) in order to benefit from Two-Weapon Fighting.</p>
<p> <strong>NWN-ish Armor vs. Dexterity [Luke]</strong><br />
<p> <strong>PnP: -4 THAC0 in darkness (Dungeon / night areas) [Luke]</strong><br />
<em><abbr title="Enhanced Edition">EEex</abbr></em></p>
<p> This component simply &quot;forces&quot; characters to wield light armors (or no armor) if they have high Dexterity.
In particular: </p>
<ul>
<li>If a character is equipped with a Medium Armor, it will only benefit from half the bonus derived from its Dexterity (see <a href="https://gibberlings3.github.io/iesdp/files/2da/2da_bgee/dexmod.htm"><code>dexmod.2da</code></a>)
<ul>
<li>So for instance, a character with <code>18</code> DEX equipped with a Chain Mail Armor will suffer a <code>-4 / 2 = -2</code> AC penalty.</li>
</ul>
</li>
<li>If a character is equipped with a Heavy Armor, it will not benefit from the bonus derived from its Dexterity (see <a href="https://gibberlings3.github.io/iesdp/files/2da/2da_bgee/dexmod.htm"><code>dexmod.2da</code></a>)
<ul>
<li>So for instance, a character with <code>18</code> DEX equipped with a Plate Mail will suffer a <code>-4</code> AC penalty.</li>
</ul>
</li>
</ul>
<p>
All creatures without the Infravision ability will incur a -4 penalty to THAC0 in darkness (Dungeon or night areas), as per AD&D rules.
</p>
<p> <strong>Defensive Roll feat for Thieves [Luke]</strong><br />
<em><abbr title="Enhanced Edition">EEex</abbr></em></p>
<p> 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.</p>
Expand Down
19 changes: 10 additions & 9 deletions cdtweaks/setup-cdtweaks.tp2
Original file line number Diff line number Diff line change
Expand Up @@ -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~

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
Expand Down