Jump to content

CRE modding questions


Miloch

Recommended Posts

I have some rather elementary questions now I'm getting into CRE modding. I've searched around quite a bit (including the IESDP) but can't find a decent resource or answer for these.

 

What's the difference between the ALIGN and ALIGNMEN.IDS tables. In BG1 they appear identical except for some reason the chaotic alignments were moved from 0x31 in ALIGNMEN to 0x41 in ALIGN. Which of these is used to determine alignment?

 

I have a vague idea of what morale, morale recovery and morale break are but what do the numbers assigned here mean in game terms?

 

What significance does race have? For example, I'm modding a CRE that appears to be a demon but is assigned 0x1 human for race. Shouldn't it be 0x79 demonic or something? (I know a lot of races are assigned incorrectly in the vanilla games - just wondering what it does.)

 

What's the significance of and difference between script values (override, class, race, general, default, death variable)? Are some used in certain circumstances vs. others?

 

Some of the CREs I'm looking at have levels of 1, when they should probably be higher. Is this significant only for PC/NPC classes?

 

Finally does anyone know of a decent resource (preferably online and searchable) for determining things like XP value, HP, THAC0 etc. for standard CREs. I actually have the original Monster Manual, but it doesn't list XP values for some reason, and I don't really feel like paging through this rotting tome everytime I need to look up something basic.

 

Guess that's it for now. :p Cheers.

Link to comment

I can't answer most of your questions. In fact, I'm curious about the answers myself.

 

I can answer little bits of them.

 

Race is used for things that affect or are usable by certain races. Thus, a CRE who looks like a demon and uses a demon animation might be listed as a human because that way, spells that affect humans affect him and he can use items usable by humans. If my NPC had an item that did quadruple damage against wolves, for example, if a wolf was incorrectly flagged as a human, the item would not do quadruple damage against it.

 

You will probably find rough guestimates of THACO in a 2E Players Handbook and experience values in a 2E Dungeon Master's Guide. There are better ways, but if you have the books handy, that's a cheap and dirty way to find stuff.

Link to comment

That makes sense about races. In that case, the demon CRE's race should be demonic otherwise cavaliers wouldn't get their bonuses against it.

 

I also found this to use as a searchable reference for XP values etc.

 

