Jump to content

WEIDU - items basic coding problems


ptifab

Recommended Posts

1 hour ago, DavidW said:

Your code is probably not working because you are removing the lines as you go along. That is: first your code finds row 167, and removes it. Then it checks row 168 - but the old row 168 is now at row 167, because it got bumped one earlier. So some rows are being missed.

That said, I strongly recommend not removing those entries, as they're there for a reason: they are used by spells in Icewind Dale: Enhanced Edition. (And so Beamdog guarantees that if they - or a modder - wants to bring a spell that uses IWD icons over to BG2, the space is there for it and all that has to be done is add the descriptive string).

I'm not sure what mod you are using* but it ought to be reading statdesc.2da and adding new icons in where there's space, not just assuming that it can start at 166. 

* and I will look silly if it's one of mine

EDIT: there is a function in SCS, add_to_statdesc, that does this automatically. It's in stratagems/sfo/general/lib_general.tpa, and anyone is welcome to borrow it. 

thank you @DavidW i was suspecting those "blank" -1 lines had something to do with other mods. The mod that got me concerned is refinements, wich adds new HLAs but also new portrait icons. The code is rough and append directly to those blank lines, notably taking those IWD placeholders you've mentioned, and overlapping the line 188 wich is a basic EE one. I'm actually talking with @subtledoctor if we can add a solution for both things.

Edited by ptifab
Link to comment

Worth saying up front: just because I have updated some parts of Refinements (appending to HLA tables, some of the installer's structure, bugs in a coupkle .SPL files), doesn't mean I have a grip on the whole mod.  Here's what I can piece together and deem relevant:

  • I have never looked at STATDESC.2da and don't know what it does.
  • A review of the Refinements forum does not turn up any prior discussion of the way HLAB.tpa appends to STATDESC.2da.  Seemed okay, so I never touched it.
  • However, the last time that code was possibly looked over or changed, was probably around ~2010, in Refinements v3.31 being installed on TOB or BGT - not BG2EE
  • Looking at the IESDP, the TOB version of that files ends on line 165.  Refinements begins APPENDing line 166.  Makes sense.
  • However, the BG2EE version of STATDESC.2da goes up to line 191.  So the APPEND command in Refinements will not work well there.
  • The code could fairly simply be tuned to find the next new line, and APPEND each new line with a new index number, which would be valid for any game and would not duplicate any index numbers.
  • However, once again, I have no clear idea what this file does, and I can only presume that various HLAs installed by Refinements make some kind of reference to the index numbers in this file...?  And Refinements being what it is, of the time that it is of, it follows a bit of the SR practice in tuning binary .SPL files in NI or DLTCEP and then simply mass-copying them into the game.  So there is no easy way to link up which .SPL connects to which line of STATDESC.2da and would need to be modified at install-time... if indeed that is what needs to happen.

I don't know what the consequence of this is.  If anyone has a plan or code for fixing it, I gently suggest that running a test or two and doing a pull request with good code would be more efficient than hoping that I learn about it and fix it myself.  OTOH I have just started playing a BG2EE game with Refinements installed (in particular, Refinements is installed after SCS' IWD spells), which means my STATDESC.2da file is probably screwy, and I don't know what that will eventually do to my game. So, I guess consider me motivated to fix this if it needs fixing.
 

EDIT - also worth noting that the EE version of this file includes an extra column, which Refinements does not fill out.  Again, easy enough to account for in the Weidu.  I just don't know what to put there, because I don't know what that (or any) column actually does.

Edited by subtledoctor
Link to comment

The statdesc.2da just link the string and bam file to its respective portrait icon. So if you apply an opcode 142, the parameter2 refers to this statdesc.2da. The problem i'm actually diving into is that refinement mod code is overlapping both IWD spells mentioned by DavidW in a previous post and one base BG2EE icon. That means it will display a wrong icon and string name in the portrait icon and character sheets. Not a big gamebreaking bug, but it can be annoying.

I'm actually studying something with @DavidW to clear this out.

