Jump to content

Photo

[Fixed in v2] XP-matching script update


32 replies to this topic

#1 Grozzle

Grozzle
  • Members
  • 23 posts
  • Gender:Male
  • Location:Australia

Posted 14 July 2014 - 07:54 PM

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, 15 July 2014 - 12:55 PM.


#2 Grozzle

Grozzle
  • Members
  • 23 posts
  • Gender:Male
  • Location:Australia

Posted 14 July 2014 - 10:49 PM

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, 16 July 2014 - 07:15 AM.


#3 Grozzle

Grozzle
  • Members
  • 23 posts
  • Gender:Male
  • Location:Australia

Posted 16 July 2014 - 03:42 PM

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.

#4 Jarno Mikkola

Jarno Mikkola

    The Imp

  • Modders
  • 6831 posts
  • Gender:Male
  • Location:The town where the dead haven't keeled over, yet. In Finland.

Posted 16 July 2014 - 04:32 PM

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.
Welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand.
Here's how to install all the ... mods you ever really could want to Infinity Engine games. I removed the stable word from there as Roxanne began to add BS mods that are likely to break compatibility from the BWS.

#5 Grozzle

Grozzle
  • Members
  • 23 posts
  • Gender:Male
  • Location:Australia

Posted 17 July 2014 - 08:32 AM

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, 17 July 2014 - 08:36 AM.


#6 Grozzle

Grozzle
  • Members
  • 23 posts
  • Gender:Male
  • Location:Australia

Posted 20 July 2014 - 04:51 AM

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, 21 July 2014 - 06:15 AM.


#7 Grozzle

Grozzle
  • Members
  • 23 posts
  • Gender:Male
  • Location:Australia

Posted 20 July 2014 - 02:49 PM

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, 21 July 2014 - 06:40 AM.


#8 Dakk

Dakk
  • Modders
  • 941 posts
  • Gender:Male

Posted 20 July 2014 - 02:51 PM

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?



#9 Grozzle

Grozzle
  • Members
  • 23 posts
  • Gender:Male
  • Location:Australia

Posted 20 July 2014 - 02:57 PM

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, 20 July 2014 - 04:32 PM.


#10 Grozzle

Grozzle
  • Members
  • 23 posts
  • Gender:Male
  • Location:Australia

Posted 21 July 2014 - 06:32 AM

New version - which I'm going to call "1" : http://users.tpg.com...1NPCxp-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, 27 July 2014 - 06:28 AM.


#11 Grozzle

Grozzle
  • Members
  • 23 posts
  • Gender:Male
  • Location:Australia

Posted 21 July 2014 - 02:08 PM

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

                                       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, 21 July 2014 - 02:34 PM.


#12 Mike1072

Mike1072
  • Gibberling Poobah
  • 2545 posts
  • Gender:Male
  • Location:Canada

Posted 21 July 2014 - 02:53 PM

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

 

No, it scares everyone.



#13 Dakk

Dakk
  • Modders
  • 941 posts
  • Gender:Male

Posted 21 July 2014 - 07:30 PM

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? :)



#14 Grozzle

Grozzle
  • Members
  • 23 posts
  • Gender:Male
  • Location:Australia

Posted 21 July 2014 - 07:37 PM

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, 24 July 2014 - 02:15 PM.


#15 Grozzle

Grozzle
  • Members
  • 23 posts
  • Gender:Male
  • Location:Australia

Posted 26 July 2014 - 07:25 AM

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.

 

Spoiler

 

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, 27 July 2014 - 06:31 AM.




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users