I have another question about how to set CRE proficiencies. The IESDP lists the BG1-style proficiencies start at 0x6e. But it also indicates these are unused in BG2 and doesn't indicate where you'd set the BG2-style proficiencies (unless I'm missing something). Any ideas?

 

Also it indicates 0x18 (Current XP) is the Creature Power Level (for summoning spells) / XP of the creature (for party members). Can someone clarify this? This field seems to be blank in a lot of cases - does it only apply to summoning spells? And if so, what exactly does the value in this field mean?

Link to comment
What's the difference between the ALIGN and ALIGNMEN.IDS tables. In BG1 they appear identical except for some reason the chaotic alignments were moved from 0x31 in ALIGNMEN to 0x41 in ALIGN. Which of these is used to determine alignment?
Baldur's Gate II is the only (?) IE game that uses ALIGN. The rest use ALIGNMEN; ALIGN is broken in Baldur's Gate.

 

I have a vague idea of what morale, morale recovery and morale break are but what do the numbers assigned here mean in game terms?
Morale is the current morale level of a creature. Morale recovery is the time it takes to recover from morale failure (specified in some unit of time, as either time taken to recover 1 morale point or to fully reset morale to 10; I can't remember). Morale break is the cutoff value at which morale failure occurs (the creature panics if morale <= breakpoint).

 

Morale influence is hard-coded; some actions, like the death of allies and the strength of enemies, apparently alter a creature's morale level. There are a few spells which temporarily increase the morale break (which causes the target to instantly panic).

 

What significance does race have? For example, I'm modding a CRE that appears to be a demon but is assigned 0x1 human for race. Shouldn't it be 0x79 demonic or something? (I know a lot of races are assigned incorrectly in the vanilla games - just wondering what it does.)
It's mostly only important for abilities or traits that give a bonus against certain races. Some of the effects allow various bonuses or penalties when fighting creatures of a certain race, and the ranger's racial enemy works against creatures specified as the same race.

 

Race can be retrieved via scripting with the Race() trigger and when specifying object specs (e.g., something like [0.0.DEMONIC]).

 

What's the significance of and difference between script values (override, class, race, general, default, death variable)? Are some used in certain circumstances vs. others?
Scripts are evaluated in preferential order. The game will completely evaluate one script (starting with the override); if any block in that script is true, the game executes the action list and starts reevaluating all the scripts; if no blocks are true, the game moves on to the next script "level." You can check the SCRLEV.IDS file for the exact precedence.

 

A creature's script name (death variable) is the name used to refer to it in scripts and dialogues. An action like CreateCreature() calls for a resource reference (so you'd use the actual base filename), but calls like ActionOverride() or Dead() use a creature's script name.

 

Some of the CREs I'm looking at have levels of 1, when they should probably be higher. Is this significant only for PC/NPC classes?
Level is only important for player classes. You might get an edge case where someone is scripting level checks or something that might not work as intended without a reasonably accurate level, but the engine doesn't care about it. A Level 1 KOBOLD_XVART should be the same as a Level 12 KOBOLD_XVART.

 

Finally does anyone know of a decent resource (preferably online and searchable) for determining things like XP value, HP, THAC0 etc. for standard CREs. I actually have the original Monster Manual, but it doesn't list XP values for some reason, and I don't really feel like paging through this rotting tome everytime I need to look up something basic.
You should stick to just making it up. Try to find something reasonable or an already-existing creature that you can copy and modify. I don't think official resources would translate very well, so you're probably better off just copying stuff that already works.
Link to comment
Baldur's Gate II is the only (?) IE game that uses ALIGN. The rest use ALIGNMEN; ALIGN is broken in Baldur's Gate.
Ok - so I have a mod that's triple-platform for BG1, BGT and Tutu (the latter two using BG2 engine stuff I'm assuming). And I have a CRE in the mod that's chaotic evil. Would it then make sense to set the CRE's alignment to 0x43 except for BG1 in which case it should be 0x33? (Does it really matter?)
Morale is the current morale level of a creature. Morale recovery is the time it takes to recover from morale failure (specified in some unit of time, as either time taken to recover 1 morale point or to fully reset morale to 10; I can't remember). Morale break is the cutoff value at which morale failure occurs (the creature panics if morale <= breakpoint).
Ok, maybe an example here would help too. This same CRE has a morale of 20, a morale recovery of 45 and a morale break of 5. So... the CRE's morale would have to be reduced somehow from 20 to 5 for it to panic? And when it does, it takes 45 x's to recover... but what does x equal - seconds (that seems rather long)? Does a morale recovery of zero (or a morale break of zero) mean for all effective purposes, the CRE cannot panic? Are there dice involved with any of this (if so, which type) or is that irrelevant?
Baldur's Gate II proficiencies are attached effects. You need to add an EFF v2 structure to the creature definition to add a proficiency.
(Copied this from the other thread so as not to clutter up the BG2 Fixpack forum.) Could someone give me a rough example of TP2 code that would patch a CRE with an EFF like this? Ideally, I'd like to query for an existing proficiency value and if it's less than what I want to set it to (or doesn't exist), set it. (For example, see what a CRE's long sword proficiency is - if 1 or 0 set to 2). For Tutu (and perhaps BGT) this would be complicated by the existence of the BG2 Tweaks component whether using oldstyle BG1 or BG2 proficiencies. (But since Tweaks is usually installed last or late, I guess the component should convert the BG2 proficiencies to BG1 accordingly.)

 

Also, dunno if you saw this one:

[The IESDP] indicates 0x18 (Current XP) is the Creature Power Level (for summoning spells) / XP of the creature (for party members). Can someone clarify this? This field seems to be blank in a lot of cases - does it only apply to summoning spells? And if so, what exactly does the value in this field mean?
Thanks for all the info - it's very helpful. :p
Link to comment
Ok - so I have a mod that's triple-platform for BG1, BGT and Tutu (the latter two using BG2 engine stuff I'm assuming). And I have a CRE in the mod that's chaotic evil. Would it then make sense to set the CRE's alignment to 0x43 except for BG1 in which case it should be 0x33? (Does it really matter?)
ALIGN is broken in Baldur's Gate. If you look, you should notice that its ALIGNMEN matches both in Baldur's Gate II. In any case, alignment is constant across all IE titles. You'll always want 0x33.

 

