Author Topic: Small incompatibility report (Kelsey vs. the Fixpack)  (Read 13991 times)

Igneous

  • Guest
Small incompatibility report (Kelsey vs. the Fixpack)
« on: December 10, 2010, 02:49:04 PM »
In the vanilla game, Spell Shield is hardcoded to display portrait icon #73 (Protection from Magic Energy). The Fixpack's solution to this predicament is to swap the two spells' portrait icon bams, as well as their strrefs in statdesc.2da, and then to amend PfME accordingly.

But when Kelsey is installed, the changes to PfME are overwritten with Kelsey's own spwi606.spl, rather ancient. As a result, when PfME is cast, the spell references the old icon instead, and the recipient gets Spell Shield slapped across their portrait.

One possible solution would be to copy-paste the Fixpack's patch-code directly into Kelsey's .tp2 file, after all the spell overwrites have taken place. So, you could insert this code...

Code: [Select]
ACTION_IF (MOD_IS_INSTALLED ~bg2fixpack\setup-bg2fixpack.tp2~ 0) BEGIN
  COPY_EXISTING ~spwi606.spl~ ~override~
    READ_LONG  0x64 "abil_off"
    READ_SHORT 0x68 "abil_num"
    READ_LONG  0x6a "fx_off"
    FOR (index = 0 ; index < abil_num ; index = index + 1) BEGIN
      READ_SHORT ("%abil_off%" + 0x1e + (0x28 * "%index%")) "abil_fx_num"
      READ_SHORT ("%abil_off%" + 0x20 + (0x28 * "%index%")) "abil_fx_idx"
      FOR (index2 = 0 ; index2 < abil_fx_num ; index2 = index2 + 1) BEGIN
        READ_SHORT ("%fx_off%" +        (0x30 * ("%abil_fx_idx%" + "%index2%"))) "opcode"
        READ_LONG  ("%fx_off%" + 0x08 + (0x30 * ("%abil_fx_idx%" + "%index2%"))) "icon"
        PATCH_IF (("%opcode%" = 142) AND ("%icon%" = 73)) BEGIN // display old pro-magic energy icon
          WRITE_LONG ("%fx_off%" + 0x08 + (0x30 * ("%abil_fx_idx%" + "%index2%"))) 123 // change to new pro-magic energy icon
        END
      END
    END
  BUT_ONLY_IF_IT_CHANGES
END

... at circa line 582 in Kelsey.tp2. I've tested it and everything looks good. Of course, this is only a stop-gap measure, and doesn't solve the underlying overwrite problem.

