Jump to content
Grozzle

[Fixed in v2] XP-matching script update

Recommended Posts

Hi there. I'm thinking of doing an updated version of the closer XP when joining script as an introduction to IE.

I'm only up to a bit of spreadsheet and looking at the limitations of IE scripts, and figured I'd best check if someone has already looked at it in preparation for a 1.10.

Edited by Grozzle

Share this post


Link to post

Hmmm, working out what level/class a dual class character was initially seems surprisingly difficult, especially while the first class is inactive. Silly pseudo-multiclass nonsense :|

 

EDIT: Anyway, I had a few hours this evening and 6000 lines of kludgey IF statements later... I think I have it going.

 

So far it's been a test AI script (with optional hotkey) and I've just rolled it back into a file for L1NPC and am going to do a fresh install of BGT for testing. Even if it's not suitable for the mod it should cut back on my CLUAConsole-ing.

 

I went about it this way:

Stage 1: Wipe the NPC XP down to zero(ish) with four XP slashes. This should cut XP to about 1% of the previous total (on average).

Stage 2: Add a chunk of XP based on the PC XP (on average about 2.5% less than the PC XP - but it varies depending on how close the PC is to the band cutoffs).

Stage 3: Half-heartedly try to work out if the PC is Dual Classed, and (super kludgily) add on XP to the NPC as if the PC's original class was a Cleric. I mentioned kludgey, right?

Stage 4: Half-heartedly try to work out if the NPC is Dual Classed. If so subtract XP as if their original class was Thief, as long as they have enough XP to cover it (I was feeling generous.)

 

WIth regard to Dual Classing it's a long, long way from perfect, but should fix up the issue of having recruited NPCs with no XP directly after dual classing. BG2 seems a bit inconsistent about how LEVEL2 and LEVEL3 are used in single class characters, so my code might not pick up on dual classing until after gaining Level 2 in the second class...

 

I'll post back here once I've done a little more light testing.

 

Update: Seems to work fine, although I'm a little concerned it's a bloated monstrosity... That hasn't stopped me replacing a neat group of 20 statements wtih 200 to cut Stage 1 from four lines of XP cutting to one though, so more checking required on the new version.

Edited by Grozzle

Share this post


Link to post

On consideration sorting out dual class XP based on actual class shouldn't be too monstrous, at least after the original class becomes active again.

Share this post


Link to post

On consideration sorting out dual class XP based on actual class shouldn't be too monstrous, at least after the original class becomes active again.

You might think so, but there is a few things... like: Is the XP table the same one ? Let's take the worst case here, if you notice the original BG2 druids row in the xptable.2da, it is horrible to all sorts of decrees. The xp amount between the levels 16 and 23 is zero XP. As in, it dips below the original amount at level 17 onwards.

 

Not that that should remove any of the need for better system.

The temporary maintainer of the mod visits here only so often, but if you have things he could use, I am sure they'll be appreciated... and I could test your work.

Share this post


Link to post

Hmmm. I've replaced the druid XP table myself, but I don't like my chances of working out how to have weidu pull the current xp tables off the install to render the .BAF...

 

I did a major rewrite tonight, with identification of dual class (using stock XP tables, copied into spreadsheet from PlayItHardcore) and a bit of restructuring to try to reduce breaks back to the beginning of the script. After Perl wrote the .BAF it was a staggering 14000 lines (1800 odd IFs), and I was extremely surprised when it ran out of the box and more or less worked. In the restructuring I missed a couple of conditions (which treated multi classes as dualed) and was a little overzealous with Continue() - so more testing ahead.

 

I'll have to revisit it sometime that isn't 2AM and see where I can Continue() and where I do need Waits, and ponder what to do if the XP cap is disabled.

Edited by Grozzle

Share this post


Link to post

Well, a bit bloated (to say the least) but I'm about done for now....

 

19200 lines, 1670 IF statements!

Support for XP up to 100 million.