Conveniently, lawful is 0x10, lcneutral is 0x20, and chaotic is 0x30, with good as 0x1 and geneutral as 0x2 and evil as 0x3. If you want a chaotic evil creature, just WRITE_BYTE 0x275 0x33 (or 0x22 for true neutral or 0x21 for neutral good, etc.).

 

Ok, maybe an example here would help too. This same CRE has a morale of 20, a morale recovery of 45 and a morale break of 5. So... the CRE's morale would have to be reduced somehow from 20 to 5 for it to panic? And when it does, it takes 45 x's to recover... but what does x equal - seconds (that seems rather long)? Does a morale recovery of zero (or a morale break of zero) mean for all effective purposes, the CRE cannot panic? Are there dice involved with any of this (if so, which type) or is that irrelevant?
The creature would suffer morale failure if it's morale dropped to 5 or less, yes. The time is most likely the AI update rate (1/15th of a second by default), so it probably regains 1 point of morale every 3 seconds.

 

A morale break of 0, for all intents and purposes, is immunity to morale failure. Morale is an unsigned value, so it can never be lower than 0. Creatures like demons or other fearless beasties will usually have a 0 or 1 here and 0 or 1 (or some suitably low value) for the recovery rate.

 

[The IESDP] indicates 0x18 (Current XP) is the Creature Power Level (for summoning spells) / XP of the creature (for party members). Can someone clarify this? This field seems to be blank in a lot of cases - does it only apply to summoning spells? And if so, what exactly does the value in this field mean?
This is how much experience a creature has. It's largely irrelevant for NPCs, but the one of the summoning effects uses this value when determining how many creatures to bring in. You can search through the ToB effects or another thread of mine around the same time in the IESDP archives board to see how the summoning seems to be handled.
Link to comment

While there isn't much in the way of level based scripting checks and less in the way of level restricted items, there are some spell effects that do icky things to creatures below a certain level (Death Spell, Command) and level decides "caster level" for some spells, so it's not entirely meaningless.

 

Adding to the BG1 spears proficiency (one byte at 0x71 in the creature file) would only affect a creature's ability with weapons that are set up to use BG1 spear proficiency (i.e., they have 0x03 for the byte at 0x31 in the item file). As there are no such weapons in BG2, it's useless clutter.

 

It's annoying to mess with proficiencies en mass, so if you needed to you'd probably want something like

COPY_EXISTING ~creature~ ~override~
 SET "weapon_type"	   = 90
 SET "proficiency_stars" = 2
 LAUNCH_PATCH_MACRO ~add_cre_prof~
BUT_ONLY_IF_IT_CHANGES

 

with something like the below between ALWAYS ... END in the .tp2 header.

DEFINE_PATCH_MACRO ~add_cre_prof~ BEGIN
 PATCH_IF (%SOURCE_SIZE% > 0x02d3) THEN BEGIN
READ_LONG 0x02a0  "known_spells_offset"
READ_LONG 0x02a4  "known_spells_count"
READ_LONG 0x02a8  "spell_memorization_info_offset"
READ_LONG 0x02ac  "spell_memorization_info_entries_count"
READ_LONG 0x02b0  "memorized_spells_offset"
READ_LONG 0x02b4  "memorized_spells_count"
READ_LONG 0x02b8  "offset_to_item_slots"
READ_LONG 0x02bc  "offset_to_items"
READ_LONG 0x02c0  "count_of_items"
READ_LONG 0x02c4  "offset_to_effects"
READ_LONG 0x02c8  "count_of_effects"
SET "existing_weapon_type" = 0xff
FOR ("i" = 0x00; "i" < ("count_of_effects" * 0x108); "i" = ("i" + 0x108)) BEGIN
  READ_LONG		("offset_to_effects" + "i" + 0x08) "existing_opcode"
  PATCH_IF ("opcode" = 233) THEN BEGIN
	READ_LONG	  ("offset_to_effects" + "i" + 0x18) "existing_weapon_type"
	PATCH_IF ("existing_weapon_type" = "weapon_type") THEN BEGIN
	  READ_LONG	("offset_to_effects" + "i" + 0x14) "existing_proficiency_stars"
	  PATCH_IF (NOT "existing_proficiency_stars" > "proficiency_stars") THEN BEGIN
		WRITE_LONG ("offset_to_effects" + "i" + 0x14) "proficiency_stars"
	  END
	  SET "i" =  ("count_of_effects" * 0x108)
	END
  END