I saw in the thread below you were planning on modernising Kelsey sometime, but would you like me to report this to the BiG World folks in the interim? (Not that I'd need to, I suppose. They are quite assiduous.)

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6233
  • Gender: Female
  • The perfect moment is now.
Re: Small incompatibility report (Kelsey vs. the Fixpack)
« Reply #1 on: December 11, 2010, 12:38:56 AM »
Sounds good to me(though I'm not good at patching, alas). I propose adding various "modify Kelsey" things to one topic, so they do not get lost. This topic sounds like a good start.

Igneous

  • Guest
Re: Small incompatibility report (Kelsey vs. the Fixpack)
« Reply #2 on: December 11, 2010, 09:23:58 PM »
Sounds good to me(though I'm not good at patching, alas).

Neither am I, unfortunately—I've only just started learning. That's why my initial solution wasn't a terribly good one. It only accounts for the Fixpack's changes.

I educated myself on the use of ADD_SPELL_EFFECT earlier today, so here's some patch-code I cobbled together that does away with the need for Kelsey to overwrite spwi606.spl. (And, thus, nullifies the need for the code posted above.)

Apparently, the only additions to Kelsey's version of the spell were the extra [Modify script state] effects under each header. All that's needed is to replace this... (line 564, Kelsey.tp2)

Code: [Select]
COPY ~kelsey\SPWI606.spl~ ~OVERRIDE\SPWI606.spl~

... with this:

Code: [Select]
COPY_EXISTING ~spwi606.spl~ ~override~
  READ_LONG 0x64 ~ab_off~
  READ_SHORT 0x68 ~ab_num~
  FOR (i=0; i<%ab_num%; ++i) BEGIN
    SET ~opcode~ = 282        // effect: #282 (modify script state)
    SET ~target~ = 2          // target: preset target (2)
    SET ~timing~ = 0          // timing mode: duration (0)
    SET ~parameter1~ = 1      // value: 1
    SET ~parameter2~ = 27     // scripting state: 27
    SET ~power~ = 4           // power: 4
    SET ~resist_dispel~ = 3   // dispel/resist: 3 (dispel/bypass resistance)

    READ_SHORT (%ab_off% + %i%*0x28 + 0x10) ~min_lvl~
    PATCH_IF (%min_lvl% > 12) BEGIN
      SET ~duration~ = (%min_lvl% * 60)
    END ELSE BEGIN
      SET ~duration~ = 720
    END

    SET ~probability1~ = 100  // prob1: 100%
    SET ~probability2~ = 0    // prob2: 0%
    SET ~dicenumber~ = 0      // dicenumber: 0
    SET ~dicesize~ = 0        // dicesize: 0
    SET ~savingthrow~ = 0     // save type: 0 (no save)
    SET ~savebonus~ = 0       // save bonus: 0
    SPRINT ~resource~ 0       // resref: n/a
    SET ~header~ = %i%+1      // add to every header, accounting for variable duration

    LAUNCH_PATCH_MACRO ~ADD_SPELL_EFFECT~
  END
BUT_ONLY

If there's anything glaringly wrong with the code, please feel free to give a shout-out.

Eh... it just occurred to me... is the use of [Modify script state] for Kelsey's Detectable Spells? I recall reading his version of DS is outdated and troublesome. So I suppose if Kelsey's installer is modernised, this will be unnecessary, anyway.

I guess this code will help, though, until that happens.

~Igneous

  • Guest
Re: Small incompatibility report (Kelsey vs. the Fixpack)
« Reply #3 on: December 15, 2010, 02:27:44 PM »
Alrighty, now I have some inkling on the use of functions, too. As per Lollorian's suggestion, here's a revised fix to Kelsey's .tp2, somewhat shorter.

Replace this...

Code: [Select]
COPY ~kelsey\SPWI606.spl~ ~OVERRIDE\SPWI606.spl~

With this...

Code: [Select]
COPY_EXISTING ~spwi606.spl~ ~override~
  READ_LONG 0x64 ~ab_off~
  READ_SHORT 0x68 ~ab_num~
  FOR (i=0; i<%ab_num%; ++i) BEGIN
    READ_SHORT (%ab_off% + %i%*0x28 + 0x10) ~min_lvl~
    LAUNCH_PATCH_FUNCTION ~ADD_SPELL_EFFECT~ INT_VAR
      ~opcode~ = 282
      ~target~ = 2
      ~parameter1~ = 1
      ~parameter2~ = 27
      ~power~ = 4
      ~resist_dispel~ = 3
      ~duration~ = %min_lvl% > 12 ? %min_lvl%*60 : 720
      ~header~ = %i%+1
    END
  END
BUT_ONLY

Successfully tested, all looks to be in order. Any feedback or suggestions for possible improvement are very welcome. :)

Offline jcompton

  • Niche Exploiter
  • Administrator
  • Planewalker
  • *****
  • Posts: 7244
Re: Small incompatibility report (Kelsey vs. the Fixpack)
« Reply #4 on: December 15, 2010, 05:58:56 PM »
The guaranteed outcome of any Kelsey refresh will be to remove DS entirely, so I wouldn't beat your brains out any further trying to come up with a future-looking solution.
Cespenar says, "Kelsey and friends be at the Pocket Plane? Ohhh yesssss!" http://www.pocketplane.net

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: Small incompatibility report (Kelsey vs. the Fixpack)
« Reply #5 on: December 15, 2010, 06:15:49 PM »
Why would Kelsey even need DS? Like, he has banters when you cast Spook?

~Igneous

  • Guest
Re: Small incompatibility report (Kelsey vs. the Fixpack)
« Reply #6 on: December 15, 2010, 11:22:57 PM »
The guaranteed outcome of any Kelsey refresh will be to remove DS entirely, so I wouldn't beat your brains out any further trying to come up with a future-looking solution.

No worries, no beating out of brains involved. I figured any possible refresh would be a ways off, and working this out has proven one way of increasing my knowledge, anyway.

Offline jcompton

  • Niche Exploiter
  • Administrator
  • Planewalker
  • *****
  • Posts: 7244
Re: Small incompatibility report (Kelsey vs. the Fixpack)
« Reply #7 on: December 15, 2010, 11:57:00 PM »
Why would Kelsey even need DS? Like, he has banters when you cast Spook?

No, it was a decision Ghrey made because he wanted to use DS-aware AI for the Kelsey personal quest fights.
Cespenar says, "Kelsey and friends be at the Pocket Plane? Ohhh yesssss!" http://www.pocketplane.net

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1417
  • Gender: Male
  • Searcher of Bugs
Re: Small incompatibility report (Kelsey vs. the Fixpack)
« Reply #8 on: December 16, 2010, 06:53:14 AM »
Are you interested in retaining a heavy default AI?


edit: sorry - you have already answered this question: http://forums.pocketplane.net/index.php/topic,27371.msg325441.html#msg325441

« Last Edit: December 16, 2010, 07:55:23 AM by cmorgan »

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: Small incompatibility report (Kelsey vs. the Fixpack)
« Reply #9 on: December 16, 2010, 10:42:58 PM »
Maybe he'd get more takers if he made it a contest...

These days, probably not.

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1417
  • Gender: Male
  • Searcher of Bugs
Re: Small incompatibility report (Kelsey vs. the Fixpack)
« Reply #10 on: December 16, 2010, 11:23:13 PM »
We could do it as a community; the bigg has the outline, DS can be dropped, the scripts swapped for vanilla, etc. There just needs to be some decompiling of pre- compiled .bcs, and an evaluation of what dialogs need to be altertrans or other non-destructive integrations; most of the work would be figuring out what is replicated in the ToB portion and setting it up so there is no duplication of distributed resources. I am behind on helping two other projects, but if it is just a matter of someone saying "let's start", the community has already done the impossible by troubleshooting BWP installs of mods that never, ever were to be put together on the same install. Modernizing a stable, well built mod with no need for bugfixing other than an old version of DS should be easy by comparison. So, let's donate coding in a separate thread, and just do it.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: