Jump to content


Photo

Creating a Script/Batch file to Modify many CRE Files?


  • Please log in to reply
12 replies to this topic

#1 Masterpoobaa

Masterpoobaa
  • Member
  • 17 posts

Posted 07 December 2011 - 02:56 PM

Many Many Moons ago I made a few "mods" for BG1&2 - namely multiplying the HP and Exp rewards for all creatures.
Back then I did it by manually editing each and every .CRE file.

Now Im back and have the Big World Project installed (standard).
I wonder if anyone knows how to write a script/batch file that does the following:

Open the 1st .CRE file in a large list of them.
Make simple changes to HP/Exp/Saving throw/AC/Thaco fields - eg multiply current and max HP by 2x, ExP add 50.
Save and Override the .CRE file.
Repeat with the next .CRE file down in the directory
etcetcetc

Jarno suggested I try mixmod - this mod appears to partially do the trick, but it doesn't allow any Exp changes, and i dont need the mixmod changes to ammo/scrolls/potions etc.

Edited by Masterpoobaa, 07 December 2011 - 03:00 PM.


#2 GeN1e

GeN1e

    A very GAR character

  • Modder
  • 1604 posts

Posted 07 December 2011 - 04:32 PM

For every CRE in existance.
COPY_EXISTING_REGEXP GLOB ~.*\.cre~ override
// do read/write patches to cre's stats here
BUT_ONLY

For a custom list of CREs.
COPY_EXISTING crename1.cre override
 crename2.cre override
 crename3.cre override
// do read/write patches to cre's stats here
BUT_ONLY

For a custom list of CREs, alternative.
ACTION_FOR_EACH creature IN
 crename1
 crename2
 crename3
BEGIN
  ACTION_IF FILE_EXISTS_IN_GAME ~%creature%.cre~ BEGIN
    COPY_EXISTING ~%creature%.cre~ override
    // do read/write patches to cre's stats here
    BUT_ONLY
  END
END

Edited by GeN1e, 07 December 2011 - 04:34 PM.

Retired from modding.


#3 Zyraen

Zyraen
  • Modder
  • 1402 posts

Posted 07 December 2011 - 09:12 PM

I have such a script, you can find it by looking at the TP2 in this module
http://www.shsforums...ds&showfile=564

It suffices for a TP2 script to directly edit CREs, which generates HP, XP, Thac0, AC, etc values for otherwise identical creatures of Level 8 10 12 14 16 18 20 23 26 29 32 35 38, and also for "stronger" versions with extra HP and bonuses, as well as for some other creatures (like Balrogs), where Resistances and HP are altered. Items and AI Scripts are also altered.
Mathematical formulas are included and can easily be adapted.

Edited by Zyraen, 07 December 2011 - 09:18 PM.

kiyos.jpg____btlbn2.gif____kovaS.jpg
Love between a Law Enforcer and a Fugitive - can such a thing even happen?
SoA Release - Overview / Download Links

Zyraen's Miscellaneous Mods - Ust Natha Accelerator, item tweaks, XP caps, The Ub3r Reaver Kit, and much more...
Spellhold Gauntlet - more than just a Spellhold-Be-Gone
Hidden Kits - hidden dual-classed kits with a twist for progression


#4 Lollorian

Lollorian

    smiley addict

  • Member
  • 4150 posts

Posted 08 December 2011 - 01:03 AM

