Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Dark Dreams of Furiae - a new module for NWN:EE! Buy now
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

[MOD] EEex (v0.8.7-alpha)

1303132333436»

Comments

  • fortysevenfortyseven Member Posts: 79
    @Bubb I have a question regarding opcode 214 (Select Spell).

    Would it be possible for EEex to make the opcode check both a custom 2da spell list and then cross-reference “known spells” before it presents the list you can select spells from?

    I’m trying to make a number of specific select spell abilities that are limited both by the spells known in your spell book and by certain characteristics e.g. spell level, aoe damage, utility spells, damage type, etc.
    At the moment it looks like the opcode lets you cast all spells on a 2da list or forces you to memorise those spells in a spell slot so they can be cast. Essentially, I’m looking for a middle ground between those two options.

    Many thanks!
    47

  • BubbBubb Member Posts: 825
    @fortyseven: Something like this would work when invoked from op402 (InvokeLua):
    • B3LIST is a normal op214 2DA. This is hardcoded for the function.
    • B3FILT is the Lua Function you invoke with op402.
    • You can EEex_AddTail() to add any CButtonData you like - see how to construct a CButtonData below. There are no requirements on this spell; if you add it to the internal list, it'll be castable. The 2DA cross-reference is more rigid than what the function can theoretically do, (think iterating the player's known spells, and only adding the Necromancy spells).
    if test2DA then test2DA:free() end
    test2DA = EEex_Wrap2DA("B3LIST")
    
    function B3FILT(effectData, creatureData)
    
        local actorID = EEex_GetActorIDShare(creatureData)
        if not EEex_IsSprite(actorID) then return end
    
        local selectedActors = EEex_GetAllActorIDSelected()
        if #selectedActors ~= 1 or selectedActors[1] ~= actorID then return end
    
        local internalList = EEex_GetClearInternalList(creatureData)
    
        local knownSpells = {}
        EEex_ProcessKnownWizardSpells(actorID, function(resrefLocation)
            local resref = EEex_ReadString(resrefLocation)
            knownSpells[resref] = true
        end)
    
        local typeColumn = test2DA:findColumnLabel("Type")
        test2DA:iterateColumnLabel("ResRef", function(y, resref)
    
            if not knownSpells[resref] then return end
            local type = test2DA:getAtPoint(typeColumn, y)
    
            local spellData = EEex_GetSpellData(resref)
            local spellAbility = EEex_GetSpellAbilityData(creatureData, resref)
            local CButtonData = EEex_ConstructButtonData(resref, spellData, spellAbility, type)
            EEex_AddTail(internalList, CButtonData)
        end)
    
        EEex_SetActionbarState(0x6F)
    
    end
    

    Most of the above is new functionality introduced in master. Also, make sure your spell ability is set up to be Target=7, so the InvokeLua is executed instantly and while the game is paused like normal op214 spells.

    fortyseven
  • AndreaColomboAndreaColombo Member Posts: 5,365
    @Bubb Perhaps this has been asked before, but can EEex be made to include an option to disable the grey Stoneskin graphic effect? ToBEx has a similar component for vanilla games and it would be quite handy.

  • fortysevenfortyseven Member Posts: 79
    Bubb wrote: »
    @fortyseven: Something like this would work when invoked from op402 (InvokeLua):
    • B3LIST is a normal op214 2DA. This is hardcoded for the function.
    • B3FILT is the Lua Function you invoke with op402.
    • You can EEex_AddTail() to add any CButtonData you like - see how to construct a CButtonData below. There are no requirements on this spell; if you add it to the internal list, it'll be castable. The 2DA cross-reference is more rigid than what the function can theoretically do, (think iterating the player's known spells, and only adding the Necromancy spells).
    if test2DA then test2DA:free() end
    test2DA = EEex_Wrap2DA("B3LIST")
    
    function B3FILT(effectData, creatureData)
    
        local actorID = EEex_GetActorIDShare(creatureData)
        if not EEex_IsSprite(actorID) then return end
    
        local selectedActors = EEex_GetAllActorIDSelected()
        if #selectedActors ~= 1 or selectedActors[1] ~= actorID then return end
    
        local internalList = EEex_GetClearInternalList(creatureData)
    
        local knownSpells = {}
        EEex_ProcessKnownWizardSpells(actorID, function(resrefLocation)
            local resref = EEex_ReadString(resrefLocation)
            knownSpells[resref] = true
        end)
    
        local typeColumn = test2DA:findColumnLabel("Type")
        test2DA:iterateColumnLabel("ResRef", function(y, resref)
    
            if not knownSpells[resref] then return end
            local type = test2DA:getAtPoint(typeColumn, y)
    
            local spellData = EEex_GetSpellData(resref)
            local spellAbility = EEex_GetSpellAbilityData(creatureData, resref)
            local CButtonData = EEex_ConstructButtonData(resref, spellData, spellAbility, type)
            EEex_AddTail(internalList, CButtonData)
        end)
    
        EEex_SetActionbarState(0x6F)
    
    end
    

    Most of the above is new functionality introduced in master. Also, make sure your spell ability is set up to be Target=7, so the InvokeLua is executed instantly and while the game is paused like normal op214 spells.


    This looks really cool, although I don't think I fully grasp all it can do. I have not been able to process it properly and will be busy with work for the next several days. Would it be possible to get a worked example? Such as a spell selection spell for "all known wiz spells" and "all level 1 spells" for arguments sake?

    You say this is mostly new functionality. I have a master from June which you kindly provided. Would I need an update to that?

    Many thanks @Bupp once again!

  • fortysevenfortyseven Member Posts: 79
    edited April 23
    @Bupp
    I have tried to implement what you have posted and haven't had any success.
    This might be because I don't have the up-to-date master. However, I also have a feeling I'm not doing it correctly.

    First I created a 2DA file named B3LIST with a custom spell list in the 214 format.
    Then I copied your lua code into a new file named B3FILT.lua
    Then I created a SPL file in Nearinfinity with ability calling opcode 402.
    I set target to 7 (which comes up as "target group" in NI).
    Then in the unused field I entered B3FILT (as string).
    I put all of these files in the override folder and added the prefix M_ to B3FILT.lua

    Unfortunately, I get this error code:
    [string "M_B3FILT.lua"]:2 attempt to call global 'EEex_Wrap2DA' (a nil value)

  • BubbBubb Member Posts: 825
    @fortyseven: Don't know who Bupp is, I'm Bubb ;)

    Your steps look mostly right. Only one correction:
    • The Target=7 I mentioned would be the spell ability target, not the effect target. The effect should be targeting Self (1). I've attached an example spell that shows you how it's set up.

    Also, new versions of Near Infinity have EEex field support built in, (thanks argent!), so you don't have to deal with the unused field nonsense. You can find that here.

    And yes, you are getting that error because you aren't using the latest master version of EEex. Download from here and you should have the necessary EEex code for things to work.

    Grammarsaladfortyseven
  • GrammarsaladGrammarsalad Member Posts: 2,572
    Bubb wrote: »
    @fortyseven: Don't know who Bupp is, I'm Bubb ;)

    Your steps look mostly right. Only one correction:
    • The Target=7 I mentioned would be the spell ability target, not the effect target. The effect should be targeting Self (1). I've attached an example spell that shows you how it's set up.

    Also, new versions of Near Infinity have EEex field support built in, (thanks argent!), so you don't have to deal with the unused field nonsense. You can find that here.

    And yes, you are getting that error because you aren't using the latest master version of EEex. Download from here and you should have the necessary EEex code for things to work.

    @Bubb Does EEex work with version 2.6? I have been holding off on reinstalling eeex as I just assumed it wouldn't be compatible

  • GrammarsaladGrammarsalad Member Posts: 2,572
    edited April 24
    Bubb wrote: »
    @Grammarsalad: It does not. v2.6 compatibility requires a complete rewrite, and I will most likely be taking this time to work on the cross-platform aspirations of EEex, (and as @suy has proposed here, Frida looks like a good framework to build the next version on top of). A working v2.6 version is at least months away, and it might be significantly reworked.

    Makes perfect sense. Thanks for the update (I’ll just keep a pre2.6 version of bgee on my pc until it’s updated)

  • fortysevenfortyseven Member Posts: 79
    edited April 24
    Sorry for misspelling your name @Bubb. I'm dyslexic and names like yours are pure kryptonite! I had a good run though, took me all these years to get it wrong!

    With the new master the lua code is working fine for one iteration of B3LIST. I cannot get it to recognise different lua variations for different SPL files. In your intial reply you mention that B3LIST is hardcoded. Does that mean I can't make multilple variations where one selection spell uses a lua refering to a 2DA for necromancy spells and another uses a different lua refering to a 2DA for evocation spells?

    Many thanks for all your help!

  • GrammarsaladGrammarsalad Member Posts: 2,572
    Here's an updated pdf readme for EEex. I haven't worked on this in a while, but this version is still more updated than the last time I shared it:

    https://homebrewery.naturalcrit.com/share/rJZOF-sOCV

    Flashburnsuy
Sign In or Register to comment.