You are here

Misc Bugs in MOTB I don't see posts on

87 posts / 0 new
Last post
Strider
Misc Bugs in MOTB I don't see posts on

I started MOTB NWN2 and finding that persistant haste doesn't last but about 15 minutes in game time instead of 24 hours in game time.  I thought maybe it was getting dispelled, but I've cast it and just ran around and it disappears within 15 minutes game time.  What gives?  I don't know why I have bugs like this when I don't see posts about this bug all over the place.  I have seen a few mentions of it but no replies in different forums.

Another bug I have is in enchanting.  The pristine earth essences + weapon in the satchel says they aren't valid recipes.  The brilliant earth work right but not these pristine recipes.

Acid Fog on Satchel with Weapon
1 Pristine Earth Essence (CL 24) = 3d6 Acid Damage\par
2 Pristine Earth Essences (CL 27) = 4d6 Acid Damage\par
3 Pristine Earth Essences (CL 30) = 5d6 Acid Damage\par

*************************

Anyone have these problems or know of solutions to them?

  • up
    50%
  • down
    50%
kevL's

testing here with a clean override says both work fine.

Safiya 27 casting Persistent Haste lasted 24 hrs.
casting Acid Fog on the Enchanter's Satchel w/ 1 Pristine Earth Essence added 3d6 Acid to Flamestaff +5 (3d6 fire)


offhand i'd think it's something in your override folder,
- haste is controlled by files nw_s0_haste and spells.2da
- crafting recipes are in file crafting.2da

check for rogues ...

  • up
    50%
  • down
    50%
Strider

Thanks for testing it.  Atleast I know it's suppose to work properly.  I do use Complete Craftsmen and Companion and Monster AI 2.2.  I removed Complete craftsmen before to test it and the pristine earth enchantment still didn't work.

I'm gonna remove my override folder and see if that does it.

Edit: I removed my override folder and Persistant Haste worked but Acid Fog enchant didn't because I was using Imbue Item. So, I downloaded the Imbue Item Fix and that works now with Imbue Item instead of Acid Fog.

**************

Unfortunately I really like The Complete Craftsmen which uses the same files as Imbue Item Fix.   I have no clue how to merge them.  Anyone know if there is a fix / merge for this?

**

I found out the problem with Persistant Haste was with the Meta Rod of Preparation mod.  It casts the haste from persistant spell slot 9 but for some reason it's not the persistant haste.  If I cast it seperately after I use the rod of preparation then it lasts 24 hours.

  • up
    50%
  • down
    50%
kevL's

i just downloaded the Rod from here and set it up in the same clean override as before

Persistent Haste, via Rod worked fine ...


myself I use the Complete Craftsman Rebalanced -- but i see Vandervecken has rebooted it, and so that's the one I'd suggest now. Perhaps if there's still an issue there ...

  • up
    50%
  • down
    50%
Strider

That is the version of the rod I'm using.  kl_metaprepa_vbeta95_130706.7z.  If I cast persistant haste instantly along with other spells it becomes just regular haste but if I cast it regularly after I'm done using the rod it will last 24 hours. 

I just noticed your the author of this version.  It's an excellent mod.  Thanks for the help on this.

I can give you the order of what I'm casting if you are interested.  In testing I removed the haste page from the red wizard prep bag and deleted it.  Then I went back into learning mode and recast it but it put it at the beginning of the bag again.  Thought maybe if it was cast last.   I'll retest it with casting just that spell in the bag instantly.

**************

The problem I find Complete Craftsman is using Imbue Item.  Testing yesterday with Acid Fog spell worked but doesn't with Imbue Item feat on that Pristine Earth recipes.  I use the rebalanced version

tcc_-_motb_update_patch-113-18_-_rebalanced.zip - Rebalanced version-1070-1-8.zip

I see there is a 113-19 rebalanced version I can test but I think it will have the same issue.  It's not a problem with the mod perse but it's based on a bug of NWN2 in which certain recipes aren't recognized using the Imbue Item feat to cover the spell part.

This mod fixes that part:

https://neverwintervault.org/project/nwn2/script/imbue-item-indexing-bug-fix  but this mod doesn't seem to contain this fix.

 

 

  • up
    50%
  • down
    50%
kevL's

for the Rod, open the Book and examine the page for Persistent Haste. It should have a line that says

iMetaMagic 64

(#64 is persistent)

As a sidenote, that i don't think pertains but will mention it, if there are too many spells in a Book the casting sequence cuts short ... i think it's around 20 spells.

ps. I tested Persistent Haste on my system as both Instant and As Actions, but they both worked for 24 hrs. if I can't reproduce it it's like archery practice on goblins in haystacks.

--
I don't play Warlock (much) and have never used Imbue Item, but have heard it's bugged. perhaps i'll have a look at that fix .....

 

edit: you could try clearing your Book (all books), just take the pages out is enough ( or they can be activated on themselves to delete them iirc ). Then prepare *only* PH and try it

  • up
    50%
  • down
    50%
Strider

I was just about to reply.  I did just that.  I deleted all my books and just added the haste spell.  It works by itself and is cast as persistant but not with a group of spells.  I'm not casting that many.  10 in Safiya's bag.

I'm testing with a clean override folder and just this mod.  It is listed as

iMetaMagic 64
 

but only works as persistent if it's not cast with these other spells listed in order. (Safiya's bag)