END
PATCH_IF ("existing_weapon_type" != "weapon_type") THEN BEGIN
  INSERT_BYTES ("offset_to_effects" + "i" + 0x00) 0x108 // embedded eff size
  WRITE_LONG   ("offset_to_effects" + "i" + 0x08) 233   // opcode
  WRITE_LONG   ("offset_to_effects" + "i" + 0x14) "proficiency_stars"
  WRITE_LONG   ("offset_to_effects" + "i" + 0x18) "weapon_type"
  WRITE_LONG   ("offset_to_effects" + "i" + 0x1c) 9	 // timing mode: permanent after death
  WRITE_SHORT  ("offset_to_effects" + "i" + 0x24) 100   // minimum probability
  WRITE_LONG   ("offset_to_effects" + "i" + 0xc4) 1	 // secondary type
  SET "count_of_effects" = ("count_of_effects" + 0x01)
  WRITE_LONG   0x02c8  "count_of_effects"
  PATCH_IF ((NOT "known_spells_offset" < "offset_to_effects") AND ("known_spells_count" > 0x00)) THEN BEGIN
	SET "known_spells_offset" = ("known_spells_offset" + 0x0108)
	WRITE_LONG 0x02a0  "known_spells_offset"
  END
  PATCH_IF ((NOT "spell_memorization_info_offset" < "offset_to_effects") AND ("spell_memorization_info_entries_count" > 0x00)) THEN BEGIN
	SET "spell_memorization_info_offset" = ("spell_memorization_info_offset" + 0x0108)
	WRITE_LONG 0x02a8  "spell_memorization_info_offset"
  END
  PATCH_IF ((NOT "memorized_spells_offset" < "offset_to_effects") AND ("memorized_spells_count" > 0x00)) THEN BEGIN
	SET "memorized_spells_offset" = ("memorized_spells_offset" + 0x0108)
	WRITE_LONG 0x02b0  "memorized_spells_offset"
  END
  PATCH_IF  (NOT "offset_to_item_slots" < "offset_to_effects") THEN BEGIN
	SET "offset_to_item_slots" = ("offset_to_item_slots" + 0x0108)
	WRITE_LONG 0x02b8  "offset_to_item_slots"
  END
  PATCH_IF ((NOT "offset_to_items" < "offset_to_effects") AND ("count_of_items" > 0x00)) THEN BEGIN
	SET "offset_to_items" = ("offset_to_items" + 0x0108)
	WRITE_LONG 0x02bc  "offset_to_items"
  END
END
 END
END

 

Nota bene: I spent maybe ten minutes throwing that together, so it probably doesn't work as written, but you get the general idea :p

Link to comment
While there isn't much in the way of level based scripting checks and less in the way of level restricted items, there are some spell effects that do icky things to creatures below a certain level (Death Spell, Command) and level decides "caster level" for some spells, so it's not entirely meaningless.
True. You caught me sleeping. :)

 

Adding to the BG1 spears proficiency (one byte at 0x71 in the creature file) would only affect a creature's ability with weapons that are set up to use BG1 spear proficiency (i.e., they have 0x03 for the byte at 0x31 in the item file). As there are no such weapons in BG2, it's useless clutter.
Actually, the proficiency here will grant bonuses to all weapons with the spear category (and maybe halberds, if they were lumped with spears in BG). The proficiencies aren't affected by and have no effect on the BG2 proficiency values in the item definitions.
Link to comment
ALIGN is broken in Baldur's Gate. If you look, you should notice that its ALIGNMEN matches both in Baldur's Gate II. In any case, alignment is constant across all IE titles. You'll always want 0x33.
Yes... that seems to be true (getting confused by all this multiple platform stuff).
Nota bene: I spent maybe ten minutes throwing that together, so it probably doesn't work as written, but you get the general idea :p
Wow... that's some fast coding! Thought someone could perhaps just copy an example from an existing mod (though I didn't think it'd take that much code, but then, it doesn't surprise me). Thanks for that, I'm sure it'll prove handy. :p
While there isn't much in the way of level based scripting checks and less in the way of level restricted items, there are some spell effects that do icky things to creatures below a certain level (Death Spell, Command) and level decides "caster level" for some spells, so it's not entirely meaningless.
True. You caught me sleeping. :)
So the short story is it makes more sense to have a L20 demon lord than a L1, yeah? ;)
Adding to the BG1 spears proficiency (one byte at 0x71 in the creature file) would only affect a creature's ability with weapons that are set up to use BG1 spear proficiency (i.e., they have 0x03 for the byte at 0x31 in the item file). As there are no such weapons in BG2, it's useless clutter.
Actually, the proficiency here will grant bonuses to all weapons with the spear category (and maybe halberds, if they were lumped with spears in BG). The proficiencies aren't affected by and have no effect on the BG2 proficiency values in the item definitions.
I guess I'm still confused on this one (and it's compounded by the fact I'm working on platforms that can be using either the BG1-style *or* the BG2 proficiencies). So if I gave a CRE the BG1 Spear proficiency, that carries over to BG2 Halberds (assuming it was grouped, as you said)? Disregarding the ITM side of things for the moment - on the CRE side, does it make sense to assign *both* the BG1 and BG2 style profs (e.g. large sword and long sword) to be on the safe side?
Link to comment
So the short story is it makes more sense to have a L20 demon lord than a L1, yeah?
You want a creature's level to make sense; as I stated, the engine doesn't even bother with this value, but as Nythrun points out, there are level checks in some spell and item effects that could do weird things (like snuffing out your Level 20 demon lord!) if the NPC's level wasn't appropriate.

 