Might I recommend DEFJAM for reference? :) (aka ding0's Experience Fixer - XPMod :devil:)

Edited by Lollorian, 08 December 2011 - 01:05 AM.

"I am the smiley addict, yellow and round, this is my grin :D when I'm usually around :P.
When there's trouble brewing, see me post, cuz it's usually a wall o' yellow and your eyes are toast!!!"

BWP GUIDE - BWP FIXES - impFAQ - NPC LIST - KIT LIST - AREA LIST

GitHub Links : BWP Fixpack | Lolfixer | BWP Trimpack | RezMod


#5 Masterpoobaa

Masterpoobaa
  • Member
  • 17 posts

Posted 09 December 2011 - 04:14 AM

Might I recommend DEFJAM for reference? :) (aka ding0's Experience Fixer - XPMod :devil:)


Kewl!

Though I think I've discovered a slight flaw in my Masterful plan... I have no idea about anything and don't know what to do next :P

COPY_EXISTING_REGEXP GLOB ~.*\.cre~ override

SET hp1 = hp * 5
SET hp2 = hp * 5
SET xp1 = xp * 5
WRITE_LONG 0x14 %xp2%
WRITE_SHORT 0x24 %hp2%
WRITE_SHORT 0x26 %hp2%

BUT_ONLY

Edited by Masterpoobaa, 09 December 2011 - 01:40 PM.


#6 Masterpoobaa

Masterpoobaa
  • Member
  • 17 posts

Posted 11 December 2011 - 12:39 AM

Nope. I have no idea. Best if i move myself to the moron forum.

#7 Lollorian

Lollorian

    smiley addict

  • Member
  • 4150 posts

Posted 11 December 2011 - 01:05 AM

Try this :)

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ ~override~
  PATCH_IF (SOURCE_SIZE > 0x2d3) THEN BEGIN
    READ_LONG  0x14  "xp" ELSE 0
    READ_SHORT 0x24  "hp1" ELSE 0
    READ_SHORT 0x26  "hp2" ELSE 0
    SET hp11 = hp1 * 5
    SET hp21 = hp2 * 5
    SET xp1 = xp * 5
    WRITE_LONG  0x14 %xp1%
    WRITE_SHORT 0x24 %hp11%
    WRITE_SHORT 0x26 %hp21%
  END
BUT_ONLY_IF_IT_CHANGES

Edited by Lollorian, 11 December 2011 - 01:05 AM.

"I am the smiley addict, yellow and round, this is my grin :D when I'm usually around :P.
When there's trouble brewing, see me post, cuz it's usually a wall o' yellow and your eyes are toast!!!"

BWP GUIDE - BWP FIXES - impFAQ - NPC LIST - KIT LIST - AREA LIST

GitHub Links : BWP Fixpack | Lolfixer | BWP Trimpack | RezMod


#8 Masterpoobaa

Masterpoobaa
  • Member
  • 17 posts

Posted 12 December 2011 - 04:47 PM

WOOT.
The mod works!
For some reason it kept dying on line 3
'VERSION ~V1~'
Soon as I stripped that out it worked very nicely.
And now that the basic's are working it can be expanded to include Thaco, AC, Saves, Resistances etc.

=====================================================
BACKUP ~hpexpmod/backup~
AUTHOR ~Poohey~

BEGIN ~hp and exp mod~

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ ~override~
  PATCH_IF (SOURCE_SIZE > 0x2d3) THEN BEGIN
    READ_LONG  0x14  "xp" ELSE 0
    READ_SHORT 0x24  "hp1" ELSE 0
    READ_SHORT 0x26  "hp2" ELSE 0
    SET hp11 = hp1 * 5
    SET hp21 = hp2 * 5
    SET xp1 = xp * 5
    WRITE_LONG  0x14 %xp1%
    WRITE_SHORT 0x24 %hp11%
    WRITE_SHORT 0x26 %hp21%
  END
BUT_ONLY_IF_IT_CHANGES
======================================================

#9 Jarno Mikkola

Jarno Mikkola

    The Imp in his pink raincoat.

  • Member
  • 10911 posts

Posted 12 December 2011 - 10:54 PM

WOOT.
The mod works!
For some reason it kept dying on line 3
'VERSION ~V1~'
Soon as I stripped that out it worked very nicely.

Where did you put the line to ? As it needs to be under the AUTHOR line... not before it or after the BEGIN line... well you might also have the README - line before it.

So it becomes:
=====================================================
BACKUP ~hpexpmod/backup~
AUTHOR ~Poohey~
README ~hpexpmod/Readme.txt~
VERSION ~v1~


BEGIN ~hp and exp mod~

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ ~override~
PATCH_IF (SOURCE_SIZE > 0x2d3) THEN BEGIN
READ_LONG 0x14 "xp" ELSE 0
READ_SHORT 0x24 "hp1" ELSE 0
READ_SHORT 0x26 "hp2" ELSE 0
SET hp11 = hp1 * 5
SET hp21 = hp2 * 5
SET xp1 = xp * 5
WRITE_LONG 0x14 %xp1%
WRITE_SHORT 0x24 %hp11%
WRITE_SHORT 0x26 %hp21%
END
BUT_ONLY_IF_IT_CHANGES
======================================================

Deactivated account. The user today is known as The Imp.


#10 Masterpoobaa

Masterpoobaa
  • Member
  • 17 posts

Posted 13 December 2011 - 06:09 PM

Where did you put the line to ? As it needs to be under the AUTHOR line... not before it or after the BEGIN line... well you might also have the README - line before it.


