Jump to content

BG1 Tweak Pack


Guest grogerson

Recommended Posts

A differing question, but one I do not wish to ask in another thread;

 

What happens if you use REPLACE_CRE_ITEM and replace the item with nothing?

 

For example

COPY_EXISTING ~mel01.cre~ ~override~ //I just grasped for a known cre file there...
REPLACE_CRE_ITEM ~~ #0  #0 #0 ~IDENTIFIED~ ~UNDROPPABLE~ ~UNSTEALABLE~ ~WEAPON1~ EQUIP //if I get this, this should install. Maybe.

 

Icen

Link to comment
A differing question, but one I do not wish to ask in another thread;

 

What happens if you use REPLACE_CRE_ITEM and replace the item with nothing?

 

For example

COPY_EXISTING ~mel01.cre~ ~override~ //I just grasped for a known cre file there...
REPLACE_CRE_ITEM ~~ #0  #0 #0 ~IDENTIFIED~ ~UNDROPPABLE~ ~UNSTEALABLE~ ~WEAPON1~ EQUIP //if I get this, this should install. Maybe.

 

Icen

REPLACE_CRE_ITEM will replace and remove an item that is in the specified slot otherwise if no items are in that slot it will default to ADD_CRE_ITEM.

 

For example the little bit of code I post on the previous page regarding khalid as a fighter/mage adds a bow and arrows where there are no items, but I used REPLACE_CRE_ITEM since it will be for the tweak pack and could be installed after something else has played around with khalid....

Link to comment
Thanks for the help, plainab. I've got a nearly working tweak for Khalid now. Two problems remain, however, and I'm studying your code for one of them.

 

There are four Khalid .cre's, you gave for only the first (Khalid.cre, not Khalid2.cre).

 

First, for the other .cre's I've yet to work out setting the memorizable spell slots and the spells memorized (ADD_MEMORIZED_SPELL ...).

 

Second, it's necessary to remove items from the .cre before adding them. REPLACE doesn't appear to be working. Do I need to REMOVE or DESTROY the items, and how do I do it?

 

This is working without copying any files from the tweak package, so far...

I only did the one because I thought you might like to look over what I did for it and see if you can create your own code based on it for the others. Just trying to help you learn a little....

 

For your first problem:

If you want Khalid to come with some pre-memorized spells then you would probably use ADD_MEMORIZED_SPELL. You'll need to check the weidu readme on the syntax and usage. I believe theBigg has modified add_memorized_spell to automatically include add_known_spell if the spell to memorize is not already known.

If you want khalid to come with some blank spell slots that the player can fill with their own choosing look to the code I posted. The memorizable spell slots are where you would change that. There is no cool single line of code for it so you'll have to tinker with the idea i put in there.

 

For your second problem:

Replace should work and you don't need to remove items first.

Are you getting any errors in your weidu install?

Are you getting any errors when you open the modified files in dltcep or near infinity?

If so then there is an offset not getting updated properly.

Otherwise, you may want to try a newer version of weidu if you still have problems.

Without seeing what code you've got for the other three versions of khalid I can't really say for sure what's going on.

Link to comment

Once again, thank you, plainab. And thank you, Icendoan, for asking the right question for me. REPLACE didn't work because it was aimed at the wrong place. REMOVE has taken care of the remaining problems I had.

 

All I need to do now is test the tweak. The Khalid .cre's all change as desired.

 

Credit is yours. :)

 

Edit: Rats!!! CTD when I enter the FAI. Looks like I'll have to use p#fw2301.baf and p#khalid.baf after all. Only thing is, they don't work...

 

p#fw2301.baf - "[LevelLT] not found in TRIGGER.IDS" (same with [LevelGT])

p#khalid.baf - "[RealSetGlobalTimer] not found in ACTION.IDS"

Link to comment
p#fw2301.baf - "[LevelLT] not found in TRIGGER.IDS" (same with [LevelGT])

p#khalid.baf - "[RealSetGlobalTimer] not found in ACTION.IDS"

There are no real time timers in BG1, only "GobalTimer".

According to the IESDP, "Level()" doesn't exist, either, nor does "XP()" (which might have served as a workaround). :)

Link to comment
According to the IESDP, "Level()" doesn't exist, either, nor does "XP()" (which might have served as a workaround). :)

 

You can use one of these as a substitute:

 

CheckStatLT(Myself,161000,XP)

 