Link to comment

Does anyone know whether the index number actually matters, or is just for show? I vaguely recollect from working with other .2da files (e.g. kitlist) that the stated index doesn’t matter, the engine actually looks at the row number of the file...? Right?

In my game all the IWD spells seem to have the proper .BAMs... I think. If this conjecture is correct then it would mean this just affects Refinements spells. Should be able to test.  

Link to comment
41 minutes ago, subtledoctor said:

Does anyone know whether the index number actually matters, or is just for show? I vaguely recollect from working with other .2da files (e.g. kitlist) that the stated index doesn’t matter, the engine actually looks at the row number of the file...? Right?

STATDESC.2DA looks up the entry based on the index number + column heading, so yes, in this 2DA it actually matters.

Link to comment

Following up on this... I have restricted Refinements' malarkey with STATDESC.2da to the old engine.  Here's what happens:

  • Refinements assumed statdesc.2da and states.bam are unchanged from the vanilla TOB version
  • It copies over its own version of states.bam, which is just like the vanilla version but with ~24 new portrait icons added as new cycles
  • It appends lines to  statdesc.2da, which line up with the new cycles of states.bam

All of that will still happen on the old engine - if it was working, it will still work.  But for the EEs, it doesn't work, not least because statdesc.2da is structured differently, but also because new portrait icons can be added with .bam files that are not cycles of states.bam

So what I would like to do, it extract those new portrait icons into new, separate .bam files; add them individually on the EE games; and use the CD_NEW_PORTRAIT_ICON function to add them to the new HLAs as appropriate.

I have a .BAM file with the 24 new icons, but... a couple of them seem to be duplicates of each other?  From what I can tell, from /Refinements/lib/hlab.tpa, they line up like this with the new entries in statdesc.2da:

Spoiler

cycle 230 = elem transform (now the 1st cycle of the attached .bam)
  232 = aqua 
  233 = idol 
  234 = spirf
  235 = scion
  236 = chant
  237 = dragf
  238 = tigs 
  239 = chanm
  240 = cripp
  241 = divsh
  242 = endu 
  243 = guard
  244 = exor 
  245 = ling 
  246 = prec 
  247 = merc 
  248 = spii 
  249 = tkai 
  250 = secw 
  251 = inti 
  252 = aegi 
  253 = shol 
  254 = fors 

But I don't know which icon goes with which HLA.  I can guess at a few - "aegi" probably goes with Aegis... but then again, "aegi" is the 3rd-to-last cycle, but the 2nd-to-last cycle looks like a shield, which I guessed would be with the Aegis HLA. So, I'm not sure how well these things really line up?

It's been 10 years since I played through to HLA levels with Refinements installed.  I'm just not familiar enough with the spells in the mod to know what to do with these icons.  So I guess I'm asking for help from people who might be really familiar with these spells.  I'll attach the .bam file with only the new icons... I'm just not sure whaat to do with it at this point.  If someone could say something like "cycle 22 goes with Aegis, cycle 16 goes with Foresight, etc." then I would be able to take it from there and fully fix the mod for the EEs.  But at the moment I'm at a bit of a loss.