Dual class support up to level 50. (Using XP tables BG2_Tweak installed when I asked it to remove the XP Cap)

 

My testing has worked fine (I've only been using humans, mainly to test out the dual class code).

The only issue I've had is with the Angelo mod - I suspect that mod either has its own XP code or that something in the combat scripting that happens when he joins the party interferes with the L1NPC XP modification object.

 

To try it out:

Back up your save games.

 

Back up your whole BG2 game folder :)

 

A zip of the scripts can be found here: [EDIT - A newer link can be found below ]

 

Contained therein is an fjxpmooc.baf that may be replaced in Level1NPCs before installation for automatic XP setting on joining.

 

For the less adventurous - included is an AI script (xpmatch.baf) triggered by hotkey S

It has additional features -

  • Grants bonus XP to the player for testing (10!) - alright it's left over debugging hints about which stage the script is in as it runs.
  • Pollutes the NPC local variables with its temporary state (10 or so L1NXP_ variables)

[ EDIT: Seriously though, the AI script is much more convenient for testing, doesn't require (re)installation of L1NPCs, and is just plain safer to try out than the automatic addition on joining.

It does exactly the same thing as the fjxpmooc.baf ]

 

There's a little more detail in the readme.txt in the zip, and many (occasionally useful) comments in the .BAF files.

 

In fact, why am I typing stuff I could copy from the Readme and comments???

 

// IE Script - Set NPCs to have closer XP to the PC

fjxpmooc.baf - Automatic version (applied on joining party)
This version is placed in the xpmod sub folder of level1npcs before running install
Weidu compiles during the installation process

xpmatch.baf - Test version for manual application
This version can be compiled to a .bs and placed in the BG2 scripts folder as an AI script.
There is an ai compile script available in the "script compiler" folder, although I've only
used weidu (I'm on Linux and don't trust .exe files ;) )
It is triggered by pressing S while having the NPC selected.
Note, this pollutes the local variables of the NPC (9 vars, I think)
Requires Party AI to be enabled, may affect performance.
Token XP is added to Player1 as this runs to indicate which step the script has reached

// Limitations -
// 1) It's not very consistent as it works on approximation bands of XP.
// Usually NPC/PC match within 2%, but can potentially mismatch by up to 5%
// 2) Dual class calculations only handle the standard dual class combinations
// 3) The script can't determine the original class of a dual classed (N)PC is until after
// the original class re-activates.
// For the PC it guesses Cleric (a middle ground)
// For the NPC we use Thief (most generous, and 2/3 of stock dualed NPCs were Thief.
// 4) It only handles XP up to 100000000 - XP beyond that is not synced (or not well)