or

 

CheckStatLT(Myself,10,LEVEL)

 

Note however, that LEVEL, LEVEL2 and LEVEL3 are different values and are used for multi and dual-classed characters, so using XP might be your best bet.

Link to comment

Apologies, jastey. I should have stated they didn't exist in BG1.

 

Thanks, aVENGER_(RR). I'll try the XP check, once I get rid of this CTD.

 

Here's the .tp2 code:

COPY_EXISTING ~khalid.cre~ ~override/cdb04060.g3~

 

COPY_EXISTING ~khalid.cre~ ~override~

~khalid2.cre~ ~override~

~khalid4.cre~ ~override~

~khalid6.cre~ ~override~

PATCH_IF (%SOURCE_SIZE% > 724) BEGIN //ensure file is at least header size

WRITE_LONG 0x10 0 // remove all class flags, CTD with or without this line

WRITE_BYTE 0x70 2 // raise longbow prof

WRITE_BYTE 0x74 0 // remove axe prof

WRITE_BYTE 0x236 0 // remove 3rd class level

WRITE_BYTE 0x23a 15 // increase intelligence

WRITE_BYTE 0x273 7 // change class to fighter/mage

REMOVE_CRE_ITEM ~CHAN04~

REMOVE_CRE_ITEM ~SHLD03~

REMOVE_CRE_ITEM ~BOW03~

REPLACE_CRE_ITEM ~SW1H01~ #0 #0 #0 ~IDENTIFIED~ ~WEAPON1~

REPLACE_CRE_ITEM ~BOW03~ #0 #0 #0 ~IDENTIFIED~ ~INV2~ EQUIP TWOHANDED

REPLACE_CRE_ITEM ~AROW01~ #40 #0 #0 ~IDENTIFIED~ ~QUIVER1~

READ_LONG 0x2a8 memoff

READ_LONG 0x2ac memnum

FOR (x=0;x<%memnum%;x+=1) BEGIN

READ_SHORT (%memoff% + (0x10 * %x%) + 0x0) level

READ_SHORT (%memoff% + (0x10 * %x%) + 0x6) type

PATCH_IF ((%level% = 0) AND (%type% = 1)) BEGIN //add info to have a mem spell slot available

WRITE_SHORT (%memoff% + (0x10 * %x%) + 0x2) 1

WRITE_SHORT (%memoff% + (0x10 * %x%) + 0x4) 1

END

PATCH_IF (%x% = 16) BEGIN

DELETE_BYTES (%memoff% + (0x10 * %x%)) 0x10 //removes innate mem info slot

WRITE_LONG 0x2ac (%memnum% - 1) //legalize mem info number

SET x = %memnum%

END

END

READ_LONG 0x2b0 memspellsoff

PATCH_IF (%memspellsoff% >= %memoff%) BEGIN

WRITE_LONG 0x2b0 (%memspellsoff% - 0x10)

END

READ_LONG 0x2b8 itemslots

PATCH_IF (%itemslots% >= %memoff%) BEGIN

WRITE_LONG 0x2b8 (%itemslots% - 0x10)

END

READ_LONG 0x2bc itemoff

PATCH_IF (%itemoff% >= %memoff%) BEGIN

WRITE_LONG 0x2bc (%itemoff% - 0x10)

END

READ_LONG 0x2c4 fxoff

PATCH_IF (%fxoff% >= %memoff%) BEGIN

WRITE_LONG 0x2c4 (%fxoff% - 0x10)

END

END

BUT_ONLY_IF_IT_CHANGES

 

//add in spells and items

// COPY_EXISTING ~khalid.cre~ ~override~

// PATCH_IF (~%DEST_RES%~ STRING_EQUAL ~khalid~) THEN BEGIN

COPY_EXISTING ~khalid.cre~ ~override~

WRITE_LONG 0x18 4888 // raise XP

WRITE_SHORT 0x24 8 // current hp

WRITE_SHORT 0x26 8 // max hp

WRITE_BYTE 0x52 19 // lower thac0

WRITE_BYTE 0x66 3 // lower lore

WRITE_BYTE 0x234 2 // 1st class level

WRITE_BYTE 0x235 1 // 2nd class level

ADD_KNOWN_SPELL ~SPWI114~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI116~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI108~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI112~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI119~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI110~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI102~ #0 ~wizard~

ADD_MEMORIZED_SPELL ~SPWI102~ #0 ~wizard~ (1)