Haste (persistant) on PC

Englarge Person (Extend) on PC

Stoneskin (Extend) on PC

Bear's Endurance on PC

Bear's Endurance on Myself

Greater Magic weapon on West

Greater stoneskin on Myself

Spell mantle on myself

Premonition on Myself

Protection from Spells on myself

I'll remove them one by one and see which is causing the problem.

***************

With the Complete Craftsman rebalanced I noticed the author has put up a 119 version since I last downloaded 118 so he must be active still.  I put a post on that mods page.  It seems like an easy workaround / fix for someone who knows what they are doing with recompiling scripts and such.  :)

According to the author of the Imbue Item Bug fix.

  • up
    50%
  • down
    50%
Strider

Ok I found the problem.  If other spells follow persistent haste in the meta book then it will be cast as regular haste.  I started a new character to test it thinking maybe it had something to do with my current one and I cast Bear's Endurance first this time and then I used Persistent Haste and it worked.

I tested on my regular character and found I have to delete the meta bag and not just the haste spell page for it to work properly.  If I delete just the haste metapage and then relearn haste it will be added to the same spot it was in the bag before I deleted it and it won't work as a persistent spell.

If I delete the bag and recast all my spells I want first then cast haste persistent as the last spell it will stay for 24 hours.

Hopefully you can verify this.   I had Gann learn a few after setting up Safiya and luckily it still works.

I would have to delete Safiya's meta bag each time and redo all the spells if I wanted to add a new spell then have haste at the end it seems for me.

  • up
    50%
  • down
    50%
kevL's

hi,
am working on the Imbue Item fix ... I see the problem and have a different solution (by testing the Index against a numeric string it should bypass the need for the Acid Fog triggerspell to be on row #40 -- in my modified Crafting_Index.2da for example, the Acid Fog trigger is on row #71). It's not complicated since Lord Grave already laid the groundwork; but it is tedious and intricate in that I'd like some version in nwn2fixes, and about all i can do for you is provide instructions ... too many Crafting editions out there otherwise.

re Rod.
you don't have to delete the bag, to fix the extra-slot thingiedorf. Just remove pages from the bottom up to where the invisible extra slot is; or, what I do is remove them all, and add pages back into the Book in the order to execute. For me that refills the bag's slots in order.

it's gonna be a while before I work on the bug (i'll have to reproduce it exactly, yadda..) Thanks so far,

--
edit: I think i'll put Lord Grave's fix for ImbueItem into nwn2fixes as is. Because if anyone is using one of the Crafting extensions the scripts will likely be b&gered and inconsistent anyway. Then will put the 'advanced' fix in mine and describe it here.

  • up
    50%
  • down
    50%
Strider

(QUOTE)

re Rod.
you don't have to delete the bag, to fix the extra-slot thingiedorf. Just remove pages from the bottom up to where the invisible extra slot is; or, what I do is remove them all, and add pages back into the Book in the order to execute. For me that refills the bag's slots in order.

**********

Ah I had tried just removing the haste page and closing the bag and then adding the page back to it but it always got stuck back in the same spot at beginning of the bag.  But if I remove all the spells it does work where I can add them back as I want them to be cast and they stay in that order.  Thanks

*****************

That would be good to have Imbue Item fixed with latest rebalanced complete craftsman 1.19.  I kind of "cheat" in that I have any character I create have that feat so I don't have to worry about hunting down and memorizing the right spell for each craft / enchant.

  • up
    50%
  • down
    50%
kevL's

Lord Grave's ImbueItem fix has been added to nwn2fixes.


okay, here's how to modify Crafting expansions.

find this file in your Override: ginc_crafting

search for the function, GetRowIndexes

change these lines

iCat = StringToInt(Get2DAString(CRAFTING_INDEX_2DA, COL_CRAFTING_CATEGORY, iIndexRow));
if (iCat == 0)


to

if (!isSpellId(Get2DAString(CRAFTING_INDEX_2DA, COL_CRAFTING_CATEGORY, iIndexRow)))

and add this function just above function GetRowIndexes

// Checks if Crafting_Index.2da category is a trigger-spell.
int isSpellId(string sCategory)
{
    string sDigits = "0123456789";
    string sChar;

    int iLength = GetStringLength(sCategory);
    int i;
    for (i = 0; i != iLength; ++i)
    {
        sChar = GetSubString(sCategory, i, 1);
        if (!TestStringAgainstPattern("**" + sChar + "**", sDigits))
            return FALSE;
    }
    return TRUE;
}



Save.
Now you have to recompile any scripts that directly or indirectly use those functions.

Open the toolset. File->Open Conversation/Script

open the */Override* versions of the following scripts (not the ones in Data/Scripts):