(#4 is really a left over comment from when the max was 8 million XP...)

 

Prompted by an issue with what to do when granting XP to dual classed NPCs near the level cap today I had a major rethink of how I was doing things, and instead of changing XP in four steps it does it in two (wipe xp, add xp). It's also slightly faster than previous versions, but can still take ~10 seconds with a dual class PC and a joining dual class NPC.

 

I still can't find a way to determine the inactive dual class, so the script continues to assume Cleric until the original class is reactivated.

 

When I next have enthusiasm I'll see if Weidu pull details out of xplevel.2da and create a custom .BAF at install time. Perhaps when I finish ToB (first time player here!).

Edited by Grozzle

Share this post


Link to post

In thinking about an XP floor for Khalid and Jaheira so they can at least pretend to be the experienced protector adventurers the PC was led to believe. Multi class Jaheira takes a long time to get anywhere at the start of BG1 without her 3500 XP head start.

Perhaps give each 2000 if single class and 4000 otherwise...

Edited by Grozzle

Share this post


Link to post

In thinking about an XP floor for Khalid and Jaheira so they can at least pretend to be the experienced protector adventurers the PC is lead to believe. Multi class Jaheira takes a long time to get anywhere at the start of BG1 without her 3500 XP head start.

 

Perhaps give each 2000 if single class and 4000 otherwise...

This I second! I've considered asking for that as an component in a suitable mod. Didn't they have a bit of extra XP in vanilla BG1?

 

Share this post


Link to post

Jaheira starts with 3500 (3572?) - a little shy of ftr/druid 2/2.

Khalid starts with close to nothing, around 50 I think.

 

EDIT: 3572 for Jaheira and 42 for Khalid.

Edited by Grozzle

Share this post


Link to post

New version - which I'm going to call "1" : http://users.tpg.com.au/penfan/Level1NPCxp-v001.zip

EDIT 20140728: Old version replaced - newer WeiDU version links later in this topic.

 

Changes:

* Cleaned up code (mainly removing comments from old versions)

* Extended XP modification down to 10 XP at the low end

* Modified the XP bands used by the calculations wipe stock BG2 NPCs to zero XP on initial joining (just for neatness). Newly acquired BG2 NPCs will average about 3% XP behind the PC.

* Added a minimum XP level for Khalid and Jaheira. They will now have at least 2500 XP if single classed, and 4000 XP if multi-classed.

 

There's a clearly labeled chunk at the beginning of each BAF that enables the minimum XP for Khalid and Jaheira.

Remove the chunk (labeled ===== CUT HERE ===== ) to disable the feature.

 

I've also realised that the new method (adding XP in a single lump instead of three slices) tends to make the NPC fall behind the PC slightly when Dual Class calculations are involved (an extra rounding down to a band of XP is done). It's not as I intended, but I was always a little miffed when an NPC ended up with more XP than my main character anyway.

 

Also, I finally noticed that the AI script interrupts whatever the NPC is doing, so remember to switch back to a stock AI script before adventuring or you'll find NPCs stop performing their regular actions every two seconds.

Edited by Grozzle

Share this post


Link to post

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

BUG DOOM! :-(

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

The script treats human multi-class characters as dual classed, wiping a big chunk of NPC XP or adding a big chunk of PC XP to the NPC (depending on which are dual class). Somehow I forgot that Level1NPCs lets you do that (and it was what *I* was doing for a while before I decided I would prefer Nalia as a Conjurer dual-classed into Thief).

 

L1NPC may be able to to force human multi-class NPCs to be half-elf, or add a flag into their local variables for the script to detect. That won't help if a human PC or NPC have been Shadowkeeper-ed into a Multi-Class though.

 

I'll see what I can see in the Level1NPC code about class setting, and look for a different way to detect Dual Class humans.

 

EDIT: The L1NPC TP2 is scaring me! (Probably just because Weidu script is new to me.)

Edited by Grozzle

Share this post


Link to post

EDIT: The L1NPC TP2 is scaring me! (Probably just because Weidu script is new to me.)

 

No, it scares everyone.

Share this post


Link to post

Jaheira starts with 3500 (3572?) - a little shy of ftr/druid 2/2.

Khalid starts with close to nothing, around 50 I think.

 

EDIT: 3572 for Jaheira and 42 for Khalid.

Does Jaheira start with this with or without (this) mod? BGT? Vanilla BG1? :)

Share this post


Link to post

The 3572 comes from a BG1 FAQ (that mined the figure or of infinity explorer looking at BG1 data files).

It's the same (or very close, not sure) when I play BGT+L1NPCs.

 

EDIT: Update on human multi-class bug -

 

My understanding is that the only true indicator of dual class are bit flags in the character that are not accessible via IE script triggers. I think I have a better idea of options now which I think will be

  1. Cut out Dual Class support (or reduce it to what's accessible via IE triggers)
  2. Use ToBEX (it exposes the dual class flags and makes a lot of the bulky scripting unnecessary)
  3. Have L1NPCs enforce "multi-class characters must be non-humans" by changing human MC NPCs to half-elf

I'm not a big fan of 2 and 3 because it stops the script potentially being a drop in replacement for the original (requiring changes to L1NPC or the requirements). Option 3 also causes grief with human multiclass mod NPCs that are not modified by L1NPCs (although I don't know if there are any).

 

I'll probably end up having a go at all the options and see how well they work. I have some ideas about Option 1 using a couple of global variables to keep track of dual class history (such as storing the original class, or dual class status when they're detectable).

 

