Jump to content

racial enemy overhaul


Recommended Posts

I'm going to start a new run on BGEE and was thinking of playing a ranger.  And then I remembered how underwhelming the "racial enemy" choices are for the class.

I have a series of ideas (and questions) below.  I have some basic modding skills, but I don't have the depth of experience that a lot of you have, so please forgive me if I ask obvious questions.  Snippets of code that I can steal are always welcome.  And, of course, if anyone has already done any or all of what I'm planning, please let me know and I'll download their mod.

My questions:

1. What is the most graceful and least harmful way to mod dialog.tlk to change all instances of "racial enemy" to "favored enemy"?  (I mean, are Giant Spiders really a race?) 

2. I was thinking of completely reorganizing racial/favored enemies along the lines of 3.5e.  So, for instance, instead of separate choices for Carrion Crawlers, Ettercaps, and Gibberlings in BGEE, there would be a more generic group, Aberrations.  Similarly, Ghouls and Skeletons could be combined under Undead.  Other categories could be introduced, for example Shapechangers (Doppelgangers and Werewolves) and Constructs (Golems, Doom Guards, Battle Horrors).  This would make choices other than Giant Spiders viable and fun.

The question is, how best to do this?  For instance, can HATERACE.2DA (such an awful name) be pointed to the "General" field in the CRE file, or must it refer to the "Race" field?  Either way, I assume that I'd have to make some additions to RACE.IDS.  What are the dangers here?  If I create a General category or Race called "Aberration" and then change the appropriate field for Ettercaps, etc., is there a down side?  Are there weapons, spells, or abilities that I need to have on my radar?  Is there anything else that I am missing?

If it works, it shouldn't be too overpowered for  BGEE.  What thoughts to people have about extending this to BG2EE?  Beholders and Mindflayers are both Aberrations; Liches and Vampires are both Undead.  Too much? 

3. I would love to build a kit around the choice of enemy, but I can't think of a way to do it.  Any ideas?  How awesome would it be to have a Crypt Ranger, Dragonslayer, or Giant Killer kit!  Even if it were simply an option to change the name of a true class Ranger, it would add flavor.

Thanks!

 

Link to comment

So, the first fundamental issue you'll run into is that the racial/favored enemy system is heavily hardcoded. You can change what races are options - that's HATERACE.2DA - but the core mechanics are out of your reach. It will always be a "race" that's the target, and any ranger will have the choice at character creation.

The first part - changing the game text to "favored enemy" - is probably the simplest. And even that is a bit tricky, because it's not just in dialog.tlk. There's also an element of L_en_US.LUA (or the equivalent for another language), specifically line 324:

Quote

    HATED_RACE_TITLE = "Racial Enemy",

