Author Topic: Add options to bit field / hexadecimal values in 2da files?  (Read 896 times)

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0


               I'm looking at a couple of the 2da files (metamagic.2da and spells.2da), and I got to thinking..."wouldn't it be great if I could add a couple of metamagic options for my PW?"  Digging and searching turned up the first 2da file.  The only problem: Is it possible to add possible values to the metamagic column and still have the game read/use them properly?

From NWNWiki, I get this info:

0x01empower spell


0x02extend spell


0x04maximize spell


0x08quicken spell


0x10silent spell


0x20still spell


So I could make it so a caster could use empower or maximize by using 1 + 4 = 0x05 or allow quicken, silent, or still with 0x26 (8 + 10 + 20 = 38, converted to hex).

But what if I want to add a few metagagic options? What numbers would be next to use in the bit field?

How are the options from metamagic.2da aligned with the bit field values?  They don't appear to match the order from the 2da file. (although they do match the order alphabetically and by feat ID number).

Is all this hardcoded and non-extendable?  If so, why include a metamagic.2da file?
               
               

               
            

Legacy_Khuzadrepa

  • Sr. Member
  • ****
  • Posts: 347
  • Karma: +0/-0
Add options to bit field / hexadecimal values in 2da files?
« Reply #1 on: July 26, 2010, 02:01:05 pm »


               Honestly, I don't know if anyone has ever tried to do what you are pondering.

I can confirm your logic on the current values, as I played around with that myself a long while ago.

My guess is that this is hard-coded.  Those values would probably need to be fed into the combat engine in order to produce some of the results (especially Quicken.)

It couldn't hurt to try to add one, though, and see what happens.  The next number in the series would probably be 0x40, since the progression is thus when converting the values:
0x01 hex = 1 in decimal
0x02  = 2
0x04  = 4
0x08  = 8
0x10 = 16
0x20 = 32

so next would be:
0x40 = 64
0x80 = 128

This is a very interesting idea.  Please let us know what you discover. '<img'>

And the metamagic.2da seems to add the spell level adjustments for spells that the metamagic feat is being used on, so that a quickened invisibility is 6th level spell to cast instead of 2nd, etc.

Hope that helps!
Cheers,
Khuzadrepa
               
               

               


                     Modifié par Khuzadrepa, 26 juillet 2010 - 01:14 .
                     
                  


            

Legacy_B_Harrison

  • Sr. Member
  • ****
  • Posts: 301
  • Karma: +0/-0
Add options to bit field / hexadecimal values in 2da files?
« Reply #2 on: July 26, 2010, 02:52:55 pm »


               Whatever you do with 2das, I think the main problem you'll run into is the actual GUI element of applying metamagic to a spell in game (the additional metamagic tabs that appear in the spellbook GUI are most certainly hardcoded).

Random alternative idea: "Dummy" feats that modify spells cast by characters who have them?
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Add options to bit field / hexadecimal values in 2da files?
« Reply #3 on: July 26, 2010, 03:16:49 pm »


               I suspect it's going to work much like adding a new damage type for weapons.  It'll look pretty and you'll get stuff to work provided you make the tlk table accept the values.  However the new feat will not actually do anything and it will either resort to the last hexcode that did something or more likely it will just cast the spell as a standard type/duration.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Add options to bit field / hexadecimal values in 2da files?
« Reply #4 on: July 26, 2010, 04:01:44 pm »


               Metamagic is hardcoded, you wont see new one in GUI and also there isnt space for it either. So you dont have to mess with spells bits since you cant do it same as it works for other metamagic. You can however make feat, which would alter spells.

Either automatic one, that would therefore stack with other metamagic, or feat that must be actived before casting a spell. Then you just need to modify all spell scripts, in most cases its possible to do via core function hooking.



Anyway I plan new spell scripts concept for my atch 1.70 project that would allow anyone to modify all spells in fly without any issues. If you want to see how it looks like I can send you example (still waiting for opinion on other scripters), you could then help me to decide if that concept is good or not. Btw one of the feature is you can have more metamagic at once.
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Add options to bit field / hexadecimal values in 2da files?
« Reply #5 on: July 26, 2010, 05:22:02 pm »


               Did some testing, and it was a failure. '<img'>

The goal was to add in some "free" metamagic feats for spellcasters that would allow them to raise the level of a spell for purposes of using a higher level spell slot for a lower level spell (like you can do in PnP D&D).  I wanted to give my players the option (if they really wanted to) to do something like fill every one of their epic level wizard's spell slots with ray of frost.

I was able to add the feats just fine (with entries in my tlk file, feat.2da, spells.2da, and cls_feat_wiz.2da), but increasing the bit field values (as posted above by Khuzadrepa) did not allow the use of the new metamagic when memorizing spells from the spellbook.

Bummer.  I sometimes (ok, often) think it's just too bad that BioWare can't do any more patches to the game.  So much of this game can be customized and enhanced, but this seems to be one of the aspects that is permanently locked away.
               
               

               


                     Modifié par The Amethyst Dragon, 26 juillet 2010 - 04:24 .
                     
                  


            

Legacy_Khuzadrepa

  • Sr. Member
  • ****
  • Posts: 347
  • Karma: +0/-0
Add options to bit field / hexadecimal values in 2da files?
« Reply #6 on: July 26, 2010, 06:01:47 pm »


               Ah well.  Worth a shot anyway.

I have seen some passive metamagic feats added, as B_Harrison described (an elemental damage one comes to mind), but your idea is too closely linked to the spellbook to be workable that way, I think.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Add options to bit field / hexadecimal values in 2da files?
« Reply #7 on: July 27, 2010, 01:58:37 am »


               Just to clarify what the numbers are.  



Each one of the Hex numbers there:



0x01 hex = 1 in decimal = 0000_0001 id binary.

0x02 = 2  = 0000_0010

0x04 = 4  = 0000_0100

0x08 = 8  = 0000_1000

0x10 = 16= 0001_0000

0x20 = 32= 0100_0000



They are nothing more then a single bit set in the binary number.  In short they are bit flags that can be easily masked out with the Logical And Operator.  This way if you want to know if a spell can be maximized you grab the 2da string and do a mask on it with the value of the Maximized.  



0x40 = 0000_0100



if ( (0x40&2da entry) == 0 ) the spell can not be maximized

else It can.  



any other bits set besides the ones defined will do nothing unless code is added for them. With no extra code they will simply be masked away.