From cc4bc505441f671d92895a472440020e32ab62b1 Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Thu, 12 Sep 2024 11:04:33 +0200 Subject: [PATCH 1/3] Bears and Boars Make Bears and Boars continue fighting after reaching 0 hit points. --- cdtweaks/languages/english/weidu.tra | 2 + cdtweaks/languages/italian/weidu.tra | 2 + cdtweaks/lib/innate_animal_last_stand.tph | 12 ++ cdtweaks/luke/lua/race/animal_last_stand.lua | 166 +++++++++++++++++++ cdtweaks/readme-cdtweaks.html | 12 ++ cdtweaks/setup-cdtweaks.tp2 | 13 ++ 6 files changed, 207 insertions(+) create mode 100644 cdtweaks/lib/innate_animal_last_stand.tph create mode 100644 cdtweaks/luke/lua/race/animal_last_stand.lua diff --git a/cdtweaks/languages/english/weidu.tra b/cdtweaks/languages/english/weidu.tra index 06daf4e..0441cfe 100644 --- a/cdtweaks/languages/english/weidu.tra +++ b/cdtweaks/languages/english/weidu.tra @@ -485,6 +485,8 @@ The uninstall messages above are normal and expected. @278000 = "Circle Kick class feat for Monks [Luke]" +@282000 = "Make Bears and Boars continue fighting after reaching 0 hit points [Luke]" + /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ ///// \\\\\ diff --git a/cdtweaks/languages/italian/weidu.tra b/cdtweaks/languages/italian/weidu.tra index 738ea95..37f46ba 100644 --- a/cdtweaks/languages/italian/weidu.tra +++ b/cdtweaks/languages/italian/weidu.tra @@ -436,6 +436,8 @@ o rimpiazzata da - un'altra facente parte di uno dei mods installati.~ @278000 = "Aggiungi talento di classe Calcio Rotante per i Monaci [Luke]" +@282000 = "Gli Orsi e i Cinghiali continueranno a combattere dopo aver raggiunto 0 punti ferita [Luke]" + /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ ///// \\\\\ diff --git a/cdtweaks/lib/innate_animal_last_stand.tph b/cdtweaks/lib/innate_animal_last_stand.tph new file mode 100644 index 0000000..1871b88 --- /dev/null +++ b/cdtweaks/lib/innate_animal_last_stand.tph @@ -0,0 +1,12 @@ +DEFINE_ACTION_FUNCTION "INNATE_ANIMAL_LAST_STAND" +BEGIN + LAF "GT_ADD_SPELL" + STR_VAR + "idsName" = "INNATE_ANIMAL_LAST_STAND" + RET + "INNATE_ANIMAL_LAST_STAND" = "resName" + END + // + LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Misc Tweaks (Innate)" "sourceFileSpec" = "cdtweaks\luke\lua\race\animal_last_stand.lua" "destRes" = "m_gtspin" END + LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Utility Functions / Listeners" "sourceFileSpec" = "cdtweaks\luke\lua\utility\effect_check.lua" "destRes" = "m_gtutil" END +END \ No newline at end of file diff --git a/cdtweaks/luke/lua/race/animal_last_stand.lua b/cdtweaks/luke/lua/race/animal_last_stand.lua new file mode 100644 index 0000000..7aae8b1 --- /dev/null +++ b/cdtweaks/luke/lua/race/animal_last_stand.lua @@ -0,0 +1,166 @@ +-- cdtweaks, Last Stand innate feat for Bears and Boars: op208 grants protection from directly applied op13, so make sure to kill the creature -- + +--[[function %INNATE_ANIMAL_LAST_STAND%(op403CGameEffect, CGameEffect, CGameSprite) + local immunityToKill = EEex_Trigger_ParseConditionalString("EEex_IsImmuneToOpcode(Myself,13)") + -- + if not immunityToKill:evalConditionalAsAIBase(CGameSprite) and CGameEffect.m_effectId == 0xD then + CGameSprite:applyEffect({ + ["effectID"] = CGameEffect.m_effectId, + ["durationType"] = CGameEffect.m_durationType, + ["duration"] = CGameEffect.m_duration, + ["dwFlags"] = CGameEffect.m_dWFlags, + ["effectAmount"] = CGameEffect.m_effectAmount, + ["savingThrow"] = CGameEffect.m_savingThrow, + ["saveMod"] = CGameEffect.m_saveMod, + ["m_maxLevel"] = CGameEffect.m_maxLevel, + ["m_minLevel"] = CGameEffect.m_minLevel, + ["spellLevel"] = CGameEffect.m_spellLevel, + ["m_sourceFlags"] = CGameEffect.m_sourceFlags, + ["m_slotNum"] = CGameEffect.m_slotNum, + ["m_casterLevel"] = CGameEffect.m_casterLevel, + ["m_sourceRes"] = CGameEffect.m_sourceRes, + ["m_sourceType"] = CGameEffect.m_sourceType, + ["noSave"] = true, -- ignore immunity provided by op208 + ["sourceID"] = CGameEffect.m_sourceId, + ["sourceTarget"] = CGameEffect.m_sourceTarget, + }) + -- + return true + end +end--]] + +-- cdtweaks, Last Stand innate feat for Bears and Boars: The boar/bear will fight for (1d4/1d4+1) rounds after reaching 0 hit points. The creature will go berserk attacking friends and foes alike + +EEex_Opcode_AddListsResolvedListener(function(sprite) + -- Sanity check + if not EEex_GameObject_IsSprite(sprite) then + return + end + -- Check creature's general / class / race / animate + local spriteGeneralStr = GT_Resource_IDSToSymbol["general"][sprite.m_typeAI.m_General] + local spriteRaceStr = GT_Resource_IDSToSymbol["race"][sprite.m_typeAI.m_Race] + local spriteClassStr = GT_Resource_IDSToSymbol["class"][sprite.m_typeAI.m_Class] + local spriteAnimateStr = GT_Resource_IDSToSymbol["animate"][sprite.m_animation.m_animation.m_animationID] + -- + local modifier = -1 + -- + if spriteGeneralStr == "ANIMAL" then + if spriteRaceStr == "BEAR" then + if spriteClassStr == "BEAR_BROWN" or spriteClassStr == "BEAR_CAVE" then + modifier = 0 + elseif spriteClassStr == "BEAR_POLAR" then + modifier = 1 + end + elseif spriteAnimateStr == "BOAR_ARCTIC" or spriteAnimateStr == "BOAR_WILD" then + modifier = 1 + end + end + -- + local roll = modifier + Infinity_RandomNumber(1, 4) -- 1d4 / 1d4+1 + -- + if sprite:getLocalInt("cdtweaksAnimalLastStand") == 1 then + if sprite.m_nLastDamageTaken >= sprite.m_baseStats.m_hitPoints and not GT_Utility_EffectCheck(sprite, {["m_effectId"] = 55, ["m_sourceRes"] = "%INNATE_ANIMAL_LAST_STAND%B"}) then + local lastHitter = EEex_GameObject_Get(sprite.m_lHitter.m_Instance) + -- + local effectCodes = { + {["op"] = 3, ["p2"] = 1, ["dur"] = 6 * roll}, -- berserk (mode: constant) + {["op"] = 176, ["p2"] = 5, ["p1"] = 200, ["dur"] = 6 * roll}, -- movement rate bonus (200%) + {["op"] = 215, ["res"] = "ICSTRENI", ["p2"] = 1, ["dur"] = 2}, -- play visual effect (over target: attached) + {["op"] = 142, ["p2"] = 4, ["dur"] = 6 * roll}, -- icon: berserk + {["op"] = 55, ["p2"] = 2, ["dur"] = 6 * roll, ["tmg"] = 4}, -- slay creature + } + -- + for _, attributes in ipairs(effectCodes) do + sprite:applyEffect({ + ["effectID"] = attributes["op"] or -1, + ["effectAmount"] = attributes["p1"] or 0, + ["dwFlags"] = attributes["p2"] or 0, + ["res"] = attributes["res"] or "", + ["duration"] = attributes["dur"] or 0, + ["durationType"] = attributes["tmg"] or 0, + ["m_sourceRes"] = "%INNATE_ANIMAL_LAST_STAND%B", + ["m_sourceType"] = 1, + ["noSave"] = true, + ["sourceID"] = lastHitter.m_id, + ["sourceTarget"] = sprite.m_id, + }) + end + end + end +end) + +-- cdtweaks, Last Stand innate feat for Bears and Boars: Apply passive trait -- + +EEex_Opcode_AddListsResolvedListener(function(sprite) + -- Sanity check + if not EEex_GameObject_IsSprite(sprite) then + return + end + -- internal function that applies the actual feat + local apply = function() + -- Mark the creature as 'feat applied' + sprite:setLocalInt("cdtweaksAnimalLastStand", 1) + -- + sprite:applyEffect({ + ["effectID"] = 321, -- Remove effects by resource + ["res"] = "%INNATE_ANIMAL_LAST_STAND%", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + sprite:applyEffect({ + ["effectID"] = 208, -- Min HP + ["effectAmount"] = 1, + ["durationType"] = 9, + ["m_sourceRes"] = "%INNATE_ANIMAL_LAST_STAND%", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + --[[sprite:applyEffect({ + ["effectID"] = 403, -- Screen effects + ["effectAmount"] = modifier, + ["durationType"] = 9, + ["res"] = "%INNATE_ANIMAL_LAST_STAND%", -- Lua func + ["m_sourceRes"] = "%INNATE_ANIMAL_LAST_STAND%", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + })--]] + + end + -- Check creature's general / class / race / animate + local spriteGeneralStr = GT_Resource_IDSToSymbol["general"][sprite.m_typeAI.m_General] + local spriteRaceStr = GT_Resource_IDSToSymbol["race"][sprite.m_typeAI.m_Race] + local spriteClassStr = GT_Resource_IDSToSymbol["class"][sprite.m_typeAI.m_Class] + local spriteAnimateStr = GT_Resource_IDSToSymbol["animate"][sprite.m_animation.m_animation.m_animationID] + -- + local applyAbility = false + -- + if spriteGeneralStr == "ANIMAL" then + if spriteRaceStr == "BEAR" then + if spriteClassStr == "BEAR_BROWN" or spriteClassStr == "BEAR_CAVE" or spriteClassStr == "BEAR_POLAR" then + applyAbility = true + end + elseif spriteAnimateStr == "BOAR_ARCTIC" or spriteAnimateStr == "BOAR_WILD" then + applyAbility = true + end + end + -- + if sprite:getLocalInt("cdtweaksAnimalLastStand") == 0 then + if applyAbility then + apply() + end + else + if applyAbility then + -- do nothing + else + -- Mark the creature as 'feat removed' + sprite:setLocalInt("cdtweaksAnimalLastStand", 0) + -- + sprite:applyEffect({ + ["effectID"] = 321, -- Remove effects by resource + ["res"] = "%INNATE_ANIMAL_LAST_STAND%", + ["sourceID"] = sprite.m_id, + ["sourceTarget"] = sprite.m_id, + }) + end + end +end) diff --git a/cdtweaks/readme-cdtweaks.html b/cdtweaks/readme-cdtweaks.html index 84c933f..ffea8bc 100644 --- a/cdtweaks/readme-cdtweaks.html +++ b/cdtweaks/readme-cdtweaks.html @@ -1098,6 +1098,18 @@