For the strings that are in dialog.tlk, you can run a search in Near Infinity. I find string 15897 "RACIAL ENEMY" (unused in the EE), string 15982 "Racial Enemy" (referenced in ENGINEST.2DA, GUICG.CHU, and GUIREC.CHU), string 24317 (description for the class feature, referenced in ENGINEST.2DA), and string 17256 (unused, identical to #24317).

So that's two strings to overwrite, replacing "Racial" with "Favored" and "racial" with "favored". Best done in WeiDU with the STRING_SET action.

On race consolidation, the things to watch out for are other effects that already care about race. Like Kondar, which checks for the LYCANTHROPE and DOPPLEGANGER races. Or the Sword of Balduran, which only checks for LYCANTHROPE. Or scripting bits. Or stuff mods create that you won't be able to predict in advance. Consolidating races could unexpectedly undermine assumptions and break things; you can predict and handle some issues, but not everything. Honestly, this one's sneaky enough that I just don't know.

For a kit based around the favored enemy, I don't think you can mess with the choice at character creation, at least without serious UI modding. But what you can do is change that stat once gameplay begins. There's no opcode for it, so you have to do it with a script action (ChangeStat).

For a class name change based on the favored enemy choice? Actually, that shouldn't be too hard. Opcode 290; look up SPIN722 GREAT_DRUID_TITLE for reference. Build a spell for that, then have a script to apply it when appropriate (Player N is a ranger, not one of the recognized kits, and their favored enemy stat matches).

Link to comment
3 hours ago, moog said:

was thinking of completely reorganizing racial/favored enemies along the lines of 3.5e.  So, for instance, instead of separate choices for Carrion Crawlers, Ettercaps, and Gibberlings in BGEE, there would be a more generic group, Aberrations.  Similarly, Ghouls and Skeletons could be combined under Undead. 

This is basically what I do with my “Regional Rangers” component. Unfortunately what you have to do, basically, is zero out the normal favored enemy choices and directly apply bonuses for the kit. Which can conflict with any other mods that touch favored enemies. 

Avoiding doing that, you could give your kit extra bonuses against some group of enemies, like giants or lycanthropes… but they would also get to choose from the list, and they could choose something unrelated to or even inappropriate for your kit. 

The mechanism is quite hard-coded and anything you do kind of has to be a kludge. :(

Link to comment

Checking that referenced component ... what it does is wipe out favored enemy selection for all rangers, making the only possibility at character selection a dummy entry that doesn't provide any bonuses against actual enemies. Obviously incompatible with any ranger kits that use favored enemies, though it won't touch NPCs that already have a favored enemy selected.

The alternative would be to allow normal favored enemy selection at character creation, and then have a script wipe it out once you start playing. Detect that kit in the party, set their favored enemy to NO_RACE. Which is even more of a kludge, but at least you can use it alongside the vanilla ranger kits.

Link to comment

Thanks for your replies, they are very helpful.

How about this--instead of editing the CRE files, I do the following:

1. Edit HATERACE.2DA to add a favored enemy, e.g., Shapechanger.  Have the target be Doppelganger.

2. Run a script that assigns a new CLAB if the favored enemy is Shapechanger.  The CLAB will have a special ability that assigns the favored enemy to hit and damage bonuses to Werewolves (and to whatever other shapechangers there might be).

3. If I wanted to go the extra mile, this script and CLAB could be the seed of a kit.

This could be done in the same way for Abominations, Undead, etc.

Link to comment

It would still be super kludgy. Your character sheet would say “favored enemy: doppelgangers” and you would have a silent bonus against werewolves too? Kind of weird. And maybe hard to communicate the categories adequately to the player. 

My mod adds variants of the Trueclass ranger, and conceptually says “these Trueclass ranger variants are true rangers, and other kits are more like pseudorangers.” Archers, Stalkers, Justifiers, Forest Runners… nothing about those kits implies specialization with singular target species. And the mod expands but controls favored enemies. Because the vanilla game’s choices are kind of dumb. Why would a Mountain Ranger be able to specialize in killing snakes? Why would a Forest Ranger or Beastmaster have expertise in killing elementals? Why would anyone have expertise in killing vampires or fiends at 1st level? 

It’s hard to see that “conflicting” with other ranger kits if the player chooses that concept. I struggle to envision a kit specifically designed to lean into the vanilla game mechanic. 

BUT I could totally see wanting to overhaul the mechanic itself. And although DavidW apparently hates it, I think the best way to do this is with an in-game dialogue. Basically you would:

— Zero out HATERACE.2da just like I did, and then give all rangers the same innate ability 

— The innate ability summons an invisible creature that starts a dialogue with the ranger. The ability would remove itself with op172 and prevent itself from working twice, with op206. 

— The dialogue would present various categories to the player: mammals, spiders, giants, corporeal undead, whatever. They could overlap if you like, some could be broad and some could be narrow, whatever.

— Each category choice would cast a spell with various op178/op179 effects for bonuses against enemies in the listed category. 

— The dialogue could be tailored such that each kit could have its own list of options. Snakes could be excluded from Mountain Rangers, yetis and winter wolves could be excluded from Desert Rangers, etc.

— You could have more limitations too, like gating certain options by level - so you could choose fiends in an SoA start (maybe gained expertise by defeating Aec’Letec) but not in a BG1 start. Sky’s the limit here, it would be very flexible. 

— Give each 178/179 spell a custom portrait icon… they could be visually identical but with different strings, so you would have an indicator on the character sheet. 

— You could even have certain game events allow rangers to change their favored enemies, or even add a second category. It would make a good feat or HLA. (I would certainly tie this into my ‘Combat Skills’ feat mod.)

Install this “Favored Enemy Overhaul” mod after kit mods, and it could contain a simple 2da table of all  extant ranger kits and which favored enemy categories each kit has access to. Broad or narrow access for certain kits could be a de facto kit advantage or disadvantage. And it would be human-readable so players could change kits’ access if they wanted.

All of this is totally doable, if you can tolerate using a dialogue to choose favored enemies. (I used to prefer GUI modding but have since come back around to preferring dialogues, which are straightforward, comprehensible, and more broadly compatible.) I have code snippets in the CSP mod which could be easily adapted and could reduce the time and effort needed. 

Edited by subtledoctor
Link to comment

You know a lot more than I do about modding.  Still, I think I got this to work.  Instead of Doppelgangers and Shapechangers, I tried something with Ghouls and Undead.

First, I created a string entry "Undead."  Then I used SET_2DA_ENTRY to have the first column of Ghoul in HATERACE.2DA use this string.  I also created corresponding text for the third column.  Here's the result:

Baldr000.png.b67cfefa9d18d932ccf9075e2570ea05.png

Then I called up a Ghoul and it looks like the to-hit and damage benefits still apply.
I think that modifying a CLAB so that the ranger bonuses apply to Zombies and Skeletons (really the only other relevant Undead in BGEE) should be fairly straightforward.

I'm sure I must've missed something.  What is it?

 

 

Link to comment

Running through the files, here are some other races that appear on undead creatures in BGEE:

- SPECTRE. Ashirukuru. The Durlag's Tower ghost is also a spectre, but isn't undead.

- WOLF. Dread and vampiric wolves.

- HUMAN. Summoned skeletons.

And of course, if you include SoD, you get stuff like wraiths, liches, goblins, shadows, vampires, and even a troll.

Maybe ... don't use race when you want to target undead in general?

Link to comment

@jmerry Thanks for the heads up.  The vampiric wolves were on my radar, but I missed the Ashirukuru.  I think the dread wolf is a mistake in the game; I don't think they're undead in BG2EE.

I'm still thinking of aggregating creatures by race, but I'm seriously considering @subtledoctor's suggestions.  As you have shown, I could miss some creatures doing it my way.

While I have your attention, what's the best way to edit the relevant line of L_en_US.LUA? I've taken care of the strings in dialog.tlk.

 

 

Edited by moog
Link to comment
3 hours ago, jmerry said:

Maybe ... don't use race when you want to target undead in general?

Yeah but that’s the issue, right? The hard-coded ranger mechanic is limited to the ‘race’ field. Why I say, rip it out root and stem. 

@moog I talked myself into liking this idea, enough that I’d be happy to collaborate. I’ve got Weidu code that could be pretty easily adapted to turn a 2da table into various kit-specific dialogues; then you could do the creative work of 1) what are the categories, 2) which kit gets which categories as options, and 3) making the .SPL files to apply the bonuses. (The SPL  files are probably best created in Weidu, given there will be many similar ones that differ slightly.)