// END ELSE PATCH_IF (~%DEST_RES%~ STRING_EQUAL ~khalid2~) THEN BEGIN

COPY_EXISTING ~khalid2.cre~ ~override~

WRITE_LONG 0x18 9944 // raise XP

WRITE_SHORT 0x24 12 // current hp

WRITE_SHORT 0x26 12 // max hp

WRITE_BYTE 0x52 18 // lower thac0

WRITE_BYTE 0x54 13 // improve save (khalid2)

WRITE_BYTE 0x66 6 // lower lore

WRITE_BYTE 0x72 1 // raise blunt prof (khalid2, 4, 6)

WRITE_BYTE 0x234 3 // 1st class level

WRITE_BYTE 0x235 2 // 2nd class level

ADD_CRE_ITEM ~brac03~ #0 #0 #0 ~IDENTIFIED~ ~GLOVES~

ADD_KNOWN_SPELL ~SPWI114~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI116~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI108~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI112~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI119~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI110~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI102~ #0 ~wizard~

ADD_MEMORIZED_SPELL ~SPWI102~ #0 ~wizard~ (1)

ADD_MEMORIZED_SPELL ~SPWI112~ #0 ~wizard~ (1)

// END ELSE PATCH_IF (~%DEST_RES%~ STRING_EQUAL ~khalid4~) THEN BEGIN

COPY_EXISTING ~khalid4.cre~ ~override~

WRITE_LONG 0x18 18822 // raise XP

WRITE_SHORT 0x24 14 // current hp

WRITE_SHORT 0x26 14 // max hp

WRITE_BYTE 0x66 9 // lower lore

WRITE_BYTE 0x6e 2 // lower large sword prof (khalid4, 6)

WRITE_BYTE 0x72 1 // raise blunt prof (khalid2, 4, 6)

WRITE_BYTE 0x234 4 // 1st class level

WRITE_BYTE 0x235 3 // 2nd class level

ADD_CRE_ITEM ~brac03~ #0 #0 #0 ~IDENTIFIED~ ~GLOVES~

ADD_CRE_ITEM ~clck14~ #0 #0 #0 ~IDENTIFIED~ ~CLOAK~

ADD_KNOWN_SPELL ~SPWI114~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI116~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI108~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI112~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI119~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI110~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI102~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI212~ #0 ~wizard~

ADD_MEMORIZED_SPELL ~SPWI102~ #0 ~wizard~ (1)

ADD_MEMORIZED_SPELL ~SPWI112~ #0 ~wizard~ (1)

ADD_MEMORIZED_SPELL ~SPWI212~ #1 ~wizard~ (1)

// END ELSE PATCH_IF (~%DEST_RES%~ STRING_EQUAL ~khalid6~) THEN BEGIN

COPY_EXISTING ~khalid6.cre~ ~override~

WRITE_LONG 0x18 43588 // raise XP

WRITE_SHORT 0x24 20 // current hp

WRITE_SHORT 0x26 20 // max hp

WRITE_BYTE 0x52 16 // lower thac0

WRITE_BYTE 0x66 15 // lower lore

WRITE_BYTE 0x6e 2 // lower large sword prof (khalid4, 6)

WRITE_BYTE 0x72 1 // raise blunt prof (khalid2, 4, 6)

WRITE_BYTE 0x234 5 // 1st class level

WRITE_BYTE 0x235 5 // 2nd class level

ADD_CRE_ITEM ~ring06~ #0 #0 #0 ~IDENTIFIED~ ~LRING~

ADD_CRE_ITEM ~brac03~ #0 #0 #0 ~IDENTIFIED~ ~GLOVES~

ADD_CRE_ITEM ~clck14~ #0 #0 #0 ~IDENTIFIED~ ~CLOAK~

ADD_KNOWN_SPELL ~SPWI114~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI116~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI108~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI112~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI119~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI110~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI102~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI212~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI213~ #0 ~wizard~

ADD_KNOWN_SPELL ~SPWI303~ #0 ~wizard~

ADD_MEMORIZED_SPELL ~SPWI102~ #0 ~wizard~ (1)

ADD_MEMORIZED_SPELL ~SPWI112~ #0 ~wizard~ (3)

ADD_MEMORIZED_SPELL ~SPWI212~ #1 ~wizard~ (1)

ADD_MEMORIZED_SPELL ~SPWI213~ #1 ~wizard~ (1)