Rule Changes

+ +

Make Bears and Boars continue fighting after reaching 0 hit points [Luke]
+ EEex

+

This component aims at implementing the PnP behavior Make Bears and Boars continue fighting after reaching 0 hit points.
+ In particular, after reaching 0 hit points, the creature will not immediately die, but go berserk for a small number rounds (Brown / Cave bears: 1d4, Polar bears / boars: 1d4+1), attacking friends and foes alike.
+ Notes: +

+

+

Convenience Tweaks and/or Cheats

diff --git a/cdtweaks/setup-cdtweaks.tp2 b/cdtweaks/setup-cdtweaks.tp2 index 5e97fb6..254d8a8 100644 --- a/cdtweaks/setup-cdtweaks.tp2 +++ b/cdtweaks/setup-cdtweaks.tp2 @@ -2990,6 +2990,19 @@ REQUIRE_PREDICATE MOD_IS_INSTALLED ~EEex.tp2~ 0 @29 REQUIRE_PREDICATE FILE_EXISTS ~cdtweaks/languages/%LANGUAGE%/circle_kick.tra~ @7 LABEL ~cd_tweaks_circle_kick~ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// +///// \\\\\///// +///// Make Bears and Boars continue fighting after reaching 0 hit points \\\\\ +///// \\\\\///// +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// + +BEGIN @282000 DESIGNATED 2820 +GROUP @9 +REQUIRE_PREDICATE MOD_IS_INSTALLED ~EEex.tp2~ 0 @29 +LABEL ~cd_tweaks_bears_and_boars~ + /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ ///// \\\\\ From 210352cfd6b276abe87b7992637d2126b8b9ff78 Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Thu, 12 Sep 2024 11:22:13 +0200 Subject: [PATCH 2/3] Create comp_2820.tpa --- cdtweaks/lib/comp_2820.tpa | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 cdtweaks/lib/comp_2820.tpa diff --git a/cdtweaks/lib/comp_2820.tpa b/cdtweaks/lib/comp_2820.tpa new file mode 100644 index 0000000..ddaa5b7 --- /dev/null +++ b/cdtweaks/lib/comp_2820.tpa @@ -0,0 +1,15 @@ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// +///// ///// +///// Make Bears and Boars continue fighting after reaching 0 hit points \\\\\ +///// \\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// + +WITH_SCOPE BEGIN + INCLUDE "cdtweaks\luke\misc.tph" + // + INCLUDE "cdtweaks\lib\innate_animal_last_stand.tph" + // + LAF "INNATE_ANIMAL_LAST_STAND" END +END \ No newline at end of file From c74131f70ec74bdb1d21a2f07475bdbe78307d01 Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Mon, 28 Oct 2024 17:03:30 +0100 Subject: [PATCH 3/3] Change DESIGNATED number Misc tweaks. --- cdtweaks/languages/english/weidu.tra | 30 +------------------- cdtweaks/languages/italian/weidu.tra | 28 +----------------- cdtweaks/lib/comp_2660.tpa | 22 +++++++------- cdtweaks/lib/comp_2820.tpa | 15 ---------- cdtweaks/lib/innate_animal_last_stand.tph | 3 +- cdtweaks/luke/lua/race/animal_last_stand.lua | 18 ++++++++---- cdtweaks/setup-cdtweaks.tp2 | 3 +- 7 files changed, 29 insertions(+), 90 deletions(-) delete mode 100644 cdtweaks/lib/comp_2820.tpa diff --git a/cdtweaks/languages/english/weidu.tra b/cdtweaks/languages/english/weidu.tra index 0441cfe..ed62222 100644 --- a/cdtweaks/languages/english/weidu.tra +++ b/cdtweaks/languages/english/weidu.tra @@ -457,35 +457,7 @@ The uninstall messages above are normal and expected. @264000 = "PnP Potions [Luke]" -@265000 = "Spontaneous Casting for Clerics [Luke]" - -@266000 = "Weapon Finesse feat for Thieves [Luke]" - -@267000 = "Dual-Wield feat for Rangers [Luke]" - -@268000 = ~"Force" the Archer kit to use bows [Luke]~ - -@269000 = "NWN-ish Armor vs. Dexterity [Luke]" - -@270000 = "Defensive Roll feat for Thieves [Luke]" - -@271000 = "Divine Grace / Dark Blessing feat for Paladins / Blackguards [Luke]" - -@272000 = "Good Aim racial feat for Halflings [Luke]" - -@273000 = "Cleave Feat for Fighters [Luke]" - -@274000 = "Sneak Attack class feat for Blackguards [Luke]" - -@275000 = "Fearless racial feat for Halflings [Luke]" - -@276000 = "Poison Save class feat for Assassins [Luke]" - -@277000 = "Planar Turning class feat for Clerics / Paladins [Luke]" - -@278000 = "Circle Kick class feat for Monks [Luke]" - -@282000 = "Make Bears and Boars continue fighting after reaching 0 hit points [Luke]" +@266000 = "Make Bears and Boars continue fighting after reaching 0 hit points [Luke (EEex)]" /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ diff --git a/cdtweaks/languages/italian/weidu.tra b/cdtweaks/languages/italian/weidu.tra index 37f46ba..e6fa945 100644 --- a/cdtweaks/languages/italian/weidu.tra +++ b/cdtweaks/languages/italian/weidu.tra @@ -410,33 +410,7 @@ o rimpiazzata da - un'altra facente parte di uno dei mods installati.~ // @257000 = ~BGT: Limite di esperienza aggiuntivo mentre sei in BG~ // @257100 = ~BGT: Limite di esperienza aggiuntivo in SoA~ -@265000 = "Aggiungi talento di classe Lancio Spontaneo per i Chierici [Luke]" - -@266000 = "Aggiungi talento Arma Preferita per i Ladri [Luke]" - -@267000 = "Aggiungi talento Doppia-Presa per i Ranger [Luke]" - -@269000 = "Armatura vs. Destrezza in stile NWN [Luke]" - -@270000 = "Aggiungi talento Tiro Difensivo per i ladri [Luke]" - -@271000 = "Grazia Divina / Benedizione Oscura per Paladini / Guardie Nere [Luke]" - -@272000 = "Aggiungi talento razziale Buona Mira per gli Halfling [Luke]" - -@273000 = "Aggiungi talento di classe Incalzare per i Guerrieri [Luke]" - -@274000 = "Aggiungi talento di classe Attacco Furtivo per Guardie Nere [Luke]" - -@275000 = "Aggiungi talento razziale Temerario per gli Halfling [Luke]" - -@276000 = "Aggiungi talento di classe Resistenza ai Veleni per Assassini [Luke]" - -@277000 = "Aggiungi talento di classe Scacciare Creature Extraplanari per Paladini e Chierici [Luke]" - -@278000 = "Aggiungi talento di classe Calcio Rotante per i Monaci [Luke]" - -@282000 = "Gli Orsi e i Cinghiali continueranno a combattere dopo aver raggiunto 0 punti ferita [Luke]" +@266000 = "Gli Orsi e i Cinghiali continueranno a combattere dopo aver raggiunto 0 punti ferita [Luke (EEex)]" /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ diff --git a/cdtweaks/lib/comp_2660.tpa b/cdtweaks/lib/comp_2660.tpa index 2219330..ddaa5b7 100644 --- a/cdtweaks/lib/comp_2660.tpa +++ b/cdtweaks/lib/comp_2660.tpa @@ -1,15 +1,15 @@ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -///// \\\\\ -///// Weapon Finesse for Thieves \\\\\ -///// \\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// +///// ///// +///// Make Bears and Boars continue fighting after reaching 0 hit points \\\\\ +///// \\\\\ +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// +/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// WITH_SCOPE BEGIN INCLUDE "cdtweaks\luke\misc.tph" - INCLUDE "cdtweaks\lib\weapon_finesse.tph" - WITH_TRA "cdtweaks\languages\english\weapon_finesse.tra" "cdtweaks\languages\%LANGUAGE%\weapon_finesse.tra" BEGIN - LAF "WEAPON_FINESSE" END - END + // + INCLUDE "cdtweaks\lib\innate_animal_last_stand.tph" + // + LAF "INNATE_ANIMAL_LAST_STAND" END END \ No newline at end of file diff --git a/cdtweaks/lib/comp_2820.tpa b/cdtweaks/lib/comp_2820.tpa deleted file mode 100644 index ddaa5b7..0000000 --- a/cdtweaks/lib/comp_2820.tpa +++ /dev/null @@ -1,15 +0,0 @@ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// -///// ///// -///// Make Bears and Boars continue fighting after reaching 0 hit points \\\\\ -///// \\\\\ -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// -/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// - -WITH_SCOPE BEGIN - INCLUDE "cdtweaks\luke\misc.tph" - // - INCLUDE "cdtweaks\lib\innate_animal_last_stand.tph" - // - LAF "INNATE_ANIMAL_LAST_STAND" END -END \ No newline at end of file diff --git a/cdtweaks/lib/innate_animal_last_stand.tph b/cdtweaks/lib/innate_animal_last_stand.tph index 1871b88..d0d2808 100644 --- a/cdtweaks/lib/innate_animal_last_stand.tph +++ b/cdtweaks/lib/innate_animal_last_stand.tph @@ -7,6 +7,5 @@ BEGIN "INNATE_ANIMAL_LAST_STAND" = "resName" END // - LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Misc Tweaks (Innate)" "sourceFileSpec" = "cdtweaks\luke\lua\race\animal_last_stand.lua" "destRes" = "m_gtspin" END - LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Utility Functions / Listeners" "sourceFileSpec" = "cdtweaks\luke\lua\utility\effect_check.lua" "destRes" = "m_gtutil" END + LAF "APPEND_LUA_FUNCTION" STR_VAR "description" = "Innate Abilities" "sourceFileSpec" = "cdtweaks\luke\lua\race\animal_last_stand.lua" "destRes" = "m_gtspin" END END \ No newline at end of file diff --git a/cdtweaks/luke/lua/race/animal_last_stand.lua b/cdtweaks/luke/lua/race/animal_last_stand.lua index 7aae8b1..4936301 100644 --- a/cdtweaks/luke/lua/race/animal_last_stand.lua +++ b/cdtweaks/luke/lua/race/animal_last_stand.lua @@ -1,4 +1,8 @@ --- cdtweaks, Last Stand innate feat for Bears and Boars: op208 grants protection from directly applied op13, so make sure to kill the creature -- +--[[ ++------------------------------------------------------+ +| cdtweaks, Last Stand innate feat for Bears and Boars | ++------------------------------------------------------+ +--]] --[[function %INNATE_ANIMAL_LAST_STAND%(op403CGameEffect, CGameEffect, CGameSprite) local immunityToKill = EEex_Trigger_ParseConditionalString("EEex_IsImmuneToOpcode(Myself,13)") @@ -29,7 +33,7 @@ end end--]] --- cdtweaks, Last Stand innate feat for Bears and Boars: The boar/bear will fight for (1d4/1d4+1) rounds after reaching 0 hit points. The creature will go berserk attacking friends and foes alike +-- The boar/bear will fight for (1d4/1d4+1) rounds after reaching 0 hit points. The creature will go berserk attacking friends and foes alike -- EEex_Opcode_AddListsResolvedListener(function(sprite) -- Sanity check @@ -59,7 +63,9 @@ EEex_Opcode_AddListsResolvedListener(function(sprite) local roll = modifier + Infinity_RandomNumber(1, 4) -- 1d4 / 1d4+1 -- if sprite:getLocalInt("cdtweaksAnimalLastStand") == 1 then - if sprite.m_nLastDamageTaken >= sprite.m_baseStats.m_hitPoints and not GT_Utility_EffectCheck(sprite, {["m_effectId"] = 55, ["m_sourceRes"] = "%INNATE_ANIMAL_LAST_STAND%B"}) then + if sprite.m_nLastDamageTaken >= sprite.m_baseStats.m_hitPoints and sprite:getLocalInt("gtAnimalRunningWild") == 0 then + sprite:setLocalInt("gtAnimalRunningWild", 1) + -- local lastHitter = EEex_GameObject_Get(sprite.m_lHitter.m_Instance) -- local effectCodes = { @@ -67,17 +73,19 @@ EEex_Opcode_AddListsResolvedListener(function(sprite) {["op"] = 176, ["p2"] = 5, ["p1"] = 200, ["dur"] = 6 * roll}, -- movement rate bonus (200%) {["op"] = 215, ["res"] = "ICSTRENI", ["p2"] = 1, ["dur"] = 2}, -- play visual effect (over target: attached) {["op"] = 142, ["p2"] = 4, ["dur"] = 6 * roll}, -- icon: berserk + {["op"] = 187, ["p1"] = 0, ["effvar"] = "gtAnimalRunningWild", ["dur"] = 6 * roll, ["tmg"] = 4}, -- set local var (reset to 0 in case the animal gets resurrected) {["op"] = 55, ["p2"] = 2, ["dur"] = 6 * roll, ["tmg"] = 4}, -- slay creature } -- for _, attributes in ipairs(effectCodes) do sprite:applyEffect({ - ["effectID"] = attributes["op"] or -1, + ["effectID"] = attributes["op"] or EEex_Error("opcode number not specified"), ["effectAmount"] = attributes["p1"] or 0, ["dwFlags"] = attributes["p2"] or 0, ["res"] = attributes["res"] or "", ["duration"] = attributes["dur"] or 0, ["durationType"] = attributes["tmg"] or 0, + ["m_scriptName"] = attributes["effvar"] or "", ["m_sourceRes"] = "%INNATE_ANIMAL_LAST_STAND%B", ["m_sourceType"] = 1, ["noSave"] = true, @@ -89,7 +97,7 @@ EEex_Opcode_AddListsResolvedListener(function(sprite) end end) --- cdtweaks, Last Stand innate feat for Bears and Boars: Apply passive trait -- +-- Apply passive trait -- EEex_Opcode_AddListsResolvedListener(function(sprite) -- Sanity check diff --git a/cdtweaks/setup-cdtweaks.tp2 b/cdtweaks/setup-cdtweaks.tp2 index 254d8a8..80c9d11 100644 --- a/cdtweaks/setup-cdtweaks.tp2 +++ b/cdtweaks/setup-cdtweaks.tp2 @@ -2998,8 +2998,9 @@ LABEL ~cd_tweaks_circle_kick~ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\///// -BEGIN @282000 DESIGNATED 2820 +BEGIN @266000 DESIGNATED 2660 GROUP @9 +REQUIRE_PREDICATE GAME_IS ~bgee bg2ee eet iwdee~ @25 REQUIRE_PREDICATE MOD_IS_INSTALLED ~EEex.tp2~ 0 @29 LABEL ~cd_tweaks_bears_and_boars~