It was as follows:
BACKUP ~hpexpmod/backup~
AUTHOR ~Poohey~
VERSION ~V1~

BEGIN ~hp and exp mod~

Anyhoo it works now and im a happy chappy.  Takes only a handful of seconds to process 7k+ files.
It was probably the missing README line that did it.

My party got slaughtered by a bunch of hobgoblins with bows - Excellent!
And a Cave Bear with 5x HP is like this slow moving Juggernaut of destruction.

I wish to thank you all for your assistance.  :)

Edited by Masterpoobaa, 13 December 2011 - 07:07 PM.


#11 Masterpoobaa

Masterpoobaa
  • Member
  • 17 posts

Posted 18 December 2011 - 08:50 PM

Did I mention I love you guys?

Have now re-installed IWD, How, Trials and as many enhancement patches as I could find, as well as my mod.  :)

I noticed that there arn't many mods for IWD, which is a bit of a shame.

Edited by Masterpoobaa, 18 December 2011 - 09:01 PM.


#12 Jarno Mikkola

Jarno Mikkola

    The Imp in his pink raincoat.

  • Member
  • 10911 posts

Posted 19 December 2011 - 01:17 AM

I noticed that there arn't many mods for IWD, which is a bit of a shame.

Well, the game is a bit hard to modify, as it lacks a good dialog support, party controls ... the plot is like a train, on a track, there's no alternatives... there's actually an NPC mod for the game, and the game is in a public beta phase of being turned into a BGII engine Total Conversion mod, it's v7 is promised to be more finish-able... as there's a few problems that need to be set with the Console, those are it's largest problems... so soon it should be done...

May I suggest that you add this feature to the mod you make...
BEGIN ~hitpoint setting component~

PRINT ~With what number do you want to multiply the enemies Hitpoints ?~
ACTION_READLN hp_int
OUTER_WHILE (!(IS_AN_INT %hp_int%) || (%hp_int% > 100) || (%hp_int% < 0)) BEGIN
  PRINT ~With what number do you want to multiply the enemies Hitpoints ?~
  ACTION_READLN hp_int
END

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ ~override~
PATCH_IF (SOURCE_SIZE > 0x2d3) THEN BEGIN
READ_SHORT 0x24 "hp1" ELSE 0
READ_SHORT 0x26 "hp2" ELSE 0
SET hp11 = ~hp1 * hp_int~
SET hp21 = ~hp2 * hp_int~
WRITE_SHORT 0x24 %hp11%
WRITE_SHORT 0x26 %hp21%
END
BUT_ONLY_IF_IT_CHANGES
And then you can do the same thing for the XP(Thaco, AC, Saves, Resistances etc.) in a different component ! The above code allows you to multiply all the enemy (and ally) Hitpoints with the factor set during the install from 1* to 99* times the original. :cheers:
It's most notable on the enemies, but the characters that do not level up when they join( in BG1&BG2) will have the multiplied HPs cause the way this is done... of course it doesn't matter in Icewind Dale. :D

Edited by Jarno Mikkola, 19 December 2011 - 01:49 AM.

Deactivated account. The user today is known as The Imp.


#13 Masterpoobaa

Masterpoobaa
  • Member
  • 17 posts

Posted 19 December 2011 - 01:37 PM

Well my quick and cheerful mod seemed to have worked for Icewind dale.  Mobs are suitably as tough as nails to take down.

EXCEPT the first 6 or so goblins you meet just over the bridge - the ones that have stolen the kids fish.
Trying to work out why they didnt get changed. (Still giving the defaul 15exp and dying in 1-2 arrow hits)
Unfortunately with the Ease of use mod installed, Nearinfinity (my favorite mod for poking around) is crashing lots with dialog.tlk errors, So its tricky to work out which goblin cre file is missing/playing up.
Hmmm.
[Edit] Nearinfinity does work when the modified .cre's are removed from the override folder. Funny
[Edit]Fixed the goblin issue. Was due to cached mobs.
Have now progressed far - but game crashes entering the Inn in kulduhar. Not getting any .err reports, just freezes and get (not responding).  I took my .CRE's out. Its not my mod *sigh*. Must be something to do with the ease of use or tweak pack thats broken the inn & temple.

Hmm well, as my build with the tweakpack is borked for some reason, Ill take you up on your offer Jarno and try the total conversion mod :)

Edited by Masterpoobaa, 20 December 2011 - 08:23 PM.