Aller au contenu

Photo

How to correctly modify hench*.2da files with TonyK's scripts


  • Veuillez vous connecter pour répondre
18 réponses à ce sujet

#1
RedRover72

RedRover72
  • Members
  • 16 messages
I've been scouring google for a way to update henchspells.2da for TonyK's AI. I found a tool that Painofdungeoneternal wrote, and it looked really promising, but it still seems to be missing some of the bit flags.

I've also tried importing the erf version of Tony's AI into a simple module and tried calling the scripts to update, but no luck their either, it doesn't actually update the 2da file.

Tony mentioned he had a C# utility that could run in Visual Studio, but I can't find that anywhere either.

I tried "manually" updating the 2da's, but figuring out the bit flags by hand is near impossible.

Can anyone point me in the right direction, or is this now a black box that really can't be updated anymore?

Thanks,
Red

:crying:

Modifié par RedRover72, 06 mai 2012 - 04:07 .


#2
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Yep it's a bit of a black box. His tool he did not release, and even if he did not sure how much good it would do. I think it was just for personal use.

Mine is based on reversing out what he did in his AI, and should work for some of the fields which i've completed, but not sure if i'll ever get thru all of it perfectly - there are more than one 2da involved as well so there is a lot of work still left. If you do figure out some of it, or notice areas which need adjustments i can incorporate those.

( if you find the nss scripts that refer to those 2da files, you can see the bitwise operations and where they are used, and figure out what is going on, i just deduced from that what each thing is doing )

( I'm at some point going to get all the main 2da's set up with similar wizards )

#3
RedRover72

RedRover72
  • Members
  • 16 messages
Meh, that's what I figured. It's a shame he didn't release the source for his C# tool, I'm sure someone would have been able to make it work. Heck, I don't care if it's user friendly, I have all sorts of ugly in-house, debug only executables too.

Good work on your handy little tool, BTW. I was sooo happy when I found it. Up till then I had been using a simple bit calculator I wrote using the information from Tony's scripts... it was a real PitA, and of course, it didn't work either. I never could get my bit totals to match what Tony had in his 2da file. Obviously part of the puzzle was swept away somewhere.

Best,
Red

#4
luna_hawke

luna_hawke
  • Members
  • 88 messages
RedRover, I've had some mild success at adding new spells by copying a similar spell in the AI file.
And changing the EffectWeight based on weather the spell is higher or lower level.
It's a bit of trial and error and isn't perfect.
But it was better than nothing.

#5
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages

RedRover72 wrote...

Meh, that's what I figured. It's a shame he didn't release the source for his C# tool, I'm sure someone would have been able to make it work. Heck, I don't care if it's user friendly, I have all sorts of ugly in-house, debug only executables too.

Good work on your handy little tool, BTW. I was sooo happy when I found it. Up till then I had been using a simple bit calculator I wrote using the information from Tony's scripts... it was a real PitA, and of course, it didn't work either. I never could get my bit totals to match what Tony had in his 2da file. Obviously part of the puzzle was swept away somewhere.

Best,
Red


Thanks, as you figure things out, please keep me updated so i can incorporate things into my program. I really just got it so it seems to work in general, have not really tested every detail in depth. Not really gotten any feedback on it, not even sure if anyone is using it besides yourself and me, so glad it's proving useful to some degree.

#6
RedRover72

RedRover72
  • Members
  • 16 messages
Sorry for the late reply, just got back.
@luna - ya, that's what I've tried to do as well. Some limited success, as you said, but it's better than nothing.

@pain - Unfortunately I haven't had a chance to use your tool much, but I am using it to calculate bit flags on the 2da's that are enabled with it. Very handy, that bit.

Well, if anyone ever figures out why the bits do not total as Tony's scripts imply, please post it up somewhere around here. I'd love to be able to add in new spells without recycling an existing entry.

#7
kevL

kevL
  • Members
  • 4 061 messages
+1

#8
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages

RedRover72 wrote...
Well, if anyone ever figures out why the bits do not total as Tony's scripts imply, please post it up somewhere around here. I'd love to be able to add in new spells without recycling an existing entry.


I'd like to know what you mean by bits that don't total as Tony's scripts imply -- if you'd share the basis of that I could actually solve said issue - but what you are asking for you should be able to use my program for.

