Skip to content

Commit

Permalink
v0.7.3-alpha
Browse files Browse the repository at this point in the history
- B3_EfMen.lua module's row count can now be changed by setting B3EffectMenu_RowCount option
- B3_EfMen.lua should no longer crash on spells that don't have a level-1 ability, (mod introduced)
- Added EEex_GetSpellAbilityDataIndex()
  • Loading branch information
Bubb13 committed Dec 20, 2019
1 parent 212e361 commit 23af5bd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion EEex/EEex.tp2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BACKUP ~EEex\backup~
AUTHOR ~Bubb~
VERSION 0.7.2
VERSION 0.7.3

BEGIN ~EEex~
REQUIRE_PREDICATE (
Expand Down
20 changes: 17 additions & 3 deletions EEex/copy/B3_EfMen.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

-----------------
-- Keybindings --
-----------------
-------------
-- Options --
-------------

B3EffectMenu_Key = EEex_GetKeyFromName("Left Shift")
B3EffectMenu_RowCount = 4

-----------------------
-- Hooks / Listeners --
Expand All @@ -18,6 +19,10 @@ function B3EffectMenu_LoadMenu()

EEex_LoadMenuFile("B3_EfMen")

local rowTotal = 35 * B3EffectMenu_RowCount
Infinity_SetArea("B3EffectMenu_Menu_Background", nil, nil, nil, rowTotal + 20)
Infinity_SetArea("B3EffectMenu_Menu_List", nil, nil, nil, rowTotal)

local actionbarOnOpen = EEex_GetMenuVariantFunction("WORLD_ACTIONBAR", "onopen")
EEex_SetMenuVariantFunction("WORLD_ACTIONBAR", "onopen", function()
local openResult = actionbarOnOpen()
Expand Down Expand Up @@ -90,8 +95,17 @@ function B3EffectMenu_LaunchInfo()
if spellData == 0x0 then return end -- Continue EEex_IterateCPtrList

local casterLevel = EEex_ReadDword(CGameEffect + 0xC4)
if casterLevel <= 0 then casterLevel = 1 end

local abilityData = EEex_GetSpellAbilityDataLevel(sourceResref, casterLevel)

-- The caster shouldn't have been able to cast this spell, just use the first ability
if abilityData == 0x0 then
abilityData = EEex_GetSpellAbilityDataIndex(sourceResref, 0)
-- The spell didn't even have an ability...
if abilityData == 0x0 then return end -- Continue EEex_IterateCPtrList
end

local spellName = Infinity_FetchString(EEex_ReadDword(spellData + 0x8))
if spellName == "" then spellName = "(No Name)" end

Expand Down
13 changes: 13 additions & 0 deletions EEex/copy/M__EEex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2843,6 +2843,19 @@ function EEex_GetQuickButtons(m_CGameSprite, buttonType, existenceCheck)
return EEex_Call(EEex_Label("CGameSprite::GetQuickButtons"), {existenceCheck, buttonType}, m_CGameSprite, 0x0)
end

function EEex_GetSpellAbilityDataIndex(resref, index)

local CResSpell = EEex_DemandCRes(resref, "SPL")
if CResSpell == 0x0 then return 0x0 end
local spellData = EEex_ReadDword(CResSpell + 0x28)

local abilitiesCount = EEex_ReadWord(spellData + 0x68, 0)
if abilitiesCount == 0 then return 0x0 end

local startAbilityAddress = spellData + EEex_ReadDword(spellData + 0x64)
return startAbilityAddress + 0x28 * index
end

function EEex_GetSpellAbilityDataLevel(resref, casterLevel)

local CResSpell = EEex_DemandCRes(resref, "SPL")
Expand Down

0 comments on commit 23af5bd

Please sign in to comment.