P.S. ToBEX has an option to let any race dual class! Gah! :)

Having a go at Option 1 - after a bit of thought I think it can work about as well as the original (with a couple of pros and cons). I'll also make a basic version that does much the same as the current L1NPC XP script (but more cleanly) so that if nothing comes of the other options I feel as if I haven't totally wasted the time.

 

Update 20140725

I have two new versions running

1) Basic XP matching - sets NPC XP to around the same as the PC XP, ignoring dual class. Incredibly fast replacement for functionality of current script

2) Dual class XP matching - slower and requires party AI enabled, but matches dual class XP.

When run the script will make note of the PC/NPC class for later use. If a character was single class (or inactive dual class) and later starts detecting as multi-class the script will treat them as dual class. A bit faster than the older versions as it's now storing some state across runs (for instance, it doesn't set PC dual class flags).

I've written a simple user AI script that can be used to flag a character as dual class (or set the flag back to non-dual). The AI script can also be used to flag non-standard characters as dual class and set the class that's used for the calculations.

 

When I have a bit of time this weekend I'll write up a readme and zip them up for testing by any interested parties. The Basic XP version is so simple it really doesn't need much testing (but give it a go). The Dual Class verison is now (I think) crippling bug free, but could do with user feedback.

Edited by Grozzle

Share this post


Link to post

Alrighty - Level 1 NPCs XP extended scripts v002

EDIT: Removed link to old version (removed from ISP storage). See later for lastest version.

 

I've included three versions

  1. Basic - A very fast (variable free) basic XP matcher (no dual class support)
  2. Basic+Floor - A slower basic XP matcher with a minimum set for Jaheira and Khalid's XP
  3. Dual Class - A giant script that tracks and ajdusts for dual class PC and NPCs

All have been cleaned up and include a Readme file in their folder.

 

I think the first two (Basic/Basic+Floor) are good general replacements for the existing script.

The Dual Class one is really for perfectionists who will not accept dual class XP being ignored and are willing to occasionally poke the settings (via AI script) to flag characters as dual classed if they can't be automatically identified.

 

I spoke too soon about being clear of crippling bugs, it turns out that !OR(#) doesn't work in IE script, and I had a couple of copy/paste errors that caused some trouble with detecting dual class characters with an inactive class.

On the other hand I was very pleased to realise that I could just put my test .BCS files into Override and have them take effect immediately.

 

I'll include the DC version readme here. The other versions are so simple as to not need much explanation.

 

 

Level1NPC mod mod - Dual Class experience script
=================================================================
These BG2 scripts extend the L1NPC experience scripts to support dual class PCs and NPCs.
To work around limitations in the BG2 Infinity Engine scripting language the script will make note of what class the PC and NPC have when used and use the data to later decide if it should treat the character as dual class.

NOTE: The script works via the AI script system of BG2. The script will only work if Party AI is enabled.

It is not necessary to start a new game to take advantage of the enhanced script, but any dual class party members who have already reactivated their original class will not be automatically detected as dual class by the script as it runs. They may be manually flagged as dual class using the xpconfig AI script.

=======================================
* Components
=======================================

This extension has three components:
fjxpmooc-aiscript.baf - Replacement for existing script that calls the new AI script
l1xpsync.baf - AI script for XP changes
xpconfig.baf - Player AI script for troubleshooting script issues

=======================================
* Installation
=======================================
1) Backup original fjxpmooc.bcs

If fjxpmooc.bcs exists in the BG2 Override folder back it up and then rename it.
I believe it resides there if the installation is not biffed.
If your installation is biffed it's included in a .bif and the original will not be deleted if a new version is placed in the Override folder.