Link to comment

Dread wolves are definitely supposed to be undead. The BG2(EE) version is the one that's mistaken.

As for editing the LUA, you open it up in WeiDU and use the text-parsing capabilities. Search and replace, with special characters escaped:

REPLACE_TEXTUALLY ~HATED_RACE_TITLE = \"Racial Enemy\",~ ~HATED_RACE_TITLE = "Favored Enemy"~

If you want to do this in more languages than just English, it gets more complicated, of course. You read the "Racial Enemy" and "Favored Enemy" equivalents from a tra file, and you also switch up which file you're editing based on which language you're working in.

Link to comment

@jmerry, thanks for the line for the LUA file and for the correction on Dread Wolves.  I've been fighting them all of these years and had no idea that they were Undead!

@subtledoctor, I'll take whatever help you can offer.  Thanks!   My hope for now is for something that is very simple on the user end: just a choice of a favored enemy from a more general list.  If we could somehow make the choice via the GUI and the rest go on in the background, great.  But I'm nowhere near the coder that either of you are and I don't fully grasp the limitations of the engine.

To flesh it out a tiny bit more, I'd like to appropriate many of the categories from the 3.5 Monster Manual as candidates for favored enemies: Aberrations, Constructs, Dragons, Elementals, Fey, Giants, Magical Beasts, Shapechangers, Undead, and Vermin.  I'd like to go forward with the BGEE category of Demonic/Fell as a stand-in for Outsider (Evil).   Perhaps some clusters of Humanoids as well. 

Dragons, Demonic/Fell, and Elementals are already implemented in BGEE.  Constructs/Golems and Faerie/Fey are implementable right now with the current engine, they just need to be added to the list.  Correct me if I'm wrong, but I believe all of the Giants in BGEE are Ogres or Ogre-adjacent, while all the Vermin are Spiders, so we're good to go there too.  That leaves Aberrations, Magical Beasts, Shapechangers, and Undead, the four of which might be the most exciting to implement.

Although my focus for now is BGEE, I can imagine expanding and tweaking this for SoD and BG2EE.

 

Edited by moog
Link to comment
On 2/1/2024 at 10:20 AM, subtledoctor said:

BUT I could totally see wanting to overhaul the mechanic itself. And although DavidW apparently hates it, I think the best way to do this is with an in-game dialogue.

Properly externalizing the favored-enemy mechanic is on my to-do list for ToF... but yes, as you say I'd do it through edits to the UI rather than through dialogue. a chacun son gout.

Link to comment
35 minutes ago, DavidW said:

a chacun son gout.

I mean, UI is better. But limited time turns the oerfect into the enemy of the good. It boils down to, my personal life does not permit time me to learn Lua, and without understanding thoroughly, I wouldn’t be able to do it well and ensure compatibility with other UI tweaks/overhauls. 

Whereas, with the Weidu I already know (mostly already written!), using dialogues I could probably whip up a complete overhaul of the Favored Enemy mechanic in under two hours, and it would be compatible with everything. And also allow on-the-spot decisions for party-joinable rangers. It’s not great from a game design perspective, just better bang for my buck by an order of magnitude or more. For something you interact with for 5-10 seconds in a hundred-hour game… it’s good enough for me.

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
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.

×
×
  • Create New...