I'm sure there's some magic formula for deducing the optimal level from a creature's hit points or hit dice or some other D&D nonsense.

 

I guess I'm still confused on this one (and it's compounded by the fact I'm working on platforms that can be using either the BG1-style *or* the BG2 proficiencies). So if I gave a CRE the BG1 Spear proficiency, that carries over to BG2 Halberds (assuming it was grouped, as you said)? Disregarding the ITM side of things for the moment - on the CRE side, does it make sense to assign *both* the BG1 and BG2 style profs (e.g. large sword and long sword) to be on the safe side?
It doesn't make sense to assign both, but I don't think they stack, so it shouldn't make a difference.

 

Baldur's Gate proficiencies were applied according to the weapon's category. Points in spears would give a bonus to all weapons using the spears category. If in Baldur's Gate, the spears proficiency was also used as the halberds proficiency (i.e., you stick points in spears to become proficient with halberds), then it would also apply to items with the halberds category (I just can't remember if halberds were lumped with spears for the BG1 profs).

 

If it's Tutu or BG2, you should probably stick with new-style proficiencies. If you need to do a lot of NPCs and they test fine using old-style proficiencies, then I wouldn't bother converting them or really worrying about it (and you won't need LAUNCH_PATCH_MACRO to WRITE_BYTE 0x6e 0x3 :D ).

Link to comment
I'm sure there's some magic formula for deducing the optimal level from a creature's hit points or hit dice or some other D&D nonsense.

 

For creatures without levels in one of the classes, it's usually levels=hit dice, but sometimes they cast spells at higher or lower levels than their actual hit dice, so that kind of messes up the level/caster level thing.

Link to comment

Another basic question, and something rather hard to determine via testing. When you add armour to a CRE via patching, does that also mod its AC automatically, or do you also have to set its effective AC? I guess the same goes for modding DEX...

Link to comment

As usual, borrowed from BG1 NPC Project tp2. It gives Ajantis his sword and shield and places them in the appropriate places. Equiping the items conveys the bonuses, so nothing else is required.

 

/* Give Ajantis his shield */
COPY_EXISTING ~_AJANTI.CRE~  ~override~
		  ~_AJANTI4.CRE~ ~override~
		  ~_AJANTI6.CRE~ ~override~
 ADD_CRE_ITEM ~_SW1H04~ #0 #0 #0 ~IDENTIFIED~ ~WEAPON1~ EQUIP
 ADD_CRE_ITEM ~X#AJSHLD~ #0 #0 #0 ~IDENTIFIED~ ~SHIELD~

Link to comment
Another basic question, and something rather hard to determine via testing. When you add armour to a CRE via patching, does that also mod its AC automatically, or do you also have to set its effective AC? I guess the same goes for modding DEX...
As berelinde says, these bonuses are automatic.

 

I think a PC's true AC will always be 10; probably the effective AC too, but I don't know if the game stores it as the current effective or just the base.

 

For NPCs, you may just want to play around with it until you find something you like. They should get the AC bonuses, but you might want something a little tougher than what the engine will automatically give you.

Link to comment

Archived

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

×
×
  • Create New...