2) Compile replacement scripts
Copy fjxpmooc-aiscript.baf, l1xpsync.baf and xpconfig.baf to your BG2 folder

Use weidu to compile the .baf files.
The WeiDU dialogue compiler can be downloaded from here:
http://weidu.org/main.html

The weidu compiler will create a .bcs file from the .baf script.
Eg.
weidu.exe fjxpmooc-aiscript.baf
weidu.exe l1xpsync.baf
weidu.exe xpconfig.baf
will create
fjxpmooc-aiscript.bcs (needs to be renamed as fjxpmooc.bs)
l1xpsync.bcs
xpconfig.bcs (needs to be renamed as xpconfig.bs)

3) Place the new joining scripts in the override folder, using the file name fjxpmooc.bcs and l1xpsync.bcs.
Place the player AI script in the scripts folder with the file name xpconfig.bs
eg. (on windows):

copy fjxpmooc-aiscript.bcs override\fjxpmooc.bcs
copy l1xpsync.bcs override\l1xpsync.bcs

copy xpconfig.bcs scripts\xpconfig.bs

=======================================
* Removal
=======================================

To restore the original version remove the new BCS files from the Override folder, and (if there was one) restore the original fjxpmooc.bcs

=======================================
* Manually flagging a character as Dual Class
=======================================
The xpconfig.bs player AI script can be used to troubleshoot the dual class flags used by the XP script.

D and C can be used to set the dual class status and original class flags used by the script.
S can be used to trigger the XP matching script run.

When finished using xpconfig on the character set the AI script back to the original value (to avoid accidentally using the xpconfig functions during play).

Function: Set dual classed flag
Hotkey: D
Values:
0) Not dual classed
1) Dual class (original class inactive)
2) Dual class (original class reactivated)
Note: Clearing dual class flag (0) will remove any original class history. This may be reset using the C hotkey.

Function: Set original class flag
Hotkey: C
Values:
0) Clear class history
1) Cleric
2) Druid
3) Fighter
4) Mage
5) Ranger
6) Thief

Function: Match NPC XP to PC (Synchronize)
Hotkey: S
Note: This triggers the same XP script used on joining the party. Party AI must be enabled.

=======================================
* Issues, fixes and workarounds
=======================================

Issue: Dual Class (N)PC treated as multi-class
Cause: Infinity Engine script doesn't allow direct detection of dual class status. To avoid weird results the script treats dual class characters as single class unless it was detected as single class by an earlier script run.
Workaround: Manually tag the character as dual class using the xpconfig AP script. For standard dual class characters it's only necessary to set the D flag to 1 or 2 - the appropriate values will be automatically detected on the next sych with the character.

Issue: Dual class XP does not take into account non-standard XP tables (eg. Druids using the Cleric XP table)
Workaround: Modify script lines for the approriate class with the desired values and recompile/install
Fix: Potentially read .2da files and modify script at install. (??)

Issue: Characters with non-standard dual classes are not automatically detected
Workaround: Set the appropriate Dual status and Class flags using the xpconfig AI script.

Issue: XPConfig AI script has awful +/- XP feedback
Fix: Rewrite script making use of WeiDU dialogue (with menu selection instead of hotkeys).

 

 

My next goal would be to package up the Dual Class version as a WeiDU package so that the very basic XPCONFIG script could be given dialogue menus.

This'll likely be only after I finish ToB (script writing kept a whole Beholder Den safe for a week and a half - and this is my first play though), and dependent on some indication that anyone else is using the script.

 

If anyone does try out the scripts please let me know. I'm wondering if the Dual Class script will make low end PCs catch fire!

 

EDIT: Oops, linked to old version. Fixed.

And I just remembered that I didn't convert the readme files to Windows line break format... Use Wordpad/Write to view them as it detects Unix style text files properly.

Edited by Grozzle

Share this post


Link to post
Guest
You are commenting as a guest. If you have an account, please sign in.
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.


×