( if they aren't in /Override, you'll have to copy them there yourself -- I suggest doing that before opening the toolset )

( Or if you *do* open the files in Data/Scripts, notice that when they are saved/compiled that copies end up in /Override ... the toolset won't overwrite anything in /Data, as far as i'm aware ... but even then you've got a bit of a mess on your hands. )

gp_forgemagic_ca
gr_domagiccrafting
i_mortar_ac
i_nx1_container01_ci
i_smithhammer_ac
nx_s2_shapers_alembic


- open each in turn and compile it. Check each for success.

Congraz, your Crafting expansion should now have ImbueItem enabled for all recipies that require spells.

Strider said

  • That would be good to have Imbue Item fixed with latest rebalanced complete craftsman 1.19.  I kind of "cheat" in that I have any character I create have that feat so I don't have to worry about hunting down and memorizing the right spell for each craft / enchant.

have you got in touch with the maintainer? Feel free to direct him/her here - it's open source :)

  • up
    50%
  • down
    50%
kevL's

note on Rod: initial test: bug reproduced. Only happens in Instant mode ... it seems.

  • up
    50%
  • down
    50%
Strider

Woot!  Worked on first try.  Never did any modding in this game before.

Both my Pristine Earth and Air essence recipes with Imbue Item succeeded.

Thanks alot.  I changed the TCC 1.19 rebalanced so I can verify this change does work with that mod.

*************

I did post a message at the botton of the TCC rebalanced reboot mod page and sent him an email but no response so far.  Hopefully he sees it.

*************

As far as the persistent spells go.  It seems haste is the only one that has that problem so far I've found.  I have my cleric casting a couple persistant spells and as far as I can tell they both are staying active 24 hours.  I did some further testing with just cleric prayer and protection circle from alignment spells as persistent and they aren't staying the full 24 hours either unless they at end of bag.  Not really an issue for now if I just keep haste at the end of the casting bag.

Thanks for the the nice upgrade to the rod mod :)  I usually didn't cast many buffs but now I'm fully buffed up all the time :)

 

  • up
    50%
  • down
    50%
kevL's

re. the Persistant thing

it seems to be a weird bug in the game engine's state machine: My guess is the metamagic variable gets dropped somehow on bInstant spells that are cast in rapid succession.

I think i found a workaround by delaying those casts 0.5 sec - i don't like it but there it is.

- will package a new version of MetaPreps after a bit more refactoring ... i love refactoring. i do ..honestly.

  • up
    50%
  • down
    50%
Strider

I've been messing around with crafting and unfortunately I've found a problem with the way Imbue Item is used with this fix especially with complete craftsmen.  TCC has alot of original style crafting enchantments that only differ in the spell that is cast to determine what buff is getting put on the item.  So it needs to know the exact spell that is getting swapped out when using imbue item.

For instance I tried to make a +6 Strength enchantment on my boots using a Glowing Fire Essence + Rogue stone + Imbue Item (Bull's Strength spell) .  It made a +6 Intelligience enchantment instead cause I guess that's first in the order and it uses exact same ingredients except for a spell of Fox's Cunning.

There's probably not an easy fix for that since it won't know what spell is needed if Imbue Item is cast.  Seems the problem is mostly with all the extra recipes that got added with The Complete Craftsman for Original Campaign.  If I just use the Satchel recipes of MOTB seems like it will work fine as is. 

TCC gives 4 books of Original campaign style recipes that can be made, which most won't work properly with Imbue Item. 

Just off the top of my head but probably not feasible / possible is if when you use Imbue Item it prompted you with a list of crafting spells (sort of like a protection of alignment spell pops up a list of alignments to pick after the spell is cast) and allows you to select which spell to cast. 

If it could somehow while casting imbue item send that spell variable so it knows which enchantment to use would be ideal.

*********

I've never really tested the length of the extended metamagic spell to see if those are correct when cast instant.  Maybe those need to be included if it's dropping all the meta magic variables for instant cast spells.

Still it's a nice workaround if it fixes them all.  Shouldn't be that noticeable.

 

  • up
    50%
  • down
    50%
kevL's

perhaps i'll rig up an input-box of some sort

i'd guess it's possible to search for multiple identical reagent lists and if only one is found, let it go through, or if more than one show a list to choose from. but that's down the road ...

  • up
    50%
  • down
    50%
Strider

Atleast it's working for all the MOTB recipes with satchel without giving "Invalid Recipe" which is what was needed.  Just using those is more than enough to make super powerful items and the original recipes will still work with the right spell.

Appreciate the work on it.

  • up
    50%
  • down
    50%
kevL's

k, no prob.

For the record, it's a issue w/ ImbueItem itself. Think about it: player never enters a trigger-spell, so what else can the code do except choose the first matching reagent-combination it comes across? (well, a coder could randomize it but that's not an option.. well, it is an option* ... but)

anyway, i'm having fun trying not to re-bork the MetaPrep scripts o.O

 

 

* hmmmmm

  • up
    50%
  • down
    50%
Vandervecken

Hi folks,
I maintain the Complete Craftsman BugFix Reboot mod. Just seeing this as I idly browsed for comments on my mod. I'm surprised I never greceived any emails of people getting in touch with me. Where did you email to? I don't see anything in my spam folder.

To the point at hand, I can make the relevant changes to the mod (especially if it's confirmed they work) but it seems to me that there's no clear way to figure out how to make this work for the Complete Craftsman. If no spell is being cast, you'll just get the first thing on the list.

Here's an idea: Change Imbue Item to grab the first Spell Scroll in the Container and extract the spell from that?  Then run the crafting using the rest of the reagents.  What do you folks think?

 

  • up
    50%
  • down
    50%
kevL's

hey V.

so ... have ImbueItem (recipies) require a scroll? i kinda like that -- but if scrolls are required that would penalize non-Warlocks, on the other hand if they're not required but simply tossed into the crafting container that would require code that explictly bypasses scrolls (and so make them ineligible as a required component). Any variation hereof becomes increasingly complicated ....

I suspect that, eventually, i'll look at the code for renaming items ( w/ smithhammer ) and use a similar GUI to input a spellname (iff a reagent combination is duplicated under multiple spell-triggers). And in the text above the input-box, list the possible triggers (so Player can see them, and type them correctly).

yes /no ?

  • up
    50%
  • down
    50%
Vandervecken

I'd do it differently, think of this flow:
If the Feat is Imbue Item
Check for a scroll. If there is no scroll fail. If there is, eat the scroll and carry on with the known spell.
If the Feat is not Imbue Item and a Scroll is found in the container, fail as usual.

You could do it with a recursive domagiccrafting function? If the feat is Imbue Item, eat the scroll and call domagiccrafting again.

  • up
    50%
  • down
    50%
Strider

Hey Vandervecken,

I sent a message by clicking on your name, then Contant button at the top.  It said successful but not sure where it goes.  If there a private mail to this forum or if it's sent to whatever email contact you used to create account.

As far as imbue item feat.  I don't think it's a very good idea to use a scroll.  The whole point of Imbue Item feat is that the Warlock does not need a spell or scroll to make enchantments or items.  Requiring a scroll I would think would be a penalty even more so then just having another character memorize the right spell.

As far as the fix it works as intended.  The problem with MoTB and Imbue Item has been corrected in that the crafter doesn't receive any 'Invalid Recipe' when using Imbue item on certain recipes with spells like Acid Fog . Pristine Earth and Pristine Air had problems.  I did the corrections with TCC 1.19 and I no issues anymore with satchel recipes since they all require different reagents / spells.

The only real issue is using Imbue Item with Original Campaign style recipes that have every reagent the same except for the spell.  It doesn't break anything that wasn't broken already using Imbue item with TCC OC style recipes.  Imbue Item would of already had those issues with those recipes.

This fix is mainly for MoTB 'Invalid Recipe' bug which it does well.

***************

If it was to be worked on further for it to work with those recipes I would think an input box after Imbue Item is cast with a list of spells needed for matching those reagents would be ideal.  So it let the warlock pick what he wanted without needing the spell like it was intended.  Since Imbue Item is being cast I think the selected spell name could be sent just to pick the right enchantment / item to make.

  • up
    50%
  • down
    50%
kevL's

Vandervecken,

i like that, i like it a lot in fact,

but it is a fundamental change in game-mechanics ... it's *almost* like Warlocks would need the spell anyway.


DoMagicCrafting() calls
- GetInventoryRecipeMatch

GetInventoryRecipeMatch() calls
- GetSortedItemList
- GetRecipeMatch

GetRecipeMatch() calls
- GetCrafting2DARecipeMatch

that's one place where the scroll could be defined and deleted, before GetMatchesAffectedItems().

An issue, if you like it so far, is that there are still many other checks in DoMagicCrafting() that can cause the craft to fail. I wouldn't want to see the scroll destroyed if things fail further along ... so instead of deleting the scroll at the start, store it as a local_object and destroy it at the end of DoMagicCrafting() iff (a) it exists and (b) on success.

note, calling DoMagicCrafting() recursively would have the same issue, i think

  • up
    50%
  • down
    50%
kevL's

Strider,

don't worry. If a scroll is required it can be reverted with a couple of // marks

at the moment we're just chatting.

  • up
    50%
  • down
    50%
Strider

Hey KevL,

I had an idea along those lines with using scrolls.  Once a character aquires the Imbue Item feat is there a way that they automatically get a bag filled with all 'Scrolls' needed for every item creation / enchantment.  Kind of like the Meta rod bag except those scrolls could only be used to cast on the satchel / workbenches and they aren't used up in the process.   Ofcourse they couldn't have restrictions like schools and stuff otherwise the warlock couldn't cast them.

Well it sounded good to start but might be too complicated as well.

Input box I think would be simpler if it's possible and wouldn't require anything extra.

*************

Also on my other forum post https://neverwintervault.org/forums/neverwinter-nights-2/nwn2-tech-qs/imbue-item-not-working-storm-zehir

I replied to it.  It's a seperate bug that's not fixed by anything we've done so far here.  I'm not sure what the problem is with that cause it's like forcing the Warlock to still have someone with the spell but all Imbue Item is doing is not using up that spell on the other character when the item is made which makes Imbue item feat kinda pointless.

  • up
    50%
  • down
    50%
kevL's

i saw that ...

my plate is full and my priority is fixing the MetaRod. it appears fixed but, refactoring

btw, the Bag o' Scrolls idea is too complicated: too many scrolls, too many bags, too many considerations for extra variables so scrolls can't be used willy-nilly. /shrug

  • up
    50%
  • down
    50%
Vandervecken

I don't think handing a warlock a big bag of scrolls is a good idea. If the Warlock wants to get a spell, they should do it in-game like everyone else has to. If all else fails, find a wizard you know (Sand, for example), feed them the scroll and then have them output scrolls for you.

In any case, we can always return the scroll to the container at the end. No reason for the scroll to be destroyed.

It's an interesting programming challenge. I might see if I can give it a try, work permitting.

  • up
    50%
  • down
    50%
Strider

Well it wasn't about giving them scrolls to cast in game.  Imbue item feat was made for warlocks since they are a caster class but unable to cast the spells required in crafting.  So imbue item feat allows them to bypass the spell requirement of crafting.  The scroll idea was just to identify the right enchantment to cast when using all the extra TCC recipes and wouldn't of been able to used in game but as Kev'l stated it would be too complicated which I figured it would be.  Just a thought.

I just mainly wanted to bring to your attention to the bug with 'Invalid Recipes' using Imbue item on the satchel in MoTB which is corrected if above fix is applied.  All other recipes will still work the same if using the correct spell.

  • up
    50%
  • down
    50%
Vandervecken

That's the thing. I don't think your change actually fixes the bug. It simply tells the function to pick the first recipe in the file with the reagent list matching. I don't think that's the correct behaviour, it's just the accidentally correct behaviour for you.

  • up
    50%
  • down
    50%
kevL's

There's 2 bugs.

1. Crafting_Index.2da. Imbue_Item returns a range of Crafting.2da indexes to check that includes all spells as triggers. In other words it needs to return the range from the top of Crafting_Index all the way down to the molds (roughly, it depends - ALC and DIS might be down there too). The way the stock code gets that range is by checking if StringToInt() returns 0. Molds, since their triggers are alpha-strings, return 0. But so does Acid Fog, because it *is* 0.

Lord Grave fixes that by skipping Crafting_Index row #40, which in the stock .2da is spellId 0, Acid Fog. My fix fixes that by checking if the row is *actually numeric*. It does not skip row #40. It includes all rows up to molds or anything else that doesn't contain a letter of the alphabet.

2. The bug we're now talking about, in Crafting.2da itself. The fact that reagent combinations that are identical can't be differentiated without a specific trigger ( in this case, a spellId )

 

edit: i've got a basic input-box working to deal w/ 2. atm it requires a manual spellId for any Imbue_Item cast ... not quite user-friendly.

  • up
    50%
  • down
    50%
kevL's

Imbue Item multiple choice

:d

  • up
    50%
  • down
    50%
Strider

That's awesome.  Didn't know if that would be possible.

  • up
    50%
  • down
    50%
kevL's

it appears to be working as intended. I've got instructions ready to post, and although they're quite long i guess I'll post them here, to make them accessible and keep these (advanced) Imbue_Item crafting fixes ( for expanded crafting ) in the same place.

just finishing up some cosmetic/informational touches ...

  • up
    100%
  • down
    0%
kevL's

first, screenshots!

Imbue Item multiple choice 1

Imbue Item multiple choice 2

 

sry bout the (print) colors - they can change ... ianaa.

  • up
    50%
  • down
    50%
Strider

That's pretty cool.  I like how you have em showing in chat so it's not a problem knowing the spell id.

  • up
    50%
  • down
    50%
kevL's

y, that was a prereq to playability. i don't imagine anyone, including me, wants to have Spells.2da open 'all the time'

semi-tested beta code, incoming

  • up
    50%
  • down
    50%
kevL's

Fix for using Imbue_Item against a Crafting.2da that has multiple triggerspells for identical reagent combinations.
NOTE: This requires the earlier fix with function isSpellId() to already be in place. Only because that function will be used again here - but if you don't have that fix then you have that bug still.

- 1 -
'ginc_crafting'
in DoMagicCrafting() - at the top, but after check for GetFirstItemInInventory() ... if there is one.

    if (iSpellID == 1081) // Imbue_Item - kL_add 160914
    {
        // if no matches or only one match, bypass this and let regular code handle it.
        string sIndices = GetCrafting2DARecipeMatches(GetFirstEquippableItem());
        if (sIndices != "" && ParseMatchingIndices(sIndices, oPC) > 0)
        {
            SetTriggerSpell(oPC);
            return;
        }
    }



extra functions, paste at the bottom of 'ginc_crafting'

// ________________________
// Functions for Imbue_Item - input triggerspell.

// Opens a GUI inputbox for entering an Imbue_Item triggerspell.
// @param oCrafter - the crafter
void SetTriggerSpell(object oCrafter)
{
    SetLocalObject(GetModule(), "ii_CraftContainer", OBJECT_SELF);  // set the crafting container as a local_object; it
                                                                    // will be used to run DoMagicCrafting() again shortly.
    int nMessageStrRef      = -1;
    string sMessage         = "Enter a Spell ID ( see chat for options )";
    string sOkCB            = "gui_trigger_spell_set";
    string sCancelCB        = "gui_trigger_spell_cancel";
    int bShowCancel         = TRUE;
    string sScreenName      = "";        // SCREEN_STRINGINPUT_MESSAGEBOX (default)
    int nOkStrRef           = 181744;    // "Okay"
    string sOkString        = "";
    int nCancelStrRef       = 181745;    // "Cancel"
    string sCancelString    = "";
    string sDefaultString   = "";
    string sVariableString  = "";

    // The gui-script will always run on the OwnedPC regardless of who the player
    // has possessed. So switch oCrafter to OwnedPC for this purpose only.

    DisplayInputBox(
            GetOwnedCharacter(oCrafter),
            nMessageStrRef,
            sMessage,
            sOkCB,
            sCancelCB,
            bShowCancel,
            sScreenName,
            nOkStrRef,
            sOkString,
            nCancelStrRef,
            sCancelString,
            sDefaultString,
            sVariableString);
}


// Gets a string of comma-delimited indices into Crafting.2da.
// @note Based on GetCrafting2DARecipeMatch() in 'ginc_crafting'.
// @param oItem - the equipable item in the crafting container if any.
// @return      - a comma-delimited list of ints that are Crafting.2da rows
//                ie. the triggerspells for Imbue_Item recipes ( "" if none found )
string GetCrafting2DARecipeMatches(object oItem)
{
    string sRet;

    string sSortedItemList = GetSortedItemList(GetIsObjectValid(oItem));
    string sRecipePrefix = MAGICAL_RECIPE_PREFIX;
    string sCategory = "1081"; // imbue_item
    string sItemsAffected;

    struct IntVector stRows = GetRowIndexes(sCategory); // get Crafting.2da rows per Crafting_Index.2da
    while (stRows.x != -1)
    {
        stRows.x = Search2DAForReagents(sSortedItemList, stRows.x, stRows.y);
        switch (stRows.x)
        {
            case -1:
                return sRet;

            default:
                sItemsAffected = Get2DAString(CRAFTING_2DA, COL_CRAFTING_TAGS, stRows.x);
                // NOTE: If this is category 0-ITEM_CATEGORY_NONE then OBJECT_INVALID will match.
                if (GetMatchesAffectedItems(oItem, sItemsAffected))
                    sRet += IntToString(stRows.x) + ",";
        }

        if (++stRows.x > stRows.y)
            return sRet;
    }
    return sRet;
}

// Finds the first match in Crafting.2da for a string of reagents.
// @note Based on Search2DA() in 'ginc_2da'.
// @param sMatchElement - a sorted list of reagents
// @param iStartRow     - the row in Crafting.2da to start the search on
// @param iEndRow       - the row in Crafting.2da to end the search on (inclusive)
// @return              - the row# if a match is found ( -1 if none found )
// @note The search does NOT stop at an empty string, unlike Search2DA().
int Search2DAForReagents(string sMatchElement, int iStartRow = 0, int iEndRow = -1)
{
    int iTotal = GetNum2DARows(CRAFTING_2DA) - 1;
    if (iEndRow == -1 || iEndRow > iTotal)
        iEndRow = iTotal;

    while (iStartRow <= iEndRow)
    {
        if (Get2DAString(CRAFTING_2DA, COL_CRAFTING_REAGENTS, iStartRow) == sMatchElement)
            return iStartRow;

        ++iStartRow;
    }
    return -1;
}

// Takes a list of Crafting.2da indices and tells player what the candidate spells for Imbue_Item are.
// @param sIndices  - a comma-delimited list of indices into Crafting.2da
// @param oCrafter  - the character to send the parsed info to
// @return          - how to proceed:
//                     1 - (or greater) show triggerspell candidates
//                     0 - don't show candidates, only one match, proceed with standard recipe
//                    -1 - no match found, abort recipe
// @note 'sIndices' will be in format: "234,34,0,2343," eg.
int ParseMatchingIndices(string sIndices, object oCrafter)
{
    int iRet = -1;

    string sSpell, sSpellId, sIndex, sDelint = ",", sNotice, sNoticeSpells;
    int iSpellId, iPos = FindSubString(sIndices, sDelint);
    while (iPos != -1)
    {
        ++iRet;

        sIndex = GetStringLeft(sIndices, iPos);
        sSpellId = Get2DAString(CRAFTING_2DA, COL_CRAFTING_CATEGORY, StringToInt(sIndex));
        iSpellId = StringToInt(sSpellId);
        sSpell = Get2DAString("spells", "Name", iSpellId);
        sSpell = GetStringByStrRef(StringToInt(sSpell));
        sNoticeSpells += "<c=seagreen>Imbued Spell ID =</c> " + sSpellId + " <c=seagreen>( " + sSpell + " )</c>\n";

        sIndices = GetStringRight(sIndices, GetStringLength(sIndices) - iPos - 1);
        iPos = FindSubString(sIndices, sDelint);
    }

    if (iRet != -1)
    {
        switch (iRet)
        {
            case 0:
                sNotice = "<c=plum>_ Crafting :</c> ";
                break;
            default:
                sNotice = "\n<c=plum>_ Crafting :</c> <c=slateblue>There is more than one Imbue Item recipe that is possible with your reagents."
                        + " Enter a Spell ID that corresponds to the recipe that you are about to attempt.</c>\n\n";
        }
        SendMessageToPC(oCrafter, sNotice + sNoticeSpells);
    }

    return iRet;
}

 

then add the prototypes at the top of 'ginc_crafting' but at the end of all the other prototypes.

// ------------------------
// functions for Imbue_Item:

// Opens a GUI inputbox for entering an Imbue_Item triggerspell.
void SetTriggerSpell(object oPC);
// Gets a string of comma-delimited indices into Crafting.2da.
string GetCrafting2DARecipeMatches(object oItem);
// Finds the first match in Crafting.2da for a string of reagents.
int Search2DAForReagents(string sMatchElement, int iStartRow = 0, int iEndRow = -1);
// Takes a list of Crafting.2da indices and tells player what the candidate spells for Imbue_Item are.
int ParseMatchingIndices(string sIndices, object oCrafter);

  • up
    50%
  • down
    50%
kevL's

- 2 -
all that's needed now are some extra scripts to handle the GUI callbacks ...

--- start ---
// 'gui_trigger_spell_set'
//
// kevL 2016 sept 13
// Callback for the GUI-inputbox that sets the trigger-spell to be used for
// crafting with ImbueItem.

#include "ginc_crafting" // isSpellId()

void main(string sSpell)
{
    object oModule = GetModule();

    string sSpace = " ";
    while (sSpell != "" && GetStringLeft(sSpell, 1) == sSpace)
        sSpell = GetStringRight(sSpell, GetStringLength(sSpell) - 1);

    while (sSpell != "" && GetStringRight(sSpell, 1) == sSpace)
        sSpell = GetStringLeft(sSpell, GetStringLength(sSpell) - 1);

    if (sSpell != "" && isSpellId(sSpell))
    {
        int iSpellId = StringToInt(sSpell);
        SetLocalInt(oModule, "ii_CraftSpellId", iSpellId);

        object oCrafter = GetControlledCharacter(OBJECT_SELF);
        SetLocalObject(oModule, "ii_CraftCrafter", oCrafter);

        string sRef = Get2DAString("spells", "Name", iSpellId);
        sRef = GetStringByStrRef(StringToInt(sRef));
        SendMessageToPC(oCrafter,
                        "<c=plum>_ Crafting :</c> <c=seagreen>Spell ID = </c><c=slateblue>"
                        + sSpell + "</c> <c=seagreen>( " + sRef + " )</c>\n");

        object oContainer = GetLocalObject(oModule, "ii_CraftContainer");
        ExecuteScript("ii_trigger_spell", oContainer);

        // clean up.
        DeleteLocalInt(oModule, "ii_CraftSpellId");
        DeleteLocalObject(oModule, "ii_CraftCrafter");
    }

    // clean up.
    DeleteLocalObject(oModule, "ii_CraftContainer");
}

--- end ---

--- start ---
// 'gui_trigger_spell_cancel'
//
// kevL 2016 sept 13
// Callback for the GUI-inputbox that cancels the trigger-spell to be used for
// crafting with ImbueItem.

void main()
{
    // clean up.
    DeleteLocalObject(GetModule(), "ii_CraftContainer");
}

--- end ---

--- start ---
// 'ii_trigger_spell'
//
// kevL 2016 sept 13
// Script that runs when a trigger-spell is accepted via GUI-inputbox.

#include "ginc_crafting" // DoMagicCrafting()

void main()
{
    object oModule = GetModule();

    int iSpellId = GetLocalInt(oModule, "ii_CraftSpellId");
    object oCrafter = GetLocalObject(oModule, "ii_CraftCrafter");

    DoMagicCrafting(iSpellId, oCrafter);
}

--- end ---

Compile those three scripts and recompile these three scripts:
gp_forgemagic_ca.NSS
gr_domagiccrafting.NSS
i_nx1_container01_ci.NSS

( i think that's it )

Btw, i noticed several semi-harmless little bugs in and around crafting while doing this stuff. oh, and if there's a blank row in Crafting.2da, that can manifest a break similar to the Indexing Bug.

edit: removed redundant semi-colon

  • up
    50%
  • down
    50%
kevL's

if you have problems compiling, welcome to compiling. I'll do what I can to smooth it through if so.

  • up
    50%
  • down
    50%
kevL's

edit: added to ParseMatchingIndices()

    [deleted]

edit2: changed to

    [deleted]

 

done & done above^

  • up
    50%
  • down
    50%
Vandervecken
I will make the changes soon in TCC. Can you push a savegame zip up to some cloud server for me to test with?
  • up
    50%
  • down
    50%
kevL's

unfortunately Dropbox changed my password and sent verification to an ancient email. But creating a new account says I need Vista or higher. etc.

so,

Create a new area
throw down a Magician's Workbench
log in with a Warlock
console xp to whatever level - target, givexp 500000
Click through recommended options (probably*)
console in items - target, giveitem xxxxxxxx (resref-strings available on the web)

- Strider pointed out a duplicate using
"cft_ess_fire3" - glowing fire essence
"cft_gem_13" - rogue stone
item: equipable non-weapon/non-armor (eg, boots)
And either Fox's Cunning or Bull's Strength.

here's some boots: "boots_hide"


note: am about to change the edit in ParseMatchingIndices() again ... (cosmetic)

 

* grab some crafting feats.

  • up
    50%
  • down
    50%
kevL's

i noticed a non-breaking quirk ... if there are 2+ spells that can trigger the same enchantment from the same reagents ... eg. Fireball OR Flamestrike creating the same product, player is given a choice of spells ... which is a bit misleading (they both do the same thing).

not making any changes about it, yet.

  • up
    50%
  • down
    50%
Vandervecken
I don't think it's a problem. A typical player is using a walkthrough, or a reference file. They won't be confused. Are you making sure to provide a list of spells that is relevant to the item type? For example, in TCC< you can't always use the same spells to place elemental damage enchantments on weapons vs gloves. Shocking Grasp vs Lightning Bolt, for example.
  • up
    50%
  • down
    50%
kevL's

i think so (untested)

GetCrafting2DARecipeMatches() passes oItem into GetMatchesAffectedItems() - and that checks GetIsItemOfBaseTypes()


( I kept the modified functions very similar to the originals. )

  • up
    50%
  • down
    50%
Vandervecken

gui_trigger_spell_set is throwing an error on line 20: no right bracket on expression.

But there clearly is :(.  Here is my line 20:
    if (sSpell != "" && isSpellId(sSpell))

Apart from that everything else has compiled.

I'm assuming your post on Thu, 2016-09-15 10:40 with edits already ahs those edits incorporated into the previous posts.

  • up
    50%
  • down
    50%
kevL's

look at the line above #20, the while loop, and make sure it's well formed.

Also, go over your incarnation of isSpellId() and make sure it's not passing the error into 'gui_trigger_spell_set'.

nb. It'd be a good idea to add a prototype for isSpellId() in 'ginc_crafting' -- I didn't put one in to keep things simple, but really there should be one.

--
The edits are incorporated (as long as the code was copied *after* i made the edits).

 

Oh, if you're using the stock compilier I suggest giving Skywing's Advanced Script Compiler plug-in a try.

i might have slipped in some c-like syntax that the ASC is okay with ... but then, I'm also using the standalone ASC and it has some differences from the plug-in, etc. Though, Sky does say

  • Various fixes are also made to ensure that scripts compiled with the console compiler are also compileable by the stock script compiler.
  • up
    50%
  • down
    50%
Vandervecken

Ok, the reason I was screwing up is that I didn't even have isSpellId.

This is because I was going off posts #37 and #38 only, and you only mention isSpellId's construction in post #11. You also mention other changes in post #11. Are they still needed? Or do Ijust need to take the isSpellId definition in post #11, and add it to the changes in posts #37 and #38?

  • up
    50%
  • down
    50%
kevL's

there's a blurb at the top of post #37 about it.

basically, it's needed. If you don't have it in you're asking for trouble ;)

  • up
    50%
  • down
    50%
kevL's

Strider said

  • I started MOTB NWN2 and finding that persistant haste doesn't last but about 15 minutes in game time instead of 24 hours in game time.  I thought maybe it was getting dispelled, but I've cast it and just ran around and it disappears within 15 minutes game time.  What gives?  I don't know why I have bugs like this when I don't see posts about this bug all over the place.  I have seen a few mentions of it but no replies in different forums.

try beta 96

  • up
    50%
  • down
    50%
Vandervecken

I have it working but it has some issues:

Issue 1:

I created a Belt of Agility and put in a Ruby and a Radiant Fire Essence. If offered me Burning Hands and Flame Strike, both of which generated "Not a valid enchantment" errors. When I tried it with a spear it offered me additionally Fireball, so it's definitely taking its cues regarding which spells to offer from the item type. It's just not doing it correctly.

Issue 2:

It allowed me to enchant a spear for fire damage with Burning Hands, despite that being of the wrong type. This might however be a flaw with the mod itself, which I am exploring.

 

Incidentally I am trying to generate debug text by using calls like:
     SendMessageToPC(GetFirstPC(),"test");
in DoMagicCrafting, but even though I compile ginc_crafting and gr_domagiccrafting, I'm not seeing the text in the chat window. Am I doing it wrong?

  • up
    50%
  • down
    50%

Pages