ADD_MEMORIZED_SPELL ~SPWI303~ #2 ~wizard~ (1)

 

EXTEND_BOTTOM ~ar2301.bcs~ ~BG1Tweaks/baf/ar2301.baf~

// EXTEND_TOP ~khalid.bcs~ ~BG1Tweaks/baf/khalid.baf~

 

Now the ar2301.baf code:

IF

!InParty("khalid")

Global("AlreadyTalkedKhalid","GLOBAL",0)

Global("DestroyKhalid","GLOBAL",0)

Exists("KHALID")

!Class("KHALID",FIGHTER_MAGE)

THEN

RESPONSE #100

SetGlobal("DestroyKhalid","GLOBAL",1)

ActionOverride("KHALID",DestroySelf())

END

 

IF

// LevelLT(Player1,2)

CheckStatLT(Myself,4500,XP)

Global("KhalidLevel1","GLOBAL",0)

Global("DestroyKhalid","GLOBAL",1)

THEN

RESPONSE #100

SetGlobal("DestroyKhalid","GLOBAL",2)

SetGlobal("KhalidLevel1","GLOBAL",1)

SetGlobal("SPRITE_IS_DEADKHALID","GLOBAL",0)

CreateCreature("KHALID",[350.670],3)

END

 

IF

// LevelGT(Player1,1) LevelLT(Player1,4)

CheckStatGT(Myself,4501,XP) CheckStatLT(Myself,16000,XP)

Global("KhalidLevel2","GLOBAL",0)

Global("DestroyKhalid","GLOBAL",1)

THEN

RESPONSE #100

SetGlobal("DestroyKhalid","GLOBAL",2)

SetGlobal("KhalidLevel2","GLOBAL",1)

SetGlobal("SPRITE_IS_DEADKHALID","GLOBAL",0)

CreateCreature("KHALID2",[350.670],3)

END

 

IF

// LevelGT(Player1,3) LevelLT(Player1,6)

CheckStatGT(Myself,16001,XP) CheckStatLT(Myself,36000,XP)

Global("KhalidLevel4","GLOBAL",0)

Global("DestroyKhalid","GLOBAL",1)

THEN

RESPONSE #100

SetGlobal("DestroyKhalid","GLOBAL",2)

SetGlobal("KhalidLevel4","GLOBAL",1)

SetGlobal("SPRITE_IS_DEADKHALID","GLOBAL",0)

CreateCreature("KHALID4",[350.670],3)

END

 

IF

// LevelGT(Player1,5)

CheckStatGT(Myself,36001,XP)

Global("KhalidLevel6","GLOBAL",0)

Global("DestroyKhalid","GLOBAL",1)

THEN

RESPONSE #100

SetGlobal("DestroyKhalid","GLOBAL",2)

SetGlobal("KhalidLevel6","GLOBAL",1)

SetGlobal("SPRITE_IS_DEADKHALID","GLOBAL",0)

CreateCreature("KHALID6",[350.670],3)

END

 

Finally, the Khalid.baf code ([CombatCounter] also not in the TRIGGER.IDS):

IF

InParty(Myself)

Global("KhalidMage","GLOBAL",0)

THEN

RESPONSE #100

SetGlobalTimer("KhalidMageTime","GLOBAL",3600)

SetGlobal("KhalidMage","GLOBAL",1)

END

 

IF

InParty(Myself) CombatCounter(0) !See([ENEMY])

GlobalTimerExpired("KhalidMageTime","GLOBAL")

Global("KhalidMage","GLOBAL",1)

THEN

RESPONSE #100

IncrementGlobal("KhalidMage","GLOBAL",1)

SetGlobalTimer("KhalidMageTimer","GLOBAL",1)

Interact(Player1)

END

 

IF

InParty(Myself)

GlobalTimerExpired("KhalidMageTimer","GLOBAL")

Global("KhalidMage","GLOBAL",2)

THEN

RESPONSE #100

IncrementGlobal("KhalidMage","GLOBAL",1)

SetGlobalTimer("KhalidMageTime","GLOBAL",3600)

END

 

I've done pretty good cobbling together what tweaks I have, but it's been mostly making minor adjustments to already existing codes. I would have though the two .baf files wouldn't be needed for this tweak, with the .cre files in their native engine.

 

A lot of help and a good dose of enlightenment would be greatly appreciated (begs) :) .