Having rebuilt his AI, and made my tool based on his AI, my values should work very closely with how the script work. There are guaranteed errors in his original data, in his tool, and even how his script parse that data in game, it's just too complicated overall. ( Even the offical spells.2da had a lot of lines which clearly had an incorrect values in at least one column ).  My tool should already have the important ones covered.

#9
RedRover72

RedRover72
  • Members
  • 16 messages
Ah, sorry if my own ignorance is getting me in trouble here.

What I meat was, when I used my own bit calculator, and your tool as well, the bit total did not add up to what was in the hench*.2da files. I looked at the bit flag values in Tony's scripts to come up with the calculations (don't remember which one off hand, but it was in his erf pack), and all but 2 fields were the same as in your tool, so I figured I must have had the right info.

I don't have any data right now, but I can recreate one if you like (probably need to wait till Saturday, though). An example; I redid the Bless spell with the same flags, but the bit total was not the same for one or two columns (pretty close, though), and the AI ignored it as a valid buff. Of course, I had to enter the weight manually, so I just put in the same value. (to do this, I had a cleric memorize a single bless spell, and nothing else). Put Tony's original values back in and it the toon would automatically buff again (when I told it to buff, anyway).

Best,
Red

Modifié par RedRover72, 10 mai 2012 - 10:46 .


#10
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Yes show me the specific one, and i can sort out what is going on and figure out the issue there. Would like to know how you instruct said character to buff just to make sure i am tracing the correct functions in the AI. ( i have debugging lines in my rebuilt version of the AI which allows me to see what is going on a lot easier )

Modifié par painofdungeoneternal, 10 mai 2012 - 10:55 .


#11
RedRover72

RedRover72
  • Members
  • 16 messages
NP, I can recreate the data again.

To tell a toon to buff I would right-click, select buff, and choose one of the buff options. I would normally choose "short duration party" for testing, as that would cast all buff spells of all durations.

It works fine if I use Tony's default values, but not if I recreated them. You may be wondering why I bothered to recreate them at all.. well, that's because I couldn't get my calculated values to work with spells I added. Sooooo, I figured I would go with a known quantity to see what happened. That's when I discovered the bit flags were not matching, and were causing the AI to ignore the entry.

#12
RedRover72

RedRover72
  • Members
  • 16 messages
@pain,
As promised, here's some data to look at. I'll use the Bless spell, since I know there was at least one column that was different there.

I know you already know all this, but this helps me through the process :)

Here is the original entry from Tony's distribution:

From HenchSpellDef.NSS:
HenchSetSpellBuffEntry(SPELL_BLESS, HENCH_SPELL_INFO_SPELL_TYPE_BUFF, 1, HENCH_SPELL_INFO_CONCENTRATION_FLAG | HENCH_SPELL_INFO_MEDIUM_DUR_BUFF ,
9.144, SHAPE_SPHERE | HENCH_SPELL_TARGET_RANGE_LONG | HENCH_SPELL_TARGET_SHAPE_LOOP | HENCH_SPELL_TARGET_REGULAR_SPELL,
HENCH_EFFECT_TYPE_ATTACK_INCREASE | HENCH_EFFECT_TYPE_SAVING_THROW_INCREASE,
0, 0, 0,
0.04)

I know from the above data, that each column is comma separated, and each bit flag in that column is separated by a pipe.
The only deviation from that (that I can tell) is that the SpellInfo column is actually the spell type, spell level, and some flags concatenated into a single value. Also, TargetInfo concatenates Radius and the flags.

The bit flags are descriped in hench_i0_spells and correspond to the henchspells.2da as follows (sorry if formating makes this look bad)
id SpellInfo      TargetInfo  EffectTypes  DamageInfo   SaveType   SaveDCType
6  369632259 67180260  516               ****                   0                   ****

NeverWorker correctly reports the following information about each column.

SpellInfo: (369632259)
Level = 1
Type = Buff
Flags = Concentration
Duration = Medium

Effect Types: (516)
Flags = Saving Throw Increase, Attack Increase

Target Info: (67180260)
Radius = 9.1
SpellShape = ???? (edit: this is missing)
Range = Long
Flags = Loop, Regular Spell

Damage Info: (****)
Null (****)

Save Type: (0)
Save 1 = Null, Effect Only
Save 2 = Null, Effect Only
Flags = Null
Custom Type = No Check

However, if I clear everything out of the row (make everything null) and re-enter it with NeverWorker, setting all the flags and entries the same as above, I see two discrepancies, which seems to cause the AI to ignore the spell as a castable buff.

Spell Info = 533507
Target Info = 67180256

TargeInfo is pretty close, only 4 off from the other bit total. I believe that is attributed to the fact that NeverWorker only counts Radius to 1 decimal place, but Tony's script counts to 3. i.e 9.1 can be entered in NeverWorker, but if you look at HenchSpellDef.NSS, Tony counted it out to 9.144. That may account for the discrepancy there. However, I don't think that would cause the AI to ignore the entry. Probably something you could look at, though.

SpellInfo is significantly different, and I think this the column that is missing some kind of bit flag. The bit total is off by 369098752 (or 16000000 in hex). So, just for kicks, I tried changing the bit flags the same way on the next 3 spells, and they were all off by the same amount! ID 9, however was off by 369098764 (1600000C), 12 more than the others (maybe the spell type 'Attr Buff' is set incorrectly?). Line 10 was back to the same dif as the other 3. That's where I stopped. I'm sure there is a pattern in there somewhere.

Anyway, I hope this is of help to you in some way.

Best,
Red

Edit:
Actually, on TargetInfo, the spell shape is missing... that's why it's off by 4.
const int HENCH_SPELL_TARGET_SHAPE_MASK             = 0x00000007;
// standard spell shapes in mask
/*
int    SHAPE_SPELLCYLINDER      = 0;
int    SHAPE_CONE               = 1;
int    SHAPE_CUBE               = 2;
int    SHAPE_SPELLCONE          = 3;
int    SHAPE_SPHERE             = 4;
*/
const int HENCH_SHAPE_NONE                          = 7;        // indicates no shape
const int HENCH_SHAPE_FACTION                       = 6;        // indicates faction targets

Modifié par RedRover72, 13 mai 2012 - 12:33 .


#13
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
That is exactly what i need. Remember it being off by 16000000 is actually saying certain bits are off or on, ( that actually is 3 different bits all not set ). I just need to figure out what label to put on the interface to describe those three bits, or if it's holding some other data in that position. Once i find 0x10000000, 0x04000000, 0x02000000, i'll be able to set it up in the editor.

| is a bitwise operator which merges values. ( Generally it's packing multiple bits into one integer, you can later test if the resulting integer contains those bits, which are just referred to by the constants, much like you use + ).

#14
RedRover72

RedRover72
  • Members
  • 16 messages
RIght, sorry; cold medicine makes me miss the obvious. I think I saw a left shift somewhere in there, I'm checking now.

Edit: Nope, no left shift that I can see. Guess I need to take more cold medicine and go back to bed, I'm obviously imagining things.

Modifié par RedRover72, 14 mai 2012 - 08:16 .


#15
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
There are shifts in there, and masks as well -- pretty complicated all told.

#16
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Think i figured it out, there is a version on the value...

Basically a 22 shifted over 24 binary spaces.
const int HENCH_SPELL_INFO_VERSION                  = 0x16000000;
const int HENCH_SPELL_INFO_VERSION_MASK             = 0xff000000;

If it does not have this included, it just won't work. Really need to just remove this check from the AI entirely as from what i understand there is only one version, so not sure what advantage is to having a version for every row. I'm going to put it in so its editable, even though it redundant, and end users will just have to make sure a 22 is in the field.

The targeting is off by 4, which means it's all in the bottom bits, need to figure out what is going on in that lower range.

Modifié par painofdungeoneternal, 15 mai 2012 - 05:14 .


#17
RedRover72

RedRover72
  • Members
  • 16 messages
Check my post above on the targeting piece... the spell shape is not implemented. Even though he has it commented out, it looks like that he included it in his in-house calculation anyway.

#18
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Yep, missing the value of SHAPE_SPHERE, added a new menu to support shape in target info. ( it is a number from 0 to 7 not bitbased but masked correlating to the SHAPE_* constants in nwscript.nss as you noted. That accounts for the 4 being off. Think i got the issues you described fixed, will be included in next release of never launcher.

Looked at the bulls strength, redid the type menu which hopefully solves that. Still seems have some outlier issues where it seems to zap something you already set and you have to reset it.

#19
kevL

kevL
  • Members
  • 4 061 messages
sweet.

I'm slowly edging closer to teasing this stuff myself; i Mean, to make the most of all the spells that have been added to the game a guy's got to, right?