EDIT - hmm, maybe could  write something up in Weidu on a game that has Refinements installed - check all spells with 142 effects, check parameter2 of each one, and PRINT the RES of the each spell corresponding to the Refinements additions to statdesc (which we know from the mod's APPEND command - the parameter in the 142 effect would be something like the statdesc index minus 65).  That would give a simple list of which new icons go with which spell - assuming the new cycles in the mod-added states.bam line up one-for-one with the APPENDed lines in stadesc.2da... which I guess is an open question.  But, if the answer to that question is "yes," then that resulting list would allow me to manually plug the icons into the spells at install-time for the  EE games, which would solve this.

refstate.bam.zip

Edited by subtledoctor
Link to comment

I can give you what I can remember, but the safest way is going to be installing Refinements on a classic version of ToB and then creating a new character and giving them enough XP to trigger a level up so you can view the HLA screen.  Then go through the list of Refinment classes (and the Sword Angel).  Any that are not a HLA will probably end up being something related to a spell of which there are only a few and should be easier to track down.

  

Quote

cycle 230 = elem transform (now the 1st cycle of the attached .bam)
  232 = aqua - Sorcerer HLA Aqua Mortis
  233 = idol - Sorcerer HLA Idol of Frost
  234 = spirf - Sorcerer HLA Spirit of Flame
  235 = scion - Sorcerer HLA Scion of Storms
  236 = chant - Monk HLA Chant
  237 = dragf - Monk HLA Dragon Fist
  238 = tigs 
  239 = chanm - Sorcerer HLA Channel Magic
  240 = cripp - Thief HLA cripple
  241 = divsh - Cleric HLA divine shell
  242 = endu - Ranger HLA endurance
  243 = guard - Might be Necromancer "Create Boneguard"
  244 = exor - Paladin HLA Exorcism
  245 = ling 
  246 = prec - Archer HLA precision
  247 = merc - Sword Angel ability Merciful Fighting
  248 = spii - Sword Angel HLA Spiritual Integrity
  249 = tkai 
  250 = secw - Monk HLA Second Wind
  251 = inti - Monk HLA Inner Time (I think)
  252 = aegi 
  253 = shol 
  254 = fors - Wizard HLA Foresight

 

Link to comment

Here you go

cycle 230 = elem transform (now the 1st cycle of the attached .bam)
  232 = aqua - Sorcerer HLA Aqua Mortis -> tg#aqua.spl
  233 = idol - Sorcerer HLA Idol of Frost -> tg#idof.spl
  234 = spirf - Sorcerer HLA Spirit of Flame -> tg#spof.spl
  235 = scion - Sorcerer HLA Scion of Storms -> tg#scst.spl
  236 = chant - Monk HLA Chant -> tg#chnt.spl
  237 = dragf - Monk HLA Dragon Fist -> tg#bl03.spl
  238 = tigs - Monk HLA Tiger Strike -> tg#tigs.spl
  239 = chanm - Sorcerer HLA Channel Magic -> tg#cham.spl
  240 = cripp - Thief HLA cripple -> tg#crip.spl
  241 = divsh - Cleric HLA divine shell -> tg#divn.spl
  242 = endu - Ranger HLA endurance -> tg#endu.spl
  243 = guard - Cleric HLA Guardian Angel -> tg#gang.spl
  244 = exor - Paladin HLA Exorcism -> tg#exor.spl
  245 = ling - Bard HLA Lingering Song -> tg#li01.spl tg#li02.spl tg#li03.spl
  246 = prec - Archer HLA precision -> tg#prec.spl
  247 = merc - Sword Angel ability Merciful Fighting -> li#merc3.spl (called from li#merc.spl)
  248 = spii - Sword Angel HLA Spiritual Integrity -> li#spii.spl
  249 = tkai - Kensai HLA True Kai -> tg#gkai.spl
  250 = secw - Monk HLA Second Wind -> tg#secw.spl
  251 = inti - Monk HLA Inner Time -> tg#inti.spl
  252 = aegi - Wizard HLA Aegis -> tg#aegi.spl
  253 = shol - Paladin HLA Shield of Law -> tg#shol.spl
  254 = fors - Wizard HLA Foresight -> tg#fors.spl

 

Link to comment

Heh... I didn't see that post, and in the meantime I wrote up a little Weidu mod to inspect every spell's opcode 142 effects and find which ones used which Refinements portrait icon. :borg: Thanks, though.

Once I had that info, and I think I extracted the various .bam frames correctly from the bundle in Refinements, I could manually add them in with each spell.  So now, as of version 4.27, it will no longer screw up STATDESC.2da, and the various HLAs should still display the appropriate portrait icons.

Thanks for the help figuring that out.

Link to comment

I'm impressed how many I got from memory.  This was discussed on the SHS forums way back in the day, but it was in the Refinements workroom and I can't remember my login info for the site anymore, even if I could still access the workroom.

Link to comment
1 hour ago, subtledoctor said:

Heh... I didn't see that post, and in the meantime I wrote up a little Weidu mod to inspect every spell's opcode 142 effects and find which ones used which Refinements portrait icon. :borg: Thanks, though.

Once I had that info, and I think I extracted the various .bam frames correctly from the bundle in Refinements, I could manually add them in with each spell.  So now, as of version 4.27, it will no longer screw up STATDESC.2da, and the various HLAs should still display the appropriate portrait icons.

Thanks for the help figuring that out.

Just tested on a fresh BG2EE install and it work with or without sword angel kit component, well done sir ! For info, the weidu installer is 24200, (actual one is 24600 if i remember) i dunno if that can have impact on some installations, but maybe you'll want to update it ?

Link to comment

I have this function

LAF statdesc_icon_ref STR_VAR bam_name = ~IUICOCLD~ RET icon_ref END
COPY_EXISTING_REGEXP GLOB ~^.+\.spl$~ override PATCH_IF SOURCE_SIZE>0x71 BEGIN
READ_LONG  0x64 abilities_off
READ_SHORT 0x68 num_abilities
READ_LONG  0x6a effects_off
READ_SHORT 0x6e effects_ind
icon_added = 0
	FOR (i = 0; i < num_abilities; i += 1) BEGIN
	READ_SHORT (abilities_off + 0x28*i + 0x1e) num_features
	READ_SHORT (abilities_off + 0x28*i + 0x20) features_ind
		FOR (j = 0; j < num_features; j += 1) BEGIN
		READ_SHORT (effects_off + 0x30*(features_ind + j) + 0x00) opcode
			PATCH_IF opcode = 206 BEGIN // protection from spell
				READ_BYTE (effects_off + 0x30*(features_ind + j) + 0x0d) resist_dispel
				READ_LONG (effects_off + 0x30*(features_ind + j) + 0x0e) duration
				READ_ASCII (effects_off + 0x30*(features_ind + j) + 0x14) resource (8)
					PATCH_IF ~%resource%~ STRING_EQUAL_CASE ~SPWI213~ || ~%resource%~ STRING_EQUAL_CASE ~SPWI213D~ || ~%resource%~ STRING_EQUAL_CASE ~SPWI502~ || ~%resource%~ STRING_EQUAL_CASE ~SPWI502D~ || ~%resource%~ STRING_EQUAL_CASE ~SPWI614~ || ~%resource%~ STRING_EQUAL_CASE ~SPWI614D~ || ~%resource%~ STRING_EQUAL_CASE ~SPWI810~ || ~%resource%~ STRING_EQUAL_CASE ~SPWI810D~ || ~%resource%~ STRING_EQUAL_CASE ~SPPR250~ || ~%resource%~ STRING_EQUAL_CASE ~RR#WI502~ || ~%resource%~ STRING_EQUAL_CASE ~DVCKILL~ || ~%resource%~ STRING_EQUAL_CASE ~DVWCKILL~ || ~%resource%~ STRING_EQUAL_CASE ~DVCKILL2~ || ~%resource%~ STRING_EQUAL_CASE ~WAND13~ BEGIN 
						PATCH_IF icon_added = 0 BEGIN
						LPF ADD_SPELL_EFFECT INT_VAR opcode = 142 target = 1 parameter2 = %icon_ref% resist_dispel = %resist_dispel% duration = %duration% insert_point = 99 END 
						LPF ADD_SPELL_EFFECT INT_VAR opcode = 139 target = 1 parameter1 = RESOLVE_STR_REF(@1000117) timing = 1 resist_dispel = 2 insert_point = 99 END 	
						icon_added += 1
						END
					END
				END
			END
	END
END // END REGEXP
BUT_ONLY

Everything is working, but i have a problem, the duration of the effect is not re-evaluated on each header (i have multiple spell level headers), does someone knows how to do that ?

Edited by ptifab
Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...