Link to comment
Now the ar2301.baf code:

IF

// LevelLT(Player1,2)

CheckStatLT(Myself,4500,XP)

 

You should replace "Myself" with "Player1" for the level checks in ar2301.baf if your intent was to scale Khalid's level to the XP of the protagonist. For example, you should change this:

 

CheckStatLT(Myself,4500,XP)

 

into this:

 

CheckStatLT(Player1,4500,XP)

 

etc.

Link to comment
WRITE_LONG 0x10 0 // remove all class flags, CTD with or without this line
I'm not really sure what should be there, (BG2tweak version had this entry zeroed out) but IESDP states:
The way a multiclass char is indicated is by the absence of any of the "original class" flags being set.
Perhaps you'll have better luck at figuring that one out...
REMOVE_CRE_ITEM ~CHAN04~

REMOVE_CRE_ITEM ~SHLD03~

REMOVE_CRE_ITEM ~BOW03~

Sorry, I hadn't stayed up to date with weidu myself. I just learned about this feature. BTW, why do you remove the bow03 item when it doesn't exist and you add it back in?
PATCH_IF ((%level% = 0) AND (%type% = 1)) BEGIN //add info to have a mem spell slot available

WRITE_SHORT (%memoff% + (0x10 * %x%) + 0x2) 1

WRITE_SHORT (%memoff% + (0x10 * %x%) + 0x4) 1

END

This not needed if you use ADD_MEMORIZED_SPELL. If you only use ADD_KNOWN_SPELL then you'll need to use it to set the desired available spell slots per level version of the cre file.
PATCH_IF (%x% = 16) BEGIN

DELETE_BYTES (%memoff% + (0x10 * %x%)) 0x10 //removes innate mem info slot

WRITE_LONG 0x2ac (%memnum% - 1) //legalize mem info number

SET x = %memnum%

END

Not really sure if this was needed, I just coded it because the bg2tweaks version of khalid did not have a slot for innate spells.

 

You can put all four files within one copy and save some duplicate typing by using the following:

//note I use source-file for khalid.cre rather than source-res because source-res could grab the other khalid files by mistake.

PATCH_IF (~%SOURCE_FILE%~ STRING_EQUAL_CASE ~khalid.cre~) BEGIN

put level 1 only changes here

END

PATCH_IF (~%SOURCE_RES%~ STRING_EQUAL_CASE ~khalid2~) BEGIN

put level 2 only changes here

END

PATCH_IF (~%SOURCE_RES%~ STRING_EQUAL_CASE ~khalid4~) BEGIN

put level 4 only changes here

END

PATCH_IF (~%SOURCE_RES%~ STRING_EQUAL_CASE ~khalid6~) BEGIN

put level 6 only changes here

END

Hope it helps. If I've got something wrong, I hope someone who knows better than me will speak up and get things corrected cause I don't want to steer anyone down the wrong way.....
Link to comment
Hope it helps. If I've got something wrong, I hope someone who knows better than me will speak up and get things corrected cause I don't want to steer anyone down the wrong way.....

 

So do I. I'm a noob, you've at least graduated to novice :) . Maybe Cam or one of the other Masters will drop by and enlighten us both...

 

Thanks for the reply. I REMOVED what I did for two reasons. The armor and shield work against the mage class and are replaced by bracers, and the bow was in the wrong place to do REPLACE for all versions of Khalid. I removed the old and replaced it with the new where I wanted it, and avoided a duplication in his inventory.

 

I'll mess around with your other ideas and see if anything works.

 

I'd still like to know if this should work without any other files, such as .baf's or .tpa's.

 

Edit: Tried removing the two PATCH_IFs you noted regarding spells. The first has no effect the way I have it. The second must remain or the inventory really gets strange...

 

The PATCH_IF for SOURCE_FILE gave me an error the way you have it stated. COPY_EXISTING works fine.

 

The only item I now note is that in NI I see double entries for khalid4 (one known spell) and khalid6 (two known spells).

 

I still have no idea why I CTD entering FAI. I can only guess it's the modified khalid cre's...

Link to comment
I'd still like to know if this should work without any other files, such as .baf's or .tpa's.
The baf files can be inlined in the tp2 by using
<<<<<<<< filename
//baf text goes here
>>>>>>>>

You can then use the file in any of the typical script related commands so long as the command comes after the inlined file. That much I know I can help you out with....

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...